WiiFlow_Lite/source/loader/sys.c

184 lines
3.7 KiB
C
Raw Normal View History

#include <ogc/machine/processor.h>
#include <ogc/lwp_threads.h>
#include <ogc/lwp_watchdog.h>
#include <stdio.h>
#include <ogcsys.h>
#include <stdlib.h>
#include <string.h>
#include "fs.h"
#include "mload.h"
#include "sys.h"
#include "channel/channel_launcher.h"
#include "loader/nk.h"
#include "gecko/gecko.hpp"
#include "memory/mem2.hpp"
#include "memory/memory.h"
#include "wiiuse/wpad.h"
#include "sicksaxis-wrapper/sicksaxis-wrapper.h"
/* Variables */
bool reset = false;
bool shutdown = false;
volatile u8 ExitOption = 0;
const char *NeekPath = NULL;
char wii_games_dir[64];
char gc_games_dir[64];
void __Wpad_PowerCallback()
{
shutdown = 1;
}
void Open_Inputs(void)
{
/* Initialize Wiimote subsystem */
PAD_Init();
WPAD_Init();
DS3_Init();
//drc
/* Set POWER button callback */
WPAD_SetPowerButtonCallback(__Wpad_PowerCallback);
WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
WPAD_SetIdleTimeout(60 * 2); // idle after 2 minutes
}
void Close_Inputs(void)
{
u32 cnt;
/* Disconnect Wiimotes */
for(cnt = 0; cnt < 4; cnt++)
WPAD_Disconnect(cnt);
/* Shutdown Wiimote subsystem */
WPAD_Shutdown();
DS3_Cleanup();
}
bool Sys_Exiting(void)
{
DCFlushRange(&reset, 32);
DCFlushRange(&shutdown, 32);
return reset || shutdown;
}
int Sys_GetExitTo(void)
{
return ExitOption;
}
void Sys_ExitTo(int option)
{
ExitOption = option;
//magic word to force wii menu in priiloader.
if(ExitOption == EXIT_TO_MENU)
{
*Priiloader_CFG1 = 0x50756E65;// Pune
*Priiloader_CFG2 = 0x50756E65;
}
else if(ExitOption == EXIT_TO_PRIILOADER)
{
*Priiloader_CFG1 = 0x4461636F;// Daco
*Priiloader_CFG2 = 0x4461636F;
}
else // PRIILOADER_DEF
{
*Priiloader_CFG1 = 0xFFFFFFFF;
*Priiloader_CFG2 = 0xFFFFFFFF;
}
DCFlushRange((void*)Priiloader_CFG1, 4);
DCFlushRange((void*)Priiloader_CFG2, 4);
}
void Sys_Exit(void)
{
/* Shutdown Inputs */
Close_Inputs();
/* Just shutdown console*/
if(ExitOption == BUTTON_CALLBACK)
SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0);
/* We wanna to boot something */
WII_Initialize();
/* if in neek2o mode Launch_nk will just return to neek2o system menu and not launch anything */
if(ExitOption == EXIT_TO_WFNK2O)
neek2o changes: - re made it possible to use SD emunands with sNeek2o r96. - added vwii r96 beta 9.6 support. wiiflow lite will now look for vwiikernal.bin and emunands must be in a subfolder of vwiinands on USB only. - when exiting a emunand game using neek2o if on wii it will use the back2nand channel to return you to wii system menu or if on wiiu it will return you to wiiu system channel because returning to the vwii system menu isn't possible. - when using wiiflow lite and exit to neek2o it will just launch neek2o system menu. from there you can launch wiiflow or wiiflow lite (if installed on emunand) to use cheats on a emunand game. otherwise cheats do not work when using neek2o to launch a game. banner changes: - now when moving from banner to banner the background music will not play and you will not see coverflow (for a second) when using full screen banners. - now on game selected categories menu the banner will change when you change games using '+' or '-' buttons - added custom banners for plugin games. no longer using trialer thp videos as banners for plugin games. put your custom banners in the custom banner folder plus the plugin cover folder and name them the same as the rom with extension plus .bnr just like how you do for the covers. to make a plugin game banner i suggest downloading one of abdallahterro's custom gamecube dios mios booter channels and use customizemii to change the images (and sound if you want). make sure the images match exactly the size of the one's already there. when changes are done extract the banner and rename it and put it in the proper folder as previously mentioned. other changes: - trailer videos still work even for plugin games. again for plugins rename the thp and ogg file to match the rom plus extension and .thp or .ogg. on game selected screen press '-' to start or quit a trailer video if one is available. pressing 'B' or 'Home' will quit the video and return you to the main screen. - when flipping a cover none of the buttons are available and the mini banner is not shown until you press 'B' to de flip the cover to normal front view. - fixed game info menu - in case a custom channel is selected and is not included in gametdb it will display a message 'no game info' instead of random stuff from the last game viewed. tested on wiiflow lite forwarder channel. - now stopping sounds and music early when exiting wiiflow to prevent music from stuttering when exiting. - other minor coding changes.
2017-05-15 19:50:24 +02:00
Launch_nk(0x1000157464C41LL, NeekPath, 0);// 57464C41 = WFLA : 44574641 = DWFA
else if(ExitOption == EXIT_TO_SMNK2O)
Launch_nk(0, NeekPath, 0);
else if(ExitOption == EXIT_TO_BOOTMII)
neek2o changes: - re made it possible to use SD emunands with sNeek2o r96. - added vwii r96 beta 9.6 support. wiiflow lite will now look for vwiikernal.bin and emunands must be in a subfolder of vwiinands on USB only. - when exiting a emunand game using neek2o if on wii it will use the back2nand channel to return you to wii system menu or if on wiiu it will return you to wiiu system channel because returning to the vwii system menu isn't possible. - when using wiiflow lite and exit to neek2o it will just launch neek2o system menu. from there you can launch wiiflow or wiiflow lite (if installed on emunand) to use cheats on a emunand game. otherwise cheats do not work when using neek2o to launch a game. banner changes: - now when moving from banner to banner the background music will not play and you will not see coverflow (for a second) when using full screen banners. - now on game selected categories menu the banner will change when you change games using '+' or '-' buttons - added custom banners for plugin games. no longer using trialer thp videos as banners for plugin games. put your custom banners in the custom banner folder plus the plugin cover folder and name them the same as the rom with extension plus .bnr just like how you do for the covers. to make a plugin game banner i suggest downloading one of abdallahterro's custom gamecube dios mios booter channels and use customizemii to change the images (and sound if you want). make sure the images match exactly the size of the one's already there. when changes are done extract the banner and rename it and put it in the proper folder as previously mentioned. other changes: - trailer videos still work even for plugin games. again for plugins rename the thp and ogg file to match the rom plus extension and .thp or .ogg. on game selected screen press '-' to start or quit a trailer video if one is available. pressing 'B' or 'Home' will quit the video and return you to the main screen. - when flipping a cover none of the buttons are available and the mini banner is not shown until you press 'B' to de flip the cover to normal front view. - fixed game info menu - in case a custom channel is selected and is not included in gametdb it will display a message 'no game info' instead of random stuff from the last game viewed. tested on wiiflow lite forwarder channel. - now stopping sounds and music early when exiting wiiflow to prevent music from stuttering when exiting. - other minor coding changes.
2017-05-15 19:50:24 +02:00
IOS_ReloadIOS(0xfe);// IOS254 Bootmii IOS
else if(ExitOption == EXIT_TO_HBC)
{
WII_LaunchTitle(HBC_OHBC);
WII_LaunchTitle(HBC_LULZ);
WII_LaunchTitle(HBC_108);
WII_LaunchTitle(HBC_JODI);
WII_LaunchTitle(HBC_HAXX);
}
else if(ExitOption == EXIT_TO_WIIU)
WII_LaunchTitle(WIIU_CHANNEL);
/* else Return to System Menu */
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
exit(1);
}
void __Sys_ResetCallback(void)
{
reset = true;
}
void __Sys_PowerCallback(void)
{
shutdown = true;
}
void Sys_Init(void)
{
/* Set RESET/POWER button callback */
SYS_SetResetCallback(__Sys_ResetCallback);
SYS_SetPowerCallback(__Sys_PowerCallback);
}
bool AHBPROT_Patched(void)
{
return (*HW_AHBPROT == 0xFFFFFFFF);
}
/* WiiU Check by crediar, thanks */
bool WiiUChecked = false;
bool WiiUMode = false;
bool IsOnWiiU(void)
{
if(WiiUChecked)
return WiiUMode;
if((*HW_PROCESSOR >> 16) == 0xCAFE)
WiiUMode = true;
WiiUChecked = true;
return WiiUMode;
}
void Sys_SetNeekPath(const char *Path)
{
NeekPath = Path;
}
bool hw_checked = false;
bool on_hw = false;
bool Sys_HW_Access(void)
{
if(hw_checked == true)
return on_hw;
on_hw = AHBPROT_Patched();
hw_checked = true;
return on_hw;
}
/* KILL IT */
s32 __IOS_LoadStartupIOS() { return 0; }