Skip to content

Commit

Permalink
Show message when trying to launch DSi-Exclusive/DSiWare game
Browse files Browse the repository at this point in the history
ALSO: Launch DSi-mode homebrew (or homebrew with DSi-extended header) with A button
  • Loading branch information
RocketRobz committed Feb 19, 2018
1 parent adbbb02 commit 5a7b967
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
21 changes: 18 additions & 3 deletions romsel_dsimenutheme/arm9/source/fileBrowse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "date.h"

#include "ndsheaderbanner.h"
#include "iconTitle.h"
#include "graphics/fontHandler.h"
#include "graphics/graphics.h"
Expand Down Expand Up @@ -348,6 +349,10 @@ string browseForFile(const vector<string> 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++;
}
}
Expand Down Expand Up @@ -555,12 +560,16 @@ string browseForFile(const vector<string> 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;
Expand All @@ -576,6 +585,12 @@ string browseForFile(const vector<string> 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();
}
}

Expand Down Expand Up @@ -695,7 +710,7 @@ string browseForFile(const vector<string> 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();
}

}
Expand Down
19 changes: 14 additions & 5 deletions romsel_dsimenutheme/arm9/source/iconTitle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)];
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion romsel_dsimenutheme/arm9/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions romsel_dsimenutheme/arm9/source/ndsheaderbanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions romsel_dsimenutheme/arm9/source/ndsheaderbanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 5a7b967

Please sign in to comment.