LIJI32 / SameBoy

Game Boy and Game Boy Color emulator written in C
https://sameboy.github.io/
Other
1.63k stars 205 forks source link

Boot ROM ends with different registers than the official ROM #80

Closed max-m closed 6 years ago

max-m commented 6 years ago

Hi, in #gbdev at EFnet we discovered that SameBoy’s boot ROM ends with different register values than the official one does. It checks out for the DMG boot ROM, but the CGB ROM differs in both modes of operation. This has thrown bgb’s CGB mode detection off but is fixed now :sweat_smile:

The following values have been optained in bgb using the official Nintendo boot ROMs and freshly built ROMs from the current master.

Nintendo dmg_boot.bin SameBoy dmg_boot.bin
DMG game DMG game
AF: $01B0 AF: $01B0
BC: $0013 BC: $0013
DE: $00D8 DE: $00D8
HL: $014D HL: $014D
SP: $FFFE SP: $FFFE
PC: $0100 PC: $0100
Nintendo cgb_boot.bin SameBoy cgb_boot.bin
DMG game DMG game
AF: $1180 AF: $1180
BC: $3C00 BC: $0000
DE: $0008 DE: $0008
HL: $007C HL: $007C
SP: $FFFE SP: $FFFE
PC: $0100 PC: $0100
Nintendo cgb_boot.bin SameBoy cgb_boot.bin
CGB game CGB game
AF: $1180 AF: $1180
BC: $0000 BC: $0000
DE: $FF56 DE: $0008
HL: $000D HL: $007C
SP: $FFFE SP: $FFFE
PC: $0100 PC: $0100
LIJI32 commented 6 years ago

The DMG mode register initial values appear to be dependent on the ROM's header, so I'll need to research a bit more into it. What ROMs were used to test this?

LIJI32 commented 6 years ago

Checked my disassembly of the CGB boot ROM. Before booting a DMG game, B is set to the checksum of the title, but ONLY IF it's a Nintendo title with a built in palette. This means the game you were testing is Dr. Mario. :) image

max-m commented 6 years ago

f1006d6cf77469092f3b9f266d0a65da9c91ac42 Dr. Mario (World).gb

// Edit: Sniped :)

LIJI32 commented 6 years ago

Also, I'm unsure what happens in the AGB-CGB boot ROM, as it hasn't been dumped and it has B set to a different value after booting.