GTK GUI: save oldest & load recent

This patch adds load from oldest state slot & load from most recent state slot keys to joypad configuration. Also modifies logic of vOnSaveGameOldest() so that if slot is empty (no ts) it is considered oldest.
This commit is contained in:
Juha Laukkanen 2014-11-12 02:17:35 -05:00 committed by Arthur Moore
parent 8c6fd246b2
commit c86b2c6760
11 changed files with 103 additions and 34 deletions

View File

@ -47,6 +47,8 @@ extern void log(const char *,...);
extern bool systemPauseOnFrame();
extern void systemGbPrint(u8 *,int,int,int,int,int);
extern void systemScreenCapture(int);
extern void systemSaveOldest();
extern void systemLoadRecent();
extern void systemDrawScreen();
// updates the joystick data
extern bool systemReadJoypads();

View File

@ -198,6 +198,8 @@ bool gbCapture = false;
bool gbCapturePrevious = false;
int gbJoymask[4] = { 0, 0, 0, 0 };
bool saveold=false, loadrcn=false, savePrevious=false, loadPrevious=false;
u8 gbRamFill = 0xff;
int gbRomSizes[] = { 0x00008000, // 32K
@ -4972,6 +4974,21 @@ void gbEmulate(int ticksToStop)
}
gbCapturePrevious = gbCapture;
#ifdef ENABLE_GTK // todo: enable for wx also
// todo: generally this is very inefficient way to do this: cmp on every loop
saveold = (newmask & 4) ? true : false;
loadrcn = (newmask & 8) ? true : false;
if(saveold && !savePrevious) {
systemSaveOldest();
}
savePrevious = saveold;
if(loadrcn && !loadPrevious) {
systemLoadRecent();
}
loadPrevious = loadrcn;
#endif
if(gbFrameSkipCount >= framesToSkip) {
if(!gbSgbMask)

View File

@ -123,6 +123,8 @@ int captureNumber = 0;
int armOpcodeCount = 0;
int thumbOpcodeCount = 0;
extern bool saveold, loadrcn, savePrevious, loadPrevious;
const int TIMER_TICKS[4] = {
0,
6,
@ -3765,6 +3767,20 @@ void CPULoop(int ticks)
}
capturePrevious = capture;
#ifdef ENABLE_GTK // todo: enable for wx also
// todo: generally this is very inefficient way to do this: cmp on every loop
saveold = (ext & 4) ? true : false;
loadrcn = (ext & 8) ? true : false;
if(saveold && !savePrevious) {
systemSaveOldest();
}
savePrevious = saveold;
if(loadrcn && !loadPrevious) {
systemLoadRecent();
}
loadPrevious = loadrcn;
#endif
DISPSTAT |= 1;
DISPSTAT &= 0xFFFD;
UPDATE_REG(0x04, DISPSTAT);

View File

@ -27,20 +27,22 @@ namespace VBA
const JoypadConfigDialog::SJoypadKey JoypadConfigDialog::m_astKeys[] =
{
{ KEY_UP, N_("Up :") },
{ KEY_DOWN, N_("Down :") },
{ KEY_LEFT, N_("Left :") },
{ KEY_RIGHT, N_("Right :") },
{ KEY_BUTTON_A, N_("Button A :") },
{ KEY_BUTTON_B, N_("Button B :") },
{ KEY_BUTTON_L, N_("Button L :") },
{ KEY_BUTTON_R, N_("Button R :") },
{ KEY_BUTTON_SELECT, N_("Select :") },
{ KEY_BUTTON_START, N_("Start :") },
{ KEY_BUTTON_SPEED, N_("Speed :") },
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
{ KEY_UP, N_("Up :") },
{ KEY_DOWN, N_("Down :") },
{ KEY_LEFT, N_("Left :") },
{ KEY_RIGHT, N_("Right :") },
{ KEY_BUTTON_A, N_("Button A :") },
{ KEY_BUTTON_B, N_("Button B :") },
{ KEY_BUTTON_L, N_("Button L :") },
{ KEY_BUTTON_R, N_("Button R :") },
{ KEY_BUTTON_SELECT, N_("Select :") },
{ KEY_BUTTON_START, N_("Start :") },
{ KEY_BUTTON_SPEED, N_("Speed :") },
{ KEY_BUTTON_SAVE_OLDEST, N_("SaveOldest :") },
{ KEY_BUTTON_LOAD_RECENT, N_("LoadRecent :") },
{ KEY_BUTTON_CAPTURE, N_("Capture :") },
{ KEY_BUTTON_AUTO_A, N_("Autofire A :") },
{ KEY_BUTTON_AUTO_B, N_("Autofire B :") }
};
JoypadConfigDialog::JoypadConfigDialog(Config::Section * _poConfig) :

View File

@ -93,6 +93,16 @@ void systemScreenCapture(int _iNum)
GUI()->vCaptureScreen(_iNum);
}
void systemSaveOldest()
{
GUI()->vOnSaveGameOldest();
}
void systemLoadRecent()
{
GUI()->vOnLoadGameMostRecent();
}
u32 systemGetClock()
{
Glib::TimeVal time;

View File

@ -55,22 +55,22 @@ Window * Window::m_poInstance = NULL;
const Window::SJoypadKey Window::m_astJoypad[] =
{
{ "left", KEY_LEFT },
{ "right", KEY_RIGHT },
{ "up", KEY_UP },
{ "down", KEY_DOWN },
{ "A", KEY_BUTTON_A },
{ "B", KEY_BUTTON_B },
{ "select", KEY_BUTTON_SELECT },
{ "start", KEY_BUTTON_START },
{ "L", KEY_BUTTON_L },
{ "R", KEY_BUTTON_R },
{ "speed", KEY_BUTTON_SPEED },
{ "capture", KEY_BUTTON_CAPTURE },
{ "speed", KEY_BUTTON_SPEED },
{ "capture", KEY_BUTTON_CAPTURE },
{ "autoA", KEY_BUTTON_AUTO_A },
{ "autoB", KEY_BUTTON_AUTO_B }
{ "left", KEY_LEFT },
{ "right", KEY_RIGHT },
{ "up", KEY_UP },
{ "down", KEY_DOWN },
{ "A", KEY_BUTTON_A },
{ "B", KEY_BUTTON_B },
{ "select", KEY_BUTTON_SELECT },
{ "start", KEY_BUTTON_START },
{ "L", KEY_BUTTON_L },
{ "R", KEY_BUTTON_R },
{ "speed", KEY_BUTTON_SPEED },
{ "save", KEY_BUTTON_SAVE_OLDEST },
{ "load", KEY_BUTTON_LOAD_RECENT },
{ "capture", KEY_BUTTON_CAPTURE },
{ "autoA", KEY_BUTTON_AUTO_A },
{ "autoB", KEY_BUTTON_AUTO_B }
};
Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr<Gtk::Builder> & _poXml) :
@ -480,6 +480,8 @@ void Window::vInitSDL()
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_L, GDK_a);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_R, GDK_s);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_SPEED, GDK_space);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_SAVE_OLDEST, GDK_k);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_LOAD_RECENT, GDK_l);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_CAPTURE, GDK_F12);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_AUTO_A, GDK_q);
inputSetKeymap(PAD_DEFAULT, KEY_BUTTON_AUTO_B, GDK_w);

View File

@ -112,6 +112,9 @@ public:
void vApplyPerGameConfig();
void vUpdateScreen();
virtual void vOnSaveGameOldest();
virtual void vOnLoadGameMostRecent();
inline ECartridge eGetCartridge() const { return m_eCartridge; }
protected:
@ -143,10 +146,8 @@ protected:
virtual void vOnFileOpen();
virtual void vOnFileLoad();
virtual void vOnFileSave();
virtual void vOnLoadGameMostRecent();
virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI);
void vOnLoadGame(int _iSlot);
virtual void vOnSaveGameOldest();
void vOnSaveGame(int _iSlot);
virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI);
virtual void vOnFileReset();

View File

@ -207,8 +207,11 @@ void Window::vOnSaveGameOldest()
for (int i = 0; i < 10; i++)
{
if (! m_astGameSlot[i].m_bEmpty
&& (iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin))
if (m_astGameSlot[i].m_bEmpty) {
iOldest = i;
break;
}
else if ( iOldest < 0 || m_astGameSlot[i].m_uiTime < uiTimeMin)
{
iOldest = i;
uiTimeMin = m_astGameSlot[i].m_uiTime;

View File

@ -2619,6 +2619,16 @@ void systemScreenCapture(int a)
systemScreenMessage("Screen capture");
}
void systemSaveOldest()
{
// I need to be implemented
}
void systemLoadRecent()
{
// I need to be implemented
}
u32 systemGetClock()
{
return SDL_GetTicks();

View File

@ -535,6 +535,10 @@ uint32_t inputReadJoypad(int which)
res |= 1024;
if(sdlButtons[which][KEY_BUTTON_CAPTURE])
res |= 2048;
if(sdlButtons[which][KEY_BUTTON_SAVE_OLDEST])
res |= 4096;
if(sdlButtons[which][KEY_BUTTON_LOAD_RECENT])
res |= 8192;
if(realAutoFire) {
res &= (~realAutoFire);

View File

@ -32,6 +32,8 @@ enum EKey {
KEY_BUTTON_L,
KEY_BUTTON_R,
KEY_BUTTON_SPEED,
KEY_BUTTON_SAVE_OLDEST,
KEY_BUTTON_LOAD_RECENT,
KEY_BUTTON_CAPTURE,
KEY_BUTTON_AUTO_A,
KEY_BUTTON_AUTO_B