SNES emulators port to js

459 views
Skip to first unread message

weijr

unread,
Aug 18, 2012, 10:49:01 AM8/18/12
to emscripte...@googlegroups.com
I've ported two snes emulators to js using emscripten.
More information can be found at
http://weijr.b81.org/xnes/

The SNEM based port is very fast but less compatible.  Using javascript to do canvas graphics and keyboard input.
Some machine dependent code are rewritten.

Snes9x port is a straightforward emscripten translation. It is much slower. 
It still have some bugs due to machine depended codes (typed 2 array alignment issues).

Alon Zakai

unread,
Aug 19, 2012, 3:50:36 PM8/19/12
to emscripte...@googlegroups.com
Very cool stuff, thanks for posting!

Anything we can do in emscripten to make stuff like this easier to
port or faster?

- azakai

weijr

unread,
Aug 19, 2012, 10:03:52 PM8/19/12
to emscripte...@googlegroups.com
The SNEM port is about 10x and  the snes9x port is about 20x slower than the native one.
SNEM port usually get 50~60+ fps on my 7 yrs old laptop (which has an intel T5600 CPU) when running on the nightly firefox. Hand ported JSNES (which is only a NES emulator, not a SNES emulator)  got 30~40fps.
snes9x can be compiled by emscripten almost out of the box. 
I think you guys did a very nice job.
Still, I wish there is an easy way to pass a video bitmap (a subarray of HEAP32) between the browser thread and a web worker. Currently, emscripten compiled code shares a big ArrayBuffer,  which makes it difficult to transfer an array to the browser thread.

I also encontered several bugs of emscripten when porting the emulator. I will submit them to the issue tracker.
Some of them are libsdl related. Emcc also seems to have issues with struct and union defined inside a function.

TJW

weijr

unread,
Aug 21, 2012, 6:11:21 AM8/21/12
to emscripte...@googlegroups.com
I also encountered some int32 alignment problem when porting the emulator. If dataview can be used instead of typeview, then this might help to simplify the porting task.

weijr於 2012年8月20日星期一UTC+8上午10時03分52秒寫道:

Alon Zakai

unread,
Aug 22, 2012, 7:10:20 PM8/22/12
to emscripte...@googlegroups.com
Please file issues on the problems you encountered, we definitely need
to fix those things.

About passing bitmaps, there is a proposed spec for transferring typed
arrays between workers, that might help here. But it is not yet
production-ready.

- azakai
Reply all
Reply to author
Forward
0 new messages