r/EmuDev • u/Electronic-Carry6562 • 10d ago
How do i debug my gameboy emulator??
for background i wanted to create a online gomeboy emulator for a college project na di am making it in plain javascript. At first the emulator was failing the first test of the blargg cput_instrs.
but fter some fixes instead of failing it keeping looping in the test 1 suite and doesnt output pass or fail.
here is the link: https://github.com/Flaykey/GAMEBOY_JS
4
u/ThatPurdude 10d ago
What worked for me easier instead of blargg was to make a secondary harness just to feed the gameboy unit tests and see how many of each instruction failed. I made a fork that should be accurate-ish for MBC0 cartridges (since the original did not control for trying to write to ROM) https://github.com/michaelperino/GameboyCPUTests
2
u/Electronic-Carry6562 10d ago
bro , my emulator passed all your tests but it got stuck in the blargg test roms
2
u/ThatPurdude 10d ago
Might be your interrupt implementation then? I haven’t looked at blargg in a long time to remember how it prints out its memory stuff
1
u/Electronic-Carry6562 10d ago
i use the serial print to know it it passed or not,
i really havent implemented interrupts , i do have EI and DI but they really dont do any thing1
1
u/EggplantExtra4946 9d ago
What's a harness and how is it different that regular single instruction tests?
2
u/sapoconcho_ 10d ago
Something extremely useful for me (especially for CPU) was to clone another emulator inside my project, run both side to side and stop as soon as some register differs. Took a few hours but saved me days of debugging.
1
u/Electronic-Carry6562 10d ago
i tried to do that to but i couldnt find emulatorsthat could get the values of registers
1
1
u/sapoconcho_ 9d ago
What I did is to get the source code of some emulator in github and then modify the implementation to get them through some wrapper interface in my code. Not sure that answers your question though
1
u/Creepy_Sherbert_1179 7d ago
Try to get the boot rom running, it is fewerr than 256 bytes IIRC, you can find the hexdump easily.
7
u/PandaMoniumHUN 10d ago
gameboy-doctor (https://github.com/robert/gameboy-doctor) lets you run blargg tests and compare actual registers vs the expected values after every instruction.