2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <unistd.h>
|
2012-08-05 15:48:15 +02:00
|
|
|
|
2012-11-01 17:39:42 +01:00
|
|
|
#include "const_str.hpp"
|
2012-10-13 00:25:22 +02:00
|
|
|
#include "booter/external_booter.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "channel/nand.hpp"
|
|
|
|
#include "devicemounter/DeviceHandler.hpp"
|
2012-12-08 17:17:35 +01:00
|
|
|
#include "gecko/gecko.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "gui/video.hpp"
|
|
|
|
#include "gui/text.hpp"
|
|
|
|
#include "homebrew/homebrew.h"
|
2012-10-13 00:25:22 +02:00
|
|
|
#include "loader/alt_ios_gen.h"
|
2012-09-01 11:34:18 +02:00
|
|
|
#include "loader/wdvd.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "loader/alt_ios.h"
|
|
|
|
#include "loader/sys.h"
|
|
|
|
#include "loader/wbfs.h"
|
|
|
|
#include "loader/cios.h"
|
2012-08-19 16:06:09 +02:00
|
|
|
#include "loader/nk.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "menu/menu.hpp"
|
2012-08-24 00:29:15 +02:00
|
|
|
#include "memory/memory.h"
|
2012-08-05 15:48:15 +02:00
|
|
|
|
2012-10-13 18:57:03 +02:00
|
|
|
CMenu mainMenu;
|
2012-09-05 17:52:32 +02:00
|
|
|
bool useMainIOS = false;
|
2012-12-22 17:47:02 +01:00
|
|
|
volatile bool NANDemuView = false;
|
2012-12-22 21:57:23 +01:00
|
|
|
volatile bool networkInit = false;
|
2012-11-01 17:39:42 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2012-10-13 00:25:22 +02:00
|
|
|
mainIOS = DOL_MAIN_IOS;
|
2012-12-22 17:47:02 +01:00
|
|
|
__exception_setreload(10);
|
2012-12-08 17:17:35 +01:00
|
|
|
Gecko_Init(); //USB Gecko and SD/WiFi buffer
|
2012-11-01 17:39:42 +01:00
|
|
|
gprintf(" \nWelcome to %s!\nThis is the debug output.\n", VERSION_STRING.c_str());
|
2012-05-16 16:48:01 +02:00
|
|
|
|
2012-10-15 07:12:18 +02:00
|
|
|
m_vid.init(); // Init video
|
2012-09-07 20:13:04 +02:00
|
|
|
MEM_init(); //Inits both mem1lo and mem2
|
2012-10-15 07:12:18 +02:00
|
|
|
DeviceHandle.Init();
|
2012-10-15 21:16:14 +02:00
|
|
|
NandHandle.Init();
|
2012-06-07 18:02:23 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
char *gameid = NULL;
|
2012-04-08 17:54:34 +02:00
|
|
|
bool Emulator_boot = false;
|
2012-08-19 16:06:09 +02:00
|
|
|
bool iosOK = false;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-08-19 16:06:09 +02:00
|
|
|
for(u8 i = 0; i < argc; i++)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-08-19 16:06:09 +02:00
|
|
|
if(argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
2012-08-19 16:06:09 +02:00
|
|
|
while(argv[i][0] && !isdigit(argv[i][0]))
|
|
|
|
argv[i]++;
|
2012-01-21 21:57:41 +01:00
|
|
|
if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
|
|
|
|
mainIOS = atoi(argv[i]);
|
|
|
|
}
|
2012-08-19 16:06:09 +02:00
|
|
|
else if(strlen(argv[i]) == 6)
|
2012-01-21 21:57:41 +01:00
|
|
|
{
|
|
|
|
gameid = argv[i];
|
2012-08-19 16:06:09 +02:00
|
|
|
for(u8 i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
if(!isalnum(gameid[i]))
|
2012-01-21 21:57:41 +01:00
|
|
|
gameid = NULL;
|
2012-08-19 16:06:09 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-08-19 16:06:09 +02:00
|
|
|
else if(argv[i] != NULL && strcasestr(argv[i], "EMULATOR_MAGIC") != NULL)
|
2012-04-08 17:54:34 +02:00
|
|
|
Emulator_boot = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-10-15 21:16:14 +02:00
|
|
|
/* Init ISFS */
|
|
|
|
NandHandle.Init_ISFS();
|
|
|
|
/* Handle (c)IOS Loading */
|
2012-12-25 14:42:53 +01:00
|
|
|
if(neek2o() || Sys_DolphinMode()) /* wont reload anythin */
|
2012-11-28 13:05:21 +01:00
|
|
|
iosOK = loadIOS(IOS_GetVersion(), false);
|
2012-12-25 14:42:53 +01:00
|
|
|
else if(!CustomIOS(IOS_GetType(mainIOS))) /* safe reload */
|
|
|
|
iosOK = NandHandle.LoadDefaultIOS();
|
|
|
|
else /* cIOS found and on real nand, so just use it */
|
2012-08-26 18:23:35 +02:00
|
|
|
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
|
2012-11-28 13:05:21 +01:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// Init
|
|
|
|
Sys_Init();
|
|
|
|
Sys_ExitTo(EXIT_TO_HBC);
|
2012-09-02 15:34:41 +02:00
|
|
|
|
2012-09-22 15:47:52 +02:00
|
|
|
DeviceHandle.MountAll();
|
2012-10-13 18:57:03 +02:00
|
|
|
m_vid.waitMessage(0.15f);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-08-26 14:05:04 +02:00
|
|
|
Open_Inputs();
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.init();
|
2012-09-20 18:09:32 +02:00
|
|
|
if(CurrentIOS.Version != mainIOS && !neek2o() && !Sys_DolphinMode())
|
2012-08-26 14:05:04 +02:00
|
|
|
{
|
2012-09-22 15:47:52 +02:00
|
|
|
if(useMainIOS || !DeviceHandle.UsablePartitionMounted())
|
2012-08-26 14:05:04 +02:00
|
|
|
{
|
2012-11-01 08:04:52 +01:00
|
|
|
useMainIOS = false;
|
2012-11-12 21:12:00 +01:00
|
|
|
mainMenu.TempLoadIOS();
|
2012-11-01 08:04:52 +01:00
|
|
|
iosOK = CustomIOS(CurrentIOS.Type);
|
2012-08-26 14:05:04 +02:00
|
|
|
}
|
|
|
|
}
|
2012-09-05 17:52:32 +02:00
|
|
|
if(CurrentIOS.Version == mainIOS)
|
|
|
|
useMainIOS = true; //Needed for later checks
|
2012-08-24 20:01:40 +02:00
|
|
|
if(!iosOK)
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games.");
|
2012-09-22 15:47:52 +02:00
|
|
|
else if(!DeviceHandle.UsablePartitionMounted())
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.terror("errboot2", L"Could not find a device to save configuration files on!");
|
2012-09-05 17:52:32 +02:00
|
|
|
else if(WDVD_Init() < 0)
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.terror("errboot3", L"Could not initialize the DIP module!");
|
2012-09-05 17:52:32 +02:00
|
|
|
else
|
2012-08-24 20:01:40 +02:00
|
|
|
{
|
2012-10-01 21:55:55 +02:00
|
|
|
writeStub();
|
2012-08-24 20:01:40 +02:00
|
|
|
if(Emulator_boot)
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.m_Emulator_boot = true;
|
2012-09-05 17:52:32 +02:00
|
|
|
if(gameid != NULL && strlen(gameid) == 6)
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.directlaunch(gameid);
|
2012-09-05 17:52:32 +02:00
|
|
|
else
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.main();
|
2012-07-07 21:09:56 +02:00
|
|
|
}
|
2012-08-26 14:05:04 +02:00
|
|
|
//Exit WiiFlow, no game booted...
|
2012-10-13 18:57:03 +02:00
|
|
|
mainMenu.cleanup();
|
2012-09-02 13:51:26 +02:00
|
|
|
ShutdownBeforeExit();
|
2012-01-21 21:57:41 +01:00
|
|
|
Sys_Exit();
|
|
|
|
return 0;
|
2012-07-06 21:59:45 +02:00
|
|
|
}
|