I have an old project of mine I’m aiming to resurrect, to make a 3D emulation of a C64. I initially tried using WebAssembly (AssemblyScript) for the emulation, but ran into roadblocks I can’t even recall now, so I switched back to JS, deciding to forego cycle accuracy. But now I’m thinking of trying WebGPU compute shaders for the emulation.
So the idea is that the emulator would simply accept C64 memory buffers for RAM and ROM, passed from JS, and accept user inputs from keyboard and joysticks, then output video (texture) and audio. So, emulating MOS 6510 CPU, MOS 6569 VIC-II (PAL & NTSC) and MOS 6581 SID synced by some kind of cycle-accurate timer for C64 color, dot and system clocks.
Babylon.js would render the interactive 3D “breadbox” C64, 1702 monitor, joysticks, tape & floppy drives.
Anyway, that’s the ambition. I have some of this but there’s a ways to go …
I started playing around with WebGPU compute shaders for audio and migrated JolifantoBambla/webgpu-audio.html into a Babylon PG. It works, but is not integrated with Babylon’s API as well as it could be. For instance, I didn’t find how to get the device
from Babylon, create buffers with size
& usage
or create a compute pipeline with parameters.
Eventually I’d like to have one big shader (even if comprised of separate files for manageability) that takes the aforementioned inputs and executes each chip cycle at the appropriate timing, continually updating audio and video out buffers.
This is way outside my current capabilities, so I have a bunch to learn Any help or advice is appreciated!
Here’s part of where I got to - working C64 keyboard, accurate keycaps and key mappings, basic video out, minus the static classic “breadbin” and C64C cases and 1702 monitor I’ve modelled but not depicted here.