From b996ed922052a06e47d844e914652d3469ef6bc7 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 19 Jan 2019 23:37:44 +0200 Subject: [PATCH] =?UTF-8?q?Writing=20to=20BGPD/OBPD=20while=20it=E2=80=99s?= =?UTF-8?q?=20blocked=20still=20increases=20BGPI/OBPI=20if=20needed.=20Fix?= =?UTF-8?q?es=20#145?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/memory.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/memory.c b/Core/memory.c index 262fc4d1..bf01d202 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -792,10 +792,15 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) is required. */ return; } + + uint8_t index_reg = (addr & 0xFF) - 1; if (gb->cgb_palettes_blocked) { + if (gb->io_registers[index_reg] & 0x80) { + gb->io_registers[index_reg]++; + gb->io_registers[index_reg] |= 0x80; + } return; } - uint8_t index_reg = (addr & 0xFF) - 1; ((addr & 0xFF) == GB_IO_BGPD? gb->background_palettes_data : gb->sprite_palettes_data)[gb->io_registers[index_reg] & 0x3F] = value;