NES Emulator in Javascript
benfirshman.com
benfirshman.com
Opera and Chrome comes best out so far, with a steady 57-59 FPS. Safari says it comes with 30-33 FPS, but stopped rendering. It still emulated the game fairly well though. I heard I died from a mushroom @ the super mario bros emulator. Firefox had a measly 4-5 FPS.
I tried it with Internet Explorer as well, but it wouldn't start without the sound-engine made in flash. Obviously installing flash for IE isn't that easy, so I didn't bother.
Edit: It's up at http://github.com/daeken/Dyna6502Asm now. If someone could actually host it so that people can test it out, I'd greatly appreciate it. I'm writing up a small document on how it works, for those who are curious; it'll be in the repo in a few minutes. Oh, and I believe that this was the first dynarec'd emulator for Javascript; this was back in December 2008.
Edit #2: Strategy document is up, here: http://github.com/daeken/Dyna6502Asm/blob/master/strategy.md. The same exact mechanisms should work just fine with this emulator, if someone is so inclined. One thing you ought to do, though, that I never got around to, is adding a simple checksum to the code cache. When you attempt to execute a block, check to make sure that the code in memory is the same as the one in the code cache; if it's different, then the code has been modified and needs to be recompiled.
Edit #3: Thanks to icefox, I now know how to host on github! http://daeken.github.com/Dyna6502Asm/
I think I remember seeing this last time JSNES had some exposure. I'm going write support for this right now...
The Emulator is pretty impressive, though. Especially the sound emulation/output - iirc the JavaScript Audio API has no "direct" way to play arbitrary wave forms. I guess it uses the data URL scheme and a simple WAV header!?
https://wiki.mozilla.org/Audio_Data_API
I've been meaning to write a JSNES prototype for them.
http://acko.net/files/audiosynth/index.html
Edit: It's not exactly as "dynamic" as I thought. The different samples are generated once and then played in a loop. So the audio data is not generated in real time, but it is generated.
The ones they really care about they have an ESA request on. See http://www.romnation.net/srv/page/esa.html (WARNING : horrible flashing ads). This includes all Mario games, Zelda, and so on.
But seriously, what's with Firefox canvas being so much slower than Chrome?
It can't be javascript speed because Firefox is just as fast as Chrome for JIT JS performance.
Chrome is wildly fast because it compiles everything to machine code instead of JIT compilation.
EDIT: Well, from the index.html:
"It has been in the pipeline for a while, but JSNES can now play sound! There is no way of playing dynamically generated sound in JavaScript, but I have created a tiny Flash application reads a buffer from JavaScript then writes it to the sound card."
... or, rather, it's really quite depressing once you realize this is 25-year-old technology finally making its appearance into (some!) browsers without requiring plugins.
thats a plain miracle.
The interesting part here is that it is showing that browsers and JavaScript, with a very different approach than Flash or Java, can now handle this sort of computationally intensive, graphics intensive application without any OS-specific plugins.
Wake me up when that means something from only 5 years ago and not 20.
I am using ubuntu 9.10 and the default firefox.