Beispiel #1
0
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();
		}
	}
}
Beispiel #2
0
/* File Operations - Leathl */
int Menu_FileOperations(fatFile *file, char *inFilePath)
{
	f32 filesize = (file->filestat.st_size / MB_SIZE);

	for (;;)
	{
		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", "Delete"); //There's yet nothing else than delete

		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();

		/* A button */
		if (buttons & WPAD_BUTTON_A)
			break;

		/* B button */
		if (buttons & WPAD_BUTTON_B)
			return 0;
	}

	Con_Clear();

	printf("[+] Deleting \"%s\", please wait...\n", file->filename);

	sprintf(gTmpFilePath, "%s/%s", inFilePath, file->filename);
	int error = remove(gTmpFilePath);
	if (error != 0)
		printf("    ERROR!");
	else
		printf("    Successfully deleted!");

	printf("\n");
	printf("    Press any button to continue...\n");

	WaitButtons();

	return !error;
}
Beispiel #3
0
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();
}
Beispiel #4
0
static void __DisplayEntryMessage() {
    Con_Clear();
    Con_SetColor(CON_COLOR_YELLOW);
    Con_PutString("Agni-Kernel-");
    Con_SetColor(CON_COLOR_RED);
    Con_PutString("dev-0001\n");
    Con_SetColor(CON_COLOR_WHITE);
}
Beispiel #5
0
void Menu_Loop(void)
{
	// enable the console if starting with console mode
	if (CFG.gui != CFG_GUI_START) {
		if (!(CFG.direct_launch && !CFG.intro)) {
			Gui_Console_Enable();
		}
	}

	// Direct Launch?
	Direct_Launch();

	// Start Music
	Music_Start();

	// Clear console
	// (so that it doesn't show when switching back from gui)
	Con_Clear();
	__console_scroll = 0;

	// Init Favorites
	Switch_Favorites(CFG.start_favorites);

	// Start GUI
	if (CFG.gui == CFG_GUI_START) goto skip_list;

	/* Menu loop */
	for (;;) {
		/* Clear console */
		Con_Clear();

		/* Show gamelist */
		__Menu_ShowList();

		/* Show cover */
		__Menu_ShowCover();

		//memstat();

		skip_list:
		/* Controls */
		__Menu_Controls();
	}
}
Beispiel #6
0
void Menu_Loop(void)
{
	/* Menu loop */
	for (;;) {
		/* Clear console */
		Con_Clear();

		/* Print entries */
		__Menu_PrintList();

		/* Controls */
		__Menu_Controls();
	}
}
Beispiel #7
0
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;
}
Beispiel #8
0
void Menu_Loop(void)
{
	/* Device menu */
	Menu_Device();

	/* Menu loop */
	for (;;) {
		/* Clear console */
		Con_Clear();

		/* Show gamelist */
		__Menu_ShowList();

		/* Show cover */
		__Menu_ShowCover();

		/* Controls */
		__Menu_Controls();
	}
}
Beispiel #9
0
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;
}
Beispiel #10
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;
}
Beispiel #11
0
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;
}
Beispiel #12
0
void __Menu_Controls(void)
{
	if (CFG.gui == CFG_GUI_START) {
		go_gui = true;
		goto gui_mode;
	}

	//u32 buttons = Wpad_WaitButtons();
	u32 buttons = Wpad_WaitButtonsRpt();

	/* 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 (CFG.cursor_jump) {
			__Menu_MoveList(-CFG.cursor_jump);
		} else {
			__Menu_MoveList((gameSelected-gameStart == 0) ? -ENTRIES_PER_PAGE : -(gameSelected-gameStart));
		}
	}

	if (buttons & WPAD_BUTTON_RIGHT) {
		//__Menu_MoveList(ENTRIES_PER_PAGE);
		if (CFG.cursor_jump) {
			__Menu_MoveList(CFG.cursor_jump);
		} else {
			__Menu_MoveList((gameSelected-gameStart == (ENTRIES_PER_PAGE - 1)) ? ENTRIES_PER_PAGE : ENTRIES_PER_PAGE - (gameSelected-gameStart) - 1);
		}
	}

	check_buttons:


	if (CFG.admin_lock) {
		if (buttons & CFG.button_other.mask) {

			static long long t_start;
			long long t_now;
			unsigned ms_diff = 0;
			bool display_unlock = false;

			Con_Clear();
			t_start = gettime();
			while (!display_unlock && (Wpad_Held(0) & CFG.button_other.mask)) {
				buttons = Wpad_GetButtons();
				VIDEO_WaitVSync();
				t_now = gettime();
				ms_diff = diff_msec(t_start, t_now);
				if (ms_diff > 5000)
					display_unlock = true;
			}
			if (display_unlock)
				Menu_Unlock();
			else
				buttons = buttonmap[MASTER][CFG.button_other.num];
		}
	}

	/* A button */
	//if (buttons & CFG.button_confirm.mask)
	//	Menu_Boot(0);

	int i;
	for (i = 4; i < MAX_BUTTONS; i++) {
			if (buttons & buttonmap[MASTER][i]) 
				DoAction(*(&CFG.button_M + (i - 4)));
	}
		
	//if (buttons & CFG.button_cancel.mask)
	//	DoAction(CFG.button_B);

	///* HOME button */
	//if (buttons & CFG.button_exit.mask) {
	//	DoAction(CFG.button_H);
	//	//Handle_Home(1);
	//}

	///* PLUS (+) button */
	//if (buttons & WPAD_BUTTON_PLUS)
	//	DoAction(CFG.button_P);
	////	Menu_Install();

	///* MINUS (-) button */
	//if (buttons & WPAD_BUTTON_MINUS)
	//	DoAction(CFG.button_M);
	////	Menu_Views();
	////	Menu_Remove();

	//if (buttons & WPAD_BUTTON_2)
	//	DoAction(CFG.button_2);

	//if (buttons & CFG.button_other.mask)
	//	DoAction(CFG.button_1);

	//if (buttons & WPAD_BUTTON_X)
	//	DoAction(CFG.button_X);

	//if (buttons & WPAD_BUTTON_Y)
	//	DoAction(CFG.button_Y);

	//if (buttons & WPAD_BUTTON_Z)
	//	DoAction(CFG.button_Z);

	//if (buttons & WPAD_BUTTON_C)
	//	DoAction(CFG.button_C);

	//if (buttons & WPAD_BUTTON_L)
	//	DoAction(CFG.button_L);

	//if (buttons & WPAD_BUTTON_R)
	//	DoAction(CFG.button_R);

	//// button 2 - switch favorites
	//if (buttons & CFG.button_save.mask) {
	//	extern void reset_sort_default();
	//	reset_sort_default();
	//	Switch_Favorites(!enable_favorite);
	//}


	//if (CFG.gui) {
	//	if (CFG.buttons == CFG_BTN_OPTIONS_1) {
	//		if (buttons & CFG.button_cancel.mask) go_gui = true;
	//	} else if (CFG.buttons == CFG_BTN_OPTIONS_B) {
	//		if (buttons & CFG.button_other.mask) go_gui = true;
	//	}
	//}
	//if (!CFG.disable_options) {
	//	if (CFG.buttons == CFG_BTN_OPTIONS_1) {
	//		if (buttons & CFG.button_other.mask) Menu_Options();
	//	} else if (CFG.buttons == CFG_BTN_OPTIONS_B) {
	//		if (buttons & CFG.button_cancel.mask) Menu_Options();
	//	} else { 
	//		/* ONE (1) button */
	//		if (buttons & CFG.button_other.mask) {
	//			//Menu_Device();
	//			Menu_Options();
	//		}
	//	}
	//}
	
	if (go_gui) {
		gui_mode:;
		int prev_sel = gameSelected;
		CFG.gui = 1; // disable auto start
		buttons = Gui_Mode();
		if (prev_sel != gameSelected) {
			// List scrolling
			__Menu_ScrollStartList();
		}
		// if only returning to con mode, clear button status
		/*if (CFG.buttons == CFG_BTN_OPTIONS_1) {
			if (buttons & CFG.button_cancel.mask) buttons = 0;
		} else if (CFG.buttons == CFG_BTN_OPTIONS_B) {
			if (buttons & CFG.button_other.mask) buttons = 0;
		}
		*/
		// if action started from gui, process it then return to gui
		//if (buttons) {
		//	go_gui = true;
		goto check_buttons;
		//}
	}
}
Beispiel #13
0
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();
}
Beispiel #14
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;
}
Beispiel #15
0
void Menu_Unlock() {
	u32 buttons;
	static long long t_start;
	long long t_now;
	unsigned ms_diff = 0;
	int i = 0;
	char buf[16];
	bool unlocked = false;
	memset(buf, 0, sizeof(buf));

	//init the previous settings
	if (unlock_init) {
		disable_options = CFG.disable_options;
		confirm_start = CFG.confirm_start;
		unlock_init = false;
	}
	
	Con_Clear();
	printf(gt("Configurable Loader %s"), CFG_VERSION);
	printf("\n\n");

	if (CFG.admin_mode_locked) {
		printf(gt("Enter Code: "));
		t_start = gettime();
		
		while (ms_diff < 30000 && !unlocked) {
			buttons = Wpad_GetButtons();
			if (buttons) {
				printf("*");
				buf[i] = get_unlock_buttons(buttons);
				i++;
				if (stricmp(buf, CFG.unlock_password) == 0) {
					unlocked = true;
				}
				if (i >= 10) break;
			}
			VIDEO_WaitVSync();
			t_now = gettime();
			ms_diff = diff_msec(t_start, t_now);
		}
	}
	if (unlocked) {
		//save existing settings
		disable_options = CFG.disable_options;
		confirm_start = CFG.confirm_start;

		//enable all "admin-type" screens
		CFG.disable_options = 0;
		CFG.confirm_start = 1;
		CFG.admin_mode_locked = 0;
		printf("\n\n");
		printf(gt("SUCCESS!"));
		sleep(1);
		//show the hidden games
		__Menu_GetEntries();
	} else {
		//set the lock back on
		CFG.disable_options = disable_options;
		CFG.confirm_start = confirm_start;
		CFG.admin_mode_locked = 1;
		printf("\n\n");
		printf(gt("LOCKED!"));
		sleep(1);
		//reset the hidden games
		__Menu_GetEntries();
	}
}
Beispiel #16
0
/*
================
Con_CheckResize

If the line width has changed, reformat the buffer.
================
*/
qboolean Con_CheckResize( void )
{
	int   i, textWidthInChars, oldwidth, oldtotallines, numlines, numchars;
	conChar_t buf[ CON_TEXTSIZE ];
	qboolean  ret = qtrue;

	if ( cls.glconfig.vidWidth )
	{
		const int consoleVidWidth = cls.glconfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides );
		textWidthInChars = consoleVidWidth / SCR_ConsoleFontUnicharWidth( 'W' );
	}
	else
	{
		textWidthInChars = 0;
	}

	if ( textWidthInChars == consoleState.textWidthInChars )
	{
		// nothing
	}
	else if ( textWidthInChars < 1 ) // video hasn't been initialized yet
	{
		consoleState.textWidthInChars = DEFAULT_CONSOLE_WIDTH;
		consoleState.maxScrollbackLengthInLines = CON_TEXTSIZE / consoleState.textWidthInChars;
		Con_Clear();

		consoleState.currentLine = consoleState.maxScrollbackLengthInLines - 1;
		consoleState.bottomDisplayedLine = consoleState.currentLine;
		consoleState.scrollLineIndex = consoleState.currentLine;

		ret = qfalse;
	}
	else
	{
		oldwidth = consoleState.textWidthInChars;
		consoleState.textWidthInChars = textWidthInChars;
		oldtotallines = consoleState.maxScrollbackLengthInLines;
		consoleState.maxScrollbackLengthInLines = CON_TEXTSIZE / consoleState.textWidthInChars;
		numlines = oldwidth < 0 ? 0 : oldtotallines;

		if ( consoleState.maxScrollbackLengthInLines < numlines )
		{
			numlines = consoleState.maxScrollbackLengthInLines;
		}

		numchars = oldwidth;

		if ( consoleState.textWidthInChars < numchars )
		{
			numchars = consoleState.textWidthInChars;
		}

		Com_Memcpy( buf, consoleState.text, sizeof( consoleState.text ) );
		Con_Clear();

		for ( i = 0; i < numlines; i++ )
		{
			conChar_t* destination = consoleState.text + ( consoleState.maxScrollbackLengthInLines - 1 - i ) * consoleState.textWidthInChars;
			memcpy( destination,
			        buf + ( ( consoleState.currentLine - i + oldtotallines ) % oldtotallines ) * oldwidth,
			        numchars * sizeof( conChar_t ) );

			if( destination[0].ch )
				consoleState.usedScrollbackLengthInLines++;
		}

		consoleState.currentLine = consoleState.maxScrollbackLengthInLines - 1;
		consoleState.bottomDisplayedLine = consoleState.currentLine;
		consoleState.scrollLineIndex = consoleState.currentLine;
	}

	if ( con_prompt )
	{
		char prompt[ MAX_STRING_CHARS ];

		Q_strncpyz( prompt, con_prompt->string, sizeof( prompt ) );
		Q_CleanStr( prompt );

		g_console_field_width = consoleState.textWidthInChars - 8 - Q_UTF8_Strlen( prompt );
		g_consoleField.SetWidth(g_console_field_width);
	}

	return ret;
}
Beispiel #17
0
/*
================
Con_Clear_f
================
*/
void Con_Clear_f( void )
{
	Con_Clear();
	Con_ScrollToBottom(); // go to end
}
Beispiel #18
0
/*
================
Con_CheckResize

If the line width has changed, reformat the buffer.
================
*/
void Con_CheckResize( void )
{
	int   i, width, oldwidth, oldtotallines, numlines, numchars;
	conChar_t buf[ CON_TEXTSIZE ];

	if ( cls.glconfig.vidWidth )
	{
		if ( scr_conUseOld->integer )
		{
			width = cls.glconfig.vidWidth / SCR_ConsoleFontUnicharWidth( 'W' );
		}
		else
		{
			float adjust = 30;
			SCR_AdjustFrom640( &adjust, NULL, NULL, NULL );
			width = ( cls.glconfig.vidWidth - adjust ) / SCR_ConsoleFontUnicharWidth( 'W' );
		}

		g_consoleField.widthInChars = width - Q_PrintStrlen( cl_consolePrompt->string ) - 1;
	}
	else
	{
		width = 0;
	}

	if ( width == con.linewidth )
	{
		// nothing
	}
	else if ( width < 1 ) // video hasn't been initialized yet
	{
		width = DEFAULT_CONSOLE_WIDTH;
		con.linewidth = width;
		con.totallines = CON_TEXTSIZE / con.linewidth;
		Con_Clear();

		con.current = con.totallines - 1;
		con.display = con.current;
	}
	else
	{
		SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL );

		oldwidth = con.linewidth;
		con.linewidth = width;
		oldtotallines = con.totallines;
		con.totallines = CON_TEXTSIZE / con.linewidth;
		numlines = oldtotallines;

		if ( con.totallines < numlines )
		{
			numlines = con.totallines;
		}

		numchars = oldwidth;

		if ( con.linewidth < numchars )
		{
			numchars = con.linewidth;
		}

		Com_Memcpy( buf, con.text, sizeof( con.text ) );
		Con_Clear();

		for ( i = 0; i < numlines; i++ )
		{
			memcpy( con.text + ( con.totallines - 1 - i ) * con.linewidth,
			        buf + ( ( con.current - i + oldtotallines ) % oldtotallines ) * oldwidth,
			        numchars * sizeof( conChar_t ) );
		}

		con.current = con.totallines - 1;
		con.display = con.current;
	}

	g_console_field_width = g_consoleField.widthInChars = con.linewidth - 7 - ( cl_consolePrompt ? Q_UTF8Strlen( cl_consolePrompt->string ) : 0 );
}
Beispiel #19
0
/*
================
Con_Clear_f
================
*/
void Con_Clear_f( void )
{
	Con_Clear();
	Con_Bottom(); // go to end
}
Beispiel #20
0
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();
}
Beispiel #21
0
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, &sector_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();
}
Beispiel #22
0
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();
}
Beispiel #23
0
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;
}
Beispiel #24
0
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();
}
Beispiel #25
0
void Menu_SelectIOS(void)
{
	u8 *iosVersion = NULL;
	u32 iosCnt;
	u8 tmpVersion;

	u32 cnt;
	s32 ret, selected = 0;
	bool found = false;

	/* Get IOS versions */
	ret = Title_GetIOSVersions(&iosVersion, &iosCnt);
	if (ret < 0)
		return;

	/* Sort list */
	qsort(iosVersion, iosCnt, sizeof(u8), __Menu_IsGreater);

	if (gConfig.cIOSVersion < 0)
		tmpVersion = CIOS_VERSION;
	else
	{
		tmpVersion = (u8)gConfig.cIOSVersion;
		// For debugging only
		//printf ("User pre-selected cIOS: %i\n", tmpVersion);
		//WaitButtons();
	}

	/* Set default version */
	for (cnt = 0; cnt < iosCnt; cnt++) {
		u8 version = iosVersion[cnt];

		/* Custom IOS available */
		//if (version == CIOS_VERSION)
		if (version == tmpVersion)
		{
			selected = cnt;
			found = true;
			break;
		}

		/* Current IOS */
		if (version == IOS_GetVersion())
			selected = cnt;
	}

	/* Ask user for IOS version */
	if ((gConfig.cIOSVersion < 0) || (found == false))
	{
		for (;;)
		{
			/* Clear console */
			Con_Clear();

			printf("\t>> Select IOS version to use: < IOS%d >\n\n", iosVersion[selected]);

			printf("\t   Press LEFT/RIGHT to change IOS version.\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 = (iosCnt - 1);
			}
			if (buttons & WPAD_BUTTON_RIGHT) {
				if ((++selected) >= iosCnt)
					selected = 0;
			}

			/* HOME button */
			if (buttons & WPAD_BUTTON_HOME)
				Restart();

			/* A button */
			if (buttons & WPAD_BUTTON_A)
				break;
		}
	}


	u8 version = iosVersion[selected];

	if (IOS_GetVersion() != version) {
		/* Shutdown subsystems */
		Wpad_Disconnect();

		/* Load IOS */
		ret = IOS_ReloadIOS(version);

		/* Initialize subsystems */
		Wpad_Init();
	}
}
Beispiel #26
0
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();
}
Beispiel #27
0
void Menu_NandDevice(void)
{
	s32 ret, selected = 0;

	/* Disable NAND emulator */
	if (ndev) {
		Nand_Unmount(ndev);
		Nand_Disable();
	}

	/* Select source device */
	if (gConfig.nandDeviceIndex < 0)
	{
		for (;;) {
			/* Clear console */
			Con_Clear();

			/* Selected device */
			ndev = &ndevList[selected];

			printf("\t>> Select NAND emulator device: < %s >\n\n", ndev->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_NAND_DEVICES - 1);
			}
			if (buttons & WPAD_BUTTON_RIGHT) {
				if ((++selected) >= NB_NAND_DEVICES)
					selected = 0;
			}

			/* HOME button */
			if (buttons & WPAD_BUTTON_HOME)
				Restart();

			/* A button */
			if (buttons & WPAD_BUTTON_A)
				break;
		}
	}
	else
	{
		ndev = &ndevList[gConfig.nandDeviceIndex];
	}

	/* No NAND device */
	if (!ndev->mode)
		return;

	printf("[+] Enabling NAND emulator...");
	fflush(stdout);

	/* Mount NAND device */
	ret = Nand_Mount(ndev);
	if (ret < 0) {
		printf(" ERROR! (ret = %d)\n", ret);
		goto err;
	}

	/* Enable NAND emulator */
	ret = Nand_Enable(ndev);
	if (ret < 0) {
		printf(" ERROR! (ret = %d)\n", ret);
		goto err;
	} else
		printf(" OK!\n");

	return;

err:
	printf("\n");
	printf("    Press any button to continue...\n");

	WaitButtons();

	/* Prompt menu again */
	Menu_NandDevice();
}
Beispiel #28
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;
}
Beispiel #29
0
void Menu_WadList(void)
{
	char str [100];
	fatFile *fileList = NULL;
	u32      fileCnt;
	s32 ret, selected = 0, start = 0;
    char *tmpPath = malloc (MAX_FILE_PATH_LEN);

    // wiiNinja: check for malloc error
    if (tmpPath == NULL)
    {
        ret = -999; // What am I gonna use here?
		printf(" ERROR! Out of memory (ret = %d)\n", ret);
        return;
    }

	printf("[+] Retrieving file list...");
	fflush(stdout);
	
	gDirLevel = 0;

    // wiiNinja: The root is always the primary folder
    // But if the user has a /wad directory, just go there. This makes
    // both sides of the argument win
	sprintf(tmpPath, "%s:" WAD_DIRECTORY, fdev->mount);
    PushCurrentDir(tmpPath,0,0);
	//if (strcmp (WAD_DIRECTORY, WAD_ROOT_DIRECTORY) != 0)
	if (strcmp (WAD_DIRECTORY, gConfig.startupPath) != 0)
	{
        // If the directory can be successfully opened, it must exists
        //DIR_ITER *tmpDirPtr = NULL;
        //tmpDirPtr = diropen(WAD_ROOT_DIRECTORY);
        //if (tmpDirPtr)
        //{
		//	dirclose (tmpDirPtr);

            // Now push the /wad directory as the current operating folder
            //sprintf(tmpPath, "%s:" WAD_ROOT_DIRECTORY, fdev->mount);
			sprintf(tmpPath, "%s:%s", fdev->mount, gConfig.startupPath);
			//printf ("\nThe final startupPath is: %s\n", tmpPath);
			//WaitButtons ();
            PushCurrentDir(tmpPath,0,0); // wiiNinja
        //}
	}

	/* Retrieve filelist */
getList:
    if (fileList)
    {
        free (fileList);
        fileList = NULL;
    }

	ret = __Menu_RetrieveList(tmpPath, &fileList, &fileCnt);
	if (ret < 0) {
		printf(" ERROR! (ret = %d)\n", ret);
		goto err;
	}

	/* No files */
	if (!fileCnt) {
		printf(" No files found!\n");
		goto err;
	}

	for (;;) 
	{
		u32 cnt;
		s32 index;

		/* Clear console */
		Con_Clear();

		/** Print entries **/
		cnt = strlen(tmpPath);
		if(cnt>30)
			index = cnt-30;
		else
			index = 0;

		printf("[+] WAD files on [%s]:\n\n", tmpPath+index);

		/* Print entries */
		for (cnt = start; cnt < fileCnt; cnt++) 
		{
			fatFile *file     = &fileList[cnt];
			f32      filesize = file->filestat.st_size / MB_SIZE;

			/* Entries per page limit */
			if ((cnt - start) >= ENTRIES_PER_PAGE)
				break;

			strncpy(str, file->filename, 48);
			str[48]=0;

			/* Print filename */
			//printf("\t%2s %s (%.2f MB)\n", (cnt == selected) ? ">>" : "  ", file->filename, filesize);
            if (file->filestat.st_mode & S_IFDIR) // wiiNinja
				printf("\t%2s [%s]\n", (cnt == selected) ? ">>" : "  ", str);
            else
                printf("\t%2s %s (%.2f MB)\n", (cnt == selected) ? ">>" : "  ", str, filesize);

		}

		printf("\n");

		printf("[+] Press A button to (un)install a WAD file.\n");
		if(gDirLevel>1)
			printf("    Press B button to go up-level DIR");
		else
			printf("    Press B button to select a storage device");

		/** Controls **/
		u32 buttons = WaitButtons();

		/* DPAD buttons */
		if (buttons & (WPAD_BUTTON_UP | WPAD_BUTTON_LEFT)) {
			selected -= (buttons & WPAD_BUTTON_LEFT) ? ENTRIES_PER_PAGE : 1;

			if (selected <= -1)
				selected = (fileCnt - 1);
		}
		if (buttons & (WPAD_BUTTON_DOWN | WPAD_BUTTON_RIGHT)) {
			selected += (buttons & WPAD_BUTTON_RIGHT) ? ENTRIES_PER_PAGE : 1;

			if (selected >= fileCnt)
				selected = 0;
		}

		/* HOME button */
		if (buttons & WPAD_BUTTON_HOME)
			Restart();

		/* A button */
		if (buttons & WPAD_BUTTON_A)
		{
			fatFile *tmpFile = &fileList[selected];
            char *tmpCurPath;
            if (tmpFile->filestat.st_mode & S_IFDIR) // wiiNinja
            {
                if (strcmp (tmpFile->filename, "..") == 0)
                {
					selected = 0;
					start = 0;

					// Previous dir
                    tmpCurPath = PopCurrentDir(&selected, &start);
                    if (tmpCurPath != NULL)
                        sprintf(tmpPath, "%s", tmpCurPath);
						
                    goto getList;
                }
                else if (IsListFull () == true)
                {
                    WaitPrompt ("Maximum number of directory levels is reached.\n");
                }
                else
                {
                    tmpCurPath = PeekCurrentDir ();
                    if (tmpCurPath != NULL)
                    {
						if(gDirLevel>1)
							sprintf(tmpPath, "%s/%s", tmpCurPath, tmpFile->filename);
						else
							sprintf(tmpPath, "%s%s", tmpCurPath, tmpFile->filename);
                    }
                    // wiiNinja: Need to PopCurrentDir
                    PushCurrentDir (tmpPath, selected, start);
					selected = 0;
					start = 0;
                    goto getList;
                }
            }
            else
            {
                tmpCurPath = PeekCurrentDir ();
                if (tmpCurPath != NULL)
                    Menu_WadManage(tmpFile, tmpCurPath);
            }
		}

		/* B button */
		if (buttons & WPAD_BUTTON_B)
		{
			if(gDirLevel<=1)
			{
				return;
			}

			char *tmpCurPath;
			selected = 0;
			start = 0;
			// Previous dir
			tmpCurPath = PopCurrentDir(&selected, &start);
			if (tmpCurPath != NULL)
				sprintf(tmpPath, "%s", tmpCurPath);
			goto getList;
			//return;
		}

		/** Scrolling **/
		/* List scrolling */
		index = (selected - start);

		if (index >= ENTRIES_PER_PAGE)
			start += index - (ENTRIES_PER_PAGE - 1);
		if (index <= -1)
			start += index;
	}

err:
	printf("\n");
	printf("    Press any button to continue...\n");

	free (tmpPath);
	
	/* Wait for button */
	WaitButtons();
}
Beispiel #30
0
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;
	}
}