Skip to content

Commit

Permalink
- When autobooting, pass current command-line arguments along.
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed Oct 7, 2024
1 parent 8ae8e8f commit 6687d25
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cube/swiss/include/swiss.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern void __SYS_ReadROM(void *buf,u32 len,u32 offset);
extern uiDrawObj_t * renderFileBrowser(file_handle** directory, int num_files, uiDrawObj_t *container);

extern void menu_loop();
extern void boot_dol();
extern void boot_dol(int argc, char *argv[]);
extern bool manage_file();
extern void load_file();
extern int check_game();
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/config/dolparameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Parameters* getParameters() {
return &_parameters;
}

void populateArgv(char **argz, size_t *argz_len, char *filename) {
void populateArgz(char **argz, size_t *argz_len) {
int i = 0;
Parameters* params = getParameters();
print_gecko("There are %i parameters\r\n", params->num_params);
Expand Down
2 changes: 1 addition & 1 deletion cube/swiss/source/config/dolparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ typedef struct {

void parseParameters(char *filecontents);
Parameters* getParameters();
void populateArgv(char **argz, size_t *argz_len, char *filename);
void populateArgz(char **argz, size_t *argz_len);
#endif
2 changes: 1 addition & 1 deletion cube/swiss/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ int main(int argc, char *argv[])
print_gecko("Detected %s\r\n", devices[DEVICE_CUR]->deviceName);
if(!devices[DEVICE_CUR]->init(devices[DEVICE_CUR]->initial)) {
if(devices[DEVICE_CUR]->features & FEAT_AUTOLOAD_DOL) {
load_auto_dol();
load_auto_dol(argc, argv);
}
memcpy(&curDir, devices[DEVICE_CUR]->initial, sizeof(file_handle));
needsDeviceChange = 0;
Expand Down
12 changes: 8 additions & 4 deletions cube/swiss/source/swiss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1256,8 +1256,8 @@ void load_app(ExecutableFile *fileToPatch)
}
}

void boot_dol()
{
void boot_dol(int argc, char *argv[])
{
void *dol_buffer;
void *ptr;

Expand Down Expand Up @@ -1370,13 +1370,17 @@ void boot_dol()
if(params->num_params > 0) {
DrawArgsSelector(getRelativeName(&curFile.name[0]));
// Get an argv back or none.
populateArgv(&argz, &argz_len, &curFile.name[0]);
populateArgz(&argz, &argz_len);
}
}
}
devices[DEVICE_CUR]->closeFile(dcpArgFile);
free(dcpArgFile);

for(i = 1; i < argc; i++) {
argz_add(&argz, &argz_len, argv[i]);
}

if(devices[DEVICE_CUR] != NULL) devices[DEVICE_CUR]->deinit( devices[DEVICE_CUR]->initial );
// Boot
if(!memcmp(dol_buffer, ELFMAG, SELFMAG)) {
Expand Down Expand Up @@ -2183,7 +2187,7 @@ void load_file()
//if it's a DOL, boot it
if(strlen(fileName)>4) {
if(endsWith(fileName,".bin") || endsWith(fileName,".dol") || endsWith(fileName,".dol+cli") || endsWith(fileName,".elf")) {
boot_dol();
boot_dol(0, NULL);
// if it was invalid (overlaps sections, too large, etc..) it'll return
uiDrawObj_t *msgBox = DrawPublish(DrawMessageBox(D_WARN, "Invalid DOL"));
sleep(2);
Expand Down
4 changes: 2 additions & 2 deletions cube/swiss/source/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static const char *autoboot_dols[] = {
"*/boot2.dol",
"*/swiss_r[1-9]*.dol"
};
void load_auto_dol() {
void load_auto_dol(int argc, char *argv[]) {
char trailer[sizeof(GIT_COMMIT) - 1]; // Don't include the NUL termination in the comparison
int trailer_size;

Expand Down Expand Up @@ -200,7 +200,7 @@ void load_auto_dol() {
// Emulate some of the menu's behavior to satisfy boot_dol
curSelection = i;
memcpy(&curFile, dirEntries[i], sizeof(file_handle));
boot_dol();
boot_dol(argc, argv);
memcpy(dirEntries[i], &curFile, sizeof(file_handle));
}
devices[DEVICE_CUR]->closeFile(dirEntries[i]);
Expand Down

0 comments on commit 6687d25

Please sign in to comment.