Add .firm payload booting

requires boot9strap with bootonce support
This commit is contained in:
RocketRobz 2018-10-05 17:41:46 -06:00
parent a156cd25e1
commit 219071c617
2 changed files with 27 additions and 5 deletions

View File

@ -46,6 +46,7 @@ using namespace std;
struct DirEntry {
string name;
bool isDirectory;
bool isApp;
} ;
bool nameEndsWith (const string& name) {
@ -86,7 +87,16 @@ void getDirectoryContents (vector<DirEntry>& dirContents) {
stat(pent->d_name, &st);
dirEntry.name = pent->d_name;
dirEntry.isDirectory = (st.st_mode & S_IFDIR) ? true : false;
if((dirEntry.name.substr(dirEntry.name.find_last_of(".") + 1) == "nds")
|| (dirEntry.name.substr(dirEntry.name.find_last_of(".") + 1) == "NDS")
|| (isDSiMode() && sdMounted && dirEntry.name.substr(dirEntry.name.find_last_of(".") + 1) == "firm")
|| (isDSiMode() && sdMounted && dirEntry.name.substr(dirEntry.name.find_last_of(".") + 1) == "FIRM"))
{
dirEntry.isApp = true;
} else {
dirEntry.isApp = false;
}
if (dirEntry.name.compare(".") != 0 && (dirEntry.isDirectory || nameEndsWith(dirEntry.name))) {
dirContents.push_back (dirEntry);
}
@ -232,7 +242,9 @@ string browseForFile (void) {
screenOffset = 0;
fileOffset = 0;
} else {
applaunch = true;
if (entry->isApp) {
applaunch = true;
}
// Clear the screen
iprintf ("\x1b[2J");
// Return the chosen file

View File

@ -32,6 +32,7 @@
#include "driveMenu.h"
#include "driveOperations.h"
#include "file_browse.h"
#include "fileOperations.h"
#include "gm9i_logo.h"
@ -166,9 +167,8 @@ int main(int argc, char **argv) {
argarray.push_back(strdup(filename.c_str()));
}
if ( strcasecmp (filename.c_str() + filename.size() - 4, ".nds") != 0 || argarray.size() == 0 ) {
iprintf("no nds file specified\n");
} else {
if ((strcasecmp (filename.c_str() + filename.size() - 4, ".nds") == 0)
|| (strcasecmp (filename.c_str() + filename.size() - 4, ".NDS") == 0)) {
char *name = argarray.at(0);
strcpy (filePath + pathLen, name);
free(argarray.at(0));
@ -176,7 +176,17 @@ int main(int argc, char **argv) {
iprintf ("Running %s with %d parameters\n", argarray[0], argarray.size());
int err = runNdsFile (argarray[0], argarray.size(), (const char **)&argarray[0]);
iprintf ("Start failed. Error %i\n", err);
}
if ((strcasecmp (filename.c_str() + filename.size() - 4, ".firm") == 0)
|| (strcasecmp (filename.c_str() + filename.size() - 4, ".FIRM") == 0)) {
char *name = argarray.at(0);
strcpy (filePath + pathLen, name);
free(argarray.at(0));
argarray.at(0) = filePath;
fcopy(argarray[0], "sd:/bootonce.firm");
fifoSendValue32(FIFO_USER_02, 1); // Reboot into selected .firm payload
swiWaitForVBlank();
}
while(argarray.size() !=0 ) {