misc things

This commit is contained in:
StapleButter 2018-10-24 00:32:31 +02:00
parent 8b4ba2d8b9
commit 6e1209dd32
1 changed files with 22 additions and 5 deletions

View File

@ -81,6 +81,8 @@ char ROMPath[1024];
char SRAMPath[1024]; char SRAMPath[1024];
char PrevSRAMPath[1024]; // for savestate 'undo load' char PrevSRAMPath[1024]; // for savestate 'undo load'
bool SavestateLoaded;
bool ScreenDrawInited = false; bool ScreenDrawInited = false;
uiDrawBitmap* ScreenBitmap = NULL; uiDrawBitmap* ScreenBitmap = NULL;
u32 ScreenBuffer[256*384]; u32 ScreenBuffer[256*384];
@ -764,7 +766,11 @@ void Run()
uiMenuItemEnable(MenuItem_SaveState); uiMenuItemEnable(MenuItem_SaveState);
uiMenuItemEnable(MenuItem_LoadState); uiMenuItemEnable(MenuItem_LoadState);
if (SavestateLoaded)
uiMenuItemEnable(MenuItem_UndoStateLoad); uiMenuItemEnable(MenuItem_UndoStateLoad);
else
uiMenuItemDisable(MenuItem_UndoStateLoad);
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
@ -821,6 +827,9 @@ void TryLoadROM(char* file, int prevstatus)
if (NDS::LoadROM(ROMPath, SRAMPath, Config::DirectBoot)) if (NDS::LoadROM(ROMPath, SRAMPath, Config::DirectBoot))
{ {
SavestateLoaded = false;
uiMenuItemDisable(MenuItem_UndoStateLoad);
strncpy(PrevSRAMPath, SRAMPath, 1024); // safety strncpy(PrevSRAMPath, SRAMPath, 1024); // safety
Run(); Run();
} }
@ -929,6 +938,9 @@ void LoadState(int slot)
NDS::RelocateSave(SRAMPath, false); NDS::RelocateSave(SRAMPath, false);
} }
SavestateLoaded = true;
uiMenuItemEnable(MenuItem_UndoStateLoad);
EmuRunning = prevstatus; EmuRunning = prevstatus;
} }
@ -989,6 +1001,8 @@ void SaveState(int slot)
void UndoStateLoad() void UndoStateLoad()
{ {
if (!SavestateLoaded) return;
int prevstatus = EmuRunning; int prevstatus = EmuRunning;
EmuRunning = 2; EmuRunning = 2;
while (EmuStatus != 2); while (EmuStatus != 2);
@ -1125,6 +1139,9 @@ void OnReset(uiMenuItem* item, uiWindow* window, void* blarg)
EmuRunning = 2; EmuRunning = 2;
while (EmuStatus != 2); while (EmuStatus != 2);
SavestateLoaded = false;
uiMenuItemDisable(MenuItem_UndoStateLoad);
if (ROMPath[0] == '\0') if (ROMPath[0] == '\0')
NDS::LoadBIOS(); NDS::LoadBIOS();
else else
@ -1352,9 +1369,9 @@ int main(int argc, char** argv)
{ {
char name[32]; char name[32];
if (i < 8) if (i < 8)
sprintf(name, "%d", kSavestateNum[i]); sprintf(name, "%d\tShift+F%d", kSavestateNum[i], kSavestateNum[i]);
else else
strcpy(name, "File..."); strcpy(name, "File...\tShift+F9");
uiMenuItem* ssitem = uiMenuAppendItem(submenu, name); uiMenuItem* ssitem = uiMenuAppendItem(submenu, name);
uiMenuItemOnClicked(ssitem, OnSaveState, (void*)&kSavestateNum[i]); uiMenuItemOnClicked(ssitem, OnSaveState, (void*)&kSavestateNum[i]);
@ -1369,9 +1386,9 @@ int main(int argc, char** argv)
{ {
char name[32]; char name[32];
if (i < 8) if (i < 8)
sprintf(name, "%d", kSavestateNum[i]); sprintf(name, "%d\tF%d", kSavestateNum[i], kSavestateNum[i]);
else else
strcpy(name, "File..."); strcpy(name, "File...\tF9");
uiMenuItem* ssitem = uiMenuAppendItem(submenu, name); uiMenuItem* ssitem = uiMenuAppendItem(submenu, name);
uiMenuItemOnClicked(ssitem, OnLoadState, (void*)&kSavestateNum[i]); uiMenuItemOnClicked(ssitem, OnLoadState, (void*)&kSavestateNum[i]);