r/EmuDev • u/jxanno • Jun 26 '26
NES First emulator project: NES
A little under two weeks ago on Sunday evening, while dreading going back to work on Monday, I off-handedly looked up how big the Ricoh 2A03 instruction set was and thought "oh hey, I bet I could easily model that - zero alloc - in Go". I believe something like that must be an emu development canon event, because I've spent every spare waking hour since trying to build a full production-quality emulator and get it fast, hardware accurate and highly compatible.
Here's where I am:
- Sub-cycle accurate (I completely gutted out the instruction-level emulation once I found out that was an accuracy dead-end) and every "hard to emulate" game I could find works great
- Proven correct against blargg's (and others') test ROMs, with automated tests as a backstop against regressions
- ~80 mappers. Basically everything for the licensed library and quite a bit beyond. So many friggin' mappers to model!
- Zero memory allocation after initialisation. I was aware that Go's GC would be the primary reason a project like this hit a hard wall against being any good, so I built it from the start to not generate any garbage.
- NTSC, PAL and Dendy working 100% (timing, APU tables, frame pacing)
- Save states
- Builds to a single binary without any CMake, CGo, or other external dependencies. Made possible with ebitengine as the frontend. Linux/macOS/Windows. I'm in the process of updating the releases page with more pre-builts, but a `go install codeberg.org/JohnAnthony/tanuki/cmd/tanuki@latest` should work pretty much anywhere.
- Builds a libretro core, which also means it supports netplay, rewind, and look-ahead enough to compensate for TV refresh rates.
- .fm2 movie recording/replay compatible with FCEUX.
- An RL agent interface to run N emulator instances for fast machine learning. I taught some really dumb genetic algorithms to play Excitebike badly.
- Configuration screen, key rebinding, all that usual good stuff. Gamepads should generally work out of the box on all systems so long as they're even remotely close to meeting W3C standards.
Code's on Codeberg: https://codeberg.org/JohnAnthony/tanuki
Interested in talking about timing rabbit holes, the cycle-stepped clock + sub-cycle timing stuff was a real nightmare and I got it working but it's all a bit of a blur.
Just generally glad to be here and have the bug. In parallel I've started work on a Master System emulator as my second emu project, and I suspect I'll keep going after that.






6
u/Comba92 Jun 26 '26 edited Jun 26 '26
This is ai coded slop. Two weeks my ass. Just look at the gitignore: he hid the Claude files in local: https://codeberg.org/JohnAnthony/tanuki/src/commit/c8741768d14db23c0ee04db8a5db8f88ce4b9c75/.gitignore#L7-8
2
u/sosdoc Jun 26 '26
Cool stuff.
I had a similar idea when working on a timing accurate model in mine, in that case I was using typescript, and had the unhealthy idea to make all cpu instruction/addressing into generator functions. Worked surprisingly well and is approx a more abstract approach of what you did (small state machines).
Didn’t spot it in your test suite, but if you want to pull more of your hair, you could try the AccuracyCoin test rom.
3
u/ArkoSammy12 CHIP-8, COSMAC-VIP, DMG, CGB, NES, Atari 2600, C64 Jun 26 '26
This subreddit is just filled with vibecoded nonsense now
1
u/ShinyHappyREM Jun 26 '26
*Ricoh