lots of changes here

changed gprintf() to use crediar's method because it is smaller and works just the same.

allow r-win's debug printf() stuff to be sent to the gecko to reduce redundant stuff there 

issue 1073.  headless mode - allow game to be booted via argv[1].

took out all the params from the exitprompt since they aren't used.

took out all the #ifdef stuff for building for a wii.  obviously this wont run on a gamecube so it isn't needed.

added a way to check what version of a IOS is installed before trying to boot into it.  added IOS_ReloadIOSsafe(). this should stop idiots with the 4.2 stubs from bitching about why stuff doesn't work.

use that check so you only see the "222v4 is needed" prompt in the settings if you don't already have that installed.

fix issue 1039. (must still be compiled without NO_DEBUG defined because technically WiiRD is a debugger)
This commit is contained in:
giantpune 2009-12-03 01:06:09 +00:00
parent 46cb312577
commit 55a401e4a5
21 changed files with 331 additions and 426 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>1.0 r844</version> <version>1.0 r845</version>
<release_date>200911232251</release_date> <release_date>200912030058</release_date>
<short_description>Loads games from USB-devices</short_description> <short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. <long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

View File

@ -131,7 +131,6 @@ all:
clean: clean:
@echo clean ... @echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
run: run:
make make
@ -149,6 +148,7 @@ release:
make make
cp boot.dol ./hbc/boot.dol cp boot.dol ./hbc/boot.dol
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
else else

File diff suppressed because one or more lines are too long

View File

@ -1,287 +1,31 @@
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <gccore.h> #include <gccore.h>
#include <stdio.h>
#include <string.h>
/* init-globals */ /* init-globals */
bool geckoinit = false; bool geckoinit = false;
bool textVideoInit = false;
#ifndef NO_DEBUG #ifndef NO_DEBUG
#include <stdarg.h>
//using the gprintf from crediar because it is smaller than mine
/* we use this so that we can do without the ctype library */ void gprintf( const char *str, ... )
#define is_digit(c) ((c) >= '0' && (c) <= '9')
static int skip_atoi(const char **s)
{ {
int i=0; if (!(geckoinit))return;
while (is_digit(**s)) char astr[4096];
i = i*10 + *((*s)++) - '0';
return i; va_list ap;
va_start(ap,str);
vsprintf( astr, str, ap );
va_end(ap);
usb_sendbuffer_safe( 1, astr, strlen(astr) );
} }
#define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */
#define PLUS 4 /* show plus */
#define SPACE 8 /* space if plus */
#define LEFT 16 /* left justified */
#define SPECIAL 32 /* 0x */
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \
int __res; \
__res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \
__res; })
static char * number(char * str, long num, int base, int size, int precision
,int type)
{
char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i;
if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT)
type &= ~ZEROPAD;
if (base < 2 || base > 36)
return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0;
if (type & SIGN) {
if (num < 0) {
sign = '-';
num = -num;
size--;
} else if (type & PLUS) {
sign = '+';
size--;
} else if (type & SPACE) {
sign = ' ';
size--;
}
}
if (type & SPECIAL) {
if (base == 16)
size -= 2;
else if (base == 8)
size--;
}
i = 0;
if (num == 0)
tmp[i++]='0';
else while (num != 0)
tmp[i++] = digits[do_div(num,base)];
if (i > precision)
precision = i;
size -= precision;
if (!(type&(ZEROPAD+LEFT)))
while(size-->0)
*str++ = ' ';
if (sign)
*str++ = sign;
if (type & SPECIAL) {
if (base==8)
*str++ = '0';
else if (base==16) {
*str++ = '0';
*str++ = digits[33];
}
}
if (!(type & LEFT))
while (size-- > 0)
*str++ = c;
while (i < precision--)
*str++ = '0';
while (i-- > 0)
*str++ = tmp[i];
while (size-- > 0)
*str++ = ' ';
return str;
}
int kvsprintf1(char *buf, const char *fmt, va_list args)
{
int len;
unsigned long num;
int i, base;
char * str;
const char *s;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
int qualifier; /* 'h', 'l', or 'L' for integer fields */
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
*str++ = *fmt;
continue;
}
/* process flags */
flags = 0;
repeat:
++fmt; /* this also skips first '%' */
switch (*fmt) {
case '-': flags |= LEFT; goto repeat;
case '+': flags |= PLUS; goto repeat;
case ' ': flags |= SPACE; goto repeat;
case '#': flags |= SPECIAL; goto repeat;
case '0': flags |= ZEROPAD; goto repeat;
}
/* get field width */
field_width = -1;
if (is_digit(*fmt))
field_width = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
field_width = va_arg(args, int);
if (field_width < 0) {
field_width = -field_width;
flags |= LEFT;
}
}
/* get the precision */
precision = -1;
if (*fmt == '.') {
++fmt;
if (is_digit(*fmt))
precision = skip_atoi(&fmt);
else if (*fmt == '*') {
++fmt;
/* it's the next argument */
precision = va_arg(args, int);
}
if (precision < 0)
precision = 0;
}
/* get the conversion qualifier */
qualifier = -1;
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
}
/* default base */
base = 10;
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
while (--field_width > 0)
*str++ = ' ';
*str++ = (unsigned char) va_arg(args, int);
while (--field_width > 0)
*str++ = ' ';
continue;
case 's':
s = va_arg(args, char *);
if (!s)
s = "<NULL>";
len = strnlen(s, precision);
if (!(flags & LEFT))
while (len < field_width--)
*str++ = ' ';
for (i = 0; i < len; ++i)
*str++ = *s++;
while (len < field_width--)
*str++ = ' ';
continue;
case 'p':
if (field_width == -1) {
field_width = 2*sizeof(void *);
flags |= ZEROPAD;
}
str = number(str,
(unsigned long) va_arg(args, void *), 16,
field_width, precision, flags);
continue;
case 'n':
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (str - buf);
} else {
int * ip = va_arg(args, int *);
*ip = (str - buf);
}
continue;
case '%':
*str++ = '%';
continue;
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
case 'X':
flags |= LARGE;
case 'x':
base = 16;
break;
case 'd':
case 'i':
flags |= SIGN;
case 'u':
break;
default:
*str++ = '%';
if (*fmt)
*str++ = *fmt;
else
--fmt;
continue;
}
if (qualifier == 'l')
num = va_arg(args, unsigned long);
else if (qualifier == 'h') {
num = (unsigned short) va_arg(args, int);
if (flags & SIGN)
num = (short) num;
} else if (flags & SIGN)
num = va_arg(args, int);
else
num = va_arg(args, unsigned int);
str = number(str, num, base, field_width, precision, flags);
}
*str = '\0';
return str-buf;
}
bool InitGecko() bool InitGecko()
{ {
u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1); u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
@ -293,21 +37,5 @@ bool InitGecko()
else return false; else return false;
} }
//almost verbatum from libogc. just changed to output to USB gecko
void gprintf(const char *str, ...)
{
if (!(geckoinit))return;
int len;
char __outstr[256];
va_list args;
va_start(args, str);
len=kvsprintf1(__outstr,str,args);
va_end(args);
usb_sendbuffer_safe(1,__outstr,len);
}
#endif /* NO_DEBUG */ #endif /* NO_DEBUG */

View File

@ -6,7 +6,6 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//giantpune's functions for USB gecko
#ifndef NO_DEBUG #ifndef NO_DEBUG
//use this just like printf(); //use this just like printf();

View File

@ -770,7 +770,7 @@ int MenuHomebrewBrowse() {
else if (homo.GetState() == STATE_CLICKED) { else if (homo.GetState() == STATE_CLICKED) {
cfg_save_global(); cfg_save_global();
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) { if (choice == 3) {

View File

@ -122,7 +122,6 @@ void GuiSearchBar::Update(GuiTrigger * t)
LOCK(this); LOCK(this);
if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement)) if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement))
return; return;
#ifdef HW_RVL
// cursor // cursor
if(t->wpad.ir.valid && state != STATE_DISABLED) if(t->wpad.ir.valid && state != STATE_DISABLED)
{ {
@ -142,7 +141,6 @@ void GuiSearchBar::Update(GuiTrigger * t)
mainWindow->SetState(STATE_DEFAULT); mainWindow->SetState(STATE_DEFAULT);
} }
} }
#endif
GuiWindow::Update(t); GuiWindow::Update(t);
} }
wchar_t GuiSearchBar::GetClicked() wchar_t GuiSearchBar::GetClicked()

View File

@ -16,6 +16,17 @@
#include <unistd.h> #include <unistd.h>
#include <locale.h> #include <locale.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
//#include <debug.h>
//extern "C" { //not sure if this is in teh libogc that the buildbot is using so it isnt used yet
//extern void __exception_setreload(int t);
//}
#include <gccore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <di/di.h>
#include <sys/iosupport.h>
#include "libwiigui/gui.h" #include "libwiigui/gui.h"
#include "usbloader/wbfs.h" #include "usbloader/wbfs.h"
@ -36,10 +47,13 @@
#include "fat.h" #include "fat.h"
#include "gecko.h" #include "gecko.h"
#include "svnrev.h" #include "svnrev.h"
#include "wad/title.h"
#include "usbloader/partition_usbloader.h" #include "usbloader/partition_usbloader.h"
#include "usbloader/usbstorage.h" #include "usbloader/usbstorage.h"
extern bool geckoinit; extern bool geckoinit;
extern bool textVideoInit;
extern char headlessID[8];
/* Constants */ /* Constants */
#define CONSOLE_XCOORD 260 #define CONSOLE_XCOORD 260
@ -76,9 +90,9 @@ static void BootUpProblems()
time_t curtime; time_t curtime;
time_t endtime = time(0) + 30; time_t endtime = time(0) + 30;
do { do {
ret2 = IOS_ReloadIOS(249); ret2 = IOS_ReloadIOSsafe(249);
if (ret2 < 0) { if (ret2 < 0) {
ret2 = IOS_ReloadIOS(222); ret2 = IOS_ReloadIOSsafe(222);
SDCard_Init(); SDCard_Init();
load_ehc_module(); load_ehc_module();
SDCard_deInit(); SDCard_deInit();
@ -129,6 +143,9 @@ static void BootUpProblems()
unsigned int *xfb = NULL; unsigned int *xfb = NULL;
void InitTextVideo () { void InitTextVideo () {
if (textVideoInit)return;
VIDEO_Init(); VIDEO_Init();
GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); // get default video mode GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); // get default video mode
@ -150,6 +167,11 @@ void InitTextVideo () {
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
if (vmode->viTVMode & VI_NON_INTERLACE) if (vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
//send console output to the gecko
if (geckoinit)CON_EnableGecko(1, true);
textVideoInit = true;
} }
@ -157,14 +179,24 @@ int
main(int argc, char *argv[]) { main(int argc, char *argv[]) {
// InitTextVideo(); // InitTextVideo();
//DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
//_break();
//see note above __exception_setreload(5);//auto reset is code dump nobody gives us codedump info anyways.
setlocale(LC_ALL, "en.UTF-8"); setlocale(LC_ALL, "en.UTF-8");
geckoinit = InitGecko(); geckoinit = InitGecko();
if (geckoinit)InitTextVideo();
gprintf("\x1b[2J"); gprintf("\x1b[2J");
gprintf("------------------"); gprintf("------------------");
gprintf("\nUSB Loader GX rev%s",GetRev()); gprintf("\nUSB Loader GX rev%s",GetRev());
gprintf("\nmain(int argc, char *argv[])"); gprintf("\nmain(%d", argc);
for (int i=1;i<argc;i++)
gprintf(", %s",argv[i]?argv[i]:"<NULL>");
gprintf(")");
printf("Starting up\n");
printf("\n\tStarting up");
s32 ret; s32 ret;
bool startupproblem = false; bool startupproblem = false;
@ -178,48 +210,67 @@ main(int argc, char *argv[]) {
bootDevice_found = true; bootDevice_found = true;
} }
printf("Initializing controllers\n"); printf("\n\tInitializing controllers");
/** PAD_Init has to be before InitVideo don't move that **/ /** PAD_Init has to be before InitVideo don't move that **/
PAD_Init(); // initialize PAD/WPAD PAD_Init(); // initialize PAD/WPAD
printf("Initialize USB (wake up)\n"); 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") 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")
printf("Reloading ios 249..."); gprintf("\n\tChecking for stub IOS");
ios222rev = getIOSrev(0x00000001000000dell);
ios249rev = getIOSrev(0x00000001000000f9ll);
ret = IOS_ReloadIOS(249); //if we don't like either of the cIOS then scram
if (!(ios222rev==4 && (ios249rev>=9 && ios249rev<65535)))
{
InitTextVideo();
printf("\x1b[2J");
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==65535?" (Stubbed by 4.2 update)":"");
printf("\n\t\t249 = %d%s",ios249rev,ios249rev==65535?" (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.");
printf("%d\n", ret); sleep(15);
printf("\n\n\tBye");
exit(0);
}
printf("\n\tReloading ios 249...");
ret = IOS_ReloadIOSsafe(249);
printf("%d", ret);
if (ret < 0) { if (ret < 0) {
printf("IOS 249 failed, reloading ios 222..."); printf("\n\tIOS 249 failed, reloading ios 222...");
ret = IOS_ReloadIOS(222); ret = IOS_ReloadIOSsafe(222);
printf("%d\n", ret); printf("%d", ret);
if(ret < 0) { if(ret < 0) {
printf("\n\tERROR: cIOS could not be loaded!\n"); printf("\n\tERROR: cIOS could not be loaded!\n");
sleep(5); sleep(5);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
printf("Initialize sd card\n"); printf("\n\tInitialize sd card");
SDCard_Init(); SDCard_Init();
printf("Load ehc module\n"); printf("\n\tLoad ehc module");
load_ehc_module(); load_ehc_module();
printf("deinit sd card\n"); printf("\n\tdeinit sd card");
SDCard_deInit(); SDCard_deInit();
} }
printf("Init wbfs..."); printf("\n\tInit wbfs...");
ret = WBFS_Init(WBFS_DEVICE_USB); ret = WBFS_Init(WBFS_DEVICE_USB);
printf("%d\n", ret); printf("%d", ret);
if (ret < 0) { if (ret < 0) {
printf("You have issues with a slow disc, or a difficult disc\nReloading 222..."); printf("\n\tYou have issues with a slow disc, or a difficult disc\n\tReloading 222...");
ret = IOS_ReloadIOS(222); ret = IOS_ReloadIOSsafe(222);
printf("%d\n", ret); printf("%d", ret);
if(ret < 0) { if(ret < 0) {
printf("Sleeping for 4 seconds\n"); printf("\n\tSleeping for 4 seconds");
// sleep(4); // sleep(4);
InitVideo(); // Initialise video InitVideo(); // Initialise video
@ -228,19 +279,19 @@ main(int argc, char *argv[]) {
startupproblem = true; startupproblem = true;
ret = 1; ret = 1;
} }
printf("Initialize sd card\n"); printf("\n\tInitialize sd card");
SDCard_Init(); SDCard_Init();
printf("Load ehc module\n"); printf("\n\tLoad ehc module");
load_ehc_module(); load_ehc_module();
printf("deinit sd card\n"); printf("\n\tdeinit sd card");
SDCard_deInit(); SDCard_deInit();
printf("Initialize wbfs..."); printf("\n\tInitialize wbfs...");
ret = WBFS_Init(WBFS_DEVICE_USB); ret = WBFS_Init(WBFS_DEVICE_USB);
printf("%d\n", ret); printf("%d", ret);
if(ret < 0) { if(ret < 0) {
printf("Sleeping for 4 seconds\n"); printf("\n\tSleeping for 4 seconds");
// sleep(4); // sleep(4);
InitVideo(); // Initialise video InitVideo(); // Initialise video
Menu_Render(); Menu_Render();
@ -250,14 +301,14 @@ main(int argc, char *argv[]) {
} }
} }
printf("Initialize sd card\n"); printf("\n\tInitialize sd card");
SDCard_Init(); // mount SD for loading cfg's SDCard_Init(); // mount SD for loading cfg's
printf("Initialize usb device\n"); printf("\n\tInitialize usb device");
USBDevice_Init(); // and mount USB:/ USBDevice_Init(); // and mount USB:/
gprintf("\n\tSD and USB Init OK"); gprintf("\n\tSD and USB Init OK");
if (!bootDevice_found) { if (!bootDevice_found) {
printf("Search for configuration file\n"); printf("\n\tSearch for configuration file");
//try USB //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 //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
@ -266,43 +317,43 @@ main(int argc, char *argv[]) {
|| checkfile((char*) "USB:/apps/usbloader_gx/boot.dol")) || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol"))
strcpy(bootDevice, "USB:"); strcpy(bootDevice, "USB:");
printf("Configuration file is on %s\n", bootDevice); printf("\n\tConfiguration file is on %s", bootDevice);
} }
gettextCleanUp(); gettextCleanUp();
printf("Loading configuration..."); printf("\n\tLoading configuration...");
CFG_Load(); CFG_Load();
printf("done\n"); printf("done");
gprintf("\n\tbootDevice = %s",bootDevice); // gprintf("\n\tbootDevice = %s",bootDevice);
/* Load Custom IOS */ /* Load Custom IOS */
if (Settings.cios == ios222 && IOS_GetVersion() != 222) { if (Settings.cios == ios222 && IOS_GetVersion() != 222) {
printf("Reloading IOS to config setting (222)..."); printf("\n\tReloading IOS to config setting (222)...");
SDCard_deInit();// unmount SD for reloading IOS SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit(); USBStorage_Deinit();
ret = IOS_ReloadIOS(222); ret = IOS_ReloadIOSsafe(222);
printf("%d\n", ret); printf("%d", ret);
SDCard_Init(); SDCard_Init();
load_ehc_module(); load_ehc_module();
if (ret < 0) { if (ret < 0) {
SDCard_deInit(); SDCard_deInit();
Settings.cios = ios249; Settings.cios = ios249;
ret = IOS_ReloadIOS(249); ret = IOS_ReloadIOSsafe(249);
} }
SDCard_Init(); // now mount SD:/ SDCard_Init(); // now mount SD:/
USBDevice_Init(); // and mount USB:/ USBDevice_Init(); // and mount USB:/
WBFS_Init(WBFS_DEVICE_USB); WBFS_Init(WBFS_DEVICE_USB);
} else if (Settings.cios == ios249 && IOS_GetVersion() != 249) { } else if (Settings.cios == ios249 && IOS_GetVersion() != 249) {
printf("Reloading IOS to config setting (249)..."); printf("\n\tReloading IOS to config setting (249)...");
SDCard_deInit();// unmount SD for reloading IOS SDCard_deInit();// unmount SD for reloading IOS
USBDevice_deInit();// unmount USB for reloading IOS USBDevice_deInit();// unmount USB for reloading IOS
USBStorage_Deinit(); USBStorage_Deinit();
ret = IOS_ReloadIOS(249); ret = IOS_ReloadIOSsafe(249);
printf("%d\n", ret); printf("%d", ret);
if (ret < 0) { if (ret < 0) {
Settings.cios = ios222; Settings.cios = ios222;
ret = IOS_ReloadIOS(222); ret = IOS_ReloadIOSsafe(222);
SDCard_Init(); SDCard_Init();
load_ehc_module(); load_ehc_module();
} }
@ -314,16 +365,23 @@ main(int argc, char *argv[]) {
// Partition_GetList(&partitions); // Partition_GetList(&partitions);
if (ret < 0) { if (ret < 0) {
printf("ERROR: cIOS could not be loaded!"); printf("\nERROR: cIOS could not be loaded!");
sleep(5); sleep(5);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision()); //gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());//don't need gprintf if sending console shit to gecko, too
printf("cIOS = %u (Rev %u)\n",IOS_GetVersion(), IOS_GetRevision()); printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());
// printf("Sleeping for 5 seconds\n"); // printf("Sleeping for 5 seconds\n");
// sleep(5); // 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>0&&argv[1])
{
strcpy(headlessID,argv[1]);
}
//! Init the rest of the System //! Init the rest of the System
Sys_Init(); Sys_Init();
Wpad_Init(); Wpad_Init();

View File

@ -21,6 +21,7 @@
#include "settings/cfg.h" #include "settings/cfg.h"
#include "themes/Theme_Downloader.h" #include "themes/Theme_Downloader.h"
#include "usbloader/disc.h" #include "usbloader/disc.h"
#include "usbloader/getentries.h"
#include "wad/title.h" #include "wad/title.h"
#include "xml/xml.h" #include "xml/xml.h"
#include "audio.h" #include "audio.h"
@ -51,6 +52,7 @@ GuiText * GameRegionTxt = NULL;
GuiImage * coverImg = NULL; GuiImage * coverImg = NULL;
GuiImageData * cover = NULL; GuiImageData * cover = NULL;
bool altdoldefault = true; bool altdoldefault = true;
char headlessID[8] = {0};
static lwp_t guithread = LWP_THREAD_NULL; static lwp_t guithread = LWP_THREAD_NULL;
static bool guiHalt = true; static bool guiHalt = true;
@ -72,8 +74,7 @@ extern u8 boothomebrew;
* after finishing the removal/insertion of new elements, and after initial * after finishing the removal/insertion of new elements, and after initial
* GUI setup. * GUI setup.
***************************************************************************/ ***************************************************************************/
void void ResumeGui() {
ResumeGui() {
guiHalt = false; guiHalt = false;
LWP_ResumeThread (guithread); LWP_ResumeThread (guithread);
} }
@ -86,8 +87,8 @@ ResumeGui() {
* This eliminates the possibility that the GUI is in the middle of accessing * This eliminates the possibility that the GUI is in the middle of accessing
* an element that is being changed. * an element that is being changed.
***************************************************************************/ ***************************************************************************/
void void HaltGui() {
HaltGui() { if (guiHalt)return;
guiHalt = true; guiHalt = true;
// wait for thread to finish // wait for thread to finish
@ -104,13 +105,13 @@ static void * UpdateGUI (void *arg) {
while (1) { while (1) {
if (guiHalt) { if (guiHalt) {
LWP_SuspendThread(guithread); LWP_SuspendThread(guithread);
} else { }
else {
if (!ExitRequested) { if (!ExitRequested) {
mainWindow->Draw(); mainWindow->Draw();
if (Settings.tooltips == TooltipsOn && THEME.show_tooltip != 0 && mainWindow->GetState() != STATE_DISABLED) if (Settings.tooltips == TooltipsOn && THEME.show_tooltip != 0 && mainWindow->GetState() != STATE_DISABLED)
mainWindow->DrawTooltip(); mainWindow->DrawTooltip();
#ifdef HW_RVL
for (int i=3; i >= 0; i--) { // so that player 1's cursor appears on top! for (int i=3; i >= 0; i--) { // so that player 1's cursor appears on top!
if (userInput[i].wpad.ir.valid) if (userInput[i].wpad.ir.valid)
Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, 200.0, Menu_DrawImg(userInput[i].wpad.ir.x-48, userInput[i].wpad.ir.y-48, 200.0,
@ -119,7 +120,6 @@ static void * UpdateGUI (void *arg) {
DoRumble(i); DoRumble(i);
} }
} }
#endif
Menu_Render(); Menu_Render();
@ -129,6 +129,7 @@ static void * UpdateGUI (void *arg) {
} else { } else {
for (int a = 5; a < 255; a += 10) { for (int a = 5; a < 255; a += 10) {
if (strcmp(headlessID,"")==0)
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();
@ -247,7 +248,9 @@ int MainMenu(int menu) {
currentMenu = menu; currentMenu = menu;
char imgPath[100]; char imgPath[100];
#ifdef HW_RVL //if (strcmp(headlessID,"")!=0)HaltGui();
//WindowPrompt("Can you see me now",0,"ok");
snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path);
pointer[0] = new GuiImageData(imgPath, player1_point_png); pointer[0] = new GuiImageData(imgPath, player1_point_png);
snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path);
@ -256,7 +259,6 @@ int MainMenu(int menu) {
pointer[2] = new GuiImageData(imgPath, player3_point_png); pointer[2] = new GuiImageData(imgPath, player3_point_png);
snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path);
pointer[3] = new GuiImageData(imgPath, player4_point_png); pointer[3] = new GuiImageData(imgPath, player4_point_png);
#endif
mainWindow = new GuiWindow(screenwidth, screenheight); mainWindow = new GuiWindow(screenwidth, screenheight);
@ -270,6 +272,7 @@ int MainMenu(int menu) {
bgImg = new GuiImage(background); bgImg = new GuiImage(background);
mainWindow->Append(bgImg); mainWindow->Append(bgImg);
if (strcmp(headlessID,"")==0)
ResumeGui(); ResumeGui();
bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, Settings.volume); bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, Settings.volume);
@ -311,20 +314,16 @@ int MainMenu(int menu) {
} }
} }
// MemInfoPrompt(); // MemInfoPrompt();
//for testing gprintf("\nExiting main GUI. mountMethod = %d",mountMethod);
/*if (mountMethod)
{
char tmp[30];
sprintf(tmp,"boot method --> %i",mountMethod);
WindowPrompt(0,tmp,0,0,0,0,100);
}
*/
gprintf("\nExiting main GUI");
CloseXMLDatabase(); CloseXMLDatabase();
NewTitles::DestroyInstance(); 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(); ExitGUIThreads();
bgMusic->Stop(); bgMusic->Stop();
delete bgMusic; delete bgMusic;
delete background; delete background;
@ -360,15 +359,45 @@ int MainMenu(int menu) {
WII_LaunchTitle(0x0000000100000100ULL); WII_LaunchTitle(0x0000000100000100ULL);
} }
if (boothomebrew == 1) { else if (boothomebrew == 1) {
gprintf("\nBootHomebrew"); gprintf("\nBootHomebrew");
BootHomebrew(Settings.selected_homebrew); BootHomebrew(Settings.selected_homebrew);
} else if (boothomebrew == 2) { }
else if (boothomebrew == 2) {
gprintf("\nBootHomebrewFromMenu"); gprintf("\nBootHomebrewFromMenu");
BootHomebrewFromMem(); BootHomebrewFromMem();
} else { }
else {
struct discHdr *header = NULL;
//if the GUI was "skipped" to boot a game from main(argv[1])
if (strcmp(headlessID,"")!=0)
{
gprintf("\n\tHeadless mode (%s)",headlessID);
__Menu_GetEntries(1);
//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)
{
gameSelected = i;
gprintf(" found (%d)",i);
break;
}
//if the game was not found
if (i==gameCnt-1)
{
gprintf(" not found (%d IDs checked)",i);
exit(0);
}
}
}
int ret = 0; int ret = 0;
struct discHdr *header = (mountMethod?dvdheader:&gameList[gameSelected]); header = (mountMethod?dvdheader:&gameList[gameSelected]);
struct Game_CFG* game_cfg = CFG_get_game_opt(header->id); struct Game_CFG* game_cfg = CFG_get_game_opt(header->id);
@ -595,6 +624,5 @@ int MainMenu(int menu) {
printf("Returning entry point: 0x%0x\n", ret); printf("Returning entry point: 0x%0x\n", ret);
} }
return 0; return 0;
} }

View File

@ -9,12 +9,14 @@
extern bool load_from_fat; extern bool load_from_fat;
extern char game_partition[6]; extern char game_partition[6];
extern char headlessID[8];
/**************************************************************************** /****************************************************************************
* MenuCheck * MenuCheck
***************************************************************************/ ***************************************************************************/
int MenuCheck() { int MenuCheck() {
gprintf("\nMenuCheck()"); gprintf("\nMenuCheck()");
//WindowPrompt("test",0,"ok");
int menu = MENU_NONE; int menu = MENU_NONE;
int i = 0; int i = 0;
int choice; int choice;
@ -137,6 +139,9 @@ int MenuCheck() {
//Spieleliste laden //Spieleliste laden
__Menu_GetEntries(0); __Menu_GetEntries(0);
if (strcmp(headlessID,"")!=0)
menu = MENU_EXIT;
if (menu == MENU_NONE) if (menu == MENU_NONE)
menu = MENU_DISCLIST; menu = MENU_DISCLIST;

View File

@ -695,7 +695,7 @@ int MenuDiscList() {
} else if (homeBtn.GetState() == STATE_CLICKED) { } else if (homeBtn.GetState() == STATE_CLICKED) {
gprintf("\n\thomeBtn clicked"); gprintf("\n\thomeBtn clicked");
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) { if (choice == 3) {
@ -1475,7 +1475,6 @@ void rockout(int f) {
int num=(f==2?-1:gameSelected); int num=(f==2?-1:gameSelected);
char imgPath[100]; char imgPath[100];
#ifdef HW_RVL
if ((!(strcasestr(get_title(&gameList[num]),"guitar")|| if ((!(strcasestr(get_title(&gameList[num]),"guitar")||
strcasestr(get_title(&gameList[num]),"band")|| strcasestr(get_title(&gameList[num]),"band")||
strcasestr(get_title(&gameList[num]),"rock")|| strcasestr(get_title(&gameList[num]),"rock")||
@ -1503,6 +1502,5 @@ void rockout(int f) {
snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path);
pointer[3] = new GuiImageData(imgPath, rplayer4_point_png); pointer[3] = new GuiImageData(imgPath, rplayer4_point_png);
} }
#endif
ResumeGui(); ResumeGui();
} }

View File

@ -685,10 +685,8 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
* If titel/subtitle or one of the buttons is not needed give him a 0 on that * If titel/subtitle or one of the buttons is not needed give him a 0 on that
* place. * place.
***************************************************************************/ ***************************************************************************/
int int WindowExitPrompt()
WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, {
const char *btn2Label, const char *btn3Label,
const char *btn4Label) {
gprintf("\nWindowExitPrompt()"); gprintf("\nWindowExitPrompt()");
GuiSound * homein = NULL; GuiSound * homein = NULL;
@ -735,8 +733,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
snprintf(imgPath, sizeof(imgPath), "%sbattery_bar_red.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%sbattery_bar_red.png", CFG.theme_path);
GuiImageData batteryBarRed(imgPath, battery_bar_red_png); GuiImageData batteryBarRed(imgPath, battery_bar_red_png);
#ifdef HW_RVL
int i = 0, ret = 0, level; int i = 0, ret = 0, level;
char txt[3]; char txt[3];
GuiText * batteryTxt[4]; GuiText * batteryTxt[4];
@ -746,9 +742,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
for (i=0; i < 4; i++) { for (i=0; i < 4; i++) {
if (i == 0)
sprintf(txt, "P%d", i+1);
else
sprintf(txt, "P%d", i+1); sprintf(txt, "P%d", i+1);
batteryTxt[i] = new GuiText(txt, 22, (GXColor) {255,255,255, 255}); batteryTxt[i] = new GuiText(txt, 22, (GXColor) {255,255,255, 255});
@ -776,9 +769,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
batteryBtn[2]->SetPosition(388, 150); batteryBtn[2]->SetPosition(388, 150);
batteryBtn[3]->SetPosition(494, 150); batteryBtn[3]->SetPosition(494, 150);
#endif
GuiTrigger trigA; GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigB; GuiTrigger trigB;
@ -811,7 +801,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
GuiButton btn1(&btn1Img,&btn1OverImg, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2,0); GuiButton btn1(&btn1Img,&btn1OverImg, 0, 3, 0, 0, &trigA, &btnSoundOver, btnClick2,0);
btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50); btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
GuiText btn2Txt(btn1Label, 28, (GXColor) {0, 0, 0, 255}); GuiText btn2Txt(tr("Back to Loader"), 28, (GXColor) {0, 0, 0, 255});
GuiImage btn2Img(&button); GuiImage btn2Img(&button);
if (Settings.wsprompt == yes) { if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen); btn2Txt.SetWidescreen(CFG.widescreen);
@ -824,7 +814,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
btn2.SetPosition(-150, 0); btn2.SetPosition(-150, 0);
GuiText btn3Txt(btn2Label, 28, (GXColor) {0, 0, 0, 255}); GuiText btn3Txt(tr("Wii Menu"), 28, (GXColor) {0, 0, 0, 255});
GuiImage btn3Img(&button); GuiImage btn3Img(&button);
if (Settings.wsprompt == yes) { if (Settings.wsprompt == yes) {
btn3Txt.SetWidescreen(CFG.widescreen); btn3Txt.SetWidescreen(CFG.widescreen);
@ -859,12 +849,10 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
promptWindow.Append(&titleTxt); promptWindow.Append(&titleTxt);
promptWindow.Append(&wiimoteImg); promptWindow.Append(&wiimoteImg);
#ifdef HW_RVL
promptWindow.Append(batteryBtn[0]); promptWindow.Append(batteryBtn[0]);
promptWindow.Append(batteryBtn[1]); promptWindow.Append(batteryBtn[1]);
promptWindow.Append(batteryBtn[2]); promptWindow.Append(batteryBtn[2]);
promptWindow.Append(batteryBtn[3]); promptWindow.Append(batteryBtn[3]);
#endif
HaltGui(); HaltGui();
mainWindow->SetState(STATE_DISABLED); mainWindow->SetState(STATE_DISABLED);
@ -875,7 +863,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
while (choice == -1) { while (choice == -1) {
VIDEO_WaitVSync(); VIDEO_WaitVSync();
#ifdef HW_RVL
for (i=0; i < 4; i++) { for (i=0; i < 4; i++) {
if (WPAD_Probe(i, NULL) == WPAD_ERR_NONE) { // controller connected if (WPAD_Probe(i, NULL) == WPAD_ERR_NONE) { // controller connected
level = (userInput[i].wpad.battery_level / 100.0) * 4; level = (userInput[i].wpad.battery_level / 100.0) * 4;
@ -897,7 +884,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
batteryBtn[i]->SetAlpha(70); batteryBtn[i]->SetAlpha(70);
} }
} }
#endif
if (shutdown == 1) { if (shutdown == 1) {
@ -915,10 +901,10 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
#ifdef HW_RVL
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
#endif
} else if (btn4.GetState() == STATE_SELECTED) { } else if (btn4.GetState() == STATE_SELECTED) {
wiimoteImg.SetPosition(50,165); wiimoteImg.SetPosition(50,165);
} else if (btn2.GetState() == STATE_CLICKED) { } else if (btn2.GetState() == STATE_CLICKED) {
@ -952,10 +938,10 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); btn3.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50);
wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
#ifdef HW_RVL
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50);
#endif
choice = 0; choice = 0;
} else if (btn4.GetState() != STATE_SELECTED) { } else if (btn4.GetState() != STATE_SELECTED) {
wiimoteImg.SetPosition(50,210); wiimoteImg.SetPosition(50,210);

View File

@ -16,7 +16,7 @@ int WindowPrompt(const char *title, const char *msg = NULL, const char *btn1Labe
void WindowCredits(); void WindowCredits();
int OnScreenKeyboard(char * var, u32 maxlen, int min); int OnScreenKeyboard(char * var, u32 maxlen, int min);
int WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, const char *btn3Label, const char *btn4Label); int WindowExitPrompt();
int GameWindowPrompt(); int GameWindowPrompt();
int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait); int DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait);
int FormatingPartition(const char *title, partitionEntry *entry); int FormatingPartition(const char *title, partitionEntry *entry);

View File

@ -683,7 +683,7 @@ int MenuSettings()
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -928,7 +928,7 @@ int MenuSettings()
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -992,7 +992,7 @@ int MenuSettings()
if (++Settings.cios >= settings_cios_max) { if (++Settings.cios >= settings_cios_max) {
Settings.cios = 0; Settings.cios = 0;
} }
if (Settings.cios != 0) { if (Settings.cios != 0 && ios222rev!=4) {
WindowPrompt(tr("Hermes CIOS"),tr("USB Loader GX will only run with Hermes CIOS rev 4! Please make sure you have revision 4 installed!"),tr("OK")); WindowPrompt(tr("Hermes CIOS"),tr("USB Loader GX will only run with Hermes CIOS rev 4! Please make sure you have revision 4 installed!"),tr("OK"));
} }
} }
@ -1101,7 +1101,7 @@ int MenuSettings()
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -1273,7 +1273,7 @@ int MenuSettings()
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -1454,7 +1454,7 @@ int MenuSettings()
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -1587,7 +1587,6 @@ int MenuSettings()
CFG_LoadGlobal(); CFG_LoadGlobal();
ResumeGui(); ResumeGui();
menu = MENU_SETTINGS; menu = MENU_SETTINGS;
#ifdef HW_RVL
snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer1_point.png", CFG.theme_path);
pointer[0] = new GuiImageData(imgPath, player1_point_png); pointer[0] = new GuiImageData(imgPath, player1_point_png);
snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer2_point.png", CFG.theme_path);
@ -1596,7 +1595,6 @@ int MenuSettings()
pointer[2] = new GuiImageData(imgPath, player3_point_png); pointer[2] = new GuiImageData(imgPath, player3_point_png);
snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path);
pointer[3] = new GuiImageData(imgPath, player4_point_png); pointer[3] = new GuiImageData(imgPath, player4_point_png);
#endif
if (CFG.widescreen) if (CFG.widescreen)
snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path);
else else
@ -2038,7 +2036,7 @@ int MenuSettings()
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
@ -2418,7 +2416,7 @@ int GameSettings(struct discHdr * header)
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -2682,7 +2680,7 @@ int GameSettings(struct discHdr * header)
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)
Sys_LoadMenu(); // Back to System Menu Sys_LoadMenu(); // Back to System Menu
@ -2882,7 +2880,7 @@ int GameSettings(struct discHdr * header)
cfg_save_global(); cfg_save_global();
optionBrowser2.SetState(STATE_DISABLED); optionBrowser2.SetState(STATE_DISABLED);
bgMusic->Pause(); bgMusic->Pause();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); choice = WindowExitPrompt();
bgMusic->Resume(); bgMusic->Resume();
if (choice == 3) if (choice == 3)

View File

@ -79,7 +79,7 @@ int Sys_ChangeIos(int ios) {
USBStorage_Deinit(); USBStorage_Deinit();
s32 ret = IOS_ReloadIOS(ios); s32 ret = IOS_ReloadIOSsafe(ios);
if (ret < 0) { if (ret < 0) {
ios = prevIos; ios = prevIos;
} }
@ -125,7 +125,7 @@ int Sys_IosReload(int IOS) {
if (IOS == 249 || IOS == 222 || IOS == 223) { if (IOS == 249 || IOS == 222 || IOS == 223) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
ret = IOS_ReloadIOS(IOS); ret = IOS_ReloadIOSsafe(IOS);
if (ret < 0) return ret; if (ret < 0) return ret;
if (IOS == 222 || IOS == 223) load_ehc_module(); if (IOS == 222 || IOS == 223) load_ehc_module();
ret = WBFS_Init(WBFS_DEVICE_USB); ret = WBFS_Init(WBFS_DEVICE_USB);
@ -206,3 +206,33 @@ void Sys_BackToLoader(void) {
bool Sys_IsHermes() { bool Sys_IsHermes() {
return IOS_GetVersion() == 222 || IOS_GetVersion() == 223; return IOS_GetVersion() == 222 || IOS_GetVersion() == 223;
} }
#include "wad/title.h"
s32 ios222rev = -69;
s32 ios249rev = -69;
s32 IOS_ReloadIOSsafe(int ios)
{
if (ios==222)
{
if (ios222rev == -69)
ios222rev = getIOSrev(0x00000001000000dell);
if (ios222rev != 4)return -2;
}
else if (ios==249)
{
if (ios249rev == -69)
ios249rev = getIOSrev(0x00000001000000f9ll);
if (!(ios249rev>=9 && ios249rev<65535))return -2;
}
return IOS_ReloadIOS(ios);
}

View File

@ -14,5 +14,9 @@ void Sys_BackToLoader(void);
int Sys_ChangeIos(int ios); int Sys_ChangeIos(int ios);
int Sys_IosReload(int IOS); int Sys_IosReload(int IOS);
bool Sys_IsHermes(); bool Sys_IsHermes();
s32 IOS_ReloadIOSsafe(int ios);
extern s32 ios222rev;
extern s32 ios249rev;
#endif #endif

View File

@ -361,6 +361,7 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
//u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1); //u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
//if (geckoattached)usb_flush(EXI_CHANNEL_1); //if (geckoattached)usb_flush(EXI_CHANNEL_1);
geckoinit = InitGecko();
/* Read apploader header */ /* Read apploader header */
ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET); ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET);

View File

@ -37,15 +37,11 @@ u32 frameCount = 0;
static void static void
UpdatePadsCB () { UpdatePadsCB () {
frameCount++; frameCount++;
#ifdef HW_RVL
WPAD_ScanPads(); WPAD_ScanPads();
#endif
PAD_ScanPads(); PAD_ScanPads();
for (int i=3; i >= 0; i--) { for (int i=3; i >= 0; i--) {
#ifdef HW_RVL
memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData));
#endif
userInput[i].chan = i; userInput[i].chan = i;
userInput[i].pad.btns_d = PAD_ButtonsDown(i); userInput[i].pad.btns_d = PAD_ButtonsDown(i);

View File

@ -10,6 +10,7 @@
#include "fatmounter.h" #include "fatmounter.h"
#include "id.h" #include "id.h"
#include "isfs.h" #include "isfs.h"
#include "../gecko.h"
#define MAX_TITLES 256 #define MAX_TITLES 256
@ -863,5 +864,87 @@ s32 WII_BootHBC()
return WII_LaunchTitle(tid); return WII_LaunchTitle(tid);
} }
tmd* getTMD(u64 tid){
static char filepath[256] ATTRIBUTE_ALIGN(32);
static u8 tmd_buf[MAX_SIGNED_TMD_SIZE] ATTRIBUTE_ALIGN(32);
signed_blob *s_tmd = (signed_blob *)tmd_buf;
u32 tmd_size;
if (ES_GetDataDir(tid, filepath) < 0 )
return NULL;
if (ES_GetStoredTMDSize(tid, &tmd_size) < 0)
return NULL;
if (ES_GetStoredTMD(tid, s_tmd, tmd_size) < 0)
return NULL;
tmd *t = SIGNATURE_PAYLOAD(s_tmd);
return t;
}
//some pune magic to make sure we don't try to load a stubbed IOS for those idiots that don't know what theyre doing
s32 getIOSrev(u64 req)
{
gprintf("\n\tgetIOSrev(%016llx)",req);
u32 tmdsize;
u64 tid = 0;
u64 *list;
u32 titlecount;
s32 ret;
u32 i;
ret = ES_GetNumTitles(&titlecount);
if(ret < 0)
{
ret = WII_EINTERNAL;
goto out;
}
list = memalign(32, titlecount * sizeof(u64) + 32);
ret = ES_GetTitles(list, titlecount);
if(ret < 0) {
free(list);
ret = WII_EINTERNAL;
goto out;
}
for(i=0; i<titlecount; i++) {
if (list[i]==req)
{
tid = list[i];
break;
}
}
free(list);
if(!tid)
{
ret = WII_EINSTALL;
goto out;
}
if(ES_GetStoredTMDSize(tid, &tmdsize) < 0)
{
ret = WII_EINSTALL;
goto out;
}
tmd *tmd = getTMD(tid);
if(tmd->title_version<255)
{
ret = tmd->title_version;
}
out:
gprintf(" = %d",ret);
return ret;
// TITLE_ID(0x00000001,0x000000de)
}

View File

@ -67,6 +67,9 @@ int CheckForSave(const char *gameID);
//boot HBC in either HAXX or JODI locations //boot HBC in either HAXX or JODI locations
s32 WII_BootHBC(); s32 WII_BootHBC();
//get the rev of a ISO and such without having to load it
s32 getIOSrev(u64 req);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -49,13 +49,11 @@ bool IsWpadConnected() {
int i = 0; int i = 0;
u32 test = 0; u32 test = 0;
int notconnected = 0; int notconnected = 0;
#ifdef HW_RVL
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER) { if (WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER) {
notconnected++; notconnected++;
} }
} }
#endif
if (notconnected < 4) if (notconnected < 4)
return true; return true;
else else
@ -67,16 +65,12 @@ u32 ButtonsHold(void) {
int i; int i;
u32 buttons = 0; u32 buttons = 0;
#ifdef HW_RVL
WPAD_ScanPads(); WPAD_ScanPads();
#endif
PAD_ScanPads(); PAD_ScanPads();
for (i=3; i >= 0; i--) { for (i=3; i >= 0; i--) {
buttons |= PAD_ButtonsHeld(i); buttons |= PAD_ButtonsHeld(i);
#ifdef HW_RVL
buttons |= WPAD_ButtonsHeld(i); buttons |= WPAD_ButtonsHeld(i);
#endif
} }
return buttons; return buttons;
} }
@ -86,16 +80,12 @@ u32 ButtonsPressed(void) {
int i; int i;
u32 buttons = 0; u32 buttons = 0;
#ifdef HW_RVL
WPAD_ScanPads(); WPAD_ScanPads();
#endif
PAD_ScanPads(); PAD_ScanPads();
for (i=3; i >= 0; i--) { for (i=3; i >= 0; i--) {
buttons |= PAD_ButtonsDown(i); buttons |= PAD_ButtonsDown(i);
#ifdef HW_RVL
buttons |= WPAD_ButtonsDown(i); buttons |= WPAD_ButtonsDown(i);
#endif
} }
return buttons; return buttons;