2012-01-21 21:57:41 +01:00
|
|
|
|
|
|
|
#include <ogc/system.h>
|
|
|
|
#include <unistd.h>
|
2018-07-15 22:23:32 +02:00
|
|
|
#include <sys/stat.h>
|
2012-08-05 15:48:15 +02:00
|
|
|
|
2018-11-12 21:38:37 +01:00
|
|
|
#include "defines.h"
|
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"
|
2012-12-27 00:22:44 +01:00
|
|
|
#include "channel/nand_save.hpp"
|
2012-08-05 15:48:15 +02:00
|
|
|
#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
|
|
|
|
2018-08-01 14:27:12 +02:00
|
|
|
bool isWiiVC = false;
|
2019-04-29 15:14:54 +02:00
|
|
|
bool useMainIOS = true;
|
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
|
|
|
|
2018-07-09 16:53:35 +02:00
|
|
|
/* quick check if we will be using a USB device. */
|
|
|
|
/* if not then we can skip the 20 second cycle trying to connect a USB device. */
|
|
|
|
/* this is nice for SD only users */
|
|
|
|
bool isUsingUSB() {
|
2018-08-01 14:27:12 +02:00
|
|
|
if(isWiiVC)
|
|
|
|
return false;
|
2018-07-09 16:53:35 +02:00
|
|
|
/* First check if the app path exists on the SD card, if not then we're using USB */
|
|
|
|
struct stat dummy;
|
|
|
|
string appPath = fmt("%s:/%s", DeviceName[SD], APPS_DIR);
|
|
|
|
if(DeviceHandle.IsInserted(SD) && DeviceHandle.GetFSType(SD) != PART_FS_WBFS && stat(appPath.c_str(), &dummy) != 0)
|
|
|
|
{
|
|
|
|
// No app path exists on SD card, so assuming we're using USB.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that the config file exists, or we can't do the following checks */
|
|
|
|
string configPath = fmt("%s/" CFG_FILENAME, appPath.c_str());
|
|
|
|
if(stat(configPath.c_str(), &dummy) != 0)
|
|
|
|
{
|
|
|
|
// The app path is on SD but no config file exists, so assuming we might need USB.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Load the config file */
|
|
|
|
Config m_cfg;// = new Config();
|
|
|
|
if(!m_cfg.load(configPath.c_str()))
|
|
|
|
{
|
|
|
|
// The app path is on SD and a config file exists, but we can't load it, so assuming we might need USB.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If any of the sections have partition set > 0, we're on USB */
|
|
|
|
const char *domains[] = {WII_DOMAIN, GC_DOMAIN, CHANNEL_DOMAIN, PLUGIN_DOMAIN, HOMEBREW_DOMAIN};
|
|
|
|
for(int i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
if(!m_cfg.getBool(domains[i], "disable", false) && m_cfg.getInt(domains[i], "partition", SD) != SD)
|
|
|
|
{
|
|
|
|
// a domain is enabled and partition is not SD, so assuming we're using USB.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2019-05-15 17:16:53 +02:00
|
|
|
|
|
|
|
/* if sd_only is false, then we're using USB */
|
|
|
|
if(!m_cfg.getBool("general", "sd_only", true))
|
|
|
|
{
|
|
|
|
// sd_only is false, so assuming we're using USB.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-09 16:53:35 +02:00
|
|
|
gprintf("using SD only, no need for USB mounting.\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2013-12-24 16:35:59 +01:00
|
|
|
MEM_init(); //Inits both mem1lo and mem2
|
2016-12-01 01:05:39 +01:00
|
|
|
mainIOS = DOL_MAIN_IOS;// 249
|
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
|
2018-11-12 21:38:37 +01:00
|
|
|
gprintf(" \nWelcome to %s %s!\nThis is the debug output.\n", APP_NAME, APP_VERSION);
|
2012-05-16 16:48:01 +02:00
|
|
|
|
2013-02-08 11:39:07 +01:00
|
|
|
bool iosOK = true;
|
2018-06-27 14:47:03 +02:00
|
|
|
char *gameid = NULL;
|
|
|
|
bool showFlashImg = true;
|
2018-06-13 17:36:58 +02:00
|
|
|
bool wait_loop = false;
|
|
|
|
char wait_dir[256];
|
|
|
|
memset(&wait_dir, 0, sizeof(wait_dir));
|
2018-06-27 14:47:03 +02: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]++;
|
2016-11-07 16:06:00 +01:00
|
|
|
if(atoi(argv[i]) < 254 && atoi(argv[i]) > 0)
|
2012-01-21 21:57:41 +01:00
|
|
|
mainIOS = atoi(argv[i]);
|
|
|
|
}
|
2018-06-27 14:47:03 +02:00
|
|
|
else if(strcasestr(argv[i], "waitdir=") != NULL)
|
|
|
|
{
|
|
|
|
char *ptr = strcasestr(argv[i], "waitdir=");
|
2018-11-12 21:38:37 +01:00
|
|
|
strncpy(wait_dir, ptr+strlen("waitdir="), sizeof(wait_dir) - 1);
|
2018-06-27 14:47:03 +02:00
|
|
|
}
|
|
|
|
else if(strcasestr(argv[i], "Waitloop") != NULL)
|
|
|
|
wait_loop = true;
|
|
|
|
else if(strcasestr(argv[i], "noflash") != NULL)
|
|
|
|
showFlashImg = false;
|
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
|
|
|
}
|
2018-06-27 14:47:03 +02:00
|
|
|
}
|
2018-06-13 17:36:58 +02:00
|
|
|
|
2012-01-21 21:57:41 +01:00
|
|
|
}
|
2018-06-27 14:47:03 +02:00
|
|
|
/* Init video */
|
|
|
|
m_vid.init();
|
|
|
|
if(showFlashImg)
|
|
|
|
m_vid.startImage();
|
|
|
|
|
2018-08-01 14:27:12 +02:00
|
|
|
/* check if WiiVC */
|
|
|
|
WiiDRC_Init();
|
|
|
|
isWiiVC = WiiDRC_Inited();
|
|
|
|
|
|
|
|
if(IsOnWiiU())
|
|
|
|
{
|
|
|
|
gprintf("WiiU\n");
|
|
|
|
if(isWiiVC)
|
|
|
|
gprintf("WiiVC\n");
|
|
|
|
else
|
|
|
|
gprintf("vWii Mode\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gprintf("Real Wii\n");
|
|
|
|
|
|
|
|
gprintf("AHBPROT disabled = %s\n", AHBPROT_Patched() ? "yes" : "no");
|
|
|
|
|
2018-06-27 14:47:03 +02:00
|
|
|
/* Init device partition handlers */
|
|
|
|
DeviceHandle.Init();
|
|
|
|
|
|
|
|
/* Init NAND handlers */
|
|
|
|
NandHandle.Init();
|
2018-08-01 14:27:12 +02:00
|
|
|
|
|
|
|
if(isWiiVC)
|
|
|
|
{
|
|
|
|
NandHandle.Init_ISFS();
|
|
|
|
IOS_GetCurrentIOSInfo();
|
|
|
|
DeviceHandle.SetModes();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NandHandle.LoadDefaultIOS(); /* safe reload to preferred IOS */
|
|
|
|
|
|
|
|
/* load and check wiiflow save for possible new IOS and Port settings */
|
|
|
|
if(InternalSave.CheckSave())
|
|
|
|
InternalSave.LoadSettings();
|
|
|
|
|
|
|
|
/* Handle (c)IOS Loading */
|
|
|
|
if(useMainIOS && CustomIOS(IOS_GetType(mainIOS))) /* Requested */
|
2019-04-29 15:14:54 +02:00
|
|
|
iosOK = loadIOS(mainIOS, false) && CustomIOS(CurrentIOS.Type);// reload to cIOS (249 by default)
|
2018-12-24 14:42:31 +01:00
|
|
|
else
|
2019-04-29 15:14:54 +02:00
|
|
|
gprintf("Using IOS58\n");// stay on IOS58. no reload to cIOS
|
2018-08-01 14:27:12 +02:00
|
|
|
}
|
2018-06-27 14:47:03 +02:00
|
|
|
|
2018-07-09 16:53:35 +02:00
|
|
|
/* sys inits */
|
|
|
|
Sys_Init();// set reset and power button callbacks
|
|
|
|
Sys_ExitTo(EXIT_TO_HBC);// set exit to in case of failed launch
|
2012-09-02 15:34:41 +02:00
|
|
|
|
2018-08-01 14:27:12 +02:00
|
|
|
/* mount SD */
|
|
|
|
DeviceHandle.MountSD();// mount SD before calling isUsingUSB() duh!
|
|
|
|
|
|
|
|
/* mount USB if needed */
|
2018-07-15 22:59:35 +02:00
|
|
|
DeviceHandle.SetMountUSB(isUsingUSB());
|
2018-07-15 22:23:32 +02:00
|
|
|
DeviceHandle.MountAllUSB();// only mounts any USB if isUsingUSB()
|
2018-06-27 14:47:03 +02:00
|
|
|
|
|
|
|
/* init wait images and show wait animation */
|
2018-06-13 17:36:58 +02:00
|
|
|
m_vid.setCustomWaitImgs(wait_dir, wait_loop);
|
2012-10-13 18:57:03 +02:00
|
|
|
m_vid.waitMessage(0.15f);
|
2012-01-21 21:57:41 +01:00
|
|
|
|
2018-06-27 14:47:03 +02:00
|
|
|
/* init controllers for input */
|
2018-08-01 14:27:12 +02:00
|
|
|
Open_Inputs();// WPAD_SetVRes() is called later in mainMenu.init() during cursor init which gets the theme pointer images
|
2018-06-27 14:47:03 +02:00
|
|
|
|
|
|
|
/* init configs, folders, coverflow, gui and more */
|
2017-09-22 00:03:41 +02:00
|
|
|
if(mainMenu.init())
|
2012-08-26 14:05:04 +02:00
|
|
|
{
|
2018-07-16 00:12:56 +02:00
|
|
|
if(CurrentIOS.Version != mainIOS)
|
2012-08-26 14:05:04 +02:00
|
|
|
{
|
2018-07-16 00:12:56 +02:00
|
|
|
if(useMainIOS || !DeviceHandle.UsablePartitionMounted())// if useMainIOS or there's isn't a FAT or NTFS partition
|
2017-09-22 00:03:41 +02:00
|
|
|
{
|
|
|
|
useMainIOS = false;
|
2019-05-27 18:04:46 +02:00
|
|
|
mainMenu.TempLoadIOS();// switch to cIOS
|
2017-09-22 00:03:41 +02:00
|
|
|
iosOK = CustomIOS(CurrentIOS.Type);
|
|
|
|
}
|
2012-08-26 14:05:04 +02:00
|
|
|
}
|
2017-09-22 00:03:41 +02:00
|
|
|
if(CurrentIOS.Version == mainIOS)
|
|
|
|
useMainIOS = true; //Needed for later checks
|
|
|
|
if(!iosOK)
|
|
|
|
mainMenu.terror("errboot1", L"No cIOS found!\ncIOS d2x 249 base 56 and 250 base 57 are enough for all your games.");
|
|
|
|
else if(!DeviceHandle.UsablePartitionMounted())
|
|
|
|
mainMenu.terror("errboot2", L"Could not find a device to save configuration files on!");
|
|
|
|
else if(WDVD_Init() < 0)
|
|
|
|
mainMenu.terror("errboot3", L"Could not initialize the DIP module!");
|
2018-06-27 14:47:03 +02:00
|
|
|
else // alls good lets start wiiflow
|
2017-09-22 00:03:41 +02:00
|
|
|
{
|
2018-08-01 14:27:12 +02:00
|
|
|
if(!isWiiVC)
|
|
|
|
writeStub();// copy return stub to memory
|
2018-06-27 14:47:03 +02:00
|
|
|
if(gameid != NULL && strlen(gameid) == 6)// if argv game ID then launch it
|
2017-09-22 00:03:41 +02:00
|
|
|
mainMenu.directlaunch(gameid);
|
|
|
|
else
|
2018-06-27 14:47:03 +02:00
|
|
|
mainMenu.main();// start wiiflow with main menu displayed
|
2017-09-22 00:03:41 +02:00
|
|
|
}
|
|
|
|
//Exit WiiFlow, no game booted...
|
|
|
|
mainMenu.cleanup();// removes all sounds, fonts, images, coverflow, plugin stuff, source menu and clear memory
|
2012-08-26 14:05:04 +02:00
|
|
|
}
|
-updating wiiflow lite to beta 4.3.0
-fixed using categories to hide GC disc 2's. Apparently this has never really worked right for some time or ever.
-fixed deleting the cached cover texture file for plugin games. Delete cover for plugins only deletes the cached texture file (.wfc)
-fixed favorites and adultonly (parental lock) for plugin games. Apparently I may have broke this a few revisions back.
-favorites and adultonly for plugin games now have their own domains in gamecfg1- [FAVORITES_PLUGINS] and [ADULTONLY_PLUGINS]. just makes it more organized.
-only wii, GC, channels are added to [PLAYCOUNT] and [LAST_PLAYED] in gamecfg1.
-now loading gamecfg1 at startup and leaving it loaded till exit. no more loading it and unloading all the time.
-fixed scrolling for game_info synopsis, credits, and help text.
-made source menu buttons wider for wiiflow default. old 80x80, now 100x80. looks better.
-display music info now defaults to off
-screensaver_disabled now defaults to yes
-show GC view button is now on by default no matter what. the only way it is disabled is if you edit wiiflow.ini manually. this is how all the view buttons work.
-removed hiding homebrew button but if wiiflow locked it won't work or in sourceflow it won't show.
-dump_list is now under [GENERAL] instead of each view. Also only works for Wii, GC, and channels.
-sorting only works for Wii, GC, and Channels now. disabled for sourceflow, plugins, homebrew, and combined view.
-now if no games are found a message is shown with the current path so you can see where wiiflow is looking. (except for plugins)
-removed auto create emuNAND for emuNAND view if gamelist is empty. just go to settings>NAND settings if you want to extract or disable it.
-now when no games are found all buttons at bottom are still accessible allowing you to change the view or go to settings and change current partition or path and even extract your NAND to create a EmuNAND. Or go to Home Menu and Install a Wii or GC game.
-removed auto extract NAND to emuNAND when launching a Wii game with EmuNAND save. Now a message is diplayed saying 'emuNAND for saves not found - using real NAND'.
-made the speed at which cover titles fade in/out almost instantly.
-removed update button from Home Menu. online update code is still there but not used and probably won't be used any more as there just isn't a need for it now.
-removed ftp button from Home Menu and all code for the FTP server. I just use WiiXplorer's FTP server. it seems to work better for me.
-disabled keep USB Alive thread for now. i think there's a possibilty it might be the cause of my SD/USB files getting corrupted.
-removed Btn B and - combo to switch partitions. didn't seem useful anymore.
-redid nand emulation settings menu. looks like this now:
pg1
Select EmuNAND
EmuNAND Enulation
Select SaveNAND
SaveNAND Emulation
pg2
Extract Saves All
Missing
Extract NAND
Select Saves Partition
-no longer blocking Select Plugin menu and View icons when using source menu combined view
-now Select Plugins Menu is like switching to plugin view but you get to choose the plugins first
-now [PLUGIN] partition= is the default partition for all plugins. to change individual plugins add 'romPartition=x' to the plugin ini. x is the partition number 0 thru 8 with SD being 0. this is how my usbloadergx plugin mod works.
2016-10-05 01:44:13 +02:00
|
|
|
ShutdownBeforeExit();// unmount devices and close inputs
|
2012-01-21 21:57:41 +01:00
|
|
|
Sys_Exit();
|
|
|
|
return 0;
|
2012-07-06 21:59:45 +02:00
|
|
|
}
|