2010-09-24 01:47:51 +02:00
|
|
|
#include <gctypes.h>
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
2010-05-29 09:38:54 +02:00
|
|
|
|
2010-09-24 01:47:51 +02:00
|
|
|
#include "mload/mload.h"
|
|
|
|
#include "settings/CSettings.h"
|
2010-09-26 11:25:11 +02:00
|
|
|
#include "utils/ResourceManager.h"
|
2010-05-29 09:38:54 +02:00
|
|
|
#include "audio.h"
|
|
|
|
#include "fatmounter.h"
|
2010-09-16 21:59:41 +02:00
|
|
|
#include "lstub.h"
|
2010-09-24 01:47:51 +02:00
|
|
|
#include "menu.h"
|
|
|
|
#include "video.h"
|
2010-05-29 09:38:54 +02:00
|
|
|
|
|
|
|
extern char game_partition[6];
|
|
|
|
extern u8 load_from_fs;
|
|
|
|
|
|
|
|
//Wiilight stuff
|
2010-09-24 02:48:03 +02:00
|
|
|
static vu32 *_wiilight_reg = (u32*) 0xCD0000C0;
|
|
|
|
void wiilight(int enable) // Toggle wiilight (thanks Bool for wiilight source)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
u32 val = (*_wiilight_reg & ~0x20);
|
|
|
|
if (enable && Settings.wiilight) val |= 0x20;
|
2010-09-19 01:16:05 +02:00
|
|
|
*_wiilight_reg = val;
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Variables */
|
|
|
|
u8 shutdown = 0;
|
|
|
|
u8 reset = 0;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void __Sys_ResetCallback(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
/* Reboot console */
|
|
|
|
reset = 1;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void __Sys_PowerCallback(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
/* Poweroff console */
|
|
|
|
shutdown = 1;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_Init(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
/* Initialize video subsytem */
|
|
|
|
//VIDEO_Init();
|
|
|
|
|
|
|
|
/* Set RESET/POWER button callback */
|
2010-09-24 02:48:03 +02:00
|
|
|
SYS_SetResetCallback(__Sys_ResetCallback);
|
|
|
|
SYS_SetPowerCallback(__Sys_PowerCallback);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
static void _ExitApp()
|
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
ExitGUIThreads();
|
|
|
|
StopGX();
|
|
|
|
ShutdownAudio();
|
|
|
|
|
2010-09-26 11:25:11 +02:00
|
|
|
ResourceManager::DestroyInstance();
|
|
|
|
|
2010-05-29 09:38:54 +02:00
|
|
|
UnmountNTFS();
|
|
|
|
SDCard_deInit();
|
|
|
|
USBDevice_deInit();
|
2010-09-24 02:48:03 +02:00
|
|
|
mload_set_ES_ioctlv_vector(NULL);
|
2010-05-29 09:38:54 +02:00
|
|
|
mload_close();
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_Reboot(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
/* Restart console */
|
|
|
|
_ExitApp();
|
|
|
|
STM_RebootSystem();
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
#define ShutdownToDefault 0
|
|
|
|
#define ShutdownToIdle 1
|
|
|
|
#define ShutdownToStandby 2
|
2010-05-29 09:38:54 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
static void _Sys_Shutdown(int SHUTDOWN_MODE)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
_ExitApp();
|
2010-09-24 02:48:03 +02:00
|
|
|
WPAD_Flush(0);
|
|
|
|
WPAD_Disconnect(0);
|
2010-05-29 09:38:54 +02:00
|
|
|
WPAD_Shutdown();
|
|
|
|
|
|
|
|
/* Poweroff console */
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE && SHUTDOWN_MODE != ShutdownToStandby) || SHUTDOWN_MODE
|
|
|
|
== ShutdownToIdle)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
s32 ret;
|
|
|
|
|
|
|
|
/* Set LED mode */
|
|
|
|
ret = CONF_GetIdleLedMode();
|
2010-09-24 02:48:03 +02:00
|
|
|
if (ret >= 0 && ret <= 2) STM_SetLedMode(ret);
|
2010-05-29 09:38:54 +02:00
|
|
|
|
|
|
|
/* Shutdown to idle */
|
|
|
|
STM_ShutdownToIdle();
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
/* Shutdown to standby */
|
|
|
|
STM_ShutdownToStandby();
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 01:47:51 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_Shutdown(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
_Sys_Shutdown(ShutdownToDefault);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
2010-09-24 01:47:51 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_ShutdownToIdel(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
_Sys_Shutdown(ShutdownToIdle);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_ShutdownToStandby(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
_Sys_Shutdown(ShutdownToStandby);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_LoadMenu(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
_ExitApp();
|
|
|
|
/* Return to the Wii system menu */
|
2010-09-24 02:48:03 +02:00
|
|
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
void Sys_BackToLoader(void)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-16 21:59:41 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (hbcStubAvailable())
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-05-29 09:38:54 +02:00
|
|
|
_ExitApp();
|
2010-09-24 02:48:03 +02:00
|
|
|
exit(0);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
|
|
|
// Channel Version
|
|
|
|
Sys_LoadMenu();
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
bool Sys_IsHermes()
|
|
|
|
{
|
|
|
|
return IOS_GetVersion() == 222 || IOS_GetVersion() == 223;
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ScreenShot()
|
|
|
|
{
|
2010-09-19 01:16:05 +02:00
|
|
|
time_t rawtime;
|
|
|
|
struct tm * timeinfo;
|
2010-09-24 02:48:03 +02:00
|
|
|
char buffer[80];
|
|
|
|
char buffer2[80];
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
time(&rawtime);
|
|
|
|
timeinfo = localtime(&rawtime);
|
2010-09-19 01:16:05 +02:00
|
|
|
//USBLoader_GX_ScreenShot-Month_Day_Hour_Minute_Second_Year.png
|
2010-09-24 02:48:03 +02:00
|
|
|
strftime(buffer, 80, "USBLoader_GX_ScreenShot-%b%d%H%M%S%y.png", timeinfo);
|
|
|
|
sprintf(buffer2, "%s/config/%s", bootDevice, buffer);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
TakeScreenshot(buffer2);
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|