git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit eaccd792ed75738603c97fc6367e9bf8bfb41573
parent 5127cb00221e41c8f1abda77f8ecc040856a4b91
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Sat, 18 Dec 2021 14:56:33 +0200

Fixes to safe reads, closes #422

Diffstat:
MCore/memory.c7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Core/memory.c b/Core/memory.c @@ -434,7 +434,9 @@ static uint8_t read_high_memory(GB_gameboy_t *gb, uint16_t addr) if (addr < 0xFF00) { if (gb->oam_write_blocked && !GB_is_cgb(gb)) { - GB_trigger_oam_bug_read(gb, addr); + if (!gb->disable_oam_corruption) { + GB_trigger_oam_bug_read(gb, addr); + } return 0xff; } @@ -705,6 +707,9 @@ uint8_t GB_read_memory(GB_gameboy_t *gb, uint16_t addr) uint8_t GB_safe_read_memory(GB_gameboy_t *gb, uint16_t addr) { + if (unlikely(addr == 0xFF00 + GB_IO_JOYP)) { + return gb->io_registers[GB_IO_JOYP]; + } gb->disable_oam_corruption = true; uint8_t data = read_map[addr >> 12](gb, addr); gb->disable_oam_corruption = false;

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.