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
This commit is contained in:
Jesse Talavera
2023-12-15 08:54:41 -05:00
committed by GitHub
parent c867a7f1c0
commit 24c402af51
6 changed files with 49 additions and 15 deletions

View File

@ -39,6 +39,7 @@
#include "MemRegion.h"
#include "ARMJIT_Memory.h"
#include "ARM.h"
#include "CRC32.h"
#include "DMA.h"
#include "FreeBIOS.h"
@ -227,7 +228,7 @@ private:
bool EnableJIT;
#endif
public:
public: // TODO: Encapsulate the rest of these members
int ConsoleType;
int CurCPU;
@ -261,8 +262,14 @@ public:
u8 ROMSeed0[2*8];
u8 ROMSeed1[2*8];
protected:
// These BIOS arrays should be declared *before* the component objects (JIT, SPI, etc.)
// so that they're initialized before the component objects' constructors run.
std::array<u8, ARM9BIOSSize> ARM9BIOS;
std::array<u8, ARM7BIOSSize> ARM7BIOS;
bool ARM9BIOSNative;
bool ARM7BIOSNative;
public: // TODO: Encapsulate the rest of these members
u16 ARM7BIOSProt;
u8* MainRAM;
@ -310,8 +317,19 @@ public:
void SetARM7RegionTimings(u32 addrstart, u32 addrend, u32 region, int buswidth, int nonseq, int seq);
void LoadBIOS();
[[nodiscard]] bool IsLoadedARM9BIOSBuiltIn() const noexcept { return ARM9BIOS == bios_arm9_bin; }
[[nodiscard]] bool IsLoadedARM7BIOSBuiltIn() const noexcept { return ARM7BIOS == bios_arm7_bin; }
/// @return \c true if the loaded ARM9 BIOS image is a known dump
/// of a native DS-compatible ARM9 BIOS.
[[nodiscard]] bool IsLoadedARM9BIOSKnownNative() const noexcept { return ARM9BIOSNative; }
[[nodiscard]] const std::array<u8, ARM9BIOSSize>& GetARM9BIOS() const noexcept { return ARM9BIOS; }
void SetARM9BIOS(const std::array<u8, ARM9BIOSSize>& bios) noexcept;
[[nodiscard]] const std::array<u8, ARM7BIOSSize>& GetARM7BIOS() const noexcept { return ARM7BIOS; }
void SetARM7BIOS(const std::array<u8, ARM7BIOSSize>& bios) noexcept;
/// @return \c true if the loaded ARM7 BIOS image is a known dump
/// of a native DS-compatible ARM9 BIOS.
[[nodiscard]] bool IsLoadedARM7BIOSKnownNative() const noexcept { return ARM7BIOSNative; }
[[nodiscard]] NDSCart::CartCommon* GetNDSCart() { return NDSCartSlot.GetCart(); }
[[nodiscard]] const NDSCart::CartCommon* GetNDSCart() const { return NDSCartSlot.GetCart(); }