3 ms·
I wrote a GB emulator, the main issue was debugging it. Subtlely wrong tends to lead to game crash very quickly. The trick I used was to take an existing GB em
by ReflectedImage 5y ago
I wrote a GB emulator, the main issue was debugging it. Subtlely wrong tends to lead to game crash very quickly.
The trick I used was to take an existing GB emulator, add a printf debugging statement to print out each current instruction and the registers. Add the same printf statements on mine. Then use diff on the outputs of both emulators.
It does play Pokemon. The emulator is called FireGB.
- progbits 5y agoComparing to an existing, known-good emulator is probably the most convenient way. This can be printf debugging like you describe, or even trying to compare framebuffer contents etc. However I feel like that "spoils" a bit of the fun. A more adventurous approach is to test with test ROMs [1] - they are simpler to follow by hand and discover why they don't work than real games. Of course if some game ROM is relying on some more obscure hardware quirks this might not be enough. Just wanted to bring it to attention for anyone interested in writing and debugging their emulators. [1]: https://gbdev.gg8.se/wiki/articles/Test_ROMs https://gbdev.gg8.se/wiki/articles/Test_ROMs
- ReflectedImage 5y agoAhh but it already passed the test ROMs at the point I turned to printf debugging.