Tried it on different browsers, and wow, this is an alternative way to check the efficiency of the javascript-engines.
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.
It doesn't work at all in IE. It's not anything to do with flash, rather, IE's lack of support for canvas. It gives a JS error on page load (object doesn't support this property or method), on line 28 where it tries to call Canvas getContext.
Insanely, insanely fast. I created a fork of http://6502asm.com/ that dynarec'd 6502 machine code to Javascript and cached the functions; the speedup was on the order of 25-100x, depending on the code in question. I used to have it hosted, but it's since disappeared; let me go throw it on github.
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.
It depends on how aggressively you optimize. In the worst case scenario (the compiler just copies the code that the interpreter would run) you end up with the same performance as the interpreter.
Found a paper http://www.jordansmind.com/files/Laughy-DBT.pdf last night titled "Implementation of a Dynamic Binary Translator for the Nintendo Entertainment System (NES) console" Converting had a ten time speedup. Given that the js engines we have today determining the best way to convert the nes asm to js seems like it would be a very interesting project.
No. They aren't "abandonware" either, as many of them can still be bought for the Wii's virtual console.
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!?
It says on the site that it uses Flash for dynamic sound. I looked into this a while ago and dynamic playback in <audio> is being prototyped by at least a few people, so maybe someday soon it'll hit the mainstream.
Actually it uses a small Flash app to generate the sound (see the News section at the bottom of the page). I wonder if data URLs could be used like that though?
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.
Many games are essentially open at this point, in that Nintendo and other publishers haven't asked that the roms not be distributed.
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.
Long story short: Firefox is just slow. It's tracing engine doesn't cope with heavily branching code like that in an emulator, and it just falls back to interpreting it. It's nothing to do with the canvas. (In fact, Chrome's canvas is far slower than Firefox's.)
Chrome is wildly fast because it compiles everything to machine code instead of JIT compilation.
I did not looked deep enough, but there's a swf file called jssound.swf in the codebase.
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."
On my 2 year old laptop on Vista + Chrome 5beta, it runs just as fast as it did when I played it sitting at a TV screen eons ago. It's really quite impressive.
... 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.
No, it's because Applets, like Flash, are a narrow, specific, proprietary setting. Nobody has ever questioned that Java can handle something like that.
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.
getting code to work is easy, getting the largest most influential tech companies to cooperate on building a platform for you to deliver applications that work on most devices in the world entirely for free with no real financial incentive.
yeah, but as people have noted this doesn't work on anything other than the latest builds of chrome and safari. Still impressive but this is not exactly a compatibility win.
But this is an implementation based on open web standards. It'll eventually work on mainstream Firefox, Safari, Chrome, Opera and maybe (if <canvas> is supported and planets align) IE9.
This is too slow to play on my Dell i7 720, which I think says more about Dell's screwed up architecture causing horrible CPU performance than it does about this code.
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.