8 ms·
NES Emulator in Javascript
- albertzeyer 16y agoI wonder, are all those NES which can be played there public domain?
- zebra 16y agoAre they licensable? If not - in my world they become public domain.
- deleted 16y ago[deleted]
- rufo 16y agoYou can buy many of those games on Nintendo's Virtual Console service, so yes, they are licensable.
- phoboslab 16y agoNo. 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!?
- chipsy 16y agoIt 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.
- kj12345 16y agoActually 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?
- bfirsh 16y agoI tried that, but unfortunately data URLs are far too slow. Firefox 3.7 has some exciting audio APIs though: https://wiki.mozilla.org/Audio_Data_API https://wiki.mozilla.org/Audio_Data_API I've been meaning to write a JSNES prototype for them.
- kj12345 16y agoThanks, looks like a very useful API. In addition to synthesizing audio it also has the ability to do spectrum analysis: http://vimeo.com/8525101 http://vimeo.com/8525101
- phoboslab 16y agoThis demo seems to do just that: http://acko.net/files/audiosynth/index.html 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.
- dRother 16y agoMany 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 http://www.romnation.net/srv/page/esa.html (WARNING : horrible flashing ads). This includes all Mario games, Zelda, and so on.
- baby 16y agoso laggy, can't play it on my laptop.
- deleted 16y ago[deleted]
- thorax 16y agoOn 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.
- albertzeyer 16y agoWhy is that depressing? I find it amazing and exiting.
- mynameishere 16y agoWhy do you find it amazing? I saw this first probably 10 years ago with java applets. Is it more amazing because applets are unfashionable?
- icefox 16y agoapplets don't work on [insert random browser on device]
- lukesandberg 16y agoyeah, 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.
- Rauchg 16y ago
- icefox 16y agoIf you were to convert the nes asm into javascript how much faster would it run?
- earcar 16y agoIt 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.
- icefox 16y agoFound a paper http://www.jordansmind.com/files/Laughy-DBT.pdf 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.
- daeken 16y agoInsanely, insanely fast. I created a fork of http://6502asm.com/ 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 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 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/ http://daeken.github.com/Dyna6502Asm/
- savrajsingh 16y agoCool. How do you do the sound in javascript?
- zppx 16y agoI 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."
- savrajsingh 16y agook cool. yes pure javascript sound has always been elusive.
- upinsmoke 16y agoThis is awesome. Even Konami code works in Contra!
- stuntmouse 16y agoguess this kills my nacl port.
- rick_2047 16y agoI tried to play it but it is not taking input from keyboard I am using ubuntu 9.10 and the default firefox.
- JeanPierre 16y agoTried 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.
- dRother 16y agoIt 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.
- fuzzythinker 16y agoHope Simucal sees this. Sounds like he was working on an NES emulator 1/2 yr ago. They can probably team up.
- ck2 16y agoYay Bubble Bobble! 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.
- bfirsh 16y agoLong 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.