From 5a7b967cb5e7a63a3b1d163d5e77b79ee5857c8d Mon Sep 17 00:00:00 2001 From: Robz8 Date: Sun, 18 Feb 2018 22:24:41 -0700 Subject: [PATCH] Show message when trying to launch DSi-Exclusive/DSiWare game ALSO: Launch DSi-mode homebrew (or homebrew with DSi-extended header) with A button --- .../arm9/source/fileBrowse.cpp | 21 ++++++++++++++++--- romsel_dsimenutheme/arm9/source/iconTitle.cpp | 19 ++++++++++++----- romsel_dsimenutheme/arm9/source/main.cpp | 2 +- .../arm9/source/ndsheaderbanner.cpp | 2 ++ .../arm9/source/ndsheaderbanner.h | 2 ++ 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/romsel_dsimenutheme/arm9/source/fileBrowse.cpp b/romsel_dsimenutheme/arm9/source/fileBrowse.cpp index f25b34a12b..bb20375d92 100644 --- a/romsel_dsimenutheme/arm9/source/fileBrowse.cpp +++ b/romsel_dsimenutheme/arm9/source/fileBrowse.cpp @@ -35,6 +35,7 @@ #include "date.h" +#include "ndsheaderbanner.h" #include "iconTitle.h" #include "graphics/fontHandler.h" #include "graphics/graphics.h" @@ -348,6 +349,10 @@ string browseForFile(const vector extensionList, const char* username) for(int i = 0; i < 40; i++) { if (i+pagenum*40 < file_count) { if (romtype == 0) updateBannerSequence(dirContents[scrn].at(i+pagenum*40).isDirectory, dirContents[scrn].at(i+pagenum*40).name.c_str(), i); + else { + launchable[i] = true; + isHomebrew[i] = false; + } spawnedtitleboxes++; } } @@ -555,12 +560,16 @@ string browseForFile(const vector extensionList, const char* username) screenOffset = 0; cursorPosition = 0; */ } - else + else if (launchable[cursorPosition]) { mmEffectEx(&snd_launch); applaunch = true; applaunchprep = true; - useBootstrap = true; + if (!isHomebrew[cursorPosition]) { + useBootstrap = true; + } else { + useBootstrap = false; + } showbubble = false; showSTARTborder = false; @@ -576,6 +585,12 @@ string browseForFile(const vector extensionList, const char* username) // Return the chosen file return entry->name; + } else { + mmEffectEx(&snd_wrong); + int yPos = 160; + if (theme == 1) yPos -= 4; + printSmallCentered(false, yPos, "This game cannot be launched."); + for (int i = 0; i < 90; i++) swiWaitForVBlank(); } } @@ -695,7 +710,7 @@ string browseForFile(const vector extensionList, const char* username) int yPos = 160; if (theme == 1) yPos -= 4; printSmallCentered(false, yPos, "Donor ROM is set."); - for (int i = 0; i < 90; i++) swiWaitForVBlank(); + for (int i = 0; i < 90; i++) swiWaitForVBlank(); } } diff --git a/romsel_dsimenutheme/arm9/source/iconTitle.cpp b/romsel_dsimenutheme/arm9/source/iconTitle.cpp index edd975f33e..2019127416 100644 --- a/romsel_dsimenutheme/arm9/source/iconTitle.cpp +++ b/romsel_dsimenutheme/arm9/source/iconTitle.cpp @@ -47,6 +47,7 @@ extern int theme; static int iconTexID[10][8]; static int gbcTexID; static int nesTexID; +sNDSHeaderExt ndsHeader; sNDSBannerExt ndsBanner; static glImage ndsIcon[10][8][(32 / 32) * (256 / 32)]; @@ -230,6 +231,8 @@ void updateBannerSequence(bool isDir, const char* name, int num) bnriconframenumY[num] = 0; bannerFlip[num] = GL_FLIP_NONE; bnriconisDSi[num] = false; + launchable[num] = true; + isHomebrew[num] = false; if (isDir) { @@ -300,7 +303,6 @@ void updateBannerSequence(bool isDir, const char* name, int num) { // this is an nds file! FILE *fp; - unsigned int iconTitleOffset; int ret; // open file for reading info @@ -314,9 +316,9 @@ void updateBannerSequence(bool isDir, const char* name, int num) } - ret = fseek(fp, offsetof(tNDSHeader, bannerOffset), SEEK_SET); + ret = fseek(fp, 0, SEEK_SET); if (ret == 0) - ret = fread(&iconTitleOffset, sizeof (int), 1, fp); // read if seek succeed + ret = fread(&ndsHeader, sizeof (ndsHeader), 1, fp); // read if seek succeed else ret = 0; // if seek fails set to !=1 @@ -326,12 +328,19 @@ void updateBannerSequence(bool isDir, const char* name, int num) return; } - if (iconTitleOffset == 0) + if(ndsHeader.unitCode == 0x03 && strcmp(ndsHeader.gameCode, "####") != 0) { + launchable[num] = false; + } else if(ndsHeader.unitCode == 0x02 || ndsHeader.unitCode == 0x03) { + if(ndsHeader.arm9romOffset == 0x4000 && strcmp(ndsHeader.gameCode, "####") == 0) + isHomebrew[num] = true; + } + + if (ndsHeader.bannerOffset == 0) { fclose(fp); return; } - ret = fseek(fp, iconTitleOffset, SEEK_SET); + ret = fseek(fp, ndsHeader.bannerOffset, SEEK_SET); if (ret == 0) ret = fread(&ndsBanner, sizeof (ndsBanner), 1, fp); // read if seek succeed else diff --git a/romsel_dsimenutheme/arm9/source/main.cpp b/romsel_dsimenutheme/arm9/source/main.cpp index c17874e1e8..df685c2c5f 100644 --- a/romsel_dsimenutheme/arm9/source/main.cpp +++ b/romsel_dsimenutheme/arm9/source/main.cpp @@ -872,7 +872,7 @@ int main(int argc, char **argv) { stop(); } } else { - iprintf ("Running %s with %d parameters\n", argarray[0], argarray.size()); + //iprintf ("Running %s with %d parameters\n", argarray[0], argarray.size()); int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0]); char text[32]; snprintf (text, sizeof(text), "Start failed. Error %i", err); diff --git a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp index 726493d195..77ca72e35d 100644 --- a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp +++ b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp @@ -93,6 +93,8 @@ int bannerFlip[40] = {GL_FLIP_NONE}; // bnriconisDSi[] bool bnriconisDSi[40] = {false}; +bool launchable[40] = {true}; +bool isHomebrew[40] = {false}; /** * Get banner sequence from banner file. diff --git a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h index 49ecb1a56d..aa015b6f25 100644 --- a/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h +++ b/romsel_dsimenutheme/arm9/source/ndsheaderbanner.h @@ -234,6 +234,8 @@ extern int bannerFlip[40]; // bnriconisDSi[] extern bool bnriconisDSi[40]; +extern bool launchable[40]; +extern bool isHomebrew[40]; /** * Get banner sequence from banner file.