all repos — mgba @ 2266ecf86ec1f03c4a9de96138d89c3cbafee48c

mGBA Game Boy Advance Emulator

GB IO: Fix edge cases for JOYP
Jeffrey Pfau jeffrey@endrift.com
Tue, 16 Feb 2016 23:40:02 -0800
commit

2266ecf86ec1f03c4a9de96138d89c3cbafee48c

parent

f47b6881fc2d3f984794c33ff48c25efe4303a3a

1 files changed, 5 insertions(+), 3 deletions(-)

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

@@ -359,14 +359,16 @@

static uint8_t _readKeys(struct GB* gb) { uint8_t keys = *gb->keySource; switch (gb->memory.io[REG_JOYP] & 0x30) { + case 0x30: + keys = 0; + break; case 0x20: keys >>= 4; break; case 0x10: break; - default: - // ??? - keys = 0; + case 0x00: + keys |= keys >> 4; break; } return 0xC0 | (gb->memory.io[REG_JOYP] | 0xF) ^ (keys & 0xF);