Skip to content

Commit

Permalink
GB I/O: Fix SGB command clocking (fixes #1029)
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Mar 31, 2018
1 parent 36de596 commit 16eed8e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gb/io.c
Expand Up @@ -106,7 +106,7 @@ static const uint8_t _registerMask[] = {

static void _writeSGBBits(struct GB* gb, int bits) {
if (!bits) {
gb->sgbBit = 0;
gb->sgbBit = -1;
memset(gb->sgbPacket, 0, sizeof(gb->sgbPacket));
}
if (bits == gb->currentSgbBits) {
Expand All @@ -122,9 +122,12 @@ static void _writeSGBBits(struct GB* gb, int bits) {
}
switch (bits) {
case 1:
if (gb->sgbBit < 0) {
return;
}
gb->sgbPacket[gb->sgbBit >> 3] |= 1 << (gb->sgbBit & 7);
// Fall through
case 2:
break;
case 3:
++gb->sgbBit;
default:
break;
Expand Down

0 comments on commit 16eed8e

Please sign in to comment.