1 // Screen Window
2 #include "burner.h"
3 #include <shlobj.h>
4
5 #define HORIZONTAL_ORIENTED_RES 0
6 #define VERTICAL_ORIENTED_RES 1
7
8 int nActiveGame;
9
10 static bool bLoading = 0;
11
12 int OnMenuSelect(HWND, HMENU, int, HMENU, UINT);
13 int OnInitMenuPopup(HWND, HMENU, UINT, BOOL);
14 int OnUnInitMenuPopup(HWND, HMENU, UINT, BOOL);
15 void DisplayPopupMenu(int nMenu);
16
17 RECT SystemWorkArea = { 0, 0, 640, 480 }; // Work area on the desktop
18 int nWindowPosX = -1, nWindowPosY = -1; // Window position
19
20 int bAutoPause = 1;
21
22 bool bMenuEnabled = true;
23 bool bHasFocus = false;
24
25 int nSavestateSlot = 1;
26
27 static TCHAR* szClass = _T("FB Alpha"); // Window class name
28 HWND hScrnWnd = NULL; // Handle to the screen window
29 HWND hRebar = NULL; // Handle to the Rebar control containing the menu
30
31 static bool bMaximised;
32 static int nPrevWidth, nPrevHeight;
33
34 static int bBackFromHibernation = 0;
35
36 #define ID_NETCHAT 999
37 HWND hwndChat = NULL;
38 WNDPROC pOldWndProc = NULL;
39
40 bool bRescanRoms = false;
41
42 static bool bDrag = false;
43 static int nDragX, nDragY;
44 static int nOldWindowX, nOldWindowY;
45 static int nLeftButtonX, nLeftButtonY;
46
47 static int OnCreate(HWND, LPCREATESTRUCT);
48 static void OnActivateApp(HWND, BOOL, DWORD);
49 static void OnPaint(HWND);
50 static void OnClose(HWND);
51 static void OnDestroy(HWND);
52 static void OnCommand(HWND, int, HWND, UINT);
53 static int OnSysCommand(HWND, UINT, int, int);
54 static void OnSize(HWND, UINT, int, int);
55 static void OnEnterSizeMove(HWND);
56 static void OnExitSizeMove(HWND);
57 static void OnEnterIdle(HWND, UINT, HWND);
58 static void OnEnterMenuLoop(HWND, BOOL);
59 static void OnExitMenuLoop(HWND, BOOL);
60 static int OnMouseMove(HWND, int, int, UINT);
61 static int OnLButtonUp(HWND, int, int, UINT);
62 static int OnLButtonDown(HWND, BOOL, int, int, UINT);
63 static int OnLButtonDblClk(HWND, BOOL, int, int, UINT);
64 static int OnRButtonUp(HWND, int, int, UINT);
65 static int OnRButtonDown(HWND, BOOL, int, int, UINT);
66
67 static int OnDisplayChange(HWND, UINT, UINT, UINT);
68
69 int OnNotify(HWND, int, NMHDR* lpnmhdr);
70
UseDialogs()71 static bool UseDialogs()
72 {
73 if (/*!bDrvOkay ||*/ !nVidFullscreen) {
74 return true;
75 }
76
77 return false;
78 }
79
SetPauseMode(bool bPause)80 void SetPauseMode(bool bPause)
81 {
82 bRunPause = bPause;
83 bAltPause = bPause;
84
85 if (bPause) {
86 AudBlankSound();
87 if (UseDialogs()) {
88 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
89 }
90 } else {
91 GameInpCheckMouse();
92 }
93 }
94
CreateKailleraList()95 static char* CreateKailleraList()
96 {
97 unsigned int nOldDrvSelect = nBurnDrvActive;
98 int nSize = 256 * 1024;
99 char* pList = (char*)malloc(nSize);
100 char* pName = pList;
101
102 if (pList == NULL) {
103 return NULL;
104 }
105
106 // Add chat option to the gamelist
107 pName += sprintf(pName, "* Chat only");
108 pName++;
109
110 // Put games in the Favorites list at the top of the list.
111 { // (don't check avOk, this should work even if romlist isn't scanned! -dink)
112 LoadFavorites();
113
114 for (nBurnDrvActive = 0; nBurnDrvActive < nBurnDrvCount; nBurnDrvActive++) {
115 if (CheckFavorites(BurnDrvGetTextA(DRV_NAME)) != -1) {
116 char* szDecoratedName = DecorateGameName(nBurnDrvActive);
117
118 if (pName + strlen(szDecoratedName) >= pList + nSize) {
119 char* pNewList;
120 nSize <<= 1;
121 pNewList = (char*)realloc(pList, nSize);
122 if (pNewList == NULL) {
123 return NULL;
124 }
125 pName -= (INT_PTR)pList;
126 pList = pNewList;
127 pName += (INT_PTR)pList;
128 }
129 pName += sprintf(pName, "%s", szDecoratedName);
130 pName++;
131 }
132 }
133 }
134
135 if (avOk) {
136 // Add all the driver names to the list
137 for (nBurnDrvActive = 0; nBurnDrvActive < nBurnDrvCount; nBurnDrvActive++) {
138 if(BurnDrvGetFlags() & BDF_GAME_WORKING && gameAv[nBurnDrvActive]) {
139 char* szDecoratedName = DecorateGameName(nBurnDrvActive);
140
141 if (pName + strlen(szDecoratedName) >= pList + nSize) {
142 char* pNewList;
143 nSize <<= 1;
144 pNewList = (char*)realloc(pList, nSize);
145 if (pNewList == NULL) {
146 return NULL;
147 }
148 pName -= (INT_PTR)pList;
149 pList = pNewList;
150 pName += (INT_PTR)pList;
151 }
152 pName += sprintf(pName, "%s", szDecoratedName);
153 pName++;
154 }
155 }
156 }
157
158 *pName = '\0';
159 pName++;
160
161 nBurnDrvActive = nOldDrvSelect;
162
163 return pList;
164 }
165
DeActivateChat()166 void DeActivateChat()
167 {
168 bEditActive = false;
169 DestroyWindow(hwndChat);
170 hwndChat = NULL;
171 }
172
ActivateChat()173 int ActivateChat()
174 {
175 RECT rect;
176 GetClientRect(hScrnWnd, &rect);
177
178 DeActivateChat();
179
180 // Create an invisible edit control
181 hwndChat = CreateWindow(
182 _T("EDIT"), NULL,
183 WS_CHILD | ES_LEFT,
184 0, rect.bottom - 32, rect.right, 32,
185 hScrnWnd, (HMENU)ID_NETCHAT, (HINSTANCE)GetWindowLongPtr(hScrnWnd, GWLP_HINSTANCE), NULL); // pointer not needed
186
187 EditText[0] = 0;
188 bEditTextChanged = true;
189 bEditActive = true;
190
191 SendMessage(hwndChat, EM_LIMITTEXT, MAX_CHAT_SIZE, 0); // Limit the amount of text
192
193 SetFocus(hwndChat);
194
195 return 0;
196 }
197
gameCallback(char * game,int player,int numplayers)198 static int WINAPI gameCallback(char* game, int player, int numplayers)
199 {
200 bool bFound = false;
201 HWND hActive;
202
203 for (nBurnDrvActive = 0; nBurnDrvActive < nBurnDrvCount; nBurnDrvActive++) {
204
205 char* szDecoratedName = DecorateGameName(nBurnDrvActive);
206
207 if (!strcmp(szDecoratedName, game)) {
208 bFound = true;
209 break;
210 }
211 }
212
213 if (!bFound) {
214 // kailleraEndGame();
215 Kaillera_End_Game();
216 return 1;
217 }
218
219 kNetGame = 1;
220 hActive = GetActiveWindow();
221
222 bCheatsAllowed = false; // Disable cheats during netplay
223 AudSoundStop(); // Stop while we load roms
224 DrvInit(nBurnDrvActive, false); // Init the game driver
225 ScrnInit();
226 AudSoundPlay(); // Restart sound
227 VidInit();
228 SetFocus(hScrnWnd);
229
230 // dprintf(_T(" ** OSD startnet text sent.\n"));
231
232 TCHAR szTemp1[256];
233 TCHAR szTemp2[256];
234 VidSAddChatMsg(FBALoadStringEx(hAppInst, IDS_NETPLAY_START, true), 0xFFFFFF, BurnDrvGetText(DRV_FULLNAME), 0xFFBFBF);
235 _sntprintf(szTemp1, 256, FBALoadStringEx(hAppInst, IDS_NETPLAY_START_YOU, true), player);
236 _sntprintf(szTemp2, 256, FBALoadStringEx(hAppInst, IDS_NETPLAY_START_TOTAL, true), numplayers);
237 VidSAddChatMsg(szTemp1, 0xFFFFFF, szTemp2, 0xFFBFBF);
238
239 RunMessageLoop();
240
241 DrvExit();
242 if (kNetGame) {
243 kNetGame = 0;
244 // kailleraEndGame();
245 Kaillera_End_Game();
246 }
247 DeActivateChat();
248
249 bCheatsAllowed = true; // reenable cheats netplay has ended
250
251 SetFocus(hActive);
252 return 0;
253 }
254
kChatCallback(char * nick,char * text)255 static void WINAPI kChatCallback(char* nick, char* text)
256 {
257 TCHAR szTemp[128];
258 _sntprintf(szTemp, 128, _T("%.32hs "), nick);
259 VidSAddChatMsg(szTemp, 0xBFBFFF, ANSIToTCHAR(text, NULL, 0), 0x7F7FFF);
260 }
261
kDropCallback(char * nick,int playernb)262 static void WINAPI kDropCallback(char *nick, int playernb)
263 {
264 TCHAR szTemp[128];
265 _sntprintf(szTemp, 128, FBALoadStringEx(hAppInst, IDS_NETPLAY_DROP, true), playernb, nick);
266 VidSAddChatMsg(szTemp, 0xFFFFFF, NULL, 0);
267 }
268
DoNetGame()269 static void DoNetGame()
270 {
271 kailleraInfos ki;
272 char tmpver[128];
273 char* gameList;
274
275 if(bDrvOkay) {
276 DrvExit();
277 ScrnTitle();
278 }
279 MenuEnableItems();
280
281 #ifdef _UNICODE
282 _snprintf(tmpver, 128, APP_TITLE " v%.20ls", szAppBurnVer);
283 #else
284 _snprintf(tmpver, 128, APP_TITLE " v%.20s", szAppBurnVer);
285 #endif
286
287 gameList = CreateKailleraList();
288
289 ki.appName = tmpver;
290 ki.gameList = gameList;
291 ki.gameCallback = &gameCallback;
292 ki.chatReceivedCallback = &kChatCallback;
293 ki.clientDroppedCallback = &kDropCallback;
294 ki.moreInfosCallback = NULL;
295
296 Kaillera_Set_Infos(&ki);
297 //kailleraSetInfos(&ki);
298
299 Kaillera_Select_Server_Dialog(NULL);
300 //kailleraSelectServerDialog(NULL);
301
302 if (gameList) {
303 free(gameList);
304 gameList = NULL;
305 }
306
307 End_Network();
308
309 POST_INITIALISE_MESSAGE;
310 }
311
CreateDatfileWindows(int bType)312 int CreateDatfileWindows(int bType)
313 {
314 TCHAR szTitle[1024];
315 TCHAR szFilter[1024];
316
317 TCHAR szConsoleString[64];
318 _sntprintf(szConsoleString, 64, _T(""));
319 if (bType == DAT_MEGADRIVE_ONLY) _sntprintf(szConsoleString, 64, _T(", Megadrive only"));
320 if (bType == DAT_PCENGINE_ONLY) _sntprintf(szConsoleString, 64, _T(", PC-Engine only"));
321 if (bType == DAT_TG16_ONLY) _sntprintf(szConsoleString, 64, _T(", TurboGrafx16 only"));
322 if (bType == DAT_SGX_ONLY) _sntprintf(szConsoleString, 64, _T(", SuprGrafx only"));
323 if (bType == DAT_SG1000_ONLY) _sntprintf(szConsoleString, 64, _T(", Sega SG-1000 only"));
324 if (bType == DAT_COLECO_ONLY) _sntprintf(szConsoleString, 64, _T(", ColecoVision only"));
325 if (bType == DAT_MASTERSYSTEM_ONLY) _sntprintf(szConsoleString, 64, _T(", Master System only"));
326 if (bType == DAT_GAMEGEAR_ONLY) _sntprintf(szConsoleString, 64, _T(", Game Gear only"));
327 if (bType == DAT_MSX_ONLY) _sntprintf(szConsoleString, 64, _T(", MSX 1 Games only"));
328 if (bType == DAT_SPECTRUM_ONLY) _sntprintf(szConsoleString, 64, _T(", ZX Spectrum Games only"));
329
330 TCHAR szProgramString[25];
331 _sntprintf(szProgramString, 25, _T("ClrMame Pro XML"));
332
333 _sntprintf(szChoice, MAX_PATH, _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), szAppBurnVer, szProgramString, szConsoleString);
334 _sntprintf(szTitle, 256, FBALoadStringEx(hAppInst, IDS_DAT_GENERATE, true), szProgramString);
335
336 _stprintf(szFilter, FBALoadStringEx(hAppInst, IDS_DISK_ALL_DAT, true), _T(APP_TITLE));
337 memcpy(szFilter + _tcslen(szFilter), _T(" (*.dat)\0*.dat\0\0"), 16 * sizeof(TCHAR));
338
339 memset(&ofn, 0, sizeof(ofn));
340 ofn.lStructSize = sizeof(ofn);
341 ofn.hwndOwner = hScrnWnd;
342 ofn.lpstrFilter = szFilter;
343 ofn.lpstrFile = szChoice;
344 ofn.nMaxFile = sizeof(szChoice) / sizeof(TCHAR);
345 ofn.lpstrInitialDir = _T(".");
346 ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
347 ofn.lpstrDefExt = _T("dat");
348 ofn.lpstrTitle = szTitle;
349 ofn.Flags |= OFN_OVERWRITEPROMPT;
350
351 if (GetSaveFileName(&ofn) == 0)
352 return -1;
353
354 return create_datfile(szChoice, bType);
355 }
356
CreateAllDatfilesWindows()357 int CreateAllDatfilesWindows()
358 {
359 INT32 nRet = 0;
360
361 LPMALLOC pMalloc = NULL;
362 BROWSEINFO bInfo;
363 ITEMIDLIST* pItemIDList = NULL;
364 TCHAR buffer[MAX_PATH];
365 TCHAR szFilename[MAX_PATH];
366 TCHAR szProgramString[25];
367
368 _sntprintf(szProgramString, 25, _T("ClrMame Pro XML"));
369
370 SHGetMalloc(&pMalloc);
371
372 memset(&bInfo, 0, sizeof(bInfo));
373 bInfo.hwndOwner = hScrnWnd;
374 bInfo.pszDisplayName = buffer;
375 bInfo.lpszTitle = FBALoadStringEx(hAppInst, IDS_ROMS_SELECT_DIR, true);
376 bInfo.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS;
377
378 pItemIDList = SHBrowseForFolder(&bInfo);
379
380 if (pItemIDList) {
381 if (SHGetPathFromIDList(pItemIDList, buffer)) {
382 int strLen = _tcslen(buffer);
383 if (strLen) {
384 if (buffer[strLen - 1] != _T('\\')) {
385 buffer[strLen] = _T('\\');
386 buffer[strLen + 1] = _T('\0');
387 }
388 }
389 }
390 pMalloc->Free(pItemIDList);
391 }
392 pMalloc->Release();
393
394 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(""));
395 create_datfile(szFilename, DAT_ARCADE_ONLY);
396
397 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", Megadrive only"));
398 create_datfile(szFilename, DAT_MEGADRIVE_ONLY);
399
400 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", PC-Engine only"));
401 create_datfile(szFilename, DAT_PCENGINE_ONLY);
402
403 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", TurboGrafx16 only"));
404 create_datfile(szFilename, DAT_TG16_ONLY);
405
406 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", SuprGrafx only"));
407 create_datfile(szFilename, DAT_SGX_ONLY);
408
409 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", Sega SG-1000 only"));
410 create_datfile(szFilename, DAT_SG1000_ONLY);
411
412 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", ColecoVision only"));
413 create_datfile(szFilename, DAT_COLECO_ONLY);
414
415 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", Master System only"));
416 create_datfile(szFilename, DAT_MASTERSYSTEM_ONLY);
417
418 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", Game Gear only"));
419 create_datfile(szFilename, DAT_GAMEGEAR_ONLY);
420
421 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", MSX 1 Games only"));
422 create_datfile(szFilename, DAT_MSX_ONLY);
423
424 _sntprintf(szFilename, MAX_PATH, _T("%s") _T(APP_TITLE) _T(" v%.20s (%s%s).dat"), buffer, szAppBurnVer, szProgramString, _T(", ZX Spectrum Games only"));
425 create_datfile(szFilename, DAT_SPECTRUM_ONLY);
426
427 return nRet;
428 }
429
430 // Returns true if a VidInit is needed when the window is resized
VidInitNeeded()431 static bool VidInitNeeded()
432 {
433 // D3D blitter needs to re-initialise only when auto-size RGB effects are enabled
434 if (nVidSelect == 1 && (nVidBlitterOpt[nVidSelect] & 0x00030000) == 0x00030000) {
435 return true;
436 }
437 if (nVidSelect == 3) {
438 return true;
439 }
440
441 return false;
442 }
443
444 // Refresh the contents of the window when re-sizing it
RefreshWindow(bool bInitialise)445 static void RefreshWindow(bool bInitialise)
446 {
447 if (nVidFullscreen) {
448 return;
449 }
450
451 if (bInitialise && VidInitNeeded()) {
452 VidInit();
453 if (bVidOkay && (bRunPause || !bDrvOkay)) {
454 VidRedraw();
455 VidPaint(0);
456 }
457 }
458 }
459
ScrnProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam)460 static LRESULT CALLBACK ScrnProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
461 {
462 switch (Msg) {
463 HANDLE_MSG(hWnd, WM_CREATE, OnCreate);
464 HANDLE_MSG(hWnd, WM_ACTIVATEAPP, OnActivateApp);
465 HANDLE_MSGB(hWnd,WM_PAINT, OnPaint);
466 HANDLE_MSG(hWnd, WM_CLOSE, OnClose);
467 HANDLE_MSG(hWnd, WM_DESTROY, OnDestroy);
468 HANDLE_MSG(hWnd, WM_COMMAND, OnCommand);
469
470 // We can't use the macro from windowsx.h macro for this one
471 case WM_SYSCOMMAND: {
472 if (OnSysCommand(hWnd,(UINT)wParam,(int)(short)LOWORD(lParam),(int)(short)HIWORD(lParam))) {
473 return 0;
474 }
475 break;
476 }
477 // - dink - handle return from Hibernation
478 case WM_POWERBROADCAST: {
479 if (wParam == PBT_APMRESUMESUSPEND || wParam == PBT_APMSUSPEND) {
480 bBackFromHibernation = 1;
481 }
482 break;
483 }
484 // - dink - end
485 HANDLE_MSG(hWnd, WM_SIZE, OnSize);
486 HANDLE_MSG(hWnd, WM_ENTERSIZEMOVE, OnEnterSizeMove);
487 HANDLE_MSG(hWnd, WM_EXITSIZEMOVE, OnExitSizeMove);
488 HANDLE_MSG(hWnd, WM_ENTERIDLE, OnEnterIdle);
489
490 HANDLE_MSG(hWnd, WM_MOUSEMOVE, OnMouseMove);
491 HANDLE_MSG(hWnd, WM_LBUTTONUP, OnLButtonUp);
492 HANDLE_MSG(hWnd, WM_LBUTTONDOWN, OnLButtonDown);
493
494 HANDLE_MSG(hWnd, WM_LBUTTONDBLCLK, OnLButtonDblClk);
495
496 HANDLE_MSG(hWnd, WM_RBUTTONUP, OnRButtonUp);
497 HANDLE_MSG(hWnd, WM_RBUTTONDBLCLK, OnRButtonDown);
498 HANDLE_MSG(hWnd, WM_RBUTTONDOWN, OnRButtonDown);
499
500 HANDLE_MSG(hWnd, WM_NOTIFY, OnNotify);
501 HANDLE_MSG(hWnd, WM_MENUSELECT, OnMenuSelect);
502 HANDLE_MSG(hWnd, WM_ENTERMENULOOP, OnEnterMenuLoop);
503 HANDLE_MSGB(hWnd,WM_EXITMENULOOP, OnExitMenuLoop);
504 HANDLE_MSGB(hWnd,WM_INITMENUPOPUP, OnInitMenuPopup);
505 HANDLE_MSG(hWnd, WM_UNINITMENUPOPUP,OnUnInitMenuPopup);
506
507 HANDLE_MSG(hWnd, WM_DISPLAYCHANGE, OnDisplayChange);
508 }
509
510 return DefWindowProc(hWnd, Msg, wParam, lParam);
511 }
512
OnDisplayChange(HWND,UINT,UINT,UINT)513 static int OnDisplayChange(HWND, UINT, UINT, UINT)
514 {
515 if (!nVidFullscreen) {
516 POST_INITIALISE_MESSAGE;
517 }
518
519 return 0;
520 }
521
522 /******************************************************************************/
523 /* Fixed right click mouse events, now they work properly without interfering
524 with other applications in the background [CaptainCPS-X] */
525 //----------------------------------------------------------------------------//
526 bool bRDblClick = false;
527
OnRButtonDown(HWND hwnd,BOOL bDouble,int,int,UINT)528 static int OnRButtonDown(HWND hwnd, BOOL bDouble, int, int, UINT)
529 {
530 if (hwnd != hScrnWnd && !nVidFullscreen) return 1;
531
532 if (bDouble) {
533 // Right double-click at fullcreen happened, turn this flag 'true' so
534 // when right double-click ends (OnRButtonUp) it doesn't do anything else.
535 bRDblClick = true;
536 }
537 return 1;
538 }
539
OnRButtonUp(HWND hwnd,int,int,UINT)540 static int OnRButtonUp(HWND hwnd, int, int, UINT)
541 {
542 // If fullscreen and right double-click
543 if (hwnd == hScrnWnd && nVidFullscreen && bRDblClick)
544 {
545 // game running
546 if (bDrvOkay)
547 {
548 // toggle fullscreen
549 nVidFullscreen = !nVidFullscreen;
550 bRDblClick = false;
551 POST_INITIALISE_MESSAGE;
552 return 0;
553 }
554 }
555
556 // If not fullscreen and this event is not related to 'toggle fullscreen' right double-click event
557 if (!nVidFullscreen && !bRDblClick) {
558 bMenuEnabled = !bMenuEnabled;
559 POST_INITIALISE_MESSAGE;
560 return 0;
561 }
562
563 return 1;
564 }
565 /*************************************************************************/
566
OnMouseMove(HWND hwnd,int x,int y,UINT keyIndicators)567 static int OnMouseMove(HWND hwnd, int x, int y, UINT keyIndicators)
568 {
569 if (bDrag && hwnd == hScrnWnd && keyIndicators == MK_LBUTTON && !nVidFullscreen && !bMenuEnabled) {
570 RECT clientRect;
571
572 GetWindowRect(hScrnWnd, &clientRect);
573
574 if ((nLeftButtonX - (clientRect.left + x)) < nDragX && (nLeftButtonX - (clientRect.left + x)) > -nDragX && (nLeftButtonY - (clientRect.top + y)) < nDragY && (nLeftButtonY - (clientRect.top + y)) > -nDragY) {
575 SetWindowPos(hScrnWnd, NULL, nOldWindowX, nOldWindowY, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE);
576 } else {
577 nWindowPosX = nOldWindowX - (nLeftButtonX - (clientRect.left + x));
578 nWindowPosY = nOldWindowY - (nLeftButtonY - (clientRect.top + y));
579
580 SetWindowPos(hScrnWnd, NULL, nWindowPosX, nWindowPosY, 0, 0, SWP_NOREPOSITION | SWP_NOSIZE);
581 }
582
583 return 0;
584 }
585
586 return 1;
587 }
588
OnLButtonDown(HWND hwnd,BOOL,int x,int y,UINT)589 static int OnLButtonDown(HWND hwnd, BOOL, int x, int y, UINT)
590 {
591 if (hwnd == hScrnWnd && !nVidFullscreen && !bMenuEnabled) {
592 RECT clientRect;
593
594 GetWindowRect(hScrnWnd, &clientRect);
595
596 nOldWindowX = clientRect.left;
597 nOldWindowY = clientRect.top;
598
599 nLeftButtonX = clientRect.left + x;
600 nLeftButtonY = clientRect.top + y;
601
602 bDrag = true;
603
604 return 0;
605 }
606
607 return 1;
608 }
609
OnLButtonUp(HWND hwnd,int x,int y,UINT)610 static int OnLButtonUp(HWND hwnd, int x, int y, UINT)
611 {
612 bDrag = false;
613
614 if (nVidFullscreen) {
615
616 if (hwnd != hScrnWnd) {
617 return 1;
618 }
619
620 if (UseDialogs()) {
621 RECT clientRect;
622 GetWindowRect(hScrnWnd, &clientRect);
623
624 TrackPopupMenuEx(hMenuPopup, TPM_LEFTALIGN | TPM_TOPALIGN, clientRect.left + x, clientRect.top + y, hScrnWnd, NULL);
625 return 0;
626 }
627 } else {
628 if (!bMenuEnabled) {
629 RECT clientRect;
630 GetWindowRect(hScrnWnd, &clientRect);
631
632 if ((nLeftButtonX - (clientRect.left + x)) < nDragX && (nLeftButtonX - (clientRect.left + x)) > -nDragX && (nLeftButtonY - (clientRect.top + y)) < nDragY && (nLeftButtonY - (clientRect.top + y)) > -nDragY) {
633 TrackPopupMenuEx(hMenuPopup, TPM_LEFTALIGN | TPM_TOPALIGN, clientRect.left + x, clientRect.top + y, hScrnWnd, NULL);
634 return 0;
635 }
636 }
637 }
638
639 return 1;
640 }
641
OnLButtonDblClk(HWND hwnd,BOOL,int,int,UINT)642 static int OnLButtonDblClk(HWND hwnd, BOOL, int, int, UINT)
643 {
644 if (bDrvOkay) {
645 nVidFullscreen = !nVidFullscreen;
646 POST_INITIALISE_MESSAGE;
647 return 0;
648 }
649
650 return 1;
651 }
652
OnCreate(HWND,LPCREATESTRUCT)653 static int OnCreate(HWND, LPCREATESTRUCT) // HWND hwnd, LPCREATESTRUCT lpCreateStruct
654 {
655 return 1;
656 }
657
OnActivateApp(HWND hwnd,BOOL fActivate,DWORD)658 static void OnActivateApp(HWND hwnd, BOOL fActivate, DWORD /* dwThreadId */)
659 {
660 bHasFocus = fActivate;
661 if (!kNetGame && bAutoPause && !bAltPause && hInpdDlg == NULL && hInpCheatDlg == NULL && hInpDIPSWDlg == NULL) {
662 bRunPause = fActivate? 0 : 1;
663 }
664 if (fActivate == false && hwnd == hScrnWnd) {
665 EndMenu();
666 }
667 if (fActivate == false && bRunPause) {
668 AudBlankSound();
669 }
670
671 if (fActivate) {
672 if (hInpdDlg || hInpCheatDlg || hInpDIPSWDlg || hDbgDlg) {
673 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
674 } else {
675 GameInpCheckMouse();
676 }
677 }
678 }
679
680 extern HWND hSelDlg;
681
PausedRedraw(void)682 void PausedRedraw(void)
683 {
684 if (bVidOkay && bRunPause && bDrvOkay && (hSelDlg == NULL)) { // Redraw the screen to show certain messages while paused. - dink
685 INT16 *pBtemp = pBurnSoundOut;
686 pBurnSoundOut = NULL; // Mute the sound as VidRedraw() draws the frame (if no driver Redraw function is available)
687
688 VidRedraw();
689 VidPaint(0);
690
691 pBurnSoundOut = pBtemp;
692 }
693 }
694
OnPaint(HWND hWnd)695 static void OnPaint(HWND hWnd)
696 {
697 if (hWnd == hScrnWnd)
698 {
699 VidPaint(1);
700
701 if (bBackFromHibernation) {
702 PausedRedraw(); // redraw game screen if paused and returning from hibernation - dink
703 bBackFromHibernation = 0;
704 }
705
706 // draw menu
707 if (!nVidFullscreen) {
708 RedrawWindow(hRebar, NULL, NULL, RDW_FRAME | RDW_UPDATENOW | RDW_ALLCHILDREN);
709 }
710 }
711 }
712
OnClose(HWND)713 static void OnClose(HWND)
714 {
715 #ifdef INCLUDE_AVI_RECORDING
716 AviStop();
717 #endif
718 PostQuitMessage(0); // Quit the program if the window is closed
719 }
720
OnDestroy(HWND)721 static void OnDestroy(HWND)
722 {
723 VidExit(); // Stop using video with the Window
724 hScrnWnd = NULL; // Make sure handle is not used again
725 }
726
727 OPENFILENAME bgFn;
728 TCHAR szFile[MAX_PATH];
729
UpdatePreviousGameList()730 static void UpdatePreviousGameList()
731 {
732 int nRecentIdenticalTo = -1;
733
734 // check if this game is identical to any of the listed in the recent menu
735 for(int x = 0; x < SHOW_PREV_GAMES; x++) {
736 if(!_tcscmp(BurnDrvGetText(DRV_NAME), szPrevGames[x])) {
737 nRecentIdenticalTo = x;
738 }
739 }
740
741 // Declare temporary array
742 TCHAR szTmp[SHOW_PREV_GAMES][32];
743
744 // Backup info for later use
745 for(int x = 0; x < SHOW_PREV_GAMES; x++) {
746 _tcscpy(szTmp[x], szPrevGames[x]);
747 }
748
749 switch(nRecentIdenticalTo)
750 {
751 case -1:
752 // Normal rotation when recent game is not identical to any of the ones listed
753 // - - -
754 _tcscpy(szPrevGames[9], szPrevGames[8]); // Recent 10 = 9
755 _tcscpy(szPrevGames[8], szPrevGames[7]); // Recent 9 = 8
756 _tcscpy(szPrevGames[7], szPrevGames[6]); // Recent 8 = 7
757 _tcscpy(szPrevGames[6], szPrevGames[5]); // Recent 7 = 6
758 _tcscpy(szPrevGames[5], szPrevGames[4]); // Recent 6 = 5
759 _tcscpy(szPrevGames[4], szPrevGames[3]); // Recent 5 = 4
760 _tcscpy(szPrevGames[3], szPrevGames[2]); // Recent 4 = 3
761 _tcscpy(szPrevGames[2], szPrevGames[1]); // Recent 3 = 2
762 _tcscpy(szPrevGames[1], szPrevGames[0]); // Recent 2 = 1
763 _tcscpy(szPrevGames[0], BurnDrvGetText(DRV_NAME)); // Update most recent game played (Recent 1)
764 break;
765 case 0:
766 break; // Nothing Change
767 case 1:
768 _tcscpy(szPrevGames[0], szTmp[1]); // Update most recent game played (Recent 1 = 2)
769 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
770 break;
771 case 2:
772 _tcscpy(szPrevGames[0], szTmp[2]); // Update most recent game played (Recent 1 = 3)
773 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
774 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
775 break;
776 case 3:
777 _tcscpy(szPrevGames[0], szTmp[3]); // Update most recent game played (Recent 1 = 4)
778 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
779 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
780 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
781 break;
782 case 4:
783 _tcscpy(szPrevGames[0], szTmp[4]); // Update most recent game played (Recent 1 = 5)
784 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
785 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
786 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
787 _tcscpy(szPrevGames[4], szTmp[3]); // Recent 5 = 4
788 break;
789 case 5:
790 _tcscpy(szPrevGames[0], szTmp[5]); // Update most recent game played (Recent 1 = 6)
791 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
792 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
793 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
794 _tcscpy(szPrevGames[4], szTmp[3]); // Recent 5 = 4
795 _tcscpy(szPrevGames[5], szTmp[4]); // Recent 6 = 5
796 break;
797 case 6:
798 _tcscpy(szPrevGames[0], szTmp[6]); // Update most recent game played (Recent 1 = 7)
799 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
800 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
801 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
802 _tcscpy(szPrevGames[4], szTmp[3]); // Recent 5 = 4
803 _tcscpy(szPrevGames[5], szTmp[4]); // Recent 6 = 5
804 _tcscpy(szPrevGames[6], szTmp[5]); // Recent 7 = 6
805 break;
806 case 7:
807 _tcscpy(szPrevGames[0], szTmp[7]); // Update most recent game played (Recent 1 = 8)
808 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
809 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
810 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
811 _tcscpy(szPrevGames[4], szTmp[3]); // Recent 5 = 4
812 _tcscpy(szPrevGames[5], szTmp[4]); // Recent 6 = 5
813 _tcscpy(szPrevGames[6], szTmp[5]); // Recent 7 = 6
814 _tcscpy(szPrevGames[7], szTmp[6]); // Recent 8 = 7
815 break;
816 case 8:
817 _tcscpy(szPrevGames[0], szTmp[8]); // Update most recent game played (Recent 1 = 9)
818 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
819 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
820 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
821 _tcscpy(szPrevGames[4], szTmp[3]); // Recent 5 = 4
822 _tcscpy(szPrevGames[5], szTmp[4]); // Recent 6 = 5
823 _tcscpy(szPrevGames[6], szTmp[5]); // Recent 7 = 6
824 _tcscpy(szPrevGames[7], szTmp[6]); // Recent 8 = 7
825 _tcscpy(szPrevGames[8], szTmp[7]); // Recent 9 = 8
826 break;
827 case 9:
828 _tcscpy(szPrevGames[0], szTmp[9]); // Update most recent game played (Recent 1 = 10)
829 _tcscpy(szPrevGames[1], szTmp[0]); // Recent 2 = 1
830 _tcscpy(szPrevGames[2], szTmp[1]); // Recent 3 = 2
831 _tcscpy(szPrevGames[3], szTmp[2]); // Recent 4 = 3
832 _tcscpy(szPrevGames[4], szTmp[3]); // Recent 5 = 4
833 _tcscpy(szPrevGames[5], szTmp[4]); // Recent 6 = 5
834 _tcscpy(szPrevGames[6], szTmp[5]); // Recent 7 = 6
835 _tcscpy(szPrevGames[7], szTmp[6]); // Recent 8 = 7
836 _tcscpy(szPrevGames[8], szTmp[7]); // Recent 9 = 8
837 _tcscpy(szPrevGames[9], szTmp[8]); // Recent 10 = 9
838 break;
839 }
840 }
841
842 static bool bSramLoad = true; // always true, unless BurnerLoadDriver() is called from StartFromReset()
843
844 // Compact driver loading module
BurnerLoadDriver(TCHAR * szDriverName)845 int BurnerLoadDriver(TCHAR *szDriverName)
846 {
847 unsigned int j;
848
849 int nOldDrvSelect = nBurnDrvActive;
850 DrvExit();
851 bLoading = 1;
852
853 for (j = 0; j < nBurnDrvCount; j++) {
854 nBurnDrvActive = j;
855 if (!_tcscmp(szDriverName, BurnDrvGetText(DRV_NAME)) && (!(BurnDrvGetFlags() & BDF_BOARDROM))) {
856 nBurnDrvActive = nOldDrvSelect;
857 nDialogSelect = j;
858 SplashDestroy(1);
859 StopReplay();
860
861 DrvExit();
862 DrvInit(j, bSramLoad); // Init the game driver
863 MenuEnableItems();
864 bAltPause = 0;
865 AudSoundPlay(); // Restart sound
866 bLoading = 0;
867 UpdatePreviousGameList();
868 if (bVidAutoSwitchFull) {
869 nVidFullscreen = 1;
870 POST_INITIALISE_MESSAGE;
871 }
872 break;
873 }
874 }
875
876 return 0;
877 }
878
StartFromReset(TCHAR * szDriverName)879 int StartFromReset(TCHAR *szDriverName)
880 {
881 if (!bDrvOkay || (szDriverName && _tcscmp(szDriverName, BurnDrvGetText(DRV_NAME))) ) {
882 bSramLoad = false;
883 BurnerLoadDriver(szDriverName);
884 bSramLoad = true;
885 return 1;
886 }
887 //if(nBurnDrvActive < 1) return 0;
888
889 int nOldDrvSelect = nBurnDrvActive;
890
891 DrvExit();
892 bLoading = 1;
893
894 nBurnDrvActive = nOldDrvSelect;
895 nDialogSelect = nOldDrvSelect;
896 SplashDestroy(1);
897 StopReplay();
898
899 DrvInit(nOldDrvSelect, false); // Init the game driver, without loading SRAM
900 MenuEnableItems();
901 bAltPause = 0;
902 AudSoundPlay(); // Restart sound
903 bLoading = 0;
904 UpdatePreviousGameList();
905 if (bVidAutoSwitchFull) {
906 nVidFullscreen = 1;
907 POST_INITIALISE_MESSAGE;
908 }
909 return 1;
910 }
911
scrnSSUndo()912 void scrnSSUndo() // called from the menu (shift+F8) and CheckSystemMacros() in run.cpp
913 {
914 if (bDrvOkay) {
915 TCHAR szString[256] = _T("state undo");
916 TCHAR szStringFailed[256] = _T("state: nothing to undo");
917 if (!StatedUNDO(nSavestateSlot)) {
918 VidSNewShortMsg(szString);
919 } else {
920 VidSNewShortMsg(szStringFailed);
921 }
922 PausedRedraw();
923 }
924 }
925
OnCommand(HWND,int id,HWND,UINT codeNotify)926 static void OnCommand(HWND /*hDlg*/, int id, HWND /*hwndCtl*/, UINT codeNotify)
927 {
928 //if(id >= ID_MDI_START_CHILD) {
929 // DefFrameProc(hwndCtl, hWndChildFrame, WM_COMMAND, wParam, lParam);
930 // return;
931 //} else {
932 // HWND hWndCurrent = (HWND)SendMessage(hWndChildFrame, WM_MDIGETACTIVE,0,0);
933 // if(hWndCurrent) {
934 // SendMessage(hWndCurrent, WM_COMMAND, wParam, lParam);
935 // return;
936 // }
937 //}
938
939 if (bLoading) {
940 return;
941 }
942
943 switch (id) {
944 case MENU_LOAD: {
945 int nGame;
946
947 if(kNetGame || !UseDialogs() || bLoading) {
948 break;
949 }
950
951 SplashDestroy(1);
952 StopReplay();
953
954 #ifdef INCLUDE_AVI_RECORDING
955 AviStop();
956 #endif
957
958 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
959
960 bLoading = 1;
961 AudSoundStop(); // Stop while the dialog is active or we're loading ROMs
962
963 nGame = SelDialog(0, hScrnWnd); // Bring up select dialog to pick a driver
964
965 extern bool bDialogCancel;
966
967 if (nGame >= 0 && bDialogCancel == false) {
968 DrvExit();
969 DrvInit(nGame, true); // Init the game driver
970 MenuEnableItems();
971 bAltPause = 0;
972 AudSoundPlay(); // Restart sound
973 bLoading = 0;
974 UpdatePreviousGameList();
975 if (bVidAutoSwitchFull) {
976 nVidFullscreen = 1;
977 POST_INITIALISE_MESSAGE;
978 }
979
980 POST_INITIALISE_MESSAGE;
981 break;
982 } else {
983 GameInpCheckMouse();
984 AudSoundPlay(); // Restart sound
985 bLoading = 0;
986 break;
987 }
988 }
989
990 case MENU_PREVIOUSGAMES1:
991 case MENU_PREVIOUSGAMES2:
992 case MENU_PREVIOUSGAMES3:
993 case MENU_PREVIOUSGAMES4:
994 case MENU_PREVIOUSGAMES5:
995 case MENU_PREVIOUSGAMES6:
996 case MENU_PREVIOUSGAMES7:
997 case MENU_PREVIOUSGAMES8:
998 case MENU_PREVIOUSGAMES9:
999 case MENU_PREVIOUSGAMES10: {
1000 BurnerLoadDriver(szPrevGames[id - MENU_PREVIOUSGAMES1]);
1001 break;
1002 }
1003
1004 case MENU_START_NEOGEO_MVS: {
1005 BurnerLoadDriver(_T("neogeo"));
1006 break;
1007 }
1008
1009 case MENU_START_NEOGEO_CD: {
1010 BurnerLoadDriver(_T("neocdz"));
1011 break;
1012 }
1013
1014 case MENU_LOAD_NEOCD: {
1015 AudBlankSound();
1016 if (UseDialogs()) {
1017 NeoCDList_Init();
1018 }
1019 break;
1020 }
1021
1022 case MENU_CDIMAGE: {
1023 nCDEmuSelect = 0;
1024 TCHAR szFilter[100];
1025 _stprintf(szFilter, _T("%s"), FBALoadStringEx(hAppInst, IDS_CD_SELECT_FILTER, true));
1026 memcpy(szFilter + _tcslen(szFilter), _T(" (*.ccd,*.cue)\0*.ccd;*.cue\0\0"), 28 * sizeof(TCHAR));
1027 TCHAR szTitle[100];
1028 _stprintf(szTitle, _T("%s"), FBALoadStringEx(hAppInst, IDS_CD_SELECT_IMAGE_TITLE, true));
1029 if (UseDialogs() && !bDrvOkay) {
1030 memset(&ofn, 0, sizeof(ofn));
1031 ofn.lStructSize = sizeof(ofn);
1032 ofn.hwndOwner = hScrnWnd;
1033 ofn.lpstrFile = StrReplace(CDEmuImage, _T('/'), _T('\\'));
1034 ofn.nMaxFile = MAX_PATH;
1035 ofn.lpstrTitle = szTitle;
1036 ofn.lpstrFilter = szFilter;
1037 ofn.lpstrInitialDir = _T(".");
1038 ofn.Flags = OFN_NOCHANGEDIR | OFN_HIDEREADONLY;
1039 ofn.lpstrDefExt = _T("cue");
1040
1041 GetOpenFileName(&ofn);
1042 }
1043 break;
1044 }
1045
1046 case MENU_STARTNET:
1047 if (Init_Network()) {
1048 MessageBox(hScrnWnd, FBALoadStringEx(hAppInst, IDS_ERR_NO_NETPLAYDLL, true), FBALoadStringEx(hAppInst, IDS_ERR_ERROR, true), MB_OK);
1049 break;
1050 }
1051 #ifdef BUILD_A68K
1052 if (bBurnUseASMCPUEmulation) {
1053 FBAPopupAddText(PUF_TEXT_DEFAULT, _T("Please uncheck \"Misc -> Options -> Use Assembly MC68000 Core\" before starting a netgame!"));
1054 FBAPopupDisplay(PUF_TYPE_ERROR);
1055 break;
1056 }
1057 #endif
1058 if (!kNetGame) {
1059 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1060 AudBlankSound();
1061 SplashDestroy(1);
1062 StopReplay();
1063 #ifdef INCLUDE_AVI_RECORDING
1064 AviStop();
1065 #endif
1066 DrvExit();
1067 DoNetGame();
1068 MenuEnableItems();
1069 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1070 }
1071 break;
1072
1073 case MENU_STARTREPLAY:
1074 if (UseDialogs()) {
1075 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1076 AudSoundStop();
1077 SplashDestroy(1);
1078 StopReplay();
1079 StartReplay();
1080 GameInpCheckMouse();
1081 AudSoundPlay();
1082 }
1083 break;
1084 case MENU_STARTRECORD:
1085 if (UseDialogs() && nReplayStatus != 1) {
1086 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1087 AudBlankSound();
1088 StopReplay();
1089 StartRecord();
1090 GameInpCheckMouse();
1091 }
1092 break;
1093 case MENU_STOPREPLAY:
1094 StopReplay();
1095 SetPauseMode(1);
1096 break;
1097
1098 #ifdef INCLUDE_AVI_RECORDING
1099 case MENU_AVISTART:
1100 if (AviStart()) {
1101 AviStop();
1102 } else {
1103 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_REC_AVI, true), 0x0000FF);
1104 }
1105 break;
1106 case MENU_AVISTOP:
1107 AviStop();
1108 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_STOP_AVI, true), 0xFF3F3F);
1109 break;
1110 #endif
1111
1112 case MENU_QUIT:
1113 AudBlankSound();
1114 if (nVidFullscreen) {
1115 nVidFullscreen = 0;
1116 VidExit();
1117 }
1118 if (bDrvOkay) {
1119 StopReplay();
1120 #ifdef INCLUDE_AVI_RECORDING
1121 AviStop();
1122 #endif
1123 DrvExit();
1124 if (kNetGame) {
1125 kNetGame = 0;
1126 // kailleraEndGame();
1127 Kaillera_End_Game();
1128 DeActivateChat();
1129 PostQuitMessage(0);
1130 }
1131 bCheatsAllowed = true; // reenable cheats netplay has ended
1132
1133 ScrnSize();
1134 ScrnTitle();
1135 MenuEnableItems();
1136 nDialogSelect = -1;
1137 nBurnDrvActive = ~0U;
1138
1139 POST_INITIALISE_MESSAGE;
1140 }
1141 break;
1142
1143 case MENU_EXIT:
1144 StopReplay();
1145 #ifdef INCLUDE_AVI_RECORDING
1146 AviStop();
1147 #endif
1148 if (kNetGame) {
1149 kNetGame = 0;
1150 // kailleraEndGame();
1151 Kaillera_End_Game();
1152 DeActivateChat();
1153 }
1154 PostQuitMessage(0);
1155 return;
1156
1157 case MENU_PAUSE:
1158 if (bDrvOkay && !kNetGame) {
1159 SetPauseMode(!bRunPause);
1160 } else {
1161 SetPauseMode(0);
1162 }
1163 break;
1164
1165 case MENU_INPUT:
1166 AudBlankSound();
1167 if (UseDialogs()) {
1168 InputSetCooperativeLevel(false, false);
1169 InpdCreate();
1170 }
1171 break;
1172
1173 case MENU_DIPSW:
1174 AudBlankSound();
1175 if (UseDialogs()) {
1176 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1177 InpDIPSWCreate();
1178 }
1179 break;
1180
1181 case MENU_SETCPUCLOCK:
1182 AudBlankSound();
1183 CPUClockDialog();
1184 MenuEnableItems();
1185 GameInpCheckMouse();
1186 break;
1187 case MENU_RESETCPUCLOCK:
1188 nBurnCPUSpeedAdjust = 0x0100;
1189 MenuEnableItems();
1190 break;
1191
1192 case MENU_MEMCARD_CREATE:
1193 if (bDrvOkay && UseDialogs() && !kNetGame && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOGEO) {
1194 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1195 AudBlankSound();
1196 MemCardEject();
1197 MemCardCreate();
1198 MemCardInsert();
1199 GameInpCheckMouse();
1200 }
1201 break;
1202 case MENU_MEMCARD_SELECT:
1203 if (bDrvOkay && UseDialogs() && !kNetGame && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOGEO) {
1204 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1205 AudBlankSound();
1206 MemCardEject();
1207 MemCardSelect();
1208 MemCardInsert();
1209 GameInpCheckMouse();
1210 }
1211 break;
1212 case MENU_MEMCARD_INSERT:
1213 if (!kNetGame && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOGEO) {
1214 MemCardInsert();
1215 }
1216 break;
1217 case MENU_MEMCARD_EJECT:
1218 if (!kNetGame && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOGEO) {
1219 MemCardEject();
1220 }
1221 break;
1222
1223 case MENU_MEMCARD_TOGGLE:
1224 if (bDrvOkay && !kNetGame && (BurnDrvGetHardwareCode() & HARDWARE_PUBLIC_MASK) == HARDWARE_SNK_NEOGEO) {
1225 MemCardToggle();
1226 }
1227 break;
1228
1229 case MENU_STATE_LOAD_DIALOG:
1230 if (UseDialogs() && !kNetGame) {
1231 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1232 AudSoundStop();
1233 SplashDestroy(1);
1234 StatedLoad(0);
1235 GameInpCheckMouse();
1236 AudSoundPlay();
1237 }
1238 break;
1239 case MENU_STATE_SAVE_DIALOG:
1240 if (UseDialogs()) {
1241 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1242 AudBlankSound();
1243 StatedSave(0);
1244 GameInpCheckMouse();
1245 }
1246 return;
1247 case MENU_STATE_PREVSLOT: {
1248 TCHAR szString[256];
1249
1250 nSavestateSlot--;
1251 if (nSavestateSlot < 1) {
1252 nSavestateSlot = 1;
1253 }
1254 _sntprintf(szString, 256, FBALoadStringEx(hAppInst, IDS_STATE_ACTIVESLOT, true), nSavestateSlot);
1255 VidSNewShortMsg(szString);
1256 PausedRedraw();
1257 break;
1258 }
1259 case MENU_STATE_NEXTSLOT: {
1260 TCHAR szString[256];
1261
1262 nSavestateSlot++;
1263 if (nSavestateSlot > 8) {
1264 nSavestateSlot = 8;
1265 }
1266 _sntprintf(szString, 256, FBALoadStringEx(hAppInst, IDS_STATE_ACTIVESLOT, true), nSavestateSlot);
1267 VidSNewShortMsg(szString);
1268 PausedRedraw();
1269 break;
1270 }
1271 case MENU_STATE_UNDO:
1272 scrnSSUndo();
1273 break;
1274 case MENU_STATE_LOAD_SLOT:
1275 if (bDrvOkay && !kNetGame) {
1276 if (StatedLoad(nSavestateSlot) == 0) {
1277 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_STATE_LOADED, true), 0, 40);
1278 } else {
1279 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_STATE_LOAD_ERROR, true), 0xFF3F3F);
1280 }
1281 PausedRedraw();
1282 }
1283 break;
1284 case MENU_STATE_SAVE_SLOT:
1285 if (bDrvOkay) {
1286 if (StatedSave(nSavestateSlot) == 0) {
1287 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_STATE_SAVED, true), 0, 40);
1288 } else {
1289 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_STATE_SAVE_ERROR, true), 0xFF3F3F);
1290 SetPauseMode(1);
1291 }
1292 PausedRedraw();
1293 }
1294 break;
1295
1296 case MENU_ALLRAM:
1297 bDrvSaveAll = !bDrvSaveAll;
1298 break;
1299
1300 case MENU_NOSTRETCH:
1301 bVidCorrectAspect = 0;
1302 bVidFullStretch = 0;
1303 POST_INITIALISE_MESSAGE;
1304 break;
1305
1306 case MENU_STRETCH:
1307 bVidFullStretch = true;
1308 if (bVidFullStretch) {
1309 bVidCorrectAspect = 0;
1310 }
1311 POST_INITIALISE_MESSAGE;
1312 break;
1313
1314 case MENU_ASPECT:
1315 bVidCorrectAspect = true;
1316 if (bVidCorrectAspect) {
1317 bVidFullStretch = 0;
1318 }
1319 POST_INITIALISE_MESSAGE;
1320 break;
1321
1322 case MENU_TRIPLE:
1323 bVidTripleBuffer = !bVidTripleBuffer;
1324 POST_INITIALISE_MESSAGE;
1325 break;
1326
1327 case MENU_DWMFIX:
1328 bVidDWMSync = !bVidDWMSync;
1329 if (bVidDWMSync && bVidVSync)
1330 bVidVSync = 0;
1331
1332 POST_INITIALISE_MESSAGE;
1333 break;
1334
1335 case MENU_BLITTER_1:
1336 VidSelect(0);
1337 POST_INITIALISE_MESSAGE;
1338 break;
1339 case MENU_BLITTER_2:
1340 VidSelect(1);
1341 POST_INITIALISE_MESSAGE;
1342 break;
1343 case MENU_BLITTER_3:
1344 VidSelect(2);
1345 POST_INITIALISE_MESSAGE;
1346 break;
1347 case MENU_BLITTER_4:
1348 VidSelect(3);
1349 POST_INITIALISE_MESSAGE;
1350 break;
1351 case MENU_BLITTER_5:
1352 VidSelect(4);
1353 POST_INITIALISE_MESSAGE;
1354 break;
1355 #if 0
1356 case MENU_BLITTER_6:
1357 VidSelect(5);
1358 POST_INITIALISE_MESSAGE;
1359 break;
1360 case MENU_BLITTER_7:
1361 VidSelect(6);
1362 POST_INITIALISE_MESSAGE;
1363 break;
1364 case MENU_BLITTER_8:
1365 VidSelect(7);
1366 POST_INITIALISE_MESSAGE;
1367 break;
1368 #endif
1369
1370 case MENU_RES_ARCADE:
1371 bVidArcaderesHor = !bVidArcaderesHor;
1372 nScreenSizeHor = 0;
1373 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1374 nScreenSize = nScreenSizeHor;
1375 bVidArcaderes = bVidArcaderesHor;
1376 }
1377 break;
1378
1379 case MENU_SINGLESIZESCREEN:
1380 nScreenSizeHor = 1;
1381 bVidArcaderesHor = false;
1382 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1383 nScreenSize = nScreenSizeHor;
1384 bVidArcaderes = bVidArcaderesHor;
1385 }
1386 break;
1387 case MENU_DOUBLESIZESCREEN:
1388 nScreenSizeHor = 2;
1389 bVidArcaderesHor = false;
1390 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1391 nScreenSize = nScreenSizeHor;
1392 bVidArcaderes = bVidArcaderesHor;
1393 }
1394 break;
1395 case MENU_TRIPLESIZESCREEN:
1396 nScreenSizeHor = 3;
1397 bVidArcaderesHor = false;
1398 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1399 nScreenSize = nScreenSizeHor;
1400 bVidArcaderes = bVidArcaderesHor;
1401 }
1402 break;
1403 case MENU_QUADSIZESCREEN:
1404 nScreenSizeHor = 4;
1405 bVidArcaderesHor = false;
1406 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1407 nScreenSize = nScreenSizeHor;
1408 bVidArcaderes = bVidArcaderesHor;
1409 }
1410 break;
1411
1412 case MENU_RES_1:
1413 nVidHorWidth = VidPreset[0].nWidth;
1414 nVidHorHeight = VidPreset[0].nHeight;
1415 bVidArcaderesHor = false;
1416 nScreenSizeHor = 0;
1417 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1418 nScreenSize = nScreenSizeHor;
1419 bVidArcaderes = bVidArcaderesHor;
1420 nVidWidth = nVidHorWidth;
1421 nVidHeight = nVidHorHeight;
1422 }
1423 break;
1424 case MENU_RES_2:
1425 nVidHorWidth = VidPreset[1].nWidth;
1426 nVidHorHeight = VidPreset[1].nHeight;
1427 bVidArcaderesHor = false;
1428 nScreenSizeHor = 0;
1429 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1430 nScreenSize = nScreenSizeHor;
1431 bVidArcaderes = bVidArcaderesHor;
1432 nVidWidth = nVidHorWidth;
1433 nVidHeight = nVidHorHeight;
1434 }
1435 break;
1436 case MENU_RES_3:
1437 nVidHorWidth = VidPreset[2].nWidth;
1438 nVidHorHeight = VidPreset[2].nHeight;
1439 bVidArcaderesHor = false;
1440 nScreenSizeHor = 0;
1441 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1442 nScreenSize = nScreenSizeHor;
1443 bVidArcaderes = bVidArcaderesHor;
1444 nVidWidth = nVidHorWidth;
1445 nVidHeight = nVidHorHeight;
1446 }
1447 break;
1448 case MENU_RES_4:
1449 nVidHorWidth = VidPreset[3].nWidth;
1450 nVidHorHeight = VidPreset[3].nHeight;
1451 bVidArcaderesHor = false;
1452 nScreenSizeHor = 0;
1453 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1454 nScreenSize = nScreenSizeHor;
1455 bVidArcaderes = bVidArcaderesHor;
1456 nVidWidth = nVidHorWidth;
1457 nVidHeight = nVidHorHeight;
1458 }
1459 break;
1460
1461
1462 case MENU_RES_OTHER:
1463 bVidArcaderesHor = false;
1464 nScreenSizeHor = 0;
1465 if ((bDrvOkay) && !(BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1466 nScreenSize = nScreenSizeHor;
1467 bVidArcaderes = bVidArcaderesHor;
1468 }
1469 AudBlankSound();
1470 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1471 ResCreate(HORIZONTAL_ORIENTED_RES);
1472 GameInpCheckMouse();
1473 break;
1474
1475 case MENU_FULLSCREEN_MONITOR:
1476 if (UseDialogs()) {
1477 AudBlankSound();
1478 ChooseMonitorCreate();
1479 GameInpCheckMouse();
1480 }
1481 break;
1482
1483 // Vertical
1484 case MENU_RES_ARCADE_VERTICAL:
1485 bVidArcaderesVer = !bVidArcaderesVer;
1486 nScreenSizeVer = 0;
1487 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1488 nScreenSize = nScreenSizeVer;
1489 bVidArcaderes = bVidArcaderesVer;
1490 }
1491 break;
1492
1493 case MENU_SINGLESIZESCREEN_VERTICAL:
1494 nScreenSizeVer = 1;
1495 bVidArcaderesVer = false;
1496 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1497 nScreenSize = nScreenSizeVer;
1498 bVidArcaderes = bVidArcaderesVer;
1499 }
1500 break;
1501 case MENU_DOUBLESIZESCREEN_VERTICAL:
1502 nScreenSizeVer = 2;
1503 bVidArcaderesVer = false;
1504 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1505 nScreenSize = nScreenSizeVer;
1506 bVidArcaderes = bVidArcaderesVer;
1507 }
1508 break;
1509 case MENU_TRIPLESIZESCREEN_VERTICAL:
1510 nScreenSizeVer = 3;
1511 bVidArcaderesVer = false;
1512 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1513 nScreenSize = nScreenSizeVer;
1514 bVidArcaderes = bVidArcaderesVer;
1515 }
1516 break;
1517 case MENU_QUADSIZESCREEN_VERTICAL:
1518 nScreenSizeVer = 4;
1519 bVidArcaderesVer = false;
1520 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1521 nScreenSize = nScreenSizeVer;
1522 bVidArcaderes = bVidArcaderesVer;
1523 }
1524 break;
1525
1526 case MENU_RES_1_VERTICAL:
1527 nVidVerWidth = VidPresetVer[0].nWidth;
1528 nVidVerHeight = VidPresetVer[0].nHeight;
1529 bVidArcaderesVer = false;
1530 nScreenSizeVer = 0;
1531 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1532 nScreenSize = nScreenSizeVer;
1533 bVidArcaderes = bVidArcaderesVer;
1534 nVidWidth = nVidVerWidth;
1535 nVidHeight = nVidVerHeight;
1536 }
1537 break;
1538 case MENU_RES_2_VERTICAL:
1539 nVidVerWidth = VidPresetVer[1].nWidth;
1540 nVidVerHeight = VidPresetVer[1].nHeight;
1541 bVidArcaderesVer = false;
1542 nScreenSizeVer = 0;
1543 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1544 nScreenSize = nScreenSizeVer;
1545 bVidArcaderes = bVidArcaderesVer;
1546 nVidWidth = nVidVerWidth;
1547 nVidHeight = nVidVerHeight;
1548 }
1549 break;
1550 case MENU_RES_3_VERTICAL:
1551 nVidVerWidth = VidPresetVer[2].nWidth;
1552 nVidVerHeight = VidPresetVer[2].nHeight;
1553 bVidArcaderesVer = false;
1554 nScreenSizeVer = 0;
1555 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1556 nScreenSize = nScreenSizeVer;
1557 bVidArcaderes = bVidArcaderesVer;
1558 nVidWidth = nVidVerWidth;
1559 nVidHeight = nVidVerHeight;
1560 }
1561 break;
1562 case MENU_RES_4_VERTICAL:
1563 nVidVerWidth = VidPresetVer[3].nWidth;
1564 nVidVerHeight = VidPresetVer[3].nHeight;
1565 bVidArcaderesVer = false;
1566 nScreenSizeVer = 0;
1567 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1568 nScreenSize = nScreenSizeVer;
1569 bVidArcaderes = bVidArcaderesVer;
1570 nVidWidth = nVidVerWidth;
1571 nVidHeight = nVidVerHeight;
1572 }
1573 break;
1574
1575 case MENU_RES_OTHER_VERTICAL:
1576 bVidArcaderesVer = false;
1577 nScreenSizeVer = 0;
1578 if ((bDrvOkay) && (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL)) {
1579 nScreenSize = nScreenSizeVer;
1580 bVidArcaderes = bVidArcaderesVer;
1581 }
1582 AudBlankSound();
1583 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1584 ResCreate(VERTICAL_ORIENTED_RES);
1585 GameInpCheckMouse();
1586 break;
1587
1588 case MENU_16:
1589 nVidDepth = 16;
1590 break;
1591
1592 case MENU_24:
1593 nVidDepth = 24;
1594 break;
1595
1596 case MENU_32:
1597 nVidDepth = 32;
1598 break;
1599
1600 case MENU_GAMMA_DO:
1601 bDoGamma = !bDoGamma;
1602 if (bDrvOkay) {
1603 if (nVidSelect == 1) {
1604 VidInit();
1605 }
1606 SetBurnHighCol(nVidImageDepth);
1607 if (bRunPause) {
1608 VidRedraw();
1609 }
1610 }
1611 break;
1612
1613 case MENU_GAMMA_DARKER:
1614 nGamma = 1.25;
1615 ComputeGammaLUT();
1616 bDoGamma = 1;
1617 if (bDrvOkay) {
1618 if (nVidSelect == 1) {
1619 VidInit();
1620 }
1621 SetBurnHighCol(nVidImageDepth);
1622 if (bRunPause) {
1623 VidRedraw();
1624 }
1625 }
1626 break;
1627
1628 case MENU_GAMMA_LIGHTER:
1629 nGamma = 0.80;
1630 ComputeGammaLUT();
1631 bDoGamma = 1;
1632 if (bDrvOkay) {
1633 if (nVidSelect == 1) {
1634 VidInit();
1635 }
1636 SetBurnHighCol(nVidImageDepth);
1637 if (bRunPause) {
1638 VidRedraw();
1639 }
1640 }
1641 break;
1642
1643 case MENU_GAMMA_OTHER: {
1644 if (UseDialogs()) {
1645 double nOldGamma = nGamma;
1646 bDoGamma = 1;
1647 if (bDrvOkay) {
1648 if (nVidSelect == 1) {
1649 VidInit();
1650 }
1651 SetBurnHighCol(nVidImageDepth);
1652 }
1653 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
1654 AudBlankSound();
1655 GammaDialog();
1656 if (nGamma > 0.999 && nGamma < 1.001) {
1657 nGamma = nOldGamma;
1658 bDoGamma = 0;
1659 if (nVidSelect == 1) {
1660 VidInit();
1661 }
1662 SetBurnHighCol(nVidImageDepth);
1663 } else {
1664 bDoGamma = 1;
1665 ComputeGammaLUT();
1666 }
1667 if (bDrvOkay) {
1668 VidRecalcPal();
1669 }
1670 GameInpCheckMouse();
1671 }
1672 break;
1673 }
1674
1675 case MENU_GAMMA_USE_HARDWARE:
1676 bVidUseHardwareGamma = 1;
1677 bHardwareGammaOnly = 0;
1678 if (bDrvOkay) {
1679 if (nVidSelect == 1) {
1680 VidInit();
1681 }
1682 SetBurnHighCol(nVidImageDepth);
1683 VidRecalcPal();
1684 if (bRunPause) {
1685 VidRedraw();
1686 }
1687 }
1688 break;
1689 case MENU_GAMMA_HARDWARE_ONLY:
1690 bVidUseHardwareGamma = 1;
1691 bHardwareGammaOnly = 1;
1692 if (bDrvOkay) {
1693 if (nVidSelect == 1) {
1694 VidInit();
1695 }
1696 SetBurnHighCol(nVidImageDepth);
1697 VidRecalcPal();
1698 if (bRunPause) {
1699 VidRedraw();
1700 }
1701 }
1702 break;
1703 case MENU_GAMMA_SOFTWARE_ONLY:
1704 bVidUseHardwareGamma = 0;
1705 bHardwareGammaOnly = 0;
1706 if (bDrvOkay) {
1707 if (nVidSelect == 1) {
1708 VidInit();
1709 }
1710 SetBurnHighCol(nVidImageDepth);
1711 VidRecalcPal();
1712 if (bRunPause) {
1713 VidRedraw();
1714 }
1715 }
1716 break;
1717
1718 case MENU_FULL:
1719 if (bDrvOkay || nVidFullscreen) {
1720 nVidFullscreen = !nVidFullscreen;
1721 POST_INITIALISE_MESSAGE;
1722 }
1723 return;
1724
1725 case MENU_AUTOSWITCHFULL:
1726 bVidAutoSwitchFull = !bVidAutoSwitchFull;
1727 break;
1728
1729 case MENU_BASIC_MEMAUTO:
1730 case MENU_SOFTFX_MEMAUTO:
1731 nVidTransferMethod = -1;
1732 POST_INITIALISE_MESSAGE;
1733 break;
1734
1735 case MENU_BASIC_VIDEOMEM:
1736 case MENU_SOFTFX_VIDEOMEM:
1737 nVidTransferMethod = 0;
1738 POST_INITIALISE_MESSAGE;
1739 break;
1740
1741 case MENU_BASIC_SYSMEM:
1742 case MENU_SOFTFX_SYSMEM:
1743 nVidTransferMethod = 1;
1744 POST_INITIALISE_MESSAGE;
1745 break;
1746
1747 case MENU_AUTOSIZE:
1748 if (nWindowSize != 0) {
1749 nWindowSize = 0;
1750 POST_INITIALISE_MESSAGE;
1751 }
1752 break;
1753 case MENU_SINGLESIZEWINDOW:
1754 if (nWindowSize != 1) {
1755 nWindowSize = 1;
1756 POST_INITIALISE_MESSAGE;
1757 }
1758 break;
1759 case MENU_DOUBLESIZEWINDOW:
1760 if (nWindowSize != 2) {
1761 nWindowSize = 2;
1762 POST_INITIALISE_MESSAGE;
1763 }
1764 break;
1765 case MENU_TRIPLESIZEWINDOW:
1766 if (nWindowSize != 3) {
1767 nWindowSize = 3;
1768 POST_INITIALISE_MESSAGE;
1769 }
1770 break;
1771 case MENU_QUADSIZEWINDOW:
1772 if (nWindowSize != 4) {
1773 nWindowSize = 4;
1774 POST_INITIALISE_MESSAGE;
1775 }
1776 break;
1777 case MENU_MAXIMUMSIZEWINDOW:
1778 if (nWindowSize <= 4) {
1779 nWindowSize = 9999;
1780 POST_INITIALISE_MESSAGE;
1781 }
1782 break;
1783
1784 case MENU_MONITORAUTOCHECK:
1785 bMonitorAutoCheck = !bMonitorAutoCheck;
1786 if (bMonitorAutoCheck) MonitorAutoCheck();
1787 POST_INITIALISE_MESSAGE;
1788 break;
1789
1790 case MENU_ASPECTNORMAL:
1791 bMonitorAutoCheck = false; nVidScrnAspectX = 4; nVidScrnAspectY = 3;
1792 POST_INITIALISE_MESSAGE;
1793 break;
1794 case MENU_ASPECTLCD:
1795 bMonitorAutoCheck = false; nVidScrnAspectX = 5; nVidScrnAspectY = 4;
1796 POST_INITIALISE_MESSAGE;
1797 break;
1798 case MENU_ASPECTWIDE:
1799 bMonitorAutoCheck = false; nVidScrnAspectX = 16; nVidScrnAspectY = 9;
1800 POST_INITIALISE_MESSAGE;
1801 break;
1802 case MENU_ASPECTWIDELCD:
1803 bMonitorAutoCheck = false; nVidScrnAspectX = 16; nVidScrnAspectY = 10;
1804 POST_INITIALISE_MESSAGE;
1805 break;
1806 case MENU_MONITORMIRRORVERT:
1807 nVidRotationAdjust ^= 2;
1808 POST_INITIALISE_MESSAGE;
1809 break;
1810
1811 case MENU_ROTATEVERTICAL:
1812 nVidRotationAdjust ^= 1;
1813 POST_INITIALISE_MESSAGE;
1814 break;
1815
1816 case MENU_FORCE60HZ:
1817 bForce60Hz = !bForce60Hz;
1818 break;
1819
1820 case MENU_VIDEOVSYNC:
1821 bVidVSync = !bVidVSync;
1822 if (bVidVSync && bVidDWMSync)
1823 bVidDWMSync = 0;
1824
1825 POST_INITIALISE_MESSAGE;
1826 break;
1827
1828 case MENU_AUTOFRAMESKIP:
1829 bAlwaysDrawFrames = !bAlwaysDrawFrames;
1830 POST_INITIALISE_MESSAGE;
1831 break;
1832
1833 case MENU_AUD_PLUGIN_1:
1834 AudSelect(0);
1835 POST_INITIALISE_MESSAGE;
1836 break;
1837
1838 case MENU_AUD_PLUGIN_2:
1839 AudSelect(1);
1840 POST_INITIALISE_MESSAGE;
1841 break;
1842
1843 case MENU_DSOUND_NOSOUND:
1844 if (!bDrvOkay) {
1845 nAudSampleRate[0] = 0;
1846 POST_INITIALISE_MESSAGE;
1847 }
1848 break;
1849 case MENU_DSOUND_11025:
1850 if (!bDrvOkay) {
1851 nAudSampleRate[0] = 11025;
1852 POST_INITIALISE_MESSAGE;
1853 }
1854 break;
1855 case MENU_DSOUND_22050:
1856 if (!bDrvOkay) {
1857 nAudSampleRate[0] = 22050;
1858 POST_INITIALISE_MESSAGE;
1859 }
1860 break;
1861 case MENU_DSOUND_44100:
1862 if (!bDrvOkay) {
1863 nAudSampleRate[0] = 44100;
1864 POST_INITIALISE_MESSAGE;
1865 }
1866 break;
1867 case MENU_DSOUND_48000:
1868 if (!bDrvOkay) {
1869 nAudSampleRate[0] = 48000;
1870 POST_INITIALISE_MESSAGE;
1871 }
1872 break;
1873
1874 case MENU_XAUDIO_NOSOUND:
1875 if (!bDrvOkay) {
1876 nAudSampleRate[1] = 0;
1877 POST_INITIALISE_MESSAGE;
1878 }
1879 break;
1880 case MENU_XAUDIO_11025:
1881 if (!bDrvOkay) {
1882 nAudSampleRate[1] = 11025;
1883 POST_INITIALISE_MESSAGE;
1884 }
1885 break;
1886 case MENU_XAUDIO_22050:
1887 if (!bDrvOkay) {
1888 nAudSampleRate[1] = 22050;
1889 POST_INITIALISE_MESSAGE;
1890 }
1891 break;
1892 case MENU_XAUDIO_44100:
1893 if (!bDrvOkay) {
1894 nAudSampleRate[1] = 44100;
1895 POST_INITIALISE_MESSAGE;
1896 }
1897 break;
1898 case MENU_XAUDIO_48000:
1899 if (!bDrvOkay) {
1900 nAudSampleRate[1] = 48000;
1901 POST_INITIALISE_MESSAGE;
1902 }
1903 break;
1904
1905 case MENU_FRAMES:
1906 if (UseDialogs()) {
1907 if (!bDrvOkay) {
1908 // AudBlankSound();
1909 NumDialCreate(0);
1910 POST_INITIALISE_MESSAGE;
1911 }
1912 }
1913 break;
1914
1915 case MENU_INTERPOLATE_0:
1916 nInterpolation = 0;
1917 break;
1918 case MENU_INTERPOLATE_1:
1919 nInterpolation = 1;
1920 break;
1921 case MENU_INTERPOLATE_3:
1922 nInterpolation = 3;
1923 break;
1924
1925 case MENU_INTERPOLATE_FM_0:
1926 nFMInterpolation = 0;
1927 break;
1928 case MENU_INTERPOLATE_FM_1:
1929 nFMInterpolation = 1;
1930 break;
1931 case MENU_INTERPOLATE_FM_3:
1932 nFMInterpolation = 3;
1933 break;
1934
1935 case MENU_DSOUND_BASS:
1936 nAudDSPModule[0] = !nAudDSPModule[0];
1937 break;
1938
1939 case MENU_XAUDIO_BASS:
1940 nAudDSPModule[1] ^= 1;
1941 break;
1942
1943 case MENU_XAUDIO_REVERB:
1944 nAudDSPModule[1] ^= 2;
1945 break;
1946
1947 case MENU_WLOGSTART:
1948 AudBlankSound();
1949 WaveLogStart();
1950 break;
1951
1952 case MENU_WLOGEND:
1953 AudBlankSound();
1954 WaveLogStop();
1955 break;
1956
1957 case MENU_AUTOPAUSE:
1958 bAutoPause = !bAutoPause;
1959 break;
1960
1961 case MENU_PROCESSINPUT:
1962 bAlwaysProcessKeyboardInput = !bAlwaysProcessKeyboardInput;
1963 break;
1964
1965 case MENU_DISPLAYINDICATOR:
1966 nVidSDisplayStatus = !nVidSDisplayStatus;
1967 // VidRedraw();
1968 VidPaint(2);
1969 break;
1970
1971 case MENU_MODELESS:
1972 bModelessMenu = !bModelessMenu;
1973 POST_INITIALISE_MESSAGE;
1974 break;
1975
1976 case MENU_NOCHANGENUMLOCK:
1977 bNoChangeNumLock = !bNoChangeNumLock;
1978 break;
1979
1980 case MENU_HIGHRESTIMER:
1981 bEnableHighResTimer = !bEnableHighResTimer;
1982 DisableHighResolutionTiming(); // disable if active
1983 EnableHighResolutionTiming(); // use new setting.
1984 break;
1985
1986 case MENU_CREATEDIRS:
1987 bAlwaysCreateSupportFolders = !bAlwaysCreateSupportFolders;
1988 break;
1989
1990 case MENU_AUTOLOADGAMELIST:
1991 bAutoLoadGameList = !bAutoLoadGameList;
1992 break;
1993
1994 case MENU_SAVEHISCORES:
1995 EnableHiscores = !EnableHiscores;
1996 break;
1997
1998 case MENU_USEBLEND:
1999 bBurnUseBlend = !bBurnUseBlend;
2000 break;
2001
2002 case MENU_GEARSHIFT:
2003 BurnShiftEnabled = !BurnShiftEnabled;
2004 break;
2005
2006 #ifdef INCLUDE_AVI_RECORDING
2007 case MENU_AVI1X:
2008 nAvi3x = 1;
2009 break;
2010
2011 case MENU_AVI2X:
2012 nAvi3x = 2;
2013 break;
2014
2015 case MENU_AVI3X:
2016 nAvi3x = 3;
2017 break;
2018 #endif
2019
2020 case MENU_ROMDIRS:
2021 RomsDirCreate(hScrnWnd);
2022 break;
2023
2024 case MENU_SUPPORTDIRS:
2025 SupportDirCreate(hScrnWnd);
2026 break;
2027
2028 case MENU_SELECTPLACEHOLDER:
2029 if (UseDialogs()) {
2030 SelectPlaceHolder();
2031 POST_INITIALISE_MESSAGE;
2032 }
2033 break;
2034
2035 case MENU_DISABLEPLACEHOLDER:
2036 ResetPlaceHolder();
2037 POST_INITIALISE_MESSAGE;
2038 break;
2039
2040 case MENU_LANGUAGE_SELECT:
2041 if (UseDialogs()) {
2042 FBALocaliseLoadTemplate();
2043 POST_INITIALISE_MESSAGE;
2044 }
2045 break;
2046 case MENU_LANGUAGE_EXPORT:
2047 if (UseDialogs()) {
2048 FBALocaliseCreateTemplate();
2049 }
2050 break;
2051 case MENU_LANGUAGE_RESET:
2052 szLocalisationTemplate[0] = _T('\0');
2053 FBALocaliseInit(szLocalisationTemplate);
2054 POST_INITIALISE_MESSAGE;
2055 break;
2056 case MENU_LANGUAGE_DOWNLOAD:
2057 if (UseDialogs()) {
2058 LocaliseDownloadCreate(hScrnWnd);
2059 }
2060 break;
2061
2062 case MENU_LANGUAGE_GL_SELECT:
2063 if (UseDialogs()) {
2064 FBALocaliseGamelistLoadTemplate();
2065 }
2066 break;
2067 case MENU_LANGUAGE_GL_EXPORT:
2068 if (UseDialogs()) {
2069 FBALocaliseGamelistCreateTemplate();
2070 }
2071 break;
2072 case MENU_LANGUAGE_GL_RESET:
2073 szGamelistLocalisationTemplate[0] = _T('\0');
2074 nGamelistLocalisationActive = false;
2075 break;
2076
2077 case MENU_ENABLEICONS: {
2078 bEnableIcons = !bEnableIcons;
2079 if(!bEnableIcons && bIconsLoaded) {
2080 // unload icons
2081 UnloadDrvIcons();
2082 bIconsLoaded = 0;
2083 }
2084 if(bEnableIcons && !bIconsLoaded) {
2085 // load icons
2086 LoadDrvIcons();
2087 bIconsLoaded = 1;
2088 }
2089 break;
2090 }
2091
2092 case MENU_ICONS_PARENTSONLY: {
2093 bIconsOnlyParents = !bIconsOnlyParents;
2094 if(bEnableIcons && bIconsLoaded) {
2095 // unload icons
2096 UnloadDrvIcons();
2097 bIconsLoaded = 0;
2098 // load icons
2099 LoadDrvIcons();
2100 bIconsLoaded = 1;
2101 }
2102 break;
2103 }
2104
2105 case MENU_ICONS_SIZE_16: {
2106 nIconsSize = ICON_16x16;
2107 if(bEnableIcons && bIconsLoaded) {
2108 // unload icons
2109 UnloadDrvIcons();
2110 bIconsLoaded = 0;
2111 // load icons
2112 LoadDrvIcons();
2113 bIconsLoaded = 1;
2114 }
2115 if(bEnableIcons && !bIconsLoaded) {
2116 // load icons
2117 LoadDrvIcons();
2118 bIconsLoaded = 1;
2119 }
2120 break;
2121 }
2122
2123 case MENU_ICONS_SIZE_24: {
2124 nIconsSize = ICON_24x24;
2125 if(bEnableIcons && bIconsLoaded) {
2126 // unload icons
2127 UnloadDrvIcons();
2128 bIconsLoaded = 0;
2129 // load icons
2130 LoadDrvIcons();
2131 bIconsLoaded = 1;
2132 }
2133 if(bEnableIcons && !bIconsLoaded) {
2134 // load icons
2135 LoadDrvIcons();
2136 bIconsLoaded = 1;
2137 }
2138 break;
2139 }
2140
2141 case MENU_ICONS_SIZE_32: {
2142 nIconsSize = ICON_32x32;
2143 if(bEnableIcons && bIconsLoaded) {
2144 // unload icons
2145 UnloadDrvIcons();
2146 bIconsLoaded = 0;
2147 // load icons
2148 LoadDrvIcons();
2149 bIconsLoaded = 1;
2150 }
2151 if(bEnableIcons && !bIconsLoaded) {
2152 // load icons
2153 LoadDrvIcons();
2154 bIconsLoaded = 1;
2155 }
2156 break;
2157 }
2158
2159 case MENU_INPUT_AUTOFIRE_RATE_1: nAutoFireRate = 22; break;
2160 case MENU_INPUT_AUTOFIRE_RATE_2: nAutoFireRate = 12; break;
2161 case MENU_INPUT_AUTOFIRE_RATE_3: nAutoFireRate = 8; break;
2162 case MENU_INPUT_AUTOFIRE_RATE_4: nAutoFireRate = 4; break;
2163
2164 case MENU_PRIORITY_REALTIME:
2165 nAppThreadPriority = THREAD_PRIORITY_TIME_CRITICAL;
2166 SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
2167 break;
2168 case MENU_PRIORITY_HIGH:
2169 nAppThreadPriority = THREAD_PRIORITY_HIGHEST;
2170 SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
2171 break;
2172 case MENU_PRIORITY_ABOVE_NORMAL:
2173 nAppThreadPriority = THREAD_PRIORITY_ABOVE_NORMAL;
2174 SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
2175 break;
2176 case MENU_PRIORITY_NORMAL:
2177 nAppThreadPriority = THREAD_PRIORITY_NORMAL;
2178 SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
2179 break;
2180 case MENU_PRIORITY_BELOW_NORMAL:
2181 nAppThreadPriority = THREAD_PRIORITY_BELOW_NORMAL;
2182 SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
2183 break;
2184 case MENU_PRIORITY_LOW:
2185 nAppThreadPriority = THREAD_PRIORITY_LOWEST;
2186 SetThreadPriority(GetCurrentThread(), nAppThreadPriority);
2187 break;
2188
2189 case MENU_CLRMAME_PRO_XML:
2190 if (UseDialogs()) {
2191 CreateDatfileWindows(DAT_ARCADE_ONLY);
2192 }
2193 break;
2194
2195 case MENU_CLRMAME_PRO_XML_MD_ONLY:
2196 if (UseDialogs()) {
2197 CreateDatfileWindows(DAT_MEGADRIVE_ONLY);
2198 }
2199 break;
2200
2201 case MENU_CLRMAME_PRO_XML_PCE_ONLY:
2202 if (UseDialogs()) {
2203 CreateDatfileWindows(DAT_PCENGINE_ONLY);
2204 }
2205 break;
2206
2207 case MENU_CLRMAME_PRO_XML_TG16_ONLY:
2208 if (UseDialogs()) {
2209 CreateDatfileWindows(DAT_TG16_ONLY);
2210 }
2211 break;
2212
2213 case MENU_CLRMAME_PRO_XML_SGX_ONLY:
2214 if (UseDialogs()) {
2215 CreateDatfileWindows(DAT_SGX_ONLY);
2216 }
2217 break;
2218
2219 case MENU_CLRMAME_PRO_XML_SG1000_ONLY:
2220 if (UseDialogs()) {
2221 CreateDatfileWindows(DAT_SG1000_ONLY);
2222 }
2223 break;
2224
2225 case MENU_CLRMAME_PRO_XML_COLECO_ONLY:
2226 if (UseDialogs()) {
2227 CreateDatfileWindows(DAT_COLECO_ONLY);
2228 }
2229 break;
2230
2231 case MENU_CLRMAME_PRO_XML_SMS_ONLY:
2232 if (UseDialogs()) {
2233 CreateDatfileWindows(DAT_MASTERSYSTEM_ONLY);
2234 }
2235 break;
2236
2237 case MENU_CLRMAME_PRO_XML_GG_ONLY:
2238 if (UseDialogs()) {
2239 CreateDatfileWindows(DAT_GAMEGEAR_ONLY);
2240 }
2241 break;
2242
2243 case MENU_CLRMAME_PRO_XML_MSX_ONLY:
2244 if (UseDialogs()) {
2245 CreateDatfileWindows(DAT_MSX_ONLY);
2246 }
2247 break;
2248
2249 case MENU_CLRMAME_PRO_XML_SPECTRUM_ONLY:
2250 if (UseDialogs()) {
2251 CreateDatfileWindows(DAT_SPECTRUM_ONLY);
2252 }
2253 break;
2254
2255 case MENU_CLRMAME_PRO_ALL_DATS:
2256 if (UseDialogs()) {
2257 CreateAllDatfilesWindows();
2258 }
2259 break;
2260
2261 case MENU_ENABLECHEAT:
2262 AudBlankSound();
2263 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2264 InpCheatCreate();
2265 break;
2266
2267 case MENU_DEBUG:
2268 if (UseDialogs()) {
2269 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2270 DebugCreate();
2271 }
2272 break;
2273
2274 case MENU_PALETTEVIEWER: {
2275 AudBlankSound();
2276 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2277 PaletteViewerDialogCreate(hScrnWnd);
2278 break;
2279 }
2280
2281 #ifdef BUILD_A68K
2282 case MENU_ASSEMBLYCORE:
2283 bBurnUseASMCPUEmulation = !bBurnUseASMCPUEmulation;
2284 break;
2285 #endif
2286
2287 case MENU_SAVESNAP: {
2288 if (bDrvOkay) {
2289 int status = MakeScreenShot();
2290
2291 if (!status) {
2292 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_SSHOT_SAVED, true));
2293 } else {
2294 TCHAR tmpmsg[256];
2295
2296 _sntprintf(tmpmsg, 256, FBALoadStringEx(hAppInst, IDS_SSHOT_ERROR, true), status);
2297 VidSNewShortMsg(tmpmsg, 0xFF3F3F);
2298 }
2299 }
2300 break;
2301 }
2302
2303 case MENU_SNAPFACT:
2304 if (UseDialogs()) {
2305 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2306 SFactdCreate();
2307 }
2308 break;
2309
2310 case MENU_CHEATSEARCH_START: {
2311 CheatSearchStart();
2312
2313 TCHAR szText[100];
2314 _stprintf(szText, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_NEW, true));
2315 VidSAddChatMsg(NULL, 0xFFFFFF, szText, 0xFFBFBF);
2316
2317 EnableMenuItem(hMenu, MENU_CHEATSEARCH_NOCHANGE, MF_ENABLED | MF_BYCOMMAND);
2318 EnableMenuItem(hMenu, MENU_CHEATSEARCH_CHANGE, MF_ENABLED | MF_BYCOMMAND);
2319 EnableMenuItem(hMenu, MENU_CHEATSEARCH_DECREASE, MF_ENABLED | MF_BYCOMMAND);
2320 EnableMenuItem(hMenu, MENU_CHEATSEARCH_INCREASE, MF_ENABLED | MF_BYCOMMAND);
2321 EnableMenuItem(hMenu, MENU_CHEATSEARCH_DUMPFILE, MF_ENABLED | MF_BYCOMMAND);
2322 EnableMenuItem(hMenu, MENU_CHEATSEARCH_EXIT, MF_ENABLED | MF_BYCOMMAND);
2323 break;
2324 }
2325
2326 case MENU_CHEATSEARCH_NOCHANGE: {
2327 TCHAR tmpmsg[256];
2328 unsigned int nValues = CheatSearchValueNoChange();
2329
2330 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_ADD_MATCH, true), nValues);
2331 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2332
2333 if (nValues <= CHEATSEARCH_SHOWRESULTS) {
2334 for (unsigned int i = 0; i < nValues; i++) {
2335 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_RESULTS, true), CheatSearchShowResultAddresses[i], CheatSearchShowResultValues[i]);
2336 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2337 }
2338 }
2339 break;
2340 }
2341
2342 case MENU_CHEATSEARCH_CHANGE: {
2343 TCHAR tmpmsg[256];
2344 unsigned int nValues = CheatSearchValueChange();
2345
2346 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_ADD_MATCH, true), nValues);
2347 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2348
2349 if (nValues <= CHEATSEARCH_SHOWRESULTS) {
2350 for (unsigned int i = 0; i < nValues; i++) {
2351 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_RESULTS, true), CheatSearchShowResultAddresses[i], CheatSearchShowResultValues[i]);
2352 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2353 }
2354 }
2355 break;
2356 }
2357
2358 case MENU_CHEATSEARCH_DECREASE: {
2359 TCHAR tmpmsg[256];
2360 unsigned int nValues = CheatSearchValueDecreased();
2361
2362 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_ADD_MATCH, true), nValues);
2363 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2364
2365 if (nValues <= CHEATSEARCH_SHOWRESULTS) {
2366 for (unsigned int i = 0; i < nValues; i++) {
2367 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_RESULTS, true), CheatSearchShowResultAddresses[i], CheatSearchShowResultValues[i]);
2368 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2369 }
2370 }
2371 break;
2372 }
2373
2374 case MENU_CHEATSEARCH_INCREASE: {
2375 TCHAR tmpmsg[256];
2376
2377 unsigned int nValues = CheatSearchValueIncreased();
2378
2379 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_ADD_MATCH, true), nValues);
2380 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2381
2382 if (nValues <= CHEATSEARCH_SHOWRESULTS) {
2383 for (unsigned int i = 0; i < nValues; i++) {
2384 _stprintf(tmpmsg, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_RESULTS, true), CheatSearchShowResultAddresses[i], CheatSearchShowResultValues[i]);
2385 VidSAddChatMsg(NULL, 0xFFFFFF, tmpmsg, 0xFFBFBF);
2386 }
2387 }
2388 break;
2389 }
2390
2391 case MENU_CHEATSEARCH_DUMPFILE: {
2392 CheatSearchDumptoFile();
2393 break;
2394 }
2395
2396 case MENU_CHEATSEARCH_EXIT: {
2397 CheatSearchExit();
2398
2399 TCHAR szText[100];
2400 _stprintf(szText, FBALoadStringEx(hAppInst, IDS_CHEAT_SEARCH_EXIT, true));
2401 VidSAddChatMsg(NULL, 0xFFFFFF, szText, 0xFFBFBF);
2402
2403 EnableMenuItem(hMenu, MENU_CHEATSEARCH_NOCHANGE, MF_GRAYED | MF_BYCOMMAND);
2404 EnableMenuItem(hMenu, MENU_CHEATSEARCH_CHANGE, MF_GRAYED | MF_BYCOMMAND);
2405 EnableMenuItem(hMenu, MENU_CHEATSEARCH_DECREASE, MF_GRAYED | MF_BYCOMMAND);
2406 EnableMenuItem(hMenu, MENU_CHEATSEARCH_INCREASE, MF_GRAYED | MF_BYCOMMAND);
2407 EnableMenuItem(hMenu, MENU_CHEATSEARCH_DUMPFILE, MF_GRAYED | MF_BYCOMMAND);
2408 EnableMenuItem(hMenu, MENU_CHEATSEARCH_EXIT, MF_GRAYED | MF_BYCOMMAND);
2409 break;
2410 }
2411
2412 case MENU_ASSOCIATE:
2413 RegisterExtensions(true);
2414 break;
2415 case MENU_DISASSOCIATE:
2416 RegisterExtensions(false);
2417 break;
2418
2419 case MENU_SAVEGAMEINPUTNOW:
2420 ConfigGameSave(true);
2421 break;
2422
2423 case MENU_SAVEGAMEINPUT:
2424 bSaveInputs = !bSaveInputs;
2425 break;
2426
2427 case MENU_SAVESET:
2428 ConfigAppSave();
2429 break;
2430
2431 case MENU_LOADSET:
2432 ConfigAppLoad();
2433 POST_INITIALISE_MESSAGE;
2434 break;
2435
2436 case MENU_ABOUT:
2437 if (UseDialogs()) {
2438 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2439 AudBlankSound();
2440 AboutCreate();
2441 GameInpCheckMouse();
2442 }
2443 break;
2444 case MENU_SYSINFO:
2445 if (UseDialogs()) {
2446 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2447 AudBlankSound();
2448 SystemInfoCreate();
2449 GameInpCheckMouse();
2450 }
2451 break;
2452
2453 case MENU_CONTENTS: {
2454 if (!nVidFullscreen) {
2455 FILE* fp = _tfopen(_T("fba.chm"), _T("r"));
2456 if (fp) {
2457 fclose(fp);
2458 ShellExecute(NULL, _T("open"), _T("fba.chm"), NULL, NULL, SW_SHOWNORMAL);
2459 }
2460 }
2461 break;
2462 }
2463
2464 case MENU_WHATSNEW: {
2465 if (!nVidFullscreen) {
2466 FILE* fp = _tfopen(_T("whatsnew.html"), _T("r"));
2467 if (fp) {
2468 fclose(fp);
2469 ShellExecute(NULL, _T("open"), _T("whatsnew.html"), NULL, NULL, SW_SHOWNORMAL);
2470 }
2471 }
2472 break;
2473 }
2474
2475 case MENU_WWW_HOME:
2476 if (!nVidFullscreen) {
2477 ShellExecute(NULL, _T("open"), _T("https://www.fbalpha.com/"), NULL, NULL, SW_SHOWNORMAL);
2478 }
2479 break;
2480
2481 case MENU_WWW_NSFORUM:
2482 if (!nVidFullscreen) {
2483 ShellExecute(NULL, _T("open"), _T("http://neo-source.com/"), NULL, NULL, SW_SHOWNORMAL);
2484 }
2485 break;
2486
2487 // default:
2488 // printf(" * Command %i sent.\n");
2489
2490 }
2491
2492 switch (nVidSelect) {
2493 case 0: {
2494 switch (id) {
2495 // Options for the Default DirectDraw blitter
2496 case MENU_BASIC_NORMAL:
2497 bVidScanlines = 0;
2498 POST_INITIALISE_MESSAGE;
2499 break;
2500 case MENU_BASIC_SCAN:
2501 bVidScanlines = 1;
2502 bVidScanHalf = 0;
2503 POST_INITIALISE_MESSAGE;
2504 break;
2505 case MENU_SCAN50:
2506 bVidScanlines = 1;
2507 bVidScanHalf = 1;
2508 POST_INITIALISE_MESSAGE;
2509 break;
2510
2511 case MENU_BASIC_ROTSCAN:
2512 bVidScanRotate = !bVidScanRotate;
2513 POST_INITIALISE_MESSAGE;
2514 break;
2515
2516 case MENU_FORCE_FLIP:
2517 bVidForceFlip = !bVidForceFlip;
2518 POST_INITIALISE_MESSAGE;
2519 break;
2520 }
2521 break;
2522 }
2523 case 1: {
2524 switch (id) {
2525 // Options for the Direct3D blitter
2526 case MENU_DISABLEFX:
2527 bVidBilinear = 0;
2528 bVidScanlines = 0;
2529 nVidBlitterOpt[nVidSelect] &= 0xF40200FF;
2530 POST_INITIALISE_MESSAGE;
2531 break;
2532
2533 case MENU_BILINEAR:
2534 bVidBilinear = !bVidBilinear;
2535 if (bVidOkay && (bRunPause || !bDrvOkay)) {
2536 VidRedraw();
2537 }
2538 break;
2539
2540 case MENU_PHOSPHOR:
2541 bVidScanDelay = !bVidScanDelay;
2542 break;
2543
2544 case MENU_ENHANCED_NORMAL:
2545 nVidBlitterOpt[nVidSelect] &= ~0x00110000;
2546 POST_INITIALISE_MESSAGE;
2547 break;
2548 case MENU_ENHANCED_SCAN:
2549 bVidScanlines = !bVidScanlines;
2550 nVidBlitterOpt[nVidSelect] &= ~0x00010000;
2551 POST_INITIALISE_MESSAGE;
2552 break;
2553 case MENU_RGBEFFECTS:
2554 nVidBlitterOpt[nVidSelect] &= ~0x00100000;
2555 nVidBlitterOpt[nVidSelect] |= 0x00010000;
2556 bVidScanlines = 0;
2557 ScrnSize();
2558 VidInit();
2559 if (bVidScanlines) {
2560 ScrnSize();
2561 VidInit();
2562 }
2563 if (bVidOkay && (bRunPause || !bDrvOkay)) {
2564 VidRedraw();
2565 }
2566 break;
2567 case MENU_3DPROJECTION:
2568 nVidBlitterOpt[nVidSelect] &= ~0x00010000;
2569 nVidBlitterOpt[nVidSelect] |= 0x00100000;
2570 POST_INITIALISE_MESSAGE;
2571 break;
2572
2573 case MENU_EFFECT_AUTO:
2574 nVidBlitterOpt[nVidSelect] &= ~0x001000000;
2575 nVidBlitterOpt[nVidSelect] |= 0x00030000;
2576 POST_INITIALISE_MESSAGE;
2577 if (bVidOkay && (bRunPause || !bDrvOkay)) {
2578 VidRedraw();
2579 }
2580 break;
2581 case MENU_EFFECT_01:
2582 case MENU_EFFECT_02:
2583 case MENU_EFFECT_03:
2584 case MENU_EFFECT_04:
2585 case MENU_EFFECT_05:
2586 case MENU_EFFECT_06:
2587 case MENU_EFFECT_07:
2588 case MENU_EFFECT_08:
2589 case MENU_EFFECT_09:
2590 case MENU_EFFECT_0A:
2591 case MENU_EFFECT_0B:
2592 case MENU_EFFECT_0C:
2593 case MENU_EFFECT_0D:
2594 case MENU_EFFECT_0E:
2595 case MENU_EFFECT_0F:
2596 case MENU_EFFECT_10:
2597 nVidBlitterOpt[nVidSelect] &= ~0x001300FF;
2598 nVidBlitterOpt[nVidSelect] |= 0x00010008 + id - MENU_EFFECT_01;
2599 POST_INITIALISE_MESSAGE;
2600 if (bVidOkay && (bRunPause || !bDrvOkay)) {
2601 VidRedraw();
2602 }
2603 break;
2604
2605 case MENU_ENHANCED_ROTSCAN:
2606 bVidScanRotate = !bVidScanRotate;
2607 POST_INITIALISE_MESSAGE;
2608 break;
2609
2610 case MENU_PRESCALE:
2611 nVidBlitterOpt[nVidSelect] ^= 0x01000000;
2612 POST_INITIALISE_MESSAGE;
2613 break;
2614 case MENU_SOFTFX:
2615 nVidBlitterOpt[nVidSelect] ^= 0x02000000;
2616 nVidBlitterOpt[nVidSelect] |= 0x01000000;
2617 POST_INITIALISE_MESSAGE;
2618 break;
2619
2620 case MENU_ENHANCED_SOFT_STRETCH:
2621 case MENU_ENHANCED_SOFT_SCALE2X:
2622 case MENU_ENHANCED_SOFT_SCALE3X:
2623 case MENU_ENHANCED_SOFT_2XPM_LQ:
2624 case MENU_ENHANCED_SOFT_2XPM_HQ:
2625 case MENU_ENHANCED_SOFT_EAGLE:
2626 case MENU_ENHANCED_SOFT_SUPEREAGLE:
2627 case MENU_ENHANCED_SOFT_2XSAI:
2628 case MENU_ENHANCED_SOFT_SUPER2XSAI:
2629 case MENU_ENHANCED_SOFT_SUPEREAGLE_VBA:
2630 case MENU_ENHANCED_SOFT_2XSAI_VBA:
2631 case MENU_ENHANCED_SOFT_SUPER2XSAI_VBA:
2632 case MENU_ENHANCED_SOFT_SUPERSCALE:
2633 case MENU_ENHANCED_SOFT_SUPERSCALE75:
2634 case MENU_ENHANCED_SOFT_HQ2X:
2635 case MENU_ENHANCED_SOFT_HQ3X:
2636 case MENU_ENHANCED_SOFT_HQ4X:
2637 case MENU_ENHANCED_SOFT_HQ2XS_VBA:
2638 case MENU_ENHANCED_SOFT_HQ3XS_VBA:
2639 case MENU_ENHANCED_SOFT_HQ2XS_SNES9X:
2640 case MENU_ENHANCED_SOFT_HQ3XS_SNES9X:
2641 case MENU_ENHANCED_SOFT_HQ2XBOLD:
2642 case MENU_ENHANCED_SOFT_HQ3XBOLD:
2643 case MENU_ENHANCED_SOFT_EPXB:
2644 case MENU_ENHANCED_SOFT_EPXC:
2645 case MENU_ENHANCED_SOFT_2XBR_A:
2646 case MENU_ENHANCED_SOFT_2XBR_B:
2647 case MENU_ENHANCED_SOFT_2XBR_C:
2648 case MENU_ENHANCED_SOFT_3XBR_A:
2649 case MENU_ENHANCED_SOFT_3XBR_B:
2650 case MENU_ENHANCED_SOFT_3XBR_C:
2651 case MENU_ENHANCED_SOFT_4XBR_A:
2652 case MENU_ENHANCED_SOFT_4XBR_B:
2653 case MENU_ENHANCED_SOFT_4XBR_C:
2654 case MENU_ENHANCED_SOFT_DDT3X: {
2655 nVidBlitterOpt[nVidSelect] &= 0x0FFFFFFF;
2656 nVidBlitterOpt[nVidSelect] |= 0x03000000 + ((long long)(id - MENU_ENHANCED_SOFT_STRETCH) << 32);
2657 POST_INITIALISE_MESSAGE;
2658 break;
2659 }
2660 case MENU_ENHANCED_SOFT_AUTOSIZE:
2661 nVidBlitterOpt[nVidSelect] ^= 0x04000000;
2662 POST_INITIALISE_MESSAGE;
2663 break;
2664
2665 case MENU_ENHANCED_SCANINTENSITY:
2666 if (UseDialogs()) {
2667 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2668 AudBlankSound();
2669 if (!bVidScanlines) {
2670 bVidScanlines = 1;
2671 ScrnSize();
2672 VidInit();
2673 VidRedraw();
2674 }
2675 if (nVidBlitterOpt[nVidSelect] & 0x00010000) {
2676 nVidBlitterOpt[nVidSelect] &= ~0x00010000;
2677 ScrnSize();
2678 VidInit();
2679 VidRedraw();
2680 }
2681 ScanlineDialog();
2682 GameInpCheckMouse();
2683 }
2684 break;
2685
2686 case MENU_PHOSPHORINTENSITY:
2687 if (UseDialogs()) {
2688 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2689 AudBlankSound();
2690 PhosphorDialog();
2691 bVidScanDelay = 1;
2692 }
2693 break;
2694
2695 case MENU_3DSCREENANGLE:
2696 if (UseDialogs()) {
2697 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2698 AudBlankSound();
2699 if ((nVidBlitterOpt[nVidSelect] & 0x00100000) == 0) {
2700 nVidBlitterOpt[nVidSelect] &= ~0x00010000;
2701 nVidBlitterOpt[nVidSelect] |= 0x00100000;
2702 ScrnSize();
2703 VidInit();
2704 VidRedraw();
2705 }
2706 ScreenAngleDialog();
2707 if (!bRunPause) {
2708 GameInpCheckMouse();
2709 }
2710 }
2711 break;
2712
2713 case MENU_FORCE_16BIT:
2714 bVidForce16bit = !bVidForce16bit;
2715 VidInit();
2716 if (bVidOkay && (bRunPause || !bDrvOkay)) {
2717 VidRedraw();
2718 }
2719 break;
2720 case MENU_TEXTUREMANAGE:
2721 if (nVidTransferMethod != 0) {
2722 nVidTransferMethod = 0;
2723 } else {
2724 nVidTransferMethod = 1;
2725 }
2726 VidInit();
2727 if (bVidOkay && (bRunPause || !bDrvOkay)) {
2728 VidRedraw();
2729 }
2730 break;
2731 }
2732 break;
2733 }
2734 case 2: {
2735 switch (id) {
2736 // Options for the DirectDraw Software Effects blitter
2737 case MENU_SOFTFX_SOFT_STRETCH:
2738 case MENU_SOFTFX_SOFT_SCALE2X:
2739 case MENU_SOFTFX_SOFT_SCALE3X:
2740 case MENU_SOFTFX_SOFT_2XPM_LQ:
2741 case MENU_SOFTFX_SOFT_2XPM_HQ:
2742 case MENU_SOFTFX_SOFT_EAGLE:
2743 case MENU_SOFTFX_SOFT_SUPEREAGLE:
2744 case MENU_SOFTFX_SOFT_2XSAI:
2745 case MENU_SOFTFX_SOFT_SUPER2XSAI:
2746 case MENU_SOFTFX_SOFT_SUPEREAGLE_VBA:
2747 case MENU_SOFTFX_SOFT_2XSAI_VBA:
2748 case MENU_SOFTFX_SOFT_SUPER2XSAI_VBA:
2749 case MENU_SOFTFX_SOFT_SUPERSCALE:
2750 case MENU_SOFTFX_SOFT_SUPERSCALE75:
2751 case MENU_SOFTFX_SOFT_HQ2X:
2752 case MENU_SOFTFX_SOFT_HQ3X:
2753 case MENU_SOFTFX_SOFT_HQ4X:
2754 case MENU_SOFTFX_SOFT_HQ2XS_VBA:
2755 case MENU_SOFTFX_SOFT_HQ3XS_VBA:
2756 case MENU_SOFTFX_SOFT_HQ2XS_SNES9X:
2757 case MENU_SOFTFX_SOFT_HQ3XS_SNES9X:
2758 case MENU_SOFTFX_SOFT_HQ2XBOLD:
2759 case MENU_SOFTFX_SOFT_HQ3XBOLD:
2760 case MENU_SOFTFX_SOFT_EPXB:
2761 case MENU_SOFTFX_SOFT_EPXC:
2762 case MENU_SOFTFX_SOFT_2XBR_A:
2763 case MENU_SOFTFX_SOFT_2XBR_B:
2764 case MENU_SOFTFX_SOFT_2XBR_C:
2765 case MENU_SOFTFX_SOFT_3XBR_A:
2766 case MENU_SOFTFX_SOFT_3XBR_B:
2767 case MENU_SOFTFX_SOFT_3XBR_C:
2768 case MENU_SOFTFX_SOFT_4XBR_A:
2769 case MENU_SOFTFX_SOFT_4XBR_B:
2770 case MENU_SOFTFX_SOFT_4XBR_C:
2771 case MENU_SOFTFX_SOFT_DDT3X:
2772 nVidBlitterOpt[nVidSelect] &= ~0xFF;
2773 nVidBlitterOpt[nVidSelect] |= id - MENU_SOFTFX_SOFT_STRETCH;
2774 POST_INITIALISE_MESSAGE;
2775 break;
2776
2777 case MENU_SOFTFX_SOFT_AUTOSIZE:
2778 nVidBlitterOpt[nVidSelect] ^= 0x0100;
2779 POST_INITIALISE_MESSAGE;
2780 break;
2781 case MENU_SOFT_DIRECTACCESS:
2782 nVidBlitterOpt[nVidSelect] ^= 0x0200;
2783 POST_INITIALISE_MESSAGE;
2784 break;
2785 }
2786 break;
2787 }
2788 case 3:
2789 switch (id) {
2790 // Options for the DirectX Graphics 9 blitter
2791 case MENU_DX9_POINT:
2792 nVidBlitterOpt[nVidSelect] &= ~(3 << 24);
2793 nVidBlitterOpt[nVidSelect] |= (0 << 24);
2794 POST_INITIALISE_MESSAGE;
2795 break;
2796 case MENU_DX9_LINEAR:
2797 nVidBlitterOpt[nVidSelect] &= ~(3 << 24);
2798 nVidBlitterOpt[nVidSelect] |= (1 << 24);
2799 POST_INITIALISE_MESSAGE;
2800 break;
2801 case MENU_DX9_CUBIC:
2802 nVidBlitterOpt[nVidSelect] &= ~(3 << 24);
2803 nVidBlitterOpt[nVidSelect] |= (2 << 24);
2804 POST_INITIALISE_MESSAGE;
2805 break;
2806
2807 case MENU_DX9_CUBIC_LIGHT:
2808 dVidCubicB = 0.0;
2809 dVidCubicC = 0.0;
2810 VidRedraw();
2811 break;
2812 case MENU_DX9_CUBIC_BSPLINE:
2813 dVidCubicB = 1.0;
2814 dVidCubicC = 0.0;
2815 VidRedraw();
2816 break;
2817 case MENU_DX9_CUBIC_NOTCH:
2818 dVidCubicB = 3.0 / 2.0;
2819 dVidCubicC = -0.25;
2820 VidRedraw();
2821 break;
2822 case MENU_DX9_CUBIC_OPTIMAL:
2823 dVidCubicB = 1.0 / 3.0;
2824 dVidCubicC = 1.0 / 3.0;
2825 VidRedraw();
2826 break;
2827 case MENU_DX9_CUBIC_CATMULL:
2828 dVidCubicB = 0.0;
2829 dVidCubicC = 0.5;
2830 VidRedraw();
2831 break;
2832 case MENU_DX9_CUBIC_SHARP:
2833 dVidCubicB = 0.0;
2834 dVidCubicC = 1.0;
2835 VidRedraw();
2836 break;
2837
2838 /*
2839 if (UseDialogs()) {
2840 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2841 AudBlankSound();
2842 if ((nVidBlitterOpt[nVidSelect] & (3 << 24)) != (2 << 24)) {
2843 nVidBlitterOpt[nVidSelect] &= ~(3 << 24);
2844 nVidBlitterOpt[nVidSelect] |= (2 << 24);
2845 ScrnSize();
2846 VidInit();
2847 VidRedraw();
2848 }
2849 CubicSharpnessDialog();
2850 GameInpCheckMouse();
2851 }
2852 break;
2853 */
2854
2855 case MENU_EXP_SCAN:
2856 bVidScanlines = !bVidScanlines;
2857 POST_INITIALISE_MESSAGE;
2858 break;
2859 case MENU_EXP_SCANINTENSITY:
2860 if (UseDialogs()) {
2861 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
2862 AudBlankSound();
2863 if (!bVidScanlines) {
2864 bVidScanlines = 1;
2865 ScrnSize();
2866 VidInit();
2867 VidRedraw();
2868 }
2869 ScanlineDialog();
2870 GameInpCheckMouse();
2871 }
2872 break;
2873
2874 case MENU_DX9_FPTERXTURES:
2875 POST_INITIALISE_MESSAGE;
2876 break;
2877
2878 case MENU_DX9_FORCE_PS14:
2879 nVidBlitterOpt[nVidSelect] ^= (1 << 9);
2880 POST_INITIALISE_MESSAGE;
2881 break;
2882
2883 case MENU_DX9_CUBIC0:
2884 nVidBlitterOpt[nVidSelect] &= ~(7 << 28);
2885 nVidBlitterOpt[nVidSelect] |= (0 << 28);
2886
2887 nVidBlitterOpt[nVidSelect] |= (1 << 8);
2888 nVidBlitterOpt[nVidSelect] |= (1 << 9);
2889 POST_INITIALISE_MESSAGE;
2890 break;
2891 case MENU_DX9_CUBIC1:
2892 nVidBlitterOpt[nVidSelect] &= ~(7 << 28);
2893 nVidBlitterOpt[nVidSelect] |= (1 << 28);
2894
2895 nVidBlitterOpt[nVidSelect] |= (1 << 8);
2896 nVidBlitterOpt[nVidSelect] |= (1 << 9);
2897 POST_INITIALISE_MESSAGE;
2898 break;
2899 case MENU_DX9_CUBIC2:
2900 nVidBlitterOpt[nVidSelect] &= ~(7 << 28);
2901 nVidBlitterOpt[nVidSelect] |= (2 << 28);
2902
2903 nVidBlitterOpt[nVidSelect] |= (1 << 8);
2904 nVidBlitterOpt[nVidSelect] |= (1 << 9);
2905 POST_INITIALISE_MESSAGE;
2906 break;
2907 case MENU_DX9_CUBIC3:
2908 nVidBlitterOpt[nVidSelect] &= ~(7 << 28);
2909 nVidBlitterOpt[nVidSelect] |= (3 << 28);
2910
2911 nVidBlitterOpt[nVidSelect] |= (1 << 8);
2912 nVidBlitterOpt[nVidSelect] |= (1 << 9);
2913 POST_INITIALISE_MESSAGE;
2914 break;
2915 case MENU_DX9_CUBIC4:
2916 nVidBlitterOpt[nVidSelect] &= ~(7 << 28);
2917 nVidBlitterOpt[nVidSelect] |= (4 << 28);
2918
2919 nVidBlitterOpt[nVidSelect] &= ~(1 << 8);
2920 nVidBlitterOpt[nVidSelect] &= ~(1 << 9);
2921 POST_INITIALISE_MESSAGE;
2922 break;
2923
2924 }
2925 break;
2926 case 4:
2927 switch (id) {
2928 // Options for the DirectX Graphics 9 Alternate blitter
2929 case MENU_DX9_ALT_POINT:
2930 bVidDX9Bilinear = 0;
2931 POST_INITIALISE_MESSAGE;
2932 break;
2933
2934 case MENU_DX9_ALT_LINEAR:
2935 bVidDX9Bilinear = 1;
2936 POST_INITIALISE_MESSAGE;
2937 break;
2938
2939 case MENU_DX9_ALT_SOFT_STRETCH:
2940 case MENU_DX9_ALT_SOFT_SCALE2X:
2941 case MENU_DX9_ALT_SOFT_SCALE3X:
2942 case MENU_DX9_ALT_SOFT_2XPM_LQ:
2943 case MENU_DX9_ALT_SOFT_2XPM_HQ:
2944 case MENU_DX9_ALT_SOFT_EAGLE:
2945 case MENU_DX9_ALT_SOFT_SUPEREAGLE:
2946 case MENU_DX9_ALT_SOFT_2XSAI:
2947 case MENU_DX9_ALT_SOFT_SUPER2XSAI:
2948 case MENU_DX9_ALT_SOFT_SUPEREAGLE_VBA:
2949 case MENU_DX9_ALT_SOFT_2XSAI_VBA:
2950 case MENU_DX9_ALT_SOFT_SUPER2XSAI_VBA:
2951 case MENU_DX9_ALT_SOFT_SUPERSCALE:
2952 case MENU_DX9_ALT_SOFT_SUPERSCALE75:
2953 case MENU_DX9_ALT_SOFT_HQ2X:
2954 case MENU_DX9_ALT_SOFT_HQ3X:
2955 case MENU_DX9_ALT_SOFT_HQ4X:
2956 case MENU_DX9_ALT_SOFT_HQ2XS_VBA:
2957 case MENU_DX9_ALT_SOFT_HQ3XS_VBA:
2958 case MENU_DX9_ALT_SOFT_HQ2XS_SNES9X:
2959 case MENU_DX9_ALT_SOFT_HQ3XS_SNES9X:
2960 case MENU_DX9_ALT_SOFT_HQ2XBOLD:
2961 case MENU_DX9_ALT_SOFT_HQ3XBOLD:
2962 case MENU_DX9_ALT_SOFT_EPXB:
2963 case MENU_DX9_ALT_SOFT_EPXC:
2964 case MENU_DX9_ALT_SOFT_2XBR_A:
2965 case MENU_DX9_ALT_SOFT_2XBR_B:
2966 case MENU_DX9_ALT_SOFT_2XBR_C:
2967 case MENU_DX9_ALT_SOFT_3XBR_A:
2968 case MENU_DX9_ALT_SOFT_3XBR_B:
2969 case MENU_DX9_ALT_SOFT_3XBR_C:
2970 case MENU_DX9_ALT_SOFT_4XBR_A:
2971 case MENU_DX9_ALT_SOFT_4XBR_B:
2972 case MENU_DX9_ALT_SOFT_4XBR_C:
2973 case MENU_DX9_ALT_SOFT_DDT3X:
2974 nVidBlitterOpt[nVidSelect] &= ~0xFF;
2975 nVidBlitterOpt[nVidSelect] |= id - MENU_DX9_ALT_SOFT_STRETCH;
2976 POST_INITIALISE_MESSAGE;
2977 break;
2978
2979 case MENU_DX9_ALT_SOFT_AUTOSIZE:
2980 nVidBlitterOpt[nVidSelect] ^= 0x0100;
2981 POST_INITIALISE_MESSAGE;
2982 break;
2983
2984 case MENU_DX9_ALT_HARDWAREVERTEX:
2985 bVidHardwareVertex = !bVidHardwareVertex;
2986 POST_INITIALISE_MESSAGE;
2987 break;
2988
2989 case MENU_DX9_ALT_MOTIONBLUR:
2990 bVidMotionBlur = !bVidMotionBlur;
2991 POST_INITIALISE_MESSAGE;
2992 break;
2993
2994 case MENU_DX9_ALT_FORCE_16BIT:
2995 bVidForce16bitDx9Alt = !bVidForce16bitDx9Alt;
2996 POST_INITIALISE_MESSAGE;
2997 break;
2998 }
2999 break;
3000 }
3001
3002 if (hwndChat) {
3003 switch (codeNotify) {
3004 case EN_CHANGE: {
3005 bEditTextChanged = true;
3006 SendMessage(hwndChat, WM_GETTEXT, (WPARAM)MAX_CHAT_SIZE + 1, (LPARAM)EditText);
3007 break;
3008 }
3009 case EN_KILLFOCUS: {
3010 SetFocus(hwndChat);
3011 break;
3012 }
3013 case EN_MAXTEXT: {
3014 VidSNewShortMsg(FBALoadStringEx(hAppInst, IDS_NETPLAY_TOOMUCH, true), 0xFF3F3F);
3015 break;
3016 }
3017 }
3018 }
3019
3020 MenuUpdate();
3021 }
3022
3023 // Block screensaver and windows menu if needed
OnSysCommand(HWND,UINT sysCommand,int,int)3024 static int OnSysCommand(HWND, UINT sysCommand, int, int)
3025 {
3026 switch (sysCommand) {
3027 case SC_MONITORPOWER:
3028 case SC_SCREENSAVE: {
3029 if (!bRunPause && bDrvOkay) {
3030 return 1;
3031 }
3032 break;
3033 }
3034 case SC_KEYMENU:
3035 case SC_MOUSEMENU: {
3036 if (kNetGame && !bModelessMenu) {
3037 return 1;
3038 }
3039 break;
3040 }
3041 }
3042
3043 return 0;
3044 }
3045
OnSize(HWND,UINT state,int cx,int cy)3046 static void OnSize(HWND, UINT state, int cx, int cy)
3047 {
3048 if (state == SIZE_MINIMIZED) {
3049 bMaximised = false;
3050 } else {
3051 bool bSizeChanged = false;
3052
3053 MoveWindow(hRebar, 0, 0, cx, nMenuHeight, TRUE);
3054
3055 if (hwndChat) {
3056 MoveWindow(hwndChat, 0, cy - 32, cx, 32, FALSE);
3057 }
3058
3059 if (state == SIZE_MAXIMIZED) {
3060 if (!bMaximised) {
3061 bSizeChanged = true;
3062 }
3063 bMaximised = true;
3064 }
3065 if (state == SIZE_RESTORED) {
3066 if (bMaximised) {
3067 bSizeChanged = true;
3068 }
3069 bMaximised = false;
3070 }
3071
3072 if (bSizeChanged) {
3073 RefreshWindow(true);
3074 } else {
3075 RefreshWindow(false);
3076 }
3077 }
3078 }
3079
OnEnterSizeMove(HWND)3080 static void OnEnterSizeMove(HWND)
3081 {
3082 RECT rect;
3083
3084 AudBlankSound();
3085
3086 GetClientRect(hScrnWnd, &rect);
3087 nPrevWidth = rect.right;
3088 nPrevHeight = rect.bottom;
3089 }
3090
OnExitSizeMove(HWND)3091 static void OnExitSizeMove(HWND)
3092 {
3093 RECT rect;
3094
3095 GetClientRect(hScrnWnd, &rect);
3096 if (rect.right != nPrevWidth || rect.bottom != nPrevHeight) {
3097 RefreshWindow(true);
3098 }
3099
3100 GetWindowRect(hScrnWnd, &rect);
3101 nWindowPosX = rect.left;
3102 nWindowPosY = rect.top;
3103 }
3104
OnEnterIdle(HWND,UINT,HWND)3105 static void OnEnterIdle(HWND /*hwnd*/, UINT /*source*/, HWND /*hwndSource*/)
3106 {
3107 MSG Message;
3108
3109 // Modeless dialog is idle
3110 while (kNetGame && !PeekMessage(&Message, NULL, 0, 0, PM_NOREMOVE)) {
3111 RunIdle();
3112 }
3113 }
3114
OnEnterMenuLoop(HWND,BOOL)3115 static void OnEnterMenuLoop(HWND, BOOL)
3116 {
3117 if (!bModelessMenu) {
3118 InputSetCooperativeLevel(false, bAlwaysProcessKeyboardInput);
3119 AudBlankSound();
3120 } else {
3121 if (!kNetGame && bAutoPause) {
3122 bRunPause = 1;
3123 }
3124 }
3125 }
3126
OnExitMenuLoop(HWND,BOOL)3127 static void OnExitMenuLoop(HWND, BOOL)
3128 {
3129 if (!bModelessMenu) {
3130 GameInpCheckMouse();
3131 }
3132 }
3133
ScrnRegister()3134 static int ScrnRegister()
3135 {
3136 WNDCLASSEX WndClassEx;
3137 ATOM Atom = 0;
3138
3139 // Register the window class
3140 memset(&WndClassEx, 0, sizeof(WndClassEx)); // Init structure to all zeros
3141 WndClassEx.cbSize = sizeof(WndClassEx);
3142 WndClassEx.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_CLASSDC;// These cause flicker in the toolbar
3143 WndClassEx.lpfnWndProc = ScrnProc;
3144 WndClassEx.hInstance = hAppInst;
3145 WndClassEx.hIcon = LoadIcon(hAppInst, MAKEINTRESOURCE(IDI_APP));
3146 WndClassEx.hCursor = LoadCursor(NULL, IDC_ARROW);
3147 WndClassEx.hbrBackground = static_cast<HBRUSH>( GetStockObject ( BLACK_BRUSH ));
3148 WndClassEx.lpszClassName = szClass;
3149
3150 // Register the window class with the above information:
3151 Atom = RegisterClassEx(&WndClassEx);
3152 if (Atom) {
3153 return 0;
3154 } else {
3155 return 1;
3156 }
3157 }
3158
ScrnSize()3159 int ScrnSize()
3160 {
3161 int x, y, w, h, ew, eh;
3162 int nScrnWidth, nScrnHeight;
3163 int nBmapWidth = nVidImageWidth, nBmapHeight = nVidImageHeight;
3164 int nGameAspectX = 4, nGameAspectY = 3;
3165 int nMaxSize;
3166
3167 SystemParametersInfo(SPI_GETWORKAREA, 0, &SystemWorkArea, 0); // Find the size of the visible WorkArea
3168
3169 if (hScrnWnd == NULL || nVidFullscreen) {
3170 return 1;
3171 }
3172
3173 if (bDrvOkay) {
3174 if ((BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) && (nVidRotationAdjust & 1)) {
3175 BurnDrvGetVisibleSize(&nBmapHeight, &nBmapWidth);
3176 BurnDrvGetAspect(&nGameAspectY, &nGameAspectX);
3177 } else {
3178 BurnDrvGetVisibleSize(&nBmapWidth, &nBmapHeight);
3179 BurnDrvGetAspect(&nGameAspectX, &nGameAspectY);
3180 }
3181
3182 if (nBmapWidth <= 0 || nBmapHeight <= 0) {
3183 return 1;
3184 }
3185 }
3186
3187 nDragX = GetSystemMetrics(SM_CXDRAG) / 2;
3188 nDragY = GetSystemMetrics(SM_CYDRAG) / 2;
3189
3190 nScrnWidth = SystemWorkArea.right - SystemWorkArea.left;
3191 nScrnHeight = SystemWorkArea.bottom - SystemWorkArea.top;
3192
3193 if (nVidSelect == 2 && nVidBlitterOpt[2] & 0x0100) { // The Software effects blitter uses a fixed size
3194 nMaxSize = 9;
3195 } else {
3196 if (nWindowSize) {
3197 nMaxSize = nWindowSize;
3198 if (bDrvOkay && nWindowSize == 2 && nBmapWidth >= 400 && nBmapHeight >= 400) {
3199 // For Popeye, Hole Land and Syvalion, MCR..etc. when running Windowed: Double Size
3200 bprintf(PRINT_NORMAL, _T(" * Game is double-sized to begin with.\n"));
3201 nMaxSize = 1;
3202 }
3203 } else {
3204 if (nBmapWidth < nBmapHeight) {
3205 if (SystemWorkArea.bottom - SystemWorkArea.top <= 600) {
3206 nMaxSize = 1;
3207 } else {
3208 if (SystemWorkArea.bottom - SystemWorkArea.top <= 960) {
3209 nMaxSize = 2;
3210 } else {
3211 if (SystemWorkArea.bottom - SystemWorkArea.top <= 1280) {
3212 nMaxSize = 3;
3213 } else {
3214 nMaxSize = 4;
3215 }
3216 }
3217 }
3218 } else {
3219 if (SystemWorkArea.right - SystemWorkArea.left <= 640) {
3220 nMaxSize = 1;
3221 } else {
3222 if (SystemWorkArea.right - SystemWorkArea.left <= 1152) {
3223 nMaxSize = 2;
3224 } else {
3225 if (SystemWorkArea.right - SystemWorkArea.left <= 1600) {
3226 nMaxSize = 3;
3227 } else {
3228 nMaxSize = 4;
3229 }
3230 }
3231 }
3232 }
3233 }
3234 }
3235
3236 // Find the width and height
3237 w = nScrnWidth;
3238 h = nScrnHeight;
3239
3240 // Find out how much space is taken up by the borders
3241 ew = GetSystemMetrics(SM_CXSIZEFRAME) << 1;
3242 eh = GetSystemMetrics(SM_CYSIZEFRAME) << 1;
3243
3244 // Visual Studio 2012 (seems to have an issue with these, other reports on the web about it too
3245 #if defined _MSC_VER
3246 #if _MSC_VER >= 1700
3247 // using the old XP supporting SDK we don't need to alter anything
3248 #if !defined BUILD_VS_XP_TARGET
3249 ew <<= 1;
3250 eh <<= 1;
3251 #endif
3252 #endif
3253 #endif
3254
3255 if (bMenuEnabled) {
3256 eh += GetSystemMetrics(SM_CYCAPTION);
3257 eh += nMenuHeight;
3258 } else {
3259 eh += 1 << 1;
3260 ew += 1 << 1;
3261 }
3262
3263 if (bMenuEnabled || !bVidScanlines || nVidSelect == 2) {
3264 // Subtract the border space
3265 w -= ew;
3266 h -= eh;
3267 }
3268
3269 if ((bVidCorrectAspect || bVidFullStretch) && !(nVidSelect == 2 && (nVidBlitterOpt[2] & 0x0100) == 0)) {
3270 int ww = w;
3271 int hh = h;
3272
3273 do {
3274 if (nBmapWidth < nBmapHeight && bVidScanRotate) {
3275 if (ww > nBmapWidth * nMaxSize) {
3276 ww = nBmapWidth * nMaxSize;
3277 }
3278 if (hh > ww * nVidScrnAspectX * nGameAspectY * nScrnHeight / (nScrnWidth * nVidScrnAspectY * nGameAspectX)) {
3279 hh = ww * nVidScrnAspectX * nGameAspectY * nScrnHeight / (nScrnWidth * nVidScrnAspectY * nGameAspectX);
3280 }
3281 } else {
3282 if (hh > nBmapHeight * nMaxSize) {
3283 hh = nBmapHeight * nMaxSize;
3284 }
3285 if (ww > hh * nVidScrnAspectY * nGameAspectX * nScrnWidth / (nScrnHeight * nVidScrnAspectX * nGameAspectY)) {
3286 ww = hh * nVidScrnAspectY * nGameAspectX * nScrnWidth / (nScrnHeight * nVidScrnAspectX * nGameAspectY);
3287 }
3288 }
3289 } while ((ww > w || hh > h) && nMaxSize-- > 1);
3290 w = ww;
3291 h = hh;
3292 } else {
3293 while ((nBmapWidth * nMaxSize > w || nBmapHeight * nMaxSize > h) && nMaxSize > 1) {
3294 nMaxSize--;
3295 }
3296
3297 if (w > nBmapWidth * nMaxSize || h > nBmapHeight * nMaxSize) {
3298 w = nBmapWidth * nMaxSize;
3299 h = nBmapHeight * nMaxSize;
3300 }
3301 }
3302
3303 if (!bDrvOkay) {
3304 if (w < 304) w = 304;
3305 if (h < 224) h = 224;
3306 }
3307
3308 RECT rect = { 0, 0, w, h };
3309 VidImageSize(&rect, nBmapWidth, nBmapHeight);
3310 w = rect.right - rect.left + ew;
3311 h = rect.bottom - rect.top + eh;
3312
3313 x = nWindowPosX; y = nWindowPosY;
3314 if (x + w > SystemWorkArea.right || y + h > SystemWorkArea.bottom) {
3315 // Find the midpoint for the window
3316 x = SystemWorkArea.left + SystemWorkArea.right;
3317 x /= 2;
3318 y = SystemWorkArea.bottom + SystemWorkArea.top;
3319 y /= 2;
3320
3321 x -= w / 2;
3322 y -= h / 2;
3323 }
3324
3325 MenuUpdate();
3326
3327 bMaximised = false;
3328
3329 MoveWindow(hScrnWnd, x, y, w, h, true);
3330
3331 // SetWindowPos(hScrnWnd, NULL, x, y, w, h, SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER);
3332
3333 nWindowPosX = x; nWindowPosY = y;
3334
3335 return 0;
3336 }
3337
3338 #include "neocdlist.h" // IsNeoGeoCD()
3339
ScrnTitle()3340 int ScrnTitle()
3341 {
3342 TCHAR szText[1024] = _T("");
3343
3344 // Create window title
3345 if (bDrvOkay) {
3346 TCHAR* pszPosition = szText;
3347 TCHAR* pszName = BurnDrvGetText(DRV_FULLNAME);
3348
3349 pszPosition += _sntprintf(szText, 1024, _T(APP_TITLE) _T( " v%.20s") _T(SEPERATOR_1) _T("%s"), szAppBurnVer, pszName);
3350 while ((pszName = BurnDrvGetText(DRV_NEXTNAME | DRV_FULLNAME)) != NULL) {
3351 if (pszPosition + _tcslen(pszName) - 1024 > szText) {
3352 break;
3353 }
3354 pszPosition += _stprintf(pszPosition, _T(SEPERATOR_2) _T("%s"), pszName);
3355 }
3356
3357 if (IsNeoGeoCD()) {
3358 NeoCDInfo_SetTitle();
3359 return 0;
3360 }
3361
3362 } else {
3363 _stprintf(szText, _T(APP_TITLE) _T( " v%.20s") _T(SEPERATOR_1) _T("[%s]"), szAppBurnVer, FBALoadStringEx(hAppInst, IDS_SCRN_NOGAME, true));
3364 }
3365
3366 SetWindowText(hScrnWnd, szText);
3367 return 0;
3368 }
3369
3370
3371 // Init the screen window (create it)
ScrnInit()3372 int ScrnInit()
3373 {
3374 REBARINFO rebarInfo;
3375 REBARBANDINFO rebarBandInfo;
3376 RECT rect;
3377 int nWindowStyles, nWindowExStyles;
3378
3379 ScrnExit();
3380
3381 if (ScrnRegister() != 0) {
3382 return 1;
3383 }
3384
3385 if (nVidFullscreen) {
3386 nWindowStyles = WS_POPUP;
3387 nWindowExStyles = 0;
3388 } else {
3389 if (bMenuEnabled) {
3390 nWindowStyles = WS_OVERLAPPEDWINDOW;
3391 nWindowExStyles = 0;
3392 } else {
3393 nWindowStyles = WS_MINIMIZEBOX | WS_POPUP | WS_SYSMENU | WS_THICKFRAME;
3394 nWindowExStyles = WS_EX_CLIENTEDGE;
3395 }
3396 }
3397
3398 hScrnWnd = CreateWindowEx(nWindowExStyles, szClass, _T(APP_TITLE), nWindowStyles,
3399 0, 0, 0, 0, // size of window
3400 NULL, NULL, hAppInst, NULL);
3401
3402 if (hScrnWnd == NULL) {
3403 ScrnExit();
3404 return 1;
3405 }
3406
3407 nMenuHeight = 0;
3408 if (!nVidFullscreen) {
3409
3410 // Create the menu toolbar itself
3411 MenuCreate();
3412
3413 // Create the toolbar
3414 if (bMenuEnabled) {
3415 // Create the Rebar control that will contain the menu toolbar
3416 hRebar = CreateWindowEx(WS_EX_TOOLWINDOW,
3417 REBARCLASSNAME, NULL,
3418 RBS_BANDBORDERS | CCS_NOPARENTALIGN | CCS_NODIVIDER | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
3419 0, 0, 0, 0,
3420 hScrnWnd, NULL, hAppInst, NULL);
3421
3422 rebarInfo.cbSize = sizeof(REBARINFO);
3423 rebarInfo.fMask = 0;
3424 rebarInfo.himl = NULL;
3425
3426 SendMessage(hRebar, RB_SETBARINFO, 0, (LPARAM)&rebarInfo);
3427
3428 // Add the menu toolbar to the rebar
3429 GetWindowRect(hMenubar, &rect);
3430
3431 rebarBandInfo.cbSize = sizeof(REBARBANDINFO);
3432 rebarBandInfo.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;// | RBBIM_BACKGROUND;
3433 rebarBandInfo.fStyle = 0;//RBBS_GRIPPERALWAYS;// | RBBS_FIXEDBMP;
3434 rebarBandInfo.hwndChild = hMenubar;
3435 rebarBandInfo.cxMinChild = 100;
3436 rebarBandInfo.cyMinChild = ((SendMessage(hMenubar, TB_GETBUTTONSIZE, 0, 0)) >> 16) + 1;
3437 rebarBandInfo.cx = rect.right - rect.left;
3438
3439 SendMessage(hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rebarBandInfo);
3440
3441 GetWindowRect(hRebar, &rect);
3442 nMenuHeight = rect.bottom - rect.top;
3443
3444 }
3445
3446 ScrnTitle();
3447 ScrnSize();
3448 }
3449
3450 return 0;
3451 }
3452
3453 // Exit the screen window (destroy it)
ScrnExit()3454 int ScrnExit()
3455 {
3456 // Ensure the window is destroyed
3457 DeActivateChat();
3458
3459 if (hRebar) {
3460 DestroyWindow(hRebar);
3461 hRebar = NULL;
3462 }
3463
3464 if (hScrnWnd) {
3465 DestroyWindow(hScrnWnd);
3466 hScrnWnd = NULL;
3467 }
3468
3469 UnregisterClass(szClass, hAppInst); // Unregister the scrn class
3470
3471 MenuDestroy();
3472
3473 return 0;
3474 }
3475
Reinitialise()3476 void Reinitialise()
3477 {
3478 POST_INITIALISE_MESSAGE;
3479 VidReInitialise();
3480 }
3481