*Finished the background initialization thread for devices started by giantpune and merged it into trunk. Now you can startup the loader without a HDD. Also you can put in your device after startup and it will be recognized. Hot swapping not yet added (as in remove and than stick it in).

You will see the list of available channels on your system if you start without a HDD or if your HDD is slow and is being recognized late. The list of games is than reloading as soon as it is recognized.
*Hot swapping of the SD card was implemented into background thread (by giantpune)
*Made lots of cleanups and some fixes
*Format menu was moved to settings page 3 (only on godmode accessable)
*Added ScreenShot and Reset/Shutdown call to background thread. Removed the not needed ones. Now you can call for Screenshot/Reset/Shutdown anywhere in the loader (after gui is started).
This commit is contained in:
dimok321 2010-01-06 23:07:35 +00:00
parent ffb017b6bc
commit 15bcbfa482
33 changed files with 3592 additions and 3743 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,6 +6,30 @@
***************************************************************************/
#include "gui_banner.h"
typedef struct
{
u32 texture_header_offset;
u32 palette_header_offset;
} TPLTexture;
typedef struct
{
u16 heigth;
u16 width;
//...
//there is more but we only need these
} TPLTextureHeader;
//only one field tpls
typedef struct
{
u32 magic;
u32 ntextures;
u32 texture_size;
TPLTexture textures;
} TPLHeader;
GuiBanner::GuiBanner(const char *tplfilepath)
{
memory = NULL;
@ -17,12 +41,6 @@ GuiBanner::GuiBanner(const char *tplfilepath)
if(tplfp !=NULL) {
unsigned short heighttemp = 0;
unsigned short widthtemp = 0;
fseek(tplfp , 0x14, SEEK_SET);
fread((void*)&heighttemp,1,2,tplfp);
fread((void*)&widthtemp,1,2,tplfp);
fseek (tplfp , 0 , SEEK_END);
tplfilesize = ftell (tplfp);
rewind (tplfp);
@ -34,6 +52,13 @@ GuiBanner::GuiBanner(const char *tplfilepath)
fread(memory, 1, tplfilesize, tplfp);
fclose(tplfp);
const u8 * buffer = (const u8*) memory;
const TPLHeader *hdr = (TPLHeader *) buffer;
const TPLTextureHeader *texhdr = (TPLTextureHeader *) &buffer[hdr->textures.texture_header_offset];
height = texhdr[0].heigth;
width = texhdr[0].width;
TPLFile tplfile;
int ret;
@ -51,8 +76,6 @@ GuiBanner::GuiBanner(const char *tplfilepath)
}
TPL_CloseTPLFile(&tplfile);
width = widthtemp;
height = heighttemp;
widescreen = 0;
filecheck = true;
@ -62,14 +85,20 @@ GuiBanner::GuiBanner(const char *tplfilepath)
}
}
GuiBanner::GuiBanner(void *mem, u32 len, int w, int h)
GuiBanner::GuiBanner(void *mem, u32 len)
{
if(!mem || !len)
return;
memory = mem;
tplfilesize = len;
width = w;
height = h;
const u8 * buffer = (const u8*) memory;
const TPLHeader *hdr = (TPLHeader *) buffer;
const TPLTextureHeader *texhdr = (TPLTextureHeader *) &buffer[hdr->textures.texture_header_offset];
height = texhdr[0].heigth;
width = texhdr[0].width;
TPLFile tplfile;

View File

@ -19,9 +19,7 @@ public:
//!Constructor
//!\param mem Memory of the loaded tpl
//!\param len Filesize of the tpl
//!\param w Width of the tpl
//!\param h Height of the tpl
GuiBanner(void *mem, u32 len, int w, int h);
GuiBanner(void *mem, u32 len);
//!Destructor
~GuiBanner();
void Draw();

View File

@ -13,6 +13,8 @@ extern "C"
{
#endif
#include <gccore.h>
/***********************************************************
* Error description:
* 0 Successfully extracted

View File

@ -12,11 +12,7 @@
#include "filelist.h"
#include "sys.h"
#include "gct.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
#include "../menu/menus.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;

View File

@ -28,9 +28,7 @@
#include "unzip/miniunz.h"
#include "usbloader/utils.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
#include "../menu/menus.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;
@ -39,8 +37,6 @@ extern GuiImage * bgImg;
extern u32 infilesize;
extern u32 uncfilesize;
extern char wiiloadVersion[2];
extern u8 shutdown;
extern u8 reset;
extern struct SSettings Settings;
extern void *innetbuffer;
@ -731,11 +727,6 @@ int MenuHomebrewBrowse() {
MainButton4.ResetState();
}
else if (shutdown == 1)
Sys_Shutdown();
else if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED) {
menu = MENU_DISCLIST;
changed = true;

View File

@ -129,13 +129,13 @@ GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, co
for(int i=0; i < pagesize; i++)
{
gameTxt[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext);
gameTxt[i] = new GuiText(NULL, 20, THEME.gametext);
gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
gameTxt[i]->SetPosition(24,0);
gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED);
gameTxtOver[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext);
gameTxtOver[i] = new GuiText(NULL, 20, THEME.gametext);
gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
gameTxtOver[i]->SetPosition(24,0);
gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL);
@ -326,6 +326,9 @@ void GuiGameBrowser::Draw()
void GuiGameBrowser::UpdateListEntries()
{
if(!gameList)
return;
int next = listOffset;
for(int i=0; i<pagesize; i++)
{

View File

@ -15,14 +15,13 @@
#include <ogcsys.h>
#include <unistd.h>
#include <locale.h>
#include <ogc/libversion.h>
#include <wiiuse/wpad.h>
//#include <debug.h>
extern "C"
{
extern "C" {
extern void __exception_setreload(int t);
}
#include <di/di.h>
#include <sys/iosupport.h>
@ -50,10 +49,14 @@ extern "C"
#include "usbloader/usbstorage.h"
#include "memory/mem2.h"
#include "lstub.h"
#include "xml/xml.h"
#include "settings/newtitles.h"
#include "menu/menus.h"
extern bool geckoinit;
extern bool textVideoInit;
extern char headlessID[8];
PartList partitions;
/* Constants */
#define CONSOLE_XCOORD 260
@ -63,152 +66,50 @@ extern char headlessID[8];
FreeTypeGX *fontSystem=0;
FreeTypeGX *fontClock=0;
PartList partitions;
u8 dbvideo =0;
static void BootUpProblems()
void LoadHeadlessID(const char * ID)
{
s32 ret2;
// load main font from file, or default to built-in font
fontSystem = new FreeTypeGX();
fontSystem->loadFont(NULL, font_ttf, font_ttf_size, 0);
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
GuiImageData bootimageData(gxlogo_png);
GuiImage bootimage(&bootimageData);
GuiText boottext(NULL, 20, (GXColor) {255, 255, 255, 255}
);
boottext.SetPosition(200, 240-1.2*bootimage.GetHeight()/2+250);
bootimage.SetPosition(320-1.2*bootimage.GetWidth()/2, 240-1.2*bootimage.GetHeight()/2);
bootimage.SetScale(1.2);
GuiImageData usbimageData(usbport_png);
GuiImage usbimage(&usbimageData);
usbimage.SetPosition(400,300);
usbimage.SetScale(.7);
usbimage.SetAlpha(200);
time_t curtime;
InitTextVideo();
strncpy(headlessID, ID, sizeof(headlessID));
InitCheckThread();
time_t endtime = time(0) + 30;
do
time_t curtime;
printf("\tWaiting for USB-Device:\n");
while(checkthreadState != 1)
{
/*ret2 = IOS_ReloadIOSsafe(249);
if (ret2 < 0) {
ret2 = IOS_ReloadIOSsafe(222);
SDCard_Init();
load_ehc_module();
SDCard_deInit();
if(ret2 <0) {
boottext.SetText("ERROR: cIOS could not be loaded!");
bootimage.Draw();
boottext.Draw();
Menu_Render();
usleep(100);
curtime = time(0);
printf("\t\t%d\n", int(endtime-curtime));
if(endtime == curtime)
{
printf("\n\tDevice could not be loaded.\n\tExiting...\n");
sleep(5);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
}*/
USBDevice_deInit();
USBDevice_Init();
ret2 = WBFS_Init(WBFS_DEVICE_USB);
if (ret2 >= 0)
{
boottext.SetText("Loading...");
bootimage.Draw();
boottext.Draw();
Menu_Render();
break;
}
curtime = time(0);
boottext.SetTextf("Waiting for your slow USB Device: %i secs...", int(endtime-curtime));
while(curtime == time(0))
{
boottext.Draw();
bootimage.Draw();
if (endtime-curtime<15)usbimage.Draw();
Menu_Render();
}
} while((endtime-time(0)) > 0);
/*if(ret2 < 0) {
boottext.SetText("ERROR: USB device could not be loaded!");
usbimage.Draw();
bootimage.Draw();
boottext.Draw();
Menu_Render();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}*/
///delete font to load up custom if set
if(fontSystem)
{
delete fontSystem;
fontSystem = NULL;
}
mountMethod = 0;
checkthreadState = 0;
ExitCheckThread();
CloseXMLDatabase();
NewTitles::DestroyInstance();
ShutdownAudio();
StopGX();
gettextCleanUp();
menuBootgame(headlessID);
}
unsigned int *xfb = NULL;
void InitTextVideo ()
{
gprintf("\nInitTextVideo ()");
if (textVideoInit)
{
gprintf("...0");
return;
}
dbvideo=1;
VIDEO_Init();
// get default video mode
GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL);
// widescreen fix
VIDEO_Configure (vmode);
// Allocate the video buffers
xfb = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
// A console is always useful while debugging
console_init (xfb, 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
// Clear framebuffers etc.
VIDEO_ClearFrameBuffer (vmode, xfb, COLOR_BLACK);
VIDEO_SetNextFramebuffer (xfb);
VIDEO_SetBlack (FALSE);
VIDEO_Flush ();
VIDEO_WaitVSync ();
if (vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync ();
//send console output to the gecko
if (geckoinit)CON_EnableGecko(1, true);
textVideoInit = true;
gprintf("...1");
}
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
setlocale(LC_ALL, "en.UTF-8");
geckoinit = InitGecko();
if (hbcStubAvailable() || geckoinit)
{
InitTextVideo();
}
// DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
//_break();
__exception_setreload(5);//auto reset code dump nobody gives us codedump info anyways.
gprintf("\n\n------------------");
gprintf("\nUSB Loader GX rev%s",GetRev());
gprintf("\nUSB Loader GX rev%s linked with %s",GetRev(), _V_STRING);
gprintf("\nmain(%d", argc);
for (int i=0;i<argc;i++)
gprintf(", %s",argv[i]?argv[i]:"<NULL>");
@ -217,10 +118,7 @@ main(int argc, char *argv[])
// This part is added, because we need a identify patched ios
//printf("\n\tReloading into ios 236");
if (IOS_ReloadIOSsafe(236) < 0)
{
// printf("\n\tIOS 236 not found, reloading into 36");
IOS_ReloadIOSsafe(36);
}
printf("\n\tStarting up");
@ -228,13 +126,10 @@ main(int argc, char *argv[])
MEM2_takeBigOnes(true);
s32 ret;
bool startupproblem = false;
bool bootDevice_found=false;
if (argc >= 1)
{
if (!strncasecmp(argv[0], "usb:/", 5))
{
if (argc >= 1) {
if (!strncasecmp(argv[0], "usb:/", 5)) {
strcpy(bootDevice, "USB:");
bootDevice_found = true;
} else if (!strncasecmp(argv[0], "sd:/", 4))
@ -249,136 +144,18 @@ main(int argc, char *argv[])
printf("\n\tInitialize USB (wake up)");
USBDevice_Init();// seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5")
gprintf("\n\tChecking for stub IOS");
ios222rev = getIOSrev(0x00000001000000dell);
ios249rev = getIOSrev(0x00000001000000f9ll);
//if we don't like either of the cIOS then scram
if (!(ios222rev==4 || (ios249rev>=9 && ios249rev<65280)))
{
InitTextVideo();
printf("\x1b[2J");
if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL))
{
printf("\n\n\n\tWARNING!");
printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.");
printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,");
printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii.");
printf("\n\n\tThis message will show every time.");
sleep(5);
}
else
{
printf("\n\n\n\tERROR!");
printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":"");
printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":"");
printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me.");
sleep(15);
printf("\n\n\tBye");
USBDevice_deInit();
exit(0);
}
}
printf("\n\tReloading ios 249...");
ret = IOS_ReloadIOSsafe(249);
printf("%d", ret);
if (ret < 0)
{
printf("\n\tIOS 249 failed, reloading ios 222...");
ret = IOS_ReloadIOSsafe(222);
printf("%d", ret);
if (ret < 0)
{
printf("\n\tIOS 222 failed, reloading ios 250...");
ret = IOS_ReloadIOSsafe(250);
printf("%d", ret);
if(ret < 0)
{
printf("\n\tIOS 250 failed, reloading ios 223...");
ret = IOS_ReloadIOSsafe(223);
printf("%d", ret);
if (ret < 0)
{
printf("\n\tERROR: cIOS could not be loaded!\n");
sleep(5);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
}
}
printf("\n\tInitialize sd card");
SDCard_Init();
printf("\n\tLoad ehc module");
load_ehc_module();
printf("\n\tdeinit sd card");
SDCard_deInit();
}
printf("\n\tInit wbfs...");
ret = WBFS_Init(WBFS_DEVICE_USB);
printf("%d", ret);
if (ret < 0)
{
printf("\n\tYou have issues with a slow disc, or a difficult disc\n\tReloading 222...");
ret = IOS_ReloadIOSsafe(222);
printf("%d", ret);
/*if(ret < 0) {
// printf("\n\tSleeping for 4 seconds");
// sleep(4);
InitVideo(); // Initialise video
Menu_Render();
BootUpProblems();
startupproblem = true;
ret = 1;
}*/
printf("\n\tInitialize sd card");
SDCard_Init();
printf("\n\tLoad ehc module");
load_ehc_module();
printf("\n\tdeinit sd card");
SDCard_deInit();
printf("\n\tInitialize wbfs...");
USBDevice_deInit();
USBDevice_Init();
ret = WBFS_Init(WBFS_DEVICE_USB);
printf("%d", ret);
if(ret < 0)
{
// printf("\n\tSleeping for 4 seconds");
// sleep(4);
InitVideo(); // Initialise video
Menu_Render();
BootUpProblems();
startupproblem = true;
ret = 1;
}
}
ret = CheckForCIOS();
printf("\n\tInitialize sd card");
SDCard_Init(); // mount SD for loading cfg's
//this should have already been done by now in order to WBFS_Init().
printf("\n\tInitialize usb device");
USBDevice_Init(); // and mount USB:/
if (!bootDevice_found)
{
printf("\n\tSearch for configuration file");
//try USB
//left in all the dol and elf files in this check in case this is the first time running the app and they dont have the config
if (checkfile((char*) "USB:/config/GXglobal.cfg") || (checkfile((char*) "USB:/apps/usbloader_gx/boot.elf"))
@ -389,95 +166,25 @@ main(int argc, char *argv[])
printf("\n\tConfiguration file is on %s", bootDevice);
}
// Try opening and closing the configuration file here
// to prevent a crash dump later on - giantpune
char GXGlobal_cfg[26];
sprintf(GXGlobal_cfg, "%s/config/GXGlobal.cfg", bootDevice);
FILE *fp = fopen(GXGlobal_cfg, "r");
if (fp)
{
fclose(fp);
}
gettextCleanUp();
printf("\n\tLoading configuration...");
CFG_Load();
printf("done");
// gprintf("\n\tbootDevice = %s",bootDevice);
/* Load Custom IOS */
if ((Settings.cios == ios222 && IOS_GetVersion() != 222) ||
(Settings.cios == ios223 && IOS_GetVersion() != 223))
{
printf("\n\tReloading IOS to config setting (%d)...", ios222 ? 222 : 223);
SDCard_deInit(); // unmount SD for reloading IOS
USBDevice_deInit(); // unmount USB for reloading IOS
USBStorage_Deinit();
ret = IOS_ReloadIOSsafe(ios222 ? 222 : 223);
printf("%d", ret);
SDCard_Init();
load_ehc_module();
if (ret < 0)
{
SDCard_deInit();
Settings.cios = ios249;
ret = IOS_ReloadIOSsafe(249);
// now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card
SDCard_Init();
}
USBDevice_Init(); // and mount USB:/
WBFS_Init(WBFS_DEVICE_USB);
} else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) ||
(Settings.cios == ios250 && IOS_GetVersion() != 250))
{
printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250);
SDCard_deInit(); // unmount SD for reloading IOS
USBDevice_deInit(); // unmount USB for reloading IOS
USBStorage_Deinit();
ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250);
printf("%d", ret);
if (ret < 0)
{
Settings.cios = ios222;
ret = IOS_ReloadIOSsafe(222);
SDCard_Init();
load_ehc_module();
}
else SDCard_Init(); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card
USBDevice_Init(); // and mount USB:/
WBFS_Init(WBFS_DEVICE_USB);
}
// Partition_GetList(&partitions);
if (ret < 0)
{
printf("\nERROR: cIOS could not be loaded!");
sleep(5);
exit(0);
//SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
//gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());//don't need gprintf if sending console shit to gecko, too
LoadAppCIOS();
printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());
// printf("Sleeping for 5 seconds\n");
// sleep(5);
//if a ID was passed via args copy it and try to boot it after the partition is mounted
//its not really a headless mode. more like hairless.
if (argc > 1 && argv[1])
{
if (strlen(argv[1]) == 6)
strncpy(headlessID, argv[1], sizeof(headlessID));
LoadHeadlessID(argv[1]);
}
//! Init the rest of the System
Sys_Init();
Wpad_Init();
if(!startupproblem)
InitVideo();
InitAudio(); // Initialize audio
@ -498,6 +205,7 @@ main(int argc, char *argv[])
gprintf("\n\tEnd of Main()");
InitGUIThreads();
MainMenu(MENU_CHECK);
MainMenu(MENU_DISCLIST);
return 0;
}

View File

@ -21,7 +21,9 @@
#include "settings/cfg.h"
#include "themes/Theme_Downloader.h"
#include "usbloader/disc.h"
#include "usbloader/wdvd.h"
#include "usbloader/getentries.h"
#include "usbloader/usbstorage.h"
#include "wad/title.h"
#include "xml/xml.h"
#include "audio.h"
@ -44,7 +46,7 @@ GuiSound *btnClick2 = NULL;
struct discHdr *dvdheader = NULL;
int currentMenu;
u8 mountMethod=0;
u8 mountMethod=3;
char game_partition[6];
int load_from_fs;
@ -65,8 +67,6 @@ static int ExitRequested = 0;
/*** Extern variables ***/
extern struct discHdr * gameList;
extern FreeTypeGX *fontClock;
extern u8 shutdown;
extern u8 reset;
extern s32 gameSelected, gameStart;
extern u8 boothomebrew;
extern u8 dbvideo;
@ -79,7 +79,8 @@ extern u8 dbvideo;
* after finishing the removal/insertion of new elements, and after initial
* GUI setup.
***************************************************************************/
void ResumeGui() {
void ResumeGui()
{
guiHalt = false;
LWP_ResumeThread (guithread);
}
@ -92,8 +93,11 @@ void ResumeGui() {
* This eliminates the possibility that the GUI is in the middle of accessing
* an element that is being changed.
***************************************************************************/
void HaltGui() {
if (guiHalt)return;
void HaltGui()
{
if (guiHalt)
return;
guiHalt = true;
// wait for thread to finish
@ -182,13 +186,16 @@ void InitGUIThreads() {
LWP_CreateThread(&guithread, UpdateGUI, NULL, NULL, 0, LWP_PRIO_HIGHEST);
InitProgressThread();
InitNetworkThread();
InitCheckThread();
if (Settings.autonetwork)
ResumeNetworkThread();
}
void ExitGUIThreads() {
void ExitGUIThreads()
{
ExitRequested = 1;
ExitCheckThread();
LWP_JoinThread(guithread, NULL);
guithread = LWP_THREAD_NULL;
}
@ -253,9 +260,6 @@ int MainMenu(int menu) {
currentMenu = menu;
char imgPath[100];
//if (strcmp(headlessID,"")!=0)HaltGui();
//WindowPrompt("Can you see me now",0,"ok");
snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path);
pointer[0] = new GuiImageData(imgPath, player1_point_png);
snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path);
@ -277,7 +281,6 @@ int MainMenu(int menu) {
bgImg = new GuiImage(background);
mainWindow->Append(bgImg);
if (strcmp(headlessID,"")==0)
ResumeGui();
bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, Settings.volume);
@ -291,11 +294,8 @@ int MainMenu(int menu) {
while (currentMenu != MENU_EXIT) {
bgMusic->SetVolume(Settings.volume);
switch (currentMenu) {
case MENU_CHECK:
currentMenu = MenuCheck();
break;
switch (currentMenu)
{
case MENU_FORMAT:
currentMenu = MenuFormat();
break;
@ -315,19 +315,16 @@ int MainMenu(int menu) {
currentMenu = MenuDiscList();
break;
default: // unrecognized menu
currentMenu = MenuCheck();
currentMenu = MenuDiscList();
break;
}
}
// MemInfoPrompt();
gprintf("\nExiting main GUI. mountMethod = %d",mountMethod);
CloseXMLDatabase();
NewTitles::DestroyInstance();
if (strcmp(headlessID,"")!=0)//the GUIthread was never started, so it cant be ended and joined properly if headless mode was used. so we resume it and close it.
ResumeGui();
ExitGUIThreads();
bgMusic->Stop();
@ -347,11 +344,13 @@ int MainMenu(int menu) {
StopGX();
gettextCleanUp();
if(dbvideo)
{
InitVideodebug ();
printf("\n\n\n\n\n");
menuBootgame("");
return 0;
}
void menuBootgame(const char *headless)
{
if (mountMethod==3)
{
struct discHdr *header = &gameList[gameSelected];
@ -382,22 +381,22 @@ int MainMenu(int menu) {
gprintf("\n\tSettings.partition:%d",Settings.partition);
struct discHdr *header = NULL;
//if the GUI was "skipped" to boot a game from main(argv[1])
if (strcmp(headlessID,"")!=0)
if (strcmp(headless,"")!=0)
{
gprintf("\n\tHeadless mode (%s)",headlessID);
gprintf("\n\tHeadless mode (%s)",headless);
__Menu_GetEntries(1);
if (!gameCnt)
{
gprintf(" ERROR : !gameCnt");
exit(0);
}
//gprintf("\n\tgameCnt:%d",gameCnt);
gprintf("\n\tgameCnt:%d",gameCnt);
for(u32 i=0;i<gameCnt;i++)
{
header = &gameList[i];
char tmp[8];
sprintf(tmp,"%c%c%c%c%c%c",header->id[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5]);
if (strcmp(tmp,headlessID)==0)
if (strcmp(tmp,headless)==0)
{
gameSelected = i;
gprintf(" found (%d)",i);
@ -470,18 +469,19 @@ int MainMenu(int menu) {
}
// When the selected ios is 249, and you're loading from FAT, reset ios to 222
if (load_from_fs != PART_FS_WBFS && ios2 == 249) {
if (load_from_fs != PART_FS_WBFS && ios2 == 249)
ios2 = 222;
}
bool onlinefix = ShutdownWC24();
ShutdownWC24();
// You cannot reload ios when loading from fat
if (IOS_GetVersion() != ios2 || onlinefix) {
if (IOS_GetVersion() != ios2)
{
ret = Sys_ChangeIos(ios2);
if (ret < 0) {
if (ret < 0)
Sys_ChangeIos(249);
}
}
if (!mountMethod)
{
gprintf("\nLoading fragment list...");
@ -498,14 +498,18 @@ int MainMenu(int menu) {
}
else {
gprintf("\n\tUSB not set, loading DVD");
Disc_SetUSB(NULL);
ret = WDVD_Close();
ret = Disc_Init();
}
ret = Disc_Open();
gprintf("\n\tDisc_Open():%d",ret);
if (ret < 0) Sys_BackToLoader();
if (ret < 0 && !mountMethod) Sys_BackToLoader();
if (gameList){
if (gameList)
free(gameList);
}
if(dvdheader)
delete dvdheader;
@ -513,12 +517,12 @@ int MainMenu(int menu) {
ret = do_bca_code(header->id);
gprintf("%d\n", ret);
if (reloadblock == on && Sys_IsHermes()) {
if (reloadblock == on && Sys_IsHermes())
{
patch_cios_data();
if (load_from_fs == PART_FS_WBFS) {
if (load_from_fs == PART_FS_WBFS)
mload_close();
}
}
u8 errorfixer002 = 0;
switch (fix002) {
@ -653,5 +657,4 @@ int MainMenu(int menu) {
printf("Returning entry point: 0x%0x\n", ret);
}
return 0;
}

View File

@ -15,8 +15,11 @@
void InitGUIThreads(void);
void ExitGUIThreads(void);
void ResumeGui();
void HaltGui();
void menuBootgame(const char *headless);
int MainMenu (int menuitem);
int MainMenu (int menu);
enum {
MENU_EXIT = -1,

View File

@ -0,0 +1,202 @@
#include <dirent.h>
#include <unistd.h>
#include "gecko.h"
#include "menus.h"
#include "wpad.h"
#include "fatmounter.h"
#include "usbloader/getentries.h"
#include "usbloader/wbfs.h"
extern int load_from_fs;
extern char game_partition[6];
static lwp_t checkthread = LWP_THREAD_NULL;
static bool checkHalt = false;
static bool ExitRequested = false;
static u8 sdState =0;
u8 hddState = 0;
u8 checkthreadState = 0;
extern u8 shutdown;
extern u8 reset;
void ResumeCheck()
{
checkHalt = false;
LWP_ResumeThread(checkthread);
}
void HaltCheck()
{
if(checkHalt)
return;
checkHalt = true;
while (!LWP_ThreadIsSuspended(checkthread))
usleep(50);
}
int CheckPartition()
{
s32 ret2 = -1;
memset(game_partition, 0, 6);
load_from_fs = -1;
extern PartList partitions;
// Added for slow HDD
for (int runs = 0; runs < 10; runs++)
{
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0)
continue;
if (Settings.partition != -1 && partitions.num > Settings.partition)
{
PartInfo pinfo = partitions.pinfo[Settings.partition];
if (WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size, (char *) &game_partition) == 0)
{
ret2 = 0;
load_from_fs = pinfo.part_fs;
break;
}
}
if (partitions.wbfs_n != 0)
{
ret2 = WBFS_Open();
for (int p = 0; p < partitions.num; p++)
{
if (partitions.pinfo[p].fs_type == FS_TYPE_WBFS)
{
Settings.partition = p;
load_from_fs = PART_FS_WBFS;
break;
}
}
}
else if (Sys_IsHermes() && (partitions.fat_n != 0 || partitions.ntfs_n != 0))
{
// Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one)
u32 count;
for (int i = 0; i < partitions.num; i++)
{
if (partitions.pinfo[i].fs_type == FS_TYPE_FAT32 || partitions.pinfo[i].fs_type == FS_TYPE_NTFS)
{
if (!WBFS_OpenPart(partitions.pinfo[i].part_fs, partitions.pinfo[i].index, partitions.pentry[i].sector, partitions.pentry[i].size, (char *) &game_partition))
{
// Get the game count...
WBFS_GetCount(&count);
if (count > 0)
{
load_from_fs = partitions.pinfo[i].part_fs;
Settings.partition = i;
break;
}
else
{
WBFS_Close();
}
}
}
}
}
if ((ret2 >= 0 || load_from_fs != PART_FS_WBFS) && isInserted(bootDevice))
{
cfg_save_global();
break;
}
}
if (ret2 < 0 && load_from_fs != PART_FS_WBFS)
return ret2;
ret2 = Disc_Init();
if (ret2 < 0)
return ret2;
// open database if needed, load titles if needed
if(isInserted(bootDevice))
OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true);
hddState = 1;
return hddState;
}
int CheckHDD()
{
USBDevice_deInit();
USBDevice_Init();
int wbfsinit = WBFS_Init(WBFS_DEVICE_USB);
if (wbfsinit >= 0)
wbfsinit = CheckPartition();
return wbfsinit;
}
static void * CheckDevices (void *arg)
{
sdState = isInserted(bootDevice);
while (!ExitRequested)
{
usleep(100);
if (checkHalt && !ExitRequested)
{
LWP_SuspendThread(checkthread);
continue;
}
if (shutdown == 1)
Sys_Shutdown();
else if (reset == 1)
Sys_Reboot();
if (!hddState)
{
if(CheckHDD() >= 0)
{
checkthreadState = 1;
}
}
//this really doesnt work right. it seems that isInserted() isn't what it should be.
int sdNow = isInserted(bootDevice);
if (sdState != sdNow)
{
sdState = sdNow;
checkthreadState = 2;
WindowPrompt("2",0,"OK");
}
u32 buttons = ButtonsPressed();
if((buttons & WPAD_NUNCHUK_BUTTON_Z) || (buttons & WPAD_CLASSIC_BUTTON_ZL) ||
(buttons & PAD_TRIGGER_Z))
{
gprintf("\n\tscreenShotBtn clicked");
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
}
return NULL;
}
void InitCheckThread()
{
LWP_CreateThread(&checkthread, CheckDevices, NULL, NULL, 0, 0);
}
void ExitCheckThread()
{
ExitRequested = true;
LWP_ResumeThread(checkthread);
LWP_JoinThread(checkthread, NULL);
checkthread = LWP_THREAD_NULL;
}

View File

@ -1,164 +0,0 @@
#include <dirent.h>
#include <unistd.h>
#include "menus.h"
#include "wpad.h"
#include "fatmounter.h"
#include "usbloader/getentries.h"
#include "usbloader/wbfs.h"
extern int load_from_fs;
extern char game_partition[6];
extern char headlessID[8];
/****************************************************************************
* MenuCheck
***************************************************************************/
int MenuCheck() {
gprintf("\nMenuCheck()");
int menu = MENU_NONE;
int i = 0;
int choice;
s32 ret2, wbfsinit;
OptionList options;
options.length = i;
VIDEO_WaitVSync ();
wbfsinit = WBFS_Init(WBFS_DEVICE_USB);
if (wbfsinit < 0) {
ret2 = WindowPrompt(tr("No USB Device found."), tr("Do you want to retry for 30 secs?"), "cIOS249", "cIOS222", tr("Back to Wii Menu"));
SDCard_deInit();
USBDevice_deInit();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
if (ret2 == 1) {
Settings.cios = ios249;
} else if (ret2 == 2) {
Settings.cios = ios222;
} else {
Sys_LoadMenu();
}
ret2 = DiscWait(tr("No USB Device"), tr("Waiting for USB Device"), 0, 0, 1);
//reinitialize SD and USB
Wpad_Init();
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
if (ret2 < 0) {
WindowPrompt (tr("Error !"),tr("USB Device not found"), tr("OK"));
Sys_LoadMenu();
}
}
ret2 = -1;
memset(game_partition, 0, 6);
load_from_fs = -1;
extern PartList partitions;
// Added for slow HDD
for (int runs = 0; runs < 10; runs++) {
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0) {
sleep(1);
continue;
}
if (Settings.partition != -1 && partitions.num > Settings.partition) {
PartInfo pinfo = partitions.pinfo[Settings.partition];
if (WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector, partitions.pentry[Settings.partition].size, (char *) &game_partition) == 0)
{
ret2 = 0;
load_from_fs = pinfo.part_fs;
break;
}
}
if (partitions.wbfs_n != 0) {
ret2 = WBFS_Open();
for (int p = 0; p < partitions.num; p++) {
if (partitions.pinfo[p].fs_type == FS_TYPE_WBFS) {
Settings.partition = p;
load_from_fs = PART_FS_WBFS;
break;
}
}
} else if (Sys_IsHermes() && (partitions.fat_n != 0 || partitions.ntfs_n != 0)) {
// Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one)
u32 count;
for (int i = 0; i < partitions.num; i++) {
if (partitions.pinfo[i].fs_type == FS_TYPE_FAT32 || partitions.pinfo[i].fs_type == FS_TYPE_NTFS) {
if (!WBFS_OpenPart(partitions.pinfo[i].part_fs, partitions.pinfo[i].index, partitions.pentry[i].sector, partitions.pentry[i].size, (char *) &game_partition)) {
// Get the game count...
WBFS_GetCount(&count);
if (count > 0) {
load_from_fs = partitions.pinfo[i].part_fs;
Settings.partition = i;
break;
} else {
WBFS_Close();
}
}
}
}
}
if ((ret2 >= 0 || load_from_fs != PART_FS_WBFS) && isInserted(bootDevice)) {
cfg_save_global();
break;
}
sleep(1);
}
if (ret2 < 0 && load_from_fs != PART_FS_WBFS) {
choice = WindowPrompt(tr("No WBFS or FAT/NTFS partition found"),tr("You need to select or format a partition"), tr("Select"), tr("Format"), tr("Return"));
if (choice == 0) {
Sys_LoadMenu();
} else {
load_from_fs = choice == 1 ? PART_FS_FAT : PART_FS_WBFS;
menu = MENU_FORMAT;
}
}
ret2 = Disc_Init();
if (ret2 < 0) {
WindowPrompt (tr("Error !"),tr("Could not initialize DIP module!"),tr("OK"));
Sys_LoadMenu();
}
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
if (wbfsinit < 0) {
sleep(1);
}
// open database if needed, load titles if needed
if(isInserted(bootDevice))OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride==1?true:false, true);
// titles.txt loaded after database to override database titles with custom titles
//snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path);
//cfg_parsefile(pathname, &title_set);
//Spieleliste laden
__Menu_GetEntries(0);
if (strcmp(headlessID,"")!=0)
menu = MENU_EXIT;
if (menu == MENU_NONE)
menu = MENU_DISCLIST;
//for HDDs with issues
if (wbfsinit < 0) {
sleep(1);
USBDevice_Init();
SDCard_Init();
}
return menu;
}

View File

@ -42,6 +42,7 @@ void DiscListWinUpdateCallback(void * e);
void rockout(int f = 0);
static u32 startat = 0;
//static u8 ignoreNewDisc =0;//ignore the new drive when it is detected
/****************************************************************************
* MenuDiscList
@ -49,7 +50,11 @@ static u32 startat = 0;
int MenuDiscList() {
gprintf("\nMenuDiscList()");
//TakeScreenshot("SD:/screenshot1.png");
if(checkthreadState == 1)
{
mountMethod = 0;
checkthreadState = 0;
}
__Menu_GetEntries();
int offset = MIN(startat,gameCnt-1);
startat = offset;
@ -188,12 +193,8 @@ int MenuDiscList() {
trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0);
GuiTrigger trig1;
trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
GuiTrigger trigN;
trigN.SetButtonOnlyTrigger(0, 0, 0);
char spaceinfo[30];
if (load_from_fs != PART_FS_WBFS) {
@ -219,7 +220,7 @@ int MenuDiscList() {
gamecntBtn.SetPosition(THEME.gamecount_x,THEME.gamecount_y);
gamecntBtn.SetLabel(&gamecntTxt);
gamecntBtn.SetEffectGrow();
gamecntBtn.SetTrigger(&trigA);
if (mountMethod!=3)gamecntBtn.SetTrigger(&trigA);
GuiTooltip installBtnTT(tr("Install a game"));
if (Settings.wsprompt == yes)
@ -230,7 +231,7 @@ int MenuDiscList() {
installBtnImg.SetWidescreen(CFG.widescreen);
installBtnImgOver.SetWidescreen(CFG.widescreen);
GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, &trigA, &btnSoundOver, btnClick2, 1, &installBtnTT,24,-30, 0,5);
GuiButton installBtn(&installBtnImg, &installBtnImgOver, ALIGN_LEFT, ALIGN_TOP, THEME.install_x, THEME.install_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2, 1, &installBtnTT,24,-30, 0,5);
GuiTooltip settingsBtnTT(tr("Settings"));
@ -294,7 +295,7 @@ int MenuDiscList() {
GuiImage favoriteBtnImg_g(&imgfavIcon_gray);
if(favoriteBtnImg_g.GetImage() == NULL) { favoriteBtnImg_g = favoriteBtnImg; favoriteBtnImg_g.SetGrayscale();}
favoriteBtnImg_g.SetWidescreen(CFG.widescreen);
GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_favorite_x, THEME.gamelist_favorite_y, &trigA, &btnSoundOver, btnClick2,1, &favoriteBtnTT, -15, 52, 0, 3);
GuiButton favoriteBtn(&favoriteBtnImg_g,&favoriteBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_favorite_x, THEME.gamelist_favorite_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &favoriteBtnTT, -15, 52, 0, 3);
favoriteBtn.SetAlpha(180);
GuiTooltip searchBtnTT(tr("Set Search-Filter"));
@ -307,7 +308,7 @@ int MenuDiscList() {
GuiImage searchBtnImg_g(&imgsearchIcon_gray);
if(searchBtnImg_g.GetImage() == NULL) { searchBtnImg_g = searchBtnImg; searchBtnImg_g.SetGrayscale();}
searchBtnImg_g.SetWidescreen(CFG.widescreen);
GuiButton searchBtn(&searchBtnImg_g,&searchBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_search_x, THEME.gamelist_search_y, &trigA, &btnSoundOver, btnClick2,1, &searchBtnTT, -15, 52, 0, 3);
GuiButton searchBtn(&searchBtnImg_g,&searchBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_search_x, THEME.gamelist_search_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &searchBtnTT, -15, 52, 0, 3);
searchBtn.SetAlpha(180);
GuiTooltip abcBtnTT(Settings.fave ? tr("Sort by rank") : tr("Sort alphabetically"));
@ -346,7 +347,7 @@ int MenuDiscList() {
GuiImage listBtnImg_g(&imgarrangeList_gray);
if(listBtnImg_g.GetImage() == NULL) { listBtnImg_g = listBtnImg; listBtnImg_g.SetGrayscale();}
listBtnImg_g.SetWidescreen(CFG.widescreen);
GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_list_x, THEME.gamelist_list_y, &trigA, &btnSoundOver, btnClick2,1, &listBtnTT, 15, 52, 1, 3);
GuiButton listBtn(&listBtnImg_g,&listBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_list_x, THEME.gamelist_list_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &listBtnTT, 15, 52, 1, 3);
listBtn.SetAlpha(180);
GuiTooltip gridBtnTT(tr("Display as a grid"));
@ -359,7 +360,7 @@ int MenuDiscList() {
GuiImage gridBtnImg_g(&imgarrangeGrid_gray);
if(gridBtnImg_g.GetImage() == NULL) { gridBtnImg_g = gridBtnImg; gridBtnImg_g.SetGrayscale();}
gridBtnImg_g.SetWidescreen(CFG.widescreen);
GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_grid_x, THEME.gamelist_grid_y, &trigA, &btnSoundOver, btnClick2,1, &gridBtnTT, 15, 52, 1, 3);
GuiButton gridBtn(&gridBtnImg_g,&gridBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_grid_x, THEME.gamelist_grid_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &gridBtnTT, 15, 52, 1, 3);
gridBtn.SetAlpha(180);
GuiTooltip carouselBtnTT(tr("Display as a carousel"));
@ -372,7 +373,7 @@ int MenuDiscList() {
GuiImage carouselBtnImg_g(&imgarrangeCarousel_gray);
if(carouselBtnImg_g.GetImage() == NULL) { carouselBtnImg_g = carouselBtnImg; carouselBtnImg_g.SetGrayscale();}
carouselBtnImg_g.SetWidescreen(CFG.widescreen);
GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_carousel_x, THEME.gamelist_carousel_y, &trigA, &btnSoundOver, btnClick2,1, &carouselBtnTT, 15, 52, 1, 3);
GuiButton carouselBtn(&carouselBtnImg_g,&carouselBtnImg_g, ALIGN_LEFT, ALIGN_TOP, THEME.gamelist_carousel_x, THEME.gamelist_carousel_y, mountMethod!=3?&trigA:&trigN, &btnSoundOver, btnClick2,1, &carouselBtnTT, 15, 52, 1, 3);
carouselBtn.SetAlpha(180);
bool canUnlock = (Settings.parentalcontrol == 0 && Settings.parental.enabled == 1);
@ -458,7 +459,7 @@ int MenuDiscList() {
countBtn.SetImageOver(&countBtnImg);
countBtn.SetAlpha(255);
}
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list || mountMethod == 3) {
listBtn.SetImage(&listBtnImg);
listBtn.SetImageOver(&listBtnImg);
listBtn.SetAlpha(255);
@ -472,7 +473,7 @@ int MenuDiscList() {
carouselBtn.SetAlpha(255);
}
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
favoriteBtn.SetPosition(THEME.gamelist_favorite_x, THEME.gamelist_favorite_y);
searchBtn.SetPosition(THEME.gamelist_search_x, THEME.gamelist_search_y);
abcBtn.SetPosition(THEME.gamelist_abc_x, THEME.gamelist_abc_y);
@ -541,7 +542,7 @@ int MenuDiscList() {
GuiGameBrowser * gameBrowser = NULL;
GuiGameGrid * gameGrid = NULL;
GuiGameCarousel * gameCarousel = NULL;
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser = new GuiGameBrowser(THEME.gamelist_w, THEME.gamelist_h, gameList, gameCnt, CFG.theme_path, bg_options_png, startat, offset);
gameBrowser->SetPosition(THEME.gamelist_x, THEME.gamelist_y);
gameBrowser->SetAlignment(ALIGN_LEFT, ALIGN_CENTRE);
@ -583,7 +584,6 @@ int MenuDiscList() {
w.Append(&settingsBtn);
w.Append(&DownloadBtn);
w.Append(&idBtn);
w.Append(&screenShotBtn);
// Begin Toolbar
@ -618,13 +618,13 @@ int MenuDiscList() {
w.Append(&clockTime);
}
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
mainWindow->Append(gameBrowser);
}
if (Settings.gameDisplay==grid) {
else if (Settings.gameDisplay==grid) {
mainWindow->Append(gameGrid);
}
if (Settings.gameDisplay==carousel) {
else if (Settings.gameDisplay==carousel) {
mainWindow->Append(gameCarousel);
}
mainWindow->Append(&w);
@ -702,12 +702,12 @@ int MenuDiscList() {
if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}}
// respond to button presses
if (shutdown == 1) {
/* if (shutdown == 1) {
gprintf("\n\tshutdown");
Sys_Shutdown();
}
if (reset == 1)
Sys_Reboot();
Sys_Reboot();*/
if (updateavailable == true) {
gprintf("\n\tUpdate Available");
@ -734,7 +734,7 @@ int MenuDiscList() {
Sys_ShutdownToStandby();
} else {
poweroffBtn.ResetState();
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -758,14 +758,6 @@ int MenuDiscList() {
menu = MENU_DISCLIST;
break;
}
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
} else if (homeBtn.GetState() == STATE_CLICKED) {
gprintf("\n\thomeBtn clicked");
bgMusic->Pause();
@ -778,7 +770,7 @@ int MenuDiscList() {
Sys_BackToLoader();
} else {
homeBtn.ResetState();
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -792,7 +784,7 @@ int MenuDiscList() {
dataed++;
wiiBtn.ResetState();
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -807,7 +799,7 @@ int MenuDiscList() {
break;
} else {
installBtn.ResetState();
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -815,8 +807,25 @@ int MenuDiscList() {
gameCarousel->SetFocus(1);
}
}
}else if ((covert & 0x2)&&(covert!=covertOld)) {
gprintf("\n\tNew Disc Detected");
}
else if (dvdBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tdvdBtn Clicked");
mountMethodOLD = (mountMethod==3?mountMethod:0);
int ass =DiscMount(dvdheader);
if (ass>0)mountMethod=ass;
gprintf("\n\tmountMethod:%d",mountMethod);
//dvdBtn.ResetState();
covertOld =2;
rockout();
//break;
}
else if ((covert & 0x2)&&(covert!=covertOld)&& mountMethod!=1 && mountMethod!=2) {
//gprintf("\n\tNew Disc Detected mountMethod:%d covert:%d old:%d",mountMethod,covert,covertOld);
if(!mountMethod)
choice = WindowPrompt(tr("New Disc Detected"),0,tr("Install"),tr("Mount DVD drive"),tr("Cancel"));
if (choice == 1) {
if (load_from_fs == PART_FS_NTFS) {
@ -826,11 +835,11 @@ int MenuDiscList() {
break;
}
}
else if (choice ==2)
else if (choice ==2 || mountMethod==3)
{
dvdBtn.SetState(STATE_CLICKED);
}else {
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -838,13 +847,14 @@ int MenuDiscList() {
gameCarousel->SetFocus(1);
}
}
}
else if (sdcardBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tsdCardBtn Clicked");
SDCard_deInit();
SDCard_Init();
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
startat = gameBrowser->GetSelectedOption();
offset = gameBrowser->GetOffset();
} else if (Settings.gameDisplay==grid) {
@ -895,9 +905,9 @@ int MenuDiscList() {
} else {
WindowPrompt(tr("No SD-Card inserted!"), tr("Insert an SD-Card to download images."), tr("OK"));
}
menu = MENU_DISCLIST;
if (choice)menu = MENU_DISCLIST;
DownloadBtn.ResetState();
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -908,7 +918,7 @@ int MenuDiscList() {
else if (settingsBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tsettingsBtn Clicked");
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list|| mountMethod == 3) {
startat = gameBrowser->GetSelectedOption();
offset = gameBrowser->GetOffset();
} else if (Settings.gameDisplay==grid) {
@ -935,7 +945,7 @@ int MenuDiscList() {
}
else if (searchBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
else if (searchBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tsearchBtn Clicked");
show_searchwindow=!show_searchwindow;
@ -1159,17 +1169,8 @@ int MenuDiscList() {
}
}
}
else if (dvdBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tdvdBtn Clicked");
mountMethodOLD = (mountMethod==3?mountMethod:0);
mountMethod=DiscMount(dvdheader);
dvdBtn.ResetState();
rockout();
//break;
}
if (Settings.gameDisplay==grid) {
if (Settings.gameDisplay==grid && mountMethod != 3) {
int selectimg;
DownloadBtn.SetSize(0,0);
selectimg = gameGrid->GetSelectedOption();
@ -1177,14 +1178,14 @@ int MenuDiscList() {
selectImg1=selectimg;
}
if (Settings.gameDisplay==carousel) {
else if (Settings.gameDisplay==carousel && mountMethod != 3) {
int selectimg;
DownloadBtn.SetSize(0,0);
selectimg = gameCarousel->GetSelectedOption();
gameSelected = gameCarousel->GetClickedOption();
selectImg1=selectimg;
}
if (Settings.gameDisplay==list) {
else if (Settings.gameDisplay==list || mountMethod == 3) {
//Get selected game under cursor
int selectimg;
DownloadBtn.SetSize(160,224);
@ -1451,7 +1452,7 @@ int MenuDiscList() {
} else if (choice == 2) {
wiilight(0);
HaltGui();
if (Settings.gameDisplay==list) mainWindow->Remove(gameBrowser);
if (Settings.gameDisplay==list || mountMethod == 3) mainWindow->Remove(gameBrowser);
else if (Settings.gameDisplay==grid) mainWindow->Remove(gameGrid);
else if (Settings.gameDisplay==carousel) mainWindow->Remove(gameCarousel);
mainWindow->Remove(&w);
@ -1464,7 +1465,7 @@ int MenuDiscList() {
//menu = MENU_DISCLIST; // refresh titles (needed if the language setting has changed)
*/
HaltGui();
if (Settings.gameDisplay==list) mainWindow->Append(gameBrowser);
if (Settings.gameDisplay==list || mountMethod == 3) mainWindow->Append(gameBrowser);
else if (Settings.gameDisplay==grid) mainWindow->Append(gameGrid);
else if (Settings.gameDisplay==carousel) mainWindow->Append(gameCarousel);
mainWindow->Append(&w);
@ -1495,7 +1496,7 @@ int MenuDiscList() {
} else if (choice == 0) {
rockout(2);
if (mountMethod==1||mountMethod==2)mountMethod = mountMethodOLD;
if (Settings.gameDisplay==list) {
if (Settings.gameDisplay==list || mountMethod == 3) {
gameBrowser->SetFocus(1);
} else if (Settings.gameDisplay==grid) {
gameGrid->SetFocus(1);
@ -1527,11 +1528,30 @@ int MenuDiscList() {
}
if (screensaverIsOn==1)check=0;
}
if (dvdBtn.GetState() != STATE_CLICKED)
covertOld=covert;
else
dvdBtn.ResetState();
//respond to the checkthread and unpause it
switch(checkthreadState)
{
case 1:
mountMethod = 0;
menu = MENU_DISCLIST;
checkthreadState = 0;
gprintf("\ncase 1");
break;
case 2:
sdcardBtn.SetState(STATE_CLICKED);
checkthreadState = 0;
gprintf("\ncase 2");
break;
}
}
// set alt dol default
if (menu == MENU_EXIT && altdoldefault) {
if (menu == MENU_EXIT && altdoldefault && mountMethod!=3) {
struct discHdr *header = (mountMethod==1||mountMethod==2?dvdheader:&gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
// use default only if no alt dol was selected manually

View File

@ -1,5 +1,6 @@
#include <unistd.h>
#include "menus.h"
#include "menus.h"
#include "fatmounter.h"
#include "usbloader/usbstorage.h"
@ -69,6 +70,11 @@ int MenuFormat() {
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0);
GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiButton backBtn(0,0);
backBtn.SetTrigger(&trigB);
GuiImage poweroffBtnImg(&btnpwroff);
GuiImage poweroffBtnImgOver(&btnpwroffOver);
@ -89,6 +95,7 @@ int MenuFormat() {
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&poweroffBtn);
w.Append(&backBtn);
w.Append(&exitBtn);
mainWindow->Append(&w);
@ -110,7 +117,7 @@ int MenuFormat() {
WBFS_OpenPart(partitions.pinfo[ret].part_fs, partitions.pinfo[ret].index, entry->sector,
entry->size, (char *) &game_partition);
load_from_fs = partitions.pinfo[ret].part_fs;
menu = MENU_DISCLIST;
menu = MENU_SETTINGS;
Settings.partition = ret;
if(isInserted(bootDevice))cfg_save_global();
@ -131,7 +138,7 @@ int MenuFormat() {
WindowPrompt(tr("ERROR"), tr("Failed to open partition"), tr("OK"));
Sys_LoadMenu();
}
menu = MENU_DISCLIST;
menu = MENU_SETTINGS;
}
}
}
@ -154,10 +161,10 @@ int MenuFormat() {
}
}
if (shutdown == 1)
/* if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
Sys_Reboot();*/
if (poweroffBtn.GetState() == STATE_CLICKED) {
choice = WindowPrompt (tr("Shutdown System"),tr("Are you sure?"),tr("Yes"),tr("No"));
@ -171,6 +178,10 @@ int MenuFormat() {
Sys_LoadMenu();
}
}
else if (backBtn.GetState() == STATE_CLICKED) {
menu = MENU_SETTINGS;
break;
}
}

View File

@ -134,15 +134,6 @@ int MenuInstall() {
menu = MENU_DISCLIST;
break;
}
if (shutdown == 1) {
wiilight(0);
Sys_Shutdown();
}
if (reset == 1) {
wiilight(0);
Sys_Reboot();
}
}
//Turn off the WiiLight

View File

@ -1,6 +1,8 @@
#ifndef _MENUS_H
#define _MENUS_H
#include <unistd.h>
#include "libwiigui/gui.h"
#include "language/gettext.h"
#include "prompts/PromptWindows.h"
@ -9,16 +11,21 @@
#include "filelist.h"
#include "sys.h"
extern void ResumeGui();
extern void HaltGui();
extern GuiWindow * mainWindow;
extern GuiSound * bgMusic;
extern u8 shutdown;
extern u8 reset;
extern u8 checkthreadState;
extern u8 needToReloadGamelist;
extern u8 hddOK;
extern u8 mountMethod;
int MenuInstall();
int MenuDiscList();
int MenuFormat();
int MenuCheck();
extern void ResumeCheck();
extern void HaltCheck();
extern void InitCheckThread();
extern void ExitCheckThread();
#endif // _MENUS_H

View File

@ -10,6 +10,7 @@
#include "prompts/PromptWindows.h"
#include "filelist.h"
#include "menu.h"
#include "../menu/menus.h"
#include "usbloader/disc.h"
#include "usbloader/fstfile.h"
#include "usbloader/wdvd.h"
@ -21,14 +22,8 @@
#include "../gecko.h"
#include "../patches/dvd_broadway.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern u8 shutdown;
extern u8 reset;
extern u8 mountMethod;
/********************************************************************************
@ -204,11 +199,6 @@ int DiscBrowse(struct discHdr * header) {
while (!exit) {
VIDEO_WaitVSync();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
ret = optionBrowser3.GetClickedOption();
if (ret > 0) {
@ -501,7 +491,7 @@ void __dvd_readidcb(s32 result)
dvddone = result;
}
u8 DiscMount(discHdr *header) {
u8 DiscMount1(discHdr *header) {
gprintf("\nDiscMount() ");
int ret;
HaltGui();
@ -533,3 +523,53 @@ u8 DiscMount(discHdr *header) {
}
return (header->magic == 0x5D1C9EA3) ? 1 : 2; // Don't check gamecube magic (0xC2339F3D)
}
u8 DiscMount(discHdr *header) {
gprintf("\nDiscMount() ");
HaltGui();
GuiWindow w(screenwidth, screenheight);
mainWindow->Append(&w);
ResumeGui();
//HaltCheck();
int ret = Disc_SetUSB(NULL);
ret = WDVD_Close();
ret = Disc_Init();
ret = DiscWait(tr("Insert Disk"),tr("Waiting..."),tr("Cancel"),0,0);
if (ret < 0) {
WindowPrompt (tr("Error reading Disc"),0,tr("Back"));
goto OUT;
}
mainWindow->SetState(STATE_DISABLED);
//gprintf("..1");
ret = Disc_Open();
if (ret < 0) {
WindowPrompt (tr("Could not open Disc"),0,tr("Back"));
goto OUT;
}
//gprintf("..2");
Disc_ReadHeader(header);
//gprintf("..3");
ret = Disc_IsWii();
//gprintf("..4");
//ResumeCheck();
if (ret < 0) {
ret = 2;
}
ret = 1;
OUT:
HaltGui();
mainWindow->Remove(&w);
mainWindow->SetState(STATE_DEFAULT);
ResumeGui();
return ret;
}

View File

@ -40,10 +40,6 @@ static time_t start;
extern GuiWindow * mainWindow;
extern float gamesize;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/****************************************************************************
* GameInstallProgress

View File

@ -23,7 +23,6 @@
#include "fatmounter.h"
#include "listfiles.h"
#include "menu.h"
#include "menu.h"
#include "filelist.h"
#include "sys.h"
#include "wpad.h"
@ -53,15 +52,10 @@ extern u32 gameCnt;
extern s32 gameSelected, gameStart;
extern float gamesize;
extern struct discHdr * gameList;
extern u8 shutdown;
extern u8 reset;
extern u8 mountMethod;
extern struct discHdr *dvdheader;
extern char game_partition[6];
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
extern u8 shutdown;
/****************************************************************************
* OnScreenNumpad
@ -696,17 +690,9 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
}
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&titleTxt);
promptWindow.Append(&msgTxt);
promptWindow.Append(&screenShotBtn);
if (btn1Label)
promptWindow.Append(&btn1);
@ -726,12 +712,7 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
while (choice == -1) {
VIDEO_WaitVSync();
if (shutdown == 1) {
wiilight(0);
Sys_Shutdown();
}
if (reset == 1)
Sys_Reboot();
if (btn1.GetState() == STATE_CLICKED) {
choice = 1;
} else if (btn2.GetState() == STATE_CLICKED) {
@ -746,11 +727,6 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
choice = 3;
} else if (btn4.GetState() == STATE_CLICKED) {
choice = 0;
} else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
if (count>0)count--;
if (count==0) choice = 1;
@ -978,12 +954,9 @@ int WindowExitPrompt()
}
if (shutdown == 1) {
if (shutdown == 1)
wiilight(0);
Sys_Shutdown();
}
if (reset == 1)
Sys_Reboot();
if (btn1.GetState() == STATE_CLICKED) {
choice = 1;
btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
@ -1138,12 +1111,6 @@ int GameWindowPrompt() {
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
GuiTrigger trigMinus;
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
if (CFG.widescreen)
snprintf(imgPath, sizeof(imgPath), "%swdialogue_box_startgame.png", CFG.theme_path);
@ -1274,7 +1241,6 @@ int GameWindowPrompt() {
promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&nameBtn);
promptWindow.Append(&playcntTxt);
promptWindow.Append(&screenShotBtn);
promptWindow.Append(&btn2);
if (!mountMethod)//stuff we don't show if it is a DVD mounted
{
@ -1452,19 +1418,6 @@ int GameWindowPrompt() {
diskImg.SetSpin(btn1.GetState() == STATE_SELECTED);
diskImg2.SetSpin(btn1.GetState() == STATE_SELECTED);
if (shutdown == 1) { //for power button
promptWindow.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
mainWindow->SetState(STATE_DEFAULT);
while (promptWindow.GetEffect() > 0) usleep(50);
HaltGui();
mainWindow->Remove(&promptWindow);
ResumeGui();
wiilight(0);
Sys_Shutdown();
}
if (reset == 1) //for reset button
Sys_Reboot();
if(gameSound)
{
@ -1544,12 +1497,6 @@ int GameWindowPrompt() {
}
btnFavorite5.ResetState();
}
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
// this next part is long because nobody could agree on what the left/right buttons should do
else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)) {//next game
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
@ -3569,14 +3516,6 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
btn2.SetPosition(-40, 2);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
promptWindow.Append(&screenShotBtn);
promptWindow.Append(&dialogBoxImg);
if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg);
if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg);
@ -3603,23 +3542,15 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
while (choice == -1) {
VIDEO_WaitVSync();
if (shutdown == 1) {
if (shutdown == 1)
wiilight(0);
Sys_Shutdown();
}
if (reset == 1)
Sys_Reboot();
if (btn1.GetState() == STATE_CLICKED) {
choice = 1;
} else if (btn2.GetState() == STATE_CLICKED) {
choice = 0;
}
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) {
if (long_descriptionTxt.GetFirstLine()>1)
long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1);

View File

@ -20,6 +20,7 @@
#include "settings/cfg.h"
#include "sys.h"
#include "menu.h"
#include "../menu/menus.h"
#include "audio.h"
#include "wad/wad.h"
#include "xml/xml.h"
@ -37,14 +38,8 @@ u32 titleCnt;
extern struct discHdr * gameList;
extern u32 gameCnt;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern u8 shutdown;
extern u8 reset;
extern u32 infilesize;
extern wchar_t *gameFilter;
@ -295,16 +290,8 @@ int TitleBrowser(u32 type) {
wifiBtn.SetAlpha(80);
wifiBtn.SetTrigger(&trigA);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
HaltGui();
GuiWindow w(screenwidth, screenheight);
w.Append(&screenShotBtn);
w.Append(&settingsbackgroundbtn);
w.Append(&titleTxt);
w.Append(&cancelBtn);
@ -320,12 +307,7 @@ int TitleBrowser(u32 type) {
while (!exit) {
VIDEO_WaitVSync();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
else if (wifiBtn.GetState() == STATE_CLICKED) {
if (wifiBtn.GetState() == STATE_CLICKED) {
ResumeNetworkWait();
wifiBtn.ResetState();
@ -547,12 +529,6 @@ int TitleBrowser(u32 type) {
exit = true;
ret = -10;
}
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
}
CloseConnection();

View File

@ -20,6 +20,7 @@
#include <algorithm>
#include "menu.h"
#include "../menu/menus.h"
#include "listfiles.h"
#include "language/gettext.h"
@ -27,15 +28,10 @@
#include "libwiigui/gui.h"
#include "sys.h"
#include "filebrowser.h"
#include "../menu.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern u8 shutdown;
extern u8 reset;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
static int curDevice = -1;
static std::vector<BROWSERINFO> browsers;
@ -393,12 +389,6 @@ int BrowseDevice(char * Path, int Path_size, int Flags, FILTERCASCADE *Filter/*=
while (menu == MENU_NONE) {
VIDEO_WaitVSync();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
for (i=0; i<FILEBROWSERSIZE; i++) {
if (fileBrowser.fileList[i]->GetState() == STATE_CLICKED) {
fileBrowser.fileList[i]->ResetState();

View File

@ -19,22 +19,18 @@
#include "gameinfo.h"
#include "usbloader/getentries.h"
#include "../gecko.h"
#include "../menu.h"
#include "../menu/menus.h"
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern GuiSound * bgMusic;
extern u8 shutdown;
extern u8 reset;
extern struct gameXMLinfo gameinfo;
extern struct gameXMLinfo gameinfo_reset;
extern u32 gameCnt;
extern struct discHdr * gameList;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/****************************************************************************
* gameinfo
@ -781,13 +777,6 @@ int showGameInfo(char *ID) {
gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 100);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
gameinfoWindow.Append(&screenShotBtn);
HaltGui();
//mainWindow->SetState(STATE_DISABLED);
mainWindow->Append(&gameinfoWindow);
@ -799,13 +788,8 @@ int showGameInfo(char *ID) {
while (choice == -1) {
VIDEO_WaitVSync();
if (shutdown == 1) {
wiilight(0);
Sys_Shutdown();
} else if (reset == 1)
Sys_Reboot();
else if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)) {
if ((backBtn.GetState()==STATE_CLICKED)||(backBtn.GetState()==STATE_HELD)) {
backBtn.ResetState();
if (page==1) {
choice=1;
@ -816,13 +800,11 @@ int showGameInfo(char *ID) {
gameinfoWindow2.Remove(&nextBtn);
gameinfoWindow2.Remove(&backBtn);
gameinfoWindow2.Remove(&homeBtn);
gameinfoWindow2.Remove(&screenShotBtn);
gameinfoWindow2.SetVisible(false);
gameinfoWindow.SetVisible(true);
gameinfoWindow.Append(&backBtn);
gameinfoWindow.Append(&nextBtn);
gameinfoWindow.Append(&homeBtn);
gameinfoWindow.Append(&screenShotBtn);
mainWindow->Remove(&gameinfoWindow2);
ResumeGui();
page=1;
@ -835,14 +817,12 @@ int showGameInfo(char *ID) {
gameinfoWindow.Remove(&nextBtn);
gameinfoWindow.Remove(&backBtn);
gameinfoWindow.Remove(&homeBtn);
gameinfoWindow.Remove(&screenShotBtn);
gameinfoWindow.SetVisible(false);
gameinfoWindow2.SetVisible(true);
coverImg->SetPosition(15,30);
gameinfoWindow2.Append(&nextBtn);
gameinfoWindow2.Append(&backBtn);
gameinfoWindow2.Append(&homeBtn);
gameinfoWindow2.Append(&screenShotBtn);
mainWindow->Append(&gameinfoWindow2);
ResumeGui();
page=2;
@ -851,13 +831,11 @@ int showGameInfo(char *ID) {
gameinfoWindow2.Remove(&nextBtn);
gameinfoWindow2.Remove(&backBtn);
gameinfoWindow2.Remove(&homeBtn);
gameinfoWindow2.Remove(&screenShotBtn);
gameinfoWindow2.SetVisible(false);
gameinfoWindow.SetVisible(true);
gameinfoWindow.Append(&backBtn);
gameinfoWindow.Append(&nextBtn);
gameinfoWindow.Append(&homeBtn);
gameinfoWindow.Append(&screenShotBtn);
mainWindow->Remove(&gameinfoWindow2);
ResumeGui();
page=1;
@ -916,12 +894,6 @@ int showGameInfo(char *ID) {
}
urlBtn.ResetState();
}
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
}
if (page==1) {
gameinfoWindow.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_OUT, 100);

View File

@ -13,6 +13,7 @@
#include "cheats/cheatmenu.h"
#include "fatmounter.h"
#include "menu.h"
#include "menu/menus.h"
#include "filelist.h"
#include "listfiles.h"
#include "sys.h"
@ -23,9 +24,6 @@
#define MAXOPTIONS 13
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
extern void titles_default();
/*** Extern variables ***/
@ -34,8 +32,6 @@ extern GuiSound * bgMusic;
extern GuiImage * bgImg;
extern GuiImageData * pointer[4];
extern GuiImageData * background;
extern u8 shutdown;
extern u8 reset;
extern u8 mountMethod;
extern struct discHdr *dvdheader;
extern PartList partitions;
@ -537,7 +533,7 @@ int MenuSettings()
snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Theme Downloader"));
MainButton1Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr(" "));
snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr("Partition Format Menu"));
MainButton2Txt.SetText(MainButtonText);
snprintf(MainButtonText, sizeof(MainButtonText), "%s", tr(" "));
MainButton3Txt.SetText(MainButtonText);
@ -557,6 +553,7 @@ int MenuSettings()
w.Append(&GoRightBtn);
w.Append(&GoLeftBtn);
w.Append(&MainButton1);
w.Append(&MainButton2);
PageIndicatorBtn1.SetAlpha(50);
PageIndicatorBtn2.SetAlpha(50);
@ -611,10 +608,6 @@ int MenuSettings()
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
if ( pageToDisplay == 1 )
{
@ -658,12 +651,7 @@ int MenuSettings()
returnhere = 1;
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED)
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
exit = true;
@ -920,12 +908,7 @@ int MenuSettings()
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED)
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
exit = true;
@ -1119,12 +1102,7 @@ int MenuSettings()
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED)
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
exit = true;
@ -1294,11 +1272,7 @@ int MenuSettings()
bool returnhere = true;
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED)
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
exit = true;
@ -1474,12 +1448,8 @@ int MenuSettings()
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED)
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
exit = true;
@ -2048,6 +2018,20 @@ int MenuSettings()
pageToDisplay = 0;
break;
}
if (MainButton2.GetState() == STATE_CLICKED)
{
if(Settings.godmode == 1)
{
if (isInserted(bootDevice))
cfg_save_global();
menu = MENU_FORMAT;
pageToDisplay = 0;
break;
}
else
WindowPrompt(tr("You can't access this menu!"), tr("Unlock the app first."), tr("OK"));
MainButton2.ResetState();
}
}
@ -2449,11 +2433,6 @@ int GameSettings(struct discHdr * header)
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
if (MainButton1.GetState() == STATE_CLICKED)
{
w.Append(&saveBtn);
@ -2489,10 +2468,6 @@ int GameSettings(struct discHdr * header)
returnhere = 1;
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();
@ -2762,10 +2737,6 @@ int GameSettings(struct discHdr * header)
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
if (backBtn.GetState() == STATE_CLICKED)
{
backBtn.ResetState();

View File

@ -10,6 +10,7 @@
#include "settings/cfg.h"
#include "network/URL_List.h"
#include "listfiles.h"
#include "menu/menus.h"
#include "main.h"
#include "fatmounter.h"
#include "filelist.h"
@ -20,13 +21,6 @@
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern GuiSound * bgMusic;
extern u8 shutdown;
extern u8 reset;
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/****************************************************************************
* MenuOGG
@ -183,11 +177,6 @@ bool MenuOGG() {
while (!returnhere) {
if (shutdown == 1)
Sys_Shutdown();
if (reset == 1)
Sys_Reboot();
if (backBtn.GetState() == STATE_CLICKED) {
if (nothingchanged == 1 && countoggs > 0) {
if (strcmp("", Settings.oggload_path) && strcmp("notset", Settings.ogg_path)) {
@ -453,12 +442,7 @@ int MenuLanguageSelect() {
while (!returnhere) {
if (shutdown == 1)
Sys_Shutdown();
else if (reset == 1)
Sys_Reboot();
else if (backBtn.GetState() == STATE_CLICKED) {
if (backBtn.GetState() == STATE_CLICKED) {
backBtn.ResetState();
break;

View File

@ -385,7 +385,11 @@ void Global_Default(void) {
}
char *cfg_get_title(u8 *id) {
char *cfg_get_title(u8 *id)
{
if(!id)
return NULL;
int i;
for (i=0; i<num_title; i++) {
if (memcmp(id, cfg_title[i].id, 4) == 0) {

View File

@ -14,10 +14,13 @@
#include "fatmounter.h"
#include "sys.h"
#include "wpad.h"
#include "menu/menus.h"
extern char game_partition[6];
extern u8 load_from_fs;
extern u8 hddState;
//Wiilight stuff
static vu32 *_wiilight_reg = (u32*)0xCD0000C0;
void wiilight(int enable) { // Toggle wiilight (thanks Bool for wiilight source)
@ -70,15 +73,17 @@ int Sys_ChangeIos(int ios) {
s32 prevIos = IOS_GetVersion();
SDCard_deInit();
if (hddState)
USBDevice_deInit();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
if (hddState)
{
WDVD_Close();
USBStorage_Deinit();
}
s32 ret = IOS_ReloadIOSsafe(ios);
if (ret < 0) {
@ -90,6 +95,8 @@ int Sys_ChangeIos(int ios) {
if (ios == 222 || ios == 223) {
load_ehc_module();
}
if (hddState)
USBDevice_Init();
PAD_Init();
@ -97,6 +104,8 @@ int Sys_ChangeIos(int ios) {
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
if (hddState)
{
WBFS_Init(WBFS_DEVICE_USB);
Disc_Init();
@ -105,6 +114,7 @@ int Sys_ChangeIos(int ios) {
} else {
WBFS_Open();
}
}
return ret;
}
@ -114,17 +124,22 @@ int Sys_IosReload(int IOS) {
//shutdown SD and USB before IOS Reload in DiscWait
SDCard_deInit();
if (hddState)
USBDevice_deInit();
WPAD_Flush(0);
WPAD_Disconnect(0);
WPAD_Shutdown();
if (hddState)
{
WDVD_Close();
USBStorage_Deinit();
}
if (IOS == 249 || IOS == 222 || IOS == 223) {
ret = IOS_ReloadIOSsafe(IOS);
if (ret < 0) return ret;
if ((IOS == 249 || IOS == 222 || IOS == 223) && hddState) {
for (int i = 0; i < 10; i++) {
ret = IOS_ReloadIOSsafe(IOS);
if (ret < 0) return ret;
@ -148,6 +163,7 @@ int Sys_IosReload(int IOS) {
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
//reinitialize SD and USB
SDCard_Init();
if (hddState)
USBDevice_Init();
return ret;
@ -263,6 +279,120 @@ s32 IOS_ReloadIOSsafe(int ios)
return r;
}
s32 CheckForCIOS()
{
gprintf("\n\tChecking for stub IOS");
s32 ret = -1;
s32 ios222rev = getIOSrev(0x00000001000000dell);
s32 ios249rev = getIOSrev(0x00000001000000f9ll);
//if we don't like either of the cIOS then scram
if (!(ios222rev==4 || ios222rev==5 || (ios249rev>=9 && ios249rev<65280)))
{
InitTextVideo();
printf("\x1b[2J");
if ((ios222rev < 0 && ios222rev != WII_EINSTALL) && (ios249rev < 0 && ios249rev != WII_EINSTALL)) {
printf("\n\n\n\tWARNING!");
printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
printf("\n\n\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.");
printf("\n\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,");
printf("\n\tand you should go figure out how to get some cios action going on\n\tin your Wii.");
printf("\n\n\tThis message will show every time.");
sleep(5);
} else {
printf("\n\n\n\tERROR!");
printf("\n\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+");
printf("\n\n\tI found \n\t\t222 = %d%s",ios222rev,ios222rev==65280?" (Stubbed by 4.2 update)":"");
printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65280?" (Stubbed by 4.2 update)":"");
printf("\n\n\tGo figure out how to get some cIOS action going on\n\tin your Wii and come back and see me.");
sleep(15);
printf("\n\n\tBye");
USBDevice_deInit();
exit(0);
}
}
printf("\n\tReloading ios 249...");
ret = IOS_ReloadIOSsafe(249);
printf("%d", ret);
if (ret < 0)
{
printf("\n\tIOS 249 failed, reloading ios 222...");
ret = IOS_ReloadIOSsafe(222);
printf("%d", ret);
if (ret < 0) {
printf("\n\tIOS 222 failed, reloading ios 250...");
ret = IOS_ReloadIOSsafe(250);
printf("%d", ret);
if (ret < 0) {
printf("\n\tERROR: cIOS could not be loaded!\n");
sleep(5);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
}
else
{
//only for 222 loading ehc modules
printf("\n\tLoad ehc module");
load_ehc_module();
}
}
return ret;
}
int LoadAppCIOS()
{
s32 ret = 1;
/* Load Custom IOS */
if (Settings.cios == ios222 && IOS_GetVersion() != 222)
{
printf("\n\tReloading IOS to config setting (%d)...", ios222 ? 222 : 223);
SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit();
ret = IOS_ReloadIOSsafe(ios222 ? 222 : 223);
printf("%d", ret);
if (ret < 0)
{
Settings.cios = ios249;
IOS_ReloadIOSsafe(249);
}
SDCard_Init();
USBDevice_Init(); // and mount USB:/
if(ret >= 0)
load_ehc_module();
}
else if ((Settings.cios == ios249 && IOS_GetVersion() != 249) ||
(Settings.cios == ios250 && IOS_GetVersion() != 250))
{
printf("\n\tReloading IOS to config setting (%d)...", ios249 ? 249 : 250);
SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit();
ret = IOS_ReloadIOSsafe(ios249 ? 249 : 250);
printf("%d", ret);
if (ret < 0) {
Settings.cios = ios222;
ret = IOS_ReloadIOSsafe(222);
SDCard_Init();
load_ehc_module();
}
else SDCard_Init(); // now mount SD:/ //no need to keep mindlessly mounting and unmounting SD card
USBDevice_Init(); // and mount USB:/
}
return ret;
}
#include <time.h>
void ScreenShot()

View File

@ -13,6 +13,8 @@ void Sys_LoadMenu(void);
void Sys_BackToLoader(void);
int Sys_ChangeIos(int ios);
int Sys_IosReload(int IOS);
s32 CheckForCIOS();
int LoadAppCIOS();
bool Sys_IsHermes();
s32 IOS_ReloadIOSsafe(int ios);
void ScreenShot();

View File

@ -24,16 +24,10 @@
#include "ZipFile.h"
#include "gecko.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/*** Extern variables ***/
extern GuiWindow * mainWindow;
extern GuiSound * bgMusic;
extern GuiImage * bgImg;
extern u8 shutdown;
extern u8 reset;
int DownloadTheme(const char *url, const char *title)
@ -245,11 +239,6 @@ static int Theme_Prompt(const char *title, const char *author, GuiImageData *thu
{
VIDEO_WaitVSync();
if (shutdown == 1)
Sys_Shutdown();
else if (reset == 1)
Sys_Reboot();
if (downloadBtn.GetState() == STATE_CLICKED)
{
int choice = WindowPrompt(tr("Do you want to download this theme?"), title, tr("Yes"), tr("Cancel"));
@ -579,12 +568,7 @@ int Theme_Downloader()
{
VIDEO_WaitVSync ();
if (shutdown == 1)
Sys_Shutdown();
else if (reset == 1)
Sys_Reboot();
else if (wifiBtn.GetState() == STATE_CLICKED)
if (wifiBtn.GetState() == STATE_CLICKED)
{
Initialize_Network();
wifiBtn.ResetState();

View File

@ -9,6 +9,7 @@
#include "../prompts/TitleBrowser.h"
#include "../gecko.h"
#include "wad/wad.h"
#include "xml/xml.h"
#include "../wad/title.h"
@ -407,14 +408,14 @@ int buildTitleList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *PgameC
continue;
}*/
if(gameFilter && *gameFilter) {
/*if(gameFilter && *gameFilter) {
u32 filter_len = wcslen(gameFilter);
wchar_t *gameName = FreeTypeGX::charToWideChar(get_title(header));
if (!gameName || wcsnicmp(gameName, gameFilter, filter_len)) {
delete [] gameName;
continue;
}
}
}*/
if(i != cnt2)
buffer[cnt2] = buffer[i];
cnt2++;
@ -469,7 +470,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg
ret = WBFS_GetCount(&cnt);
if (ret < 0)
return ret;
//gprintf("\n WBFS_GetCount:%d",cnt);
/* Buffer length */
len = sizeof(struct discHdr) * cnt;
@ -562,7 +563,7 @@ int __Menu_GetGameList(int t, wchar_t* gameFilter, discHdr ** PgameList, u32 *Pg
}
int __Menu_GetEntries(int t, const wchar_t* Filter) {
//gprintf("\n__Menu_GetEntries()");
/*if (mountMethod==3)
{
return buildTitleList();
@ -576,24 +577,42 @@ int __Menu_GetEntries(int t, const wchar_t* Filter) {
wchar_t *new_gameFilterPrev = NULL;
new_gameFilter = wcsdup_new(Filter ? Filter : (gameFilter ? gameFilter : L"") );
if(new_gameFilter == NULL) return -1;
if(new_gameFilter == NULL)
{
//gprintf("\nnew_gameFilter == NULL");
return -1;
}
for(;;)
{
if (mountMethod==3)
{if(buildTitleList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0)
return -1;}
{int butt =buildTitleList(t, new_gameFilter, &new_gameList, &new_gameCnt);
if (butt < 0)
{
gprintf("\nbutt:%d", butt);
return -1;
}
}
else
{if(__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0)
return -1;}
{
if(__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0)
{
gprintf("\n__Menu_GetGameList(t, new_gameFilter, &new_gameList, &new_gameCnt) < 0");
return -1;
}
}
if(new_gameCnt > 0 || new_gameFilter[0] == 0)
{
//gprintf("\nnew_gameCnt:%d",new_gameCnt);
break;
}
new_gameFilter[wcslen(new_gameFilter)-1] = 0;
}
if (mountMethod!=3)
{
/* init GameFilterNextList */
if(__Menu_GetGameFilter_NextList(new_gameList, new_gameCnt, &new_gameFilter, &new_gameFilterNextList) < 0)
goto error;
@ -601,7 +620,7 @@ int __Menu_GetEntries(int t, const wchar_t* Filter) {
/* init GameFilterPrev */
if(__Menu_GetPrevFilter(t, new_gameFilter, new_gameCnt, &new_gameFilterPrev) < 0)
goto error;
}
/* Set values */
if(gameList) free(gameList);
if(gameFilter) delete [] gameFilter;
@ -614,10 +633,15 @@ int __Menu_GetEntries(int t, const wchar_t* Filter) {
gameFilterNextList = new_gameFilterNextList;
gameFilterPrev = new_gameFilterPrev;
/* Reset variables */
gameSelected = gameStart = 0;
//gprintf("\ncnt:%d", gameCnt);
return 0;
error: // clean up
gprintf("\nERROR");
if(new_gameList) free(new_gameList);
if(new_gameFilter) delete [] new_gameFilter;
if(new_gameFilterNextList) delete [] new_gameFilterNextList;

View File

@ -30,6 +30,9 @@ int screenheight;
int screenwidth;
u32 frameCount = 0;
extern bool textVideoInit;
extern bool geckoinit;
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy)
@ -198,6 +201,46 @@ InitVideo () {
ResetVideo_Menu();
// Finally, the video is up and ready for use :)
}
void InitTextVideo ()
{
unsigned int *xfb = NULL;
gprintf("\nInitTextVideo ()");
if (textVideoInit)
{
gprintf("...0");
return;
}
VIDEO_Init();
GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); // get default video mode
// widescreen fix
VIDEO_Configure (vmode);
// Allocate the video buffers
xfb = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
// A console is always useful while debugging
console_init (xfb, 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
// Clear framebuffers etc.
VIDEO_ClearFrameBuffer (vmode, xfb, COLOR_BLACK);
VIDEO_SetNextFramebuffer (xfb);
VIDEO_SetBlack (FALSE);
VIDEO_Flush ();
VIDEO_WaitVSync ();
if (vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync ();
//send console output to the gecko
if (geckoinit)CON_EnableGecko(1, true);
textVideoInit = true;
gprintf("...1");
}
static unsigned int *xfbDB = NULL;
void InitVideodebug () {
@ -241,8 +284,8 @@ void StopGX() {
*
* Renders everything current sent to GX, and flushes video
***************************************************************************/
void Menu_Render() {
void Menu_Render()
{
whichfb ^= 1; // flip framebuffer
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
@ -492,6 +535,13 @@ void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexO
***************************************************************************/
s32 TakeScreenshot(const char *path)
{
//check if it is possible to write
FILE *f = fopen(path, "wb");
if(!f)
return -1;
else
fclose(f);
gprintf("\nTakeScreenshot(%s)", path);
IMGCTX ctx = PNGU_SelectImageFromDevice (path);
s32 ret = PNGU_EncodeFromYCbYCr(ctx,vmode->fbWidth, vmode->efbHeight,xfb[whichfb],0);
@ -499,3 +549,4 @@ s32 TakeScreenshot(const char *path)
gprintf(":%d", ret);
return 1;
}

View File

@ -13,6 +13,7 @@
void InitVideo ();
void InitVideodebug();
void InitTextVideo();
void StopGX();
void ResetVideo_Menu();
void Menu_Render();

View File

@ -8,22 +8,15 @@
#include "utils.h"
#include "video.h"
#include "wad.h"
#include "prompts/PromptWindows.h"
#include "libwiigui/gui.h"
#include "language/gettext.h"
#include "menu.h"
#include "filelist.h"
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
/*** Extern variables ***/
extern GuiWindow * mainWindow;
/* 'WAD Header' structure */
typedef struct {
/* Header length */