GB Video: Fix input iteration on SGB (fixes #1064)
Vicki Pfau vi@endrift.com
Tue, 24 Apr 2018 11:21:28 -0700
2 files changed,
18 insertions(+),
5 deletions(-)
M
src/gb/io.c
→
src/gb/io.c
@@ -113,12 +113,25 @@ if (bits == gb->currentSgbBits) {
return; } gb->currentSgbBits = bits; - if (bits == 3) { - gb->sgbCurrentController = (gb->sgbCurrentController + 1) & gb->sgbControllers; - } if (gb->sgbBit == 128 && bits == 2) { GBVideoWriteSGBPacket(&gb->video, gb->sgbPacket); ++gb->sgbBit; + } + if (gb->sgbBit > 128) { + switch (bits) { + case 1: + gb->sgbBit |= 2; + break; + case 2: + gb->sgbBit |= 4; + break; + case 3: + if (gb->sgbBit == 135 && bits == 3 && !(gb->video.sgbCommandHeader & 7)) { + gb->sgbBit &= ~6; + gb->sgbCurrentController = (gb->sgbCurrentController + 1) & gb->sgbControllers; + } + break; + } } if (gb->sgbBit >= 128) { return;@@ -511,8 +524,7 @@ keys = 0;
} switch (gb->memory.io[REG_JOYP] & 0x30) { case 0x30: - // TODO: Increment - keys = (gb->video.sgbCommandHeader >> 3) == SGB_MLT_REQ ? 0xF - gb->sgbCurrentController : 0; + keys = 0xF - gb->sgbCurrentController; break; case 0x20: keys >>= 4;
M
src/gb/video.c
→
src/gb/video.c
@@ -703,6 +703,7 @@ case SGB_ATTR_SET:
break; case SGB_MLT_REQ: video->p->sgbControllers = video->sgbPacketBuffer[1] & 0x3; + video->p->sgbCurrentController = 0; return; case SGB_MASK_EN: video->renderer->sgbRenderMode = video->sgbPacketBuffer[1] & 0x3;