From 2266ecf86ec1f03c4a9de96138d89c3cbafee48c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 16 Feb 2016 23:40:02 -0800 Subject: [PATCH] GB IO: Fix edge cases for JOYP --- src/gb/io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gb/io.c b/src/gb/io.c index 542593376..b392c7d52 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -359,14 +359,16 @@ void GBIOWrite(struct GB* gb, unsigned address, uint8_t value) { 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);