Writing to BGPD/OBPD while it’s blocked still increases BGPI/OBPI if needed. Fixes #145

This commit is contained in:
Lior Halphon 2019-01-19 23:37:44 +02:00
parent 73a54049d2
commit b996ed9220
1 changed files with 6 additions and 1 deletions

View File

@ -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;