Skip to content
This repository was archived by the owner on Dec 24, 2018. It is now read-only.

Commit e39495d

Browse files
committed
Add compatibility checking
ALSO: Add NSMB to donor SDK list
1 parent 0bdcb85 commit e39495d

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

gui/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ VERSION_PARTS := $(subst ., ,$(VERSION_DIRTY))
3030

3131
VERSION_MAJOR := 5
3232
VERSION_MINOR := 4
33-
VERSION_MICRO := 1
33+
VERSION_MICRO := 2
3434

3535
#VERSION_MAJOR := $(word 1, $(VERSION_PARTS))
3636
#VERSION_MINOR := $(word 2, $(VERSION_PARTS))

gui/source/main.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ void SetDonorSDK() {
470470
static const char sdk3_list[][4] = {
471471
"AMC", // Mario Kart DS
472472
"EKD", // Ermii Kart DS (Mario Kart DS hack)
473+
"A2D", // New Super Mario Bros.
473474
"ADA", // Pokemon Diamond
474475
"APA", // Pokemon Pearl
475476
"ARZ", // Rockman ZX/MegaMan ZX
@@ -527,6 +528,39 @@ void SetDonorSDK() {
527528

528529
}
529530

531+
/**
532+
* Set compatibility check for a specific game.
533+
*/
534+
void SetCompatibilityCheck() {
535+
char nds_path[256];
536+
snprintf(nds_path, sizeof(nds_path), "sdmc:/%s/%s", settings.ui.romfolder.c_str() , rom);
537+
FILE *f_nds_file = fopen(nds_path, "rb");
538+
539+
char game_TID[5];
540+
grabTID(f_nds_file, game_TID);
541+
game_TID[4] = 0;
542+
game_TID[3] = 0;
543+
fclose(f_nds_file);
544+
545+
settings.twl.run_timeout = true;
546+
547+
// Check for games that don't need compatibility checks.
548+
static const char list[][4] = {
549+
"###", // Homebrew
550+
"NTR", // Download Play ROMs
551+
"AZD", // The Legend of Zelda: Twilight Princess E3 Trailer
552+
};
553+
554+
// TODO: If the list gets large enough, switch to bsearch().
555+
for (unsigned int i = 0; i < sizeof(list)/sizeof(list[0]); i++) {
556+
if (!memcmp(game_TID, list[i], 3)) {
557+
// Found a match.
558+
settings.twl.run_timeout = false;
559+
break;
560+
}
561+
}
562+
}
563+
530564
/**
531565
* Set MPU settings for a specific game.
532566
*/
@@ -780,9 +814,11 @@ static void SaveBootstrapConfig(void)
780814
// Set ROM path if ROM is selected
781815
if (!settings.twl.launchslot1) {
782816
SetDonorSDK();
817+
SetCompatibilityCheck();
783818
SetMPUSettings();
784819
bootstrapini.SetString(bootstrapini_ndsbootstrap, bootstrapini_ndspath, fat+settings.ui.romfolder+slashchar+rom);
785820
bootstrapini.SetInt(bootstrapini_ndsbootstrap, "DONOR_SDK_VER", settings.twl.donorSdkVer);
821+
bootstrapini.SetInt(bootstrapini_ndsbootstrap, "CHECK_COMPATIBILITY", settings.twl.run_timeout);
786822
bootstrapini.SetInt(bootstrapini_ndsbootstrap, bootstrapini_mpuregion, settings.twl.mpuregion);
787823
bootstrapini.SetInt(bootstrapini_ndsbootstrap, bootstrapini_mpusize, settings.twl.mpusize);
788824
if (gbarunnervalue == 0) {

gui/source/settings.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ typedef struct _Settings_t {
9191

9292
int donorSdkVer;
9393

94+
bool run_timeout;
95+
9496
int mpuregion; // Region 0, 1, 2, 3
9597
int mpusize; // Size 0, 1, 3145728
9698

0 commit comments

Comments
 (0)