From e6a87c05fefc3d828308bf975fdc9aa2fb7d6970 Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Sun, 16 Jan 2011 13:12:07 +0000 Subject: [PATCH] *Fixed display of partition size on WBFS partitions with a different wbfs sector size than 512bytes. *Made the ProgressWindow for game installation more accurate *Added displaying newly installed games (marked as new) on favorite list, so you don't have to change to full list when installing new games. (Thanks Cyan for the patch) *Lot's a small fixes *Added WDM Menu on game start. You can set it in the alternative DOL option (one new option there). The menu lists all DOLs on the disc and if a wdm file is provided in the WDM path (configurable in the settings) than the dol parameter and dol replacement name will be taken from the wdm. The DOLs that are not listed in the WDM but exist on the DISC will be listed at the end of the list. *Added avoid of multiple app cleanup when game fails to boot *Changed libfat to use FS info sector on FAT32 partitions. This speeds up the free space information getting to instant. For that the FS info sector has to have correct values. The values of all partitions where homebrews were writing to are currently incorrect because the official libfat does not support FS info sector (i submited a patch) (Windows does write it correct though). That is why there needs to be a synchronization of the FS info sector for partitions used with homebrews. For this purpose a new setting was added in the Loader Settings. You can synchronize all your FAT32 partitions on the USB with it once and you are done (if you don't write to that partition with current homebrews). After that you can enable free space display and it will be instant like on WBFS/NTFS/EXT partitions. --- HBC/META.XML | 4 +- gui.pnproj | 2 +- source/Controls/PartitionHandle.cpp | 3 +- source/GameBootProcess.cpp | 8 +- source/libs/libfat/libcustomfat.a | Bin 76172 -> 78528 bytes source/libs/libwbfs/libwbfs.c | 14 +- source/libs/libwbfs/libwbfs.h | 2 +- source/libs/libwbfs/wiidisc.c | 3 +- source/menu/GameBrowseMenu.cpp | 41 ++-- source/menu/WDMMenu.cpp | 264 +++++++++++++++++++++++ source/menu/WDMMenu.hpp | 44 ++++ source/menu/menu_install.cpp | 12 +- source/prompts/DiscBrowser.cpp | 3 - source/prompts/ProgressWindow.cpp | 21 +- source/settings/CSettings.cpp | 9 +- source/settings/CSettings.h | 1 + source/settings/menus/CustomPathsSM.cpp | 11 + source/settings/menus/GameLoadSM.cpp | 3 +- source/settings/menus/LoaderSettings.cpp | 31 +++ source/sys.cpp | 5 + source/usbloader/GameList.cpp | 10 +- source/usbloader/WDMFile.cpp | 75 +++++++ source/usbloader/WDMFile.hpp | 30 +++ source/usbloader/apploader.c | 2 +- source/usbloader/disc.c | 5 +- source/usbloader/disc.h | 2 +- source/usbloader/wbfs.cpp | 2 +- source/usbloader/wbfs.h | 2 +- source/usbloader/wbfs/wbfs_base.cpp | 1 - source/usbloader/wbfs/wbfs_base.h | 2 +- source/usbloader/wbfs/wbfs_fat.cpp | 9 +- source/usbloader/wbfs/wbfs_fat.h | 2 +- source/usbloader/wbfs/wbfs_rw.c | 6 +- source/usbloader/wbfs/wbfs_rw.h | 1 - source/usbloader/wbfs/wbfs_wbfs.cpp | 21 +- source/usbloader/wbfs/wbfs_wbfs.h | 2 +- 36 files changed, 577 insertions(+), 76 deletions(-) create mode 100644 source/menu/WDMMenu.cpp create mode 100644 source/menu/WDMMenu.hpp create mode 100644 source/usbloader/WDMFile.cpp create mode 100644 source/usbloader/WDMFile.hpp 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 88a275244e6f4a9d741a1a3f59130a0a9e684232..9d2e32e3a5d8a5bf6da32aca2420ee30126cd2f7 100644 GIT binary patch delta 8681 zcmcgx4|G&zcE8`ukWBty1{lb{VKO0+1cD?$lu45flM*15EJQNtW;LftmgvHQONu!< zb`#zJsV17$z{hbC3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2&$?iJ+O)GoXprrG)=eem4HWKH$T0fP~@=uSZuoDTvwjA~* zs|$|hvfN;ko#mu73nDzs_trcYZWfzHyxD@ic9s|C0@xHBwX?JgPhT$Cdl}_46-lKX z4x>+OCEN?H;FO&?nJZ{>1$W+>)7x& zwvNA>aCc<7-5tdnp6ci=v~)a@YdN@u@|&9LN}BdPaI0y5T}ek$gAaUcz*~y@7R^<* z;0Ba&U=7k_(38tnTWgP`*rUdEDwm-4aM!dv4at>IXdY24DV zejOi5UCVR!eji@tOaYQK^B2&JhDjJk$nmjDFm%Z4;G#9q9dr-4(G z%Hw$;R2X2&mnbeE3w}viC{%|34p=ZWA|si11}BSH>R0KfXy_QEPKr)s!9djN_$z?L z_~pn*W^d51jE4dW-k_k#+=eT9|x^35vUEki(MyR%V_bSycFCU4|3VyGY zt(R~6uT|!NSEyHq_-k0KUP@S`WEHN(dZ}=I?DZkOqf%A;X5E8oQ|z*$Ul84)?#rv# zLU*X9n$dj#+>E{0#FI(=v|u-4umR&#ykSfSPsU(lj}9J)!6tVU7F*cV9P5aK#wyb| z++-RI;Z#@%ufeBu@Yxug;MKvsF<5w{`p%=b5$b8Ccu!{u>~M7gnvKC?lc^sx4ErS~ zYHEf@jXi2ob~oUtMOle%EUc)0*%;0d;M1& 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); };