2010-01-19 11:48:50 +01:00
|
|
|
#include <dirent.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "menus.h"
|
|
|
|
#include "wpad.h"
|
|
|
|
#include "fatmounter.h"
|
|
|
|
#include "usbloader/wbfs.h"
|
2010-09-19 22:25:12 +02:00
|
|
|
#include "xml/xml.h"
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
extern int load_from_fs;
|
|
|
|
extern char game_partition[6];
|
|
|
|
extern char headlessID[8];
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* MenuCheck
|
|
|
|
***************************************************************************/
|
2010-09-19 01:16:05 +02:00
|
|
|
int MenuCheck()
|
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
gprintf("\nMenuCheck()");
|
2010-01-19 11:48:50 +01:00
|
|
|
int menu = MENU_NONE;
|
|
|
|
int i = 0;
|
|
|
|
int choice;
|
|
|
|
s32 ret2, wbfsinit;
|
|
|
|
OptionList options;
|
|
|
|
options.length = i;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
VIDEO_WaitVSync();
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
wbfsinit = WBFS_Init(WBFS_DEVICE_USB);
|
|
|
|
if (wbfsinit < 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
ret2 = WindowPrompt(tr( "No USB Device found." ), tr( "Do you want to retry for 30 secs?" ), "cIOS249",
|
|
|
|
"cIOS222", tr( "Back to Wii Menu" ));
|
2010-01-19 11:48:50 +01:00
|
|
|
SDCard_deInit();
|
|
|
|
USBDevice_deInit();
|
2010-09-24 02:48:03 +02:00
|
|
|
WPAD_Flush(0);
|
|
|
|
WPAD_Disconnect(0);
|
2010-01-19 11:48:50 +01:00
|
|
|
WPAD_Shutdown();
|
2010-09-24 02:48:03 +02:00
|
|
|
if (ret2 == 1)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-19 22:25:12 +02:00
|
|
|
Settings.cios = 249;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (ret2 == 2)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-19 22:25:12 +02:00
|
|
|
Settings.cios = 222;
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_LoadMenu();
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
ret2 = DiscWait(tr( "No USB Device" ), tr( "Waiting for USB Device" ), 0, 0, 1);
|
2010-01-19 11:48:50 +01:00
|
|
|
//reinitialize SD and USB
|
|
|
|
Wpad_Init();
|
2010-09-24 02:48:03 +02:00
|
|
|
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
|
|
|
|
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
|
|
|
|
if (ret2 < 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
WindowPrompt(tr( "Error !" ), tr( "USB Device not found" ), tr( "OK" ));
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_LoadMenu();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-19 01:16:05 +02:00
|
|
|
ret2 = -1;
|
2010-09-24 02:48:03 +02:00
|
|
|
memset(game_partition, 0, 6);
|
2010-09-19 01:16:05 +02:00
|
|
|
load_from_fs = -1;
|
|
|
|
|
|
|
|
extern PartList partitions;
|
|
|
|
// Added for slow HDD
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int runs = 0; runs < 10; runs++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (Partition_GetList(WBFS_DEVICE_USB, &partitions) != 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
sleep(1);
|
2010-09-19 01:16:05 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (Settings.partition != -1 && partitions.num > Settings.partition)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
PartInfo pinfo = partitions.pinfo[Settings.partition];
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!WBFS_OpenPart(pinfo.part_fs, pinfo.index, partitions.pentry[Settings.partition].sector,
|
|
|
|
partitions.pentry[Settings.partition].size, (char *) &game_partition))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
ret2 = 0;
|
|
|
|
load_from_fs = pinfo.part_fs;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (partitions.wbfs_n != 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
ret2 = WBFS_Open();
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int p = 0; p < partitions.num; p++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (partitions.pinfo[p].fs_type == FS_TYPE_WBFS)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
Settings.partition = p;
|
|
|
|
load_from_fs = PART_FS_WBFS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
else if (Sys_IsHermes() && (partitions.fat_n != 0 || partitions.ntfs_n != 0))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
// Loop through FAT/NTFS partitions, and find the first partition with games on it (if there is one)
|
|
|
|
u32 count;
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
for (int i = 0; i < partitions.num; i++)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
if (partitions.pinfo[i].fs_type == FS_TYPE_FAT32 || partitions.pinfo[i].fs_type == FS_TYPE_NTFS)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (!WBFS_OpenPart(partitions.pinfo[i].part_fs, partitions.pinfo[i].index,
|
|
|
|
partitions.pentry[i].sector, partitions.pentry[i].size, (char *) &game_partition))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
// Get the game count...
|
2010-09-24 02:48:03 +02:00
|
|
|
WBFS_GetCount(&count);
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (count > 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
|
|
|
load_from_fs = partitions.pinfo[i].part_fs;
|
|
|
|
Settings.partition = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WBFS_Close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if ((ret2 >= 0 || load_from_fs != PART_FS_WBFS) && isInserted(bootDevice))
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-19 22:25:12 +02:00
|
|
|
Settings.Save();
|
2010-09-19 01:16:05 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-09-24 02:48:03 +02:00
|
|
|
sleep(1);
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (ret2 < 0 && load_from_fs != PART_FS_WBFS)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
choice = WindowPrompt(tr( "No WBFS or FAT/NTFS partition found" ),
|
|
|
|
tr( "You need to select or format a partition" ), tr( "Select" ), tr( "Format" ), tr( "Return" ));
|
|
|
|
if (choice == 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_LoadMenu();
|
2010-09-19 01:16:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
load_from_fs = choice == 1 ? PART_FS_FAT : PART_FS_WBFS;
|
2010-01-19 11:48:50 +01:00
|
|
|
menu = MENU_FORMAT;
|
|
|
|
}
|
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
|
2010-01-19 11:48:50 +01:00
|
|
|
ret2 = Disc_Init();
|
2010-09-24 02:48:03 +02:00
|
|
|
if (ret2 < 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
WindowPrompt(tr( "Error !" ), tr( "Could not initialize DIP module!" ), tr( "OK" ));
|
2010-01-19 11:48:50 +01:00
|
|
|
Sys_LoadMenu();
|
|
|
|
}
|
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (shutdown == 1) Sys_Shutdown();
|
|
|
|
if (reset == 1) Sys_Reboot();
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (wbfsinit < 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
sleep(1);
|
2010-01-19 11:48:50 +01:00
|
|
|
}
|
2010-09-19 01:16:05 +02:00
|
|
|
|
|
|
|
// open database if needed, load titles if needed
|
2010-09-24 02:48:03 +02:00
|
|
|
if (isInserted(bootDevice)) OpenXMLDatabase(Settings.titlestxt_path, Settings.db_language, Settings.db_JPtoEN,
|
|
|
|
true, Settings.titlesOverride == 1 ? true : false, true);
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
// titles.txt loaded after database to override database titles with custom titles
|
|
|
|
//snprintf(pathname, sizeof(pathname), "%stitles.txt", Settings.titlestxt_path);
|
|
|
|
//cfg_parsefile(pathname, &title_set);
|
|
|
|
|
|
|
|
//Spieleliste laden
|
2010-02-05 07:18:23 +01:00
|
|
|
//__Menu_GetEntries(0);//no point getting the gamelist here
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (strcmp(headlessID, "") != 0) menu = MENU_EXIT;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
2010-09-24 02:48:03 +02:00
|
|
|
if (menu == MENU_NONE) menu = MENU_DISCLIST;
|
2010-01-19 11:48:50 +01:00
|
|
|
|
|
|
|
//for HDDs with issues
|
2010-09-24 02:48:03 +02:00
|
|
|
if (wbfsinit < 0)
|
2010-09-19 01:16:05 +02:00
|
|
|
{
|
2010-09-24 02:48:03 +02:00
|
|
|
sleep(1);
|
2010-01-19 11:48:50 +01:00
|
|
|
USBDevice_Init();
|
|
|
|
SDCard_Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|