Posts tagged wasm

Compiling a C-64 Emulator to WebAssembly

We use a variety of emulators in 8bitworkshop. Many of them, like most of the Z80 emulators, are written from scratch in JavaScript directly against our Platform API. This facilitates deep introspection into the emulator state, which comes in handy for things like debugger support and CPU visualization.

To save effort, we also integrate a couple of open source emulators. Atari 2600 support is courtesy of Javatari, and NES support is courtesy of JSNES. Each of them requires significant patching to expose hooks for the extra features the IDE supports, like breakpoints and bus-monitoring.

We can also use MAME, compiling it to WebAssembly using Emscripten. The trouble is that it’s a bit heavyweight and monolithic, and wants to be treated as an application, not a library. Due to the way it’s architected, interacting with the debugger via JavaScript isn’t really feasible. Even simple things like re-loading the ROM require a ton of Lua scripting.

Read more ...