restructure main loops

This commit is contained in:
dborth 2009-02-08 22:30:42 +00:00
parent 25b192c940
commit 4aefa04e9d
2 changed files with 78 additions and 93 deletions

View File

@ -1082,6 +1082,7 @@ MainMenu (int selectedMenu)
case -1: // Button B
// Return to Game
if(SNESROMSize > 0)
quit = 1;
break;
}

View File

@ -78,9 +78,9 @@ void ExitCleanup()
{
LWP_SuspendThread (devicethread);
UnmountAllFAT();
CloseShare();
#ifdef HW_RVL
CloseShare();
DI_Close();
#endif
}
@ -192,16 +192,43 @@ void setFrameTimerMethod()
extern void S9xInitSync();
bool CheckVideo = 0; // for forcing video reset in video.cpp
extern uint32 prevRenderedFrameCount;
static int selectedMenu = -1;
void
emulate ()
{
S9xSetSoundMute (TRUE);
AudioStart ();
S9xInitSync(); // Eke-Eke: initialize frame Sync
while (1)
{
// go back to checking if devices were inserted/removed
// since we're entering the menu
LWP_ResumeThread (devicethread);
ConfigRequested = 1;
if(SNESROMSize > 0 && selectedMenu != 2)
selectedMenu = 2;
MainMenu (selectedMenu); // go to menu
ConfigRequested = 0;
Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false);
Settings.MouseMaster = (GCSettings.Mouse > 0 ? true : false);
Settings.JustifierMaster = (GCSettings.Justifier > 0 ? true : false);
SetControllers ();
// stop checking if devices were removed/inserted
// since we're starting emulation again
LWP_SuspendThread (devicethread);
ResetVideo_Emu();
FrameTimer = 0;
setFrameTimerMethod(); // set frametimer method every time a ROM is loaded
CheckVideo = 1; // force video update
prevRenderedFrameCount = IPPU.RenderedFramesCount;
while(1)
{
S9xMainLoop ();
@ -245,47 +272,12 @@ emulate ()
ShutdownWii();
#endif
// GUI Stuff
/*
gui_alloc();
gui_makebg ();
gui_clearscreen();
gui_draw ();
gui_showscreen ();
//gui_savescreen ();
*/
MainMenu (2); // go to game menu
// save zoom level
SavePrefs(SILENT);
FrameTimer = 0;
setFrameTimerMethod (); // set frametimer method every time a ROM is loaded
Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false);
Settings.MouseMaster = (GCSettings.Mouse > 0 ? true : false);
Settings.JustifierMaster = (GCSettings.Justifier > 0 ? true : false);
SetControllers ();
//S9xReportControllers ();
ConfigRequested = 0;
#ifdef _DEBUG_VIDEO
// log stuff
fprintf(debughandle, "\n\nPlaying ROM: %s", Memory.ROMFilename);
fprintf(debughandle, "\nrender: %u", GCSettings.render);
#endif
CheckVideo = 1; // force video update
prevRenderedFrameCount = IPPU.RenderedFramesCount;
// stop checking if devices were removed/inserted
// since we're starting emulation again
LWP_SuspendThread (devicethread);
}//if ConfigRequested
}//while
break;
}
}
}
}
void CreateAppPath(char origpath[])
@ -337,8 +329,6 @@ main(int argc, char *argv[])
DI_Init(); // first
#endif
int selectedMenu = -1;
#ifdef DEBUG_WII
DEBUG_Init(GDBSTUB_DEVICE_USB, 1); // init debugging
//_break();
@ -464,16 +454,10 @@ main(int argc, char *argv[])
}
#endif
// Get the user to load a ROM
while (SNESROMSize <= 0)
{
MainMenu (selectedMenu);
}
S9xSetSoundMute (TRUE);
AudioStart ();
S9xInitSync(); // initialize frame sync
// Emulate
emulate ();
// NO! - We're never leaving here!
while (1);
return 0;
}