From 13de73daf2f868dbd0a47c149f5ab9e625231e61 Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 3 Jul 2008 15:33:04 +0000 Subject: [PATCH] Autofire pattern now remembered in config file. --- src/drivers/win/config.cpp | 3 +++ src/drivers/win/main.cpp | 2 +- src/drivers/win/main.h | 2 ++ src/drivers/win/window.cpp | 26 +++++++++++++++++++++++++- src/fceu.cpp | 4 ++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 2ec61ca7..e310cd7d 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -57,6 +57,7 @@ extern int CDLogger_wndx, CDLogger_wndy; extern int GGConv_wndx, GGConv_wndy; extern int TasEdit_wndx, TasEdit_wndy; extern int EnableAutosave; +extern int AFon, AFoff; //Structure that contains configuration information static CFGSTRUCT fceuconfig[] = { @@ -189,6 +190,8 @@ static CFGSTRUCT fceuconfig[] = { AC(TasEdit_wndy), AC(pauseAfterPlayback), + AC(AFon), + AC(AFoff), //ACS(memwLastfile[2048]), ENDCFGSTRUCT diff --git a/src/drivers/win/main.cpp b/src/drivers/win/main.cpp index 4e14958e..f65fe908 100644 --- a/src/drivers/win/main.cpp +++ b/src/drivers/win/main.cpp @@ -664,7 +664,7 @@ int main(int argc,char *argv[]) } if (MemWatchLoadOnStart) CreateMemWatch(); if (PauseAfterLoad) FCEUI_ToggleEmulationPause(); - + SetAutoFirePattern(AFon, AFoff); UpdateCheckedMenuItems(); doloopy: UpdateFCEUWindow(); diff --git a/src/drivers/win/main.h b/src/drivers/win/main.h index 9bcd14bb..3ad62bb5 100644 --- a/src/drivers/win/main.h +++ b/src/drivers/win/main.h @@ -39,6 +39,8 @@ extern int input_display; extern int allowUDLR; extern int pauseAfterPlayback; extern int EnableBackgroundInput; +extern int AFon; +extern int AFoff; extern int vmod; diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 40237b63..99554452 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -112,6 +112,30 @@ static uint32 mousex,mousey,mouseb; static int vchanged = 0; +int GetCheckedAutoFirePattern(); + +int GetCheckedAutoFirePattern() +{ +//adelikat: sorry, I'm sure there is an easier way to accomplish this. +//This function allows the proper check to be displayed on the auto-fire pattern offset at start up when another autofire pattern is saved in config + if (AFon == 1 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_2; + if (AFon == 1 && AFoff == 3) return MENU_AUTOFIRE_PATTERN_3; + if (AFon == 1 && AFoff == 4) return MENU_AUTOFIRE_PATTERN_4; + if (AFon == 1 && AFoff == 5) return MENU_AUTOFIRE_PATTERN_5; + if (AFon == 2 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_6; + if (AFon == 2 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_7; + if (AFon == 2 && AFoff == 3) return MENU_AUTOFIRE_PATTERN_8; + if (AFon == 2 && AFoff == 4) return MENU_AUTOFIRE_PATTERN_9; + if (AFon == 3 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_10; + if (AFon == 3 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_11; + if (AFon == 3 && AFoff == 3) return MENU_AUTOFIRE_PATTERN_12; + if (AFon == 4 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_13; + if (AFon == 4 && AFoff == 2) return MENU_AUTOFIRE_PATTERN_14; + if (AFon == 5 && AFoff == 1) return MENU_AUTOFIRE_PATTERN_15; + +return MENU_AUTOFIRE_PATTERN_1; +} + // Internal functions void SplitRecentArchiveFilename(std::string src, std::string& archive, std::string& file) @@ -311,7 +335,7 @@ void UpdateCheckedMenuItems() 0}; x = 0; - + CheckedAutoFirePattern = GetCheckedAutoFirePattern(); while(AutoFirePatternIDs[x]) { CheckMenuItem(fceumenu, AutoFirePatternIDs[x], diff --git a/src/fceu.cpp b/src/fceu.cpp index 84e32a85..4aa64589 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -52,10 +52,13 @@ //TODO - we really need some kind of global platform-specific options api #ifdef WIN32 #include "drivers/win/main.h" + #else #include "drivers/sdl/sdl.h" #endif +int AFon, AFoff; + static void CloseGame(void) { if(GameInfo) @@ -465,6 +468,7 @@ void SetAutoFirePattern(int onframes, int offframes) { AutoFirePatternLength = onframes + offframes; } + AFon = onframes; AFoff = offframes; } void SetAutoFireOffset(int offset)