GB IO: Fix edge cases for JOYP

This commit is contained in:
Jeffrey Pfau 2016-02-16 23:40:02 -08:00
parent f47b6881fc
commit 2266ecf86e
1 changed files with 5 additions and 3 deletions

View File

@ -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);