From ed23ae3ef76c05cee93fa40c5545ec97561403fd Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 15 Jun 2021 20:44:24 -0700 Subject: [PATCH] GBA SIO: Fix SI value for unattached MULTI mode --- CHANGES | 1 + src/gba/sio/lockstep.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5b7a317f1..b04428adc 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Emulation fixes: - GB Video: Clear VRAM on reset (fixes mgba.io/i/2152) - GBA SIO: Add missing NORMAL8 implementation bits (fixes mgba.io/i/2172) - GBA SIO: Fix missing interrupt on an unattached NORMAL transfer + - GBA SIO: Fix SI value for unattached MULTI mode - GBA Video: Revert scanline latching changes (fixes mgba.io/i/2153, mgba.io/i/2149) Other fixes: - 3DS: Fix disabling "wide" mode on 2DS (fixes mgba.io/i/2167) diff --git a/src/gba/sio/lockstep.c b/src/gba/sio/lockstep.c index e243e5f86..7cb2d858a 100644 --- a/src/gba/sio/lockstep.c +++ b/src/gba/sio/lockstep.c @@ -179,10 +179,14 @@ static uint16_t GBASIOLockstepNodeMultiWriteRegister(struct GBASIODriver* driver mLOG(GBA_SIO, DEBUG, "Lockstep %i: SIOCNT <- %04X", node->id, value); enum mLockstepPhase transferActive; + int attached; ATOMIC_LOAD(transferActive, node->p->d.transferActive); + ATOMIC_LOAD(attached, node->p->d.attached); + + driver->p->siocnt = GBASIOMultiplayerSetSlave(driver->p->siocnt, node->id || attached < 2); if (value & 0x0080 && transferActive == TRANSFER_IDLE) { - if (!node->id && GBASIOMultiplayerIsReady(node->d.p->siocnt)) { + if (!node->id && attached > 1 && GBASIOMultiplayerIsReady(node->d.p->siocnt)) { mLOG(GBA_SIO, DEBUG, "Lockstep %i: Transfer initiated", node->id); ATOMIC_STORE(node->p->d.transferActive, TRANSFER_STARTING); ATOMIC_STORE(node->p->d.transferCycles, GBASIOCyclesPerTransfer[GBASIOMultiplayerGetBaud(node->d.p->siocnt)][node->p->d.attached - 1]);