From 53ce6fb0541954ef13a57fa5776d81c8569fce4c Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Tue, 23 Jul 2019 19:06:28 +0800 Subject: [PATCH] libretro: add SIO Control register (GBA) - emulate SIOCNT reg, which is still needed for some games to trigger IRQ's even in single, non-link mode - Fixes Digimon Racing (Europe) stuck in intro as reported in libretro docs page https://docs.libretro.com/library/vba_m/#compatibility - Related PR: https://github.com/libretro/vbam-libretro/commit/f9efb79a7d5ce3463987b260f558cf90ae3289f0#diff-385704891f00846c986e9056b5d7c5a5 --- src/libretro/libretro.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/libretro/libretro.cpp b/src/libretro/libretro.cpp index 777e9565..06ca7979 100644 --- a/src/libretro/libretro.cpp +++ b/src/libretro/libretro.cpp @@ -90,6 +90,8 @@ bool EmuReseted; int winGbPrinterEnabled; bool gba_joybus_active = false; +#define UPDATE_REG(address, value) WRITE16LE(((uint16_t*)&ioMem[address]), value) + LinkMode GetLinkMode() { return LINK_DISCONNECTED; @@ -97,7 +99,10 @@ LinkMode GetLinkMode() void StartGPLink(uint16_t value) { - WRITE16LE(((uint16_t*)&ioMem[COMM_RCNT]), value); + if (!ioMem) + return; + + UPDATE_REG(COMM_RCNT, value); } void LinkUpdate(int ticks) @@ -106,6 +111,23 @@ void LinkUpdate(int ticks) void StartLink(uint16_t siocnt) { +/* log("'s' siocnt = %04x\n", siocnt); */ + + if (!ioMem) + return; + + 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); } void CheckLinkConnection()