void Handle_Home(int disable_screenshot) { if (CFG.home == CFG_HOME_EXIT) { Con_Clear(); printf("\n"); printf_("Exiting..."); __console_flush(0); Sys_Exit(); } else if (CFG.home == CFG_HOME_SCRSHOT) { __console_flush(0); Make_ScreenShot(); if (disable_screenshot) CFG.home = CFG_HOME_EXIT; } else if (CFG.home == CFG_HOME_HBC) { Con_Clear(); printf("\n"); printf_("HBC..."); __console_flush(0); Sys_HBC(); } else if (CFG.home == CFG_HOME_REBOOT) { Con_Clear(); Restart(); } else { // Priiloader magic words, and channels if ((CFG.home & 0xFF) < 'a') { // upper case final letter implies channel Con_Clear(); Sys_Channel(CFG.home); } else { // lower case final letter implies magic word Con_Clear(); *(vu32*)0x8132FFFB = CFG.home; Restart(); } } }
void Restart(void) { printf("\n"); printf_(gt("Restarting Wii...")); fflush(stdout); __console_flush(0); /* Load system menu */ Sys_LoadMenu(); }
void __console_vipostcb(u32 retraceCnt) { if (retrace_cnt < 5) { retrace_cnt++; return; } if (!fb_change) return; do_xfb_copy = TRUE; __console_flush(0); do_xfb_copy = FALSE; }
void __WBFS_Spinner(s32 x, s32 max) { static time_t start; static u32 expected; f32 percent, size; u32 d, h, m, s; /* First time */ if (!x) { start = time(0); expected = 300; } /* Elapsed time */ d = time(0) - start; if (x != max) { /* Expected time */ if (d && x) expected = (expected * 3 + d * max / x) / 4; /* Remaining time */ d = (expected > d) ? (expected - d) : 1; } /* Calculate time values */ h = d / 3600; m = (d / 60) % 60; s = d % 60; /* Calculate percentage/size */ percent = (x * 100.0) / max; if (hdd) { size = (hdd->wii_sec_sz / GB_SIZE) * max; } else { size = (0x8000 / GB_SIZE) * max; } Con_ClearLine(); /* Show progress */ if (x != max) { printf_(gt("%.2f%% of %.2fGB (%c) ETA: %d:%02d:%02d"), percent, size, "/-\\|"[(x / 10) % 4], h, m, s); printf("\r"); fflush(stdout); } else { printf_(gt("%.2fGB copied in %d:%02d:%02d"), size, h, m, s); printf(" \n"); } __console_flush(1); }
int filter_games(int (*filter) (struct discHdr *, int, char *, bool), char * name, bool num) { int i, len; int ret = 0; u8 *id = NULL; // filter if (filter_gameList) { len = sizeof(struct discHdr) * all_gameCnt; memcpy(filter_gameList, all_gameList, len); filter_gameCnt = filter(filter_gameList, all_gameCnt, name, num); } if (gameSelected < gameCnt) { id = gameList[gameSelected].id; } if (filter_gameCnt > 0) { gameList = filter_gameList; gameCnt = filter_gameCnt; ret = 1; } else { Con_Clear(); FgColor(CFG.color_header); printf("\n"); printf(gt("%s No games found!!"), CFG.cursor); printf("\n"); printf(gt("Loading previous game list...")); printf("\n"); DefaultColor(); __console_flush(0); sleep(1); ret = -1; } gameStart = 0; gameSelected = 0; for (i=0; i<gameCnt; i++) { if (strncmp((char*)gameList[i].id, (char*)id, 6) == 0) { gameSelected = i; break; } } // scroll start list __Menu_ScrollStartList(); return ret; }
void get_time2(long long *t, char *s) { if (!t) return; if (*t == 0) *t = gettime(); char c; char *p; char ss[32]; char *dir; int len; long long tt = gettime(); p = strchr(s, '.'); if (p) p++; else p = s; STRCOPY(ss, p); len = strlen(ss) - 1; c = ss[len]; if (c == '1') { dir = "-->"; ss[len] = 0; } else if (c == '2') { dir = "<--"; ss[len] = 0; } else return; //dir = "---"; dbg_printf("[%.3f] %s %s\n", diff_fsec(TIME.boot1, tt), dir, ss); if (CFG.debug) __console_flush(0); }
void Save_Game_List() { struct discHdr *buffer = NULL; u32 cnt, len; s32 ret; char name[200]; FILE *f; int i; // Get Game List ret = WBFS_GetCount(&cnt); if (ret < 0) return; printf_x(gt("Saving gamelist.txt ... ")); __console_flush(0); len = sizeof(struct discHdr) * cnt; buffer = (struct discHdr *)memalign(32, len); if (!buffer) goto error; memset(buffer, 0, len); ret = WBFS_GetHeaders(buffer, cnt, sizeof(struct discHdr)); if (ret < 0) goto error; snprintf(D_S(name), "%s/%s", USBLOADER_PATH, "gamelist.txt"); f = fopen(name, "wb"); if (!f) goto error; fprintf(f, "# CFG USB Loader game list %s\n", CFG_VERSION); for (i=0; i<gameCnt; i++) { fprintf(f, "# %.6s %s\n", gameList[i].id, gameList[i].title); fprintf(f, "%.6s = %s\n", gameList[i].id, get_title(&gameList[i])); } fclose(f); SAFE_FREE(buffer); printf("OK"); return; error: SAFE_FREE(buffer); printf(gt("ERROR")); }
void DoAction(int action) { if (action & CFG_BTN_REMAP) return; switch(action) { case CFG_BTN_NOTHING: break; case CFG_BTN_OPTIONS: if (!CFG.disable_options) Menu_Options(); break; case CFG_BTN_GUI: if (go_gui) { action_string[0] = 0; action_alpha=0; } if (CFG.gui) go_gui = !go_gui; break; case CFG_BTN_REBOOT: Con_Clear(); Restart(); break; case CFG_BTN_EXIT: Con_Clear(); printf("\n"); printf_("Exiting..."); __console_flush(0); Sys_Exit(); break; case CFG_BTN_SCREENSHOT: __console_flush(0); Make_ScreenShot(); CFG.home = CFG_HOME_EXIT; break; case CFG_BTN_MAIN_MENU: Menu_Views(); break; case CFG_BTN_GLOBAL_OPS: if (!CFG.disable_options) Menu_Global_Options(); break; case CFG_BTN_PROFILE: if (CFG.current_profile == CFG.num_profiles-1) CFG.current_profile = 0; else CFG.current_profile++; Switch_Favorites(enable_favorite); sprintf(action_string, gt("Profile: %s"), CFG.profile_names[CFG.current_profile]); break; case CFG_BTN_FAVORITES: { extern void reset_sort_default(); reset_sort_default(); Switch_Favorites(!enable_favorite); } break; case CFG_BTN_BOOT_GAME: Menu_Boot(0); break; case CFG_BTN_BOOT_DISC: Menu_Boot(1); break; case CFG_BTN_THEME: CFG_switch_theme(cur_theme + 1); if (gameCnt) Gui_DrawCover(gameList[gameSelected].id);//redraw_cover = 1; Cache_Invalidate(); sprintf(action_string, gt("Theme: %s"), theme_list[cur_theme]); if (go_gui) action_alpha = 0xFF; break; case CFG_BTN_UNLOCK: if (CFG.admin_lock) Menu_Unlock(); break; case CFG_BTN_HBC: Con_Clear(); printf("\n"); printf_("HBC..."); __console_flush(0); Sys_HBC(); break; case CFG_BTN_SORT: if (sort_desc) { sort_desc = 0; if (sort_index == sortCnt - 1) sort_index = 0; else sort_index = sort_index + 1; sortList(sortTypes[sort_index].sortAsc); } else { sort_desc = 1; sortList(sortTypes[sort_index].sortDsc); } if (gameCnt) Gui_DrawCover(gameList[gameSelected].id);//redraw_cover = 1; sprintf(action_string, gt("Sort: %s-%s"), sortTypes[sort_index].name, (sort_desc) ? "DESC":"ASC"); break; case CFG_BTN_FILTER: Menu_Filter(); break; default: // Priiloader magic words, and channels if ((action & 0xFF) < 'a') { // upper case final letter implies channel Con_Clear(); Sys_Channel(action); } else { // lower case final letter implies magic word Con_Clear(); *(vu32*)0x8132FFFB = action; Restart(); } break; } }
int Menu_Views() { struct discHdr *header = NULL; int redraw_cover = 0; struct Menu menu; if (gameCnt) { header = &gameList[gameSelected]; } const int NUM_OPT = 8; char active[NUM_OPT]; menu_init(&menu, NUM_OPT); for (;;) { menu.line_count = 0; menu_init_active(&menu, active, sizeof(active)); active[3] = 0; // disable_remove active[4] = 0; // disable_install if (CFG.disable_options) { active[1] = 0; active[2] = 0; } Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Main Menu")); printf(":\n\n"); DefaultColor(); MENU_MARK(); printf("<%s>\n", gt("Start Game")); MENU_MARK(); printf("<%s>\n", gt("Game Options")); MENU_MARK(); printf("<%s>\n", gt("Global Options")); MENU_MARK(); printf("<%s>\n", gt("Sort Games")); MENU_MARK(); printf("<%s>\n", gt("Filter Games")); MENU_MARK(); printf("<%s>\n", gt("Boot Disc")); DefaultColor(); printf("\n"); printf_h(gt("Press %s button to select."), (button_names[CFG.button_confirm.num])); printf("\n"); DefaultColor(); __console_flush(0); if (redraw_cover) { if (header) Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); menu_move_active(&menu, buttons); int change = -2; if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT) change = +1; if (buttons & CFG.button_confirm.mask) change = 0; // #define CHANGE(V,M) {V+=change;if(V>M)V=M;if(V<0)V=0;} if (change > -2) { switch (menu.current) { case 0: CFG.confirm_start = 0; Menu_Boot(0); break; case 1: Menu_Game_Options(); break; case 2: Menu_Global_Options(); break; case 3: Menu_Sort(); break; case 4: Menu_Filter(); break; case 5: Menu_Boot(1); break; } } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_cancel.mask) break; } return 0; }
int Menu_Boot_Options(struct discHdr *header) { int ret_val = 0; if (CFG.disable_options) return 0; struct Game_CFG_2 *game_cfg2 = NULL; struct Game_CFG *game_cfg = NULL; int opt_saved, opt_ios_reload; int redraw_cover = 0; int rows, cols, win_size; CON_GetMetrics(&cols, &rows); if ((win_size = rows-9) < 3) win_size = 3; Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Selected Game")); printf(":"); __console_flush(0); printf(" (%.6s)\n", header->id); DefaultColor(); printf(" %s %s\n\n", CFG.cursor_space, __Menu_PrintTitle(get_title(header))); __console_flush(0); // load_dolmenu((char*)header->id); game_cfg2 = CFG_get_game(header->id); if (!game_cfg2) { printf(gt("ERROR game opt")); printf("\n"); sleep(5); return 0; } game_cfg = &game_cfg2->curr; struct Menu menu; const int NUM_OPT = 16; char active[NUM_OPT]; menu_init(&menu, NUM_OPT); for (;;) { /* // fat on 249? if (wbfs_part_fs && !disc) { if (!is_ios_idx_mload(game_cfg->ios_idx)) { game_cfg->ios_idx = CFG_IOS_222_MLOAD; } } */ menu_init_active(&menu, active, sizeof(active)); opt_saved = game_cfg2->is_saved; // if not mload disable block ios reload opt opt_ios_reload = game_cfg->block_ios_reload; // if not ocarina and not wiird, deactivate hooks if (!game_cfg->ocarina && !CFG.wiird) { active[11] = 0; } //if admin lock is off or they're not in admin // mode then they can't hide/unhide games if (!CFG.admin_lock || CFG.admin_mode_locked) { active[14] = 0; } //These things shouldn't be changed if using a disc...maybe active[0] = 0; active[8] = 0; active[9] = 0; active[14] = 0; Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Selected Game")); printf(":"); printf(" (%.6s)\n", header->id); DefaultColor(); printf(" %s %s\n\n", CFG.cursor_space, __Menu_PrintTitle(get_title(header))); FgColor(CFG.color_header); printf_x(gt("Game Options: %s"), CFG_is_changed(header->id) ? gt("[ CHANGED ]") : opt_saved ? gt("[ SAVED ]") : ""); printf("\n"); DefaultColor(); char c1 = '<', c2 = '>'; //if (opt_saved) { c1 = '['; c2 = ']'; } const char *str_vpatch[3]; str_vpatch[0] = gt("Off"); str_vpatch[1] = gt("On"); str_vpatch[2] = gt("All"); // start menu draw menu_begin(&menu); menu_jump_active(&menu); #define PRINT_OPT_S(N,V) \ printf("%s%c %s %c\n", con_align(N,18), c1, V, c2) #define PRINT_OPT_A(N,V) \ printf("%s%c%s%c\n", con_align(N,18), c1, V, c2) #define PRINT_OPT_B(N,V) \ PRINT_OPT_S(N,(V?gt("On"):gt("Off"))) menu_window_begin(&menu, win_size, NUM_OPT); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Favorite:"), is_favorite(header->id) ? gt("Yes") : gt("No")); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Language:"), languages[game_cfg->language]); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Video:"), videos[game_cfg->video]); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Video Patch:"), str_vpatch[game_cfg->video_patch]); if (menu_window_mark(&menu)) PRINT_OPT_B("VIDTV:", game_cfg->vidtv); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Country Fix:"), game_cfg->country_patch); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Anti 002 Fix:"), game_cfg->fix_002); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Block IOS Reload:"), opt_ios_reload); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Ocarina (cheats):"), game_cfg->ocarina); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Hook Type:"), hook_name[game_cfg->hooktype]); if (menu_window_mark(&menu)) PRINT_OPT_A(gt("Cheat Codes:"), gt("Manage")); if (menu_window_mark(&menu)) printf("%s%s\n", con_align(gt("Cover Image:"), 18), imageNotFound ? gt("< DOWNLOAD >") : gt("[ FOUND ]")); if (menu_window_mark(&menu)) PRINT_OPT_S(gt("Hide Game:"), is_hide_game(header->id) ? gt("Yes") : gt("No")); if (menu_window_mark(&menu)) PRINT_OPT_B(gt("Write Playlog:"), game_cfg->write_playlog); DefaultColor(); menu_window_end(&menu, cols); printf_h(gt("Press %s to start game"), (button_names[CFG.button_confirm.num])); printf("\n"); bool need_save = !opt_saved || CFG_is_changed(header->id); if (need_save) printf_h(gt("Press %s to save options"), (button_names[CFG.button_save.num])); else printf_h(gt("Press %s to discard options"), (button_names[CFG.button_save.num])); printf("\n"); printf_h(gt("Press %s for global options"), (button_names[CFG.button_other.num])); DefaultColor(); __console_flush(0); if (redraw_cover) { Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); int change = 0; menu_move_active(&menu, buttons); if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT) change = +1; if (change) { switch (menu.current) { case 0: printf("\n\n"); printf_x(gt("Saving Settings... ")); __console_flush(0); if (set_favorite(header->id, change > 0)) { printf(gt("OK")); } else { printf(gt("ERROR")); sleep(1); } __console_flush(0); Gui_DrawCover(header->id); break; case 1: CHANGE(game_cfg->language, CFG_LANG_MAX); break; case 2: CHANGE(game_cfg->video, CFG_VIDEO_MAX); break; case 3: CHANGE(game_cfg->video_patch, 2); break; case 4: CHANGE(game_cfg->vidtv, 1); break; case 5: CHANGE(game_cfg->country_patch, 1); break; case 6: CHANGE(game_cfg->fix_002, 1); break; case 7: CHANGE(game_cfg->block_ios_reload, 1); break; case 8: CHANGE(game_cfg->ocarina, 1); break; case 9: CHANGE(game_cfg->hooktype, NUM_HOOK-1); break; case 10: Menu_Cheats(header); break; case 11: printf("\n\n"); Download_Cover((char*)header->id, change > 0, true); Cache_Invalidate(); Gui_DrawCover(header->id); Menu_PrintWait(); break; case 12: // hide game printf("\n\n"); printf_x(gt("Saving Settings... ")); __console_flush(0); if (set_hide_game(header->id, change > 0)) { printf(gt("OK")); } else { printf(gt("ERROR")); sleep(1); } __console_flush(0); Gui_DrawCover(header->id); break; case 13: CHANGE(game_cfg->write_playlog, 1); break; } } if (buttons & CFG.button_confirm.mask) { CFG.confirm_start = 0; Menu_Boot(); break; } if (buttons & CFG.button_save.mask) { bool ret; printf("\n\n"); if (need_save) { ret = CFG_save_game_opt(header->id); if (ret) { printf_x(gt("Options saved for this game.")); } else printf(gt("Error saving options!")); } else { ret = CFG_discard_game_opt(header->id); if (ret) printf_x(gt("Options discarded for this game.")); else printf(gt("Error discarding options!")); } sleep(1); } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_other.mask) { ret_val = 1; break; } if (buttons & CFG.button_cancel.mask) break; } CFG_release_game(game_cfg2); return ret_val; }
void __Menu_ShowList(void) { FgColor(CFG.color_header); if (enable_favorite) { printf_x(gt("Favorite Games")); printf(":\n"); } else { if (!CFG.hide_header) { printf_x(gt("Select the game you want to boot")); printf(":\n"); } } DefaultColor(); if (CFG.console_mark_page && gameStart > 0) { printf(" %s +", CFG.cursor_space); } printf("\n"); /* No game list*/ if (gameCnt) { u32 cnt; /* Print game list */ for (cnt = gameStart; cnt < gameCnt; cnt++) { struct discHdr *header = &gameList[cnt]; /* Entries per page limit reached */ if ((cnt - gameStart) >= ENTRIES_PER_PAGE) break; if (gameSelected == cnt) { FgColor(CFG.color_selected_fg); BgColor(CFG.color_selected_bg); Con_ClearLine(); } else { DefaultColor(); } /* Print entry */ //printf(" %2s %s\n", (gameSelected == cnt) ? ">>" : " ", char *title = __Menu_PrintTitle(get_title(header)); // cursor printf(" %s", (gameSelected == cnt) ? CFG.cursor : CFG.cursor_space); // favorite mark printf("%s", (CFG.console_mark_favorite && is_favorite(header->id)) ? CFG.favorite : " "); // title printf("%s", title); // saved mark if (CFG.console_mark_saved) { printf("%*s", (MAX_CHARACTERS - con_len(title)), (CFG_is_saved(header->id)) ? CFG.saved : " "); } printf("\n"); } DefaultColor(); if (CFG.console_mark_page && cnt < gameCnt) { printf(" %s +", CFG.cursor_space); } else { printf(" %s ", CFG.cursor_space); } //if (CFG.hide_hddinfo) { FgColor(CFG.color_footer); BgColor(CONSOLE_BG_COLOR); int num_page = 1 + (gameCnt - 1) / ENTRIES_PER_PAGE; int cur_page = 1 + gameSelected / ENTRIES_PER_PAGE; printf(" %-*.*s %d/%d", MAX_CHARACTERS - 8, MAX_CHARACTERS - 8, action_string, cur_page, num_page); action_string[0] = 0; //} } else { printf(" "); printf(gt("%s No games found!!"), CFG.cursor); printf("\n"); } /* Print free/used space */ FgColor(CFG.color_footer); BgColor(CONSOLE_BG_COLOR); if (!CFG.hide_footer) { printf("\n"); // (B) GUI (1) Options (2) Favorites // B: GUI 1: Options 2: Favorites //char c_gui = 'B', c_opt = '1'; //if (CFG.buttons == CFG_BTN_OPTIONS_B) { // c_gui = '1'; c_opt = 'B'; //} printf_(""); if (CFG.gui && CFG.button_gui) { printf("%s: GUI ", (button_names[CFG.button_gui])); } if (!CFG.disable_options && CFG.button_opt) { printf("%s: Options ", (button_names[CFG.button_opt])); } if (CFG.button_fav) { printf("%s: Favorites", (button_names[CFG.button_fav])); } } if (CFG.db_show_info) { printf("\n"); //load game info from XML - lustar __Menu_ShowGameInfo(false, gameList[gameSelected].id); } DefaultColor(); __console_flush(0); }
int Menu_Filter3() { struct discHdr *header = NULL; int redraw_cover = 0; struct Menu menu; int rows, cols, size; CON_GetMetrics(&cols, &rows); if ((size = rows-8) < 3) size = 3; menu_init(&menu, featureCnt+3); for (;;) { menu.line_count = 0; if (gameCnt) { header = &gameList[gameSelected]; } else { header = NULL; } int n; Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Filter by Online Features")); printf(":\n\n"); MENU_MARK(); printf("<%s>\n", gt("Filter by Genre")); MENU_MARK(); printf("<%s>\n", gt("Filter by Controller")); MENU_MARK(); printf("%s %s\n", ((filter_type == -1) ? "*" : " "), gt("All Games")); menu_window_begin(&menu, size, featureCnt); for (n=0;n<featureCnt;n++) { if (menu_window_mark(&menu)) printf("%s %s\n", ((filter_index == n && filter_type == 3) ? "*": " "), featureTypes[n][1]); } DefaultColor(); menu_window_end(&menu, cols); printf_h(gt("Press %s to select filter type"), (button_names[CFG.button_confirm.num])); __console_flush(0); if (redraw_cover) { if (header) Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); menu_move(&menu, buttons); int change = 0; if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT || buttons & CFG.button_confirm.mask || buttons & CFG.button_save.mask) change = +1; if (change) { if (0 == menu.current) { Menu_Filter(); redraw_cover = 1; goto end; } else if (1 == menu.current) { Menu_Filter2(); redraw_cover = 1; goto end; } else if (2 == menu.current) { showAllGames(); filter_type = -1; redraw_cover = 1; } for (n=0;n<featureCnt;n++) { if (3+n == menu.current) { redraw_cover = 1; if (filter_games(filter_features, featureTypes[n][0], 0) > -1) { filter_type = 3; filter_index = n; } break; } } } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_cancel.mask) break; } end: return 0; }
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_Partition(bool must_select) { int i; s32 ret = 0; int pnum = WBFS_GetPartitionCount(); struct Menu menu; char active[256]; menu_init(&menu, pnum); menu_init_active(&menu, active, 256); loop: menu_begin(&menu); /* Clear console */ Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Select a partition")); printf(":\n\n"); DefaultColor(); printf_("P# Name\n"); printf_("-----------------------------\n"); // P#1 ram1ro // P#2 sda1ro // P#3 sda2ro char partname[32]; for (i = 0; i < pnum; i++) { memset(partname, 0, 32); WBFS_GetPartitionName(i, (char *) &partname); MENU_MARK(); printf("%d %s\n", i, partname); } printf("\n"); printf_h(gt("Press %s button to select."), (button_names[CFG.button_confirm.num])); printf("\n"); printf_h(gt("Press %s button to go back."), (button_names[CFG.button_cancel.num])); printf("\n"); u32 buttons = Wpad_WaitButtonsCommon(); menu_move(&menu, buttons); // B button if (buttons & CFG.button_cancel.mask) { if (must_select) { if (WBFS_Selected()) return; printf("\n"); printf_(gt("No partition selected!")); printf("\n"); sleep(2); } else { return; } } // A button if (buttons & CFG.button_confirm.mask) { i = menu.current; __console_flush(0); ret = WBFS_OpenPart(i, CFG.partition); if (ret == 0) { if (must_select) { // called from global options __Menu_GetEntries(); } return; } } goto loop; }
int Menu_Sort() { struct discHdr *header = NULL; int redraw_cover = 0; int n = 0; bool first_run = 1; bool descend[sortCnt]; for (;n<sortCnt;n++) descend[n] = 0; struct Menu menu; menu_init(&menu, sortCnt); for (;;) { menu.line_count = 0; if (gameCnt) { header = &gameList[gameSelected]; } else { header = NULL; } Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Choose a sorting method")); printf(":\n\n"); for (n=0; n<sortCnt; n++) { if (sort_index == n && sort_desc && first_run) { first_run = 0; descend[n] = 1; } MENU_MARK(); printf("%s ", (sort_index == n ? "*": " ")); printf("%s", con_align(sortTypes[n].name,25)); printf("%s\n", !descend[n] ? gt("< ASC >") : gt("< DESC >")); } DefaultColor(); printf("\n"); printf_h(gt("Press %s to select sorting method"), (button_names[CFG.button_confirm.num])); __console_flush(0); if (redraw_cover) { if (header) Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); menu_move(&menu, buttons); int change = 0; if (buttons & WPAD_BUTTON_LEFT || buttons & WPAD_BUTTON_RIGHT) change = -1; if (buttons & CFG.button_confirm.mask || buttons & CFG.button_save.mask) change = +1; if (change) { for (n=0; n<sortCnt; n++) { if (menu.current == n) { if (change == -1) descend[n] = !descend[n]; else { if (descend[n]) { sort_desc = 1; sortList(sortTypes[n].sortDsc); } else { sort_desc = 0; sortList(sortTypes[n].sortAsc); } redraw_cover = 1; sort_index = n; break; } } } } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_cancel.mask) break; } return 0; }
int Menu_Global_Options() { int rows, cols, win_size = 11; CON_GetMetrics(&cols, &rows); if (strcmp(LAST_CFG_PATH, USBLOADER_PATH)) win_size += 2; if ((win_size = rows-win_size) < 3) win_size = 3; if (CFG.disable_options) return 0; struct discHdr *header = NULL; int redraw_cover = 0; struct Menu menu; menu_init(&menu, 9); for (;;) { menu.line_count = 0; if (gameCnt) { header = &gameList[gameSelected]; } else { header = NULL; } Con_Clear(); FgColor(CFG.color_header); printf_x(gt("Global Options")); printf(":\n\n"); DefaultColor(); menu_window_begin(&menu, win_size, 9); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Main Menu")); if (menu_window_mark(&menu)) printf("%s%2d/%-2d< %s > (%d)\n", con_align(gt("Profile:"),8), CFG.current_profile + 1, CFG.num_profiles, CFG.profile_names[CFG.current_profile], CFG.num_favorite_game); if (menu_window_mark(&menu)) printf("%s%2d/%2d < %s >\n", con_align(gt("Theme:"),7), cur_theme + 1, num_theme, *CFG.theme ? CFG.theme : gt("none")); if (menu_window_mark(&menu)) printf("%s< %s >\n", con_align(gt("Partition:"),13), CFG.partition); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Download All Missing Covers")); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Update WiiTDB Game Database")); // download database - lustar if (menu_window_mark(&menu)) printf("<%s>\n", gt("Update titles.txt")); if (menu_window_mark(&menu)) printf("<%s>\n", gt("Check For Updates")); DefaultColor(); menu_window_end(&menu, cols); printf_h(gt("Press %s for game options"), (button_names[CFG.button_other.num])); printf("\n"); printf_h(gt("Press %s to save global settings"), (button_names[CFG.button_save.num])); printf("\n\n"); Print_SYS_Info(); DefaultColor(); __console_flush(0); if (redraw_cover) { if (header) Gui_DrawCover(header->id); redraw_cover = 0; } u32 buttons = Wpad_WaitButtonsRpt(); menu_move(&menu, buttons); int change = 0; if (buttons & WPAD_BUTTON_LEFT) change = -1; if (buttons & WPAD_BUTTON_RIGHT) change = +1; if (buttons & CFG.button_confirm.mask) change = +1; if (change) { switch (menu.current) { case 0: Menu_Views(); return 0; case 1: CHANGE(CFG.current_profile, CFG.num_profiles-1); // refresh favorites list Switch_Favorites(enable_favorite); redraw_cover = 1; break; case 2: CFG_switch_theme(cur_theme + change); redraw_cover = 1; Cache_Invalidate(); break; case 3: Menu_Partition(true); return 0; case 4: Download_All_Covers(change > 0); Cache_Invalidate(); if (header) Gui_DrawCover(header->id); Menu_PrintWait(); break; case 5: Download_XML(); break; case 6: Download_Titles(); break; case 7: Online_Update(); break; } } // HOME button if (buttons & CFG.button_exit.mask) { Handle_Home(0); } if (buttons & CFG.button_save.mask) { int ret; printf("\n"); printf_x(gt("Saving Settings... ")); printf("\n"); __console_flush(0); FgColor(CFG.color_inactive); ret = CFG_Save_Global_Settings(); DefaultColor(); if (ret) { printf_(gt("OK")); printf("\n"); Save_Game_List(); } else { printf_(gt("ERROR")); } printf("\n"); //sleep(2); Menu_PrintWait(); } if (buttons & WPAD_BUTTON_PLUS) { printf("\n"); mem_stat(); Menu_PrintWait(); } if (buttons & CFG.button_other.mask) return 1; if (buttons & CFG.button_cancel.mask) break; } return 0; }
s32 WBFS_OpenNamed(char *partition) { int i = 0; u32 part_fs = PART_FS_WBFS; u32 part_idx = 0; u32 part_lba = 0; s32 ret = 0; PartList plist; int x, fs; // close WBFS_Close(); dbg_printf("open_part(%s)\n", partition); // Get partition entries ret = Partition_GetList(wbfsDev, &plist); if (ret || plist.num == 0) return -1; // parse partition option if (strcasecmp(partition, "auto") == 0) { int fs_list[] = { PART_FS_WBFS, PART_FS_FAT, PART_FS_NTFS }; // PART_FS_EXT int n = sizeof(fs_list) / sizeof(int); for (x=0; x<n; x++) { fs = fs_list[x]; i = PartList_FindFS(&plist, fs, 1, NULL); if (i < 0) continue; if ((fs == PART_FS_WBFS) || is_game_fs(wbfsDev, plist.pentry[i].sector)) { part_fs = fs; part_idx = 1; goto found; } } } else { for (x=0; x<PART_FS_NUM; x++) { fs = PART_FS_FIRST + x; char *fsname = get_fs_name(fs); int len = strlen(fsname); if (strncasecmp(partition, fsname, len) == 0) { int idx = atoi(partition + len); if (idx < 1 || idx > 9) goto err; i = PartList_FindFS(&plist, fs, idx, NULL); if (i >= 0) { part_fs = fs; part_idx = idx; goto found; } } } } // nothing found goto err; found: if (i >= plist.num) goto err; // set partition lba sector part_lba = plist.pentry[i].sector; if (WBFS_OpenPart(part_fs, part_idx, part_lba, plist.pentry[i].size, partition)) { goto err; } // success dbg_printf("OK! partition=%s\n", partition); return 0; err: Gui_Console_Enable(); printf(gt("Invalid partition: '%s'"), partition); printf("\n"); __console_flush(0); sleep(2); return -1; }