little optimization

This commit is contained in:
dimok321 2010-09-24 13:46:32 +00:00
parent 37c23c7676
commit f8c1692809
14 changed files with 186 additions and 204 deletions

View File

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

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\libfat" x="false"></e><e p="gui\source\prompts" x="false"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\libntfs" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\menu" x="false"></e><e p="gui\source\ramdisk" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e><e p="gui\source\memory" x="false"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e></ViewState></pd>
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\utils" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\libfat" x="false"></e><e p="gui\source\prompts" x="false"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\libntfs" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\menu" x="false"></e><e p="gui\source\ramdisk" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\system" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="false"></e><e p="gui\source\patches" x="false"></e><e p="gui\source\themes" x="false"></e><e p="gui\source\memory" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e></ViewState></pd>

View File

@ -6,30 +6,32 @@ extern "C"
{
#endif
extern int fat_sd_mount;
extern sec_t fat_sd_sec;
extern int fat_usb_mount;
extern sec_t fat_usb_sec;
extern int fat_wbfs_mount;
extern sec_t fat_wbfs_sec;
#include <gccore.h>
int USBDevice_Init();
void USBDevice_deInit();
int WBFSDevice_Init(u32 sector);
void WBFSDevice_deInit();
int isInserted(const char *path);
int SDCard_Init();
void SDCard_deInit();
extern int fat_sd_mount;
extern sec_t fat_sd_sec;
extern int fat_usb_mount;
extern sec_t fat_usb_sec;
extern int fat_wbfs_mount;
extern sec_t fat_wbfs_sec;
s32 MountNTFS(u32 sector);
s32 UnmountNTFS(void);
int USBDevice_Init();
void USBDevice_deInit();
int WBFSDevice_Init(u32 sector);
void WBFSDevice_deInit();
int isInserted(const char *path);
int SDCard_Init();
void SDCard_deInit();
extern int fat_usb_mount;
extern sec_t fat_usb_sec;
extern int fat_wbfs_mount;
extern sec_t fat_wbfs_sec;
extern int fs_ntfs_mount;
extern sec_t fs_ntfs_sec;
s32 MountNTFS(u32 sector);
s32 UnmountNTFS(void);
extern int fat_usb_mount;
extern sec_t fat_usb_sec;
extern int fat_wbfs_mount;
extern sec_t fat_wbfs_sec;
extern int fs_ntfs_mount;
extern sec_t fs_ntfs_sec;
#ifdef __cplusplus
}

View File

@ -29,7 +29,7 @@ static char* determineStubTIDLocation()
s32 Set_Stub(u64 reqID)
{
if (titles.IndexOf(reqID) < 0) return WII_EINSTALL;
if (NandTitles.IndexOf(reqID) < 0) return WII_EINSTALL;
char *stub = determineStubTIDLocation();
if (!stub) return -68;

View File

@ -58,7 +58,6 @@ extern bool geckoinit;
extern char headlessID[8];
char bootDevice[10];
NandTitle titles;
PartList partitions;
int main(int argc, char *argv[])
@ -70,7 +69,7 @@ int main(int argc, char *argv[])
__exception_setreload(20);
printf("\tStarting up\n");
titles.Get();
NandTitles.Get();
bool bootDevice_found = false;
if (argc >= 1)
@ -109,8 +108,7 @@ int main(int argc, char *argv[])
printf("done\n");
// Let's load the cIOS now
IosLoader loader(titles);
if (loader.LoadAppCios() < 0)
if (IosLoader::LoadAppCios() < 0)
{
printf("\n\tWARNING!\n");
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+\n\n");

View File

@ -612,8 +612,8 @@ int MainMenu(int menu)
u32 channel = 0;
if (returnToLoaderGV)
{
int idx = titles.FindU32(Settings.returnTo);
if (idx >= 0) channel = TITLE_LOWER( titles.At( idx ) );
int idx = NandTitles.FindU32(Settings.returnTo);
if (idx >= 0) channel = TITLE_LOWER( NandTitles.At( idx ) );
}
//This is temporary

View File

@ -59,19 +59,19 @@ bool TitleSelector(char output[])
ISFS_Initialize();//initialize for "titles.Exists()"
// Get count of titles of the good titles
num_titles = titles.SetType(0x10001);
num_titles = NandTitles.SetType(0x10001);
u32 n = num_titles;
//gprintf("num_titles: %u\n", num_titles );
for (u32 i = 0; i < n; i++)
{
u64 tid = titles.Next();
u64 tid = NandTitles.Next();
if (!tid)
{
break;
}
//remove ones not actually installed on the nand
if (!titles.Exists(tid))
if (!NandTitles.Exists(tid))
{
num_titles--;
}
@ -89,29 +89,29 @@ bool TitleSelector(char output[])
//write the titles on the option browser
s32 i = 0;
titles.SetType(0x10001);
NandTitles.SetType(0x10001);
while (i < num_titles)
{
u64 tid = titles.Next();
u64 tid = NandTitles.Next();
if (!tid)
{
gprintf("shit happened\n");
break;
}
if (!titles.Exists(tid))
if (!NandTitles.Exists(tid))
{
continue;
}
char id[5];
titles.AsciiTID(tid, (char*) &id);
NandTitles.AsciiTID(tid, (char*) &id);
const char* name = titles.NameOf(tid);
const char* name = NandTitles.NameOf(tid);
//gprintf("%016llx: %s: %s\n%p\t%p\n", tid, id, name, &id, name );
options4.SetName(i, "%s", id);
options4.SetValue(i, "%s", name ? titles.NameOf(tid) : tr( "Unknown" ));
options4.SetValue(i, "%s", name ? NandTitles.NameOf(tid) : tr( "Unknown" ));
titleList[i] = tid;
i++;
}
@ -238,29 +238,29 @@ int TitleBrowser()
ISFS_Initialize();//initialize for "titles.Exists()"
// Get count of titles of the good titles
num_titles = titles.SetType(0x10001);
num_titles = NandTitles.SetType(0x10001);
u32 n = num_titles;
for (u32 i = 0; i < n; i++)
{
u64 tid = titles.Next();
u64 tid = NandTitles.Next();
if (!tid)
{
break;
}
//remove ones not actually installed on the nand
if (!titles.Exists(tid))
if (!NandTitles.Exists(tid))
{
num_titles--;
}
}
// Get count of system titles
num_sys_titles = titles.SetType(0x10002);
num_sys_titles = NandTitles.SetType(0x10002);
n = num_sys_titles;
for (u32 i = 0; i < n; i++)
{
u64 tid = titles.Next();
u64 tid = NandTitles.Next();
if (!tid)
{
break;
@ -273,7 +273,7 @@ int TitleBrowser()
}
//these aren't installed on the nand
if (!titles.Exists(tid))
if (!NandTitles.Exists(tid))
{
num_sys_titles--;
}
@ -290,55 +290,55 @@ int TitleBrowser()
//write the titles on the option browser
u32 i = 0;
titles.SetType(0x10001);
NandTitles.SetType(0x10001);
//first add the good stuff
while (i < num_titles)
{
u64 tid = titles.Next();
u64 tid = NandTitles.Next();
if (!tid)
{
gprintf("shit happened3\n");
break;
}
gprintf("[ %u ] tid: %016llx\t%s\n", i, tid, titles.NameOf(tid));
gprintf("[ %u ] tid: %016llx\t%s\n", i, tid, NandTitles.NameOf(tid));
if (!titles.Exists(tid))
if (!NandTitles.Exists(tid))
{
continue;
}
char id[5];
titles.AsciiTID(tid, (char*) &id);
NandTitles.AsciiTID(tid, (char*) &id);
const char* name = titles.NameOf(tid);
const char* name = NandTitles.NameOf(tid);
options3.SetName(i, "%s", id);
options3.SetValue(i, "%s", name ? titles.NameOf(tid) : tr( "Unknown" ));
options3.SetValue(i, "%s", name ? NandTitles.NameOf(tid) : tr( "Unknown" ));
titleList[i] = tid;
i++;
}
titles.SetType(0x10002);
NandTitles.SetType(0x10002);
while (i < num_sys_titles + num_titles)
{
u64 tid = titles.Next();
u64 tid = NandTitles.Next();
if (!tid)
{
break;
}
if (TITLE_LOWER( tid ) == 0x48414741 || TITLE_LOWER( tid ) == 0x48414141 || TITLE_LOWER( tid ) == 0x48414641) continue;
if (!titles.Exists(tid))
if (!NandTitles.Exists(tid))
{
continue;
}
char id[5];
titles.AsciiTID(tid, (char*) &id);
const char* name = titles.NameOf(tid);
NandTitles.AsciiTID(tid, (char*) &id);
const char* name = NandTitles.NameOf(tid);
options3.SetName(i, "%s", id);
options3.SetValue(i, "%s", name ? titles.NameOf(tid) : tr( "Unknown" ));
options3.SetValue(i, "%s", name ? NandTitles.NameOf(tid) : tr( "Unknown" ));
titleList[i] = tid;
i++;
}
@ -470,9 +470,9 @@ int TitleBrowser()
//set the title's name, number, ID to text
char text[0x100];
char id[5];
titles.AsciiTID(titleList[ret], (char*) &id);
NandTitles.AsciiTID(titleList[ret], (char*) &id);
snprintf(text, sizeof(text), "%s : %s", id, titles.NameOf(titleList[ret]));
snprintf(text, sizeof(text), "%s : %s", id, NandTitles.NameOf(titleList[ret]));
//prompt to boot selected title
if (WindowPrompt(tr( "Boot?" ), text, tr( "OK" ), tr( "Cancel" )))

View File

@ -1045,8 +1045,8 @@ int MenuSettings()
Settings.cios = 222;
break;
}
if ((Settings.cios == 222 && titles.VersionOf(0x1000000deULL) != 4)
|| (Settings.cios == 2 && titles.VersionOf(0x1000000dfULL) != 4))
if ((Settings.cios == 222 && NandTitles.VersionOf(0x1000000deULL) != 4)
|| (Settings.cios == 2 && NandTitles.VersionOf(0x1000000dfULL) != 4))
{
WindowPrompt(
tr( "Hermes CIOS" ),
@ -1135,10 +1135,10 @@ int MenuSettings()
snprintf(Settings.returnTo, sizeof(Settings.returnTo), "%s", tidChar);
}
}
int haveTitle = titles.FindU32(Settings.returnTo);
int haveTitle = NandTitles.FindU32(Settings.returnTo);
if (haveTitle >= 0)
{
name = (char*) titles.NameFromIndex(haveTitle);
name = (char*) NandTitles.NameFromIndex(haveTitle);
if (!strlen(name)) name = NULL;
}
options2.SetValue(Idx, "%s", name ? name : tr( opts_off_on[ 0 ] ));
@ -2719,12 +2719,12 @@ int GameSettings(struct discHdr * header)
if (ret == Idx && ++returnToLoaderGV >= settings_off_on_max) returnToLoaderGV = 0;
char text[IMET_MAX_NAME_LEN];
int channel = titles.FindU32(Settings.returnTo);//is the channel set in the global settings actually installed?
int channel = NandTitles.FindU32(Settings.returnTo);//is the channel set in the global settings actually installed?
if (!returnToLoaderGV || channel < 0)//channel is not installed or the uer wants to not use it
sprintf(text, "%s", tr( opts_off_on[ 0 ] ));
else snprintf(text, sizeof(text), "%s", titles.NameFromIndex(channel));
else snprintf(text, sizeof(text), "%s", NandTitles.NameFromIndex(channel));
options2.SetValue(Idx, "%s", text);
}

View File

@ -1,115 +1,100 @@
#include <gctypes.h>
#include "IosLoader.h"
#include "../fatmounter.h"
#include "../usbloader/usbstorage2.h"
#include "../wad/nandtitle.h"
#include "../mload/mload_modules.h"
#include "../settings/CSettings.h"
/******************************************************************************
* Construction/Destruction:
******************************************************************************/
/* Initializes a new instance of the IosLoader class. */
IosLoader::IosLoader(NandTitle titles)
{
nandTitles = titles;
}
/* Finalizes an instance of the IosLoader class. */
IosLoader::~IosLoader()
{
}
/******************************************************************************
* Public Methods:
******************************************************************************/
/*
* Loads CIOS (If possible the one from the settings file).
* @return 0 if a cios has been successfully loaded. Else a value below 0 is returned.
*/
s32 IosLoader::LoadAppCios()
{
s32 ret = -1;
// Unmount devices before reloading IOS.
SDCard_deInit();
USBDevice_deInit();
USBStorage2_Deinit();
u32 ciosLoadPriority[] = { 250, 249, 222, Settings.cios }; // Descending.
u32 activeCios = IOS_GetVersion();
for (u8 i=(sizeof(ciosLoadPriority)/sizeof(ciosLoadPriority[0])); i>=0; i--)
{
u32 cios = ciosLoadPriority[i];
if (activeCios == cios)
{
ret = 0;
break;
}
if ((ret = ReloadIosSafe(cios)) > -1)
{
// Remember working cios.
Settings.cios = cios;
break;
}
}
// Remount devices after reloading IOS.
SDCard_Init();
if (IOS_GetVersion() == 222) load_ehc_module();
USBDevice_Init();
return ret;
}
/******************************************************************************
* Private/Protected Methods:
******************************************************************************/
/*
* Reloads a certain IOS under the condition, that an appropriate version of the IOS is installed.
* @return a negative value if a safe reload of the ios was not possible.
*/
s32 IosLoader::ReloadIosSafe(s32 ios)
{
switch (ios)
{
case 222:
{
s32 ios222rev = nandTitles.VersionOf(0x1000000deULL);
if (ios222rev == 4 || ios222rev == 5 || ios222rev == 65535) break;
return -2;
}
case 223:
{
s32 ios223rev = nandTitles.VersionOf(0x1000000dfULL);
if (ios223rev == 4 || ios223rev == 5 || ios223rev == 65535) break;
return -2;
}
case 249:
{
s32 ios249rev = nandTitles.VersionOf(0x1000000f9ULL);
if (ios249rev < 9 || ios249rev == 65280) return -2;
break;
}
case 250:
{
s32 ios250rev = nandTitles.VersionOf(0x1000000faULL);
if (ios250rev < 9 || ios250rev == 65280) return -2;
break;
}
default:
return -3;
}
s32 r = IOS_ReloadIOS(ios);
if (r >= 0) WII_Initialize();
return r;
}
#include <gctypes.h>
#include "IosLoader.h"
#include "../fatmounter.h"
#include "../usbloader/usbstorage2.h"
#include "../wad/nandtitle.h"
#include "../mload/mload_modules.h"
#include "../settings/CSettings.h"
#include "wad/nandtitle.h"
/******************************************************************************
* Public Methods:
******************************************************************************/
/*
* Loads CIOS (If possible the one from the settings file).
* @return 0 if a cios has been successfully loaded. Else a value below 0 is returned.
*/
s32 IosLoader::LoadAppCios()
{
s32 ret = -1;
// Unmount devices before reloading IOS.
SDCard_deInit();
USBDevice_deInit();
USBStorage2_Deinit();
u32 ciosLoadPriority[] = { 250, 249, 222, Settings.cios }; // Descending.
u32 activeCios = IOS_GetVersion();
for (u8 i=(sizeof(ciosLoadPriority)/sizeof(ciosLoadPriority[0])); i>=0; i--)
{
u32 cios = ciosLoadPriority[i];
if (activeCios == cios)
{
ret = 0;
break;
}
if ((ret = ReloadIosSafe(cios)) > -1)
{
// Remember working cios.
Settings.cios = cios;
break;
}
}
// Remount devices after reloading IOS.
SDCard_Init();
if (IOS_GetVersion() == 222) load_ehc_module();
USBDevice_Init();
return ret;
}
/******************************************************************************
* Private/Protected Methods:
******************************************************************************/
/*
* Reloads a certain IOS under the condition, that an appropriate version of the IOS is installed.
* @return a negative value if a safe reload of the ios was not possible.
*/
s32 IosLoader::ReloadIosSafe(s32 ios)
{
switch (ios)
{
case 222:
{
s32 ios222rev = NandTitles.VersionOf(0x1000000deULL);
if (ios222rev == 4 || ios222rev == 5 || ios222rev == 65535) break;
return -2;
}
case 223:
{
s32 ios223rev = NandTitles.VersionOf(0x1000000dfULL);
if (ios223rev == 4 || ios223rev == 5 || ios223rev == 65535) break;
return -2;
}
case 249:
{
s32 ios249rev = NandTitles.VersionOf(0x1000000f9ULL);
if (ios249rev < 9 || ios249rev == 65280) return -2;
break;
}
case 250:
{
s32 ios250rev = NandTitles.VersionOf(0x1000000faULL);
if (ios250rev < 9 || ios250rev == 65280) return -2;
break;
}
default:
return -3;
}
s32 r = IOS_ReloadIOS(ios);
if (r >= 0) WII_Initialize();
return r;
}

View File

@ -1,19 +1,13 @@
#ifndef _IOSLOADER_H_
#define _IOSLOADER_H_
#include <gctypes.h>
#include "../wad/nandtitle.h"
class IosLoader
{
public:
IosLoader(NandTitle titles);
~IosLoader();
s32 CheckForCios();
s32 LoadAppCios();
private:
NandTitle nandTitles;
s32 ReloadIosSafe(s32 ios);
};
#endif
#ifndef _IOSLOADER_H_
#define _IOSLOADER_H_
#include <gctypes.h>
class IosLoader
{
public:
static s32 LoadAppCios();
static s32 ReloadIosSafe(s32 ios);
};
#endif

View File

@ -1,6 +1,8 @@
#include "nandtitle.h"
#include "gecko.h"
NandTitle NandTitles;
extern "C"
{
extern s32 MagicPatches(s32);

View File

@ -108,5 +108,6 @@ class NandTitle
u32 currentType;
};
extern NandTitle titles;
extern NandTitle NandTitles;
#endif // NANDTITLE_H

View File

@ -560,7 +560,7 @@ s32 Wad_Uninstall(FILE *fp)
msg2Txt.SetText(tr( ">> Deleting tickets..." ));
// Get ticket views
ret = titles.GetTicketViews(tid, &viewData, &viewCnt);
ret = NandTitles.GetTicketViews(tid, &viewData, &viewCnt);
if (ret < 0)
{
char errTxt[50];