all repos — mgba @ 32a515ee7fa851943ac8c73860cc0bf5a96a0913

mGBA Game Boy Advance Emulator

GBA IO: Fix regression breaking keyCallbacks
Vicki Pfau vi@endrift.com
Tue, 25 Feb 2020 18:11:41 -0800
commit

32a515ee7fa851943ac8c73860cc0bf5a96a0913

parent

03d85b44d2e7d65f458fbe1cf5600edfb3699676

1 files changed, 18 insertions(+), 20 deletions(-)

jump to
M src/gba/io.csrc/gba/io.c

@@ -723,8 +723,7 @@ case REG_TM3CNT_LO:

GBATimerUpdateRegister(gba, 3, 2); break; - case REG_KEYINPUT: - { + case REG_KEYINPUT: { size_t c; for (c = 0; c < mCoreCallbacksListSize(&gba->coreCallbacks); ++c) { struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&gba->coreCallbacks, c);

@@ -732,29 +731,28 @@ if (callbacks->keysRead) {

callbacks->keysRead(callbacks->context); } } - } - uint16_t input = 0; - if (gba->keyCallback) { - input = gba->keyCallback->readKeys(gba->keyCallback); - if (gba->keySource) { - *gba->keySource = input; - } - } else if (gba->keySource) { - input = *gba->keySource; - if (!gba->allowOpposingDirections) { - unsigned rl = input & 0x030; - unsigned ud = input & 0x0C0; - input &= 0x30F; - if (rl != 0x030) { - input |= rl; + uint16_t input = 0; + if (gba->keyCallback) { + input = gba->keyCallback->readKeys(gba->keyCallback); + if (gba->keySource) { + *gba->keySource = input; } - if (ud != 0x0C0) { - input |= ud; + } else if (gba->keySource) { + input = *gba->keySource; + if (!gba->allowOpposingDirections) { + unsigned rl = input & 0x030; + unsigned ud = input & 0x0C0; + input &= 0x30F; + if (rl != 0x030) { + input |= rl; + } + if (ud != 0x0C0) { + input |= ud; + } } } return 0x3FF ^ input; } - case REG_SIOCNT: return gba->sio.siocnt; case REG_RCNT: