2009-10-01 01:10:58 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* USB Loader GX Team
|
|
|
|
*
|
|
|
|
* Main loadup of the application
|
|
|
|
*
|
|
|
|
* libwiigui
|
|
|
|
* Tantric 2009
|
|
|
|
***************************************************************************/
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/dir.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <unistd.h>
|
2009-10-15 16:13:13 +02:00
|
|
|
#include <locale.h>
|
2009-10-01 01:10:58 +02:00
|
|
|
#include <wiiuse/wpad.h>
|
2009-12-03 02:06:09 +01:00
|
|
|
#include <di/di.h>
|
|
|
|
#include <sys/iosupport.h>
|
2009-10-01 01:10:58 +02:00
|
|
|
|
|
|
|
#include "libwiigui/gui.h"
|
|
|
|
#include "usbloader/wbfs.h"
|
|
|
|
#include "language/gettext.h"
|
|
|
|
#include "mload/mload.h"
|
2010-02-15 00:22:52 +01:00
|
|
|
#include "mload/mload_modules.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "video.h"
|
|
|
|
#include "audio.h"
|
2010-10-27 21:50:48 +02:00
|
|
|
#include "menu/menus.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "menu.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "filelist.h"
|
2010-09-25 08:54:27 +02:00
|
|
|
#include "FileOperations/fileops.h"
|
2010-11-28 16:31:08 +01:00
|
|
|
#include "settings/CGameSettings.h"
|
|
|
|
#include "settings/CGameStatistics.h"
|
|
|
|
#include "themes/CTheme.h"
|
2009-10-01 01:10:58 +02:00
|
|
|
#include "main.h"
|
|
|
|
#include "fatmounter.h"
|
|
|
|
#include "sys.h"
|
2009-10-20 13:46:55 +02:00
|
|
|
#include "gecko.h"
|
2009-11-15 22:30:44 +01:00
|
|
|
#include "usbloader/partition_usbloader.h"
|
2010-02-22 22:29:47 +01:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2009-12-04 16:05:20 +01:00
|
|
|
#include "memory/mem2.h"
|
2009-12-10 21:27:36 +01:00
|
|
|
#include "lstub.h"
|
2010-09-16 21:59:41 +02:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2010-09-19 01:04:39 +02:00
|
|
|
#include "wad/nandtitle.h"
|
2010-09-24 01:47:51 +02:00
|
|
|
#include "system/IosLoader.h"
|
2010-10-27 21:50:48 +02:00
|
|
|
#include "GameBootProcess.h"
|
2009-10-20 13:46:55 +02:00
|
|
|
|
2010-10-28 11:00:52 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2010-11-28 16:31:08 +01:00
|
|
|
void __exception_setreload(int t);
|
2010-10-28 11:00:52 +02:00
|
|
|
}
|
|
|
|
|
2010-01-19 11:48:50 +01:00
|
|
|
PartList partitions;
|
|
|
|
|
2010-09-24 01:47:51 +02:00
|
|
|
int main(int argc, char *argv[])
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-09-24 01:47:51 +02:00
|
|
|
MEM2_init(48);
|
|
|
|
setlocale(LC_ALL, "en.UTF-8");
|
2010-09-19 10:13:06 +02:00
|
|
|
InitVideo();
|
2010-11-28 16:31:08 +01:00
|
|
|
InitGecko();
|
2010-09-24 01:47:51 +02:00
|
|
|
__exception_setreload(20);
|
2009-12-30 10:52:24 +01:00
|
|
|
|
2010-09-24 01:47:51 +02:00
|
|
|
printf("\tStarting up\n");
|
2010-09-24 15:46:32 +02:00
|
|
|
NandTitles.Get();
|
2009-12-30 10:52:24 +01:00
|
|
|
|
2010-11-28 16:31:08 +01:00
|
|
|
// Let's try loading some cIOS
|
2010-09-24 15:46:32 +02:00
|
|
|
if (IosLoader::LoadAppCios() < 0)
|
2010-09-16 21:59:41 +02:00
|
|
|
{
|
2010-09-24 01:47:51 +02:00
|
|
|
printf("\n\tWARNING!\n");
|
2010-11-13 23:34:53 +01:00
|
|
|
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4+ or 249 v9+\n\n");
|
2010-09-24 01:47:51 +02:00
|
|
|
|
2010-11-28 16:31:08 +01:00
|
|
|
printf("\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n");
|
2010-09-24 01:47:51 +02:00
|
|
|
printf("\tTherefor, if loading of USB Loader GX fails, you\n\tprobably have installed the 4.2 update,\n");
|
|
|
|
printf("\tand you should go figure out how to get some cios action going on\n\tin your Wii.\n");
|
|
|
|
|
|
|
|
printf("\tERROR: No cIOS could be loaded. Exiting....\n");
|
|
|
|
sleep(10);
|
2010-09-16 21:59:41 +02:00
|
|
|
Sys_BackToLoader();
|
2010-05-29 09:38:54 +02:00
|
|
|
}
|
2010-11-28 16:31:08 +01:00
|
|
|
|
|
|
|
//Let's use libogc sd/usb for config loading
|
|
|
|
printf("\tInitialize sd card...%s\n", SDCard_Init() < 0 ? "failed" : "done");
|
|
|
|
printf("\tInitialize usb device...%s\n", USBDevice_Init_Loop() < 0 ? "failed" : "done");
|
|
|
|
|
|
|
|
//Load configurations
|
|
|
|
printf("\tLoading config...%s\n", Settings.Load() ? "done" : "failed");
|
|
|
|
printf("\tLoading language...%s\n", Settings.LoadLanguage(Settings.language_path, CONSOLE_DEFAULT) ? "done" : "failed");
|
|
|
|
printf("\tLoading game settings...%s\n", GameSettings.Load(Settings.ConfigPath) ? "done" : "failed");
|
|
|
|
printf("\tLoading game statistics...%s\n", GameStatistics.Load(Settings.ConfigPath) ? "done" : "failed");
|
2010-12-26 18:02:14 +01:00
|
|
|
printf("\tLoading theme...%s\n", Theme::Load(Settings.theme_path) ? "done" : "failed (using default)");
|
2010-11-28 16:31:08 +01:00
|
|
|
|
|
|
|
VIDEO_SetWidescreen(Settings.widescreen);
|
|
|
|
|
|
|
|
if(Settings.cios != IOS_GetVersion())
|
|
|
|
{
|
|
|
|
// Unmount fat before reloading IOS.
|
|
|
|
SDCard_deInit();
|
|
|
|
USBDevice_deInit();
|
|
|
|
|
|
|
|
// Loading now the cios setup in the settings
|
|
|
|
IosLoader::LoadAppCios();
|
|
|
|
|
|
|
|
// Remount devices after reloading IOS.
|
|
|
|
SDCard_Init();
|
|
|
|
USBDevice_Init_Loop();
|
|
|
|
}
|
2010-12-05 20:09:32 +01:00
|
|
|
printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
|
2010-05-29 09:38:54 +02:00
|
|
|
|
2010-01-19 11:48:50 +01:00
|
|
|
//if a ID was passed via args copy it and try to boot it after the partition is mounted
|
|
|
|
//its not really a headless mode. more like hairless.
|
2010-09-24 01:47:51 +02:00
|
|
|
if (argc > 1 && argv[1])
|
2010-02-09 11:59:55 +01:00
|
|
|
{
|
2010-10-27 21:50:48 +02:00
|
|
|
MountGamePartition(false);
|
|
|
|
return BootGame(argv[1]);
|
2010-01-19 11:48:50 +01:00
|
|
|
}
|
2010-01-18 00:59:59 +01:00
|
|
|
|
2010-12-03 19:38:57 +01:00
|
|
|
//! Now we startup the GUI so no need for console prints. Output only to gecko.
|
|
|
|
USBGeckoOutput();
|
|
|
|
|
2009-10-01 01:10:58 +02:00
|
|
|
//! Init the rest of the System
|
|
|
|
Sys_Init();
|
2010-09-17 19:48:16 +02:00
|
|
|
SetupPads();
|
2010-09-16 21:59:41 +02:00
|
|
|
InitAudio();
|
2009-10-01 01:10:58 +02:00
|
|
|
|
2010-10-27 21:50:48 +02:00
|
|
|
MainMenu(MENU_DISCLIST);
|
2009-10-01 01:10:58 +02:00
|
|
|
return 0;
|
|
|
|
}
|