From 7df4e564549fe17e784d0b0d48fad8f5d3f32048 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 12 Aug 2017 21:42:47 +0300 Subject: [PATCH] KEY1 is only writable in CGB mode; screen should be black is LCD is on while in stop mode. --- Core/display.c | 8 +++++--- Core/memory.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/display.c b/Core/display.c index e624ac9..0573b9c 100755 --- a/Core/display.c +++ b/Core/display.c @@ -204,10 +204,12 @@ static void display_vblank(GB_gameboy_t *gb) } if (!gb->disable_rendering && ((!(gb->io_registers[GB_IO_LCDC] & 0x80) || gb->stopped) || gb->frame_skip_state == GB_FRAMESKIP_LCD_TURNED_ON)) { - /* LCD is off, set screen to white */ - uint32_t white = gb->rgb_encode_callback(gb, 0xFF, 0xFF, 0xFF); + /* LCD is off, set screen to white or black (if LCD is on in stop mode) */ + uint32_t color = (gb->io_registers[GB_IO_LCDC] & 0x80) && gb->stopped ? + gb->rgb_encode_callback(gb, 0, 0, 0) : + gb->rgb_encode_callback(gb, 0xFF, 0xFF, 0xFF); for (unsigned i = 0; i < WIDTH * LINES; i++) { - gb ->screen[i] = white; + gb ->screen[i] = color; } } diff --git a/Core/memory.c b/Core/memory.c index c914e55..e1bffcd 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -558,7 +558,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) } return; case GB_IO_KEY1: - if (!gb->is_cgb) { + if (!gb->cgb_mode) { return; } gb->io_registers[GB_IO_KEY1] = value;