Improved handling of DSi roms and DSiWare. Fixes some system tools DSi roms being misdetected as DSiWare (related to #23)

This commit is contained in:
Gericom
2025-12-06 19:56:48 +01:00
parent 0d0fa445c9
commit 656f696411
6 changed files with 84 additions and 75 deletions

View File

@@ -63,9 +63,11 @@ struct nds_header_ntr_t
static_assert(sizeof(nds_header_ntr_t) == 0x170, "Invalid size for nds_header_ntr_t");
struct nds_header_twl_t
#define NDS_HEADER_TWL_ACCESS_CONTROL_SD_ACCESS (1 << 3)
#define NDS_HEADER_TWL_ACCESS_CONTROL_NAND_ACCESS (1 << 4)
struct nds_header_twl_t : public nds_header_ntr_t
{
nds_header_ntr_t ntrHeader;
u8 gap170[0x10];
u32 globalMbkSettings[5]; // slot mapping
u32 arm9MbkSettings[3]; // wram mapping
@@ -130,14 +132,19 @@ struct nds_header_twl_t
u8 gapF00[0x80];
u8 headerRsaSha1Signature[0x80];
constexpr bool IsTwlRom() const
{
return ntrHeader.IsTwlRom();
}
constexpr bool IsDsiWare() const
{
return IsTwlRom() && ((titleId >> 32) & 0xFF) != 0;
return IsTwlRom() && ((titleId >> 32) & 4) != 0;
}
constexpr bool HasSdAccess() const
{
return IsTwlRom() && (accessControl & NDS_HEADER_TWL_ACCESS_CONTROL_SD_ACCESS) != 0;
}
constexpr bool HasNandAccess() const
{
return IsTwlRom() && (accessControl & NDS_HEADER_TWL_ACCESS_CONTROL_NAND_ACCESS) != 0;
}
};