gameboy-doctor icon indicating copy to clipboard operation
gameboy-doctor copied to clipboard

Show the actual value of the flags registers if there is a mismatch in the lower nybble

Open yoursred opened this issue 3 years ago • 8 comments

yoursred avatar Dec 07 '22 09:12 yoursred

Ahh do you mean show the full 2-digit hex, rather than just the 4 flags? In case there's a mismatch in the bits in the F register outside those used for the flags?

robert avatar Dec 07 '22 10:12 robert

Yup. Only show it if there is a mismatch in the lower four bits.

yoursred avatar Dec 07 '22 11:12 yoursred

👍 makes sense, I'll do that at some point!

robert avatar Dec 07 '22 14:12 robert

This sent me for a loop, I had to manually look at the logs to figure out what was going on. F register was getting bit 0 set, gb dr said the line was wrong, but the diff it displayed me was identical. Specifically happened for the 01-special.gb test.

CosmicBagel avatar Feb 24 '23 11:02 CosmicBagel

Thanks for the vote, I'll keep this in mind. If you're interested in submitting a patch then that would be awesome, although the code is a little gnarly so might be tricky XD.

robert avatar Feb 24 '23 13:02 robert

I think the lower nybble of F is always 0.

ld b, 0xff
ld c, 0xff
push bc
pop af
push af
pop bc

If you check c after all this in an emulator like BGB, the lower nybble will be zeroed out because when the values were pushed back onto the stack the lower f nybble is zeroed. The cpu_instrs does something goofy like this to feed state to the CRC checker and I found the lower nybble was zeroed out. Also this reference shows the lower nybble as zeroed out.

I'm not an expert though. If I'm wrong, please don't neglect your duty.

dan-mcdonald avatar Oct 11 '23 15:10 dan-mcdonald

Heh you're probably right. Do you think we should change anything about gameboy doctor or is this just interesting trivia?

robert avatar Oct 12 '23 08:10 robert

I just commented to be helpful since it sounded like a fellow GB emulator developer was on the wrong path, and people from the future finding for this issue might benefit.

I think the ideal output from gameboy-doctor would be to check the lower F nybble and when it is non-zero explain that it should never be zero.

dan-mcdonald avatar Oct 12 '23 14:10 dan-mcdonald