2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <unistd.h>
|
2012-08-05 15:48:15 +02:00
|
|
|
|
2012-02-18 16:29:22 +01:00
|
|
|
#include "defines.h"
|
|
|
|
#include "svnrev.h"
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-08-05 15:48:15 +02:00
|
|
|
#include "channel/nand.hpp"
|
|
|
|
#include "devicemounter/DeviceHandler.hpp"
|
|
|
|
#include "gecko/gecko.h"
|
|
|
|
#include "gecko/wifi_gecko.h"
|
|
|
|
#include "gui/video.hpp"
|
|
|
|
#include "gui/text.hpp"
|
|
|
|
#include "homebrew/homebrew.h"
|
|
|
|
#include "loader/disc.h"
|
|
|
|
#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-01-21 21:57:41 +01:00
|
|
|
CMenu *mainMenu;
|
2012-08-24 20:01:40 +02:00
|
|
|
bool useMainIOS;
|
2012-05-13 17:13:33 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
__exception_setreload(5);
|
2012-08-05 15:48:15 +02:00
|
|
|
InitGecko();
|
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();
|
2012-05-16 16:48:01 +02:00
|
|
|
|
2012-08-21 18:33:44 +02:00
|
|
|
Nand::Instance()->Init_ISFS();
|
2012-07-06 14:12:03 +02:00
|
|
|
MEM2_init(47); //Should be safe to use
|
2012-06-07 18:02:23 +02: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
|
|
|
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-07-14 18:19:41 +02:00
|
|
|
#ifndef DOLPHIN
|
2012-01-21 21:57:41 +01:00
|
|
|
// Load Custom IOS
|
2012-08-19 16:06:09 +02:00
|
|
|
if(neek2o())
|
|
|
|
{
|
|
|
|
iosOK = true;
|
|
|
|
memset(&CurrentIOS, 0, sizeof(IOS_Info));
|
|
|
|
CurrentIOS.Version = 254;
|
2012-08-24 15:50:17 +02:00
|
|
|
CurrentIOS.Type = IOS_TYPE_NEEK2O;
|
2012-08-19 16:06:09 +02:00
|
|
|
CurrentIOS.Base = 254;
|
|
|
|
CurrentIOS.Revision = 999;
|
|
|
|
DCFlushRange(&CurrentIOS, sizeof(IOS_Info));
|
2012-08-24 22:46:13 +02:00
|
|
|
DeviceHandler::Instance()->SetModes();
|
2012-08-19 16:06:09 +02:00
|
|
|
}
|
2012-08-26 18:23:35 +02:00
|
|
|
else if(AHBRPOT_Patched() && IOS_GetVersion() == 58)
|
2012-08-19 16:06:09 +02:00
|
|
|
{
|
2012-08-26 18:23:35 +02:00
|
|
|
gprintf("AHBPROT patched out, use IOS58\n");
|
|
|
|
iosOK = loadIOS(58, false);
|
2012-08-24 00:29:15 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-26 18:23:35 +02:00
|
|
|
gprintf("Loading cIOS: %d\n", mainIOS);
|
|
|
|
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);
|
2012-08-19 16:06:09 +02:00
|
|
|
}
|
2012-07-14 18:19:41 +02:00
|
|
|
#else
|
2012-08-19 16:06:09 +02:00
|
|
|
iosOK = true;
|
2012-07-14 18:19:41 +02:00
|
|
|
#endif
|
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-07-14 18:19:41 +02:00
|
|
|
#ifndef DOLPHIN
|
2012-08-24 20:01:40 +02:00
|
|
|
const DISC_INTERFACE *handle = DeviceHandler::GetUSB0Interface();
|
|
|
|
u8 timeout = time(NULL);
|
2012-08-25 14:06:21 +02:00
|
|
|
while(time(NULL) - timeout < 20)
|
2012-08-24 20:01:40 +02:00
|
|
|
{
|
2012-08-25 14:06:21 +02:00
|
|
|
if(handle->startup() && handle->isInserted())
|
2012-08-24 20:01:40 +02:00
|
|
|
break;
|
|
|
|
usleep(50000);
|
|
|
|
}
|
2012-08-24 15:50:17 +02:00
|
|
|
#endif
|
2012-08-24 20:01:40 +02:00
|
|
|
DeviceHandler::Instance()->MountAll();
|
|
|
|
vid.waitMessage(0.15f);
|
|
|
|
bool dipOK = Disc_Init() >= 0;
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2012-08-24 20:01:40 +02:00
|
|
|
mainMenu = new CMenu(vid);
|
2012-08-26 14:05:04 +02:00
|
|
|
Open_Inputs();
|
2012-08-24 20:01:40 +02:00
|
|
|
mainMenu->init();
|
2012-08-26 14:05:04 +02:00
|
|
|
if(CurrentIOS.Version != mainIOS && !neek2o())
|
|
|
|
{
|
|
|
|
if(useMainIOS || (!DeviceHandler::Instance()->IsInserted(SD) && !DeviceHandler::Instance()->IsInserted(USB1)))
|
|
|
|
{
|
|
|
|
iosOK = loadIOS(mainIOS, true) && CustomIOS(CurrentIOS.Type);
|
|
|
|
Open_Inputs();
|
|
|
|
mainMenu->init();
|
|
|
|
}
|
|
|
|
}
|
2012-08-24 20:01:40 +02:00
|
|
|
if(!iosOK)
|
|
|
|
mainMenu->terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games.");
|
2012-08-26 14:05:04 +02:00
|
|
|
else if(!DeviceHandler::Instance()->IsInserted(SD) && !DeviceHandler::Instance()->IsInserted(USB1))
|
2012-08-24 20:01:40 +02:00
|
|
|
mainMenu->terror("errboot2", L"Could not find a device to save configuration files on!");
|
|
|
|
else if(!dipOK)
|
|
|
|
mainMenu->terror("errboot3", L"Could not initialize the DIP module!");
|
|
|
|
else if(gameid != NULL && strlen(gameid) == 6)
|
|
|
|
mainMenu->directlaunch(gameid);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(Emulator_boot)
|
|
|
|
mainMenu->m_Emulator_boot = true;
|
|
|
|
mainMenu->main();
|
2012-07-07 21:09:56 +02:00
|
|
|
}
|
2012-08-26 14:05:04 +02:00
|
|
|
//Exit WiiFlow, no game booted...
|
2012-07-11 16:59:09 +02:00
|
|
|
mainMenu->cleanup();
|
2012-08-24 20:01:40 +02:00
|
|
|
DeviceHandler::Instance()->UnMountAll();
|
2012-08-21 18:33:44 +02:00
|
|
|
Nand::Instance()->DeInit_ISFS();
|
2012-01-21 21:57:41 +01:00
|
|
|
Sys_Exit();
|
2012-07-06 21:59:45 +02:00
|
|
|
exit(1);
|
2012-01-21 21:57:41 +01:00
|
|
|
return 0;
|
2012-07-06 21:59:45 +02:00
|
|
|
}
|