From dec7b6902ee871452345ec0284391a7b19029e4a Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 8 Nov 2017 01:07:38 -0800 Subject: [PATCH] GB IO: Use correct lockout register --- include/mgba/internal/gb/io.h | 1 + src/gb/io.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/mgba/internal/gb/io.h b/include/mgba/internal/gb/io.h index 5ed4cb0fe..665586e04 100644 --- a/include/mgba/internal/gb/io.h +++ b/include/mgba/internal/gb/io.h @@ -84,6 +84,7 @@ enum GBIORegisters { REG_WX = 0x4B, // CGB + REG_UNK4C = 0x4C, REG_KEY1 = 0x4D, REG_VBK = 0x4F, REG_HDMA1 = 0x51, diff --git a/src/gb/io.c b/src/gb/io.c index 533a33e79..bb20e44e9 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -174,6 +174,7 @@ void GBIOReset(struct GB* gb) { GBIOWrite(gb, REG_WY, 0x00); GBIOWrite(gb, REG_WX, 0x00); if (gb->model >= GB_MODEL_CGB) { + GBIOWrite(gb, REG_UNK4C, 0); GBIOWrite(gb, REG_JOYP, 0xFF); GBIOWrite(gb, REG_VBK, 0); GBIOWrite(gb, REG_BCPS, 0); @@ -424,7 +425,7 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { free(gb->memory.romBase); gb->memory.romBase = gb->memory.rom; } - if (gb->model >= GB_MODEL_CGB && gb->memory.io[0x6C]) { + if (gb->model >= GB_MODEL_CGB && gb->memory.io[REG_UNK4C] < 0x80) { gb->model = GB_MODEL_DMG; GBVideoDisableCGB(&gb->video); } @@ -436,6 +437,8 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { default: if (gb->model >= GB_MODEL_CGB) { switch (address) { + case REG_UNK4C: + break; case REG_KEY1: value &= 0x1; value |= gb->memory.io[address] & 0x80;