@@ -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 ) {
0 commit comments