From 6a223ccd3f09099d6651fc0dce92cf159c2c7006 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 17 Sep 2017 16:46:10 -0700 Subject: [PATCH] GBA: Fix keypad IRQs not firing when extra buttons are pressed --- CHANGES | 1 + src/gba/core.c | 1 - src/gba/gba.c | 6 ++---- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 853ed76b9..22bac2821 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,7 @@ Bugfixes: - GBA BIOS: Use core's VRAM variable instead of renderer's - GBA Savedata: Fix 512 byte EEPROM saving as 8kB (fixes mgba.io/i/877) - SDL: Fix potential race condition when pressing keys (fixes mgba.io/i/872) + - GBA: Fix keypad IRQs not firing when extra buttons are pressed Misc: - Qt: Don't rebuild library view if style hasn't changed - SDL: Fix 2.0.5 build on macOS under some circumstances diff --git a/src/gba/core.c b/src/gba/core.c index 6736af8eb..e223e8ddc 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -489,7 +489,6 @@ static void _GBACoreAddKeys(struct mCore* core, uint32_t keys) { static void _GBACoreClearKeys(struct mCore* core, uint32_t keys) { struct GBACore* gbacore = (struct GBACore*) core; gbacore->keys &= ~keys; - GBATestKeypadIRQ(core->board); } static int32_t _GBACoreFrameCounter(const struct mCore* core) { diff --git a/src/gba/gba.c b/src/gba/gba.c index 1d44bc563..a6614300a 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -695,19 +695,17 @@ void GBATestKeypadIRQ(struct GBA* gba) { return; } int isAnd = keycnt & 0x8000; - uint16_t keyInput; - if (!gba->keySource) { // TODO? return; } keycnt &= 0x3FF; - keyInput = *gba->keySource; + uint16_t keyInput = *gba->keySource & keycnt; if (isAnd && keycnt == keyInput) { GBARaiseIRQ(gba, IRQ_KEYPAD); - } else if (!isAnd && keycnt & keyInput) { + } else if (!isAnd && keyInput) { GBARaiseIRQ(gba, IRQ_KEYPAD); } }