void Menu_Remove(void) { struct discHdr *header = NULL; s32 ret; /* No game list */ if (!gameCnt) return; /* Selected game */ header = &gameList[gameSelected]; /* Clear console */ Con_Clear(); printf("[+] Are you sure you want to remove this\n"); printf(" game?\n\n"); /* Show game info */ __Menu_PrintInfo(header); printf(" Press A button to continue.\n"); printf(" Press B button to go back.\n\n\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) return; } printf("[+] Removing game, please wait..."); fflush(stdout); /* Remove game */ ret = WBFS_RemoveGame(header->id); if (ret < 0) { printf("\n ERROR! (ret = %d)\n", ret); goto out; } else printf(" OK!\n"); /* Reload entries */ __Menu_GetEntries(); out: printf("\n"); printf(" Press any button to continue...\n"); /* Wait for any button */ Wpad_WaitButtons(); }
void __Menu_Controls(void) { u32 buttons = Wpad_WaitButtons(); /* UP/DOWN buttons */ if (buttons & WPAD_BUTTON_UP) __Menu_MoveList(-1); if (buttons & WPAD_BUTTON_DOWN) __Menu_MoveList(1); /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) __Menu_MoveList(-ENTRIES_PER_PAGE); if (buttons & WPAD_BUTTON_RIGHT) __Menu_MoveList(ENTRIES_PER_PAGE); /* HOME button */ if (buttons & WPAD_BUTTON_HOME) Restart(); /* PLUS (+) button */ if (buttons & WPAD_BUTTON_PLUS) Menu_Manage(selected, 'i'); /* MINUS (-) button */ if (buttons & WPAD_BUTTON_MINUS) Menu_Manage(selected, 'u'); /* ONE (1) button */ if (buttons & WPAD_BUTTON_1) Menu_Device(); }
void Disclaimer(void) { /* Print disclaimer */ printf(" [DISCLAIMER]:\n\n"); printf(" THIS APPLICATION COMES WITH NO WARRANTY AT ALL,\n"); printf(" NEITHER EXPRESS NOR IMPLIED.\n"); printf(" I DO NOT TAKE ANY RESPONSIBILITY FOR ANY DAMAGE IN YOUR\n"); printf(" WII CONSOLE BECAUSE OF A IMPROPER USAGE OF THIS SOFTWARE.\n\n"); printf(">> If you agree and install the streamed wad\n"); printf(">> press A button to continue.\n"); printf(">> Otherwise, press B button to restart your Wii.\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if ((buttons & WPAD_BUTTON_A)||(buttons & PAD_BUTTON_A)) break; /* B button */ if ((buttons & WPAD_BUTTON_B)||(buttons & WPAD_CLASSIC_BUTTON_B)) Restart(); } }
void Restart_Wait(void) { printf("\n"); printf(" Press any button to restart..."); fflush(stdout); /* Wait for button */ Wpad_WaitButtons(); printf(" Restarting Wii..."); fflush(stdout); /* Load system menu */ Sys_LoadMenu(); }
void Direct_Launch() { int i; if (!CFG.direct_launch) return; // enable console in case there is some input // required when loading game, depends on options, like: // confirm ocarina, alt_dol=disk (asks for dol) // but this can be moved to those points and removed from here // so that console is shown only if needed... if (CFG.intro) { Gui_Console_Enable(); } // confirm_direct_start //CFG.confirm_start = 0; //sleep(1); Con_Clear(); printf(gt("Configurable Loader %s"), CFG_VERSION); printf("\n\n"); //sleep(1); for (i=0; i<gameCnt; i++) { if (strncmp(CFG.launch_discid, (char*)gameList[i].id, 6) == 0) { gameSelected = i; Menu_Boot(0); goto out; } } Gui_Console_Enable(); printf(gt("Auto-start game: %.6s not found!"), CFG.launch_discid); printf("\n"); printf(gt("Press any button...")); printf("\n"); Wpad_WaitButtons(); out: CFG.direct_launch = 0; }
void __Menu_Controls(void) { u32 buttons = Wpad_WaitButtons(); /* UP/DOWN buttons */ if (buttons & WPAD_BUTTON_UP) __Menu_MoveList(-1); if (buttons & WPAD_BUTTON_DOWN) __Menu_MoveList(1); /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) __Menu_MoveList(-ENTRIES_PER_PAGE); if (buttons & WPAD_BUTTON_RIGHT) __Menu_MoveList(ENTRIES_PER_PAGE); /* HOME button */ if (buttons & WPAD_BUTTON_HOME) Restart(); /* A button */ if (buttons & WPAD_BUTTON_A) Firmware_Install(&fwList[selected]); }
void Menu_Boot() { struct discHdr *header; bool gc = false; header = &gameList[gameSelected]; s32 ret; struct Game_CFG_2 *game_cfg = NULL; /* Clear console */ if (!CFG.direct_launch) { Con_Clear(); } FgColor(CFG.color_header); printf_x(gt("Start this game?")); printf("\n\n"); DefaultColor(); game_cfg = CFG_find_game(header->id); // Get game size gc = header->magic == GC_MAGIC; bool do_skip = !CFG.confirm_start; /* SoundInfo snd; u8 banner_title[84]; memset(banner_title, 0, 84); memset(&snd, 0, sizeof(snd)); WBFS_Banner(header->id, &snd, banner_title, !do_skip, CFG_read_active_game_setting(header->id).write_playlog); */ if (do_skip) { goto skip_confirm; } printf("\n"); /* Show game info */ printf_("%s\n", get_title(header)); printf_("(%.6s)\n\n", header->id); __Menu_ShowGameInfo(true, header->id); /* load game info from XML */ printf("\n"); //Does DL warning apply to launching discs too? Not sure printf_h(gt("Press %s button to continue."), (button_names[CFG.button_confirm.num])); printf("\n"); printf_h(gt("Press %s button to go back."), (button_names[CFG.button_cancel.num])); if (!gc) { printf("\n"); printf_h(gt("Press %s button for options."), (button_names[CFG.button_other.num])); } printf("\n\n"); __console_flush(0); // play banner sound /* if (snd.dsp_data) { SND_PauseVoice(0, 1); // pause mp3 int fmt = (snd.channels == 2) ? VOICE_STEREO_16BIT : VOICE_MONO_16BIT; SND_SetVoice(1, fmt, snd.rate, 0, snd.dsp_data, snd.size, 255,255, //volume,volume, NULL); //DataTransferCallback } */ /* Wait for user answer */ u32 buttons; for (;;) { buttons = Wpad_WaitButtons(); if (buttons & CFG.button_confirm.mask) break; if (buttons & CFG.button_cancel.mask) break; if (!gc && (buttons & CFG.button_other.mask)) break; if (buttons & CFG.button_exit.mask) break; } /* // stop banner sound, resume mp3 if (snd.dsp_data) { SND_StopVoice(1); SAFE_FREE(snd.dsp_data); if (buttons & CFG.button_confirm.mask) { SND_ChangeVolumeVoice(0, 0, 0); } SND_PauseVoice(0, 0); } */ if (buttons & CFG.button_cancel.mask) goto close; if (buttons & CFG.button_exit.mask) { Handle_Home(0); return; } if (!gc && (buttons & CFG.button_other.mask)) { Menu_Boot_Options(header); return; } // A button: continue to boot skip_confirm: if (game_cfg) { CFG.game = game_cfg->curr; } if (CFG.game.write_playlog && set_playrec(header->id, (u8 *) header->title) < 0) { // banner_title) < 0) { printf_(gt("Error storing playlog file.\nStart from the Wii Menu to fix.")); printf("\n"); printf_h(gt("Press %s button to exit."), (button_names[CFG.button_exit.num])); printf("\n"); if (!Menu_Confirm(0)) return; } WBFS_OpenDisc(header->id, header->game_idx); printf("\n"); printf_x(gt("Booting Wii game, please wait...")); printf("\n\n"); // load stuff before ios reloads & services close ocarina_load_code(header->id); load_wip_patches(header->id); // Close the wode stuff WBFS_Close(); use_dvdx = 0; Disc_Init(); ret = Disc_Wait(); if (ret < 0) { printf("Cannot mount newly selected image: %d\n", ret); } Disc_Open(); // stop services (music, gui) Services_Close(); setPlayStat(header->id); //I'd rather do this after the check, but now you unmount fat before that ;) Fat_UnmountAll(); if (gc) { WII_Initialize(); ret = WII_LaunchTitle(0x0000000100000100ULL); } else { switch(CFG.game.language) { // 0 = CFG_LANG_CONSOLE case 0: configbytes[0] = 0xCD; break; case 1: configbytes[0] = 0x00; break; case 2: configbytes[0] = 0x01; break; case 3: configbytes[0] = 0x02; break; case 4: configbytes[0] = 0x03; break; case 5: configbytes[0] = 0x04; break; case 6: configbytes[0] = 0x05; break; case 7: configbytes[0] = 0x06; break; case 8: configbytes[0] = 0x07; break; case 9: configbytes[0] = 0x08; break; case 10: configbytes[0] = 0x09; break; } /* Boot Wii disc */ ret = Disc_WiiBoot(); } printf_(gt("Returned! (ret = %d)"), ret); printf("\n"); printf("\n"); printf_(gt("Press any button to exit...")); printf("\n"); /* Wait for button */ Wpad_WaitButtonsCommon(); exit(0); close: WDVD_StopMotor(); header = &gameList[gameSelected]; Gui_DrawCover(header->id); // Reopen the wode WBFS_Init(); return; }
void Menu_Boot(void) { struct discHdr *header = NULL; s32 ret; /* No game list */ if (!gameCnt) return; /* Selected game */ header = &gameList[gameSelected]; /* Clear console */ Con_Clear(); printf("[+] Are you sure you want to boot this\n"); printf(" game?\n\n"); /* Show game info */ __Menu_PrintInfo(header); printf(" Press A button to continue.\n"); printf(" Press B button to go back.\n\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) return; } printf("\n"); printf("[+] Booting Wii game, please wait...\n"); /* Set WBFS mode */ Disc_SetWBFS(wbfsDev, header->id); /* Open disc */ ret = Disc_Open(); if (ret < 0) { printf(" ERROR: Could not open game! (ret = %d)\n", ret); goto out; } /* Boot Wii disc */ Disc_WiiBoot(); printf(" Returned! (ret = %d)\n", ret); out: printf("\n"); printf(" Press any button to continue...\n"); /* Wait for button */ Wpad_WaitButtons(); }
void Menu_Install(void) { static struct discHdr header ATTRIBUTE_ALIGN(32); s32 ret; /* Clear console */ Con_Clear(); printf("[+] Are you sure you want to install a\n"); printf(" new Wii game?\n\n"); printf(" Press A button to continue.\n"); printf(" Press B button to go back.\n\n\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) return; } /* Disable WBFS mode */ Disc_SetWBFS(0, NULL); printf("[+] Insert the game DVD disc..."); fflush(stdout); /* Wait for disc */ ret = Disc_Wait(); if (ret < 0) { printf("\n ERROR! (ret = %d)\n", ret); goto out; } else printf(" OK!\n"); printf("[+] Opening DVD disc..."); fflush(stdout); /* Open disc */ ret = Disc_Open(); if (ret < 0) { printf("\n ERROR! (ret = %d)\n", ret); goto out; } else printf(" OK!\n\n"); /* Check disc */ ret = Disc_IsWii(); if (ret < 0) { printf("[+] ERROR: Not a Wii disc!!\n"); goto out; } /* Read header */ Disc_ReadHeader(&header); /* Check if game is already installed */ ret = WBFS_CheckGame(header.id); if (ret) { printf("[+] ERROR: Game already installed!!\n"); goto out; } printf("[+] Installing game, please wait...\n\n"); printf(" %s\n", header.title); printf(" (%c%c%c%c)\n\n", header.id[0], header.id[1], header.id[2], header.id[3]); /* Install game */ ret = WBFS_AddGame(); if (ret < 0) { printf("[+] Installation ERROR! (ret = %d)\n", ret); goto out; } /* Reload entries */ __Menu_GetEntries(); out: printf("\n"); printf(" Press any button to continue...\n"); /* Wait for any button */ Wpad_WaitButtons(); }
void Menu_Device(void) { u32 timeout = 30; s32 ret; /* Ask user for device */ for (;;) { char *devname = "Unknown!"; /* Set device name */ switch (wbfsDev) { case WBFS_DEVICE_USB: devname = "USB Mass Storage Device"; break; case WBFS_DEVICE_SDHC: devname = "SD/SDHC Card"; break; } /* Clear console */ Con_Clear(); printf("[+] Select WBFS device:\n"); printf(" < %s >\n\n", devname); printf(" Press LEFT/RIGHT to select device.\n"); printf(" Press A button to continue.\n\n"); u32 buttons = Wpad_WaitButtons(); /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) { if ((--wbfsDev) < WBFS_MIN_DEVICE) wbfsDev = WBFS_MAX_DEVICE; } if (buttons & WPAD_BUTTON_RIGHT) { if ((++wbfsDev) > WBFS_MAX_DEVICE) wbfsDev = WBFS_MIN_DEVICE; } /* A button */ if (buttons & WPAD_BUTTON_A) break; } printf("[+] Mounting device, please wait...\n"); printf(" (%d seconds timeout)\n\n", timeout); fflush(stdout); /* Initialize WBFS */ ret = WBFS_Init(wbfsDev, timeout); if (ret < 0) { printf(" ERROR! (ret = %d)\n", ret); /* Restart wait */ Restart_Wait(); } /* Try to open device */ while (WBFS_Open() < 0) { /* Clear console */ Con_Clear(); printf("[+] WARNING:\n\n"); printf(" No WBFS partition found!\n"); printf(" You need to format a partition.\n\n"); printf(" Press A button to format a partition.\n"); printf(" Press B button to restart.\n\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) Restart(); } /* Format device */ Menu_Format(); } /* Get game list */ __Menu_GetEntries(); }
void Menu_Format(void) { partitionEntry partitions[MAX_PARTITIONS]; u32 cnt, sector_size; s32 ret, selected = 0; /* Clear console */ Con_Clear(); /* Get partition entries */ ret = Partition_GetEntries(wbfsDev, partitions, §or_size); if (ret < 0) { printf("[+] ERROR: No partitions found! (ret = %d)\n", ret); /* Restart */ Restart_Wait(); } loop: /* Clear console */ Con_Clear(); printf("[+] Selected the partition you want to \n"); printf(" format:\n\n"); /* Print partition list */ for (cnt = 0; cnt < MAX_PARTITIONS; cnt++) { partitionEntry *entry = &partitions[cnt]; /* Calculate size in gigabytes */ f32 size = entry->size * (sector_size / GB_SIZE); /* Selected entry */ (selected == cnt) ? printf(">> ") : printf(" "); fflush(stdout); /* Valid partition */ if (size) printf("Partition #%d: (size = %.2fGB)\n", cnt + 1, size); else printf("Partition #%d: (cannot be formatted)\n", cnt + 1); } partitionEntry *entry = &partitions[selected]; u32 buttons = Wpad_WaitButtons(); /* UP/DOWN buttons */ if (buttons & WPAD_BUTTON_UP) { if ((--selected) <= -1) selected = MAX_PARTITIONS - 1; } if (buttons & WPAD_BUTTON_DOWN) { if ((++selected) >= MAX_PARTITIONS) selected = 0; } /* B button */ if (buttons & WPAD_BUTTON_B) return; /* Valid partition */ if (entry->size) { /* A button */ if (buttons & WPAD_BUTTON_A) goto format; } goto loop; format: /* Clear console */ Con_Clear(); printf("[+] Are you sure you want to format\n"); printf(" this partition?\n\n"); printf(" Partition #%d\n", selected + 1); printf(" (size = %.2fGB - type: %02X)\n\n", entry->size * (sector_size / GB_SIZE), entry->type); printf(" Press A button to continue.\n"); printf(" Press B button to go back.\n\n\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) goto loop; } printf("[+] Formatting, please wait..."); fflush(stdout); /* Format partition */ ret = WBFS_Format(entry->sector, entry->size); if (ret < 0) { printf("\n ERROR! (ret = %d)\n", ret); goto out; } else printf(" OK!\n"); out: printf("\n"); printf(" Press any button to continue...\n"); /* Wait for any button */ Wpad_WaitButtons(); }
void Menu_Manage(u32 index, u8 mode) { fatDevice *dev = NULL; fatFile *file = NULL; FILE *fp = NULL; char filepath[128]; f32 filesize; /* No files */ if (!fileCnt) return; /* Selected file/device */ dev = &deviceList[device]; file = &fileList[index]; /* File size in megabytes */ filesize = (file->filestat.st_size / MB_SIZE); /* Clear console */ Con_Clear(); /* Ask user */ switch (mode) { case 'i': printf("[+] Are you sure you want to install this WAD file?\n\n"); break; case 'u': printf("[+] Are you sure you want to uninstall this WAD file?\n\n"); break; } printf(" Filename: %s\n", file->filename); printf(" Filesize: %.2f MB\n\n", filesize); printf(" Press A to continue.\n"); printf(" Press B to return to the menu.\n\n"); /* Wait for user answer */ for (;;) { u32 buttons = Wpad_WaitButtons(); /* A button */ if (buttons & WPAD_BUTTON_A) break; /* B button */ if (buttons & WPAD_BUTTON_B) return; } /* Generate filepath */ sprintf(filepath, "%s:" WAD_DIRECTORY "/%s", dev->mount, file->filename); printf("[+] Opening WAD file, please wait..."); fflush(stdout); /* Open WAD */ fp = fopen(filepath, "rb"); if (!fp) { printf(" ERROR!\n"); goto out; } else printf(" OK!\n\n"); /* (Un)Install WAD */ switch (mode) { case 'i': printf("[+] Installing WAD, please wait...\n"); /* Install WAD */ Wad_Install(fp); break; case 'u': printf("[+] Uninstalling WAD, please wait...\n"); /* Uninstall WAD */ Wad_Uninstall(fp); break; } out: /* Close file */ if (fp) fclose(fp); printf("\n"); printf(" Press any button to continue...\n"); /* Wait for button */ Wpad_WaitButtons(); }
void Menu_Device(void) { fatDevice *dev = NULL; s32 ret; /* Select source device */ for (;;) { /* Clear console */ Con_Clear(); /* Selected device */ dev = &deviceList[device]; printf("\t>> Select source device: < %s >\n\n", dev->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\n"); u32 buttons = Wpad_WaitButtons(); /* LEFT/RIGHT buttons */ if (buttons & WPAD_BUTTON_LEFT) { if ((--device) <= -1) device = (NB_DEVICES - 1); } if (buttons & WPAD_BUTTON_RIGHT) { if ((++device) >= NB_DEVICES) device = 0; } /* HOME button */ if (buttons & WPAD_BUTTON_HOME) Restart(); /* A button */ if (buttons & WPAD_BUTTON_A) break; } /* Mount device */ printf("[+] Mounting device, please wait..."); fflush(stdout); /* Mount device */ ret = Fat_Mount(dev); if (ret < 0) { printf(" ERROR! (ret = %d)\n", ret); goto err; } else printf(" OK!\n"); printf("[+] Retrieving file list..."); fflush(stdout); /* Retrieve filelist */ ret = __Menu_RetrieveList(); if (ret < 0) { printf(" ERROR! (ret = %d)\n", ret); goto err; } else printf(" OK!\n"); return; err: /* Unmount device */ Fat_Unmount(dev); printf("\n"); printf(" Press any button to continue...\n"); Wpad_WaitButtons(); /* Prompt menu again */ Menu_Device(); }