From 7526b140a6039c6fa106b72eae93c64662137ab0 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Wed, 6 May 2009 09:51:16 +0000 Subject: [PATCH] *Some little changes --- source/menu.cpp | 124 +++++++++++++++++++++--------------------------- source/sys.c | 46 ++++++++++++++++++ source/sys.h | 3 +- 3 files changed, 101 insertions(+), 72 deletions(-) diff --git a/source/menu.cpp b/source/menu.cpp index 20c96c7b..e6cbc743 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -1248,10 +1248,12 @@ FormatingPartition(const char *title, partitionEntry *entry) /**************************************************************************** * NetworkInit ***************************************************************************/ -char * NetworkInitPromp(int choice2) +int NetworkInitPromp(int choice2) { - char myIP [16]; - char * IP = 0; + char hostip[16]; + char * IP = NULL; + s32 ret = -1; + GuiWindow promptWindow(472,320); promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE); promptWindow.SetPosition(0, -10); @@ -1298,22 +1300,31 @@ char * NetworkInitPromp(int choice2) mainWindow->SetState(STATE_DISABLED); mainWindow->Append(&promptWindow); mainWindow->ChangeFocus(&promptWindow); + ResumeGui(); - VIDEO_WaitVSync(); - - while (!IP) + while (!IP) { - Net_Init(myIP); - IP = myIP; - if (IP) { + VIDEO_WaitVSync(); + + ret = Net_Init(hostip); + + if (ret > 0) { + IP = hostip; + } + + if (ret <= 0) { + msgTxt.SetText("Could not initialize network!"); + } + + if (IP && ret > 0) { sprintf(msg, "IP: %s", IP); msgTxt.SetText(msg); cntMissFiles = 0; u32 i = 0; char filename[11]; - // char filenameshort[10]; + bool found1 = false;/////add Ids of games that are missing covers to cntMissFiles bool found2 = false; for (i = 0; i < gameCnt && cntMissFiles < 500; i++) @@ -1348,8 +1359,9 @@ char * NetworkInitPromp(int choice2) break; } - if(btn1.GetState() == STATE_CLICKED) { //pending: this should be inside the for loop + if(btn1.GetState() == STATE_CLICKED) { IP = 0; + ret = -1; break; } @@ -1360,7 +1372,8 @@ char * NetworkInitPromp(int choice2) mainWindow->Remove(&promptWindow); mainWindow->SetState(STATE_DEFAULT); ResumeGui(); - return IP; + + return ret; } /**************************************************************************** @@ -2503,7 +2516,14 @@ static int MenuDiscList() WPAD_Flush(0); WPAD_Disconnect(0); WPAD_Shutdown(); + + /* Set LED mode */ + ret = CONF_GetIdleLedMode(); + if(ret >= 0 && ret <= 2) + STM_SetLedMode(ret); + STM_ShutdownToIdle(); + } else if(choice == 2) { WPAD_Flush(0); WPAD_Disconnect(0); @@ -2563,17 +2583,20 @@ static int MenuDiscList() if (choice != 0) { - char * myIP; + int netset; int choice2 = choice; - myIP = NetworkInitPromp(choice2); + netset = NetworkInitPromp(choice2); networkisinitialized = 1; - if( !myIP ) + + if(netset < 0) { - WindowPrompt("Network init error", 0, "ok",0); + WindowPrompt("Network init error", 0, "OK",0); netcheck = false; + + } else { + netcheck = true; } - else netcheck = true; if (netcheck) { @@ -2762,49 +2785,27 @@ static int MenuDiscList() // if we have used the network or cios222 we need to reload the disklist if(networkisinitialized == 1 || ios2 == 1 || Settings.cios == ios222) { - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); - - WDVD_Close(); - - USBStorage_Deinit(); if(ios2 == 1) { - ret = IOS_ReloadIOS(222); - if(ret < 0) { + ret = Sys_IosReload(222); + if(ret < 0) { Wpad_Init(); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); WindowPrompt("You don't have cIOS222!","Loading in cIOS249!","OK", 0); - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); - - IOS_ReloadIOS(249); + Sys_IosReload(249); ios2 = 0; } } else { - ret = IOS_ReloadIOS(249); + ret = Sys_IosReload(249); } - - ret = WBFS_Init(WBFS_DEVICE_USB); - - PAD_Init(); - Wpad_Init(); - WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); - - ret = Disc_Init(); - ret = WBFS_Open(); - } /* Set USB mode */ @@ -2829,7 +2830,8 @@ static int MenuDiscList() else { menu = MENU_EXIT; } - }break; + } + break; } bool returnHere = true;// prompt to start game while (returnHere) @@ -2860,54 +2862,34 @@ static int MenuDiscList() break; } - // 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) { - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); - - WDVD_Close(); - - USBStorage_Deinit(); if(ios2 == 1) { - ret = IOS_ReloadIOS(222); - if(ret < 0) { + ret = Sys_IosReload(222); + if(ret < 0) { Wpad_Init(); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); WindowPrompt("You don't have cIOS222!","Loading in cIOS249!","OK", 0); - WPAD_Flush(0); - WPAD_Disconnect(0); - WPAD_Shutdown(); - - IOS_ReloadIOS(249); + Sys_IosReload(249); ios2 = 0; } } else { - ret = IOS_ReloadIOS(249); + ret = Sys_IosReload(249); } - - ret = WBFS_Init(WBFS_DEVICE_USB); - - PAD_Init(); - Wpad_Init(); - WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); - WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); - - ret = Disc_Init(); - ret = WBFS_Open(); - } + + /* Set USB mode */ ret = Disc_SetUSB(header->id, ios2); if (ret < 0) { diff --git a/source/sys.c b/source/sys.c index c2785f81..90ecf73c 100644 --- a/source/sys.c +++ b/source/sys.c @@ -1,8 +1,15 @@ #include #include +#include +#include #include "sys.h" #include "wpad.h" +#include "wdvd.h" +#include "usbstorage.h" +#include "disc.h" +#include "wbfs.h" +#include "video.h" /* Constants */ #define CERTS_LEN 0x280 @@ -41,6 +48,45 @@ void Sys_Reboot(void) STM_RebootSystem(); } +int Sys_IosReload(int IOS) +{ + s32 ret; + + fatUnmount("SD"); + __io_wiisd.shutdown(); + + WPAD_Flush(0); + WPAD_Disconnect(0); + WPAD_Shutdown(); + + WDVD_Close(); + + USBStorage_Deinit(); + + ret = IOS_ReloadIOS(IOS); + + if(ret < 0) { + return ret; + } + + PAD_Init(); + Wpad_Init(); + WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); + WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight); + + __io_wiisd.startup(); + fatMountSimple("SD", &__io_wiisd); + + if(IOS == 249 || IOS == 222) { + ret = WBFS_Init(WBFS_DEVICE_USB); + ret = Disc_Init(); + ret = WBFS_Open(); + } + + return ret; + +} + void Sys_Shutdown(void) { Wpad_Disconnect(); diff --git a/source/sys.h b/source/sys.h index fbfdcac1..691c8a80 100644 --- a/source/sys.h +++ b/source/sys.h @@ -10,7 +10,8 @@ extern "C" void Sys_Init(void); void Sys_Reboot(void); void Sys_Shutdown(void); -void Sys_LoadMenu(void); +void Sys_LoadMenu(void); +int Sys_IosReload(int IOS); s32 Sys_GetCerts(signed_blob **, u32 *); #ifdef __cplusplus