From d5e434c684f36200fca0f4505bc4885b9fdd9c66 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Fri, 20 Nov 2020 02:34:07 -0800 Subject: [PATCH] GB: Fix CGB-to-DMG switchover --- .../misc/boot_hwio-C/xbaseline_0000.png | Bin 846 -> 827 bytes src/gb/gb.c | 11 ++++++----- src/gb/io.c | 6 +++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cinema/gb/mooneye-gb/misc/boot_hwio-C/xbaseline_0000.png b/cinema/gb/mooneye-gb/misc/boot_hwio-C/xbaseline_0000.png index cb37cb619c559ad7defcd227f00231c8a4e60760..fb836d344a281e22ec87159031e82cd3d3f6b310 100644 GIT binary patch delta 549 zcmV+=0^0q~2D=83B!2=)L_t(|obB4%lA!hZ_F4)m-nEPvRz(m2n5 z#(!0E_`~##6*M<;XuX|V^&BnTo^<)r^V!2Yv{OU2@F;t&t_Vl%@F%5lF4_9#l{R(N zdb4lbp)1dn^*pE_@xuaV@(iuFDV)J4Hz~f3>bS^@Byp`_=^T&M;T`zAe^}M|%-{GXujJ7|y_O28J^*oPpsC47V-S zdClxBUOJx`7RZhhztl4?+cVGFKNDOZr*o+9_4`|Nb|>R`q0%f$&+JNRez)@5Y;)G7 ze_C_sd7jsV|MNk1?k|15w0!e6kIo}|)nr5ec2d>O;D3s{&y2gr!FLTBAF|Hh5pm)C zt|lBW(M#d#+Ihc6cASa%-R9@Gt1jK=hx%|%7sB~H7_RXtI{VU_Z~UC*_uwV`(9!&H zBYylR_ZH3ZQ}j0XJ@s4oJ@|E3C32rVgCFs4RsUzV|Br2{eoy_tTa-2A(?2EYB)Z*!<%oZX%VBM0O3 zY{rl!UuC|&X1UtW@w#hAMs2{W92@+(JG;ZB_Vi%b`0%=Xe}5lo1!)I*R*;sT{@Ogwcc2B8|bMhrlgO3h) z)q0Bu?$82-gP%sPSGAL)cs)fd0A|D3iX|KC%* zL|@{igCDbf9e)mQQv7aox6D=k;G%I~e{zjI>3&SVx-$dA85qvMa0Z4mFr0zm z3=FqS;k;&X7OyscIW&2kFP|3ZnP=^v3696<9O}M)zKbsITB7rwify91PcZ7hU|*;roi;tah{5SA7ni zcmG_6Zc)C`EiA9T*ZN~E$3Cat%R6s!`!v6IRZ{o4c)r5+G4R-aSH;`yueur+EmQb8 z^#gBF?hO~z9i6whuWvuV@%$Wmemory.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; diff --git a/src/gb/io.c b/src/gb/io.c index e46e50412..612e4d819 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -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);