Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Hey! Yeah there are bugs in the emulator so it's not time perfect, I've not really touched the emulator code in about 5 years so will take me some time to get back into it.

Thanks for the tip about requestAnimationFrame (/u/knackers mentioned as well) I'll look into it! That's what's good about sharing this stuff - you learn something new!

I'll probably tinker with the project here and there, I want to implement another cartridge type that for some reason I left out, I found a ROM last night that wasn't supported and I think it's MBC2. But I don't intend for it to be a perfect emulator or anything, more just a sandbox to play around with. There are definitely better emulators out there that strive for accuracy.



Btw, my WebAssembly emulators here (https://floooh.github.io/tiny8bit/) work quite well with a 60hz frame update even on mobile devices (some of them are still quite CPU hungry since they're doing a cycle-correct display emulation).

The WebAssembly version uses the following HTML5 features:

- requestAnimationFrame for frame scheduling

- WebGL for rendering (emulator code creates a linear RGBA8 framebuffer, which is copied into a double-buffered WebGL texture, which is then rendered as a fullscreen rectangle)

- WebAudio with ScriptProcessorNode and 2048-samples output buffer size to 'render' the audio (at 44.1 kHz), technically ScriptProcessorNode is deprecated, it works surprisingly well though

- everything is running in the browser thread

- everything is written in C, no dynamic memory allocation, except at startup


Thanks for this. It's pleasing to hear there might be a better way!

I shot myself in the foot a bit when I saw the web worker thing working (ish!) and carried on down that path, so didn't really explore the other means with requestAnimationFrame etc

Will be definitely looking at it now though, it's good to know that everything can run on the browser thread!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: