From 69491004460fd623b81cfa3ad4bcede3e8d6250c Mon Sep 17 00:00:00 2001
From: Nadia Holmquist Pedersen <nadia@nhp.sh>
Date: Fri, 8 Dec 2023 18:29:30 +0100
Subject: Fix GBA<->DS comm not working when using FreeBIOS

Thanks CasualPokePlayer for pointing this out
---
 src/NDS.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/NDS.cpp b/src/NDS.cpp
index 54aa270..c00aa51 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -284,6 +284,13 @@ void NDS::SetupDirectBoot()
     const u8* cartrom = NDSCartSlot.GetCart()->GetROM();
     MapSharedWRAM(3);
 
+    // Copy the Nintendo logo from the NDS ROM header to the ARM9 BIOS if using FreeBIOS
+    // Games need this for DS<->GBA comm to work
+    if (IsLoadedARM9BIOSBuiltIn())
+    {
+        memcpy(ARM9BIOS.data() + 0x20, header.NintendoLogo, 0x9C);
+    }
+
     // setup main RAM data
 
     for (u32 i = 0; i < 0x170; i+=4)
@@ -4192,4 +4199,4 @@ void NDS::ARM7IOWrite32(u32 addr, u32 val)
     Log(LogLevel::Debug, "unknown ARM7 IO write32 %08X %08X %08X\n", addr, val, ARM7.R[15]);
 }
 
-}
\ No newline at end of file
+}
-- 
cgit v1.2.3