all repos — mgba @ f33593537beac5434ac1277c594c18ba4e6ff886

mGBA Game Boy Advance Emulator

GB: Fix GBC game registers after skipping BIOS
Vicki Pfau vi@endrift.com
Wed, 13 May 2020 01:41:02 -0700
commit

f33593537beac5434ac1277c594c18ba4e6ff886

parent

46860b40e6b59f035073f885906da26954953ed8

2 files changed, 10 insertions(+), 2 deletions(-)

jump to
M CHANGESCHANGES

@@ -5,6 +5,7 @@ - Add APNG recording

Emulation fixes: - ARM: Fix ALU reading PC after shifting - ARM: Fix STR storing PC after address calculation + - GB: Fix GBC game registers after skipping BIOS - GBA: Add missing RTC overrides for Legendz games - GBA BIOS: Implement dummy sound driver calls - GBA BIOS: Improve HLE BIOS timing
M src/gb/gb.csrc/gb/gb.c

@@ -478,6 +478,7 @@ }

void GBSkipBIOS(struct GB* gb) { struct SM83Core* cpu = gb->cpu; + const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; int nextDiv = 0; switch (gb->model) {

@@ -539,9 +540,15 @@ case GB_MODEL_CGB:

cpu->a = 0x11; cpu->f.packed = 0x80; cpu->c = 0; - cpu->e = 0x08; cpu->h = 0; - cpu->l = 0x7C; + if (cart->cgb & 0x80) { + cpu->d = 0xFF; + cpu->e = 0x56; + cpu->l = 0x0D; + } else { + cpu->e = 0x08; + cpu->l = 0x7C; + } gb->timer.internalDiv = 0x1EA; nextDiv = 0xC; break;