Commit 9a7ca63f authored by bbbradsmith's avatar bbbradsmith
Browse files

start to exit GUI, ability to savestate into and out of GUI

parent d79d4a6e
...@@ -62,7 +62,7 @@ A Auto-Fire / Right mouse button ...@@ -62,7 +62,7 @@ A Auto-Fire / Right mouse button
Y Toggle virtual keyboard Shift Y Toggle virtual keyboard Shift
X Show/hide virtual keyboard X Show/hide virtual keyboard
SEL Toggle Joystick / Mouse mode SEL Toggle Joystick / Mouse mode
STR Hatari GUI STR Enter/Exit Hatari GUI
L Show/Hide status L Show/Hide status
R Select virtual keyboard page R Select virtual keyboard page
L2 Lower Mouse Speed (1-6) for gui and emu L2 Lower Mouse Speed (1-6) for gui and emu
......
...@@ -54,13 +54,12 @@ void Dialog_AboutDlg(void) ...@@ -54,13 +54,12 @@ void Dialog_AboutDlg(void)
aboutdlg[1].x = (aboutdlg[0].w - strlen(PROG_NAME)) / 2; aboutdlg[1].x = (aboutdlg[0].w - strlen(PROG_NAME)) / 2;
SDLGui_CenterDlg(aboutdlg); SDLGui_CenterDlg(aboutdlg);
do do
{ {
but=SDLGui_DoDialog(aboutdlg, NULL); but=SDLGui_DoDialog(aboutdlg, NULL);
gui_poll_events(); if (gui_poll_events()) break;
}
} while (but != DLGABOUT_EXIT && but != SDLGUI_QUIT
while (but != DLGABOUT_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
} }
...@@ -171,11 +171,10 @@ static int DlgAlert_ShowDlg(const char *text) ...@@ -171,11 +171,10 @@ static int DlgAlert_ShowDlg(const char *text)
bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY); bOldMouseVisibility = SDL_ShowCursor(SDL_QUERY);
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
do do
{ {
i = SDLGui_DoDialog(alertdlg, NULL); i = SDLGui_DoDialog(alertdlg, NULL);
gui_poll_events(); if (gui_poll_events()) break;
} }
while (i != DLGALERT_OK && i != DLGALERT_CANCEL && i != SDLGUI_QUIT while (i != DLGALERT_OK && i != DLGALERT_CANCEL && i != SDLGUI_QUIT
&& i != SDLGUI_ERROR && !bQuitProgram); && i != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -145,7 +145,7 @@ void Dialog_DeviceDlg(void) ...@@ -145,7 +145,7 @@ void Dialog_DeviceDlg(void)
true); true);
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DEVDLG_EXIT && but != SDLGUI_QUIT while (but != DEVDLG_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -833,7 +833,7 @@ char* SDLGui_FileSelect(const char *title,const char *path_and_name, char **zip_ ...@@ -833,7 +833,7 @@ char* SDLGui_FileSelect(const char *title,const char *path_and_name, char **zip_
scrollbar_Ypos = 0.0; scrollbar_Ypos = 0.0;
} }
} /* other button code */ } /* other button code */
gui_poll_events(); if (gui_poll_events()) retbut=SGFSDLG_CANCEL;
} /* do */ } /* do */
while (retbut!=SGFSDLG_OKAY && retbut!=SGFSDLG_CANCEL while (retbut!=SGFSDLG_OKAY && retbut!=SGFSDLG_CANCEL
......
...@@ -289,7 +289,7 @@ void DlgFloppy_Main(void) ...@@ -289,7 +289,7 @@ void DlgFloppy_Main(void)
} }
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT while (but != FLOPPYDLG_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -211,7 +211,7 @@ printf("skip: %d\n", ConfigureParams.HardDisk.nHardDiskDrive); ...@@ -211,7 +211,7 @@ printf("skip: %d\n", ConfigureParams.HardDisk.nHardDiskDrive);
ConfigureParams.HardDisk.bUseHardDiskDirectories = true; ConfigureParams.HardDisk.bUseHardDiskDirectories = true;
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DISKDLG_EXIT && but != SDLGUI_QUIT while (but != DISKDLG_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -260,7 +260,7 @@ void Dialog_JoyDlg(void) ...@@ -260,7 +260,7 @@ void Dialog_JoyDlg(void)
} }
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGJOY_EXIT && but != SDLGUI_QUIT while (but != DLGJOY_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -82,7 +82,7 @@ void Dialog_KeyboardDlg(void) ...@@ -82,7 +82,7 @@ void Dialog_KeyboardDlg(void)
ConfigureParams.Keyboard.szMappingFileName, ConfigureParams.Keyboard.szMappingFileName,
keyboarddlg[DLGKEY_MAPNAME].w, false); keyboarddlg[DLGKEY_MAPNAME].w, false);
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGKEY_EXIT && but != SDLGUI_QUIT while (but != DLGKEY_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -160,8 +160,7 @@ int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot) ...@@ -160,8 +160,7 @@ int Dialog_MainDlg(bool *bReset, bool *bLoadedSnapshot)
bQuitProgram = true; bQuitProgram = true;
break; break;
} }
gui_poll_events(); if (gui_poll_events()) retbut = MAINDLG_CANCEL;
} }
while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT while (retbut != MAINDLG_OK && retbut != MAINDLG_CANCEL && retbut != SDLGUI_QUIT
&& retbut != SDLGUI_ERROR && !bQuitProgram); && retbut != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -130,7 +130,7 @@ bool Dialog_MemDlg(void) ...@@ -130,7 +130,7 @@ bool Dialog_MemDlg(void)
} }
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGMEM_EXIT && but != SDLGUI_QUIT while (but != DLGMEM_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram ); && but != SDLGUI_ERROR && !bQuitProgram );
......
...@@ -146,7 +146,7 @@ char *DlgNewDisk_Main(void) ...@@ -146,7 +146,7 @@ char *DlgNewDisk_Main(void)
} }
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGNEWDISK_EXIT && but != SDLGUI_QUIT while (but != DLGNEWDISK_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -87,7 +87,7 @@ void DlgRom_Main(void) ...@@ -87,7 +87,7 @@ void DlgRom_Main(void)
false); false);
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGROM_EXIT && but != SDLGUI_QUIT while (but != DLGROM_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -265,7 +265,7 @@ void Dialog_MonitorDlg(void) ...@@ -265,7 +265,7 @@ void Dialog_MonitorDlg(void)
sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight); sprintf(sVdiHeight, "%4i", ConfigureParams.Screen.nVdiHeight);
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGSCRN_EXIT_MONITOR && but != SDLGUI_QUIT while (but != DLGSCRN_EXIT_MONITOR && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
...@@ -411,7 +411,7 @@ void Dialog_WindowDlg(void) ...@@ -411,7 +411,7 @@ void Dialog_WindowDlg(void)
} }
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGSCRN_EXIT_WINDOW && but != SDLGUI_QUIT while (but != DLGSCRN_EXIT_WINDOW && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
......
...@@ -171,7 +171,7 @@ void Dialog_SoundDlg(void) ...@@ -171,7 +171,7 @@ void Dialog_SoundDlg(void)
} }
break; break;
} }
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGSOUND_EXIT && but != SDLGUI_QUIT while (but != DLGSOUND_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram ); && but != SDLGUI_ERROR && !bQuitProgram );
......
...@@ -257,13 +257,12 @@ void Dialog_SystemDlg(void) ...@@ -257,13 +257,12 @@ void Dialog_SystemDlg(void)
int but; int but;
do do
{ {
/* Show the dialog: */ /* Show the dialog: */
but=SDLGui_DoDialog(systemdlg, NULL); but=SDLGui_DoDialog(systemdlg, NULL);
gui_poll_events(); if (gui_poll_events()) break;
} }
while (but != DLGSYS_EXIT && but != SDLGUI_QUIT while (but != DLGSYS_EXIT && but != SDLGUI_QUIT
&& but != SDLGUI_ERROR && !bQuitProgram); && but != SDLGUI_ERROR && !bQuitProgram);
/* Read values from dialog: */ /* Read values from dialog: */
......
...@@ -51,9 +51,9 @@ char RPATH[512]; ...@@ -51,9 +51,9 @@ char RPATH[512];
int NPAGE=-1, KCOL=1, BKGCOLOR=0, MAXPAS=6; int NPAGE=-1, KCOL=1, BKGCOLOR=0, MAXPAS=6;
int SHIFTON=-1,MOUSEMODE=-1,SHOWKEY=-1,PAS=4,STATUTON=-1; int SHIFTON=-1,MOUSEMODE=-1,SHOWKEY=-1,PAS=4,STATUTON=-1;
int SND=1; //SOUND ON/OFF int SND=1; //SOUND ON/OFF
int firstps=0;
int pauseg=0; //enter_gui int pauseg=0; //enter_gui
int slowdown=0; int slowdown=0;
int exitgui=0; // exit gui (not serialized)
//JOY //JOY
int al[2];//left analog1 int al[2];//left analog1
...@@ -124,7 +124,7 @@ static bool hatari_mapper_serialize_bidi(char* data, char version) ...@@ -124,7 +124,7 @@ static bool hatari_mapper_serialize_bidi(char* data, char version)
serialize_int(&gmx); serialize_int(&gmx);
serialize_int(&gmy); serialize_int(&gmy);
int NUMjoy=0; serialize_int(&NUMjoy); // this variable was removed int NUMjoy=0; serialize_int(&NUMjoy); // this variable was removed
serialize_int(&firstps); int firstps=0; serialize_int(&firstps); // this variable was removed
serialize_int(&mbL); serialize_int(&mbL);
serialize_int(&mbR); serialize_int(&mbR);
serialize_int(&mmbL); serialize_int(&mmbL);
...@@ -154,7 +154,12 @@ bool hatari_mapper_unserialize(const char* data, char version) ...@@ -154,7 +154,12 @@ bool hatari_mapper_unserialize(const char* data, char version)
serialize_forward = false; serialize_forward = false;
int pauseg_old = pauseg; int pauseg_old = pauseg;
bool result = hatari_mapper_serialize_bidi((char*)data, version); bool result = hatari_mapper_serialize_bidi((char*)data, version);
if (pauseg_old) pauseg = pauseg_old; // because of the co-thread implementation there's really no way to save-state out of the GUI, so: stay paused exitgui = 0;
if (pauseg_old && !pauseg) // want to exit GUI, turn pauseg back on and tell it to exit on its own
{
pauseg = pauseg_old;
exitgui = 1;
}
return result; return result;
} }
...@@ -205,10 +210,11 @@ long GetTicks(void) ...@@ -205,10 +210,11 @@ long GetTicks(void)
} }
//NO SURE FIND BETTER WAY TO COME BACK IN MAIN THREAD IN HATARI GUI //NO SURE FIND BETTER WAY TO COME BACK IN MAIN THREAD IN HATARI GUI
void gui_poll_events(void) bool gui_poll_events(void)
{ {
slowdown=0; slowdown=0;
co_switch(mainThread); co_switch(mainThread);
return (exitgui != 0);
} }
//save bkg for screenshot //save bkg for screenshot
...@@ -318,21 +324,12 @@ void texture_init(void) ...@@ -318,21 +324,12 @@ void texture_init(void)
void enter_gui(void) void enter_gui(void)
{ {
save_bkg(); save_bkg();
exitgui=0;
pauseg=1; // should already be set
Dialog_DoProperty(); Dialog_DoProperty();
pauseg=0; pauseg=0;
} }
void pause_select(void)
{
if(pauseg==1 && firstps==0)
{
firstps=1;
enter_gui();
firstps=0;
}
}
void Print_Statut(void) void Print_Statut(void)
{ {
STAT_BASEY=CROP_HEIGHT+24; STAT_BASEY=CROP_HEIGHT+24;
...@@ -435,7 +432,7 @@ void Deadzone(int* a) ...@@ -435,7 +432,7 @@ void Deadzone(int* a)
L2 MOUSE SPEED DOWN (gui/emu) L2 MOUSE SPEED DOWN (gui/emu)
R2 MOUSE SPEED UP(gui/emu) R2 MOUSE SPEED UP(gui/emu)
SEL toggle mouse/joy mode SEL toggle mouse/joy mode
STR Hatari Gui STR Hatari Gui / Exit Gui
B fire/mouse-left/valid key in vkbd B fire/mouse-left/valid key in vkbd
A mouse-right A mouse-right
Y switch Shift ON/OFF Y switch Shift ON/OFF
...@@ -466,8 +463,11 @@ void update_input(void) ...@@ -466,8 +463,11 @@ void update_input(void)
Process_key(); Process_key();
i=RETRO_DEVICE_ID_JOYPAD_START;// Hatari GUI i=RETRO_DEVICE_ID_JOYPAD_START;// Hatari GUI
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) ) if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
{ {
mbt[i]=0;
pauseg=1; pauseg=1;
} }
...@@ -820,6 +820,17 @@ void input_gui(void) ...@@ -820,6 +820,17 @@ void input_gui(void)
PAS++;if(PAS>MAXPAS)PAS=1; PAS++;if(PAS>MAXPAS)PAS=1;
} }
// START to exit GUI
i=RETRO_DEVICE_ID_JOYPAD_START;
if ( input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) && mbt[i]==0 )
mbt[i]=1;
else if ( mbt[i]==1 && ! input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i) )
{
mbt[i]=0;
exitgui=1;
}
//emulate mouse with joy analog left //emulate mouse with joy analog left
al[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X)); al[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X));
al[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y)); al[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y));
...@@ -885,6 +896,4 @@ void input_gui(void) ...@@ -885,6 +896,4 @@ void input_gui(void)
gmy=0; gmy=0;
if (gmy>retroh-1) if (gmy>retroh-1)
gmy=retroh-1; gmy=retroh-1;
// TODO could pressing START act like "escape" for the purpose of quitting the GUI back to game?
} }
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "graph.h" #include "graph.h"
extern void gui_poll_events(); extern bool gui_poll_events();
extern int GuiGetMouseState( int * x,int * y); extern int GuiGetMouseState( int * x,int * y);
extern int pauseg; extern int pauseg;
...@@ -19,7 +19,7 @@ extern char RETRO_DIR[512]; ...@@ -19,7 +19,7 @@ extern char RETRO_DIR[512];
extern char RETRO_TOS[512]; extern char RETRO_TOS[512];
extern char RPATH[512]; extern char RPATH[512];
extern long GetTicks(void); extern long GetTicks(void);
extern void pause_select(); extern void enter_gui();
extern int LoadTosFromRetroSystemDir(); extern int LoadTosFromRetroSystemDir();
extern void retro_shutdown_hatari(void); extern void retro_shutdown_hatari(void);
......
...@@ -312,7 +312,7 @@ void Main_WaitOnVbl(void) ...@@ -312,7 +312,7 @@ void Main_WaitOnVbl(void)
Sint64 nDelay; Sint64 nDelay;
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
if(pauseg==1)pause_select(); if(pauseg==1)enter_gui();
co_switch(mainThread); co_switch(mainThread);
#if defined(WIIU) || defined(VITA) #if defined(WIIU) || defined(VITA)
return; return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment