Skip to content

Commit

Permalink
Win32: Show whether save state exists when slot selected.
Browse files Browse the repository at this point in the history
  • Loading branch information
bearoso committed May 7, 2024
1 parent 77f86ef commit 73cb801
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion win32/wlanguage.h
Expand Up @@ -360,7 +360,7 @@ Nintendo is a trademark.")

// Save Messages

#define FREEZE_INFO_SET_SLOT_N "Set save slot %03d"
#define FREEZE_INFO_SET_SLOT_N "Set save slot %03d [%s]"
#define FREEZE_INFO_SET_BANK_N "Set save bank %03d"

// AVI Messages
Expand Down
28 changes: 19 additions & 9 deletions win32/wsnes9x.cpp
Expand Up @@ -727,6 +727,22 @@ static char InfoString [100];
static uint32 prevPadReadFrame = (uint32)-1;
static bool skipNextFrameStop = false;

static void ShowStatusSlotInfo()
{
static char str[64];

char filename[_MAX_PATH + 1]
GetSlotFilename(GUI.CurrentSaveBank * SAVE_SLOTS_PER_BANK + GUI.CurrentSaveSlot, filename);

bool exists = false;
struct stat stats;
if (stat(filename, &stats) == 0)
exists = true;

sprintf(str, FREEZE_INFO_SET_SLOT_N, GUI.CurrentSaveSlot, exists ? "used" : "empty");
S9xSetInfoString(str);
}

int HandleKeyMessage(WPARAM wParam, LPARAM lParam)
{
// update toggles
Expand Down Expand Up @@ -889,9 +905,7 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam)
if(GUI.CurrentSaveSlot > LAST_SAVE_SLOT_IN_BANK)
GUI.CurrentSaveSlot = 0;

static char str [64];
sprintf(str, FREEZE_INFO_SET_SLOT_N, GUI.CurrentSaveSlot);
S9xSetInfoString(str);
ShowStatusSlotInfo();

hitHotKey = true;
}
Expand All @@ -902,9 +916,7 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam)
if(GUI.CurrentSaveSlot < 0)
GUI.CurrentSaveSlot = 9;

static char str [64];
sprintf(str, FREEZE_INFO_SET_SLOT_N, GUI.CurrentSaveSlot);
S9xSetInfoString(str);
ShowStatusSlotInfo();

hitHotKey = true;
}
Expand Down Expand Up @@ -1270,9 +1282,7 @@ int HandleKeyMessage(WPARAM wParam, LPARAM lParam)
{
GUI.CurrentSaveSlot = GUI.CurrentSaveBank * SAVE_SLOTS_PER_BANK + i;

static char str [64];
sprintf(str, FREEZE_INFO_SET_SLOT_N, GUI.CurrentSaveSlot);
S9xSetInfoString(str);
ShowStatusSlotInfo();

hitHotKey = true;
}
Expand Down

0 comments on commit 73cb801

Please sign in to comment.