mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-18 01:09:16 +01:00
*Fix for startup problems. Especially for those with wiitdb.
*Startup is now using libogc usbstorage for loading configs *Improved storing gametitles from wiitdb with less memory usage *Added freeing of the memory allocated for wiitdb titles (oh boy) *Changed wiitdb.zip search
This commit is contained in:
parent
ca9455aa53
commit
d16ba4ed6c
@ -127,9 +127,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("\n\tInitialize USB (wake up)");
|
||||
USBDevice_Init();// seems enough to wake up some HDDs if they are in sleep mode when the loader starts (tested with WD MyPassport Essential 2.5")
|
||||
USBDevice_deInit();
|
||||
|
||||
s32 ret;
|
||||
printf("\n\tInitialize sd card");
|
||||
SDCard_Init(); // mount SD for loading cfg's
|
||||
|
||||
bool bootDevice_found=false;
|
||||
if (argc >= 1) {
|
||||
@ -140,17 +139,7 @@ int main(int argc, char *argv[])
|
||||
bootDevice_found = true;
|
||||
}
|
||||
|
||||
printf("\n\tInitializing controllers");
|
||||
|
||||
/** PAD_Init has to be before InitVideo don't move that **/
|
||||
PAD_Init(); // initialize PAD/WPAD
|
||||
|
||||
ret = CheckForCIOS();
|
||||
|
||||
printf("\n\tInitialize sd card");
|
||||
SDCard_Init(); // mount SD for loading cfg's
|
||||
printf("\n\tInitialize usb device");
|
||||
USBDevice_Init(); // and mount USB:/
|
||||
CheckForCIOS();
|
||||
|
||||
if (!bootDevice_found)
|
||||
{
|
||||
@ -170,6 +159,17 @@ int main(int argc, char *argv[])
|
||||
CFG_Load();
|
||||
printf("done");
|
||||
|
||||
printf("\n\tLoading Background Music...");
|
||||
bgMusic = new GuiBGM(bg_music_ogg, bg_music_ogg_size, Settings.volume);
|
||||
if(strstr(Settings.ogg_path, "USB:") == 0)
|
||||
bgMusic->Load(Settings.ogg_path);
|
||||
bgMusic->SetLoop(Settings.musicloopmode); //loop music
|
||||
|
||||
printf("\n\tOpening XML Database...");
|
||||
// open database if available, load titles if needed
|
||||
if(!OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride == 1 ? true: false, true))
|
||||
printf("failed");
|
||||
|
||||
LoadAppCIOS();
|
||||
printf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());
|
||||
|
||||
@ -181,6 +181,10 @@ int main(int argc, char *argv[])
|
||||
LoadHeadlessID(argv[1]);
|
||||
}
|
||||
|
||||
|
||||
printf("\n\tInitializing controllers");
|
||||
/** PAD_Init has to be before InitVideo don't move that **/
|
||||
PAD_Init(); // initialize PAD/WPAD
|
||||
//! Init the rest of the System
|
||||
Sys_Init();
|
||||
Wpad_Init();
|
||||
|
@ -281,13 +281,8 @@ int MainMenu(int menu) {
|
||||
bgImg = new GuiImage(background);
|
||||
mainWindow->Append(bgImg);
|
||||
|
||||
bgMusic = new GuiBGM(bg_music_ogg, bg_music_ogg_size, Settings.volume);
|
||||
bgMusic->SetLoop(Settings.musicloopmode); //loop music
|
||||
if(strstr(Settings.ogg_path, "USB:/") == 0) //usb is not detected at this point yet
|
||||
{
|
||||
bgMusic->Load(Settings.ogg_path);
|
||||
bgMusic->Play();
|
||||
}
|
||||
bgMusic->Play();
|
||||
|
||||
ResumeGui();
|
||||
|
||||
|
||||
@ -324,6 +319,8 @@ int MainMenu(int menu) {
|
||||
|
||||
CloseXMLDatabase();
|
||||
NewTitles::DestroyInstance();
|
||||
CFG_Cleanup();
|
||||
|
||||
if (strcmp(headlessID,"")!=0)//the GUIthread was never started, so it cant be ended and joined properly if headless mode was used. so we resume it and close it.
|
||||
ResumeGui();
|
||||
ExitGUIThreads();
|
||||
|
@ -39,37 +39,6 @@ void HaltCheck()
|
||||
usleep(50);
|
||||
}
|
||||
|
||||
void ReloadHDD_Settings()
|
||||
{
|
||||
if(strstr(bootDevice, "USB:") != 0)
|
||||
{
|
||||
CFG_Load();
|
||||
int ios = 249;
|
||||
switch(Settings.cios)
|
||||
{
|
||||
case ios249:
|
||||
ios = 249;
|
||||
break;
|
||||
case ios222:
|
||||
ios = 222;
|
||||
break;
|
||||
case ios250:
|
||||
ios = 250;
|
||||
break;
|
||||
}
|
||||
if(ios != IOS_GetVersion())
|
||||
Sys_ChangeIos(ios);
|
||||
}
|
||||
if(strstr(Settings.ogg_path, "USB:/") != 0)
|
||||
{
|
||||
bgMusic->Load(Settings.ogg_path);
|
||||
bgMusic->Play();
|
||||
}
|
||||
|
||||
// open database if available, load titles if needed
|
||||
OpenXMLDatabase(Settings.titlestxt_path,Settings.db_language, Settings.db_JPtoEN, true, Settings.titlesOverride == 1 ? true: false, true);
|
||||
}
|
||||
|
||||
int CheckPartition()
|
||||
{
|
||||
s32 ret2 = -1;
|
||||
@ -190,7 +159,11 @@ static void * CheckDevices (void *arg)
|
||||
{
|
||||
LWP_SetThreadPriority(LWP_GetSelf(), 0);
|
||||
|
||||
ReloadHDD_Settings();
|
||||
if(strstr(Settings.ogg_path, "USB:/") != 0)
|
||||
{
|
||||
bgMusic->Load(Settings.ogg_path);
|
||||
bgMusic->Play();
|
||||
}
|
||||
|
||||
checkthreadState = 1;
|
||||
}
|
||||
|
@ -1426,7 +1426,7 @@ int MenuSettings()
|
||||
{
|
||||
bgMusic->LoadStandard();
|
||||
bgMusic->Play();
|
||||
options2.SetValue(Idx, "%s", tr("Standard"));
|
||||
options2.SetValue(0, "%s", tr("Standard"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,11 +42,9 @@ u8 listDisplay = 0;
|
||||
u8 partition = -1;
|
||||
char alternatedname[40];
|
||||
|
||||
#define TITLE_MAX 200
|
||||
|
||||
struct ID_Title {
|
||||
char id[6];
|
||||
char title[TITLE_MAX];
|
||||
char * title;
|
||||
};
|
||||
|
||||
struct ID_Control {
|
||||
@ -391,8 +389,9 @@ char *cfg_get_title(u8 *id)
|
||||
return NULL;
|
||||
|
||||
int i;
|
||||
for (i=0; i<num_title; i++) {
|
||||
if (memcmp(id, cfg_title[i].id, 6) == 0) {
|
||||
for (i=0; i<num_title; i++)
|
||||
{
|
||||
if (strncmp((char*) id, cfg_title[i].id, 6) == 0) {
|
||||
return cfg_title[i].title;
|
||||
}
|
||||
}
|
||||
@ -411,20 +410,31 @@ char *get_title(struct discHdr *header)
|
||||
|
||||
void title_set(char *id, char *title)
|
||||
{
|
||||
if(!id || !title)
|
||||
return;
|
||||
|
||||
if(!cfg_title)
|
||||
cfg_title = (struct ID_Title *) malloc(sizeof(struct ID_Title));
|
||||
|
||||
char *idt = cfg_get_title((u8*)id);
|
||||
if (idt) {
|
||||
// replace
|
||||
strlcpy(idt, title, TITLE_MAX);
|
||||
free(idt);
|
||||
idt = strdup(title);
|
||||
} else {
|
||||
cfg_title = realloc(cfg_title, (num_title+1) * sizeof(struct ID_Title));
|
||||
if (!cfg_title) {
|
||||
struct ID_Title * tmpStruct = (struct ID_Title *) realloc(cfg_title, (num_title+1) * sizeof(struct ID_Title));
|
||||
if (!tmpStruct) {
|
||||
// error
|
||||
CFG_Cleanup();
|
||||
num_title = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
cfg_title = tmpStruct;
|
||||
|
||||
// add
|
||||
strcpy(cfg_title[num_title].id, id);
|
||||
strlcpy(cfg_title[num_title].title, title, TITLE_MAX);
|
||||
strncpy(cfg_title[num_title].id, id, 6);
|
||||
cfg_title[num_title].title = strdup(title);
|
||||
num_title++;
|
||||
}
|
||||
}
|
||||
@ -433,7 +443,8 @@ void titles_default() {
|
||||
int i;
|
||||
for (i=0; i<num_title; i++) {
|
||||
memset(cfg_title[i].id, 0, 6);
|
||||
strlcpy(cfg_title[i].title, "", TITLE_MAX);
|
||||
free(cfg_title[i].title);
|
||||
cfg_title[i].title = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1868,7 +1879,15 @@ void CFG_LoadGlobal(void) {
|
||||
cfg_parsefile(GXGlobal_cfg, &global_cfg_set);
|
||||
}
|
||||
|
||||
void CFG_Cleanup(void) {
|
||||
void CFG_Cleanup(void)
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i < num_title; i++)
|
||||
{
|
||||
if(cfg_title[i].title)
|
||||
free(cfg_title[i].title);
|
||||
cfg_title[i].title = NULL;
|
||||
}
|
||||
if (cfg_title) {
|
||||
free(cfg_title);
|
||||
cfg_title = NULL;
|
||||
|
@ -316,48 +316,20 @@ s32 CheckForCIOS()
|
||||
}
|
||||
}
|
||||
|
||||
//Needed for Settings load of HDD
|
||||
printf("\n\tReloading ios 222...");
|
||||
ret = IOS_ReloadIOSsafe(222);
|
||||
printf("%d", ret);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("\n\tIOS 222 failed, reloading ios 249...");
|
||||
ret = IOS_ReloadIOSsafe(249);
|
||||
printf("%d", ret);
|
||||
if (ret < 0) {
|
||||
printf("\n\tIOS 222 failed, reloading ios 250...");
|
||||
ret = IOS_ReloadIOSsafe(250);
|
||||
printf("%d", ret);
|
||||
if (ret < 0) {
|
||||
printf("\n\tERROR: cIOS could not be loaded!\n");
|
||||
sleep(5);
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SDCard_Init();
|
||||
//only for 222 loading ehc modules
|
||||
printf("\n\tLoad ehc module");
|
||||
load_ehc_module();
|
||||
SDCard_deInit();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LoadAppCIOS()
|
||||
{
|
||||
s32 ret = 1;
|
||||
bool IOS_Reloaded = false;
|
||||
/* Load Custom IOS */
|
||||
SDCard_deInit();// unmount SD for reloading IOS
|
||||
USBDevice_deInit();// unmount USB for reloading IOS
|
||||
USBStorage_Deinit();
|
||||
|
||||
//this is needed otherwise IOS_Reload fails
|
||||
IOS_ReloadIOSsafe(249);
|
||||
|
||||
if (Settings.cios == ios222 && IOS_GetVersion() != 222)
|
||||
{
|
||||
printf("\n\tReloading IOS to config setting (222)...");
|
||||
@ -368,7 +340,6 @@ int LoadAppCIOS()
|
||||
Settings.cios = ios249;
|
||||
IOS_ReloadIOSsafe(249);
|
||||
}
|
||||
IOS_Reloaded = true;
|
||||
}
|
||||
|
||||
if ((Settings.cios == ios249 && IOS_GetVersion() != 249)
|
||||
@ -381,11 +352,10 @@ int LoadAppCIOS()
|
||||
Settings.cios = ios222;
|
||||
ret = IOS_ReloadIOSsafe(222);
|
||||
}
|
||||
IOS_Reloaded = true;
|
||||
}
|
||||
|
||||
SDCard_Init();
|
||||
if(IOS_GetVersion() == 222 && IOS_Reloaded)
|
||||
if(IOS_GetVersion() == 222)
|
||||
load_ehc_module();
|
||||
|
||||
USBDevice_Init();
|
||||
|
@ -7,19 +7,18 @@ Load game information from XML - Lustar
|
||||
#include <malloc.h>
|
||||
#include "unzip/unzip.h"
|
||||
#include "settings/cfg.h"
|
||||
#include "listfiles.h"
|
||||
#include "usbloader/partition_usbloader.h"
|
||||
#include "xml/xml.h"
|
||||
//#include "cfg.h"
|
||||
//#include "xml.h"
|
||||
|
||||
|
||||
extern struct SSettings Settings; // for loader GX
|
||||
extern void title_set(char *id, char *title);
|
||||
extern char* trimcopy(char *dest, char *src, int size);
|
||||
extern char game_partition[6];
|
||||
|
||||
|
||||
/* config */
|
||||
static bool xmldebug = false;
|
||||
static char xmlcfg_filename[100] = "wiitdb";
|
||||
static int xmlmaxsize = 1572864;
|
||||
|
||||
|
||||
@ -64,22 +63,45 @@ int xmlloadtime = 0;
|
||||
char * get_nodetext(mxml_node_t *node, char *buffer, int buflen);
|
||||
bool xml_loaded = false;
|
||||
|
||||
static void SearchXMLFile(char * pathname)
|
||||
{
|
||||
int i = 0;
|
||||
char temppath[MAXPATHLEN];
|
||||
|
||||
for(i = 0; i < 4; i++)
|
||||
{
|
||||
snprintf(temppath, sizeof(temppath), "%swiitdb_WBFS%i.zip", pathname, i);
|
||||
if(checkfile(temppath))
|
||||
{
|
||||
sprintf(pathname, "%s", temppath);
|
||||
return;
|
||||
}
|
||||
snprintf(temppath, sizeof(temppath), "%swiitdb_FAT%i.zip", pathname, i);
|
||||
if(checkfile(temppath))
|
||||
{
|
||||
sprintf(pathname, "%s", temppath);
|
||||
return;
|
||||
}
|
||||
snprintf(temppath, sizeof(temppath), "%swiitdb_NTFS%i.zip", pathname, i);
|
||||
if(checkfile(temppath))
|
||||
{
|
||||
sprintf(pathname, "%s", temppath);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(pathname, "%swiitdb.zip", pathname);
|
||||
}
|
||||
|
||||
/* load renamed titles from proper names and game info XML, needs to be after cfg_load_games */
|
||||
bool OpenXMLDatabase(char* xmlfilepath, char* argdblang, bool argJPtoEN, bool openfile, bool loadtitles, bool keepopen) {
|
||||
if (!xml_loaded) {
|
||||
bool opensuccess = false;
|
||||
char pathname[200];
|
||||
char pathname[400];
|
||||
snprintf(pathname, sizeof(pathname), "%s", xmlfilepath);
|
||||
if (xmlfilepath[strlen(xmlfilepath) - 1] != '/') snprintf(pathname, sizeof(pathname), "%s/",pathname);
|
||||
snprintf(pathname, sizeof(pathname), "%s%s_%s.zip", pathname, xmlcfg_filename, game_partition);
|
||||
SearchXMLFile(pathname);
|
||||
if (openfile) opensuccess = OpenXMLFile(pathname);
|
||||
if (!opensuccess) {
|
||||
snprintf(pathname, sizeof(pathname), "%s", xmlfilepath);
|
||||
if (xmlfilepath[strlen(xmlfilepath) - 1] != '/') snprintf(pathname, sizeof(pathname), "%s/",pathname);
|
||||
snprintf(pathname, sizeof(pathname), "%swiitdb.zip", pathname);
|
||||
if (openfile) opensuccess = OpenXMLFile(pathname);
|
||||
}
|
||||
if (!opensuccess && openfile) {
|
||||
CloseXMLDatabase();
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user