mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-04 18:45:05 +01:00
33ce3e48ab
*Homebrew boot changed a bit (cleanup) *A lot more stuff i can't remember anymore
187 lines
3.5 KiB
C++
187 lines
3.5 KiB
C++
#include <gctypes.h>
|
|
#include <ogc/system.h>
|
|
#include <wiiuse/wpad.h>
|
|
|
|
#include "mload/mload.h"
|
|
#include "settings/CSettings.h"
|
|
#include "settings/newtitles.h"
|
|
#include "language/gettext.h"
|
|
#include "utils/ResourceManager.h"
|
|
#include "FontSystem.h"
|
|
#include "audio.h"
|
|
#include "fatmounter.h"
|
|
#include "lstub.h"
|
|
#include "menu.h"
|
|
#include "video.h"
|
|
#include "gecko.h"
|
|
#include "xml/xml.h"
|
|
|
|
extern char game_partition[6];
|
|
extern u8 load_from_fs;
|
|
|
|
//Wiilight stuff
|
|
static vu32 *_wiilight_reg = (u32*) 0xCD0000C0;
|
|
void wiilight(int enable) // Toggle wiilight (thanks Bool for wiilight source)
|
|
{
|
|
u32 val = (*_wiilight_reg & ~0x20);
|
|
if (enable && Settings.wiilight) val |= 0x20;
|
|
*_wiilight_reg = val;
|
|
}
|
|
|
|
/* Variables */
|
|
u8 shutdown = 0;
|
|
u8 reset = 0;
|
|
|
|
void __Sys_ResetCallback(void)
|
|
{
|
|
/* Reboot console */
|
|
reset = 1;
|
|
}
|
|
|
|
void __Sys_PowerCallback(void)
|
|
{
|
|
/* Poweroff console */
|
|
shutdown = 1;
|
|
}
|
|
|
|
void Sys_Init(void)
|
|
{
|
|
/* Initialize video subsytem */
|
|
//VIDEO_Init();
|
|
|
|
/* Set RESET/POWER button callback */
|
|
SYS_SetResetCallback(__Sys_ResetCallback);
|
|
SYS_SetPowerCallback(__Sys_PowerCallback);
|
|
}
|
|
|
|
void AppCleanUp(void)
|
|
{
|
|
extern u8 mountMethod;
|
|
gprintf("Exiting main GUI. mountMethod = %d\n", mountMethod);
|
|
|
|
ExitGUIThreads();
|
|
|
|
delete bgMusic;
|
|
delete background;
|
|
delete bgImg;
|
|
delete mainWindow;
|
|
for (int i = 0; i < 4; i++)
|
|
delete pointer[i];
|
|
delete GameRegionTxt;
|
|
delete GameIDTxt;
|
|
delete cover;
|
|
delete coverImg;
|
|
gettextCleanUp();
|
|
CloseXMLDatabase();
|
|
ClearFontData();
|
|
NewTitles::DestroyInstance();
|
|
|
|
StopGX();
|
|
ShutdownAudio();
|
|
|
|
ResourceManager::DestroyInstance();
|
|
|
|
WPAD_Flush(0);
|
|
WPAD_Disconnect(0);
|
|
WPAD_Shutdown();
|
|
}
|
|
|
|
void ExitApp(void)
|
|
{
|
|
AppCleanUp();
|
|
UnmountNTFS();
|
|
SDCard_deInit();
|
|
USBDevice_deInit();
|
|
}
|
|
|
|
void Sys_Reboot(void)
|
|
{
|
|
/* Restart console */
|
|
ExitApp();
|
|
STM_RebootSystem();
|
|
}
|
|
|
|
#define ShutdownToDefault 0
|
|
#define ShutdownToIdle 1
|
|
#define ShutdownToStandby 2
|
|
|
|
static void _Sys_Shutdown(int SHUTDOWN_MODE)
|
|
{
|
|
ExitApp();
|
|
|
|
/* Poweroff console */
|
|
if ((CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE && SHUTDOWN_MODE != ShutdownToStandby) || SHUTDOWN_MODE
|
|
== ShutdownToIdle)
|
|
{
|
|
s32 ret;
|
|
|
|
/* Set LED mode */
|
|
ret = CONF_GetIdleLedMode();
|
|
if (ret >= 0 && ret <= 2) STM_SetLedMode(ret);
|
|
|
|
/* Shutdown to idle */
|
|
STM_ShutdownToIdle();
|
|
}
|
|
else
|
|
{
|
|
/* Shutdown to standby */
|
|
STM_ShutdownToStandby();
|
|
}
|
|
}
|
|
|
|
void Sys_Shutdown(void)
|
|
{
|
|
_Sys_Shutdown(ShutdownToDefault);
|
|
}
|
|
|
|
void Sys_ShutdownToIdel(void)
|
|
{
|
|
_Sys_Shutdown(ShutdownToIdle);
|
|
}
|
|
void Sys_ShutdownToStandby(void)
|
|
{
|
|
_Sys_Shutdown(ShutdownToStandby);
|
|
}
|
|
|
|
void Sys_LoadMenu(void)
|
|
{
|
|
ExitApp();
|
|
/* Return to the Wii system menu */
|
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
|
}
|
|
|
|
void Sys_BackToLoader(void)
|
|
{
|
|
|
|
if (hbcStubAvailable())
|
|
{
|
|
ExitApp();
|
|
exit(0);
|
|
}
|
|
// Channel Version
|
|
Sys_LoadMenu();
|
|
}
|
|
|
|
bool Sys_IsHermes()
|
|
{
|
|
int ios = IOS_GetVersion();
|
|
|
|
return ios == 222 || ios == 223 || ios == 224;
|
|
}
|
|
|
|
void ScreenShot()
|
|
{
|
|
time_t rawtime;
|
|
struct tm * timeinfo;
|
|
char buffer[80];
|
|
char buffer2[80];
|
|
|
|
time(&rawtime);
|
|
timeinfo = localtime(&rawtime);
|
|
//USBLoader_GX_ScreenShot-Month_Day_Hour_Minute_Second_Year.png
|
|
strftime(buffer, 80, "USBLoader_GX_ScreenShot-%b%d%H%M%S%y.png", timeinfo);
|
|
sprintf(buffer2, "%s/config/%s", Settings.BootDevice, buffer);
|
|
|
|
TakeScreenshot(buffer2);
|
|
}
|