GB: Fix CGB-to-DMG switchover

This commit is contained in:
Vicki Pfau 2020-11-20 02:34:07 -08:00
parent 54fba4c461
commit d5e434c684
3 changed files with 11 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 846 B

After

Width:  |  Height:  |  Size: 827 B

View File

@ -489,11 +489,6 @@ void GBSkipBIOS(struct GB* gb) {
const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
int nextDiv = 0;
if (gb->model >= GB_MODEL_CGB && !(cart->cgb & 0x80)) {
gb->model = GB_MODEL_DMG;
GBVideoDisableCGB(&gb->video);
}
switch (gb->model) {
case GB_MODEL_AUTODETECT: // Silence warnings
gb->model = GB_MODEL_DMG;
@ -559,6 +554,12 @@ void GBSkipBIOS(struct GB* gb) {
cpu->e = 0x08;
cpu->l = 0x7C;
gb->timer.internalDiv = 0x260;
gb->model = GB_MODEL_DMG;
gb->memory.io[GB_REG_KEY1] = 0xFF;
gb->memory.io[GB_REG_BCPS] = 0x88; // Faked writing 4 BG palette entries
gb->memory.io[GB_REG_OCPS] = 0x90; // Faked writing 8 OBJ palette entries
gb->memory.io[GB_REG_SVBK] = 0xFF;
GBVideoDisableCGB(&gb->video);
}
nextDiv = 0xC;
break;

View File

@ -214,7 +214,11 @@ void GBIOReset(struct GB* gb) {
GBIOWrite(gb, GB_REG_HDMA3, 0xFF);
GBIOWrite(gb, GB_REG_HDMA4, 0xFF);
gb->memory.io[GB_REG_HDMA5] = 0xFF;
} else if (gb->model & GB_MODEL_SGB) {
} else {
memset(&gb->memory.io[GB_REG_KEY0], 0xFF, GB_REG_PCM34 - GB_REG_KEY0);
}
if (gb->model & GB_MODEL_SGB) {
GBIOWrite(gb, GB_REG_JOYP, 0xFF);
}
GBIOWrite(gb, GB_REG_IE, 0x00);