-Added quick save state saving/loading to the windows port's menu

-Added shortcut keys for quick save state saving/loading to the window's port. Use shift+F1-F10 keys for saving, and F1-F10 for loading
This commit is contained in:
cyberwarriorx 2006-12-01 23:56:05 +00:00
parent cc2a52a3a2
commit 4fb62b85cc
6 changed files with 209 additions and 42 deletions

View File

@ -44,6 +44,7 @@
//#define LOG_DIV //#define LOG_DIV
char szRomPath[512]; char szRomPath[512];
char szRomBaseName[512];
MMU_struct MMU; MMU_struct MMU;

View File

@ -34,6 +34,7 @@ extern "C" {
#endif #endif
extern char szRomPath[512]; extern char szRomPath[512];
extern char szRomBaseName[512];
/* theses macros are designed for reading/writing in memory (m is a pointer to memory, like MMU.MMU_MEM[proc], and a is an adress, like 0x04000000 */ /* theses macros are designed for reading/writing in memory (m is a pointer to memory, like MMU.MMU_MEM[proc], and a is an adress, like 0x04000000 */
#define MEM_8(m, a) (((u8*)(m[((a)>>20)&0xff]))[((a)&0xfff)]) #define MEM_8(m, a) (((u8*)(m[((a)>>20)&0xff]))[((a)&0xfff)])

View File

@ -371,6 +371,13 @@ int NDS_LoadROM(const char *filename)
cflash_close(); cflash_close();
cflash_init(); cflash_init();
strcpy(szRomBaseName, filename);
if(type == ROM_DSGBA)
szRomBaseName[strlen(szRomBaseName)-strlen(DSGBA_EXTENSTION)] = 0x00;
else
szRomBaseName[strlen(szRomBaseName)-4] = 0x00;
// Setup Backup Memory // Setup Backup Memory
p = strdup(filename); p = strdup(filename);

View File

@ -257,11 +257,14 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
MSG messages; /* Here messages to the application are saved */ MSG messages; /* Here messages to the application are saved */
char text[80]; char text[80];
cwindow_struct MainWindow; cwindow_struct MainWindow;
HACCEL hAccel;
hAppInst=hThisInstance; hAppInst=hThisInstance;
InitializeCriticalSection(&section); InitializeCriticalSection(&section);
sprintf(text, "DeSmuME v%s", VERSION); sprintf(text, "DeSmuME v%s", VERSION);
hAccel = LoadAccelerators(hAppInst, MAKEINTRESOURCE(IDR_MAIN_ACCEL));
if (CWindow_Init(&MainWindow, hThisInstance, szClassName, text, if (CWindow_Init(&MainWindow, hThisInstance, szClassName, text,
WS_CAPTION| WS_SYSMENU |WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_CAPTION| WS_SYSMENU |WS_MINIMIZEBOX | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
256, 384, WindowProcedure) != 0) 256, 384, WindowProcedure) != 0)
@ -327,10 +330,13 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
while (GetMessage (&messages, NULL, 0, 0)) while (GetMessage (&messages, NULL, 0, 0))
{ {
// Translate virtual-key messages into character messages if (TranslateAccelerator(hwnd, hAccel, &messages) == 0)
TranslateMessage(&messages); {
// Send message to WindowProcedure // Translate virtual-key messages into character messages
DispatchMessage(&messages); TranslateMessage(&messages);
// Send message to WindowProcedure
DispatchMessage(&messages);
}
} }
#ifdef DEBUG #ifdef DEBUG
@ -340,6 +346,26 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
return messages.wParam; return messages.wParam;
} }
void StateSaveSlot(int num)
{
char filename[MAX_PATH];
NDS_Pause();
strcpy(filename, szRomBaseName);
sprintf(filename+strlen(filename), "%d.dst", num);
savestate_save(filename);
NDS_UnPause();
}
void StateLoadSlot(int num)
{
char filename[MAX_PATH];
NDS_Pause();
strcpy(filename, szRomBaseName);
sprintf(filename+strlen(filename), "%d.dst", num);
savestate_load(filename);
NDS_UnPause();
}
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) // handle the messages switch (message) // handle the messages
@ -651,6 +677,66 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
NDS_UnPause(); NDS_UnPause();
} }
return 0; return 0;
case IDM_STATE_SAVE_F1:
StateSaveSlot(1);
return 0;
case IDM_STATE_SAVE_F2:
StateSaveSlot(2);
return 0;
case IDM_STATE_SAVE_F3:
StateSaveSlot(3);
return 0;
case IDM_STATE_SAVE_F4:
StateSaveSlot(4);
return 0;
case IDM_STATE_SAVE_F5:
StateSaveSlot(5);
return 0;
case IDM_STATE_SAVE_F6:
StateSaveSlot(6);
return 0;
case IDM_STATE_SAVE_F7:
StateSaveSlot(7);
return 0;
case IDM_STATE_SAVE_F8:
StateSaveSlot(8);
return 0;
case IDM_STATE_SAVE_F9:
StateSaveSlot(9);
return 0;
case IDM_STATE_SAVE_F10:
StateSaveSlot(10);
return 0;
case IDM_STATE_LOAD_F1:
StateLoadSlot(1);
return 0;
case IDM_STATE_LOAD_F2:
StateLoadSlot(2);
return 0;
case IDM_STATE_LOAD_F3:
StateLoadSlot(3);
return 0;
case IDM_STATE_LOAD_F4:
StateLoadSlot(4);
return 0;
case IDM_STATE_LOAD_F5:
StateLoadSlot(5);
return 0;
case IDM_STATE_LOAD_F6:
StateLoadSlot(6);
return 0;
case IDM_STATE_LOAD_F7:
StateLoadSlot(7);
return 0;
case IDM_STATE_LOAD_F8:
StateLoadSlot(8);
return 0;
case IDM_STATE_LOAD_F9:
StateLoadSlot(9);
return 0;
case IDM_STATE_LOAD_F10:
StateLoadSlot(10);
return 0;
case IDM_SOUNDSETTINGS: case IDM_SOUNDSETTINGS:
{ {
DialogBox(GetModuleHandle(NULL), "SoundSettingsDlg", hwnd, (DLGPROC)SoundSettingsDlgProc); DialogBox(GetModuleHandle(NULL), "SoundSettingsDlg", hwnd, (DLGPROC)SoundSettingsDlgProc);

View File

@ -34,44 +34,65 @@ void refreshAll();
#define IconDeSmuME 100 #define IconDeSmuME 100
#define IDC_STATIC -1 #define IDC_STATIC -1
#define IDM_OPEN 102 #define IDM_OPEN 101
#define IDM_QUIT 103 #define IDM_QUIT 102
#define IDC_FERMER 104 #define IDC_FERMER 103
#define IDC_STEP 105 #define IDC_STEP 104
#define IDC_SETPNUM 106 #define IDC_SETPNUM 105
#define IDC_SCROLLER 107 #define IDC_SCROLLER 106
#define IDC_GO 108 #define IDC_GO 107
#define IDC_AUTO_UPDATE 109 #define IDC_AUTO_UPDATE 108
#define IDM_MEMORY 110 #define IDM_MEMORY 109
#define IDM_DISASSEMBLER 111 #define IDM_DISASSEMBLER 110
#define IDM_GAME_INFO 112 #define IDM_GAME_INFO 111
#define IDM_EXEC 113 #define IDM_EXEC 112
#define IDM_PAUSE 114 #define IDM_PAUSE 113
#define IDM_RESET 115 #define IDM_RESET 114
#define IDM_IOREG 116 #define IDM_IOREG 115
#define IDM_LOG 117 #define IDM_LOG 116
#define IDM_PAL 118 #define IDM_PAL 117
#define IDM_TILE 119 #define IDM_TILE 118
#define IDM_MAP 120 #define IDM_MAP 119
#define IDM_MBG0 121 #define IDM_MBG0 120
#define IDM_MBG1 122 #define IDM_MBG1 121
#define IDM_MBG2 123 #define IDM_MBG2 122
#define IDM_MBG3 124 #define IDM_MBG3 123
#define IDM_SBG0 125 #define IDM_SBG0 124
#define IDM_SBG1 126 #define IDM_SBG1 125
#define IDM_SBG2 127 #define IDM_SBG2 126
#define IDM_SBG3 128 #define IDM_SBG3 127
#define IDM_OAM 129 #define IDM_OAM 128
#define IDM_PRINTSCREEN 140 #define IDM_PRINTSCREEN 129
#define IDM_QUICK_PRINTSCREEN 141 #define IDM_QUICK_PRINTSCREEN 130
#define IDM_SOUNDSETTINGS 142 #define IDM_SOUNDSETTINGS 131
#define IDM_WEBSITE 143 #define IDM_WEBSITE 132
#define IDM_FORUM 144 #define IDM_FORUM 133
#define IDM_SUBMITBUGREPORT 145 #define IDM_SUBMITBUGREPORT 134
#define IDM_STATE_LOAD 135
#define IDM_STATE_SAVE 136
#define IDM_STATE_LOAD 150 #define IDR_MAIN_ACCEL 137
#define IDM_STATE_SAVE 151 #define IDM_STATE_SAVE_F1 140
#define IDM_STATE_SAVE_F2 141
#define IDM_STATE_SAVE_F3 142
#define IDM_STATE_SAVE_F4 143
#define IDM_STATE_SAVE_F5 144
#define IDM_STATE_SAVE_F6 145
#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_F1 150
#define IDM_STATE_LOAD_F2 151
#define IDM_STATE_LOAD_F3 152
#define IDM_STATE_LOAD_F4 153
#define IDM_STATE_LOAD_F5 154
#define IDM_STATE_LOAD_F6 155
#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_COMBO1 160
#define IDC_COMBO2 161 #define IDC_COMBO2 161

View File

@ -294,8 +294,34 @@ MENU_PRINCIPAL MENU
MENUITEM "&Open", IDM_OPEN MENUITEM "&Open", IDM_OPEN
MENUITEM "Rom &Info", IDM_GAME_INFO MENUITEM "Rom &Info", IDM_GAME_INFO
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Save State", IDM_STATE_SAVE MENUITEM "Save State As", IDM_STATE_SAVE
MENUITEM "Load State", IDM_STATE_LOAD MENUITEM "Load State As", IDM_STATE_LOAD
POPUP "Save State"
{
MENUITEM "1", IDM_STATE_SAVE_F1
MENUITEM "2", IDM_STATE_SAVE_F2
MENUITEM "3", IDM_STATE_SAVE_F3
MENUITEM "4", IDM_STATE_SAVE_F4
MENUITEM "5", IDM_STATE_SAVE_F5
MENUITEM "6", IDM_STATE_SAVE_F6
MENUITEM "7", IDM_STATE_SAVE_F7
MENUITEM "8", IDM_STATE_SAVE_F8
MENUITEM "9", IDM_STATE_SAVE_F9
MENUITEM "10", IDM_STATE_SAVE_F10
}
POPUP "Load State"
{
MENUITEM "1", IDM_STATE_LOAD_F1
MENUITEM "2", IDM_STATE_LOAD_F2
MENUITEM "3", IDM_STATE_LOAD_F3
MENUITEM "4", IDM_STATE_LOAD_F4
MENUITEM "5", IDM_STATE_LOAD_F5
MENUITEM "6", IDM_STATE_LOAD_F6
MENUITEM "7", IDM_STATE_LOAD_F7
MENUITEM "8", IDM_STATE_LOAD_F8
MENUITEM "9", IDM_STATE_LOAD_F9
MENUITEM "10", IDM_STATE_LOAD_F10
}
MENUITEM SEPARATOR MENUITEM SEPARATOR
MENUITEM "Save Screenshot &As", IDM_PRINTSCREEN MENUITEM "Save Screenshot &As", IDM_PRINTSCREEN
MENUITEM "&Quick Screenshot", IDM_QUICK_PRINTSCREEN MENUITEM "&Quick Screenshot", IDM_QUICK_PRINTSCREEN
@ -626,3 +652,28 @@ BEGIN
PUSHBUTTON "&Cancel",IDCANCEL,127,78,40,14 PUSHBUTTON "&Cancel",IDCANCEL,127,78,40,14
END END
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
BEGIN
VK_F1, IDM_STATE_SAVE_F1, VIRTKEY, SHIFT, NOINVERT
VK_F2, IDM_STATE_SAVE_F2, VIRTKEY, SHIFT, NOINVERT
VK_F3, IDM_STATE_SAVE_F3, VIRTKEY, SHIFT, NOINVERT
VK_F4, IDM_STATE_SAVE_F4, VIRTKEY, SHIFT, NOINVERT
VK_F5, IDM_STATE_SAVE_F5, VIRTKEY, SHIFT, NOINVERT
VK_F6, IDM_STATE_SAVE_F6, VIRTKEY, SHIFT, NOINVERT
VK_F7, IDM_STATE_SAVE_F7, VIRTKEY, SHIFT, NOINVERT
VK_F8, IDM_STATE_SAVE_F8, VIRTKEY, SHIFT, NOINVERT
VK_F9, IDM_STATE_SAVE_F9, VIRTKEY, SHIFT, NOINVERT
VK_F10, IDM_STATE_SAVE_F10, VIRTKEY, SHIFT, NOINVERT
VK_F1, IDM_STATE_LOAD_F1, VIRTKEY, NOINVERT
VK_F2, IDM_STATE_LOAD_F2, VIRTKEY, NOINVERT
VK_F3, IDM_STATE_LOAD_F3, VIRTKEY, NOINVERT
VK_F4, IDM_STATE_LOAD_F4, VIRTKEY, NOINVERT
VK_F5, IDM_STATE_LOAD_F5, VIRTKEY, NOINVERT
VK_F6, IDM_STATE_LOAD_F6, VIRTKEY, NOINVERT
VK_F7, IDM_STATE_LOAD_F7, VIRTKEY, NOINVERT
VK_F8, IDM_STATE_LOAD_F8, VIRTKEY, NOINVERT
VK_F9, IDM_STATE_LOAD_F9, VIRTKEY, NOINVERT
VK_F10, IDM_STATE_LOAD_F10, VIRTKEY, NOINVERT
END
//////////////////////////////////////////////////////////////////////////////