From d5e1a1f36bb033777d16471a01db71460766a739 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Tue, 17 Sep 2024 18:52:35 -0700 Subject: [PATCH] [GB] Properly set OPRI on startup Previously, the OPRI register was always set to be in CGB mode when not using the CGB BIOS, resulting in graphics corruption when running DMG software in CGB mode without using the CGB BIOS. This fixes the issue by properly setting bit 1 of the OPRI register as expected. This was broken in #1119. --- src/core/gb/gb.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/gb/gb.cpp b/src/core/gb/gb.cpp index bf1fa3cb..ccbaa6e9 100644 --- a/src/core/gb/gb.cpp +++ b/src/core/gb/gb.cpp @@ -2969,8 +2969,13 @@ void gbReset() inBios = true; } else if (gbHardware & 0xa) { // Set compatibility mode if it is a DMG ROM. - const uint8_t gbcFlag = g_gbCartData.SupportsCGB() ? 0x80 : 0x00; - gbMemory[0xff6c] = 0xfe | gbcFlag; + if (g_gbCartData.SupportsCGB()) { + // OPRI with bit 0 set to 0 = CGB mode. + gbMemory[0xff6c] = 0xfe; + } else { + // OPRI with bit 0 set to 1 = DMG mode. + gbMemory[0xff6c] = 0xff; + } } gbLine99Ticks = 1;