mirror of
https://github.com/dborth/snes9xgx.git
synced 2025-01-26 18:05:33 +01:00
if arguments are passed to the emu to autoboot a game, then the main
menu button should be labelled Exit, and leave the emu instead of going back to the main menu. cleanup autoboot code.
This commit is contained in:
parent
e63c43e225
commit
16e8b6dd25
@ -40,6 +40,10 @@
|
|||||||
#include "snes9x/memmap.h"
|
#include "snes9x/memmap.h"
|
||||||
#include "snes9x/cheats.h"
|
#include "snes9x/cheats.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern char* strcasestr(const char *, const char *);
|
||||||
|
}
|
||||||
|
|
||||||
BROWSERINFO browser;
|
BROWSERINFO browser;
|
||||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||||
|
|
||||||
@ -656,3 +660,32 @@ OpenGameList ()
|
|||||||
BrowserChangeFolder();
|
BrowserChangeFolder();
|
||||||
return browser.numEntries;
|
return browser.numEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AutoloadGame(char* filepath, char* filename) {
|
||||||
|
ResetBrowser();
|
||||||
|
|
||||||
|
selectLoadedFile = 1;
|
||||||
|
std::string dir(filepath);
|
||||||
|
dir.assign(&dir[dir.find_last_of(":") + 2]);
|
||||||
|
strncpy(GCSettings.LoadFolder, dir.c_str(), sizeof(GCSettings.LoadFolder));
|
||||||
|
OpenGameList();
|
||||||
|
|
||||||
|
for(int i = 0; i < browser.numEntries; i++) {
|
||||||
|
// Skip it
|
||||||
|
if (strcmp(browserList[i].filename, ".") == 0 || strcmp(browserList[i].filename, "..") == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(strcasestr(browserList[i].filename, filename) != NULL) {
|
||||||
|
browser.selIndex = i;
|
||||||
|
if(IsSz()) {
|
||||||
|
BrowserLoadSz();
|
||||||
|
browser.selIndex = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(BrowserLoadFile() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -76,5 +76,6 @@ bool IsDeviceRoot(char * path);
|
|||||||
int BrowserLoadSz();
|
int BrowserLoadSz();
|
||||||
int BrowserChangeFolder();
|
int BrowserChangeFolder();
|
||||||
int BrowserLoadFile();
|
int BrowserLoadFile();
|
||||||
|
bool AutoloadGame(char* filepath, char* filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1290,6 +1290,9 @@ static int MenuGame()
|
|||||||
gameSettingsBtn.SetEffectGrow();
|
gameSettingsBtn.SetEffectGrow();
|
||||||
|
|
||||||
GuiText mainmenuBtnTxt("Main Menu", 22, (GXColor){0, 0, 0, 255});
|
GuiText mainmenuBtnTxt("Main Menu", 22, (GXColor){0, 0, 0, 255});
|
||||||
|
if(GCSettings.AutoloadGame) {
|
||||||
|
mainmenuBtnTxt.SetText("Exit");
|
||||||
|
}
|
||||||
GuiImage mainmenuBtnImg(&btnOutline);
|
GuiImage mainmenuBtnImg(&btnOutline);
|
||||||
GuiImage mainmenuBtnImgOver(&btnOutlineOver);
|
GuiImage mainmenuBtnImgOver(&btnOutlineOver);
|
||||||
GuiButton mainmenuBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
|
GuiButton mainmenuBtn(btnOutline.GetWidth(), btnOutline.GetHeight());
|
||||||
@ -1487,6 +1490,10 @@ static int MenuGame()
|
|||||||
gameScreen = NULL;
|
gameScreen = NULL;
|
||||||
free(gameScreenPng);
|
free(gameScreenPng);
|
||||||
gameScreenPng = NULL;
|
gameScreenPng = NULL;
|
||||||
|
if(GCSettings.AutoloadGame) {
|
||||||
|
ExitApp();
|
||||||
|
}
|
||||||
|
else {
|
||||||
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){175, 200, 215, 255});
|
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){175, 200, 215, 255});
|
||||||
gameScreenImg->ColorStripe(10);
|
gameScreenImg->ColorStripe(10);
|
||||||
mainWindow->Insert(gameScreenImg, 0);
|
mainWindow->Insert(gameScreenImg, 0);
|
||||||
@ -1497,6 +1504,7 @@ static int MenuGame()
|
|||||||
menu = MENU_GAMESELECTION;
|
menu = MENU_GAMESELECTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(closeBtn.GetState() == STATE_CLICKED)
|
else if(closeBtn.GetState() == STATE_CLICKED)
|
||||||
{
|
{
|
||||||
menu = MENU_EXIT;
|
menu = MENU_EXIT;
|
||||||
|
@ -443,6 +443,7 @@ DefaultSettings ()
|
|||||||
|
|
||||||
GCSettings.WiimoteOrientation = 0;
|
GCSettings.WiimoteOrientation = 0;
|
||||||
GCSettings.ExitAction = 0;
|
GCSettings.ExitAction = 0;
|
||||||
|
GCSettings.AutoloadGame = 0;
|
||||||
GCSettings.MusicVolume = 20;
|
GCSettings.MusicVolume = 20;
|
||||||
GCSettings.SFXVolume = 40;
|
GCSettings.SFXVolume = 40;
|
||||||
GCSettings.Rumble = 1;
|
GCSettings.Rumble = 1;
|
||||||
|
@ -93,26 +93,6 @@ void ExitCleanup()
|
|||||||
void (*PSOReload) () = (void (*)()) 0x80001800;
|
void (*PSOReload) () = (void (*)()) 0x80001800;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void ExitToWiiflow()
|
|
||||||
{
|
|
||||||
ShutoffRumble();
|
|
||||||
SavePrefs(SILENT);
|
|
||||||
if (SNESROMSize > 0 && !ConfigRequested && GCSettings.AutoSave == 1)
|
|
||||||
SaveSRAMAuto(SILENT);
|
|
||||||
ExitCleanup();
|
|
||||||
|
|
||||||
if( !!*(u32*)0x80001800 )
|
|
||||||
{
|
|
||||||
// Were we launched via HBC? (or via wiiflows stub replacement? :P)
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Wii channel support
|
|
||||||
SYS_ResetSystem( SYS_RETURNTOMENU, 0, 0 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExitApp()
|
void ExitApp()
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
@ -126,9 +106,22 @@ void ExitApp()
|
|||||||
|
|
||||||
ExitCleanup();
|
ExitCleanup();
|
||||||
|
|
||||||
if(ShutdownRequested)
|
if(ShutdownRequested) {
|
||||||
SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0);
|
SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0);
|
||||||
|
}
|
||||||
|
else if(GCSettings.AutoloadGame) {
|
||||||
|
if( !!*(u32*)0x80001800 )
|
||||||
|
{
|
||||||
|
// Were we launched via HBC? (or via WiiFlow's stub replacement)
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Wii channel support
|
||||||
|
SYS_ResetSystem( SYS_RETURNTOMENU, 0, 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
if(GCSettings.ExitAction == 0) // Auto
|
if(GCSettings.ExitAction == 0) // Auto
|
||||||
{
|
{
|
||||||
@ -171,6 +164,7 @@ void ExitApp()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
void ShutdownCB()
|
void ShutdownCB()
|
||||||
@ -464,10 +458,7 @@ int main(int argc, char *argv[])
|
|||||||
InitGUIThreads();
|
InitGUIThreads();
|
||||||
|
|
||||||
bool autoboot = false;
|
bool autoboot = false;
|
||||||
if(argc > 2 && argv[1] != NULL && argv[2] != NULL)
|
if(argc > 2 && argv[1] != NULL && argv[2] != NULL) {
|
||||||
{
|
|
||||||
autoboot = true;
|
|
||||||
ResetBrowser();
|
|
||||||
LoadPrefs();
|
LoadPrefs();
|
||||||
if(strcasestr(argv[1], "sd:/") != NULL)
|
if(strcasestr(argv[1], "sd:/") != NULL)
|
||||||
{
|
{
|
||||||
@ -480,45 +471,9 @@ int main(int argc, char *argv[])
|
|||||||
GCSettings.LoadMethod = DEVICE_USB;
|
GCSettings.LoadMethod = DEVICE_USB;
|
||||||
}
|
}
|
||||||
SavePrefs(SILENT);
|
SavePrefs(SILENT);
|
||||||
selectLoadedFile = 1;
|
|
||||||
std::string dir(argv[1]);
|
GCSettings.AutoloadGame = AutoloadGame(argv[1], argv[2]);
|
||||||
dir.assign(&dir[dir.find_last_of(":") + 2]);
|
autoboot = GCSettings.AutoloadGame;
|
||||||
char arg_filename[1024];
|
|
||||||
strncpy(arg_filename, argv[2], sizeof(arg_filename));
|
|
||||||
strncpy(GCSettings.LoadFolder, dir.c_str(), sizeof(GCSettings.LoadFolder));
|
|
||||||
OpenGameList();
|
|
||||||
strncpy(GCSettings.Exit_Dol_File, argc > 3 && argv[3] != NULL ? argv[3] : "", sizeof(GCSettings.Exit_Dol_File));
|
|
||||||
if(argc > 5 && argv[4] != NULL && argv[5] != NULL)
|
|
||||||
{
|
|
||||||
sscanf(argv[4], "%08x", &GCSettings.Exit_Channel[0]);
|
|
||||||
sscanf(argv[5], "%08x", &GCSettings.Exit_Channel[1]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GCSettings.Exit_Channel[0] = 0x00010008;
|
|
||||||
GCSettings.Exit_Channel[1] = 0x57494948;
|
|
||||||
}
|
|
||||||
if(argc > 6 && argv[6] != NULL)
|
|
||||||
strncpy(GCSettings.LoaderName, argv[6], sizeof(GCSettings.LoaderName));
|
|
||||||
else
|
|
||||||
snprintf(GCSettings.LoaderName, sizeof(GCSettings.LoaderName), "WiiFlow");
|
|
||||||
for(int i = 0; i < browser.numEntries; i++)
|
|
||||||
{
|
|
||||||
// Skip it
|
|
||||||
if (strcmp(browserList[i].filename, ".") == 0 || strcmp(browserList[i].filename, "..") == 0)
|
|
||||||
continue;
|
|
||||||
if(strcasestr(browserList[i].filename, arg_filename) != NULL)
|
|
||||||
{
|
|
||||||
browser.selIndex = i;
|
|
||||||
if(IsSz())
|
|
||||||
{
|
|
||||||
BrowserLoadSz();
|
|
||||||
browser.selIndex = 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BrowserLoadFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (GCSettings.sfxOverclock)
|
switch (GCSettings.sfxOverclock)
|
||||||
@ -531,30 +486,23 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
while (1) // main loop
|
while (1) // main loop
|
||||||
{
|
{
|
||||||
|
if(!autoboot) {
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
// since we're entering the menu
|
// since we're entering the menu
|
||||||
ResumeDeviceThread();
|
ResumeDeviceThread();
|
||||||
|
|
||||||
SwitchAudioMode(1);
|
SwitchAudioMode(1);
|
||||||
|
|
||||||
if(!autoboot)
|
|
||||||
{
|
|
||||||
if(SNESROMSize == 0)
|
if(SNESROMSize == 0)
|
||||||
MainMenu(MENU_GAMESELECTION);
|
MainMenu(MENU_GAMESELECTION);
|
||||||
else
|
else
|
||||||
MainMenu(MENU_GAME);
|
MainMenu(MENU_GAME);
|
||||||
|
|
||||||
ConfigRequested = 0;
|
|
||||||
ScreenshotRequested = 0;
|
|
||||||
}
|
}
|
||||||
else if(SNESROMSize != 0 && autoboot)
|
|
||||||
autoboot = false;
|
|
||||||
else
|
|
||||||
ExitApp();
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
SelectFilterMethod();
|
SelectFilterMethod();
|
||||||
#endif
|
#endif
|
||||||
|
autoboot = false;
|
||||||
ConfigRequested = 0;
|
ConfigRequested = 0;
|
||||||
ScreenshotRequested = 0;
|
ScreenshotRequested = 0;
|
||||||
SwitchAudioMode(0);
|
SwitchAudioMode(0);
|
||||||
|
@ -93,10 +93,7 @@ struct SGCSettings{
|
|||||||
char CoverFolder[MAXPATHLEN]; // Path to cover files
|
char CoverFolder[MAXPATHLEN]; // Path to cover files
|
||||||
char ArtworkFolder[MAXPATHLEN]; // Path to artwork files
|
char ArtworkFolder[MAXPATHLEN]; // Path to artwork files
|
||||||
char ImageFolder[MAXPATHLEN]; // Saved image folder path
|
char ImageFolder[MAXPATHLEN]; // Saved image folder path
|
||||||
|
int AutoloadGame;
|
||||||
char Exit_Dol_File[MAXPATHLEN]; // Exit Path
|
|
||||||
char LoaderName[20]; // Menu Loader Name
|
|
||||||
u32 Exit_Channel[2]; // Exit Channel
|
|
||||||
|
|
||||||
char smbip[80];
|
char smbip[80];
|
||||||
char smbuser[20];
|
char smbuser[20];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user