Skip to content

Commit

Permalink
Correct read emulation of the BANK register while still in the boot ROM
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Jul 29, 2023
1 parent 10d9963 commit 4ab256d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Core/gb.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ enum {
/* Missing */

GB_IO_VBK = 0x4F, // CGB Mode Only - VRAM Bank
GB_IO_BANK = 0x50, // Write to disable the BIOS mapping
GB_IO_BANK = 0x50, // Write to disable the boot ROM mapping

/* CGB DMA */
GB_IO_HDMA1 = 0x51, // CGB Mode Only - New DMA Source, High
Expand Down
5 changes: 3 additions & 2 deletions Core/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr)
return 0xFF;
}
return (gb->io_registers[GB_IO_KEY1] & 0x7F) | (gb->cgb_double_speed? 0xFE : 0x7E);

case GB_IO_BANK:
return 0xFE | gb->boot_rom_finished;
case GB_IO_RP: {
if (!gb->cgb_mode) return 0xFF;
/* You will read your own IR LED if it's on. */
Expand Down Expand Up @@ -1572,7 +1573,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value)
return;

case GB_IO_BANK:
gb->boot_rom_finished = true;
gb->boot_rom_finished |= value & 1;
return;

case GB_IO_KEY0:
Expand Down

0 comments on commit 4ab256d

Please sign in to comment.