From 1ab46f704f9885afbc517e4267cf3860e7b46d68 Mon Sep 17 00:00:00 2001 From: Fabrice de Gans Date: Sun, 19 Mar 2023 12:11:43 -0700 Subject: [PATCH] Update SIOCNT when the link driver is disconnected Some software (like the EU version of Digimon Racing) relies on the SIOCNT register being properly updated when no cable is connected. Otherwise, they risk getting stuck in a loop waiting for an update on the SIOCNT register. --- src/gba/GBALink.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gba/GBALink.cpp b/src/gba/GBALink.cpp index 0b18620e..d12a37f1 100644 --- a/src/gba/GBALink.cpp +++ b/src/gba/GBALink.cpp @@ -669,6 +669,20 @@ ConnectionState InitLink(LinkMode mode) void StartLink(uint16_t siocnt) { if (!linkDriver || !linkDriver->start) { + // We still need to update the SIOCNT register for consistency. Some + // games (e.g. Digimon Racing EUR) will be stuck in an infinite loop + // waiting git the SIOCNT register to be updated otherwise. + // This mimicks the NO_LINK behavior. + if (siocnt & 0x80) { + siocnt &= 0xff7f; + if (siocnt & 1 && (siocnt & 0x4000)) { + UPDATE_REG(COMM_SIOCNT, 0xFF); + IF |= 0x80; + UPDATE_REG(0x202, IF); + siocnt &= 0x7f7f; + } + } + UPDATE_REG(COMM_SIOCNT, siocnt); return; }