From 7b768b83d8a26e545f9ea9407351e642c94c9235 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 10 Mar 2010 18:03:11 +0000 Subject: [PATCH] win32: straighten out the save slot 0 / F10 business --- desmume/src/saves.cpp | 13 +++++----- desmume/src/windows/main.cpp | 40 ++++++++++--------------------- desmume/src/windows/resource.h | 4 ++-- desmume/src/windows/resources.rc | Bin 903540 -> 903540 bytes 4 files changed, 20 insertions(+), 37 deletions(-) diff --git a/desmume/src/saves.cpp b/desmume/src/saves.cpp index c9b1559e1..5815f7400 100644 --- a/desmume/src/saves.cpp +++ b/desmume/src/saves.cpp @@ -578,25 +578,24 @@ void clear_savestates() savestates[i].exists = FALSE; } -/* Scan for existing savestates and update struct */ +// Scan for existing savestates and update struct void scan_savestates() { struct stat sbuf; char filename[MAX_PATH+1]; - u8 i; clear_savestates(); - for( i = 1; i <= NB_STATES; i++ ) + for(int i = 0; i < NB_STATES; i++ ) { - path.getpathnoext(path.STATES, filename); + path.getpathnoext(path.STATES, filename); if (strlen(filename) + strlen(".dst") + strlen("-2147483648") /* = biggest string for i */ >MAX_PATH) return ; sprintf(filename+strlen(filename), ".ds%d", i); if( stat(filename,&sbuf) == -1 ) continue; - savestates[i-1].exists = TRUE; - strncpy(savestates[i-1].date, format_time(sbuf.st_mtime),40); - savestates[i-1].date[40-1] = '\0'; + savestates[i].exists = TRUE; + strncpy(savestates[i].date, format_time(sbuf.st_mtime),40); + savestates[i].date[40-1] = '\0'; } return ; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 08d8f87ad..ac7fbe82a 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -1873,8 +1873,8 @@ void NDS_UnPause(bool showMsg) **/ void UpdateSaveStateMenu(int pos, char* txt) { - ModifyMenu(mainMenu,IDM_STATE_SAVE_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_SAVE_F1 + pos, txt); - ModifyMenu(mainMenu,IDM_STATE_LOAD_F1 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_LOAD_F1 + pos, txt); + ModifyMenu(mainMenu,IDM_STATE_SAVE_F10 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_SAVE_F10 + pos, txt); + ModifyMenu(mainMenu,IDM_STATE_LOAD_F10 + pos, MF_BYCOMMAND | MF_STRING, IDM_STATE_LOAD_F10 + pos, txt); } /*** @@ -1890,7 +1890,7 @@ void ResetSaveStateTimes() char ntxt[64]; for(int i = 0; i < NB_STATES;i++) { - sprintf(ntxt,"%d %s", i+1, ""); + sprintf(ntxt,"%d %s", i, ""); UpdateSaveStateMenu(i, ntxt); } } @@ -1911,7 +1911,7 @@ void LoadSaveStateInfo() { if(savestates[i].exists) { - sprintf(ntxt, "&%d %s", i+1, savestates[i].date); + sprintf(ntxt, "&%d %s", i, savestates[i].date); UpdateSaveStateMenu(i, ntxt); } } @@ -3610,8 +3610,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM //Update savestate slot items based on ROM loaded for (int x = 0; x < 10; x++) { - DesEnableMenuItem(mainMenu, IDM_STATE_SAVE_F1+x, romloaded); - DesEnableMenuItem(mainMenu, IDM_STATE_LOAD_F1+x, romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_SAVE_F10+x, romloaded); + DesEnableMenuItem(mainMenu, IDM_STATE_LOAD_F10+x, romloaded); } //Gray the recent ROM menu item if there are no recent ROMs @@ -4567,39 +4567,22 @@ DOKEYDOWN: case IDM_STATE_SAVE_F8: case IDM_STATE_SAVE_F9: case IDM_STATE_SAVE_F10: - HK_StateSaveSlot( abs(IDM_STATE_SAVE_F1 - LOWORD(wParam)) +1, true); + HK_StateSaveSlot(LOWORD(wParam)-IDM_STATE_SAVE_F10, true); return 0; case IDM_STATE_LOAD_F1: - HK_StateLoadSlot(1, true); - return 0; case IDM_STATE_LOAD_F2: - HK_StateLoadSlot(2, true); - return 0; case IDM_STATE_LOAD_F3: - HK_StateLoadSlot(3, true); - return 0; case IDM_STATE_LOAD_F4: - HK_StateLoadSlot(4, true); - return 0; case IDM_STATE_LOAD_F5: - HK_StateLoadSlot(5, true); - return 0; case IDM_STATE_LOAD_F6: - HK_StateLoadSlot(6, true); - return 0; case IDM_STATE_LOAD_F7: - HK_StateLoadSlot(7, true); - return 0; case IDM_STATE_LOAD_F8: - HK_StateLoadSlot(8, true); - return 0; case IDM_STATE_LOAD_F9: - HK_StateLoadSlot(9, true); - return 0; case IDM_STATE_LOAD_F10: - HK_StateLoadSlot(10, true); + HK_StateLoadSlot(LOWORD(wParam)-IDM_STATE_LOAD_F10, true); return 0; + case IDM_IMPORTBACKUPMEMORY: { OPENFILENAME ofn; @@ -6059,10 +6042,11 @@ void UpdateHotkeyAssignments() UpdateHotkeyAssignment(CustomKeys.NewLuaScript, IDC_NEW_LUA_SCRIPT); UpdateHotkeyAssignment(CustomKeys.MostRecentLuaScript, IDD_LUARECENT_RESERVE_START); UpdateHotkeyAssignment(CustomKeys.CloseLuaScripts, IDC_CLOSE_LUA_SCRIPTS); + for(int i = 0; i < 10; i++) - UpdateHotkeyAssignment(CustomKeys.Save[(i+1)%10], IDM_STATE_SAVE_F1 + i); + UpdateHotkeyAssignment(CustomKeys.Save[i], IDM_STATE_SAVE_F10 + i); for(int i = 0; i < 10; i++) - UpdateHotkeyAssignment(CustomKeys.Load[(i+1)%10], IDM_STATE_LOAD_F1 + i); + UpdateHotkeyAssignment(CustomKeys.Load[i], IDM_STATE_LOAD_F10 + i); } diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 0cace523a..68aa6b856 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -55,6 +55,7 @@ #define IDM_SUBMITBUGREPORT 134 #define IDM_STATE_LOAD 135 #define IDM_STATE_SAVE 136 +#define IDM_STATE_SAVE_F10 139 #define IDM_STATE_SAVE_F1 140 #define IDM_STATE_SAVE_F2 141 #define IDM_STATE_SAVE_F3 142 @@ -64,7 +65,7 @@ #define IDM_STATE_SAVE_F7 146 #define IDM_STATE_SAVE_F8 147 #define IDM_STATE_SAVE_F9 148 -#define IDM_STATE_SAVE_F10 149 +#define IDM_STATE_LOAD_F10 149 #define IDM_STATE_LOAD_F1 150 #define IDM_STATE_LOAD_F2 151 #define IDM_STATE_LOAD_F3 152 @@ -74,7 +75,6 @@ #define IDM_STATE_LOAD_F7 156 #define IDM_STATE_LOAD_F8 157 #define IDM_STATE_LOAD_F9 158 -#define IDM_STATE_LOAD_F10 159 #define IDC_COMBO1 160 #define IDC_COMBO2 161 #define IDC_COMBO3 162 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index f016d19f43dff0bce78109f7943b2e89ba4f61d9..d1b8b31ae3a9b78dce5259628b25ee16674699d7 100644 GIT binary patch delta 241 zcmew|$^6SC^M)42Elhuur+?C9vYKwd#mF{&K_gep_8BTn5v&Nob^|RYAZFffpvAIc z1wtI6xa2ZR5|ZNSK*h7#H{4_aV%F^&ZnA|uLg?5IG=3kl;t7tt%i3QYVh3W5?Jo{- rR_r677^sNdhp~M^Cl?TNZ=cY~vu`6p3&cgQta;OrEZGjU<-&!s4zva!h|;*1PaF;Vy|mI zrNsoq%-c_CvGA>cNh5TXTxLnaqHDuVmi7%dS+{Sv$rkbmS=V-;U5ijOv;(aHVvg-` xhd7z`<5vq*!+wpieL^P}5OZ&z(8;rJBeD*NPhMH`rlD8?@=4crGbdiVb^r@wWjz1@