void Menu_FatDevice(void) { s32 ret, selected = 0; /* Unmount FAT device */ if (fdev) Fat_Unmount(fdev); /* Select source device */ if (gConfig.fatDeviceIndex < 0) { for (;;) { /* Clear console */ Con_Clear(); /* Selected device */ fdev = &fdevList[selected]; printf("\t>> Select source device: < %s >\n\n", fdev->name); printf("\t Press LEFT/RIGHT to change the selected device.\n\n"); printf("\t Press A button to continue.\n"); printf("\t Press HOME button to restart.\n\n"); u32 buttons = WaitButtons(); /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) { if ((--selected) <= -1) selected = (NB_FAT_DEVICES - 1); } if (buttons & WPAD_BUTTON_RIGHT) { if ((++selected) >= NB_FAT_DEVICES) selected = 0; } /* HOME button */ if (buttons & WPAD_BUTTON_HOME) Restart(); /* A button */ if (buttons & WPAD_BUTTON_A) break; } } else { fdev = &fdevList[gConfig.fatDeviceIndex]; } printf("[+] Mounting device, please wait..."); fflush(stdout); /* Mount FAT device */ ret = Fat_Mount(fdev); if (ret < 0) { printf(" ERROR! (ret = %d)\n", ret); goto err; } else printf(" OK!\n"); return; err: WiiLightControl (WII_LIGHT_OFF); printf("\n"); printf(" Press any button to continue...\n"); WaitButtons(); /* Prompt menu again */ Menu_FatDevice(); }
void Menu_WadManage(fatFile *file, char *inFilePath) { FILE *fp = NULL; //char filepath[128]; f32 filesize; u32 mode = 0; /* File size in megabytes */ filesize = (file->filestat.st_size / MB_SIZE); for (;;) { /* Clear console */ Con_Clear(); printf("[+] WAD Filename : %s\n", file->filename); printf(" WAD Filesize : %.2f MB\n\n\n", filesize); printf("[+] Select action: < %s WAD >\n\n", (!mode) ? "Install" : "Uninstall"); printf(" Press LEFT/RIGHT to change selected action.\n\n"); printf(" Press A to continue.\n"); printf(" Press B to go back to the menu.\n\n"); u32 buttons = WaitButtons(); /* LEFT/RIGHT buttons */ if (buttons & (WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT)) mode ^= 1; /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) return; } /* Clear console */ Con_Clear(); printf("[+] Opening \"%s\", please wait...", file->filename); fflush(stdout); /* Generate filepath */ // sprintf(filepath, "%s:" WAD_DIRECTORY "/%s", fdev->mount, file->filename); sprintf(gTmpFilePath, "%s/%s", inFilePath, file->filename); // wiiNinja /* Open WAD */ fp = fopen(gTmpFilePath, "rb"); if (!fp) { printf(" ERROR!\n"); goto out; } else printf(" OK!\n\n"); printf("[+] %s WAD, please wait...\n", (!mode) ? "Installing" : "Uninstalling"); /* Do install/uninstall */ WiiLightControl (WII_LIGHT_ON); if (!mode) Wad_Install(fp); else Wad_Uninstall(fp); WiiLightControl (WII_LIGHT_OFF); out: /* Close file */ if (fp) fclose(fp); printf("\n"); printf(" Press any button to continue...\n"); /* Wait for button */ WaitButtons(); }
/* Install and/or Uninstall multiple WADs - Leathl */ int Menu_BatchProcessWads(fatFile *files, int fileCount, char *inFilePath, int installCnt, int uninstallCnt) { int count; for (;;) { Con_Clear(); if ((installCnt > 0) & (uninstallCnt == 0)) { printf("[+] %d file%s marked for installation.\n", installCnt, (installCnt == 1) ? "" : "s"); printf(" Do you want to proceed?\n"); } else if ((installCnt == 0) & (uninstallCnt > 0)) { printf("[+] %d file%s marked for uninstallation.\n", uninstallCnt, (uninstallCnt == 1) ? "" : "s"); printf(" Do you want to proceed?\n"); } else { printf("[+] %d file%s marked for installation and %d file%s for uninstallation.\n", installCnt, (installCnt == 1) ? "" : "s", uninstallCnt, (uninstallCnt == 1) ? "" : "s"); printf(" Do you want to proceed?\n"); } printf("\n\n Press A to continue.\n"); printf(" Press B to go back to the menu.\n\n"); u32 buttons = WaitButtons(); if (buttons & WPAD_BUTTON_A) break; if (buttons & WPAD_BUTTON_B) return 0; } WiiLightControl (WII_LIGHT_ON); int errors = 0; int success = 0; s32 ret; for (count = 0; count < fileCount; count++) { fatFile *thisFile = &files[count]; if ((thisFile->install == 1) | (thisFile->install == 2)) { int mode = thisFile->install; Con_Clear(); printf("[+] Opening \"%s\", please wait...\n\n", thisFile->filename); sprintf(gTmpFilePath, "%s/%s", inFilePath, thisFile->filename); FILE *fp = fopen(gTmpFilePath, "rb"); if (!fp) { printf(" ERROR!\n"); errors += 1; continue; } printf("[+] %s WAD, please wait...\n", (mode == 2) ? "Uninstalling" : "Installing"); if (mode == 2) { ret = Wad_Uninstall(fp); } else { ret = Wad_Install(fp); } if (ret < 0) errors += 1; else success += 1; thisFile->installstate = ret; if (fp) fclose(fp); } } WiiLightControl (WII_LIGHT_OFF); printf("\n"); printf(" %d titles succeeded and %d failed...\n", success, errors); if (errors > 0) { printf("\n Some operations failed"); printf("\n Press A to list.\n"); printf(" Press B skip.\n"); u32 buttons = WaitButtons(); if ((buttons & WPAD_BUTTON_A)) { Con_Clear(); int i=0; for (count = 0; count < fileCount; count++) { fatFile *thisFile = &files[count]; if (thisFile->installstate <0) { char str[41]; strncpy(str, thisFile->filename, 40); //Only 40 chars to fit the screen str[40]=0; i++; if(thisFile->installstate == -999) printf(" %s BRICK BLOCKED\n", str); else if(thisFile->installstate == -998) printf(" %s Skipped\n", str); else if(thisFile->installstate == -106) printf(" %s Not installed?\n", str); else if(thisFile->installstate == -1036 ) printf(" %s Needed IOS missing\n", str); else if(thisFile->installstate == -4100 ) printf(" %s No trucha bug?\n", str); else printf(" %s error %d\n", str, thisFile->installstate); if( i == 17 ) { printf("\n Press any button to continue\n"); WaitButtons(); i = 0; } } } } } printf("\n Press any button to continue...\n"); WaitButtons(); return 1; }