diff --git a/HBC/META.XML b/HBC/META.XML index 8464431a..5f44346f 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 1.0 r844 - 200911232251 + 1.0 r845 + 200912030058 Loads games from USB-devices 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. diff --git a/Makefile b/Makefile index c4493fc1..8a6cdde8 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map,--section-start,.init=0x80B00 #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lpngu -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -ltremor -lmad -lmxml -ljpeg +LIBS := -lpngu -lpng -lm -lz -lwiiuse -lbte -lasnd -logc -lfreetype -ltremor -lmad -lmxml -ljpeg #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib @@ -131,7 +131,6 @@ all: clean: @echo clean ... @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol - #--------------------------------------------------------------------------------- run: make @@ -148,7 +147,8 @@ reload: release: make cp boot.dol ./hbc/boot.dol - + + #--------------------------------------------------------------------------------- else diff --git a/gui.pnproj b/gui.pnproj index 870c5212..66257cb9 100644 --- a/gui.pnproj +++ b/gui.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/source/gecko.c b/source/gecko.c index ae654e5c..676a2b04 100644 --- a/source/gecko.c +++ b/source/gecko.c @@ -1,286 +1,30 @@ -/* - * 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 -#include -#include #include +#include +#include /* init-globals */ bool geckoinit = false; +bool textVideoInit = false; #ifndef NO_DEBUG +#include - -/* we use this so that we can do without the ctype library */ -#define is_digit(c) ((c) >= '0' && (c) <= '9') - -static int skip_atoi(const char **s) +//using the gprintf from crediar because it is smaller than mine +void gprintf( const char *str, ... ) { - int i=0; + if (!(geckoinit))return; - while (is_digit(**s)) - i = i*10 + *((*s)++) - '0'; - return i; -} + char astr[4096]; -#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' */ + va_list ap; + va_start(ap,str); -#define do_div(n,base) ({ \ -int __res; \ -__res = ((unsigned long) n) % (unsigned) base; \ -n = ((unsigned long) n) / (unsigned) base; \ -__res; }) + vsprintf( astr, str, ap ); -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; + va_end(ap); - 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 = ""; - - 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; -} - - + usb_sendbuffer_safe( 1, astr, strlen(astr) ); +} bool InitGecko() { @@ -293,21 +37,5 @@ bool InitGecko() 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 */ diff --git a/source/gecko.h b/source/gecko.h index 3bc0567c..83b55311 100644 --- a/source/gecko.h +++ b/source/gecko.h @@ -6,7 +6,6 @@ #ifdef __cplusplus extern "C" { #endif -//giantpune's functions for USB gecko #ifndef NO_DEBUG //use this just like printf(); diff --git a/source/homebrewboot/HomebrewBrowse.cpp b/source/homebrewboot/HomebrewBrowse.cpp index 74de3c9c..ea3bb3b4 100644 --- a/source/homebrewboot/HomebrewBrowse.cpp +++ b/source/homebrewboot/HomebrewBrowse.cpp @@ -770,7 +770,7 @@ int MenuHomebrewBrowse() { else if (homo.GetState() == STATE_CLICKED) { cfg_save_global(); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) { diff --git a/source/libwiigui/gui_searchbar.cpp b/source/libwiigui/gui_searchbar.cpp index 97683d15..12d0007a 100644 --- a/source/libwiigui/gui_searchbar.cpp +++ b/source/libwiigui/gui_searchbar.cpp @@ -122,7 +122,6 @@ void GuiSearchBar::Update(GuiTrigger * t) LOCK(this); if(_elements.size() == 0 || (state == STATE_DISABLED && parentElement)) return; - #ifdef HW_RVL // cursor if(t->wpad.ir.valid && state != STATE_DISABLED) { @@ -142,7 +141,6 @@ void GuiSearchBar::Update(GuiTrigger * t) mainWindow->SetState(STATE_DEFAULT); } } - #endif GuiWindow::Update(t); } wchar_t GuiSearchBar::GetClicked() diff --git a/source/main.cpp b/source/main.cpp index 86c72f1e..8fe4d0f5 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -16,6 +16,17 @@ #include #include #include +//#include +//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 +#include +#include +#include +#include +#include #include "libwiigui/gui.h" #include "usbloader/wbfs.h" @@ -36,10 +47,13 @@ #include "fat.h" #include "gecko.h" #include "svnrev.h" +#include "wad/title.h" #include "usbloader/partition_usbloader.h" #include "usbloader/usbstorage.h" extern bool geckoinit; +extern bool textVideoInit; +extern char headlessID[8]; /* Constants */ #define CONSOLE_XCOORD 260 @@ -76,9 +90,9 @@ static void BootUpProblems() time_t curtime; time_t endtime = time(0) + 30; do { - ret2 = IOS_ReloadIOS(249); + ret2 = IOS_ReloadIOSsafe(249); if (ret2 < 0) { - ret2 = IOS_ReloadIOS(222); + ret2 = IOS_ReloadIOSsafe(222); SDCard_Init(); load_ehc_module(); SDCard_deInit(); @@ -129,6 +143,9 @@ static void BootUpProblems() unsigned int *xfb = NULL; void InitTextVideo () { + + if (textVideoInit)return; + VIDEO_Init(); GXRModeObj *vmode = VIDEO_GetPreferredMode(NULL); // get default video mode @@ -150,21 +167,36 @@ void InitTextVideo () { VIDEO_WaitVSync (); if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync (); + + //send console output to the gecko + if (geckoinit)CON_EnableGecko(1, true); + textVideoInit = true; + } int main(int argc, char *argv[]) { // 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"); geckoinit = InitGecko(); + if (geckoinit)InitTextVideo(); gprintf("\x1b[2J"); gprintf("------------------"); gprintf("\nUSB Loader GX rev%s",GetRev()); - gprintf("\nmain(int argc, char *argv[])"); + gprintf("\nmain(%d", argc); + for (int i=1;i"); + gprintf(")"); - printf("Starting up\n"); + + printf("\n\tStarting up"); s32 ret; bool startupproblem = false; @@ -178,48 +210,67 @@ main(int argc, char *argv[]) { bootDevice_found = true; } - printf("Initializing controllers\n"); + printf("\n\tInitializing controllers"); /** PAD_Init has to be before InitVideo don't move that **/ 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") - printf("Reloading ios 249..."); - - ret = IOS_ReloadIOS(249); + gprintf("\n\tChecking for stub IOS"); + ios222rev = getIOSrev(0x00000001000000dell); + ios249rev = getIOSrev(0x00000001000000f9ll); - printf("%d\n", ret); + //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."); + + sleep(15); + printf("\n\n\tBye"); + exit(0); + } + + printf("\n\tReloading ios 249..."); + ret = IOS_ReloadIOSsafe(249); + + printf("%d", ret); if (ret < 0) { - printf("IOS 249 failed, reloading ios 222..."); - ret = IOS_ReloadIOS(222); - printf("%d\n", ret); + printf("\n\tIOS 249 failed, reloading ios 222..."); + ret = IOS_ReloadIOSsafe(222); + printf("%d", ret); if(ret < 0) { printf("\n\tERROR: cIOS could not be loaded!\n"); sleep(5); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } - printf("Initialize sd card\n"); + printf("\n\tInitialize sd card"); SDCard_Init(); - printf("Load ehc module\n"); + printf("\n\tLoad ehc module"); load_ehc_module(); - printf("deinit sd card\n"); + printf("\n\tdeinit sd card"); SDCard_deInit(); } - printf("Init wbfs..."); + printf("\n\tInit wbfs..."); ret = WBFS_Init(WBFS_DEVICE_USB); - printf("%d\n", ret); + printf("%d", ret); if (ret < 0) { - printf("You have issues with a slow disc, or a difficult disc\nReloading 222..."); - ret = IOS_ReloadIOS(222); - printf("%d\n", ret); + 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("Sleeping for 4 seconds\n"); + printf("\n\tSleeping for 4 seconds"); // sleep(4); InitVideo(); // Initialise video @@ -228,19 +279,19 @@ main(int argc, char *argv[]) { startupproblem = true; ret = 1; } - printf("Initialize sd card\n"); + printf("\n\tInitialize sd card"); SDCard_Init(); - printf("Load ehc module\n"); + printf("\n\tLoad ehc module"); load_ehc_module(); - printf("deinit sd card\n"); + printf("\n\tdeinit sd card"); SDCard_deInit(); - printf("Initialize wbfs..."); + printf("\n\tInitialize wbfs..."); ret = WBFS_Init(WBFS_DEVICE_USB); - printf("%d\n", ret); + printf("%d", ret); if(ret < 0) { - printf("Sleeping for 4 seconds\n"); + printf("\n\tSleeping for 4 seconds"); // sleep(4); InitVideo(); // Initialise video 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 - printf("Initialize usb device\n"); + printf("\n\tInitialize usb device"); USBDevice_Init(); // and mount USB:/ gprintf("\n\tSD and USB Init OK"); if (!bootDevice_found) { - printf("Search for configuration file\n"); + 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 @@ -266,43 +317,43 @@ main(int argc, char *argv[]) { || checkfile((char*) "USB:/apps/usbloader_gx/boot.dol")) strcpy(bootDevice, "USB:"); - printf("Configuration file is on %s\n", bootDevice); + printf("\n\tConfiguration file is on %s", bootDevice); } gettextCleanUp(); - printf("Loading configuration..."); + printf("\n\tLoading configuration..."); CFG_Load(); - printf("done\n"); - gprintf("\n\tbootDevice = %s",bootDevice); + printf("done"); +// gprintf("\n\tbootDevice = %s",bootDevice); /* Load Custom IOS */ 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 USBDevice_deInit();// unmount USB for reloading IOS USBStorage_Deinit(); - ret = IOS_ReloadIOS(222); - printf("%d\n", ret); + ret = IOS_ReloadIOSsafe(222); + printf("%d", ret); SDCard_Init(); load_ehc_module(); if (ret < 0) { SDCard_deInit(); Settings.cios = ios249; - ret = IOS_ReloadIOS(249); + ret = IOS_ReloadIOSsafe(249); } SDCard_Init(); // now mount SD:/ USBDevice_Init(); // and mount USB:/ WBFS_Init(WBFS_DEVICE_USB); } 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 USBDevice_deInit();// unmount USB for reloading IOS USBStorage_Deinit(); - ret = IOS_ReloadIOS(249); - printf("%d\n", ret); + ret = IOS_ReloadIOSsafe(249); + printf("%d", ret); if (ret < 0) { Settings.cios = ios222; - ret = IOS_ReloadIOS(222); + ret = IOS_ReloadIOSsafe(222); SDCard_Init(); load_ehc_module(); } @@ -314,16 +365,23 @@ main(int argc, char *argv[]) { // Partition_GetList(&partitions); if (ret < 0) { - printf("ERROR: cIOS could not be loaded!"); + printf("\nERROR: cIOS could not be loaded!"); sleep(5); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); } - gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision()); - printf("cIOS = %u (Rev %u)\n",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("\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>0&&argv[1]) + { + strcpy(headlessID,argv[1]); + } + //! Init the rest of the System Sys_Init(); Wpad_Init(); diff --git a/source/menu.cpp b/source/menu.cpp index 30e8ee8b..3f1e1ad6 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -21,6 +21,7 @@ #include "settings/cfg.h" #include "themes/Theme_Downloader.h" #include "usbloader/disc.h" +#include "usbloader/getentries.h" #include "wad/title.h" #include "xml/xml.h" #include "audio.h" @@ -51,6 +52,7 @@ GuiText * GameRegionTxt = NULL; GuiImage * coverImg = NULL; GuiImageData * cover = NULL; bool altdoldefault = true; +char headlessID[8] = {0}; static lwp_t guithread = LWP_THREAD_NULL; static bool guiHalt = true; @@ -72,8 +74,7 @@ extern u8 boothomebrew; * after finishing the removal/insertion of new elements, and after initial * GUI setup. ***************************************************************************/ -void -ResumeGui() { +void ResumeGui() { guiHalt = false; LWP_ResumeThread (guithread); } @@ -86,8 +87,8 @@ ResumeGui() { * This eliminates the possibility that the GUI is in the middle of accessing * an element that is being changed. ***************************************************************************/ -void -HaltGui() { +void HaltGui() { + if (guiHalt)return; guiHalt = true; // wait for thread to finish @@ -104,13 +105,13 @@ static void * UpdateGUI (void *arg) { while (1) { if (guiHalt) { LWP_SuspendThread(guithread); - } else { + } + else { if (!ExitRequested) { mainWindow->Draw(); if (Settings.tooltips == TooltipsOn && THEME.show_tooltip != 0 && mainWindow->GetState() != STATE_DISABLED) mainWindow->DrawTooltip(); -#ifdef HW_RVL for (int i=3; i >= 0; i--) { // so that player 1's cursor appears on top! if (userInput[i].wpad.ir.valid) 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); } } -#endif Menu_Render(); @@ -129,7 +129,8 @@ static void * UpdateGUI (void *arg) { } else { for (int a = 5; a < 255; a += 10) { - mainWindow->Draw(); + if (strcmp(headlessID,"")==0) + mainWindow->Draw(); Menu_DrawRectangle(0,0,screenwidth,screenheight,(GXColor) {0, 0, 0, a},1); Menu_Render(); } @@ -246,8 +247,10 @@ int MainMenu(int menu) { currentMenu = menu; char imgPath[100]; + + //if (strcmp(headlessID,"")!=0)HaltGui(); + //WindowPrompt("Can you see me now",0,"ok"); -#ifdef HW_RVL 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); @@ -256,7 +259,6 @@ int MainMenu(int menu) { pointer[2] = new GuiImageData(imgPath, player3_point_png); snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); pointer[3] = new GuiImageData(imgPath, player4_point_png); -#endif mainWindow = new GuiWindow(screenwidth, screenheight); @@ -270,7 +272,8 @@ int MainMenu(int menu) { bgImg = new GuiImage(background); mainWindow->Append(bgImg); - ResumeGui(); + if (strcmp(headlessID,"")==0) + ResumeGui(); bgMusic = new GuiSound(bg_music_ogg, bg_music_ogg_size, Settings.volume); bgMusic->SetLoop(1); //loop music @@ -311,20 +314,16 @@ int MainMenu(int menu) { } } + // MemInfoPrompt(); - //for testing - /*if (mountMethod) - { - char tmp[30]; - sprintf(tmp,"boot method --> %i",mountMethod); - WindowPrompt(0,tmp,0,0,0,0,100); - } - */ - gprintf("\nExiting main GUI"); + gprintf("\nExiting main GUI. mountMethod = %d",mountMethod); CloseXMLDatabase(); - NewTitles::DestroyInstance(); - ExitGUIThreads(); + 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(); delete bgMusic; delete background; @@ -360,15 +359,45 @@ int MainMenu(int menu) { WII_LaunchTitle(0x0000000100000100ULL); } - if (boothomebrew == 1) { + else if (boothomebrew == 1) { gprintf("\nBootHomebrew"); BootHomebrew(Settings.selected_homebrew); - } else if (boothomebrew == 2) { + } + else if (boothomebrew == 2) { gprintf("\nBootHomebrewFromMenu"); 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;iid[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; - struct discHdr *header = (mountMethod?dvdheader:&gameList[gameSelected]); + header = (mountMethod?dvdheader:&gameList[gameSelected]); 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); } - - return 0; + return 0; } diff --git a/source/menu/menu_check.cpp b/source/menu/menu_check.cpp index be187d9c..f1d50ae8 100644 --- a/source/menu/menu_check.cpp +++ b/source/menu/menu_check.cpp @@ -9,12 +9,14 @@ extern bool load_from_fat; extern char game_partition[6]; +extern char headlessID[8]; /**************************************************************************** * MenuCheck ***************************************************************************/ int MenuCheck() { gprintf("\nMenuCheck()"); + //WindowPrompt("test",0,"ok"); int menu = MENU_NONE; int i = 0; int choice; @@ -136,6 +138,9 @@ int MenuCheck() { //Spieleliste laden __Menu_GetEntries(0); + + if (strcmp(headlessID,"")!=0) + menu = MENU_EXIT; if (menu == MENU_NONE) menu = MENU_DISCLIST; diff --git a/source/menu/menu_disclist.cpp b/source/menu/menu_disclist.cpp index a00a1d9f..58b6c203 100644 --- a/source/menu/menu_disclist.cpp +++ b/source/menu/menu_disclist.cpp @@ -695,7 +695,7 @@ int MenuDiscList() { } else if (homeBtn.GetState() == STATE_CLICKED) { gprintf("\n\thomeBtn clicked"); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) { @@ -1475,7 +1475,6 @@ void rockout(int f) { int num=(f==2?-1:gameSelected); char imgPath[100]; -#ifdef HW_RVL if ((!(strcasestr(get_title(&gameList[num]),"guitar")|| strcasestr(get_title(&gameList[num]),"band")|| strcasestr(get_title(&gameList[num]),"rock")|| @@ -1503,6 +1502,5 @@ void rockout(int f) { snprintf(imgPath, sizeof(imgPath), "%srplayer4_point.png", CFG.theme_path); pointer[3] = new GuiImageData(imgPath, rplayer4_point_png); } -#endif ResumeGui(); } diff --git a/source/prompts/PromptWindows.cpp b/source/prompts/PromptWindows.cpp index b1d0950b..6696545c 100644 --- a/source/prompts/PromptWindows.cpp +++ b/source/prompts/PromptWindows.cpp @@ -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 * place. ***************************************************************************/ -int -WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, - const char *btn2Label, const char *btn3Label, - const char *btn4Label) { +int WindowExitPrompt() +{ gprintf("\nWindowExitPrompt()"); 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); GuiImageData batteryBarRed(imgPath, battery_bar_red_png); - -#ifdef HW_RVL int i = 0, ret = 0, level; char txt[3]; GuiText * batteryTxt[4]; @@ -746,10 +742,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, 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]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE); @@ -776,9 +769,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, batteryBtn[2]->SetPosition(388, 150); batteryBtn[3]->SetPosition(494, 150); - - -#endif GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); 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); 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); if (Settings.wsprompt == yes) { btn2Txt.SetWidescreen(CFG.widescreen); @@ -824,7 +814,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, 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); if (Settings.wsprompt == yes) { btn3Txt.SetWidescreen(CFG.widescreen); @@ -859,12 +849,10 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, promptWindow.Append(&titleTxt); promptWindow.Append(&wiimoteImg); -#ifdef HW_RVL promptWindow.Append(batteryBtn[0]); promptWindow.Append(batteryBtn[1]); promptWindow.Append(batteryBtn[2]); promptWindow.Append(batteryBtn[3]); -#endif HaltGui(); mainWindow->SetState(STATE_DISABLED); @@ -875,7 +863,6 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label, while (choice == -1) { VIDEO_WaitVSync(); -#ifdef HW_RVL for (i=0; i < 4; i++) { if (WPAD_Probe(i, NULL) == WPAD_ERR_NONE) { // controller connected 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); } } -#endif 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); titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); -#ifdef HW_RVL + for (int i = 0; i < 4; i++) batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); -#endif + } else if (btn4.GetState() == STATE_SELECTED) { wiimoteImg.SetPosition(50,165); } 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); titleTxt.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_OUT, 50); wiimoteImg.SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); -#ifdef HW_RVL + for (int i = 0; i < 4; i++) batteryBtn[i]->SetEffect(EFFECT_SLIDE_BOTTOM | EFFECT_SLIDE_OUT, 50); -#endif + choice = 0; } else if (btn4.GetState() != STATE_SELECTED) { wiimoteImg.SetPosition(50,210); diff --git a/source/prompts/PromptWindows.h b/source/prompts/PromptWindows.h index 3f1817e9..3620412d 100644 --- a/source/prompts/PromptWindows.h +++ b/source/prompts/PromptWindows.h @@ -16,7 +16,7 @@ int WindowPrompt(const char *title, const char *msg = NULL, const char *btn1Labe void WindowCredits(); 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 DiscWait(const char *title, const char *msg, const char *btn1Label, const char *btn2Label, int IsDeviceWait); int FormatingPartition(const char *title, partitionEntry *entry); diff --git a/source/settings/Settings.cpp b/source/settings/Settings.cpp index 75b118f7..17c7bd2f 100644 --- a/source/settings/Settings.cpp +++ b/source/settings/Settings.cpp @@ -683,7 +683,7 @@ int MenuSettings() cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -928,7 +928,7 @@ int MenuSettings() cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -992,7 +992,7 @@ int MenuSettings() if (++Settings.cios >= settings_cios_max) { 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")); } } @@ -1101,7 +1101,7 @@ int MenuSettings() cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -1273,7 +1273,7 @@ int MenuSettings() cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -1454,7 +1454,7 @@ int MenuSettings() cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -1587,7 +1587,6 @@ int MenuSettings() CFG_LoadGlobal(); ResumeGui(); menu = MENU_SETTINGS; - #ifdef HW_RVL 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); @@ -1596,7 +1595,6 @@ int MenuSettings() pointer[2] = new GuiImageData(imgPath, player3_point_png); snprintf(imgPath, sizeof(imgPath), "%splayer4_point.png", CFG.theme_path); pointer[3] = new GuiImageData(imgPath, player4_point_png); - #endif if (CFG.widescreen) snprintf(imgPath, sizeof(imgPath), "%swbackground.png", CFG.theme_path); else @@ -2038,7 +2036,7 @@ int MenuSettings() cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) @@ -2418,7 +2416,7 @@ int GameSettings(struct discHdr * header) cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -2682,7 +2680,7 @@ int GameSettings(struct discHdr * header) cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) Sys_LoadMenu(); // Back to System Menu @@ -2882,7 +2880,7 @@ int GameSettings(struct discHdr * header) cfg_save_global(); optionBrowser2.SetState(STATE_DISABLED); bgMusic->Pause(); - choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0); + choice = WindowExitPrompt(); bgMusic->Resume(); if (choice == 3) diff --git a/source/sys.cpp b/source/sys.cpp index 2396e828..9d4e4662 100644 --- a/source/sys.cpp +++ b/source/sys.cpp @@ -79,7 +79,7 @@ int Sys_ChangeIos(int ios) { USBStorage_Deinit(); - s32 ret = IOS_ReloadIOS(ios); + s32 ret = IOS_ReloadIOSsafe(ios); if (ret < 0) { ios = prevIos; } @@ -125,7 +125,7 @@ int Sys_IosReload(int IOS) { if (IOS == 249 || IOS == 222 || IOS == 223) { for (int i = 0; i < 10; i++) { - ret = IOS_ReloadIOS(IOS); + ret = IOS_ReloadIOSsafe(IOS); if (ret < 0) return ret; if (IOS == 222 || IOS == 223) load_ehc_module(); ret = WBFS_Init(WBFS_DEVICE_USB); @@ -206,3 +206,33 @@ void Sys_BackToLoader(void) { bool Sys_IsHermes() { 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); + +} diff --git a/source/sys.h b/source/sys.h index f2f0c2d0..6e72019d 100644 --- a/source/sys.h +++ b/source/sys.h @@ -14,5 +14,9 @@ void Sys_BackToLoader(void); int Sys_ChangeIos(int ios); int Sys_IosReload(int IOS); bool Sys_IsHermes(); +s32 IOS_ReloadIOSsafe(int ios); + +extern s32 ios222rev; +extern s32 ios249rev; #endif diff --git a/source/usbloader/apploader.c b/source/usbloader/apploader.c index 174f1b5d..394f0d40 100644 --- a/source/usbloader/apploader.c +++ b/source/usbloader/apploader.c @@ -361,6 +361,7 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 //u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1); //if (geckoattached)usb_flush(EXI_CHANNEL_1); + geckoinit = InitGecko(); /* Read apploader header */ ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET); diff --git a/source/video.cpp b/source/video.cpp index 4f549012..0b184363 100644 --- a/source/video.cpp +++ b/source/video.cpp @@ -37,15 +37,11 @@ u32 frameCount = 0; static void UpdatePadsCB () { frameCount++; -#ifdef HW_RVL WPAD_ScanPads(); -#endif PAD_ScanPads(); for (int i=3; i >= 0; i--) { -#ifdef HW_RVL memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData)); -#endif userInput[i].chan = i; userInput[i].pad.btns_d = PAD_ButtonsDown(i); diff --git a/source/wad/title.c b/source/wad/title.c index 8e493935..f28a9178 100644 --- a/source/wad/title.c +++ b/source/wad/title.c @@ -10,6 +10,7 @@ #include "fatmounter.h" #include "id.h" #include "isfs.h" +#include "../gecko.h" #define MAX_TITLES 256 @@ -863,5 +864,87 @@ s32 WII_BootHBC() 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; ititle_version<255) + { + ret = tmd->title_version; + } + +out: + gprintf(" = %d",ret); + return ret; +// TITLE_ID(0x00000001,0x000000de) +} diff --git a/source/wad/title.h b/source/wad/title.h index 7667256f..7086e34a 100644 --- a/source/wad/title.h +++ b/source/wad/title.h @@ -67,6 +67,9 @@ int CheckForSave(const char *gameID); //boot HBC in either HAXX or JODI locations s32 WII_BootHBC(); +//get the rev of a ISO and such without having to load it +s32 getIOSrev(u64 req); + #ifdef __cplusplus } #endif diff --git a/source/wpad.c b/source/wpad.c index 2801eae4..e4050e11 100644 --- a/source/wpad.c +++ b/source/wpad.c @@ -49,13 +49,11 @@ bool IsWpadConnected() { int i = 0; u32 test = 0; int notconnected = 0; -#ifdef HW_RVL for (i = 0; i < 4; i++) { if (WPAD_Probe(i, &test) == WPAD_ERR_NO_CONTROLLER) { notconnected++; } } -#endif if (notconnected < 4) return true; else @@ -67,16 +65,12 @@ u32 ButtonsHold(void) { int i; u32 buttons = 0; -#ifdef HW_RVL WPAD_ScanPads(); -#endif PAD_ScanPads(); for (i=3; i >= 0; i--) { buttons |= PAD_ButtonsHeld(i); -#ifdef HW_RVL buttons |= WPAD_ButtonsHeld(i); -#endif } return buttons; } @@ -86,16 +80,12 @@ u32 ButtonsPressed(void) { int i; u32 buttons = 0; -#ifdef HW_RVL WPAD_ScanPads(); -#endif PAD_ScanPads(); for (i=3; i >= 0; i--) { buttons |= PAD_ButtonsDown(i); -#ifdef HW_RVL buttons |= WPAD_ButtonsDown(i); -#endif } return buttons;