From aa3f4c0e6e428da6e65eb97588f0d05c94ae92f0 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 | 4 ++++ src/gba/sio/lockstep.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 1643496a9..f80f7f0ac 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +0.9.3: (Future) +Emulation fixes: + - GBA SIO: Fix SI value for unattached MULTI mode + 0.9.2: (2021-07-10) Emulation fixes: - GB Video: Clear VRAM on reset (fixes mgba.io/i/2152) diff --git a/src/gba/sio/lockstep.c b/src/gba/sio/lockstep.c index e5e7cef6c..ba1f3f0af 100644 --- a/src/gba/sio/lockstep.c +++ b/src/gba/sio/lockstep.c @@ -180,10 +180,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]);