Example #1
0
void InstallConfigData(){
	if(CheckInstallationData() == 0)
	{
		first_boot = false;
		return;
	}

	first_boot = true;
	trySetLangFromTheme();
	writeCfg();

	sprintf(str, "/rxTools/Theme/%u/cfg0TOP.bin", cfgs[CFG_THEME].val.i);
	DrawTopSplash(str, str, str);
	sprintf(str, "/rxTools/Theme/%u/cfg0.bin", cfgs[CFG_THEME].val.i);
	DrawBottomSplash(str);

	int res = InstallData("0");	//SD Card
	sprintf(str, "/rxTools/Theme/%u/cfg1%c.bin", cfgs[CFG_THEME].val.i, res == 0 ? 'O' : 'E');
	DrawBottomSplash(str);
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	DrawTopSplash(str, strl, strr);

	InputWait();
}
Example #2
0
// @breif  Main routine surely.
int main(void) {

	FSInit();
	CFW_getSystemVersion();
	if (cfw_bootGUI==true) //If gui autoboot is enabled or L is held, show the ui //L held not working
	{
		DrawClearScreenAll();
		//MENU
		while (true)
		{
			//DRAW GUI
			if (menu_idx == MENU_ITEMS - 1)
			{
				sprintf(str, "/3ds/PastaCFW/UI/%c/menu6.bin", cfw_theme);
				DrawBottomSplash(str);
				sprintf(str, "/3ds/PastaCFW/UI/%c/creditsTOP.bin", cfw_theme);
				DrawTopSplash(str);
				TOP_Current = 0;
			}
			else
			{
				sprintf(str, "/3ds/PastaCFW/UI/%c/menu0.bin", cfw_theme);
				str[23] = menu_idx + 48;
				DrawBottomSplash(str); //BOTTOM SCREEN
				if (TOP_Current == 0){
					sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme);
					DrawTopSplash(str); //TOP SCREEN
					TOP_Current = 1;
				}
			}
			//MENU CONTROLS
			u32 pad_state = HidWaitForInput();
			if ((pad_state & BUTTON_RIGHT || pad_state & BUTTON_DOWN) && menu_idx != MENU_ITEMS - 1) menu_idx++; //MOVE RIGHT/DOWN (It depends on the theme)
			else if ((pad_state & BUTTON_LEFT || pad_state & BUTTON_UP) && menu_idx != 0)menu_idx--; //MOVE LEFT/UP (It depends on the theme)
			else if (pad_state & BUTTON_A)//SELECT
			{
				if (menu_idx == 0){ CFW_Boot(); break; }//BOOT CFW
				else if (menu_idx == 1)break; //REBOOT
				else if (menu_idx == 2)CFW_NandDumper(); //NAND DUMPER
				else if (menu_idx == 4)CFW_ARM9Dumper(); //ARM9 RAM DUMPER
				else if (menu_idx == 5)CFW_Settings(); //SETTINGS
			}
			else if (pad_state & BUTTON_START && pad_state & BUTTON_SELECT) //POWER OFF
			{
				i2cWriteRegister(I2C_DEV_MCU, 0x20, (u8)(1 << 0)); //As seen on 3dbrew
				while (1);
			}
		}
	}
	else CFW_Boot(); //else directly boot the cfw
	if (firmlaunch == true && cfw_enablefirmlaunch) FirmLaunch();

	// return control to FIRM ARM9 code (performs firmlaunch)
	return 0;
}
Example #3
0
static void drawTop()
{
	wchar_t str[_MAX_LFN];
	wchar_t strl[_MAX_LFN];
	wchar_t strr[_MAX_LFN];

	swprintf(str, _MAX_LFN, L"/rxTools/Theme/%u/TOP.bin",
		cfgs[CFG_THEME].val.i);
	if (cfgs[CFG_3D].val.i) {
		swprintf(strl, _MAX_LFN, L"/rxTools/Theme/%u/TOPL.bin",
			cfgs[CFG_THEME].val.i);
		swprintf(strr, _MAX_LFN, L"/rxTools/Theme/%u/TOPR.bin",
			cfgs[CFG_THEME].val.i);
		DrawTopSplash(str, strl, strr);
	} else
		DrawTopSplash(str, str, str);
}
Example #4
0
void InstallConfigData(){
	if(CheckInstallationData() == 0) return;
	
	sprintf(str, "/rxTools/Theme/%c/cfg0TOP.bin", Theme);
	DrawTopSplash(str);
	sprintf(str, "/rxTools/Theme/%c/cfg0.bin", Theme);
	DrawBottomSplash(str);

	int res = InstallData("0");	//SD Card
	if (res == 0)
	{
		sprintf(str, "/rxTools/Theme/%c/cfg1O.bin", Theme);
		DrawBottomSplash(str);
	}
	else
	{
		sprintf(str, "/rxTools/Theme/%c/cfg1E.bin", Theme);
		DrawBottomSplash(str);
	}
	
	//print("\nPress A to exit\n"); 
	WaitForButton(BUTTON_A);
}
Example #5
0
int Initialize()
{
	char str[100];
	char strl[100];
	char strr[100];
	char tmp[256];
	wchar_t wtmp[256];
	int r;

	preloadStringsA();

	DrawString(BOT_SCREEN, strings[STR_INITIALIZING], FONT_WIDTH, SCREEN_HEIGHT-FONT_HEIGHT, WHITE, BLACK);

	if(FSInit()){
		DrawString(BOT_SCREEN, strings[STR_LOADING], BOT_SCREEN_WIDTH/2, SCREEN_HEIGHT-FONT_HEIGHT, WHITE, BLACK);
	}else{
		DrawString(BOT_SCREEN, strings[STR_FAILED], BOT_SCREEN_WIDTH/2, SCREEN_HEIGHT-FONT_HEIGHT, RED, BLACK);
		return 1;
	}

	LoadFont();
	if (fontLoaded){
		swprintf(wtmp, sizeof(wtmp)/sizeof(wtmp[0]), strings[STR_ERROR_OPENING], fontpath);
		DrawString(BOT_SCREEN, wtmp, FONT_WIDTH, SCREEN_HEIGHT-FONT_HEIGHT*2, RED, BLACK);
	}else{
		preloadStringsU();
	}

	//Console Stuff
	ConsoleSetXY(15, 20);
	ConsoleSetWH(BOT_SCREEN_WIDTH-30, SCREEN_HEIGHT-80);
	ConsoleSetBorderColor(BLUE);
	ConsoleSetTextColor(RGB(0, 141, 197));
	ConsoleSetBackgroundColor(TRANSPARENT);
	ConsoleSetSpecialColor(BLUE);
	ConsoleSetSpacing(2);
	ConsoleSetBorderWidth(3);
	//Check that the data is installed
	f_mkdir("rxTools");
	f_mkdir("rxTools/nand");
	InstallConfigData();
	readCfg();

	if (fontLoaded)
		cfgs[CFG_LANG].val.s = cfgLang;
	r = loadStrings();
	if (r) {
		sprintf(tmp, "%s/%s", langPath, cfgs[CFG_LANG].val.s);
		swprintf(wtmp, sizeof(wtmp)/sizeof(wtmp[0]), strings[STR_ERROR_OPENING], tmp);
		DrawString(BOT_SCREEN, wtmp, FONT_WIDTH, SCREEN_HEIGHT-FONT_HEIGHT*3, RED, BLACK);
	}
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	if (cfgs[CFG_3D].val.i)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	if (!cfgs[CFG_GUI].val.i)
	{
		if(cfgs[CFG_SILENT].val.i)
		{
			sprintf(str, "/rxTools/Theme/%u/boot.bin", cfgs[CFG_THEME].val.i);
			DrawBottomSplash(str);

			for (int i = 0; i < 0x333333 * 2; i++){
				uint32_t pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
		else
		{
			ConsoleInit();
			ConsoleSetTitle(strings[STR_AUTOBOOT]);
			print(strings[STR_HOLD_BUTTON_ACTION], strings[STR_BUTTON_R], strings[STR_OPEN_MENU]);
			ConsoleShow();

			for (int i = 0; i < 0x333333 * 6; i++){
				uint32_t pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
		rxMode(1);
	}
rxTools_boot:
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	if (cfgs[CFG_3D].val.i)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	return 0;
}
Example #6
0
void CFW_Settings(void)
{
	TOP_Current = 0;
	int settings_idx = 0;
	bool autobootgui = false;
	bool enable_firmlaunch = false;
	char settings[4];
	if (FSFileOpen("/3ds/PastaCFW/system.txt")){
		FSFileRead(settings, 4, 0);
		FSFileClose();
		if (settings[1] == '2')autobootgui = true;
		if (settings[2] == '1' || settings[2] == '3')enable_firmlaunch = true;
		cfw_theme = settings[3];
	}
	while (true)
	{
		//DRAW GUI
		sprintf(str, "/3ds/PastaCFW/UI/%c/options.bin", cfw_theme);
		DrawBottomSplash(str);
		TOP_Current = 0;
		drawInternalY = 0;
		DrawDebug(1, 1, "");
		DrawDebug(1, 1, "");
		DrawDebug(1, 1, "");
		DrawDebug(1, 1, "");
		int i;
		char* beg;
		for (i = 0; i < SETTINGS_ITEMS; i++)
		{
			if (i == settings_idx) beg = "->";
			else beg = "  ";

			       if (i == 0)DrawSettingsDebug(1, "%s Always boot the GUI         <%s>", beg, autobootgui ? "YES" : "NO ");
			  else if (i == 1)DrawSettingsDebug(1, "%s Enable FirmLaunch           <%s>", beg, enable_firmlaunch ? "YES" : "NO ");
			  else if (i == 2)DrawSettingsDebug(1, "%s Change theme                < %c >", beg, cfw_theme);
			  DrawDebug(1, 1, "");
		}

		//APP CONTROLS
		u32 pad_state = HidWaitForInput();
		if (pad_state & BUTTON_DOWN)
		{
			if (settings_idx != SETTINGS_ITEMS - 1) settings_idx++; //MOVE DOWN
			else settings_idx = 0; //MOVE DOWN While at bottom -> go to top
		}
		else if (pad_state & BUTTON_UP)
		{
			if (settings_idx != 0) settings_idx--; //MOVE UP
			else settings_idx = SETTINGS_ITEMS - 1; //MOVE UP While at top -> go to bottom
		}
		else if (pad_state & BUTTON_LEFT || pad_state & BUTTON_RIGHT)
		{
			if (settings_idx == 0) autobootgui = !autobootgui; //autobootgui settings
			else if (settings_idx == 1) enable_firmlaunch = !enable_firmlaunch; //enable firmlaunch
			else if (settings_idx == 2) //theme selection
			{
				if (pad_state & BUTTON_LEFT && cfw_theme != '0')
				{
					cfw_theme--;
					sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme); //DRAW TOP SCREEN TO SEE THE NEW THEME
					DrawTopSplash(str); //TOP SCREEN
				}
				else if (pad_state & BUTTON_RIGHT && cfw_theme != '9')
				{
					sprintf(str, "/3ds/PastaCFW/UI/%c/options.bin", cfw_theme + 1);
					if (FSFileOpen(str))
					{
						cfw_theme++;
						sprintf(str, "/3ds/PastaCFW/UI/%c/menuTOP.bin", cfw_theme);//DRAW TOP SCREEN TO SEE THE NEW THEME
						DrawTopSplash(str); 
					}
				}
			}
		}
		else if (pad_state & BUTTON_A)
		{
			//SAVE SETTINGS
			FSFileOpen("/3ds/PastaCFW/system.txt");
			char tobewritten[4];
			tobewritten[0] = cfw_FWValue;
			tobewritten[1] = autobootgui ? '2' : '1';
			tobewritten[2] = enable_firmlaunch ? '1' : '0';
			tobewritten[3] = cfw_theme;
			cfw_enablefirmlaunch = enable_firmlaunch;
			FSFileWrite(tobewritten, 4, 0);
			FSFileClose();
			break;
		}
		else if (pad_state & BUTTON_B) {
			cfw_theme = settings[3]; break;
		} //EXIT WITHOUT SAVING
	}
}
Example #7
0
File: main.c Project: Golui/rxTools
void Initialize(){
	char str[100];
	char strl[100];
	char strr[100];
	DrawString(BOT_SCREEN,  " INITIALIZE... ", 0, SCREEN_HEIGHT-FONT_SIZE, WHITE, BLACK);
	if(FSInit()){
		DrawString(BOT_SCREEN,  " LOADING...    ", 0, SCREEN_HEIGHT-FONT_SIZE, WHITE, BLACK);
	}else{
		DrawString(BOT_SCREEN,  " ERROR!        ", 0, SCREEN_HEIGHT-FONT_SIZE, RED, BLACK);
	}
	LoadPack();

	//Console Stuff
	ConsoleSetXY(15, 20);
	ConsoleSetWH(SCREEN_WIDTH-30, SCREEN_HEIGHT-80);
	ConsoleSetBorderColor(BLUE);
	ConsoleSetTextColor(RGB(0, 141, 197));
	ConsoleSetBackgroundColor(TRANSPARENT);
	ConsoleSetSpecialColor(BLUE);
	ConsoleSetSpacing(2);
	ConsoleSetBorderWidth(3);
	//Check that the data is installed
	f_mkdir("rxTools");
	f_mkdir("rxTools/nand");
	InstallConfigData();
	LoadSettings();

	sprintf(str, "/rxTools/Theme/%c/TOP.bin", Theme);
	sprintf(strl, "/rxTools/Theme/%c/TOPL.bin", Theme);
	sprintf(strr, "/rxTools/Theme/%c/TOPR.bin", Theme);
	if(theme_3d)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	if (!bootGUI)
	{
		if(silent_boot)
		{
			sprintf(str, "/rxTools/Theme/%c/boot.bin", Theme);
			DrawBottomSplash(str);

			for (int i = 0; i < 0x333333 * 2; i++){
				u32 pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
		else
		{
			ConsoleInit();
			ConsoleSetTitle(STR_AUTOBOOT[language]);
			print(STR_HOLD_R[language]);
			ConsoleShow();

			for (int i = 0; i < 0x333333 * 6; i++){
				u32 pad = GetInput();
				if (pad & BUTTON_R1 && i > 0x333333) goto rxTools_boot;
			}
		}
				

		rxModeQuickBoot();
	}
rxTools_boot:

	sprintf(str, "/rxTools/Theme/%c/TOP.bin", Theme);
	sprintf(strl, "/rxTools/Theme/%c/TOPL.bin", Theme);
	sprintf(strr, "/rxTools/Theme/%c/TOPR.bin", Theme);
	if(theme_3d)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);
}
Example #8
0
int Initialize()
{
	char str[100];
	char strl[100];
	char strr[100];
	char tmp[256];
	wchar_t wtmp[256];
	int r;

	preloadStringsA();

	//Show error if FSInit is not successfull
	if (!FSInit()){
		DrawString(BOT_SCREEN, strings[STR_FAILED], BOT_SCREEN_WIDTH / 2, SCREEN_HEIGHT - FONT_HEIGHT, RED, BLACK);
		return 1;
	}

	/* Set log level here for code debug/trace */
	/*
	set_loglevel(ll_info);
	log(ll_info, "Initializing rxTools...");
	*/

	//Load the font
	LoadFont();
	if (fontLoaded){
		swprintf(wtmp, sizeof(wtmp) / sizeof(wtmp[0]), strings[STR_ERROR_OPENING], fontpath);
		DrawString(BOT_SCREEN, wtmp, FONT_WIDTH, SCREEN_HEIGHT - FONT_HEIGHT * 2, RED, BLACK);
	}
	else{
		preloadStringsU();
	}

	//Console Stuff
	ConsoleSetXY(15, 20);
	ConsoleSetWH(BOT_SCREEN_WIDTH - 30, SCREEN_HEIGHT - 80);
	ConsoleSetBorderColor(BLUE);
	ConsoleSetTextColor(RGB(0, 141, 197));
	ConsoleSetBackgroundColor(TRANSPARENT);
	ConsoleSetSpecialColor(BLUE);
	ConsoleSetSpacing(2);
	ConsoleSetBorderWidth(3);
	//Check that the data is installed
	f_mkdir("rxTools");
	f_mkdir("rxTools/nand");
	InstallConfigData();
	readCfg();

	//Load strings
	if (fontLoaded)
		cfgs[CFG_LANG].val.s = cfgLang;
	r = loadStrings();
	if (r) {
		sprintf(tmp, "%s/%s", langPath, cfgs[CFG_LANG].val.s);
		swprintf(wtmp, sizeof(wtmp) / sizeof(wtmp[0]), strings[STR_ERROR_OPENING], tmp);
		DrawString(BOT_SCREEN, wtmp, FONT_WIDTH, SCREEN_HEIGHT - FONT_HEIGHT * 3, RED, BLACK);
	}

	//Draw the top screen splash
	sprintf(str, "/rxTools/Theme/%u/TOP.bin", cfgs[CFG_THEME].val.i);
	sprintf(strl, "/rxTools/Theme/%u/TOPL.bin", cfgs[CFG_THEME].val.i);
	sprintf(strr, "/rxTools/Theme/%u/TOPR.bin", cfgs[CFG_THEME].val.i);
	if (cfgs[CFG_3D].val.i)
		DrawTopSplash(str, strl, strr);
	else
		DrawTopSplash(str, str, str);

	//If the GUI is not forced, show it only if L is hold, else directly boot rxMode (sys or emu)
	if (!cfgs[CFG_GUI].val.i)
	{
		if ((~HID_STATE) & BUTTON_L1) return 0;

		if (cfgs[CFG_ABSYSN].val.i) rxMode(0);
		else rxMode(1);
	}

	return 0; //Boot rxTools menu
}