[Wii] added game auto-load support through DOL args (compatible with "Wiiflow"

plugin arguments)
NOTE: if "loader" argument is sent, return to loader stub will automatically be
allowed either from Exit menu or using Wiimote POWER button
This commit is contained in:
EkeEke 2013-06-30 18:01:37 +02:00
parent 5ee0d975dd
commit 442a475e56
3 changed files with 109 additions and 28 deletions

View File

@ -126,6 +126,10 @@ extern const u8 Button_sm_blue_png[];
extern const u8 Button_sm_grey_png[];
extern const u8 Button_sm_yellow_png[];
/* Exit callback */
void (*reload)(void);
/*****************************************************************************/
/* Specific Menu Callbacks */
/*****************************************************************************/
@ -3313,19 +3317,8 @@ static void exitmenu(void)
"Return to Loader",
};
/* autodetect loader stub */
int maxitems = 2;
u32 *sig = (u32*)0x80001800;
void (*reload)() = (void(*)())0x80001800;
#ifdef HW_RVL
if ((sig[1] == 0x53545542) && (sig[2] == 0x48415858)) // HBC
#else
if (sig[0] == 0x7c6000a6) // SDLOAD
#endif
{
maxitems = 3;
}
/* check if loader stub exists */
int maxitems = reload ? 3 : 2;
/* display option window */
switch (GUI_OptionWindow(&menu_main, osd_version, items, maxitems))
@ -3404,12 +3397,22 @@ void mainmenu(void)
slot_autosave(0, config.s_device);
#ifdef HW_RVL
/* Wiimote shutdown */
/* Detect shutdown request */
if (Shutdown)
{
GUI_FadeOut();
shutdown();
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
if (reload)
{
/* exit to loader if requested */
SYS_ResetSystem(SYS_SHUTDOWN,0,0);
__lwp_thread_stopmultitasking(*reload);
}
else
{
/* shutdown system by default */
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
}
}
/* Wiimote pointer */

View File

@ -41,6 +41,6 @@
#define _MENU_H
extern void mainmenu(void);
extern void (*reload)(void);
#endif

102
gx/main.c
View File

@ -3,7 +3,7 @@
*
* Genesis Plus GX
*
* Copyright Eke-Eke (2007-2012), based on original work from Softdev (2006)
* Copyright Eke-Eke (2007-2013), based on original work from Softdev (2006)
*
* Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met:
@ -66,13 +66,21 @@ u32 delta_samp[LOGSIZE];
#ifdef HW_RVL
/****************************************************************************
* Power Button callback
* Power Button callbacks
***************************************************************************/
static void PowerOff_cb(void)
{
Shutdown = 1;
ConfigRequested = 1;
reload = 0;
}
static void Reload_cb(void)
{
Shutdown = 1;
ConfigRequested = 1;
}
#endif
/****************************************************************************
@ -396,7 +404,7 @@ void reloadrom(void)
interlaced = 0;
audio_init(SAMPLERATE_48KHZ, get_framerate());
/* Switch virtual system on */
/* System Power-On */
system_init();
system_reset();
@ -425,12 +433,24 @@ void shutdown(void)
/* auto-save State file */
slot_autosave(config.s_default,config.s_device);
/* shutdown emulation */
/* shutdown emulation core */
audio_shutdown();
/* shutdown audio & video engines */
gx_audio_Shutdown();
gx_video_Shutdown();
#ifdef HW_RVL
/* unmount all devices */
ISO9660_Unmount("dvd:");
fatUnmount("sd");
fatUnmount("usb");
/* shutdown all devices */
DI_Close();
sdio_Deinitialize();
USBStorage_Deinitialize();
MOUSE_Deinit();
#endif
}
@ -448,6 +468,21 @@ int main (int argc, char *argv[])
DI_UseCache(0);
DI_Init();
/* autodetect loader arguments */
if ((argc >= 3) && (argv[1] != NULL))
{
/* check if autoloading from USB is requested */
if (!strncasecmp(argv[1], "usb:/", 5))
{
/* reload to IOS58 for USB2 support */
if (IOS_GetVersion() != 58)
{
/* warning: DVD support will be disabled after IOS reloading ! */
IOS_ReloadIOS(58);
}
}
}
sprintf(osd_version, "%s (IOS %d)", VERSION, IOS_GetVersion());
#else
sprintf(osd_version, "%s (GCN)", VERSION);
@ -576,16 +611,29 @@ int main (int argc, char *argv[])
else mkdir(pathname,S_IRWXU);
}
/* initialize sound engine */
/* initialize audio engine */
gx_audio_Init();
/* initialize genesis plus core */
/* initialize emulation */
history_default();
config_default();
init_machine();
/* auto-load last ROM file */
if (config.autoload)
/* file autoloading */
int autoload = config.autoload;
/* autodetect loader arguments */
if ((argc >= 3) && (argv[1] != NULL) && (argv[2] != NULL))
{
/* automatically load any file passed as argument */
autoload = 1;
/* add the file to the top of the history. */
history_add_file(argv[1], argv[2], 0);
}
/* automatically load first file from history list if requested */
if (autoload)
{
SILENT = 1;
if (OpenDirectory(TYPE_RECENT, -1))
@ -601,18 +649,48 @@ int main (int argc, char *argv[])
SILENT = 0;
}
/* show disclaimer */
/* show disclaimer before entering menu */
if (ConfigRequested)
{
legal();
}
/* initialize stub loader detection */
reload = 0;
#ifdef HW_RVL
/* power button callback */
SYS_SetPowerCallback(PowerOff_cb);
/* autodetect loader arguments */
if ((argc >= 4) && (argv[3] != NULL))
{
/* assume proper loader stub exists */
reload = (void(*)())0x80001800;
/* return to loader when POWER buttons are pressed */
SYS_SetPowerCallback(Reload_cb);
}
else
{
/* autodetect HomeBrew Channel stub */
u32 *sig = (u32*)0x80001800;
if ((sig[1] == 0x53545542) && (sig[2] == 0x48415858))
{
reload = (void(*)())0x80001800;
}
/* by default, shutdown system when POWER buttons are pressed */
SYS_SetPowerCallback(PowerOff_cb);
}
#else
/* autodetect SDLoad stub */
u32 *sig = (u32*)0x80001800;
if (sig[0] == 0x7c6000a6)
{
reload = (void(*)())0x80001800;
}
#endif
/* reset button callback */
/* RESET button callback */
SYS_SetResetCallback(Reset_cb);
/* main emulation loop */