SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit b5eea012cc6e5785a6aa40c5d9ad1592d67f85c7 parent 6a8db89ae5f6ed01c7f977c8c7037a0ff6fa1325 Author: Lior Halphon <LIJI32@gmail.com> Date: Sat, 5 Feb 2022 17:43:48 +0200 STAT reads 0 during mode 2 if DMA is active Diffstat:
| M | Core/display.c | 3 | +++ |
| M | Core/memory.c | 5 | +++++ |
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Core/display.c b/Core/display.c @@ -397,6 +397,9 @@ void GB_set_light_temperature(GB_gameboy_t *gb, double temperature) void GB_STAT_update(GB_gameboy_t *gb) { if (!(gb->io_registers[GB_IO_LCDC] & 0x80)) return; + if (GB_is_dma_active(gb) && (gb->io_registers[GB_IO_STAT] & 3) == 2) { + gb->io_registers[GB_IO_STAT] &= ~3; + } bool previous_interrupt_line = gb->stat_interrupt_line; /* Set LY=LYC bit */ diff --git a/Core/memory.c b/Core/memory.c @@ -1471,6 +1471,7 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) gb->dma_current_dest = 0xFF; gb->dma_current_src = value << 8; gb->io_registers[GB_IO_DMA] = value; + GB_STAT_update(gb); return; case GB_IO_SVBK: if (gb->cgb_mode || (GB_is_cgb(gb) && !gb->boot_rom_finished)) { @@ -1701,6 +1702,10 @@ void GB_dma_run(GB_gameboy_t *gb) cycles -= 4; if (gb->dma_current_dest >= 0xa0) { gb->dma_current_dest++; + if (gb->display_state == 8) { + gb->io_registers[GB_IO_STAT] |= 2; + GB_STAT_update(gb); + } break; } if (unlikely(gb->hdma_in_progress && (gb->hdma_steps_left > 1 || (gb->hdma_current_dest & 0xF) != 0xF))) {
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.