
JSNES: A Javascript NES emulator - jawngee
http://benfirshman.com/projects/jsnes/
======
daeken
Very neat, but it's a shame that interpretation is used. With the speed of
current Javascript implementations, dynamic recompilation (block-based
recompilation to JS functions, specifically) is insanely fast.

A while back, <http://6502asm.com/> popped up with a web-based 6502 (chip used
in the NES, Apple ][, and many others) emulator. I stumbled upon it and in a
matter of hours, I patched it to become the first (to my knowledge) dynarec
emulator in JS. You can see a live version here:
<http://ironbabel.googlepages.com/6502.html>

This same technology could easily be applied to JSNES for considerable
speedups.

~~~
jacquesm
Re <http://ironbabel.googlepages.com/6502.html>

Assemblers don't compile, they assemble.

Neat hack though!

~~~
jcl
Yes, but it's also correct to say that he wrote a compiler.

He is taking the assembly code you type in and translating it to machine code,
then he's translating the machine code to JavaScript source, then executing
that source directly.

Translating a program from one language to another is compilation, by
definition. While the first translation step could also be considered
assembling, the second cannot.

------
timdorr
I thought the Javascript CAPTCHA solver was insane. This takes the cake.

Next step, do like Cappuccino and "compile" the NES rom's back to native
Javascript. At that point, I think my head might explode.

~~~
zackattack
What javascript captcha solver?!

~~~
pjonesdotca
also -> <http://ejohn.org/blog/ocr-and-neural-nets-in-javascript/>

------
maxklein
Ah, Javascript in browsers. Making things PCs did in 1999 seem wondrous once
more.

~~~
DrJokepu
I'm looking forward the day someone comes up with the brilliant idea of
writing an OS in JavaScript.

~~~
btilly
That was done years ago: <http://www.masswerk.at/jsuix/>. Click on "terminal"
at the top.

~~~
jacquesm
impressive!

JavaScript is one of the few languages where you keep being surprised with
what can be done with it. For the longest time I saw it as pretty limited,
then one day somone shows me an apple II emulator in javascript.

------
nopassrecover
Awesome, but if I get deselected I can't get it to pick up keys again. In
firefox couldn't even get it to pick up keys to start with.

------
iman
Very impressive, but performance sucks, even in google chrome. Keep in mind
that the 486 is capable of fully emulating the NES. The truth is that
javascript will simply never be appropriate for tasks such as this. It is too
slow and no amount of magic fairy dust optimizations will make it come close
to high performance languages.

Java on the other hand (as much as I hate java) can do high performance stuff.
Here is a java applet NES emulator, with sound: <http://www.nescafeweb.com>

~~~
mhansen
I heard an interview with Brendan Eich from last year where he says there are
still many javascript optimizations that haven't been attacked yet, that there
is still a lot of low-hanging fruit.

He also predicted speeds bordering on C within a few years.

[EDIT] Source: <http://perseus.franklins.net/hanselminutes_0130.pdf>

~~~
wallflower
Yes, Java is a statically-typed language but remember how Java performed
before JIT compilers? It was closer to Perl than C.

------
rms
Did Nintendo officially give up on litigating for NES ROMs? I'm wondering how
something like this stays on the internet while supplying ROMs.

~~~
arketyp
I've heard (can't find a source) that Shigeru Miyamoto (creator of most
Nintendo's hit titles) personally has a lighthearted stance to the whole
emulator/ROM scene and basically thinks it is nice that people still play the
games.

~~~
rms
Sounds very plausible. It just seems odd that Nintendo would allow this to go
on while still making all of these games available for purchase via the Wii
store.

~~~
nuclear_eclipse
I don't think the Wii's target market really crosses much with the people who
would really use ROMs on a PC as a substitute for the real thing...

------
chaosmachine
I wonder how far behind a n64 emulator is. Does anyone else remember when
UltraHLE showed up in early 1999? Nobody expected the Nintendo64 would be
emulated that soon (GameCube was still 2 years away at that point).

------
audionerd
I wonder if sound could be added via the HTML5 <audio> support?

You can actually use the data uri scheme for <audio> src. So if you generate
WAV data on the fly via JavaScript, and encode it as Base64, you can play it
immediately.

Here's an example of on-the-fly WAV generation w/ <embed>, but I just tried it
in Firefox with <audio> and that works as well:

[http://sk89q.therisenrealm.com/2008/11/dynamically-
generatin...](http://sk89q.therisenrealm.com/2008/11/dynamically-generating-a-
wav-in-javascript/)

------
Pistos2
Pretty much unplayable in Opera (10). Opera's key mappings override the game's
mappings, and CPU usage is way up there.

------
WALoeIII
This is so cool. Props.

------
_ck_
I sure hope flashblock comes up with an optional canvas block because it all
starts with fun and games until advertisers realize "ooh hey we can skip flash
and write the content anywhere without filtering" and then you've got "hit the
monkey" all over again.

~~~
jcl
I wouldn't be too concerned... The number of people using Flashblock is
vanishingly small, and their eyeballs are worth less for many products. Also,
Flash cookies are more advertiser-friendly than browser cookies.

