2012-01-21 21:57:41 +01:00
|
|
|
#include "video.hpp"
|
|
|
|
#include "menu/menu.hpp"
|
|
|
|
#include "loader/disc.h"
|
|
|
|
|
|
|
|
#include "loader/alt_ios.h"
|
|
|
|
#include "loader/sys.h"
|
|
|
|
#include "loader/wbfs.h"
|
|
|
|
#include "text.hpp"
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "DeviceHandler.hpp"
|
|
|
|
#include "homebrew.h"
|
|
|
|
#include "gecko.h"
|
|
|
|
#include "wifi_gecko.h"
|
|
|
|
#include "cios.hpp"
|
|
|
|
#include "nand.hpp"
|
2012-02-18 16:29:22 +01:00
|
|
|
#include "defines.h"
|
|
|
|
#include "svnrev.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
CMenu *mainMenu;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
extern void __exception_setreload(int t);
|
|
|
|
|
|
|
|
void ShowError(const wstringEx &error)
|
|
|
|
{
|
|
|
|
mainMenu->error(error);
|
|
|
|
}
|
|
|
|
void HideWaitMessage()
|
|
|
|
{
|
|
|
|
mainMenu->_hideWaitMessage();
|
|
|
|
}
|
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
__exception_setreload(5);
|
2012-05-15 23:33:53 +02:00
|
|
|
MEM2_init(52);
|
2012-04-08 17:54:34 +02:00
|
|
|
|
2012-05-13 17:13:33 +02:00
|
|
|
geckoinit = InitGecko();
|
2012-02-23 18:14:42 +01:00
|
|
|
gprintf(" \nWelcome to %s (%s-r%s)!\nThis is the debug output.\n", APP_NAME, APP_VERSION, SVN_REV);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-05-13 17:13:33 +02:00
|
|
|
// Init video
|
2012-01-21 21:57:41 +01:00
|
|
|
CVideo vid;
|
2012-05-13 17:13:33 +02:00
|
|
|
vid.init();
|
|
|
|
vid.waitMessage(0.2f);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
char *gameid = NULL;
|
2012-04-08 17:54:34 +02:00
|
|
|
bool Emulator_boot = false;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
for (int i = 0; i < argc; i++)
|
|
|
|
{
|
|
|
|
if (argv[i] != NULL && strcasestr(argv[i], "ios=") != NULL && strlen(argv[i]) > 4)
|
|
|
|
{
|
|
|
|
while(argv[i][0] && !isdigit(argv[i][0])) argv[i]++;
|
|
|
|
if (atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
|
|
|
|
mainIOS = atoi(argv[i]);
|
|
|
|
}
|
|
|
|
else if (strlen(argv[i]) == 6)
|
|
|
|
{
|
|
|
|
gameid = argv[i];
|
|
|
|
for (int i=0; i < 5; i++)
|
|
|
|
if (!isalnum(gameid[i]))
|
|
|
|
gameid = NULL;
|
|
|
|
}
|
2012-04-08 17:54:34 +02:00
|
|
|
else if (argv[i] != NULL && strcasestr(argv[i], "EMULATOR_MAGIC") != NULL)
|
|
|
|
Emulator_boot = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-04-05 13:00:05 +02:00
|
|
|
gprintf("Loading cIOS: %d\n", mainIOS);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
// Load Custom IOS
|
|
|
|
bool iosOK = loadIOS(mainIOS, false);
|
2012-05-14 04:21:03 +02:00
|
|
|
|
|
|
|
ISFS_Initialize();
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
u8 mainIOSBase = 0;
|
|
|
|
iosOK = iosOK && cIOSInfo::D2X(mainIOS, &mainIOSBase);
|
2012-05-14 04:21:03 +02:00
|
|
|
gprintf("Loaded cIOS: %u has base %u\n", mainIOS, mainIOSBase);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-02-04 18:31:13 +01:00
|
|
|
Open_Inputs(); //init wiimote early
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
// Init
|
|
|
|
Sys_Init();
|
|
|
|
Sys_ExitTo(EXIT_TO_HBC);
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
int ret = 0;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
do
|
|
|
|
{
|
|
|
|
bool deviceAvailable = false;
|
|
|
|
|
|
|
|
u8 timeout = 0;
|
|
|
|
while(!deviceAvailable && timeout++ != 20)
|
|
|
|
{
|
|
|
|
DeviceHandler::Instance()->MountAll();
|
|
|
|
sleep(1);
|
|
|
|
|
2012-04-29 17:42:35 +02:00
|
|
|
for(u8 device = USB1; device <= USB8; device++)
|
2012-05-13 17:13:33 +02:00
|
|
|
{
|
2012-01-21 21:57:41 +01:00
|
|
|
if(DeviceHandler::Instance()->IsInserted(device))
|
|
|
|
deviceAvailable = true;
|
2012-05-13 17:13:33 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2012-04-29 17:42:35 +02:00
|
|
|
if(DeviceHandler::Instance()->IsInserted(SD))
|
|
|
|
deviceAvailable = true;
|
|
|
|
|
|
|
|
if(!deviceAvailable)
|
|
|
|
Sys_Exit();
|
2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
bool dipOK = Disc_Init() >= 0;
|
|
|
|
|
|
|
|
CMenu menu(vid);
|
|
|
|
menu.init();
|
2012-04-08 17:54:34 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
mainMenu = &menu;
|
|
|
|
if (!iosOK)
|
|
|
|
{
|
|
|
|
menu.error(sfmt("d2x cIOS %i rev6 or later is required", mainIOS));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!dipOK)
|
|
|
|
{
|
|
|
|
menu.error(L"Could not initialize the DIP module!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (gameid != NULL && strlen(gameid) == 6)
|
|
|
|
menu._directlaunch(gameid);
|
|
|
|
else
|
2012-04-08 17:54:34 +02:00
|
|
|
{
|
|
|
|
if(Emulator_boot)
|
|
|
|
menu.m_Emulator_boot = true;
|
2012-01-21 21:57:41 +01:00
|
|
|
ret = menu.main();
|
2012-04-08 17:54:34 +02:00
|
|
|
}
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
|
|
|
if (bootHB)
|
|
|
|
{
|
2012-03-11 16:55:13 +01:00
|
|
|
//IOS_ReloadIOS(58);
|
2012-01-21 21:57:41 +01:00
|
|
|
BootHomebrew();
|
|
|
|
}
|
2012-02-04 18:31:13 +01:00
|
|
|
Open_Inputs(); //reinit wiimote
|
2012-01-21 21:57:41 +01:00
|
|
|
} while (ret == 1);
|
|
|
|
|
|
|
|
WifiGecko_Close();
|
|
|
|
|
|
|
|
Nand::Instance()->Disable_Emu();
|
|
|
|
Nand::DestroyInstance();
|
|
|
|
|
|
|
|
Sys_Exit();
|
|
|
|
return 0;
|
2012-03-11 16:55:13 +01:00
|
|
|
};
|