NOTE: this commit requires "make clean" and the new libfat (see Downloads libfat-01-06-2009)

* clean up the wild mounts and unmounts (this and the new libfat fix the download-bug)
* reorganize shutdowns and reboots use now the functions Sys_Reboot(), Sys_Shutdown(), Sys_ShutdownToIdel(), Sys_ShutdownToStandby() and Sys_BackToLoader()
  this functions stops the GUI-Thread, Shutdowns the Audio, Video, WPad and unmounts the SD and USB
This commit is contained in:
ardi@ist-einmalig.de 2009-06-01 15:50:18 +00:00
parent 976ea2041c
commit 904fda37d4
9 changed files with 457 additions and 426 deletions

View File

@ -1,33 +1,31 @@
#include <fat.h> #include <fat.h>
#include <sys/dir.h> #include <sys/dir.h>
#include <sys/iosupport.h>
#include <ogc/lwp_watchdog.h> #include <ogc/lwp_watchdog.h>
#include <ogc/mutex.h> #include <ogc/mutex.h>
#include <ogc/system.h> #include <ogc/system.h>
#include <ogc/usbstorage.h> #include <ogc/usbstorage.h>
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
#define CACHE 32 #define CACHE 4
#define SECTORS 128 #define SECTORS 64
int USBDevice_Init() int USBDevice_Init()
{ {
//right now only mounts first partition and only under IOS36 //closing all open Files write back the cache and then shutdown em!
__io_usbstorage.startup(); fatUnmount("USB:/");
//right now only mounts first partition
if (fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS)) { if (fatMount("USB", &__io_usbstorage, 0, CACHE, SECTORS)) {
return 1; return 1;
} }
return -1;
return -1;
} }
void USBDevice_deInit() void USBDevice_deInit()
{ {
//First unmount all the devs... //closing all open Files write back the cache and then shutdown em!
fatUnmount("USB:/"); fatUnmount("USB:/");
//...and then shutdown em!
__io_usbstorage.shutdown();
} }
int isSdInserted() int isSdInserted()
@ -37,21 +35,16 @@ int isSdInserted()
int SDCard_Init() int SDCard_Init()
{ {
//mount SD if inserted //closing all open Files write back the cache and then shutdown em!
__io_wiisd.startup(); fatUnmount("SD:/");
if (!isSdInserted()){ //right now only mounts first partition
return -1; if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS))
} return 1;
if (fatMount("SD", &__io_wiisd, 0, CACHE, SECTORS)) { return -1;
return 1;
}
return -1;
} }
void SDCard_deInit() void SDCard_deInit()
{ {
//First unmount all the devs... //closing all open Files write back the cache and then shutdown em!
fatUnmount("SD:/"); fatUnmount("SD:/");
//...and then shutdown em!
__io_wiisd.shutdown();
} }

View File

@ -73,7 +73,7 @@ u32 do_sd_code(char *filename)
fp = fopen(filepath, "rb"); fp = fopen(filepath, "rb");
if (!fp) { if (!fp) {
fatUnmount("SD"); fatUnmount("SD:/");
__io_wiisd.shutdown(); __io_wiisd.shutdown();
return 0; return 0;
} }
@ -93,7 +93,7 @@ u32 do_sd_code(char *filename)
if(ret != filesize){ if(ret != filesize){
free(filebuff); free(filebuff);
fclose(fp); fclose(fp);
fatUnmount("SD"); fatUnmount("SD:/");
__io_wiisd.shutdown(); __io_wiisd.shutdown();
return 0; return 0;
} }
@ -106,7 +106,7 @@ u32 do_sd_code(char *filename)
free(filebuff); free(filebuff);
fclose(fp); fclose(fp);
fatUnmount("SD"); fatUnmount("SD:/");
__io_wiisd.shutdown(); __io_wiisd.shutdown();
return 1; return 1;

View File

@ -1,5 +1,4 @@
#include "gui.h" #include "gui.h"
extern int SetValue(int i, const char *format, ...) __attribute__((format(printf,2,3)));
class customOptionList { class customOptionList {
public: public:

View File

@ -1,130 +1,117 @@
/**************************************************************************** /****************************************************************************
* libwiigui Template * libwiigui Template
* Tantric 2009 * Tantric 2009
* *
* demo.cpp * demo.cpp
* Basic template/demonstration of libwiigui capabilities. For a * Basic template/demonstration of libwiigui capabilities. For a
* full-featured app using many more extensions, check out Snes9x GX. * full-featured app using many more extensions, check out Snes9x GX.
***************************************************************************/ ***************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ogcsys.h>
#include <unistd.h>
#include <wiiuse/wpad.h>
#include "FreeTypeGX.h"
#include "video.h"
#include "audio.h"
#include "menu.h"
#include "input.h"
#include "filelist.h"
#include "main.h"
#include "http.h"
#include "dns.h"
#include "fatmounter.h"
#include "disc.h"
#include "wbfs.h"
#include "sys.h"
#include "video2.h"
#include "wpad.h"
#include "cfg.h"
#include "language.h"
#include "fat.h"
/* Constants */
#define CONSOLE_XCOORD 260
#define CONSOLE_YCOORD 115
#define CONSOLE_WIDTH 340
#define CONSOLE_HEIGHT 218
FreeTypeGX *fontSystem=0;
FreeTypeGX *fontClock=0;
int ExitRequested = 0;
bool netcheck = false;
/*Networking - Forsaekn*/
int Net_Init(char *ip){
s32 res;
while ((res = net_init()) == -EAGAIN)
{
usleep(100 * 1000); //100ms
}
if (if_config(ip, NULL, NULL, true) < 0) {
printf(" Error reading IP address, exiting");
usleep(1000 * 1000 * 1); //1 sec
return FALSE;
}
return TRUE;
}
void ExitApp()
{
ShutoffRumble();
StopGX();
ShutdownAudio();
if(isSdInserted()) #include <gccore.h>
SDCard_deInit(); #include <stdio.h>
#include <stdlib.h>
//WPAD_Flush(0); #include <string.h>
//WPAD_Disconnect(0); #include <ogcsys.h>
//WPAD_Shutdown(); #include <unistd.h>
//exit(0); #include <wiiuse/wpad.h>
}
#include "FreeTypeGX.h"
void #include "video.h"
DefaultSettings() #include "audio.h"
{ #include "menu.h"
Settings.video = discdefault; #include "input.h"
Settings.vpatch = off; #include "filelist.h"
Settings.language = ConsoleLangDefault; #include "main.h"
Settings.ocarina = off; #include "http.h"
Settings.hddinfo = hr12; #include "dns.h"
Settings.sinfo = ((THEME.showID) ? GameID : Neither); #include "fatmounter.h"
Settings.rumble = RumbleOn; #include "disc.h"
if (THEME.showRegion) #include "wbfs.h"
{ #include "sys.h"
Settings.sinfo = ((Settings.sinfo == GameID) ? Both : GameRegion); #include "video2.h"
} #include "wpad.h"
Settings.volume = v80; #include "cfg.h"
Settings.tooltips = TooltipsOn; #include "language.h"
snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), "ab121b"); #include "fat.h"
Settings.parentalcontrol = 0;
Settings.cios = ios249;
Settings.xflip = no; /* Constants */
#define CONSOLE_XCOORD 260
#define CONSOLE_YCOORD 115
#define CONSOLE_WIDTH 340
#define CONSOLE_HEIGHT 218
FreeTypeGX *fontSystem=0;
FreeTypeGX *fontClock=0;
bool netcheck = false;
/*Networking - Forsaekn*/
int Net_Init(char *ip){
s32 res;
while ((res = net_init()) == -EAGAIN)
{
usleep(100 * 1000); //100ms
}
if (if_config(ip, NULL, NULL, true) < 0) {
printf(" Error reading IP address, exiting");
usleep(1000 * 1000 * 1); //1 sec
return FALSE;
}
return TRUE;
}
void
DefaultSettings()
{
Settings.video = discdefault;
Settings.vpatch = off;
Settings.language = ConsoleLangDefault;
Settings.ocarina = off;
Settings.hddinfo = hr12;
Settings.sinfo = ((THEME.showID) ? GameID : Neither);
Settings.rumble = RumbleOn;
if (THEME.showRegion)
{
Settings.sinfo = ((Settings.sinfo == GameID) ? Both : GameRegion);
}
Settings.volume = v80;
Settings.tooltips = TooltipsOn;
snprintf(Settings.unlockCode, sizeof(Settings.unlockCode), "ab121b");
Settings.parentalcontrol = 0;
Settings.cios = ios249;
Settings.xflip = no;
Settings.qboot = no; Settings.qboot = no;
Settings.unicodefix = 0; Settings.unicodefix = 0;
Settings.wiilight = 1; Settings.wiilight = 1;
Settings.patchcountrystrings = 0; Settings.patchcountrystrings = 0;
CFG_LoadGlobal(); CFG_LoadGlobal();
} }
// check for libfat.a from 1. Jun 2009
int extern int LibFat4USB_Loader_GX;
main(int argc, char *argv[]) int fatCheck = LibFat4USB_Loader_GX; // remove when libfat newer than 1. Jun 2009
{
int
main(int argc, char *argv[])
{
s32 ret2; s32 ret2;
SDCard_Init(); SDCard_Init(); // mount SD for loading cfg's
lang_default(); lang_default();
CFG_Load(); CFG_Load();
DefaultSettings(); DefaultSettings();
SDCard_deInit(); SDCard_deInit();// unmount SD for reloading IOS
/* Load Custom IOS */ /* Load Custom IOS */
if(Settings.cios == ios222) { if(Settings.cios == ios222) {
ret2 = IOS_ReloadIOS(222); ret2 = IOS_ReloadIOS(222);
if (ret2 < 0) { if (ret2 < 0) {
Settings.cios = ios249; Settings.cios = ios249;
@ -133,33 +120,34 @@ main(int argc, char *argv[])
} else { } else {
ret2 = IOS_ReloadIOS(249); ret2 = IOS_ReloadIOS(249);
} }
if (ret2 < 0) { if (ret2 < 0) {
printf("ERROR: cIOS could not be loaded!"); printf("ERROR: cIOS could not be loaded!");
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
SDCard_Init(); SDCard_Init(); // now mount SD:/
USBDevice_Init(); // and mount USB:/
Sys_Init();
//Video_SetMode(); Sys_Init();
//Con_Init(CONSOLE_XCOORD, CONSOLE_YCOORD, CONSOLE_WIDTH, CONSOLE_HEIGHT);
//Wpad_Init(); InitVideo(); // Initialise video
InitAudio(); // Initialize audio
PAD_Init();
InitVideo(); // Initialise video PAD_Init(); // initialize PAD/WPAD
InitAudio(); // Initialize audio Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
fontSystem = new FreeTypeGX();
fontSystem->loadFont(font_ttf, font_ttf_size, 0); fontSystem = new FreeTypeGX();
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); fontSystem->loadFont(font_ttf, font_ttf_size, 0);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
fontClock = new FreeTypeGX();
fontClock->loadFont(clock_ttf, clock_ttf_size, 0); fontClock = new FreeTypeGX();
fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); fontClock->loadFont(clock_ttf, clock_ttf_size, 0);
fontClock->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
InitGUIThreads();
MainMenu(MENU_CHECK); InitGUIThreads();
return 0; MainMenu(MENU_CHECK);
} return 0;
}

View File

@ -12,9 +12,7 @@
extern struct SSettings Settings; extern struct SSettings Settings;
void ExitApp();
void DefaultSettings(); void DefaultSettings();
extern int ExitRequested;
extern FreeTypeGX *fontSystem; extern FreeTypeGX *fontSystem;
extern bool netcheck; extern bool netcheck;
extern int Net_Init(char *ip); extern int Net_Init(char *ip);

View File

@ -19,6 +19,7 @@
#include "libwiigui/gui.h" #include "libwiigui/gui.h"
#include "menu.h" #include "menu.h"
#include "main.h" #include "main.h"
#include "audio.h"
#include "input.h" #include "input.h"
#include "http.h" #include "http.h"
#include "dns.h" #include "dns.h"
@ -66,6 +67,7 @@ static s32 gameSelected = 0, gameStart = 0;
static GuiWindow * mainWindow = NULL; static GuiWindow * mainWindow = NULL;
static lwp_t guithread = LWP_THREAD_NULL; static lwp_t guithread = LWP_THREAD_NULL;
static bool guiHalt = true; static bool guiHalt = true;
static int ExitRequested = 0;
static GuiImageData progressbar(progressbar_png); static GuiImageData progressbar(progressbar_png);
static GuiImage progressbarImg(&progressbar); static GuiImage progressbarImg(&progressbar);
int godmode = 0; int godmode = 0;
@ -404,15 +406,15 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
dialogBoxImg.SetWidescreen(CFG.widescreen); dialogBoxImg.SetWidescreen(CFG.widescreen);
} }
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,55); titleTxt.SetPosition(0,55);
GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
msgTxt.SetPosition(0,-40); msgTxt.SetPosition(0,-40);
msgTxt.SetMaxWidth(430); msgTxt.SetMaxWidth(430);
GuiText btn1Txt(btn1Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn1Txt(btn1Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn1Img(&btnOutline); GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen); btn1Txt.SetWidescreen(CFG.widescreen);
@ -423,7 +425,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
btn1.SetLabel(&btn1Txt); btn1.SetLabel(&btn1Txt);
btn1.SetState(STATE_SELECTED); btn1.SetState(STATE_SELECTED);
GuiText btn2Txt(btn2Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn2Txt(btn2Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn2Img(&btnOutline); GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn2Txt.SetWidescreen(CFG.widescreen); btn2Txt.SetWidescreen(CFG.widescreen);
@ -434,7 +436,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
if(!btn3Label && !btn4Label) if(!btn3Label && !btn4Label)
btn2.SetTrigger(&trigB); btn2.SetTrigger(&trigB);
GuiText btn3Txt(btn3Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn3Txt(btn3Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn3Img(&btnOutline); GuiImage btn3Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn3Txt.SetWidescreen(CFG.widescreen); btn3Txt.SetWidescreen(CFG.widescreen);
@ -445,7 +447,7 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
if(!btn4Label) if(!btn4Label)
btn3.SetTrigger(&trigB); btn3.SetTrigger(&trigB);
GuiText btn4Txt(btn4Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn4Txt(btn4Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn4Img(&btnOutline); GuiImage btn4Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn4Txt.SetWidescreen(CFG.widescreen); btn4Txt.SetWidescreen(CFG.widescreen);
@ -985,7 +987,7 @@ int GameWindowPrompt()
GuiTooltip nameBtnTT(LANGUAGE.RenameGameonWBFS); GuiTooltip nameBtnTT(LANGUAGE.RenameGameonWBFS);
if (Settings.wsprompt == yes) if (Settings.wsprompt == yes)
nameBtnTT.SetWidescreen(CFG.widescreen); nameBtnTT.SetWidescreen(CFG.widescreen);
GuiText nameTxt("", 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{50, 50, 50, 255}); GuiText nameTxt("", 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
if (Settings.wsprompt == yes) if (Settings.wsprompt == yes)
nameTxt.SetWidescreen(CFG.widescreen); nameTxt.SetWidescreen(CFG.widescreen);
nameTxt.SetMaxWidth(350, GuiText::SCROLL); nameTxt.SetMaxWidth(350, GuiText::SCROLL);
@ -1003,7 +1005,7 @@ int GameWindowPrompt()
nameBtn.SetEffectGrow(); nameBtn.SetEffectGrow();
} }
GuiText sizeTxt(NULL, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{50, 50, 50, 255}); //TODO: get the size here GuiText sizeTxt(NULL, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //TODO: get the size here
sizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP); sizeTxt.SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
sizeTxt.SetPosition(-60,70); sizeTxt.SetPosition(-60,70);
@ -1033,7 +1035,7 @@ int GameWindowPrompt()
btn1.SetTrigger(&trigA); btn1.SetTrigger(&trigA);
btn1.SetState(STATE_SELECTED); btn1.SetState(STATE_SELECTED);
GuiText btn2Txt(LANGUAGE.Back, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn2Txt(LANGUAGE.Back, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn2Img(&btnOutline); GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn2Txt.SetWidescreen(CFG.widescreen); btn2Txt.SetWidescreen(CFG.widescreen);
@ -1054,7 +1056,7 @@ int GameWindowPrompt()
btn2.SetLabel(&btn2Txt); btn2.SetLabel(&btn2Txt);
btn2.SetTrigger(&trigB); btn2.SetTrigger(&trigB);
GuiText btn3Txt(LANGUAGE.settings, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn3Txt(LANGUAGE.settings, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn3Img(&btnOutline); GuiImage btn3Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn3Txt.SetWidescreen(CFG.widescreen); btn3Txt.SetWidescreen(CFG.widescreen);
@ -1454,15 +1456,15 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char *
dialogBoxImg.SetWidescreen(CFG.widescreen); dialogBoxImg.SetWidescreen(CFG.widescreen);
} }
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,60); titleTxt.SetPosition(0,60);
GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
msgTxt.SetPosition(0,-40); msgTxt.SetPosition(0,-40);
msgTxt.SetMaxWidth(430); msgTxt.SetMaxWidth(430);
GuiText btn1Txt(btn1Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn1Txt(btn1Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn1Img(&btnOutline); GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen); btn1Txt.SetWidescreen(CFG.widescreen);
@ -1485,7 +1487,7 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char *
btn1.SetTrigger(&trigB); btn1.SetTrigger(&trigB);
btn1.SetState(STATE_SELECTED); btn1.SetState(STATE_SELECTED);
GuiText btn2Txt(btn2Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn2Txt(btn2Label, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn2Img(&btnOutline); GuiImage btn2Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn2Txt.SetWidescreen(CFG.widescreen); btn2Txt.SetWidescreen(CFG.widescreen);
@ -1509,7 +1511,7 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char *
} }
} }
GuiText timerTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText timerTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
timerTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); timerTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
timerTxt.SetPosition(0,160); timerTxt.SetPosition(0,160);
@ -1531,12 +1533,10 @@ DiscWait(const char *title, const char *msg, const char *btn1Label, const char *
mainWindow->ChangeFocus(&promptWindow); mainWindow->ChangeFocus(&promptWindow);
ResumeGui(); ResumeGui();
SDCard_deInit();
if(IsDeviceWait) { if(IsDeviceWait) {
while(i >= 0) while(i >= 0)
{ {
timerTxt.SetTextf("%u%s", i,LANGUAGE.secondsleft); timerTxt.SetTextf("%u %s", i,LANGUAGE.secondsleft);
VIDEO_WaitVSync(); VIDEO_WaitVSync();
if(Settings.cios == ios222) { if(Settings.cios == ios222) {
ret = IOS_ReloadIOS(222); ret = IOS_ReloadIOS(222);
@ -1599,7 +1599,7 @@ FormatingPartition(const char *title, partitionEntry *entry)
dialogBoxImg.SetWidescreen(CFG.widescreen); dialogBoxImg.SetWidescreen(CFG.widescreen);
} }
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,60); titleTxt.SetPosition(0,60);
@ -1657,16 +1657,16 @@ int NetworkInitPromp(int choice2)
dialogBoxImg.SetWidescreen(CFG.widescreen); dialogBoxImg.SetWidescreen(CFG.widescreen);
} }
GuiText titleTxt(LANGUAGE.InitializingNetwork, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(LANGUAGE.InitializingNetwork, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,60); titleTxt.SetPosition(0,60);
char msg[20] = " "; char msg[20] = " ";
GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msgTxt(msg, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
msgTxt.SetPosition(0,-40); msgTxt.SetPosition(0,-40);
GuiText btn1Txt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn1Txt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn1Img(&btnOutline); GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen); btn1Txt.SetWidescreen(CFG.widescreen);
@ -1869,14 +1869,14 @@ ProgressWindow(const char *title, const char *msg)
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarImg.SetPosition(25, 40); progressbarImg.SetPosition(25, 40);
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,60); titleTxt.SetPosition(0,60);
GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msgTxt.SetPosition(0,120); msgTxt.SetPosition(0,120);
GuiText prsTxt("%", 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText prsTxt("%", 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE); prsTxt.SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
prsTxt.SetPosition(-188,40); prsTxt.SetPosition(-188,40);
@ -1989,22 +1989,22 @@ ProgressDownloadWindow(int choice2)
progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); progressbarImg.SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
progressbarImg.SetPosition(25, 40); progressbarImg.SetPosition(25, 40);
GuiText titleTxt(LANGUAGE.Downloadingfile, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(LANGUAGE.Downloadingfile, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,60); titleTxt.SetPosition(0,60);
GuiText msgTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msgTxt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msgTxt.SetPosition(0,130); msgTxt.SetPosition(0,130);
GuiText msg2Txt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msg2Txt(NULL, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msg2Txt.SetPosition(0,100); msg2Txt.SetPosition(0,100);
prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
prTxt.SetPosition(0, 40); prTxt.SetPosition(0, 40);
GuiText btn1Txt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn1Txt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn1Img(&btnOutline); GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen); btn1Txt.SetWidescreen(CFG.widescreen);
@ -2060,64 +2060,75 @@ ProgressDownloadWindow(int choice2)
} }
} }
while (i < cntMissFiles) { while (i < cntMissFiles)
{
prTxt.SetTextf("%i%%", 100*i/cntMissFiles); prTxt.SetTextf("%i%%", 100*i/cntMissFiles);
if ((Settings.wsprompt == yes) && (CFG.widescreen)){/////////////adjust for widescreen if ((Settings.wsprompt == yes) && (CFG.widescreen))
progressbarImg.SetPosition(80,40); {
progressbarImg.SetTile(80*i/cntMissFiles); //adjust for widescreen
} else { progressbarImg.SetPosition(80,40);
progressbarImg.SetTile(100*i/cntMissFiles); progressbarImg.SetTile(80*i/cntMissFiles);
} }
else
{
progressbarImg.SetTile(100*i/cntMissFiles);
}
msgTxt.SetTextf("%i %s", cntMissFiles - i, LANGUAGE.filesleft); msgTxt.SetTextf("%i %s", cntMissFiles - i, LANGUAGE.filesleft);
msg2Txt.SetTextf("%s", missingFiles[i]); msg2Txt.SetTextf("%s", missingFiles[i]);
//download boxart image //download boxart image
char imgPath[100]; char imgPath[100];
char URLFile[100]; char URLFile[100];
if (choice2 == 2) { if (choice2 == 2)
sprintf(URLFile,"http://www.theotherzone.com/wii/3d/176/248/%s",missingFiles[i]); // For 3D Covers {
sprintf(imgPath,"%s%s", CFG.covers_path, missingFiles[i]); sprintf(URLFile,"http://www.theotherzone.com/wii/3d/176/248/%s",missingFiles[i]); // For 3D Covers
} sprintf(imgPath,"%s%s", CFG.covers_path, missingFiles[i]);
if(choice2 == 3) { }
sprintf(URLFile,"http://www.theotherzone.com/wii/diskart/160/160/%s",missingFiles[i]); if(choice2 == 3)
sprintf(imgPath,"%s%s", CFG.disc_path, missingFiles[i]); {
} sprintf(URLFile,"http://www.theotherzone.com/wii/diskart/160/160/%s",missingFiles[i]);
if(choice2 == 1) { sprintf(imgPath,"%s%s", CFG.disc_path, missingFiles[i]);
sprintf(URLFile,"http://www.theotherzone.com/wii/resize/160/224/%s",missingFiles[i]); }
sprintf(imgPath,"%s%s", CFG.covers_path, missingFiles[i]); if(choice2 == 1)
} {
sprintf(URLFile,"http://www.theotherzone.com/wii/resize/160/224/%s",missingFiles[i]);
sprintf(imgPath,"%s%s", CFG.covers_path, missingFiles[i]);
}
struct block file = downloadfile(URLFile);//reject known bad images struct block file = downloadfile(URLFile);//reject known bad images
if (file.size == 36864 || file.size <= 1024 || file.size == 7386 || file.data == NULL) { if (file.size == 36864 || file.size <= 1024 || file.size == 7386 || file.data == NULL) {
cntNotFound++; cntNotFound++;
i++; i++;
} else { }
else
if(file.data != NULL) {
{ if(file.data != NULL)
// save png to sd card {
FILE *pfile; // save png to sd card
pfile = fopen(imgPath, "wb"); FILE *pfile=NULL;
fwrite(file.data,1,file.size,pfile); if((pfile = fopen(imgPath, "wb"))!=NULL)
fclose (pfile); {
free(file.data); fwrite(file.data,1,file.size,pfile);
} fclose (pfile);
i++; }
} free(file.data);
}
if(btn1.GetState() == STATE_CLICKED) { i++;
cntNotFound = cntMissFiles-i+cntNotFound; }
break;
}
if(btn1.GetState() == STATE_CLICKED)
{
cntNotFound = cntMissFiles-i+cntNotFound;
break;
}
} }
/**Temporary redownloading 1st image because of a fucking corruption bug **/ /**Temporary redownloading 1st image because of a fucking corruption bug **/
/*
char URLFile[100]; char URLFile[100];
if (choice2 == 2) { if (choice2 == 2) {
sprintf(URLFile,"http://www.theotherzone.com/wii/3d/176/248/%s",missingFiles[0]); // For 3D Covers sprintf(URLFile,"http://www.theotherzone.com/wii/3d/176/248/%s",missingFiles[0]); // For 3D Covers
@ -2146,7 +2157,7 @@ ProgressDownloadWindow(int choice2)
free(file.data); free(file.data);
} }
} }
*/
HaltGui(); HaltGui();
mainWindow->Remove(&promptWindow); mainWindow->Remove(&promptWindow);
@ -2218,23 +2229,23 @@ ProgressUpdateWindow()
char title[50]; char title[50];
sprintf(title, "%s", LANGUAGE.CheckingforUpdates); sprintf(title, "%s", LANGUAGE.CheckingforUpdates);
GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText titleTxt(title, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
titleTxt.SetPosition(0,50); titleTxt.SetPosition(0,50);
char msg[50]; char msg[50];
sprintf(msg, "%s", LANGUAGE.InitializingNetwork); sprintf(msg, "%s", LANGUAGE.InitializingNetwork);
GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msgTxt(msg, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); msgTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
msgTxt.SetPosition(0,140); msgTxt.SetPosition(0,140);
char msg2[50] = " "; char msg2[50] = " ";
GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText msg2Txt(msg2, 26, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); msg2Txt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
msg2Txt.SetPosition(0, 50); msg2Txt.SetPosition(0, 50);
prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); prTxt.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
prTxt.SetPosition(0, 7); prTxt.SetPosition(0, 7);
GuiText btn1Txt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText btn1Txt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage btn1Img(&btnOutline); GuiImage btn1Img(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
btn1Txt.SetWidescreen(CFG.widescreen); btn1Txt.SetWidescreen(CFG.widescreen);
@ -2314,10 +2325,10 @@ ProgressUpdateWindow()
int revnumber = 0; int revnumber = 0;
int currentrev = atoi(SVN_REV); int currentrev = atoi(SVN_REV);
SDCard_deInit(); /// SDCard_deInit();
struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt"); struct block file = downloadfile("http://www.techjawa.com/usbloadergx/rev.txt");
FILE *pfile; FILE *pfile;
SDCard_Init(); /// SDCard_Init();
if(file.data != NULL) if(file.data != NULL)
{ {
@ -2442,9 +2453,7 @@ ProgressUpdateWindow()
if(!failed && ret >= 0) { if(!failed && ret >= 0) {
WindowPrompt(LANGUAGE.Successfullyupdated , LANGUAGE.Restarting, LANGUAGE.ok, 0, 0, 0); WindowPrompt(LANGUAGE.Successfullyupdated , LANGUAGE.Restarting, LANGUAGE.ok, 0, 0, 0);
ExitApp(); Sys_BackToLoader();
if (*((u32*) 0x80001800)) exit(0);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
@ -2514,13 +2523,14 @@ UpdateGUI (void *arg)
if(ExitRequested) if(ExitRequested)
{ {
for(int a = 0; a < 255; a += 15) for(int a = 5; a < 255; a += 10)
{ {
mainWindow->Draw(); mainWindow->Draw();
Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor){0, 0, 0, a},1); Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor){0, 0, 0, a},1);
Menu_Render(); Menu_Render();
} }
ExitApp(); ShutoffRumble();
return 0;
} }
} }
} }
@ -2537,7 +2547,12 @@ InitGUIThreads()
{ {
LWP_CreateThread (&guithread, UpdateGUI, NULL, NULL, 0, 70); LWP_CreateThread (&guithread, UpdateGUI, NULL, NULL, 0, 70);
} }
void
ExitGUIThreads()
{
ExitRequested = 1;
LWP_JoinThread(guithread, NULL);
}
/**************************************************************************** /****************************************************************************
* EntryCmp * EntryCmp
***************************************************************************/ ***************************************************************************/
@ -2732,7 +2747,7 @@ static int OnScreenKeyboard(char * var, u32 maxlen, int min)
GuiTrigger trigB; GuiTrigger trigB;
trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); trigB.SetSimpleTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiText okBtnTxt(LANGUAGE.ok, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText okBtnTxt(LANGUAGE.ok, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage okBtnImg(&btnOutline); GuiImage okBtnImg(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
okBtnTxt.SetWidescreen(CFG.widescreen); okBtnTxt.SetWidescreen(CFG.widescreen);
@ -2740,7 +2755,7 @@ static int OnScreenKeyboard(char * var, u32 maxlen, int min)
} }
GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 5, 15, &trigA, &btnSoundOver, &btnClick,1); GuiButton okBtn(&okBtnImg,&okBtnImg, 0, 4, 5, 15, &trigA, &btnSoundOver, &btnClick,1);
okBtn.SetLabel(&okBtnTxt); okBtn.SetLabel(&okBtnTxt);
GuiText cancelBtnTxt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText cancelBtnTxt(LANGUAGE.Cancel, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
GuiImage cancelBtnImg(&btnOutline); GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
cancelBtnTxt.SetWidescreen(CFG.widescreen); cancelBtnTxt.SetWidescreen(CFG.widescreen);
@ -2949,8 +2964,8 @@ static int MenuInstall()
mainWindow->Remove(&w); mainWindow->Remove(&w);
ResumeGui(); ResumeGui();
SDCard_deInit(); /// SDCard_deInit();
SDCard_Init(); /// SDCard_Init();
return menu; return menu;
} }
@ -3176,13 +3191,13 @@ static int MenuDiscList()
countBtn.SetImageOver(&countBtnImg); countBtn.SetImageOver(&countBtnImg);
countBtn.SetAlpha(255); countBtn.SetAlpha(255);
} }
if (Settings.gameDisplay==list) if (Settings.gameDisplay==list)
{ {
listBtn.SetImage(&listBtnImg); listBtn.SetImage(&listBtnImg);
listBtn.SetImageOver(&listBtnImg); listBtn.SetImageOver(&listBtnImg);
listBtn.SetAlpha(255); listBtn.SetAlpha(255);
} }
else if (Settings.gameDisplay==grid) else if (Settings.gameDisplay==grid)
{ {
gridBtn.SetImage(&gridBtnImg); gridBtn.SetImage(&gridBtnImg);
gridBtn.SetImageOver(&gridBtnImg); gridBtn.SetImageOver(&gridBtnImg);
@ -3371,22 +3386,9 @@ static int MenuDiscList()
choice = WindowPrompt(LANGUAGE.HowtoShutdown,0,LANGUAGE.FullShutdown, LANGUAGE.ShutdowntoIdle, LANGUAGE.Cancel,0); choice = WindowPrompt(LANGUAGE.HowtoShutdown,0,LANGUAGE.FullShutdown, LANGUAGE.ShutdowntoIdle, LANGUAGE.Cancel,0);
if(choice == 2) if(choice == 2)
{ {
WPAD_Flush(0); Sys_ShutdownToIdel();
WPAD_Disconnect(0);
WPAD_Shutdown();
/* Set LED mode */
ret = CONF_GetIdleLedMode();
if(ret >= 0 && ret <= 2)
STM_SetLedMode(ret);
STM_ShutdownToIdle();
} else if(choice == 1) { } else if(choice == 1) {
WPAD_Flush(0); Sys_ShutdownToStandby();
WPAD_Disconnect(0);
WPAD_Shutdown();
STM_ShutdownToStandby();
} else { } else {
poweroffBtn.ResetState(); poweroffBtn.ResetState();
if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);}
@ -3410,15 +3412,11 @@ static int MenuDiscList()
if(choice == 3) if(choice == 3)
{ {
ExitApp(); Sys_LoadMenu(); // Back to System Menu
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); // Back to System Menu
} }
else if (choice == 2) else if (choice == 2)
{ {
ExitApp(); Sys_BackToLoader();
if (*((u32*) 0x80001800)) exit(0);
// Channel Version
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} else { } else {
homeBtn.ResetState(); homeBtn.ResetState();
if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);} if (Settings.gameDisplay==list){gameBrowser.SetFocus(1);}
@ -3615,7 +3613,7 @@ static int MenuDiscList()
} }
countBtn.ResetState(); countBtn.ResetState();
} }
else if(listBtn.GetState() == STATE_CLICKED) { else if(listBtn.GetState() == STATE_CLICKED) {
if (Settings.gameDisplay!=list){ if (Settings.gameDisplay!=list){
@ -3623,7 +3621,7 @@ static int MenuDiscList()
mainWindow->Remove(&gameGrid); mainWindow->Remove(&gameGrid);
gridBtn.SetImage(&gridBtnImg_g); gridBtn.SetImage(&gridBtnImg_g);
gridBtn.SetImageOver(&gridBtnImg_g); gridBtn.SetImageOver(&gridBtnImg_g);
gridBtn.SetAlpha(180); gridBtn.SetAlpha(180);
} }
if (Settings.gameDisplay==carousel) { if (Settings.gameDisplay==carousel) {
mainWindow->Remove(&gameCarousel); mainWindow->Remove(&gameCarousel);
@ -3675,12 +3673,12 @@ static int MenuDiscList()
} }
} }
listBtn.ResetState(); listBtn.ResetState();
} }
else if (gridBtn.GetState() == STATE_CLICKED) { else if (gridBtn.GetState() == STATE_CLICKED) {
if (Settings.gameDisplay!=grid){ if (Settings.gameDisplay!=grid){
if (Settings.gameDisplay==list) { if (Settings.gameDisplay==list) {
mainWindow->Remove(&gameBrowser); mainWindow->Remove(&gameBrowser);
if (GameIDTxt) w.Remove(GameIDTxt); if (GameIDTxt) w.Remove(GameIDTxt);
if (GameRegionTxt) w.Remove(GameRegionTxt); if (GameRegionTxt) w.Remove(GameRegionTxt);
w.Remove(&DownloadBtn); w.Remove(&DownloadBtn);
@ -3734,12 +3732,12 @@ static int MenuDiscList()
w.Append(&carouselBtn); w.Append(&carouselBtn);
if(isSdInserted()) { if(isSdInserted()) {
cfg_save_global(); cfg_save_global();
} }
} }
gridBtn.ResetState(); gridBtn.ResetState();
} }
else if (carouselBtn.GetState() == STATE_CLICKED) { else if (carouselBtn.GetState() == STATE_CLICKED) {
if (Settings.gameDisplay!=carousel){ if (Settings.gameDisplay!=carousel){
if (Settings.gameDisplay==list) if (Settings.gameDisplay==list)
mainWindow->Remove(&gameBrowser); mainWindow->Remove(&gameBrowser);
@ -3995,31 +3993,25 @@ static int MenuDiscList()
} }
// if we have used the network or cios222 we need to reload the disklist // if we have used the network or cios222 we need to reload the disklist
if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) { if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222)
{
if(ios2 == 1)
{
ret = Sys_IosReload(222);
if(ret < 0)
if(ios2 == 1) { {
WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0);
ret = Sys_IosReload(222); Sys_IosReload(249);
ios2 = 0;
if(ret < 0) { }
Wpad_Init(); }
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); else
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); {
ret = Sys_IosReload(249);
WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0); }
Sys_IosReload(249);
ios2 = 0;
} }
} else {
ret = Sys_IosReload(249);
}
}
/* Set USB mode */ /* Set USB mode */
ret = Disc_SetUSB(header->id, ios2); ret = Disc_SetUSB(header->id, ios2);
if (ret < 0) { if (ret < 0) {
@ -4089,31 +4081,24 @@ static int MenuDiscList()
} }
// if we have used the network or cios222 we need to reload the disklist // if we have used the network or cios222 we need to reload the disklist
if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) { if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222)
{
if(ios2 == 1)
if(ios2 == 1) { {
ret = Sys_IosReload(222);
ret = Sys_IosReload(222); if(ret < 0)
{
if(ret < 0) { WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0);
Wpad_Init(); Sys_IosReload(249);
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); ios2 = 0;
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); }
}
WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0); else
{
Sys_IosReload(249); ret = Sys_IosReload(249);
ios2 = 0; }
} }
} else {
ret = Sys_IosReload(249);
}
}
/* Set USB mode */ /* Set USB mode */
@ -4191,6 +4176,7 @@ static int MenuDiscList()
static int MenuFormat() static int MenuFormat()
{ {
USBDevice_deInit();
int menu = MENU_NONE; int menu = MENU_NONE;
char imgPath[100]; char imgPath[100];
@ -4386,9 +4372,6 @@ static int MenuFormat()
choice = WindowPrompt (LANGUAGE.ShutdownSystem,LANGUAGE.Areyousure,LANGUAGE.Yes,LANGUAGE.No,0,0); choice = WindowPrompt (LANGUAGE.ShutdownSystem,LANGUAGE.Areyousure,LANGUAGE.Yes,LANGUAGE.No,0,0);
if(choice == 1) if(choice == 1)
{ {
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
Sys_Shutdown(); Sys_Shutdown();
} }
@ -4397,8 +4380,7 @@ static int MenuFormat()
choice = WindowPrompt (LANGUAGE.ReturntoWiiMenu,LANGUAGE.Areyousure,LANGUAGE.Yes,LANGUAGE.No,0,0); choice = WindowPrompt (LANGUAGE.ReturntoWiiMenu,LANGUAGE.Areyousure,LANGUAGE.Yes,LANGUAGE.No,0,0);
if(choice == 1) if(choice == 1)
{ {
ExitApp(); Sys_LoadMenu();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
} }
} }
@ -4419,6 +4401,7 @@ static int MenuFormat()
mainWindow->Remove(&optionBrowser); mainWindow->Remove(&optionBrowser);
mainWindow->Remove(&w); mainWindow->Remove(&w);
ResumeGui(); ResumeGui();
USBDevice_Init();
return menu; return menu;
} }
@ -4474,7 +4457,7 @@ static int MenuSettings()
settingsbackgroundbtn.SetPosition(0, 0); settingsbackgroundbtn.SetPosition(0, 0);
settingsbackgroundbtn.SetImage(&settingsbackground); settingsbackgroundbtn.SetImage(&settingsbackground);
GuiText backBtnTxt(LANGUAGE.Back , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText backBtnTxt(LANGUAGE.Back , 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
@ -5420,15 +5403,11 @@ static int MenuSettings()
if(choice == 3) if(choice == 3)
{ {
ExitApp(); Sys_LoadMenu(); // Back to System Menu
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); // Back to System Menu
} }
else if (choice == 2) else if (choice == 2)
{ {
ExitApp(); Sys_BackToLoader();
if (*((u32*) 0x80001800)) exit(0);
// Channel Version
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
else else
{ {
@ -5514,7 +5493,7 @@ int GameSettings(struct discHdr * header)
settingsbackgroundbtn.SetPosition(0, 0); settingsbackgroundbtn.SetPosition(0, 0);
settingsbackgroundbtn.SetImage(&settingsbackground); settingsbackgroundbtn.SetImage(&settingsbackground);
GuiText saveBtnTxt(LANGUAGE.Save, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText saveBtnTxt(LANGUAGE.Save, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
saveBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); saveBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage saveBtnImg(&btnOutline); GuiImage saveBtnImg(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
@ -5524,7 +5503,7 @@ int GameSettings(struct discHdr * header)
saveBtn.SetScale(0.9); saveBtn.SetScale(0.9);
saveBtn.SetLabel(&saveBtnTxt); saveBtn.SetLabel(&saveBtnTxt);
GuiText cancelBtnTxt(LANGUAGE.Back, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText cancelBtnTxt(LANGUAGE.Back, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage cancelBtnImg(&btnOutline); GuiImage cancelBtnImg(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
@ -5535,7 +5514,7 @@ int GameSettings(struct discHdr * header)
cancelBtn.SetLabel(&cancelBtnTxt); cancelBtn.SetLabel(&cancelBtnTxt);
cancelBtn.SetTrigger(&trigB); cancelBtn.SetTrigger(&trigB);
GuiText deleteBtnTxt(LANGUAGE.Uninstall, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); //{0, 0, 0, 255}); GuiText deleteBtnTxt(LANGUAGE.Uninstall, 22, (GXColor){THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
deleteBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); deleteBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage deleteBtnImg(&btnOutline); GuiImage deleteBtnImg(&btnOutline);
if (Settings.wsprompt == yes){ if (Settings.wsprompt == yes){
@ -5752,7 +5731,7 @@ static int MenuCheck()
int menu = MENU_NONE; int menu = MENU_NONE;
int i = 0; int i = 0;
int choice; int choice;
s32 ret2; s32 ret, ret2;
OptionList options; OptionList options;
options.length = i; options.length = i;
partitionEntry partitions[MAX_PARTITIONS]; partitionEntry partitions[MAX_PARTITIONS];
@ -5762,87 +5741,92 @@ static int MenuCheck()
ret2 = WBFS_Init(WBFS_DEVICE_USB); ret2 = WBFS_Init(WBFS_DEVICE_USB);
if (ret2 < 0) if (ret2 < 0)
{ {
//initialize WiiMote for Prompt
Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
ret2 = WindowPrompt(LANGUAGE.NoUSBDevicefound, ret2 = WindowPrompt(LANGUAGE.NoUSBDevicefound,
LANGUAGE.Doyouwanttoretryfor30secs, LANGUAGE.Doyouwanttoretryfor30secs,
"cIOS249", "cIOS222", "cIOS249", "cIOS222",
LANGUAGE.BacktoWiiMenu, 0); LANGUAGE.BacktoWiiMenu, 0);
//shutdown SD
SDCard_deInit();
if(ret2 == 1) { if(ret2 == 1) {
Settings.cios = ios249; Settings.cios = ios249;
} else if(ret2 == 2) { } else if(ret2 == 2) {
Settings.cios = ios222; if(Settings.cios != ios222)
{
//shutdown WiiMote before IOS Reload
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
//shutdown SD and USB before IOS Reload
SDCard_deInit();
USBDevice_deInit();
ret = IOS_ReloadIOS(222);
if(ret < 0)
IOS_ReloadIOS(249);
//reinitialize WiiMote for Prompt
PAD_Init();
Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
//reinitialize SD and USB
SDCard_Init();
USBDevice_Init();
if(ret < 0)
WindowPrompt(LANGUAGE.YoudonthavecIOS,LANGUAGE.LoadingincIOS,LANGUAGE.ok, 0,0,0);
else
Settings.cios = ios222;
}
} else { } else {
ExitApp(); Sys_LoadMenu();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
//shutdown WiiMote before IOS Reload //shutdown WiiMote before IOS Reload
WPAD_Flush(0); WPAD_Flush(0);
WPAD_Disconnect(0); WPAD_Disconnect(0);
WPAD_Shutdown(); WPAD_Shutdown();
SDCard_Init(); //shutdown SD and USB before IOS Reload in DiscWait
SDCard_deInit();
USBDevice_deInit();
ret2 = DiscWait(LANGUAGE.NoUSBDevice, LANGUAGE.WaitingforUSBDevice, 0, 0, 1); ret2 = DiscWait(LANGUAGE.NoUSBDevice, LANGUAGE.WaitingforUSBDevice, 0, 0, 1);
PAD_Init(); //reinitialize WiiMote for Prompt
PAD_Init();
Wpad_Init(); Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
//reinitialize SD and USB
SDCard_Init(); SDCard_Init();
USBDevice_Init();
} }
if (ret2 < 0) { if (ret2 < 0) {
SDCard_Init();
WindowPrompt (LANGUAGE.Error,LANGUAGE.USBDevicenotfound, LANGUAGE.ok, 0,0,0); WindowPrompt (LANGUAGE.Error,LANGUAGE.USBDevicenotfound, LANGUAGE.ok, 0,0,0);
SDCard_deInit(); Sys_LoadMenu();
ExitApp(); }
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} else {
PAD_Init();
Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
SDCard_Init();
}
ret2 = Disc_Init(); ret2 = Disc_Init();
if (ret2 < 0) { if (ret2 < 0) {
SDCard_Init();
WindowPrompt (LANGUAGE.Error,LANGUAGE.CouldnotinitializeDIPmodule,LANGUAGE.ok, 0,0,0); WindowPrompt (LANGUAGE.Error,LANGUAGE.CouldnotinitializeDIPmodule,LANGUAGE.ok, 0,0,0);
SDCard_deInit(); Sys_LoadMenu();
ExitApp();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
ret2 = WBFS_Open(); ret2 = WBFS_Open();
if (ret2 < 0) { if (ret2 < 0) {
SDCard_Init();
choice = WindowPrompt(LANGUAGE.NoWBFSpartitionfound, choice = WindowPrompt(LANGUAGE.NoWBFSpartitionfound,
LANGUAGE.Youneedtoformatapartition, LANGUAGE.Youneedtoformatapartition,
LANGUAGE.Format, LANGUAGE.Format,
LANGUAGE.Return,0,0); LANGUAGE.Return,0,0);
SDCard_deInit();
if(choice == 0) if(choice == 0)
{ {
ExitApp(); Sys_LoadMenu();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} else { } else {
/* Get partition entries */ /* Get partition entries */
u32 sector_size; u32 sector_size;
ret2 = Partition_GetEntries(partitions, &sector_size); ret2 = Partition_GetEntries(partitions, &sector_size);
if (ret2 < 0) { if (ret2 < 0) {
SDCard_Init();
WindowPrompt (LANGUAGE.Nopartitionsfound,0, LANGUAGE.Restart, 0,0,0); WindowPrompt (LANGUAGE.Nopartitionsfound,0, LANGUAGE.Restart, 0,0,0);
SDCard_deInit(); Sys_LoadMenu();
ExitApp();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
menu = MENU_FORMAT; menu = MENU_FORMAT;
} }
} }
@ -6302,6 +6286,7 @@ int MainMenu(int menu)
break; break;
} }
} }
ExitGUIThreads();
bgMusic->Stop(); bgMusic->Stop();
@ -6319,7 +6304,11 @@ int MainMenu(int menu)
delete cover; delete cover;
delete coverImg; delete coverImg;
ExitApp(); StopGX();
ShutdownAudio();
SDCard_deInit();
USBDevice_deInit();
struct discHdr *header = &gameList[gameSelected]; struct discHdr *header = &gameList[gameSelected];
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
@ -6461,8 +6450,7 @@ int MainMenu(int menu)
int ret = 0; int ret = 0;
ret = Disc_WiiBoot(videoselected, cheat, vipatch, Settings.patchcountrystrings); ret = Disc_WiiBoot(videoselected, cheat, vipatch, Settings.patchcountrystrings);
if (ret < 0) { if (ret < 0) {
ExitApp(); Sys_LoadMenu();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
return 0; return 0;

View File

@ -11,7 +11,16 @@
#include <ogcsys.h> #include <ogcsys.h>
void InitGUIThreads(); #ifdef __cplusplus
//extern "C"
//{
#endif
void InitGUIThreads(void);
void ExitGUIThreads(void);
#ifdef __cplusplus
//}
#endif
int MainMenu (int menuitem); int MainMenu (int menuitem);
void wiilight(int enable); void wiilight(int enable);
int GameSettings(struct discHdr *); int GameSettings(struct discHdr *);

View File

@ -8,6 +8,8 @@
#include "disc.h" #include "disc.h"
#include "wbfs.h" #include "wbfs.h"
#include "video.h" #include "video.h"
#include "audio.h"
#include "menu.h"
#include "fatmounter.h" #include "fatmounter.h"
/* Constants */ /* Constants */
@ -41,9 +43,21 @@ void Sys_Init(void)
SYS_SetPowerCallback(__Sys_PowerCallback); SYS_SetPowerCallback(__Sys_PowerCallback);
} }
static void _ExitApp()
{
ExitGUIThreads();
StopGX();
ShutdownAudio();
SDCard_deInit();
USBDevice_deInit();
}
void Sys_Reboot(void) void Sys_Reboot(void)
{ {
/* Restart console */ /* Restart console */
_ExitApp();
STM_RebootSystem(); STM_RebootSystem();
} }
@ -51,8 +65,9 @@ int Sys_IosReload(int IOS)
{ {
s32 ret; s32 ret;
if(isSdInserted()) //shutdown SD and USB before IOS Reload in DiscWait
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit();
WPAD_Flush(0); WPAD_Flush(0);
WPAD_Disconnect(0); WPAD_Disconnect(0);
@ -62,35 +77,49 @@ int Sys_IosReload(int IOS)
USBStorage_Deinit(); USBStorage_Deinit();
__IOS_ShutdownSubsystems();
ret = IOS_ReloadIOS(IOS); ret = IOS_ReloadIOS(IOS);
if(ret < 0) {
return ret;
}
PAD_Init(); PAD_Init();
Wpad_Init(); Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
if(IOS == 249 || IOS == 222) { if(ret < 0) {
ret = WBFS_Init(WBFS_DEVICE_USB); return ret;
ret = Disc_Init();
ret = WBFS_Open();
} }
if(IOS == 249 || IOS == 222 || IOS == 223) {
ret = WBFS_Init(WBFS_DEVICE_USB);
if(ret>=0)
{
ret = Disc_Init();
if(ret>=0)
ret = WBFS_Open();
}
}
//reinitialize SD and USB
SDCard_Init();
USBDevice_Init();
return ret; return ret;
} }
void Sys_Shutdown(void)
#define ShutdownToDefault 0
#define ShutdownToIdle 1
#define ShutdownToStandby 2
static void _Sys_Shutdown(int SHUTDOWN_MODE)
{ {
Wpad_Disconnect(); _ExitApp();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
/* Poweroff console */ /* Poweroff console */
if(CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE) { if((CONF_GetShutdownMode() == CONF_SHUTDOWN_IDLE && SHUTDOWN_MODE != ShutdownToStandby) || SHUTDOWN_MODE == ShutdownToIdle) {
s32 ret; s32 ret;
/* Set LED mode */ /* Set LED mode */
@ -105,13 +134,37 @@ void Sys_Shutdown(void)
STM_ShutdownToStandby(); 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) void Sys_LoadMenu(void)
{ {
_ExitApp();
/* Return to the Wii system menu */ /* Return to the Wii system menu */
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
void Sys_BackToLoader(void)
{
if (*((u32*) 0x80001800))
{
_ExitApp();
exit(0);
}
// Channel Version
Sys_LoadMenu();
}
s32 Sys_GetCerts(signed_blob **certs, u32 *len) s32 Sys_GetCerts(signed_blob **certs, u32 *len)
{ {
static signed_blob certificates[CERTS_LEN] ATTRIBUTE_ALIGN(32); static signed_blob certificates[CERTS_LEN] ATTRIBUTE_ALIGN(32);

View File

@ -3,18 +3,21 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ //{
#endif #endif
/* Prototypes */ /* Prototypes */
void Sys_Init(void); void Sys_Init(void);
void Sys_Reboot(void); void Sys_Reboot(void);
void Sys_Shutdown(void); void Sys_Shutdown(void);
void Sys_LoadMenu(void); void Sys_ShutdownToIdel(void);
void Sys_ShutdownToStandby(void);
void Sys_LoadMenu(void);
void Sys_BackToLoader(void);
int Sys_IosReload(int IOS); int Sys_IosReload(int IOS);
s32 Sys_GetCerts(signed_blob **, u32 *); s32 Sys_GetCerts(signed_blob **, u32 *);
#ifdef __cplusplus #ifdef __cplusplus
} //}
#endif #endif
#endif #endif