diff --git a/src/drivers/win/args.cpp b/src/drivers/win/args.cpp index 6d0833c3..9b499229 100644 --- a/src/drivers/win/args.cpp +++ b/src/drivers/win/args.cpp @@ -27,7 +27,7 @@ char *ParseArgies(int argc, char *argv[]) { //int x; //mbg merge 7/17/06 removed static ARGPSTRUCT FCEUArgs[]={ - {"-pal",0,&palyo,0}, + {"-pal",0,&pal_emulation,0}, {"-noicon",0,&status_icon,0}, {"-gg",0,&genie,0}, {"-no8lim",0,&eoptions,0x8000|EO_NOSPRLIM}, diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 1f8485ad..afc98949 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -55,7 +55,7 @@ static CFGSTRUCT fceuconfig[] = { AC(ntsccol),AC(ntsctint),AC(ntschue), - NAC("palyo",palyo), + NAC("palyo",pal_emulation), NAC("genie",genie), NAC("fs",fullscreen), NAC("vgamode",vmod), diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index 597d7a26..d03576c6 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -191,8 +191,11 @@ static int moviereadonly=1; static int fullscreen=0; static int soundflush=0; -static int genie=0; -static int palyo=0; +// Flag that indicates whether Game Genie is enabled or not. +static int genie = 0; + +// Flag that indicates whether PAL Emulation is enabled or not. +static int pal_emulation = 0; static int status_icon=1; static int windowedfailed; static double saspectw=1, saspecth=1; @@ -514,8 +517,8 @@ int main(int argc,char *argv[]) /* Bleh, need to find a better place for this. */ { - palyo &= 1; - FCEUI_SetVidSystem(palyo); + pal_emulation &= 1; + FCEUI_SetVidSystem(pal_emulation); genie &= 1; FCEUI_SetGameGenie(genie); @@ -564,7 +567,7 @@ int main(int argc,char *argv[]) return 1; } - UpdateMenu(); + UpdateCheckedMenuItems(); if(t) { @@ -1078,5 +1081,5 @@ int FCEUD_ShowStatusIcon(void) void FCEUD_ToggleStatusIcon(void) { status_icon=!status_icon; - UpdateMenu(); + UpdateCheckedMenuItems(); } diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index 15001295..328573b9 100644 Binary files a/src/drivers/win/res.rc and b/src/drivers/win/res.rc differ diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 79429140..97befb8b 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -17,6 +17,18 @@ #define MENU_RECORD_AVI 151 #define MENU_STOP_AVI 152 #define MENU_EXIT 153 +#define MENU_RESET 200 +#define MENU_POWER 201 +#define MENU_EJECT_DISK 202 +#define MENU_SWITCH_DISK 203 +#define MENU_INSERT_COIN 204 +#define MENU_HIDE_MENU 300 +#define MENU_RUN_IN_BACKGROUND 301 +#define MENU_BACKGROUND_INPUT 302 +#define MENU_SHOW_STATUS_ICON 303 +#define MENU_ENABLE_REWIND 304 +#define MENU_GAME_GENIE 310 +#define MENU_PAL 311 #define GUI_BOT_A_1 1000 #define GUI_BOT_B_1 1001 #define GUI_BOT_SELECT_1 1002 @@ -153,7 +165,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40025 +#define _APS_NEXT_COMMAND_VALUE 40037 #define _APS_NEXT_CONTROL_VALUE 1117 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 6c583a44..06888f97 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -47,6 +47,9 @@ static void ConfigTiming(void); static void ConfigPalette(void); static void ConfigDirectories(void); +/** +* Menu handle of the main menu. +**/ static HMENU fceumenu=0; static int tog=0; @@ -98,7 +101,24 @@ void CalcWindowSize(RECT *al) void RedoMenuGI(FCEUGI *gi) { - int simpled[]={101,111,110,200,201,204,203,141,142,143,151,152,40120,300,40003,40028, 0}; + int simpled[]= { 101, + 111, + 110, + MENU_RESET, + MENU_POWER, + 204, + 203, + 141, + 142, + 143, + 151, + 152, + 40120, + MENU_HIDE_MENU, + 40003, + 40028, + 0}; + int x; x = 0; @@ -119,49 +139,72 @@ void RedoMenuGI(FCEUGI *gi) } } -void UpdateMenu(void) +/** +* Updates menu items which need to be checked or unchecked. +**/ +void UpdateCheckedMenuItems(void) { - static int *polo[3]={&genie,&palyo,&status_icon}; - static int polo2[3]={310,311,303}; + static int *polo[] = { &genie, &pal_emulation, &status_icon }; + static int polo2[]={ MENU_GAME_GENIE, MENU_PAL, MENU_SHOW_STATUS_ICON }; int x; - for(x=0;x<3;x++) - CheckMenuItem(fceumenu,polo2[x],*polo[x]?MF_CHECKED:MF_UNCHECKED); + // Check or uncheck the necessary menu items + for(x = 0; x < sizeof(polo) / sizeof(*polo); x++) + { + CheckMenuItem(fceumenu, polo2[x], *polo[x] ? MF_CHECKED : MF_UNCHECKED); + } - if(eoptions&EO_BGRUN) - CheckMenuItem(fceumenu,301,MF_CHECKED); - else - CheckMenuItem(fceumenu,301,MF_UNCHECKED); + CheckMenuItem(fceumenu, MENU_RUN_IN_BACKGROUND, eoptions & EO_BGRUN ? MF_CHECKED : MF_UNCHECKED); - if(FCEU_BotMode()) - CheckMenuItem(fceumenu,40003, MF_CHECKED); - else - CheckMenuItem(fceumenu,40003, MF_UNCHECKED); + CheckMenuItem(fceumenu, 40003, FCEU_BotMode() ? MF_CHECKED : MF_UNCHECKED); - if(GetAutoFireDesynch()) - CheckMenuItem(fceumenu,40025, MF_CHECKED); - else - CheckMenuItem(fceumenu,40025, MF_UNCHECKED); + CheckMenuItem(fceumenu, 40025, GetAutoFireDesynch() ? MF_CHECKED : MF_UNCHECKED); - CheckMenuItem(fceumenu,302, EnableBackgroundInput?MF_CHECKED:MF_UNCHECKED); - CheckMenuItem(fceumenu,40029, EnableRewind?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(fceumenu, MENU_BACKGROUND_INPUT, EnableBackgroundInput ? MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(fceumenu, MENU_ENABLE_REWIND, EnableRewind ? MF_CHECKED : MF_UNCHECKED); - int AutoFirePatternIDs[]={40004,40005,40006,40007,40008,40009,40010,40011,40012,40013,40014,40015,40022,40023,40024,0}; - int AutoFireOffsetIDs[]={40016,40017,40018,40019,40020,40021,0}; + int AutoFirePatternIDs[] = { + 40004, + 40005, + 40006, + 40007, + 40008, + 40009, + 40010, + 40011, + 40012, + 40013, + 40014, + 40015, + 40022, + 40023, + 40024, + 0}; + + int AutoFireOffsetIDs[] = { + 40016, + 40017, + 40018, + 40019, + 40020, + 40021, + 0}; x = 0; + while(AutoFirePatternIDs[x]) { - CheckMenuItem(fceumenu,AutoFirePatternIDs[x], - AutoFirePatternIDs[x]==CheckedAutoFirePattern?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(fceumenu, AutoFirePatternIDs[x], + AutoFirePatternIDs[x] == CheckedAutoFirePattern ? MF_CHECKED : MF_UNCHECKED); x++; } x = 0; + while(AutoFireOffsetIDs[x]) { - CheckMenuItem(fceumenu,AutoFireOffsetIDs[x], - AutoFireOffsetIDs[x]==CheckedAutoFireOffset?MF_CHECKED:MF_UNCHECKED); + CheckMenuItem(fceumenu, AutoFireOffsetIDs[x], + AutoFireOffsetIDs[x] == CheckedAutoFireOffset ? MF_CHECKED : MF_UNCHECKED); x++; } } @@ -325,18 +368,21 @@ void AddRecentDir(char *fn) UpdateRMenu(recentdmenu, rdirs, 103, 700); } - - -void HideMenu(int h) +/** +* Hides the main menu. +* +* @param hide_menu Flag to turn the main menu on (0) or off (1) +**/ +void HideMenu(unsigned int hide_menu) { - if(h) - { - SetMenu(hAppWnd,0); - } - else - { - SetMenu(hAppWnd,fceumenu); - } + if(hide_menu) + { + SetMenu(hAppWnd, 0); + } + else + { + SetMenu(hAppWnd, fceumenu); + } } static LONG WindowXC=1<<30,WindowYC; @@ -366,16 +412,24 @@ void HideFWindow(int h) SetWindowPos(hAppWnd,0,0,0,0,0,SWP_FRAMECHANGED|SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_NOMOVE|SWP_NOREPOSITION|SWP_NOSIZE|SWP_NOZORDER); } +/** +* Toggles the display status of the main menu. +**/ void ToggleHideMenu(void) { - if(!fullscreen && (GameInfo || tog)) - { - tog^=1; - HideMenu(tog); - SetMainWindowStuff(); - } + if(!fullscreen && (GameInfo || tog)) + { + tog ^= 1; + HideMenu(tog); + SetMainWindowStuff(); + } } +/** +* Toggles the display status of the main menu. +* +* TODO: We could get rid of this one. +**/ void FCEUD_HideMenuToggle(void) { ToggleHideMenu(); @@ -385,8 +439,8 @@ static void ALoad(char *nameo) { if(FCEUI_LoadGame(nameo,1)) { - palyo=FCEUI_GetCurrentVidSystem(0,0); - UpdateMenu(); + pal_emulation = FCEUI_GetCurrentVidSystem(0,0); + UpdateCheckedMenuItems(); FixFL(); SetMainWindowStuff(); AddRecent(nameo); @@ -494,7 +548,7 @@ void GetMouseData(uint32 *md) //static int sizchange=0; static int vchanged=0; -extern void RestartMovieOrReset(int pow); +extern void RestartMovieOrReset(unsigned int pow); int KeyboardSetBackgroundAccess(int on); //mbg merge 7/17/06 YECH had to add void SetJoystickBackgroundAccess(int background); //mbg merge 7/17/06 YECH had to add @@ -638,77 +692,77 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) case 40004: SetAutoFirePattern(1,1); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40005: SetAutoFirePattern(1,2); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40006: SetAutoFirePattern(1,3); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40007: SetAutoFirePattern(1,4); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40008: SetAutoFirePattern(1,5); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40009: SetAutoFirePattern(2,1); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40010: SetAutoFirePattern(2,2); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40011: SetAutoFirePattern(2,3); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40012: SetAutoFirePattern(2,4); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40013: SetAutoFirePattern(3,1); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40014: SetAutoFirePattern(3,2); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40015: SetAutoFirePattern(3,3); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40022: SetAutoFirePattern(4,1); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40023: SetAutoFirePattern(4,2); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40024: SetAutoFirePattern(5,1); CheckedAutoFirePattern = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40016: case 40017: @@ -718,45 +772,77 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) case 40021: SetAutoFireOffset(wParam - 40016); CheckedAutoFireOffset = wParam; - UpdateMenu(); + UpdateCheckedMenuItems(); break; case 40025: SetAutoFireDesynch(GetAutoFireDesynch()^1); - UpdateMenu(); + UpdateCheckedMenuItems(); break; - case 300:ToggleHideMenu();break; - case 301: - eoptions^=EO_BGRUN; + + case MENU_HIDE_MENU: + // Hide menu menu was selected + ToggleHideMenu(); + break; + + case MENU_RUN_IN_BACKGROUND: + // Run in Background menu was selected + // TODO: Does this even work? + + eoptions ^= EO_BGRUN; + if((eoptions & EO_BGRUN) == 0) { EnableBackgroundInput = 0; KeyboardSetBackgroundAccess(EnableBackgroundInput); SetJoystickBackgroundAccess(EnableBackgroundInput); } - UpdateMenu(); + + UpdateCheckedMenuItems(); break; - case 302:EnableBackgroundInput ^= 1; - eoptions |= EO_BGRUN*EnableBackgroundInput; + + case MENU_BACKGROUND_INPUT: + // Enable background input menu was selected + // TODO: Does this even work? + EnableBackgroundInput ^= 1; + eoptions |= EO_BGRUN * EnableBackgroundInput; KeyboardSetBackgroundAccess(EnableBackgroundInput); SetJoystickBackgroundAccess(EnableBackgroundInput); - UpdateMenu(); + UpdateCheckedMenuItems(); break; - case 40029: + + case MENU_ENABLE_REWIND: EnableRewind^= 1; - UpdateMenu(); + UpdateCheckedMenuItems(); break; - case 303:status_icon=!status_icon;UpdateMenu();break; - case 310:genie^=1;FCEUI_SetGameGenie(genie);UpdateMenu();break; - case 311:palyo^=1; - FCEUI_SetVidSystem(palyo); + + case MENU_SHOW_STATUS_ICON: + // Show status icon menu was selected + // TODO: This does not work. + status_icon = !status_icon; + UpdateCheckedMenuItems(); + break; + + case MENU_GAME_GENIE: + // Game Genie menu was selected + + genie ^= 1; + FCEUI_SetGameGenie(genie); + UpdateCheckedMenuItems(); + break; + + case MENU_PAL: + // PAL Emulation menu was selected + pal_emulation ^= 1; + FCEUI_SetVidSystem(pal_emulation); RefreshThrottleFPS(); - UpdateMenu(); + UpdateCheckedMenuItems(); FixFL(); // DoVideoConfigFix(); SetMainWindowStuff(); break; + case 40003: FCEU_SetBotMode(1^FCEU_BotMode()); - UpdateMenu(); break; + UpdateCheckedMenuItems(); break; case 40002: CreateBasicBot();break; // case 40028: DoMemmo(0); break; //mbg merge 7/18/06 removed as part of old debugger case 320:ConfigDirectories();break; @@ -769,11 +855,30 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) case 326:ConfigVideo();break; case 328:MapInput();break; - case 200:RestartMovieOrReset(0);break; - case 201:RestartMovieOrReset(1);break; - case 40026: FCEUI_FDSSelect();break; - case 40001: FCEUI_FDSInsert();break; - case 40027: FCEUI_VSUniCoin();break; + case MENU_RESET: + // The reset menu was selected + RestartMovieOrReset(0); + break; + + case MENU_POWER: + // The power menu was selected + RestartMovieOrReset(1); + break; + + case MENU_SWITCH_DISK: + // Switch disk menu was selected + FCEUI_FDSSelect(); + break; + + case MENU_EJECT_DISK: + // Eject disk menu was selected + FCEUI_FDSInsert(); + break; + + case MENU_INSERT_COIN: + // Insert coin menu was selected + FCEUI_VSUniCoin(); + break; #ifdef FCEUDEF_DEBUGGER @@ -900,7 +1005,7 @@ LRESULT FAR PASCAL AppWndProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) { if(!(lParam&(1<<30))) { - UpdateMenu(); + UpdateCheckedMenuItems(); changerecursive=1; if(!SetVideoMode(fullscreen^1)) SetVideoMode(fullscreen); @@ -2097,8 +2202,8 @@ void FCEUD_MovieReplayFrom(void) free(fn); - palyo = FCEUI_GetCurrentVidSystem(0,0); - UpdateMenu(); + pal_emulation = FCEUI_GetCurrentVidSystem(0,0); + UpdateCheckedMenuItems(); FixFL(); SetMainWindowStuff(); RefreshThrottleFPS(); diff --git a/src/fceu.cpp b/src/fceu.cpp index 2a301a71..18c31ff1 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -69,7 +69,9 @@ static int EmulationPaused=0; static int RewindStatus[4] = {0, 0, 0, 0}; //is it safe to load rewind state static int RewindIndex = 0; //which rewind state we're on -int EnableRewind = 0; //is rewind enabled + +// Flag that indicates whether the rewind option is enabled or not +int EnableRewind = 0; ///a wrapper for unzip.c extern "C" FILE *FCEUI_UTF8fopen_C(const char *n, const char *m) { return ::FCEUD_UTF8fopen(n,m); } @@ -503,21 +505,32 @@ void FCEUI_CloseGame(void) CloseGame(); } -void RestartMovieOrReset(int pow) +/** +* @param do_power_off Power off (1) or reset (0) +**/ +void RestartMovieOrReset(unsigned int do_power_off) { extern int movie_readonly; + extern char curMovieFilename[512]; + if(FCEUMOV_IsPlaying() || FCEUMOV_IsRecording() && movie_readonly) { - extern char curMovieFilename[512]; FCEUI_LoadMovie(curMovieFilename, movie_readonly, 0); + if(FCEUI_IsMovieActive()) + { return; + } } - if(pow) + if(do_power_off) + { FCEUI_PowerNES(); + } else + { FCEUI_ResetNES(); + } } void ResetNES(void) @@ -676,9 +689,12 @@ int FCEUI_GetCurrentVidSystem(int *slstart, int *slend) return(PAL); } +/** +* Enable or disable Game Genie option. +**/ void FCEUI_SetGameGenie(int a) { - FSettings.GameGenie=a?1:0; + FSettings.GameGenie = a ? 1 : 0; } void FCEUI_SetSnapName(int a) diff --git a/src/input.cpp b/src/input.cpp index ba261257..f72f2159 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -507,11 +507,17 @@ void FCEUI_VSUniCoin(void) FCEU_QSimpleCommand(FCEUNPCMD_VSUNICOIN); } +/** +* Resets the NES +**/ void FCEUI_ResetNES(void) { FCEU_QSimpleCommand(FCEUNPCMD_RESET); } - + +/** +* Powers off the NES +**/ void FCEUI_PowerNES(void) { FCEU_QSimpleCommand(FCEUNPCMD_POWER);