From 31609319deaab51cea6113d976681b83f628bfb2 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 9 Nov 2019 14:45:38 +0200 Subject: [PATCH] Fix the set_joyp API --- Core/memory.c | 6 +++++- Core/sgb.c | 6 +----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Core/memory.c b/Core/memory.c index 7e74a80..003bb77 100644 --- a/Core/memory.c +++ b/Core/memory.c @@ -753,7 +753,11 @@ static void write_high_memory(GB_gameboy_t *gb, uint16_t addr, uint8_t value) return; case GB_IO_JOYP: - if ((gb->io_registers[GB_IO_JOYP] & 0x30) != (value & 0x30)) { + if (gb->joyp_write_callback) { + gb->joyp_write_callback(gb, value); + GB_update_joyp(gb); + } + else if ((gb->io_registers[GB_IO_JOYP] & 0x30) != (value & 0x30)) { GB_sgb_write(gb, value); gb->io_registers[GB_IO_JOYP] = value & 0xF0; GB_update_joyp(gb); diff --git a/Core/sgb.c b/Core/sgb.c index 8539238..7ebeae0 100644 --- a/Core/sgb.c +++ b/Core/sgb.c @@ -385,11 +385,7 @@ static void command_ready(GB_gameboy_t *gb) } void GB_sgb_write(GB_gameboy_t *gb, uint8_t value) -{ - if (gb->joyp_write_callback) { - gb->joyp_write_callback(gb, value); - } - +{ if (!GB_is_sgb(gb)) return; if (!GB_is_hle_sgb(gb)) { /* Notify via callback */