From 4dd6a2930a863dac9a5c7c09ef6f9aaaca5c5ab0 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 2 Sep 2019 22:06:10 -0700 Subject: [PATCH] GB: Fix SGB controller incrementing (fixes #1104) --- CHANGES | 1 + src/gb/io.c | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index acffec166..5dc7c52c4 100644 --- a/CHANGES +++ b/CHANGES @@ -21,6 +21,7 @@ Other fixes: - GBA: Set up GPIO mapping on null and ELF ROM regions (fixes mgba.io/i/1481) - GBA Cheats: Fix value incrementing in CB slide codes (fixes mgba.io/i/1501) - Qt: Improve cheat view UX + - GB: Fix SGB controller incrementing (fixes mgba.io/i/1104) Misc: - Qt: Make mute menu option also toggle fast-forward mute (fixes mgba.io/i/1424) - Qt: Show error message if file failed to load diff --git a/src/gb/io.c b/src/gb/io.c index d044ad05d..86cbe8865 100644 --- a/src/gb/io.c +++ b/src/gb/io.c @@ -119,14 +119,11 @@ static void _writeSGBBits(struct GB* gb, int bits) { if (gb->sgbBit > 128) { switch (bits) { case 1: - gb->sgbBit |= 2; - break; - case 2: - gb->sgbBit |= 4; + gb->sgbBit ^= 2; break; case 3: - if (gb->sgbBit == 135) { - gb->sgbBit &= ~6; + if (gb->sgbBit == 131) { + gb->sgbBit &= ~2; gb->sgbCurrentController = (gb->sgbCurrentController + 1) & gb->sgbControllers; } break;