diff --git a/HBC/META.XML b/HBC/META.XML index 30a4ea68..8a9eed5c 100644 --- a/HBC/META.XML +++ b/HBC/META.XML @@ -2,8 +2,8 @@ USB Loader GX USB Loader GX Team - 2.0 r1043 - 201101131909 + 2.0 r1044 + 201101141539 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/gui.pnproj b/gui.pnproj index 70ec811a..86d47f64 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/Controls/PartitionHandle.cpp b/source/Controls/PartitionHandle.cpp index 82da0edd..129ad5f8 100644 --- a/source/Controls/PartitionHandle.cpp +++ b/source/Controls/PartitionHandle.cpp @@ -332,7 +332,8 @@ void PartitionHandle::AddPartition(const char * name, u64 lba_start, u64 sec_cou { name = "WBFS"; part_type = 0xBF; //Override partition type on WBFS - sec_count = wbfs_ntohl(head->n_hd_sec); + //! correct sector size in physical sectors (512 bytes per sector) + sec_count = (u64) head->n_hd_sec * (u64) (1 << head->hd_sec_sz_s) / (u64) BYTES_PER_SECTOR; } else if(*((u16 *) (buffer + 0x1FE)) == 0x55AA) diff --git a/source/GameBootProcess.cpp b/source/GameBootProcess.cpp index b031a1ea..abebd1b2 100644 --- a/source/GameBootProcess.cpp +++ b/source/GameBootProcess.cpp @@ -1,4 +1,5 @@ #include "menu/menus.h" +#include "menu/WDMMenu.hpp" #include "mload/mload.h" #include "mload/mload_modules.h" #include "system/IosLoader.h" @@ -35,7 +36,7 @@ extern int mountMethod; static u32 BootPartition(char * dolpath, u8 videoselected, u8 languageChoice, u8 cheat, u8 vipatch, u8 patchcountrystring, u8 alternatedol, u32 alternatedoloffset, u32 returnTo, u8 fix002) { - gprintf("booting partition IOS %u v%u\n", IOS_GetVersion(), IOS_GetRevision()); + gprintf("booting partition IOS %u r%u\n", IOS_GetVersion(), IOS_GetRevision()); entry_point p_entry; s32 ret; u64 offset; @@ -140,6 +141,9 @@ int BootGame(const char * gameID) returnToLoaderGV = game_cfg->returnTo; } + if(alternatedol == 3) + alternatedoloffset = WDMMenu::GetAlternateDolOffset(); + if(iosChoice != IOS_GetVersion()) { gprintf("Reloading into game cIOS: %i...\n", iosChoice); @@ -230,7 +234,7 @@ int BootGame(const char * gameID) gprintf("Jumping to game entrypoint: 0x%08X.\n", AppEntrypoint); - return Disc_JumpToEntrypoint(videoChoice, enablecheat); + return Disc_JumpToEntrypoint(videoChoice, enablecheat, WDMMenu::GetDolParameter()); } WDVD_ClosePartition(); diff --git a/source/libs/libfat/libcustomfat.a b/source/libs/libfat/libcustomfat.a index 88a27524..9d2e32e3 100644 Binary files a/source/libs/libfat/libcustomfat.a and b/source/libs/libfat/libcustomfat.a differ diff --git a/source/libs/libwbfs/libwbfs.c b/source/libs/libwbfs/libwbfs.c index 57a4df82..abf4632b 100644 --- a/source/libs/libwbfs/libwbfs.c +++ b/source/libs/libwbfs/libwbfs.c @@ -631,8 +631,7 @@ u32 wbfs_extract_disc(wbfs_disc_t*d, rw_sector_callback_t write_dst_wii_sector, error: return 1; } -float wbfs_estimate_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, - partition_selector_t sel) +u64 wbfs_estimate_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, partition_selector_t sel) { u8 *b; int i; @@ -664,8 +663,6 @@ float wbfs_estimate_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, v b = (u8 *) info; read_src_wii_disc(callback_data, 0, 0x100, info->disc_header_copy); - //fprintf(stderr, "estimating %c%c%c%c%c%c %s...\n",b[0], b[1], b[2], b[3], b[4], b[5], b + 0x20); - for (i = 0; i < p->n_wbfs_sec_per_disc; i++) { if (block_used(used, i, wii_sec_per_wbfs_sect)) @@ -673,16 +670,15 @@ float wbfs_estimate_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, v tot++; } } - //memcpy(header, b,0x100); - - error: if (d) wd_close_disc(d); + error: + if (d) wd_close_disc(d); if (used) wbfs_free( used ); - if (info) wbfs_iofree( info ); - return tot * (((p->wbfs_sec_sz * 1.0) / p->hd_sec_sz) * 512); + return (u64) tot * (u64) p->wbfs_sec_sz; } + u32 wbfs_size_disc(wbfs_t*p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, partition_selector_t sel, u32 *comp_size, u32 *real_size) { diff --git a/source/libs/libwbfs/libwbfs.h b/source/libs/libwbfs/libwbfs.h index c115e5c0..6b712da3 100644 --- a/source/libs/libwbfs/libwbfs.h +++ b/source/libs/libwbfs/libwbfs.h @@ -215,7 +215,7 @@ extern "C" // remove some sanity checks void wbfs_set_force_mode(int force); - float wbfs_estimate_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, + u64 wbfs_estimate_disc(wbfs_t *p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, partition_selector_t sel); // compressed and real size u32 wbfs_size_disc(wbfs_t*p, read_wiidisc_callback_t read_src_wii_disc, void *callback_data, diff --git a/source/libs/libwbfs/wiidisc.c b/source/libs/libwbfs/wiidisc.c index 3c40eae6..74dd4768 100644 --- a/source/libs/libwbfs/wiidisc.c +++ b/source/libs/libwbfs/wiidisc.c @@ -169,7 +169,7 @@ static void do_files(wiidisc_t*d) if(get_fst && !d->extracted_buffer) { - d->extracted_buffer = malloc(fst_size); + d->extracted_buffer = wbfs_ioalloc(fst_size); memcpy(d->extracted_buffer, fst, fst_size); } @@ -264,6 +264,7 @@ static void do_disc(wiidisc_t*d) magic = _be32(b + 24); if (magic != 0x5D1C9EA3) { + wbfs_iofree( b ); wbfs_error( "not a wii disc" ); return; } diff --git a/source/menu/GameBrowseMenu.cpp b/source/menu/GameBrowseMenu.cpp index dac61328..bb61c558 100644 --- a/source/menu/GameBrowseMenu.cpp +++ b/source/menu/GameBrowseMenu.cpp @@ -26,6 +26,7 @@ #include "utils/ShowError.h" #include "utils/tools.h" #include "utils/PasswordCheck.h" +#include "WDMMenu.hpp" #include "gecko.h" #include "menus.h" #include "wpad.h" @@ -569,7 +570,7 @@ void GameBrowseMenu::ReloadBrowser() favoriteBtn->SetPosition(Settings.widescreen ? thInt("288 - list layout favorite btn pos x widescreen") : thInt("260 - list layout favorite btn pos x"), thInt("13 - list layout favorite btn pos y")); searchBtn->SetPosition(Settings.widescreen ? thInt("320 - list layout search btn pos x widescreen") : thInt("300 - list layout search btn pos x"), - thInt("13 - list layout search btn pos x")); + thInt("13 - list layout search btn pos y")); sortBtn->SetPosition(Settings.widescreen ? thInt("352 - list layout abc/sort btn pos x widescreen") : thInt("340 - list layout abc/sort btn pos x"), thInt("13 - list layout abc/sort btn pos y")); listBtn->SetPosition(Settings.widescreen ? thInt("384 - list layout list btn pos x widescreen") : thInt("380 - list layout list btn pos x"), @@ -1238,13 +1239,6 @@ int GameBrowseMenu::OpenClickedGame() u8 alternatedol = OFF; u8 ocarinaChoice = Settings.ocarina; - GameCFG* game_cfg = GameSettings.GetGameCFG(header->id); - if (game_cfg) - { - alternatedol = game_cfg->loadalternatedol; - ocarinaChoice = game_cfg->ocarina; - } - bool returnHere = true;// prompt to start game int choice = -1; @@ -1273,18 +1267,37 @@ int GameBrowseMenu::OpenClickedGame() if (choice == 1) { + bool RunGame = true; + wiilight(0); + + GameCFG* game_cfg = GameSettings.GetGameCFG(header->id); + if (game_cfg) + { + alternatedol = game_cfg->loadalternatedol; + ocarinaChoice = game_cfg->ocarina; + } + + if(alternatedol == 3) + if(WDMMenu::Show(header) == 0) + { + RunGame = false; + returnHere = true; + } + if (alternatedol == 2) CheckAlternativeDOL(IDfull); - if (ocarinaChoice != OFF) + if (RunGame && ocarinaChoice != OFF) CheckOcarina(IDfull); - wiilight(0); - GameStatistics.SetPlayCount(header->id, GameStatistics.GetPlayCount(header->id)+1); - GameStatistics.Save(); + if(RunGame) + { + GameStatistics.SetPlayCount(header->id, GameStatistics.GetPlayCount(header->id)+1); + GameStatistics.Save(); - //Just calling that shuts down everything and starts game - BootGame(IDfull); + //Just calling that shuts down everything and starts game + BootGame(IDfull); + } } else if (choice == 2) { diff --git a/source/menu/WDMMenu.cpp b/source/menu/WDMMenu.cpp new file mode 100644 index 00000000..57689317 --- /dev/null +++ b/source/menu/WDMMenu.cpp @@ -0,0 +1,264 @@ +/**************************************************************************** + * Copyright (C) 2010 + * by Dimok + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any + * damages arising from the use of this software. + * + * Permission is granted to anyone to use this software for any + * purpose, including commercial applications, and to alter it and + * redistribute it freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you + * must not claim that you wrote the original software. If you use + * this software in a product, an acknowledgment in the product + * documentation would be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and + * must not be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + ***************************************************************************/ +#include +#include "WDMMenu.hpp" +#include "FileOperations/fileops.h" +#include "menu/menus.h" +#include "themes/CTheme.h" +#include "language/gettext.h" +#include "usbloader/wbfs.h" +#include "libs/libwbfs/libwbfs.h" +#include "libs/libwbfs/wiidisc.h" +#include "usbloader/fstfile.h" +#include "settings/GameTitles.h" +#include "gecko.h" + +u32 WDMMenu::AlternateDolOffset = 0; +u32 WDMMenu::AlternateDolParameter = 0; + +WDMMenu::WDMMenu(const struct discHdr * header) + : GuiWindow(screenwidth, screenheight) +{ + Options = new OptionList; + + btnOutline = Resources::GetImageData("button_dialogue_box.png"); + + trigA = new GuiTrigger(); + trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); + + trigB = new GuiTrigger(); + trigB->SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); + + defaultBtnTxt = new GuiText(tr("Default"), 22, (GXColor){0, 0, 0, 255}); + defaultBtnImg = new GuiImage(btnOutline); + defaultBtn = new GuiButton(defaultBtnImg, defaultBtnImg, 2, 3, 130, 400, trigA, btnSoundOver, btnSoundClick2, 1); + defaultBtn->SetLabel(defaultBtnTxt); + Append(defaultBtn); + + backBtnTxt = new GuiText(tr("Back"), 22, (GXColor){0, 0, 0, 255}); + backBtnImg = new GuiImage(btnOutline); + backBtn = new GuiButton(backBtnImg, backBtnImg, 2, 3, -130, 400, trigA, btnSoundOver, btnSoundClick2, 1); + backBtn->SetLabel(backBtnTxt); + backBtn->SetTrigger(trigB); + Append(backBtn); + + optionBrowser = new GuiCustomOptionBrowser(396, 280, Options, "bg_options_settings.png"); + optionBrowser->SetPosition(0, 90); + optionBrowser->SetAlignment(ALIGN_CENTRE, ALIGN_TOP); + Append(optionBrowser); + + SetEffect(EFFECT_FADE, 50); + + char WDMPath[200]; + snprintf(WDMPath, sizeof(WDMPath), "%s/%.3s.wdm", Settings.WDMpath, (char *) header->id); + + if(!CheckFile(WDMPath)) + { + snprintf(WDMPath, sizeof(WDMPath), "%s/%.6s.wdm", Settings.WDMpath, (char *) header->id); + if(!CheckFile(WDMPath)) + snprintf(WDMPath, sizeof(WDMPath), "%s/%.4s.wdm", Settings.WDMpath, (char *) header->id); + } + + wdmFile = new WDMFile(WDMPath); + + CheckGameFiles(header); +} + +WDMMenu::~WDMMenu() +{ + ResumeGui(); + + SetEffect(EFFECT_FADE, -50); + while(this->GetEffect() > 0) + usleep(100); + + HaltGui(); + if(parentElement) + ((GuiWindow *) parentElement)->Remove(this); + + RemoveAll(); + + delete btnOutline; + + delete backBtnTxt; + delete backBtnImg; + delete backBtn; + + delete defaultBtnTxt; + delete defaultBtnImg; + delete defaultBtn; + + delete trigA; + delete trigB; + + delete optionBrowser; + delete wdmFile; + + ResumeGui(); +} + +int WDMMenu::GetChoice() +{ + if (shutdown) + Sys_Shutdown(); + else if (reset) + Sys_Reboot(); + + if(backBtn->GetState() == STATE_CLICKED) + return 0; + + else if(defaultBtn->GetState() == STATE_CLICKED) + return 1; + + int choice = optionBrowser->GetClickedOption(); + if(choice >= 0 && choice < (int) DOLOffsetList.size()) + { + AlternateDolOffset = DOLOffsetList[choice].first; + AlternateDolParameter = DOLOffsetList[choice].second; + return 1; + } + + return -1; +} + +int WDMMenu::Show(const struct discHdr * header) +{ + WDMMenu Menu(header); + + mainWindow->SetState(STATE_DISABLED); + mainWindow->Append(&Menu); + + int ret = -1; + + while(ret == -1) + { + usleep(100); + ret = Menu.GetChoice(); + } + mainWindow->SetState(STATE_DEFAULT); + + return ret; +} + +static inline bool stringcompare(const char * replace, const char * dolname) +{ + if(strlen(replace) == 0 || strlen(dolname) == 0) + return false; + + for( ; *replace != 0 && *dolname != 0; replace++, dolname++) + { + if(*replace == '?') + continue; + + if(toupper((int) *replace) != toupper((int) *dolname)) + return false; + } + + return true; +} + +void WDMMenu::CheckGameFiles(const struct discHdr * header) +{ + wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) header->id); + if (!disc) + { + WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" )); + return; + } + + wiidisc_t *wdisc = wd_open_disc((int(*)(void *, u32, u32, void *)) wbfs_disc_read, disc); + if (!wdisc) + { + WindowPrompt(tr( "ERROR:" ), tr( "Could not open Disc" ), tr( "OK" )); + return; + } + + FST_ENTRY * fstbuffer = (FST_ENTRY *) wd_get_fst(wdisc, ONLY_GAME_PARTITION); + if (!fstbuffer) + { + WindowPrompt(tr( "ERROR:" ), tr( "Not enough free memory." ), tr( "OK" )); + return; + } + + wd_close_disc(wdisc); + WBFS_CloseDisc(disc); + + int position = 0; + vector > FilesNotInWDM; + + for(int i = 0; i < wdmFile->size(); ++i) + { + if(stringcompare(wdmFile->GetDolName(i), "main") == true) + { + DOLOffsetList.push_back(pair(0, wdmFile->GetParameter(i))); + Options->SetName(position, "%i.", position+1); + Options->SetValue(position, wdmFile->GetReplaceName(i)); + position++; + } + } + + for (u32 i = 1; i < fstbuffer[0].filelen; i++) + { + //don't add files that aren't .dol to the list + const char * filename = fstfiles(fstbuffer, i); + const char * fileext = NULL; + + if(filename) + fileext = strrchr(filename, '.'); + + if (fileext && strcasecmp(fileext, ".dol") == 0) + { + char NameCpy[strlen(filename)+1]; + strcpy(NameCpy, filename); + char *extension = strrchr(NameCpy, '.'); + if(extension) *extension = 0; + + int j; + for(j = 0; j < wdmFile->size(); ++j) + { + if(stringcompare(wdmFile->GetDolName(j), NameCpy) == true) + { + DOLOffsetList.push_back(pair(i, wdmFile->GetParameter(j))); + Options->SetName(position, "%i.", position+1); + Options->SetValue(position, wdmFile->GetReplaceName(j)); + position++; + break; + } + } + + if(j == wdmFile->size()) + FilesNotInWDM.push_back(pair(i, filename)); + } + } + + for(u32 i = 0; i < FilesNotInWDM.size(); ++i) + { + DOLOffsetList.push_back(pair(FilesNotInWDM[i].first, 1)); + Options->SetName(position, "%i.", position+1); + Options->SetValue(position, FilesNotInWDM[i].second.c_str()); + position++; + } + + free(fstbuffer); +} diff --git a/source/menu/WDMMenu.hpp b/source/menu/WDMMenu.hpp new file mode 100644 index 00000000..011d2b28 --- /dev/null +++ b/source/menu/WDMMenu.hpp @@ -0,0 +1,44 @@ +#ifndef WDMMENU_HPP_ +#define WDMMENU_HPP_ + +#include "libwiigui/gui.h" +#include "libwiigui/gui_customoptionbrowser.h" +#include "usbloader/disc.h" +#include "usbloader/WDMFile.hpp" + +class WDMMenu : public GuiWindow +{ + public: + WDMMenu(const struct discHdr * header); + ~WDMMenu(); + int GetChoice(); + static int Show(const struct discHdr * header); + static u32 GetAlternateDolOffset() { return AlternateDolOffset; } + static u32 GetDolParameter() { return AlternateDolParameter; } + private: + void CheckGameFiles(const struct discHdr * header); + + static u32 AlternateDolOffset; + static u32 AlternateDolParameter; + + WDMFile * wdmFile; + vector > DOLOffsetList; + GuiImageData * btnOutline; + + GuiTrigger * trigA; + GuiTrigger * trigB; + + OptionList * Options; + + GuiText * backBtnTxt; + GuiImage * backBtnImg; + GuiButton * backBtn; + + GuiText * defaultBtnTxt; + GuiImage * defaultBtnImg; + GuiButton * defaultBtn; + + GuiCustomOptionBrowser * optionBrowser; +}; + +#endif diff --git a/source/menu/menu_install.cpp b/source/menu/menu_install.cpp index d9962563..2a159662 100644 --- a/source/menu/menu_install.cpp +++ b/source/menu/menu_install.cpp @@ -7,7 +7,7 @@ #include "prompts/ProgressWindow.h" #include "themes/CTheme.h" -float gamesize = -1.0f; +u64 gamesize = 0; /**************************************************************************** * MenuInstall @@ -61,11 +61,11 @@ int MenuInstall() f32 freespace, used; WBFS_DiskSpace(&used, &freespace); - gamesize = WBFS_EstimeGameSize() / GB_SIZE; + gamesize = WBFS_EstimeGameSize(); char gametxt[50]; - sprintf(gametxt, "%s : %.2fGB", name, gamesize); + sprintf(gametxt, "%s : %.2fGB", name, gamesize/GB_SIZE); wiilight(1); choice = WindowPrompt(tr( "Continue to install game?" ), gametxt, tr( "OK" ), tr( "Cancel" )); @@ -74,10 +74,10 @@ int MenuInstall() { sprintf(gametxt, "%s", tr( "Installing game:" )); - if (gamesize > freespace) + if (gamesize/GB_SIZE > freespace) { char errortxt[50]; - sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB", tr( "Game Size" ), gamesize, tr( "Free Space" ), freespace); + sprintf(errortxt, "%s: %.2fGB, %s: %.2fGB", tr( "Game Size" ), gamesize/GB_SIZE, tr( "Free Space" ), freespace); WindowPrompt(tr( "Not enough free space!" ), errortxt, tr( "OK" )); } else @@ -112,7 +112,7 @@ int MenuInstall() //Turn off the WiiLight wiilight(0); - gamesize = -1.0f; + gamesize = 0; return MENU_DISCLIST; } diff --git a/source/prompts/DiscBrowser.cpp b/source/prompts/DiscBrowser.cpp index e48d27a1..7514acb9 100644 --- a/source/prompts/DiscBrowser.cpp +++ b/source/prompts/DiscBrowser.cpp @@ -75,9 +75,6 @@ int DiscBrowse(const char * GameID, char * alternatedname, int alternatedname_si const char * filename = fstfiles(fstbuffer, i); const char * fileext = NULL; - if(filename) - gprintf("%s\n", filename); - if(filename) fileext = strrchr(filename, '.'); diff --git a/source/prompts/ProgressWindow.cpp b/source/prompts/ProgressWindow.cpp index f2acf22e..3e0618fb 100644 --- a/source/prompts/ProgressWindow.cpp +++ b/source/prompts/ProgressWindow.cpp @@ -35,8 +35,6 @@ static bool showTime = false; static bool showSize = false; static bool changed = true; -extern float gamesize; - /**************************************************************************** * StartProgress ***************************************************************************/ @@ -143,16 +141,18 @@ static void UpdateProgressValues(GuiImage *progressbarImg, GuiText *prTxt, GuiTe if(!changed) return; + extern u64 gamesize; + LWP_MutexLock(ProgressMutex); changed = false; s64 done = progressDone; s64 total = progressTotal; u32 speed = 0; - if(gamesize > 0.0f) + if(gamesize > 0) { - done = (s64) ((float) done / (float) total * gamesize * GB_SIZE); - total = (s64) (gamesize * GB_SIZE); + done = (s64) ((double) done / (double) total * (double) gamesize); + total = (s64) gamesize; } //Calculate speed in KB/s @@ -161,13 +161,16 @@ static void UpdateProgressValues(GuiImage *progressbarImg, GuiText *prTxt, GuiTe LWP_MutexUnlock(ProgressMutex); - u32 TimeLeft = 0; + u32 TimeLeft = 0, h = 0, m = 0, s = 0; if(speed > 0) TimeLeft = (total-done)/speed; - u32 h = TimeLeft / 3600; - u32 m = (TimeLeft / 60) % 60; - u32 s = TimeLeft % 60; + if(TimeLeft > 0) + { + h = TimeLeft / 3600; + m = (TimeLeft / 60) % 60; + s = TimeLeft % 60; + } float progressPercent = 100.0 * done / total; diff --git a/source/settings/CSettings.cpp b/source/settings/CSettings.cpp index 5dd02872..f491e069 100644 --- a/source/settings/CSettings.cpp +++ b/source/settings/CSettings.cpp @@ -65,6 +65,7 @@ void CSettings::SetDefault() snprintf(TxtCheatcodespath, sizeof(TxtCheatcodespath), "%s/txtcodes/", BootDevice); snprintf(BcaCodepath, sizeof(BcaCodepath), "%s/bca/", BootDevice); snprintf(WipCodepath, sizeof(WipCodepath), "%s/wip/", BootDevice); + snprintf(WDMpath, sizeof(WDMpath), "%s/wdm/", BootDevice); snprintf(theme_path, sizeof(theme_path), "%stheme/", ConfigPath); snprintf(dolpath, sizeof(dolpath), "%s/", BootDevice); strcpy(theme, ""); @@ -112,7 +113,7 @@ void CSettings::SetDefault() InstallPartitions = ONLY_GAME_PARTITION; beta_upgrades = 0; PlaylogUpdate = 1; - UseIOS58 = 1; + UseIOS58 = 0; widescreen = (CONF_GetAspectRatio() == CONF_ASPECT_16_9); } @@ -236,6 +237,7 @@ bool CSettings::Save() fprintf(file, "Cheatcodespath = %s\n ", Cheatcodespath); fprintf(file, "BcaCodepath = %s\n ", BcaCodepath); fprintf(file, "WipCodepath = %s\n ", WipCodepath); + fprintf(file, "WDMpath = %s\n ", WDMpath); fprintf(file, "titlesOverride = %d\n ", titlesOverride); fprintf(file, "patchcountrystrings = %d\n ", patchcountrystrings); fprintf(file, "screensaver = %d\n ", screensaver); @@ -585,6 +587,11 @@ bool CSettings::SetSetting(char *name, char *value) strcpy(WipCodepath, value); return true; } + else if (strcmp(name, "WDMpath") == 0) + { + strcpy(WDMpath, value); + return true; + } else if (strcmp(name, "returnTo") == 0) { strcpy(returnTo, value); diff --git a/source/settings/CSettings.h b/source/settings/CSettings.h index f18057f5..932a4833 100644 --- a/source/settings/CSettings.h +++ b/source/settings/CSettings.h @@ -95,6 +95,7 @@ class CSettings char TxtCheatcodespath[100]; char BcaCodepath[100]; char WipCodepath[100]; + char WDMpath[100]; short error002; short titlesOverride; // db_titles char db_url[200]; diff --git a/source/settings/menus/CustomPathsSM.cpp b/source/settings/menus/CustomPathsSM.cpp index 7aec2e2e..e64216ae 100644 --- a/source/settings/menus/CustomPathsSM.cpp +++ b/source/settings/menus/CustomPathsSM.cpp @@ -47,6 +47,7 @@ CustomPathsSM::CustomPathsSM() Options->SetName(Idx++, tr("BCA Codes Path")); Options->SetName(Idx++, tr("WIP Patches Path")); Options->SetName(Idx++, tr("Languagefiles Path")); + Options->SetName(Idx++, tr("WDM Files Path")); SetOptionValues(); } @@ -93,6 +94,9 @@ void CustomPathsSM::SetOptionValues() //! Settings: Languagefiles Path Options->SetValue(Idx++, Settings.languagefiles_path); + + //! Settings: WDM Files Path + Options->SetValue(Idx++, Settings.WDMpath); } int CustomPathsSM::GetMenuInternal() @@ -205,6 +209,13 @@ int CustomPathsSM::GetMenuInternal() ChangePath(Settings.languagefiles_path, sizeof(Settings.languagefiles_path)); } + //! Settings: WDM Files Path + else if (ret == ++Idx) + { + titleTxt->SetText(tr( "WDM Files Path" )); + ChangePath(Settings.WDMpath, sizeof(Settings.WDMpath)); + } + //! Global set back of the titleTxt after a change titleTxt->SetText(tr( "Custom Paths" )); SetOptionValues(); diff --git a/source/settings/menus/GameLoadSM.cpp b/source/settings/menus/GameLoadSM.cpp index 6c538c19..e47452f0 100644 --- a/source/settings/menus/GameLoadSM.cpp +++ b/source/settings/menus/GameLoadSM.cpp @@ -83,6 +83,7 @@ static const char * AlternateDOLText[] = trNOOP( "OFF" ), trNOOP( "Select a DOL from Game" ), trNOOP( "Load From SD/USB" ), + trNOOP( "List on Gamelaunch" ), }; GameLoadSM::GameLoadSM(const char * GameID) @@ -326,7 +327,7 @@ int GameLoadSM::GetMenuInternal() //! Settings: Alternate DOL else if (ret == ++Idx) { - if (++GameConfig.loadalternatedol > 2) + if (++GameConfig.loadalternatedol > 3) GameConfig.loadalternatedol = 0; } diff --git a/source/settings/menus/LoaderSettings.cpp b/source/settings/menus/LoaderSettings.cpp index 0ffab998..e422de29 100644 --- a/source/settings/menus/LoaderSettings.cpp +++ b/source/settings/menus/LoaderSettings.cpp @@ -22,9 +22,11 @@ * distribution. ***************************************************************************/ #include +#include #include "LoaderSettings.hpp" #include "Controls/DeviceHandler.hpp" #include "settings/CSettings.h" +#include "prompts/ProgressWindow.h" #include "prompts/PromptWindows.h" #include "language/gettext.h" #include "wad/nandtitle.h" @@ -121,6 +123,7 @@ LoaderSettings::LoaderSettings() Options->SetName(Idx++, "%s", tr( "Install partitions" )); Options->SetName(Idx++, "%s", tr( "Return To" )); Options->SetName(Idx++, "%s", tr( "Messageboard Update" )); + Options->SetName(Idx++, "%s", tr( "Sync FAT32 FS Info" )); SetOptionValues(); @@ -206,6 +209,9 @@ void LoaderSettings::SetOptionValues() //! Settings: Messageboard Update Options->SetValue(Idx++, "%s", tr( OnOffText[Settings.PlaylogUpdate] )); + + //! Settings: Sync FAT32 FS Info + Options->SetValue(Idx++, " "); } int LoaderSettings::GetMenuInternal() @@ -365,6 +371,31 @@ int LoaderSettings::GetMenuInternal() if (++Settings.PlaylogUpdate >= MAX_ON_OFF) Settings.PlaylogUpdate = 0; } + //! Settings: Sync FAT32 FS Info + else if (ret == ++Idx ) + { + int choice = WindowPrompt(0, tr("Do you want to sync free space info sector on all FAT32 partitions?"), tr("Yes"), tr("Cancel")); + if(choice) + { + StartProgress(tr("Synchornizing..."), tr("Please wait..."), 0, false, false); + PartitionHandle * usb = DeviceHandler::Instance()->GetUSBHandle(); + for(int i = 0; i < usb->GetPartitionCount(); ++i) + { + ShowProgress(i, usb->GetPartitionCount()); + if(strncmp(usb->GetFSName(i), "FAT", 3) == 0) + { + struct statvfs stats; + char drive[20]; + snprintf(drive, sizeof(drive), "%s:/", usb->MountName(i)); + memset(&stats, 0, sizeof(stats)); + memcpy(&stats.f_flag, "SCAN", 4); + statvfs(drive, &stats); + } + } + ProgressStop(); + } + } + SetOptionValues(); return MENU_NONE; diff --git a/source/sys.cpp b/source/sys.cpp index 7cff1413..0a3111ea 100644 --- a/source/sys.cpp +++ b/source/sys.cpp @@ -68,6 +68,11 @@ void Sys_Init(void) void AppCleanUp(void) { + static bool app_clean = false; + if(app_clean) + return; + + app_clean = true; extern u8 mountMethod; gprintf("Exiting main GUI. mountMethod = %d\n", mountMethod); diff --git a/source/usbloader/GameList.cpp b/source/usbloader/GameList.cpp index 2e2e62b0..00942674 100644 --- a/source/usbloader/GameList.cpp +++ b/source/usbloader/GameList.cpp @@ -127,7 +127,15 @@ int GameList::FilterList(const wchar_t * gameFilter) if (Settings.GameSort & SORT_FAVORITE) { GameStatus * GameStats = GameStatistics.GetGameStatus(header->id); - if (!GameStats || GameStats->FavoriteRank == 0) continue; + if (Settings.marknewtitles) + { + bool isNew = NewTitles::Instance()->IsNew(header->id); + if (!isNew && (!GameStats || GameStats->FavoriteRank == 0)) continue; + } + else + { + if (!GameStats || GameStats->FavoriteRank == 0) continue; + } } //ignore uLoader cfg "iso". i was told it is "__CFG_" but not confirmed diff --git a/source/usbloader/WDMFile.cpp b/source/usbloader/WDMFile.cpp new file mode 100644 index 00000000..e57a6f2f --- /dev/null +++ b/source/usbloader/WDMFile.cpp @@ -0,0 +1,75 @@ +#include +#include +#include "WDMFile.hpp" + +static inline int GetNumber(const char * line) +{ + while(*line == ' ') line++; + + if(line[0] == '0' && (line[1] == 'x' || line[1] == 'X')) + return strtol(line, 0, 16); + else + return strtol(line, 0, 10); +} + +WDMFile::WDMFile(const char * path) +{ + FILE * file = fopen(path, "rb"); + if(!file) + return; + + char line[255]; + int entry_number = 0; + int counter = 0; + WDMEntry Entry; + + while (fgets(line, sizeof(line), file)) + { + if(line[0] == '#') + continue; + + entry_number++; + + if(entry_number < 3) + continue; + + if(counter == 0) + { + int strlength = strlen(line); + while(strlength > 0 && (line[strlength-1] == '\n' || line[strlength-1] == '\r' || line[strlength-1] == ' ')) + { + line[strlength-1] = '\0'; + strlength--; + } + + Entry.ReplaceName = line; + } + else if(counter == 1) + { + int strlength = strlen(line); + while(strlength > 0 && (line[strlength-1] == '\n' || line[strlength-1] == '\r' || line[strlength-1] == ' ')) + { + line[strlength-1] = '\0'; + strlength--; + } + + Entry.DolName = line; + } + else if(counter == 2) + { + Entry.Parameter = GetNumber(line); + WDMEntries.push_back(Entry); + } + else if(counter == 3) + { + //This is actually the place where submenus are described + //But we skip it because its never used + counter = 0; + continue; + } + + counter++; + } + + fclose(file); +} diff --git a/source/usbloader/WDMFile.hpp b/source/usbloader/WDMFile.hpp new file mode 100644 index 00000000..5d30bc34 --- /dev/null +++ b/source/usbloader/WDMFile.hpp @@ -0,0 +1,30 @@ +#ifndef WDMFILE_HPP_ +#define WDMFILE_HPP_ + +#include +#include +#include +#include + +using namespace std; + +class WDMFile +{ + public: + WDMFile(const char * filepath); + const char * GetDolName(int pos) const { if(pos >= 0 && pos < (int) WDMEntries.size()) return WDMEntries[pos].DolName.c_str(); else return NULL; }; + const char * GetReplaceName(int pos) const { if(pos >= 0 && pos < (int) WDMEntries.size()) return WDMEntries[pos].ReplaceName.c_str(); else return NULL; }; + int GetParameter(int pos) const { if(pos >= 0 && pos < (int) WDMEntries.size()) return WDMEntries[pos].Parameter; else return 0; }; + int size() const { return WDMEntries.size(); }; + private: + struct WDMEntry + { + string DolName; + string ReplaceName; + int Parameter; + }; + + vector WDMEntries; +}; + +#endif diff --git a/source/usbloader/apploader.c b/source/usbloader/apploader.c index b6082593..b9444062 100644 --- a/source/usbloader/apploader.c +++ b/source/usbloader/apploader.c @@ -130,7 +130,7 @@ s32 Apploader_Run(entry_point *entry, char * dolpath, u8 cheat, u8 videoSelected if (dolbuffer) free(dolbuffer); } - else if (alternatedol == 1) + else if ((alternatedol == 1 || alternatedol == 3) && alternatedoloffset != 0) { wip_reset_counter(); FST_ENTRY *fst = (FST_ENTRY *) *(u32 *) 0x80000038; diff --git a/source/usbloader/disc.c b/source/usbloader/disc.c index 8ce856d1..2fb998ce 100644 --- a/source/usbloader/disc.c +++ b/source/usbloader/disc.c @@ -269,7 +269,7 @@ s32 Disc_IsWii(void) return 0; } -s32 Disc_JumpToEntrypoint(u8 videoselected, bool enablecheat) +s32 Disc_JumpToEntrypoint(u8 videoselected, bool enablecheat, u32 dolparameter) { /* Set an appropiate video mode */ __Disc_SetVMode(videoselected); @@ -290,6 +290,9 @@ s32 Disc_JumpToEntrypoint(u8 videoselected, bool enablecheat) __IOS_ShutdownSubsystems(); __exception_closeall(); + /* Originally from tueidj - taken from NeoGamme (thx) */ + *(vu32*)0xCC003024 = dolparameter != 0 ? dolparameter : 1; + if (enablecheat) { __asm__( diff --git a/source/usbloader/disc.h b/source/usbloader/disc.h index 3cbc4025..68f42e73 100644 --- a/source/usbloader/disc.h +++ b/source/usbloader/disc.h @@ -53,7 +53,7 @@ extern "C" s32 __Disc_FindPartition(u64 *outbuf); void PatchCountryStrings(void *Address, int Size); s32 __Disc_FindPartition(u64 *outbuf); - s32 Disc_JumpToEntrypoint(u8 videoselected, bool enablecheat); + s32 Disc_JumpToEntrypoint(u8 videoselected, bool enablecheat, u32 dolparameter); #ifdef __cplusplus } diff --git a/source/usbloader/wbfs.cpp b/source/usbloader/wbfs.cpp index 45c6e14f..d14ae0a4 100644 --- a/source/usbloader/wbfs.cpp +++ b/source/usbloader/wbfs.cpp @@ -164,7 +164,7 @@ s32 WBFS_ReIDGame(u8 *discid, const void *newID) return retval; } -f32 WBFS_EstimeGameSize(void) +u64 WBFS_EstimeGameSize(void) { return current->EstimateGameSize(); } diff --git a/source/usbloader/wbfs.h b/source/usbloader/wbfs.h index 7fac2938..00b8d4bb 100644 --- a/source/usbloader/wbfs.h +++ b/source/usbloader/wbfs.h @@ -35,7 +35,7 @@ extern "C" s32 WBFS_DiskSpace(f32 *, f32 *); s32 WBFS_RenameGame(u8 *, const void *); s32 WBFS_ReIDGame(u8 *discid, const void *newID); - f32 WBFS_EstimeGameSize(void); + u64 WBFS_EstimeGameSize(void); int WBFS_GetFragList(u8 *id); diff --git a/source/usbloader/wbfs/wbfs_base.cpp b/source/usbloader/wbfs/wbfs_base.cpp index a567f3d2..0f42078c 100644 --- a/source/usbloader/wbfs/wbfs_base.cpp +++ b/source/usbloader/wbfs/wbfs_base.cpp @@ -61,7 +61,6 @@ s32 Wbfs::Init(u32 device) /* Device info */ nb_sectors = 0; - sector_size = SDHC_SECTOR_SIZE; } else return -1; break; diff --git a/source/usbloader/wbfs/wbfs_base.h b/source/usbloader/wbfs/wbfs_base.h index 0f3b01c2..c52a695f 100644 --- a/source/usbloader/wbfs/wbfs_base.h +++ b/source/usbloader/wbfs/wbfs_base.h @@ -34,7 +34,7 @@ class Wbfs virtual s32 DiskSpace(f32 *, f32 *) = 0; virtual s32 RenameGame(u8 *, const void *) = 0; virtual s32 ReIDGame(u8 *discid, const void *newID) = 0; - virtual f32 EstimateGameSize(void) = 0; + virtual u64 EstimateGameSize(void) = 0; protected: static u32 nb_sectors; wbfs_t *hdd; diff --git a/source/usbloader/wbfs/wbfs_fat.cpp b/source/usbloader/wbfs/wbfs_fat.cpp index 4a77d322..9507e250 100644 --- a/source/usbloader/wbfs/wbfs_fat.cpp +++ b/source/usbloader/wbfs/wbfs_fat.cpp @@ -318,7 +318,7 @@ s32 Wbfs_Fat::ReIDGame(u8 *discid, const void *newID) return ret; } -f32 Wbfs_Fat::EstimateGameSize() +u64 Wbfs_Fat::EstimateGameSize() { wbfs_t *part = NULL; u64 size = (u64) 143432 * 2 * 0x8000ULL; @@ -332,7 +332,12 @@ f32 Wbfs_Fat::EstimateGameSize() wii_sec_sz = part->wii_sec_sz; partition_selector_t part_sel = (partition_selector_t) Settings.InstallPartitions; - return wbfs_estimate_disc(part, __ReadDVD, NULL, part_sel); + + u64 estimated_size = wbfs_estimate_disc(part, __ReadDVD, NULL, part_sel); + + wbfs_close(part); + + return estimated_size; } // TITLE [GAMEID] diff --git a/source/usbloader/wbfs/wbfs_fat.h b/source/usbloader/wbfs/wbfs_fat.h index 5e3bc295..5ab31477 100644 --- a/source/usbloader/wbfs/wbfs_fat.h +++ b/source/usbloader/wbfs/wbfs_fat.h @@ -29,7 +29,7 @@ class Wbfs_Fat: public Wbfs s32 RenameGame(u8 *, const void *); s32 ReIDGame(u8 *, const void *); - f32 EstimateGameSize(); + u64 EstimateGameSize(); int GetFragList(u8 *); virtual bool ShowFreeSpace(void); diff --git a/source/usbloader/wbfs/wbfs_rw.c b/source/usbloader/wbfs/wbfs_rw.c index 827a38d3..08343352 100644 --- a/source/usbloader/wbfs/wbfs_rw.c +++ b/source/usbloader/wbfs/wbfs_rw.c @@ -10,15 +10,11 @@ /* Constants */ #define MAX_NB_SECTORS 32 -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) -{ - sector_size = size; -} +static const u32 sector_size = 512; s32 __ReadDVD(void *fp, u32 lba, u32 len, void *iobuf) { diff --git a/source/usbloader/wbfs/wbfs_rw.h b/source/usbloader/wbfs/wbfs_rw.h index 5fe6e42a..5faac3b1 100644 --- a/source/usbloader/wbfs/wbfs_rw.h +++ b/source/usbloader/wbfs/wbfs_rw.h @@ -8,7 +8,6 @@ extern "C" #include "libs/libwbfs/libwbfs.h" - extern u32 sector_size; extern rw_sector_callback_t readCallback; extern rw_sector_callback_t writeCallback; extern const DISC_INTERFACE * currentHandle; diff --git a/source/usbloader/wbfs/wbfs_wbfs.cpp b/source/usbloader/wbfs/wbfs_wbfs.cpp index 586de99e..ba810d5d 100644 --- a/source/usbloader/wbfs/wbfs_wbfs.cpp +++ b/source/usbloader/wbfs/wbfs_wbfs.cpp @@ -4,24 +4,31 @@ #include "usbloader/wbfs.h" #include "wbfs_rw.h" -extern u32 sector_size; extern int wbfs_part_fs; s32 Wbfs_Wbfs::Open() { wbfs_t *part = NULL; + u8 buffer[512]; + memset(buffer, 0, sizeof(buffer)); + + wbfs_head_t *head = (wbfs_head_t *) buffer; + + if(readCallback(NULL, lba, 1, buffer) < 0) + return -1; + + if (head->magic != wbfs_htonl(WBFS_MAGIC)) + return -1; + /* Open partition */ - part = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, size, lba, 0); + part = wbfs_open_partition(readCallback, writeCallback, NULL, 512, head->n_hd_sec, lba, 0); if (!part) return -1; /* Close current hard disk */ Close(); hdd = part; - // Save the new sector size, so it will be used in read and write calls - sector_size = 1 << hdd->head->hd_sec_sz_s; - wbfs_part_fs = PART_FS_WBFS; return 0; @@ -61,7 +68,7 @@ s32 Wbfs_Wbfs::Format() wbfs_t *partition = NULL; /* Reset partition */ - partition = wbfs_open_partition(readCallback, writeCallback, NULL, sector_size, size, lba, 1); + partition = wbfs_open_partition(readCallback, writeCallback, NULL, 512, size, lba, 1); if (!partition) return -1; /* Free memory */ @@ -176,7 +183,7 @@ s32 Wbfs_Wbfs::ReIDGame(u8 *discid, const void *newID) return 0; } -f32 Wbfs_Wbfs::EstimateGameSize() +u64 Wbfs_Wbfs::EstimateGameSize() { partition_selector_t part_sel = (partition_selector_t) Settings.InstallPartitions; return wbfs_estimate_disc(hdd, __ReadDVD, NULL, part_sel); diff --git a/source/usbloader/wbfs/wbfs_wbfs.h b/source/usbloader/wbfs/wbfs_wbfs.h index 5ba702ca..a013d31c 100644 --- a/source/usbloader/wbfs/wbfs_wbfs.h +++ b/source/usbloader/wbfs/wbfs_wbfs.h @@ -29,7 +29,7 @@ class Wbfs_Wbfs: public Wbfs s32 RenameGame(u8 *, const void *); s32 ReIDGame(u8 *, const void *); - f32 EstimateGameSize(); + u64 EstimateGameSize(); int GetFragList(u8 *id); };