aboutsummaryrefslogtreecommitdiff
path: root/src/NDS.cpp
diff options
context:
space:
mode:
authorJesse Talavera <jesse@jesse.tg>2023-12-15 08:54:41 -0500
committerGitHub <noreply@github.com>2023-12-15 14:54:41 +0100
commit24c402af51fe9c0537582173fc48d1ad3daff459 (patch)
tree854213830c1565e0fd40571c80294741822a2d21 /src/NDS.cpp
parentc867a7f1c09b3c5f07e0772fcddabce07bcd7fe7 (diff)
Fix detection of native NDS ARM BIOS images (#1910)
* Fix detection of native NDS ARM BIOS images - Instead of checking for built-in BIOS images, now the altered methods check for native ones - The CRC32 must match exactly; patched BIOS images will result in `false` * Encapsulate `NDS::ARM9BIOS` and `ARM7BIOS` - Also compute the checksum only when setting the BIOS
Diffstat (limited to 'src/NDS.cpp')
-rw-r--r--src/NDS.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp
index 4fa5eef..ed68b68 100644
--- a/src/NDS.cpp
+++ b/src/NDS.cpp
@@ -92,6 +92,8 @@ NDS::NDS(NDSArgs&& args, int type) noexcept :
ConsoleType(type),
ARM7BIOS(args.ARM7BIOS),
ARM9BIOS(args.ARM9BIOS),
+ ARM7BIOSNative(CRC32(ARM7BIOS.data(), ARM7BIOS.size()) == ARM7BIOSCRC32),
+ ARM9BIOSNative(CRC32(ARM9BIOS.data(), ARM9BIOS.size()) == ARM9BIOSCRC32),
JIT(*this, args.JIT),
SPU(*this, args.BitDepth, args.Interpolation),
GPU(*this, std::move(args.Renderer3D)),
@@ -270,7 +272,7 @@ bool NDS::NeedsDirectBoot() const
return true;
// FreeBIOS requires direct boot (it can't boot firmware)
- if (IsLoadedARM7BIOSBuiltIn() || IsLoadedARM9BIOSBuiltIn())
+ if (!IsLoadedARM9BIOSKnownNative() || !IsLoadedARM7BIOSKnownNative())
return true;
return false;
@@ -286,7 +288,7 @@ void NDS::SetupDirectBoot()
// 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())
+ if (!IsLoadedARM9BIOSKnownNative())
{
memcpy(ARM9BIOS.data() + 0x20, header.NintendoLogo, 0x9C);
}
@@ -756,6 +758,18 @@ void NDS::LoadBIOS()
Reset();
}
+void NDS::SetARM7BIOS(const std::array<u8, ARM7BIOSSize>& bios) noexcept
+{
+ ARM7BIOS = bios;
+ ARM7BIOSNative = CRC32(ARM7BIOS.data(), ARM7BIOS.size()) == ARM7BIOSCRC32;
+}
+
+void NDS::SetARM9BIOS(const std::array<u8, ARM9BIOSSize>& bios) noexcept
+{
+ ARM9BIOS = bios;
+ ARM9BIOSNative = CRC32(ARM9BIOS.data(), ARM9BIOS.size()) == ARM9BIOSCRC32;
+}
+
u64 NDS::NextTarget()
{
u64 minEvent = UINT64_MAX;