2009-09-30 19:10:58 -04: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 11:13:13 -03:00
|
|
|
#include <locale.h>
|
2009-09-30 19:10:58 -04:00
|
|
|
#include <wiiuse/wpad.h>
|
2009-12-02 22:06:09 -03:00
|
|
|
#include <di/di.h>
|
|
|
|
#include <sys/iosupport.h>
|
2009-09-30 19:10:58 -04:00
|
|
|
|
|
|
|
#include "libwiigui/gui.h"
|
|
|
|
#include "usbloader/wbfs.h"
|
|
|
|
#include "language/gettext.h"
|
|
|
|
#include "mload/mload.h"
|
2010-02-14 20:22:52 -03:00
|
|
|
#include "mload/mload_modules.h"
|
2009-09-30 19:10:58 -04:00
|
|
|
#include "FreeTypeGX.h"
|
2010-09-17 11:15:21 -04:00
|
|
|
#include "FontSystem.h"
|
2009-09-30 19:10:58 -04:00
|
|
|
#include "video.h"
|
|
|
|
#include "audio.h"
|
2010-10-27 16:50:48 -03:00
|
|
|
#include "menu/menus.h"
|
2009-09-30 19:10:58 -04:00
|
|
|
#include "menu.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "filelist.h"
|
2010-09-25 02:54:27 -04:00
|
|
|
#include "FileOperations/fileops.h"
|
2009-09-30 19:10:58 -04:00
|
|
|
#include "main.h"
|
|
|
|
#include "fatmounter.h"
|
|
|
|
#include "sys.h"
|
|
|
|
#include "wpad.h"
|
|
|
|
#include "fat.h"
|
2009-10-20 08:46:55 -03:00
|
|
|
#include "gecko.h"
|
2009-10-20 20:00:19 -03:00
|
|
|
#include "svnrev.h"
|
2009-11-15 18:30:44 -03:00
|
|
|
#include "usbloader/partition_usbloader.h"
|
2010-02-22 18:29:47 -03:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2009-12-04 12:05:20 -03:00
|
|
|
#include "memory/mem2.h"
|
2009-12-10 17:27:36 -03:00
|
|
|
#include "lstub.h"
|
2010-09-16 15:59:41 -04:00
|
|
|
#include "usbloader/usbstorage2.h"
|
2010-09-18 19:04:39 -04:00
|
|
|
#include "wad/nandtitle.h"
|
2010-09-23 19:47:51 -04:00
|
|
|
#include "system/IosLoader.h"
|
2010-10-27 16:50:48 -03:00
|
|
|
#include "GameBootProcess.h"
|
2009-10-20 08:46:55 -03:00
|
|
|
|
2010-10-28 06:00:52 -03:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
extern void __exception_setreload(int t);
|
|
|
|
}
|
|
|
|
|
2009-10-20 08:46:55 -03:00
|
|
|
extern bool geckoinit;
|
2009-09-30 19:10:58 -04:00
|
|
|
|
2010-01-19 07:48:50 -03:00
|
|
|
PartList partitions;
|
|
|
|
|
2010-09-23 19:47:51 -04:00
|
|
|
int main(int argc, char *argv[])
|
2010-02-09 07:59:55 -03:00
|
|
|
{
|
2010-09-23 19:47:51 -04:00
|
|
|
MEM2_init(48);
|
|
|
|
setlocale(LC_ALL, "en.UTF-8");
|
2010-01-19 07:48:50 -03:00
|
|
|
geckoinit = InitGecko();
|
2010-09-19 04:13:06 -04:00
|
|
|
InitVideo();
|
2010-09-23 19:47:51 -04:00
|
|
|
__exception_setreload(20);
|
2009-12-30 06:52:24 -03:00
|
|
|
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("\tStarting up\n");
|
2010-09-24 09:46:32 -04:00
|
|
|
NandTitles.Get();
|
2009-12-30 06:52:24 -03:00
|
|
|
|
2010-09-16 15:59:41 -04:00
|
|
|
//Let's use libogc sd/usb for config loading
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("\tInitialize sd card\n");
|
2010-09-16 15:59:41 -04:00
|
|
|
SDCard_Init();
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("\tInitialize usb device\n");
|
2010-09-16 15:59:41 -04:00
|
|
|
USBDevice_Init();
|
2009-09-30 19:10:58 -04:00
|
|
|
|
|
|
|
gettextCleanUp();
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("\tLoading configuration...");
|
2010-09-19 16:25:12 -04:00
|
|
|
Settings.Load();
|
|
|
|
VIDEO_SetWidescreen(Settings.widescreen);
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("done\n");
|
2010-01-19 07:48:50 -03:00
|
|
|
|
2010-09-16 15:59:41 -04:00
|
|
|
// Let's load the cIOS now
|
2010-09-24 09:46:32 -04:00
|
|
|
if (IosLoader::LoadAppCios() < 0)
|
2010-09-16 15:59:41 -04:00
|
|
|
{
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("\n\tWARNING!\n");
|
|
|
|
printf("\tUSB Loader GX needs unstubbed cIOS 222 v4 or 249 v9+\n\n");
|
|
|
|
|
|
|
|
printf(
|
|
|
|
"\tWe cannot determine the versions on your system,\n\tsince you have no patched ios 36 or 236 installed.\n");
|
|
|
|
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 15:59:41 -04:00
|
|
|
Sys_BackToLoader();
|
2010-05-29 03:38:54 -04:00
|
|
|
}
|
2010-09-23 19:47:51 -04:00
|
|
|
printf("\tLoaded cIOS = %u (Rev %u)\n", IOS_GetVersion(), IOS_GetRevision());
|
2010-05-29 03:38:54 -04:00
|
|
|
|
2010-01-19 07:48:50 -03: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-23 19:47:51 -04:00
|
|
|
if (argc > 1 && argv[1])
|
2010-02-09 07:59:55 -03:00
|
|
|
{
|
2010-10-27 16:50:48 -03:00
|
|
|
MountGamePartition(false);
|
|
|
|
return BootGame(argv[1]);
|
2010-01-19 07:48:50 -03:00
|
|
|
}
|
2010-01-17 20:59:59 -03:00
|
|
|
|
2009-09-30 19:10:58 -04:00
|
|
|
//! Init the rest of the System
|
|
|
|
Sys_Init();
|
2010-09-17 13:48:16 -04:00
|
|
|
SetupPads();
|
2010-09-16 15:59:41 -04:00
|
|
|
InitAudio();
|
2009-09-30 19:10:58 -04:00
|
|
|
|
|
|
|
char *fontPath = NULL;
|
2010-09-23 19:47:51 -04:00
|
|
|
asprintf(&fontPath, "%sfont.ttf", Settings.theme_path);
|
|
|
|
SetupDefaultFont(fontPath);
|
|
|
|
free(fontPath);
|
2009-09-30 19:10:58 -04:00
|
|
|
|
2010-09-30 00:24:17 -04:00
|
|
|
//gprintf("\tEnd of Main()\n");
|
2009-09-30 19:10:58 -04:00
|
|
|
InitGUIThreads();
|
2010-10-27 16:50:48 -03:00
|
|
|
MainMenu(MENU_DISCLIST);
|
2009-09-30 19:10:58 -04:00
|
|
|
return 0;
|
|
|
|
}
|