Skip to content

Commit

Permalink
DSi-based themes: Use already loaded unit code for DSi binaries check
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Nov 14, 2024
1 parent d7725ff commit 7d8ec9e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions romsel_dsimenutheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3153,7 +3153,7 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
infoCheckTimer++;
if (infoCheckTimer == 30) {
if (!dsiBinariesChecked) {
hasDsiBinaries = checkDsiBinaries(dirContents[scrn].at(CURPOS + PAGENUM * 40).name.c_str());
hasDsiBinaries = checkDsiBinaries(dirContents[scrn].at(CURPOS + PAGENUM * 40).name.c_str(), CURPOS);
}
dsiBinariesChecked = true;
if (!apChecked && checkIfShowAPMsg(dirContents[scrn].at(CURPOS + PAGENUM * 40).name)) {
Expand Down Expand Up @@ -3761,7 +3761,7 @@ std::string browseForFile(const std::vector<std::string_view> extensionList) {
&& isHomebrew[CURPOS] == 0
&& checkIfDSiMode(dirContents[scrn].at(CURPOS + PAGENUM * 40).name)) {
if (!dsiBinariesChecked && dsiFeatures() && (!ms().secondaryDevice || !bs().b4dsMode)) {
hasDsiBinaries = checkDsiBinaries(dirContents[scrn].at(CURPOS + PAGENUM * 40).name.c_str());
hasDsiBinaries = checkDsiBinaries(dirContents[scrn].at(CURPOS + PAGENUM * 40).name.c_str(), CURPOS);
dsiBinariesChecked = true;
}

Expand Down
13 changes: 6 additions & 7 deletions romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ u8 unitCode[40] = {0};
u16 headerCRC[40] = {0};
u32 a7mbk6[40] = {0};

bool checkDsiBinaries(const char* filename) {
bool checkDsiBinaries(const char* filename, const int num) {
if (unitCode[num] == 0) {
return true;
}

FILE *ndsFile = fopen(filename, "rb");

sNDSHeaderExt ndsHeader;

fread(&ndsHeader, 1, sizeof(ndsHeader), ndsFile);

if (ndsHeader.unitCode == 0) {
fclose(ndsFile);
return true;
}

if (ndsHeader.arm9iromOffset < 0x8000 || ndsHeader.arm9iromOffset >= 0x20000000
|| ndsHeader.arm7iromOffset < 0x8000 || ndsHeader.arm7iromOffset >= 0x20000000) {
fclose(ndsFile);
Expand Down Expand Up @@ -97,7 +96,7 @@ u32 getSDKVersion(FILE *ndsFile)
* @param filename NDS ROM filename.
* @return true on success; false if no AP.
*/
bool checkRomAP(const char* filename, int num)
bool checkRomAP(const char* filename, const int num)
{
{
char apFixPath[256];
Expand Down
4 changes: 2 additions & 2 deletions romsel_dsimenutheme/arm9/source/ndsheaderbanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ typedef enum {
N3DS_LANG_CHINESE_TRADITIONAL = 11,
} sNDSLanguage;

bool checkDsiBinaries(const char* filename);
bool checkDsiBinaries(const char* filename, const int num);

/**
* Get SDK version from an NDS file.
Expand All @@ -267,7 +267,7 @@ u32 getSDKVersion(FILE* ndsFile);
* @param filename NDS ROM filename.
* @return true on success; false if no AP.
*/
bool checkRomAP(const char* filename, int num);
bool checkRomAP(const char* filename, const int num);

extern char gameTid[40][5];
extern u8 romVersion[40];
Expand Down
2 changes: 1 addition & 1 deletion romsel_dsimenutheme/arm9/source/perGameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void perGameSettings (std::string filename, bool* dsiBinariesFound, bool* dsiBin
fread(&clonebootFlag, sizeof(u32), 1, f_nds_file);
usesCloneboot = (clonebootFlag == 0x16361);
if (!(*dsiBinariesChecked)) {
*dsiBinariesFound = checkDsiBinaries(filenameForInfo.c_str());
*dsiBinariesFound = checkDsiBinaries(filenameForInfo.c_str(), CURPOS);
*dsiBinariesChecked = true;
}
}
Expand Down

0 comments on commit 7d8ec9e

Please sign in to comment.