mirror of https://github.com/mgba-emu/mgba.git
GB Video: Fix input iteration on SGB (fixes #1064)
This commit is contained in:
parent
279862261b
commit
5d0bbcd512
22
src/gb/io.c
22
src/gb/io.c
|
@ -113,13 +113,26 @@ static void _writeSGBBits(struct GB* gb, int bits) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gb->currentSgbBits = bits;
|
gb->currentSgbBits = bits;
|
||||||
if (bits == 3) {
|
|
||||||
gb->sgbCurrentController = (gb->sgbCurrentController + 1) & gb->sgbControllers;
|
|
||||||
}
|
|
||||||
if (gb->sgbBit == 128 && bits == 2) {
|
if (gb->sgbBit == 128 && bits == 2) {
|
||||||
GBVideoWriteSGBPacket(&gb->video, gb->sgbPacket);
|
GBVideoWriteSGBPacket(&gb->video, gb->sgbPacket);
|
||||||
++gb->sgbBit;
|
++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) {
|
if (gb->sgbBit >= 128) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -511,8 +524,7 @@ static uint8_t _readKeys(struct GB* gb) {
|
||||||
}
|
}
|
||||||
switch (gb->memory.io[REG_JOYP] & 0x30) {
|
switch (gb->memory.io[REG_JOYP] & 0x30) {
|
||||||
case 0x30:
|
case 0x30:
|
||||||
// TODO: Increment
|
keys = 0xF - gb->sgbCurrentController;
|
||||||
keys = (gb->video.sgbCommandHeader >> 3) == SGB_MLT_REQ ? 0xF - gb->sgbCurrentController : 0;
|
|
||||||
break;
|
break;
|
||||||
case 0x20:
|
case 0x20:
|
||||||
keys >>= 4;
|
keys >>= 4;
|
||||||
|
|
|
@ -703,6 +703,7 @@ void GBVideoWriteSGBPacket(struct GBVideo* video, uint8_t* data) {
|
||||||
break;
|
break;
|
||||||
case SGB_MLT_REQ:
|
case SGB_MLT_REQ:
|
||||||
video->p->sgbControllers = video->sgbPacketBuffer[1] & 0x3;
|
video->p->sgbControllers = video->sgbPacketBuffer[1] & 0x3;
|
||||||
|
video->p->sgbCurrentController = 0;
|
||||||
return;
|
return;
|
||||||
case SGB_MASK_EN:
|
case SGB_MASK_EN:
|
||||||
video->renderer->sgbRenderMode = video->sgbPacketBuffer[1] & 0x3;
|
video->renderer->sgbRenderMode = video->sgbPacketBuffer[1] & 0x3;
|
||||||
|
|
Loading…
Reference in New Issue