/*********************************************************************************** Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com), Jerremy Koot (jkoot@snes9x.com) (c) Copyright 2002 - 2004 Matthew Kendora (c) Copyright 2002 - 2005 Peter Bortas (peter@bortas.org) (c) Copyright 2004 - 2005 Joel Yliluoma (http://iki.fi/bisqwit/) (c) Copyright 2001 - 2006 John Weidman (jweidman@slip.net) (c) Copyright 2002 - 2006 funkyass (funkyass@spam.shaw.ca), Kris Bleakley (codeviolation@hotmail.com) (c) Copyright 2002 - 2010 Brad Jorsch (anomie@users.sourceforge.net), Nach (n-a-c-h@users.sourceforge.net), (c) Copyright 2002 - 2011 zones (kasumitokoduck@yahoo.com) (c) Copyright 2006 - 2007 nitsuja (c) Copyright 2009 - 2011 BearOso, OV2 BS-X C emulator code (c) Copyright 2005 - 2006 Dreamer Nom, zones C4 x86 assembler and some C emulation code (c) Copyright 2000 - 2003 _Demo_ (_demo_@zsnes.com), Nach, zsKnight (zsknight@zsnes.com) C4 C++ code (c) Copyright 2003 - 2006 Brad Jorsch, Nach DSP-1 emulator code (c) Copyright 1998 - 2006 _Demo_, Andreas Naive (andreasnaive@gmail.com), Gary Henderson, Ivar (ivar@snes9x.com), John Weidman, Kris Bleakley, Matthew Kendora, Nach, neviksti (neviksti@hotmail.com) DSP-2 emulator code (c) Copyright 2003 John Weidman, Kris Bleakley, Lord Nightmare (lord_nightmare@users.sourceforge.net), Matthew Kendora, neviksti DSP-3 emulator code (c) Copyright 2003 - 2006 John Weidman, Kris Bleakley, Lancer, z80 gaiden DSP-4 emulator code (c) Copyright 2004 - 2006 Dreamer Nom, John Weidman, Kris Bleakley, Nach, z80 gaiden OBC1 emulator code (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com), Kris Bleakley Ported from x86 assembler to C by sanmaiwashi SPC7110 and RTC C++ emulator code used in 1.39-1.51 (c) Copyright 2002 Matthew Kendora with research by zsKnight, John Weidman, Dark Force SPC7110 and RTC C++ emulator code used in 1.52+ (c) Copyright 2009 byuu, neviksti S-DD1 C emulator code (c) Copyright 2003 Brad Jorsch with research by Andreas Naive, John Weidman S-RTC C emulator code (c) Copyright 2001 - 2006 byuu, John Weidman ST010 C++ emulator code (c) Copyright 2003 Feather, John Weidman, Kris Bleakley, Matthew Kendora Super FX x86 assembler emulator code (c) Copyright 1998 - 2003 _Demo_, pagefault, zsKnight Super FX C emulator code (c) Copyright 1997 - 1999 Ivar, Gary Henderson, John Weidman Sound emulator code used in 1.5-1.51 (c) Copyright 1998 - 2003 Brad Martin (c) Copyright 1998 - 2006 Charles Bilyue' Sound emulator code used in 1.52+ (c) Copyright 2004 - 2007 Shay Green (gblargg@gmail.com) SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) 2xSaI filter (c) Copyright 1999 - 2001 Derek Liauw Kie Fa HQ2x, HQ3x, HQ4x filters (c) Copyright 2003 Maxim Stepin (maxim@hiend3d.com) NTSC filter (c) Copyright 2006 - 2007 Shay Green GTK+ GUI code (c) Copyright 2004 - 2011 BearOso Win32 GUI code (c) Copyright 2003 - 2006 blip, funkyass, Matthew Kendora, Nach, nitsuja (c) Copyright 2009 - 2011 OV2 Mac OS GUI code (c) Copyright 1998 - 2001 John Stiles (c) Copyright 2001 - 2011 zones Specific ports contains the works of other authors. See headers in individual files. Snes9x homepage: http://www.snes9x.com/ Permission to use, copy, modify and/or distribute Snes9x in both binary and source form, for non-commercial purposes, is hereby granted without fee, providing that this license information and copyright notice appear with all copies and any derived work. This software is provided 'as-is', without any express or implied warranty. In no event shall the authors be held liable for any damages arising from the use of this software or it's derivatives. Snes9x is freeware for PERSONAL USE only. Commercial users should seek permission of the copyright holders first. Commercial use includes, but is not limited to, charging money for Snes9x or software derived from Snes9x, including Snes9x or derivatives in commercial game bundles, and/or using Snes9x as a promotion for your commercial product. The copyright holders request that bug fixes and improvements to the code should be forwarded to them so everyone can benefit from the modifications in future versions. Super NES and Super Nintendo Entertainment System are trademarks of Nintendo Co., Limited and its subsidiary companies. ***********************************************************************************/ // all windows-specific command line and config file parsing/saving/loading // this stuff was moved out of wsnes.cpp, to keep things a little tidier // note: // if you want to force all users of a new version to have a // particular setting reset to its given default, // change the name string of that setting (in WinRegisterConfigItems) // to something a little different... // but if it's not in a windows-specific category, make sure you change its name elsewhere too #include "../port.h" #include "../snes9x.h" #include "wsnes9x.h" #include "wlanguage.h" #include "../display.h" #include "../conffile.h" #include "../spc7110.h" #include "../gfx.h" #include "../snapshot.h" #ifdef NETPLAY_SUPPORT #include "../netplay.h" extern SNPServer NPServer; #endif #include static void WinDeleteRegistryEntries (); void WinSetDefaultValues (); void WinDeleteRecentGamesList (); HANDLE configMutex = NULL; void S9xParseArg (char **argv, int &i, int argc) { if (strcasecmp (argv [i], "-restore") == 0) { WinDeleteRegistryEntries (); WinSetDefaultValues (); } else if (strcasecmp (argv[i], "-hidemenu") == 0) { GUI.HideMenu = true; } else if (strcasecmp (argv[i], "-fullscreen") == 0) { GUI.FullScreen = true; } } extern TCHAR multiRomA [MAX_PATH]; // lazy, should put in sGUI and add init to {0} somewhere extern TCHAR multiRomB [MAX_PATH]; void WinSetDefaultValues () { // TODO: delete the parts that are already covered by the default values in WinRegisterConfigItems char temp[4]; strcpy(temp,"C:\\"); GUI.ControllerOption = SNES_JOYPAD; GUI.ValidControllerOptions = 0xFFFF; GUI.IgnoreNextMouseMove = false; GUI.DoubleBuffered = false; GUI.FullScreen = false; GUI.Stretch = false; GUI.FlipCounter = 0; GUI.NumFlipFrames = 1; GUI.BilinearFilter = false; GUI.LockDirectories = false; GUI.window_maximized = false; GUI.EmulatedFullscreen = false; WinDeleteRecentGamesList (); GUI.SoundChannelEnable=255; // Tracing options Settings.TraceDMA = false; Settings.TraceHDMA = false; Settings.TraceVRAM = false; Settings.TraceUnknownRegisters = false; Settings.TraceDSP = false; // ROM timing options (see also H_Max above) Settings.PAL = false; Settings.FrameTimePAL = 20000; Settings.FrameTimeNTSC = 16667; Settings.FrameTime = 16667; // CPU options Settings.Paused = false; // ROM image and peripheral options Settings.MultiPlayer5Master = false; Settings.SuperScopeMaster = false; Settings.MouseMaster = false; #ifdef NETPLAY_SUPPORT Settings.Port = 1996; NetPlay.MaxFrameSkip = 10; NetPlay.MaxBehindFrameCount = 10; NPServer.SyncByReset = true; NPServer.SendROMImageOnConnect = false; #endif Settings.TakeScreenshot=false; GUI.Language=0; } static bool try_save(const char *fname, ConfigFile &conf){ STREAM fp; if((fp=OPEN_STREAM(fname, "w"))!=NULL){ fprintf(stdout, "Saving config file %s\n", fname); CLOSE_STREAM(fp); conf.SaveTo(fname); return true; } return false; } static char rom_filename [MAX_PATH] = {0}; static bool S9xSaveConfigFile(ConfigFile &conf){ configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex")); int times = 0; DWORD waitVal = WAIT_TIMEOUT; while(waitVal == WAIT_TIMEOUT && ++times <= 150) // wait at most 15 seconds waitVal = WaitForSingleObject(configMutex, 100); // save over the .conf file if it already exists, otherwise save over the .cfg file std::string fname; fname=S9xGetDirectory(DEFAULT_DIR); fname+=SLASH_STR S9X_CONF_FILE_NAME; // ensure previous config file is not lost if we crash while writing the new one std::string ftemp; { CopyFileA(fname.c_str(), (fname + ".autobak").c_str(), FALSE); ftemp=S9xGetDirectory(DEFAULT_DIR); ftemp+=SLASH_STR "config_error"; FILE* tempfile = fopen(ftemp.c_str(), "wb"); if(tempfile) fclose(tempfile); } bool ret = try_save(fname.c_str(), conf); remove(ftemp.c_str()); remove((fname + ".autobak").c_str()); ReleaseMutex(configMutex); CloseHandle(configMutex); return ret; } static void WinDeleteRegistryEntries () { // WinDeleteRegKey (HKEY_CURRENT_USER, S9X_REG_KEY_BASE); } static inline char *SkipSpaces (char *p) { while (*p && isspace (*p)) p++; return (p); } const char* WinParseCommandLineAndLoadConfigFile (char *line) { // Break the command line up into an array of string pointers, each pointer // points at a separate word or character sequence enclosed in quotes. #define MAX_PARAMETERS 100 char *p = line; static char *parameters [MAX_PARAMETERS]; int count = 0; //parameters [count++] = "Snes9X"; while (count < MAX_PARAMETERS && *p) { p = SkipSpaces (p); if (*p == '"') { p++; parameters [count++] = p; while (*p && *p != '"') p++; *p++ = 0; } else if (*p == '\'') { p++; parameters [count++] = p; while (*p && *p != '\'') p++; *p++ = 0; } else { parameters [count++] = p; while (*p && !isspace (*p)) p++; if (!*p) break; *p++ = 0; } } configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex")); int times = 0; DWORD waitVal = WAIT_TIMEOUT; while(waitVal == WAIT_TIMEOUT && ++times <= 150) // wait at most 15 seconds waitVal = WaitForSingleObject(configMutex, 100); // ensure previous config file is not lost if we crashed while writing a new one { std::string ftemp; ftemp=S9xGetDirectory(DEFAULT_DIR); ftemp+=SLASH_STR "config_error"; FILE* tempfile = fopen(ftemp.c_str(), "rb"); if(tempfile) { fclose(tempfile); std::string fname; for(int i=0; i<2; i++) { fname=S9xGetDirectory(DEFAULT_DIR); if(i == 0) fname+=SLASH_STR "snes9x.conf"; else if(i == 1) fname+=SLASH_STR "snes9x.cfg"; tempfile = fopen((fname + ".autobak").c_str(), "rb"); if(tempfile) { fclose(tempfile); MoveFileExA((fname + ".autobak").c_str(), fname.c_str(), MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH); } } remove(ftemp.c_str()); } } S9xLoadConfigFiles(parameters, count); ReleaseMutex(configMutex); CloseHandle(configMutex); const char* rf = S9xParseArgs (parameters, count); /*if(rf) strcpy(rom_filename, rf); else rom_filename[0] = '\0';*/ return rf; } #define S(x) GAMEDEVICE_VK_##x #define SO(x) GAMEDEVICE_VK_OEM_##x static const char* keyToString [256] = { "Unassigned","LMB","RMB","Break","MMB","XMB1","XMB2","0x07", S(BACK),S(TAB),"0x0A","0x0B",S(CLEAR),S(RETURN),"0x0E","0x0F", S(SHIFT),S(CONTROL),S(MENU),S(PAUSE),S(CAPITAL),"Kana","0x16","Junja", "Final","Kanji","0x1A",S(ESCAPE),"Convert","NonConvert","Accept","ModeChange", S(SPACE),S(PRIOR),S(NEXT),S(END),S(HOME),S(LEFT),S(UP),S(RIGHT), S(DOWN),S(SELECT),S(PRINT),S(EXECUTE),S(SNAPSHOT),S(INSERT),S(DELETE),S(HELP), "0","1","2","3","4","5","6","7", "8","9","0x3A","0x3B","0x3C","0x3D","0x3E","0x3F", "0x40","A","B","C","D","E","F","G", "H","I","J","K","L","M","N","O", "P","Q","R","S","T","U","V","W", "X","Y","Z",S(LWIN),S(RWIN),S(APPS),"0x5E","Sleep", "Pad0","Pad1","Pad2","Pad3","Pad4","Pad5","Pad6","Pad7", "Pad8","Pad9",S(MULTIPLY),S(ADD),S(SEPARATOR),S(SUBTRACT),S(DECIMAL),S(DIVIDE), S(F1),S(F2),S(F3),S(F4),S(F5),S(F6),S(F7),S(F8), S(F9),S(F10),S(F11),S(F12),"F13","F14","F15","F16", "F17","F18","F19","F20","F21","F22","F23","F24", "0x88","0x89","0x8A","0x8B","0x8C","0x8D","0x8E","0x8F", S(NUMLOCK),S(SCROLL),"PadEqual","Masshou","Touroku","Loya","Roya","0x97", "0x98","0x99","0x9A","0x9B","0x9C","0x9D","0x9E","0x9F", S(LSHIFT),S(RSHIFT),S(LCONTROL),S(RCONTROL),S(LMENU),S(RMENU),"BrowserBack","BrowserForward", "BrowserRefresh","BrowserStop","BrowserSearch","BrowserFavorites","BrowserHome","VolumeMute","VolumeDown","VolumeUp", "MediaNextTrack","MediaPrevTrack","MediaStop","MediaPlayPause","LaunchMail","MediaSelect","LaunchApp1","LaunchApp2", "0xB8","0xB9",";","+",",",SO(MINUS),".",SO(2), SO(3),"0xC1","0xC2","0xC3","0xC4","0xC5","0xC6","0xC7", "0xC8","0xC9","0xCA","0xCB","0xCC","0xCD","0xCE","0xCF", "0xD0","0xD1","0xD2","0xD3","0xD4","0xD5","0xD6","0xD7", "0xD8","0xD9","0xDA",SO(4),"Backslash",SO(6),"'","OEM8", "0xE0","AX","<>","ICOHelp","ICO00","Process","ICOClear","Packet", "0xE8","Reset","Jump","PA1_2","PA2","PA3","WSCTRL","CUSEL", "Attention2","Finish","Copy","Auto","ENLW","Backtab","Attention","CRSEL", "EXSEL","EREOF","Play","Zoom","NoName","PA1","Clear2","0xFF" }; static const char* keyToAlternateString [256] = { "none","LeftClick","RightClick","Cancel","MiddleClick","","","","Back","","","","","Return","","", "","","Menu","","","","","","","","","Escape","","","","", "","PageUp","PageDown","","","","","","","","PrintScreen","","","Ins","Del","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "NumLock","ScrollLock","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","",SO(1),SO(PLUS),SO(COMMA),"Minus",SO(PERIOD),"?", "","","","","","","","","","","","","","","","", "","","","oem_pa1","","","","","","","","LBracket","|","RBracket",SO(7),"", "ATTN2","","","","","","","","","","","","","","ATTN","", "","","","","","","","","","","","","","","","" }; #undef S #undef SO // We will maintain our own list of items to put in the config file, // so that each config item has only one point of change across both saving and loading // and to allow us to manage custom types of config items, such as virtual key codes represented as strings enum ConfigItemType { CIT_BOOL, CIT_INT, CIT_UINT, CIT_STRING, CIT_INVBOOL, CIT_BOOLONOFF, CIT_INVBOOLONOFF, CIT_VKEY, CIT_VKEYMOD }; struct ConfigItem { const char* name; void* addr; int size; void* def; const char* comment; ConfigItemType type; ConfigItem(const char* nname, void* naddr, int nsize, void* ndef, const char* ncomment, ConfigItemType ntype) { addr = naddr; name = nname; size = nsize; def = ndef; comment = ncomment; type = ntype; } void Get(ConfigFile& conf) { switch(type) { case CIT_BOOL: case CIT_BOOLONOFF: if(size == 1) *(uint8 *)addr = (uint8) conf.GetBool(name, def!=0); if(size == 2) *(uint16*)addr = (uint16)conf.GetBool(name, def!=0); if(size == 4) *(uint32*)addr = (uint32)conf.GetBool(name, def!=0); if(size == 8) *(uint64*)addr = (uint64)conf.GetBool(name, def!=0); break; case CIT_INT: if(size == 1) *(uint8 *)addr = (uint8) conf.GetInt(name, reinterpret_cast(def)); if(size == 2) *(uint16*)addr = (uint16)conf.GetInt(name, reinterpret_cast(def)); if(size == 4) *(uint32*)addr = (uint32)conf.GetInt(name, reinterpret_cast(def)); if(size == 8) *(uint64*)addr = (uint64)conf.GetInt(name, reinterpret_cast(def)); break; case CIT_UINT: if(size == 1) *(uint8 *)addr = (uint8) conf.GetUInt(name, reinterpret_cast(def)); if(size == 2) *(uint16*)addr = (uint16)conf.GetUInt(name, reinterpret_cast(def)); if(size == 4) *(uint32*)addr = (uint32)conf.GetUInt(name, reinterpret_cast(def)); if(size == 8) *(uint64*)addr = (uint64)conf.GetUInt(name, reinterpret_cast(def)); break; case CIT_STRING: lstrcpyn((TCHAR*)addr, _tFromChar(conf.GetString(name, reinterpret_cast(def))), size-1); ((TCHAR*)addr)[size-1] = TEXT('\0'); break; case CIT_INVBOOL: case CIT_INVBOOLONOFF: if(size == 1) *(uint8 *)addr = (uint8) !conf.GetBool(name, def!=0); if(size == 2) *(uint16*)addr = (uint16)!conf.GetBool(name, def!=0); if(size == 4) *(uint32*)addr = (uint32)!conf.GetBool(name, def!=0); if(size == 8) *(uint64*)addr = (uint64)!conf.GetBool(name, def!=0); break; case CIT_VKEY: { uint16 keyNum = (uint16)conf.GetUInt(name, reinterpret_cast(def)); const char* keyStr = conf.GetString(name); if(keyStr) { for(int i=0;i<512;i++) { if(i<256) // keys { if(!strcasecmp(keyStr,keyToString[i]) || (*keyToAlternateString[i] && !strcasecmp(keyStr,keyToAlternateString[i]))) { keyNum = i; break; } } else // joystick: { char temp [128]; extern void TranslateKey(WORD keyz,char *out); TranslateKey(0x8000|(i-256),temp); if(strlen(keyStr)>3 && !strcasecmp(keyStr+3,temp+3)) { for(int j = 0 ; j < 16 ; j++) { if(keyStr[2]-'0' == j || keyStr[2]-'a' == j-10) { keyNum = 0x8000|(i-256)|(j<<8); i = 512; break; } } } } } } if(size == 1) *(uint8 *)addr = (uint8) keyNum; if(size == 2) *(uint16*)addr = (uint16)keyNum; if(size == 4) *(uint32*)addr = (uint32)keyNum; if(size == 8) *(uint64*)addr = (uint64)keyNum; } break; case CIT_VKEYMOD: { uint16 modNum = 0; const char* modStr = conf.GetString(name); if(modStr) { if(strstr(modStr, "ft") || strstr(modStr, "FT")) modNum |= CUSTKEY_SHIFT_MASK; if(strstr(modStr, "tr") || strstr(modStr, "TR")) modNum |= CUSTKEY_CTRL_MASK; if(strstr(modStr, "lt") || strstr(modStr, "LT")) modNum |= CUSTKEY_ALT_MASK; } if(!modNum && (!modStr || strcasecmp(modStr, "none"))) modNum = conf.GetUInt(name, reinterpret_cast(def)); if(size == 1) *(uint8 *)addr = (uint8) modNum; if(size == 2) *(uint16*)addr = (uint16)modNum; if(size == 4) *(uint32*)addr = (uint32)modNum; if(size == 8) *(uint64*)addr = (uint64)modNum; } break; } // if it had a comment, override our own with it const char* newComment = conf.GetComment(name); if(newComment && *newComment) comment = newComment; } void Set(ConfigFile& conf) { switch(type) { case CIT_BOOL: if(size == 1) conf.SetBool(name, 0!=(*(uint8 *)addr), "TRUE","FALSE", comment); if(size == 2) conf.SetBool(name, 0!=(*(uint16*)addr), "TRUE","FALSE", comment); if(size == 4) conf.SetBool(name, 0!=(*(uint32*)addr), "TRUE","FALSE", comment); if(size == 8) conf.SetBool(name, 0!=(*(uint64*)addr), "TRUE","FALSE", comment); break; case CIT_BOOLONOFF: if(size == 1) conf.SetBool(name, 0!=(*(uint8 *)addr), "ON","OFF", comment); if(size == 2) conf.SetBool(name, 0!=(*(uint16*)addr), "ON","OFF", comment); if(size == 4) conf.SetBool(name, 0!=(*(uint32*)addr), "ON","OFF", comment); if(size == 8) conf.SetBool(name, 0!=(*(uint64*)addr), "ON","OFF", comment); break; case CIT_INT: if(size == 1) conf.SetInt(name, (int32)(*(uint8 *)addr), comment); if(size == 2) conf.SetInt(name, (int32)(*(uint16*)addr), comment); if(size == 4) conf.SetInt(name, (int32)(*(uint32*)addr), comment); if(size == 8) conf.SetInt(name, (int32)(*(uint64*)addr), comment); break; case CIT_UINT: if(size == 1) conf.SetUInt(name, (uint32)(*(uint8 *)addr), 10, comment); if(size == 2) conf.SetUInt(name, (uint32)(*(uint16*)addr), 10, comment); if(size == 4) conf.SetUInt(name, (uint32)(*(uint32*)addr), 10, comment); if(size == 8) conf.SetUInt(name, (uint32)(*(uint64*)addr), 10, comment); break; case CIT_STRING: if((TCHAR*)addr) conf.SetString(name, std::string(_tToChar((TCHAR*)addr)), comment); break; case CIT_INVBOOL: if(size == 1) conf.SetBool(name, 0==(*(uint8 *)addr), "TRUE","FALSE", comment); if(size == 2) conf.SetBool(name, 0==(*(uint16*)addr), "TRUE","FALSE", comment); if(size == 4) conf.SetBool(name, 0==(*(uint32*)addr), "TRUE","FALSE", comment); if(size == 8) conf.SetBool(name, 0==(*(uint64*)addr), "TRUE","FALSE", comment); break; case CIT_INVBOOLONOFF: if(size == 1) conf.SetBool(name, 0==(*(uint8 *)addr), "ON","OFF", comment); if(size == 2) conf.SetBool(name, 0==(*(uint16*)addr), "ON","OFF", comment); if(size == 4) conf.SetBool(name, 0==(*(uint32*)addr), "ON","OFF", comment); if(size == 8) conf.SetBool(name, 0==(*(uint64*)addr), "ON","OFF", comment); break; case CIT_VKEY: { uint16 keyNum = 0; if(size == 1) keyNum = (uint8)(*(uint8 *)addr); if(size == 2) keyNum = (uint16)(*(uint16*)addr); if(size == 4) keyNum = (uint16)(*(uint32*)addr); if(size == 8) keyNum = (uint16)(*(uint64*)addr); if(keyNum < 256) conf.SetString(name, keyToString[keyNum], comment); else if(keyNum & 0x8000) { char temp [128]; extern void TranslateKey(WORD keyz,char *out); TranslateKey(keyNum,temp); conf.SetString(name, temp, comment); } else conf.SetUInt(name, keyNum, 16, comment); } break; case CIT_VKEYMOD: { uint16 modNum = 0; if(size == 1) modNum = (uint8)(*(uint8 *)addr); if(size == 2) modNum = (uint16)(*(uint16*)addr); if(size == 4) modNum = (uint16)(*(uint32*)addr); if(size == 8) modNum = (uint16)(*(uint64*)addr); std::string modStr; if(modNum & CUSTKEY_CTRL_MASK) modStr += "Ctrl "; if(modNum & CUSTKEY_ALT_MASK) modStr += "Alt "; if(modNum & CUSTKEY_SHIFT_MASK) modStr += "Shift "; if(!(modNum & (CUSTKEY_CTRL_MASK|CUSTKEY_ALT_MASK|CUSTKEY_SHIFT_MASK))) modStr = "none"; else modStr.erase(modStr.length()-1); conf.SetString(name, modStr, comment); } break; } } }; std::vector configItems; // var must be a persistent variable. In the case of strings, it must point to a writeable character array. #define AddItemC(name, var, def, comment, type) configItems.push_back(ConfigItem((const char*)(CATEGORY "::" name), (void*)(&var), sizeof(var), (void*)(pint)def, (const char*)comment, (ConfigItemType)type)) #define AddItem(name, var, def, type) AddItemC(name,var,def,"",type) #define AddUInt(name, var, def) AddItem(name,var,def,CIT_UINT) #define AddInt(name, var, def) AddItem(name,var,def,CIT_INT) #define AddBool(name, var, def) AddItem(name,var,def,CIT_BOOL) #define AddBool2(name, var, def) AddItem(name,var,def,CIT_BOOLONOFF) #define AddInvBool(name, var, def) AddItem(name,var,def,CIT_INVBOOL) #define AddInvBool2(name, var, def) AddItem(name,var,def,CIT_INVBOOLONOFF) #define AddVKey(name, var, def) AddItem(name,var,def,CIT_VKEY) #define AddVKMod(name, var, def) AddItem(name,var,def,CIT_VKEYMOD) #define AddUIntC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_UINT) #define AddIntC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_INT) #define AddBoolC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_BOOL) #define AddBool2C(name, var, def, comment) AddItemC(name,var,def,comment,CIT_BOOLONOFF) #define AddInvBoolC(name, var, def, comment) AddItemC(name,var,def,comment,CIT_INVBOOL) #define AddInvBool2C(name, var, def, comment) AddItemC(name,var,def,comment,CIT_INVBOOLONOFF) #define AddStringC(name, var, buflen, def, comment) configItems.push_back(ConfigItem((const char*)(CATEGORY "::" name), (void*)var, buflen, (void*)(pint)def, (const char*)comment, CIT_STRING)) #define AddString(name, var, buflen, def) AddStringC(name, var, buflen, def, "") static char filterString [1024], filterString2 [1024], snapVerString [256]; static bool niceAlignment, showComments, readOnlyConfig; static int configSort; void WinPreSave(ConfigFile& conf) { strcpy(filterString, "output filter: "); for(int i=0;i MAX_RECENT_GAMES_LIST_SIZE) GUI.MaxRecentGames = MAX_RECENT_GAMES_LIST_SIZE; if(GUI.rewindGranularity==0) GUI.rewindGranularity = 1; bool gap = false; for(i=0;i