diff --git a/HBC/META.XML b/HBC/META.XML index 23fdac8d..5064d166 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 2.0 r1040 - 201101091911 + 2.0 r1041 + 201101111755 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. diff --git a/source/Controls/DeviceHandler.cpp b/source/Controls/DeviceHandler.cpp index 3caf5a17..35486740 100644 --- a/source/Controls/DeviceHandler.cpp +++ b/source/Controls/DeviceHandler.cpp @@ -133,14 +133,24 @@ bool DeviceHandler::MountSD() return sd->Mount(0, DeviceName[SD], true); } +const DISC_INTERFACE * DeviceHandler::GetUSBInterface() +{ + if(IOS_GetVersion() < 200) + return &__io_usbstorage; + + return &__io_usbstorage2; +} + static inline bool USBSpinUp() { bool started = false; int retries = 400; + + const DISC_INTERFACE * handle = DeviceHandler::GetUSBInterface(); // wait 20 sec for the USB to spin up...stupid slow ass HDD do { - started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted()); + started = (handle->startup() && handle->isInserted()); if(started) break; usleep(50000); } @@ -155,7 +165,7 @@ bool DeviceHandler::MountUSB(int pos, bool spinup) return false; if(!usb) - usb = new PartitionHandle(&__io_usbstorage2); + usb = new PartitionHandle(GetUSBInterface()); if(usb->GetPartitionCount() < 1) { @@ -176,7 +186,7 @@ bool DeviceHandler::MountAllUSB(bool spinup) return false; if(!usb) - usb = new PartitionHandle(&__io_usbstorage2); + usb = new PartitionHandle(GetUSBInterface()); bool result = false; diff --git a/source/Controls/DeviceHandler.hpp b/source/Controls/DeviceHandler.hpp index 2ac294e9..36a1fe09 100644 --- a/source/Controls/DeviceHandler.hpp +++ b/source/Controls/DeviceHandler.hpp @@ -76,12 +76,13 @@ class DeviceHandler void UnMountSD() { if(sd) delete sd; sd = NULL; }; void UnMountUSB(int pos); void UnMountAllUSB(); - PartitionHandle * GetSDHandle() { return sd; }; - PartitionHandle * GetUSBHandle() { return usb; }; + PartitionHandle * GetSDHandle() const { return sd; }; + PartitionHandle * GetUSBHandle() const { return usb; }; static int GetUSBFilesystemType(int part); static int PathToDriveType(const char * path); static const char * GetFSName(int dev); static const char * PathToFSName(const char * path) { return GetFSName(PathToDriveType(path)); }; + static const DISC_INTERFACE * GetUSBInterface(); private: DeviceHandler() : sd(0), usb(0) { }; ~DeviceHandler(); diff --git a/source/FreeTypeGX.cpp b/source/FreeTypeGX.cpp index a2e89e1e..7c6fffab 100644 --- a/source/FreeTypeGX.cpp +++ b/source/FreeTypeGX.cpp @@ -67,7 +67,7 @@ FreeTypeGX::FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize) FT_New_Memory_Face(ftLibrary, (FT_Byte *) fontBuffer, bufferSize, 0, &ftFace); setVertexFormat(GX_VTXFMT1); - ftKerningEnabled = FT_HAS_KERNING( ftFace ); + ftKerningEnabled = false; } /** @@ -329,6 +329,7 @@ int16_t FreeTypeGX::getStyleOffsetHeight(int16_t format, uint16_t pixelSize) * @param textStyle Flags which specify any styling which should be applied to the rendered string. * @return The number of characters printed. */ + uint16_t FreeTypeGX::drawText(int16_t x, int16_t y, int16_t z, const wchar_t *text, int16_t pixelSize, GXColor color, uint16_t textStyle, uint16_t textWidth, uint16_t widthLimit) { diff --git a/source/GameBootProcess.cpp b/source/GameBootProcess.cpp index e3750399..b031a1ea 100644 --- a/source/GameBootProcess.cpp +++ b/source/GameBootProcess.cpp @@ -106,6 +106,9 @@ int BootGame(const char * gameID) delete dvdheader; dvdheader = NULL; + + gameList.clear(); + int ret = 0; u8 videoChoice = Settings.videomode; diff --git a/source/StartUpProcess.cpp b/source/StartUpProcess.cpp index badf6e89..0970f42a 100644 --- a/source/StartUpProcess.cpp +++ b/source/StartUpProcess.cpp @@ -91,15 +91,16 @@ bool StartUpProcess::USBSpinUp() { bool started = false; int retries = 400; + const DISC_INTERFACE * handle = DeviceHandler::GetUSBInterface(); // wait 10 sec for the USB to spin up...stupid slow ass HDD do { - started = (__io_usbstorage2.startup() && __io_usbstorage2.isInserted()); + started = (handle->startup() && handle->isInserted()); usleep(50000); if(retries < 400 && retries % 20 == 0) { - messageTxt->SetTextf("Waiting for slow HDD: %i sec left\n", retries/20); + messageTxt->SetTextf("Waiting for HDD: %i sec left\n", retries/20); Draw(); } } @@ -117,23 +118,6 @@ bool StartUpProcess::Run() bool StartUpProcess::Execute() { - //! Now we startup the GUI so no need for console prints. Output only to gecko. - USBGeckoOutput(); - - // Let's try loading some cIOS - if (IosLoader::LoadAppCios() < 0) - { - titleTxt->SetText("WARNING!"); - messageTxt->SetMaxWidth(400, WRAP); - messageTxt->SetText("USB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+. \ - We cannot determine the versions on your system, since you have no patched ios 36 or 236 installed. \ - Therefor, if loading of USB Loader GX fails, you probably have installed the 4.2 update, \ - and you should go figure out how to get some cios action going on\n\tin your Wii. \ - ERROR: No cIOS could be loaded. Exiting...."); - sleep(10); - Sys_BackToLoader(); - } - SetTextf("Initialize sd card\n"); DeviceHandler::Instance()->MountSD(); @@ -147,21 +131,21 @@ bool StartUpProcess::Execute() gprintf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed"); gprintf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed"); - if(Settings.cios != IOS_GetVersion()) + if(!Settings.UseIOS58 && Settings.cios != IOS_GetVersion()) { SetTextf("Loading cIOS %i\n", Settings.cios); - DeviceHandler::Instance()->UnMountAll(); + DeviceHandler::DestroyInstance(); // Loading now the cios setup in the settings IosLoader::LoadAppCios(); SetTextf("Loaded cIOS %i R%i\n", IOS_GetVersion(), IOS_GetRevision()); - DeviceHandler::Instance()->MountAll(); + DeviceHandler::Instance()->MountSD(); + USBSpinUp(); + DeviceHandler::Instance()->MountAllUSB(false); } - else - SetTextf("Loaded cIOS %i R%i\n", IOS_GetVersion(), IOS_GetRevision()); gprintf("\tLoading font...%s\n", Theme::LoadFont(Settings.theme_path) ? "done" : "failed (using default)"); gprintf("\tLoading theme...%s\n", Theme::Load(Settings.theme) ? "done" : "failed (using default)"); diff --git a/source/gecko.c b/source/gecko.c index 21bbf356..00af0293 100644 --- a/source/gecko.c +++ b/source/gecko.c @@ -20,9 +20,7 @@ void gprintf(const char *format, ...) va_start(va, format); if((vasprintf(&tmp, format, va) >= 0) && tmp) { - u32 level = IRQ_Disable(); usb_sendbuffer(1, tmp, strlen(tmp)); - IRQ_Restore(level); } va_end(va); @@ -36,11 +34,11 @@ bool InitGecko() if (geckoattached) { usb_flush(EXI_CHANNEL_1); - CON_EnableGecko(1, false); geckoinit = true; return true; } - else return false; + + return false; } char ascii(char s) @@ -79,12 +77,7 @@ void hexdump(void *d, int len) static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len) { if(geckoinit && ptr) - { - u32 level; - level = IRQ_Disable(); usb_sendbuffer(1, ptr, len); - IRQ_Restore(level); - } return len; } diff --git a/source/libwiigui/gui_text.cpp b/source/libwiigui/gui_text.cpp index b5c091e8..bd3bbcdf 100644 --- a/source/libwiigui/gui_text.cpp +++ b/source/libwiigui/gui_text.cpp @@ -402,8 +402,7 @@ void GuiText::ScrollText() { textDyn[pos][i] = text[i]; - currentWidth - += (font ? font : fontSystem)->getCharWidth(text[i], currentSize, i > 0 ? text[i - 1] : 0x0000); + currentWidth += (font ? font : fontSystem)->getCharWidth(text[i], currentSize, i > 0 ? text[i - 1] : 0x0000); ++i; } diff --git a/source/main.cpp b/source/main.cpp index b57c25dc..41b084c0 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -39,22 +39,6 @@ extern "C" static int QuickGameBoot(const char * gameID) { - //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 (IosLoader::LoadAppCios() < 0) - { - printf("\n\tWARNING!\n"); - printf("\tUSB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+\n\n"); - - printf("\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n"); - printf("\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,\n"); - printf("\tand you should go figure out how to get some cios action going on\n\tin your Wii.\n"); - - printf("\tERROR: No cIOS could be loaded. Exiting....\n"); - sleep(10); - Sys_BackToLoader(); - } - DeviceHandler::Instance()->MountAll(); Settings.Load(); @@ -64,10 +48,14 @@ static int QuickGameBoot(const char * gameID) int main(int argc, char *argv[]) { + if(IOS_GetVersion() != 58) + IOS_ReloadIOS(58); + MEM2_init(48); __exception_setreload(20); InitVideo(); InitGecko(); + USBGeckoOutput(); NandTitles.Get(); setlocale(LC_ALL, "en.UTF-8"); diff --git a/source/menu/GameBrowseMenu.cpp b/source/menu/GameBrowseMenu.cpp index 357d5bb9..dac61328 100644 --- a/source/menu/GameBrowseMenu.cpp +++ b/source/menu/GameBrowseMenu.cpp @@ -793,7 +793,12 @@ int GameBrowseMenu::MainLoop() bgMusic->Pause(); Settings.Save(); DeviceHandler::Instance()->MountSD(); - Settings.Load(); + gprintf("\tLoading config...%s\n", Settings.Load() ? "done" : "failed"); + gprintf("\tLoading language...%s\n", Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT) ? "done" : "failed"); + gprintf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed"); + gprintf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed"); + gprintf("\tLoading font...%s\n", Theme::LoadFont(Settings.theme_path) ? "done" : "failed (using default)"); + gprintf("\tLoading theme...%s\n", Theme::Load(Settings.theme) ? "done" : "failed (using default)"); bgMusic->Resume(); wString oldFilter(gameList.GetCurrentFilter()); gameList.FilterList(oldFilter.c_str()); diff --git a/source/settings/CSettings.cpp b/source/settings/CSettings.cpp index 9e349621..5dd02872 100644 --- a/source/settings/CSettings.cpp +++ b/source/settings/CSettings.cpp @@ -112,9 +112,8 @@ void CSettings::SetDefault() InstallPartitions = ONLY_GAME_PARTITION; beta_upgrades = 0; PlaylogUpdate = 1; + UseIOS58 = 1; widescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9); - - Theme::SetDefault(); //! We need to move this later } bool CSettings::Load() @@ -252,6 +251,7 @@ bool CSettings::Save() fprintf(file, "InstallPartitions = %08X\n ", InstallPartitions); fprintf(file, "beta_upgrades = %d\n ", beta_upgrades); fprintf(file, "PlaylogUpdate = %d\n ", PlaylogUpdate); + fprintf(file, "UseIOS58 = %d\n ", UseIOS58); fprintf(file, "returnTo = %s\n ", returnTo); fclose(file); @@ -495,6 +495,11 @@ bool CSettings::SetSetting(char *name, char *value) if (sscanf(value, "%d", &i) == 1) PlaylogUpdate = i; return true; } + else if (strcmp(name, "UseIOS58") == 0) + { + if (sscanf(value, "%d", &i) == 1) UseIOS58 = i; + return true; + } else if (strcmp(name, "InstallPartitions") == 0) { InstallPartitions = strtoul(value, 0, 16); diff --git a/source/settings/CSettings.h b/source/settings/CSettings.h index 71da6141..f18057f5 100644 --- a/source/settings/CSettings.h +++ b/source/settings/CSettings.h @@ -111,6 +111,7 @@ class CSettings short beta_upgrades; short PlaylogUpdate; short ShowFreeSpace; + short UseIOS58; char returnTo[20]; protected: bool ValidVersion(FILE * file); diff --git a/source/settings/menus/LoaderSettings.cpp b/source/settings/menus/LoaderSettings.cpp index 8723abcc..0ffab998 100644 --- a/source/settings/menus/LoaderSettings.cpp +++ b/source/settings/menus/LoaderSettings.cpp @@ -111,6 +111,7 @@ LoaderSettings::LoaderSettings() Options->SetName(Idx++, "%s", tr( "Game Language" )); Options->SetName(Idx++, "%s", tr( "Patch Country Strings" )); Options->SetName(Idx++, "%s", tr( "Ocarina" )); + Options->SetName(Idx++, "%s", tr( "Use IOS58" )); Options->SetName(Idx++, "%s", tr( "Boot/Standard" )); Options->SetName(Idx++, "%s", tr( "Partition" )); Options->SetName(Idx++, "%s", tr( "Install directories" )); @@ -158,6 +159,12 @@ void LoaderSettings::SetOptionValues() //! Settings: Ocarina Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.ocarina] )); + //! Settings: Use IOS58 + if (Settings.godmode) + Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.UseIOS58] )); + else + Options->SetValue(Idx++, "********"); + //! Settings: Boot/Standard if (Settings.godmode) Options->SetValue(Idx++, "IOS %i", Settings.cios); @@ -240,6 +247,15 @@ int LoaderSettings::GetMenuInternal() if (++Settings.ocarina >= MAX_ON_OFF) Settings.ocarina = 0; } + //! Settings: Use IOS58 + else if (ret == ++Idx) + { + if(!Settings.godmode) + return MENU_NONE; + + if (++Settings.UseIOS58 >= MAX_ON_OFF) Settings.UseIOS58 = 0; + } + //! Settings: Boot/Standard else if (ret == ++Idx) { diff --git a/source/sys.cpp b/source/sys.cpp index 77affd9b..1109108d 100644 --- a/source/sys.cpp +++ b/source/sys.cpp @@ -6,6 +6,7 @@ #include "Controls/DeviceHandler.hpp" #include "FileOperations/fileops.h" #include "settings/CSettings.h" +#include "settings/GameTitles.h" #include "settings/newtitles.h" #include "language/gettext.h" #include "network/networkops.h" @@ -81,12 +82,12 @@ void AppCleanUp(void) delete pointer[i]; gettextCleanUp(); - CloseXMLDatabase(); Theme::CleanUp(); NewTitles::DestroyInstance(); ThreadedTask::DestroyInstance(); SoundHandler::DestroyInstance(); DeinitNetwork(); + GameTitles.SetDefault(); ShutdownAudio(); diff --git a/source/system/IosLoader.cpp b/source/system/IosLoader.cpp index fdd818a0..370ec493 100644 --- a/source/system/IosLoader.cpp +++ b/source/system/IosLoader.cpp @@ -91,7 +91,7 @@ s32 IosLoader::LoadGameCios(s32 ios) // Unmount fat before reloading IOS. WBFS_Close(); WDVD_Close(); - DeviceHandler::Instance()->UnMountAll(); + DeviceHandler::DestroyInstance(); ret = ReloadIosSafe(ios); diff --git a/source/usbloader/alternatedol.c b/source/usbloader/alternatedol.c index 9e46c74b..6d770c7c 100644 --- a/source/usbloader/alternatedol.c +++ b/source/usbloader/alternatedol.c @@ -253,7 +253,7 @@ u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 languageChoice, u8 pa { ret = WDVD_Read(offset, len, (doloffset << 2) + pos); - gamepatches(offset, len, videoSelected, languageChoice, patchcountrystring, vipatch, cheat, returnTo, fix002); + gamepatches(offset, len, videoSelected, languageChoice, patchcountrystring, vipatch, cheat, returnTo, fix002); Remove_001_Protection(offset, len); diff --git a/source/usbloader/wbfs/wbfs_base.cpp b/source/usbloader/wbfs/wbfs_base.cpp index 962f683f..a567f3d2 100644 --- a/source/usbloader/wbfs/wbfs_base.cpp +++ b/source/usbloader/wbfs/wbfs_base.cpp @@ -4,6 +4,7 @@ #include #include +#include "Controls/DeviceHandler.hpp" #include "usbloader/sdhc.h" #include "usbloader/usbstorage2.h" #include "wbfs_rw.h" @@ -31,24 +32,23 @@ void Wbfs::GetProgressValue(s32 * d, s32 * m) s32 Wbfs::Init(u32 device) { s32 ret; + const DISC_INTERFACE * handle = DeviceHandler::GetUSBInterface(); switch (device) { case WBFS_DEVICE_USB: /* Initialize USB storage */ - ret = USBStorage2_Init(); - if (ret >= 0) + ret = handle->startup(); + if (ret) { + currentHandle = handle; /* Setup callbacks */ readCallback = __ReadUSB; writeCallback = __WriteUSB; - /* Device info */ - /* Get USB capacity */ - nb_sectors = USBStorage2_GetCapacity(§or_size); - if (!nb_sectors) return -1; } - else return ret; - break; + else + return -1; + break; case WBFS_DEVICE_SDHC: /* Initialize SDHC */ ret = SDHC_Init(); diff --git a/source/usbloader/wbfs/wbfs_rw.c b/source/usbloader/wbfs/wbfs_rw.c index 28610c60..827a38d3 100644 --- a/source/usbloader/wbfs/wbfs_rw.c +++ b/source/usbloader/wbfs/wbfs_rw.c @@ -13,6 +13,7 @@ u32 sector_size = 512; rw_sector_callback_t readCallback = NULL; rw_sector_callback_t writeCallback = NULL; +const DISC_INTERFACE * currentHandle = NULL; void SetSectorSize(u32 size) { @@ -82,8 +83,8 @@ s32 __ReadUSB(void *fp, u32 lba, u32 count, void *iobuf) if (sectors > MAX_NB_SECTORS) sectors = MAX_NB_SECTORS; /* USB read */ - ret = USBStorage2_ReadSectors(lba + cnt, sectors, ptr); - if (ret < 0) return ret; + ret = currentHandle->readSectors(lba + cnt, sectors, ptr); + if (!ret) return -1; /* Increment counter */ cnt += sectors; @@ -107,8 +108,8 @@ s32 __WriteUSB(void *fp, u32 lba, u32 count, void *iobuf) if (sectors > MAX_NB_SECTORS) sectors = MAX_NB_SECTORS; /* USB write */ - ret = USBStorage2_WriteSectors(lba + cnt, sectors, ptr); - if (ret < 0) return ret; + ret = currentHandle->writeSectors(lba + cnt, sectors, ptr); + if (!ret) return -1; /* Increment counter */ cnt += sectors; diff --git a/source/usbloader/wbfs/wbfs_rw.h b/source/usbloader/wbfs/wbfs_rw.h index 528765b0..5fe6e42a 100644 --- a/source/usbloader/wbfs/wbfs_rw.h +++ b/source/usbloader/wbfs/wbfs_rw.h @@ -11,6 +11,7 @@ extern "C" extern u32 sector_size; extern rw_sector_callback_t readCallback; extern rw_sector_callback_t writeCallback; + extern const DISC_INTERFACE * currentHandle; s32 __ReadDVD(void *fp, u32 lba, u32 len, void *iobuf); s32 __ReadUSB(void *fp, u32 lba, u32 count, void *iobuf);