diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f4d4b9a..61ca6e15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -185,6 +185,9 @@ add_subdirectory (fex)
SET(SRC_MAIN
src/Util.cpp
+ src/common/ConfigManager.cpp
+ src/common/dictionary.c
+ src/common/iniparser.c
src/common/Patch.cpp
src/common/memgzio.c
src/common/SoundSDL.cpp
diff --git a/project/vs2010_mfc/VBA-M-MFC.vcxproj b/project/vs2010_mfc/VBA-M-MFC.vcxproj
index dd8411f4..09033723 100644
--- a/project/vs2010_mfc/VBA-M-MFC.vcxproj
+++ b/project/vs2010_mfc/VBA-M-MFC.vcxproj
@@ -242,6 +242,7 @@
+
true
diff --git a/project/vs2010_mfc/VBA-M-MFC.vcxproj.filters b/project/vs2010_mfc/VBA-M-MFC.vcxproj.filters
index f8dc21a7..c2261848 100644
--- a/project/vs2010_mfc/VBA-M-MFC.vcxproj.filters
+++ b/project/vs2010_mfc/VBA-M-MFC.vcxproj.filters
@@ -535,6 +535,9 @@
MFC
+
+ Main
+
diff --git a/project/vs2010_mfc/VBA2010.vcxproj b/project/vs2010_mfc/VBA2010.vcxproj
index 962496bd..5d80ab66 100644
--- a/project/vs2010_mfc/VBA2010.vcxproj
+++ b/project/vs2010_mfc/VBA2010.vcxproj
@@ -150,6 +150,9 @@
+
+
+
@@ -201,6 +204,9 @@
+
+
+
diff --git a/project/vs2010_mfc/VBA2010.vcxproj.filters b/project/vs2010_mfc/VBA2010.vcxproj.filters
index ee53175a..894deea5 100644
--- a/project/vs2010_mfc/VBA2010.vcxproj.filters
+++ b/project/vs2010_mfc/VBA2010.vcxproj.filters
@@ -156,6 +156,15 @@
Linking
+
+ Functionality
+
+
+ Functionality
+
+
+ Functionality
+
@@ -313,5 +322,14 @@
Linking
+
+ Functionality
+
+
+ Functionality
+
+
+ Functionality
+
\ No newline at end of file
diff --git a/project/vs2013_mfc/VBA-M-MFC.vcxproj b/project/vs2013_mfc/VBA-M-MFC.vcxproj
index fc69a38b..afdb7d33 100644
--- a/project/vs2013_mfc/VBA-M-MFC.vcxproj
+++ b/project/vs2013_mfc/VBA-M-MFC.vcxproj
@@ -249,6 +249,7 @@
+
true
diff --git a/project/vs2013_mfc/VBA-M-MFC.vcxproj.filters b/project/vs2013_mfc/VBA-M-MFC.vcxproj.filters
index f8dc21a7..c2261848 100644
--- a/project/vs2013_mfc/VBA-M-MFC.vcxproj.filters
+++ b/project/vs2013_mfc/VBA-M-MFC.vcxproj.filters
@@ -535,6 +535,9 @@
MFC
+
+ Main
+
diff --git a/project/vs2013_mfc/VBA2013.vcxproj b/project/vs2013_mfc/VBA2013.vcxproj
index 8141f76b..34189ef7 100644
--- a/project/vs2013_mfc/VBA2013.vcxproj
+++ b/project/vs2013_mfc/VBA2013.vcxproj
@@ -156,6 +156,9 @@
+
+
+
@@ -207,6 +210,9 @@
+
+
+
diff --git a/project/vs2013_mfc/VBA2013.vcxproj.filters b/project/vs2013_mfc/VBA2013.vcxproj.filters
index ee53175a..638c0d2d 100644
--- a/project/vs2013_mfc/VBA2013.vcxproj.filters
+++ b/project/vs2013_mfc/VBA2013.vcxproj.filters
@@ -156,6 +156,15 @@
Linking
+
+ Functionality
+
+
+ Functionality
+
+
+ Functionality
+
@@ -313,5 +322,14 @@
Linking
+
+ Functionality
+
+
+ Functionality
+
+
+ Functionality
+
\ No newline at end of file
diff --git a/src/common/ConfigManager.cpp b/src/common/ConfigManager.cpp
new file mode 100644
index 00000000..2c7a874e
--- /dev/null
+++ b/src/common/ConfigManager.cpp
@@ -0,0 +1,1349 @@
+#include "ConfigManager.h"
+extern "C" {
+#include "../common/iniparser.h"
+}
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "../AutoBuild.h"
+#include "../svnrev.h"
+
+#include "../common/Patch.h"
+#include "../common/ConfigManager.h"
+#include "../gba/GBA.h"
+#include "../gba/agbprint.h"
+#include "../gba/Flash.h"
+#include "../gba/Cheats.h"
+#include "../gba/RTC.h"
+#include "../gba/Sound.h"
+#include "../gb/gb.h"
+#include "../gb/gbGlobals.h"
+#include "../gb/gbCheats.h"
+#include "../gb/gbSound.h"
+#include "../Util.h"
+
+#ifndef _WIN32
+#include
+#define GETCWD getcwd
+#else // _WIN32
+#include
+#include
+#define GETCWD _getcwd
+#define snprintf sprintf
+#endif // _WIN32
+
+#ifndef __GNUC__
+#define HAVE_DECL_GETOPT 0
+#define __STDC__ 1
+#include "getopt.h"
+#else // ! __GNUC__
+#define HAVE_DECL_GETOPT 1
+#include
+#endif // ! __GNUC__
+#include
+
+enum named_opts
+{
+ OPT_AGB_PRINT = 1000,
+ OPT_AUTOFIRE,
+ OPT_AUTO_FRAME_SKIP,
+ OPT_AVI_RECORD_DIR,
+ OPT_BATTERY_DIR,
+ OPT_BIOS_FILE_NAME_GB,
+ OPT_BIOS_FILE_NAME_GBA,
+ OPT_BIOS_FILE_NAME_GBC,
+ OPT_CAPTURE_FORMAT,
+ OPT_CHEAT,
+ OPT_CPU_SAVE_TYPE,
+ OPT_EMULATOR_TYPE,
+ OPT_FS_ADAPTER,
+ OPT_FS_COLOR_DEPTH,
+ OPT_FS_FREQUENCY,
+ OPT_FS_HEIGHT,
+ OPT_FS_WIDTH,
+ OPT_GB_EMULATOR_TYPE,
+ OPT_GB_FRAME_SKIP,
+ OPT_GB_PALETTE_OPTION,
+ OPT_GDB_PORT,
+ OPT_GL_FILTER,
+ OPT_IFB_TYPE,
+ OPT_JOYPAD_DEFAULT,
+ OPT_LANGUAGE_OPTION,
+ OPT_LINK_AUTO,
+ OPT_LINK_HACKS,
+ OPT_LINK_HOST_ADDR,
+ OPT_LINK_MODE,
+ OPT_LINK_NUM_PLAYERS,
+ OPT_LINK_TIMEOUT,
+ OPT_MAX_SCALE,
+ OPT_MOVIE_RECORD_DIR,
+ OPT_OPT_FLASH_SIZE,
+ OPT_REWIND_TIMER,
+ OPT_ROM_DIR_GB,
+ OPT_ROM_DIR_GBA,
+ OPT_ROM_DIR_GBC,
+ OPT_RTC_ENABLED,
+ OPT_SAVE_DIR,
+ OPT_SCREEN_SHOT_DIR,
+ OPT_SHOW_SPEED,
+ OPT_SHOW_SPEED_TRANSPARENT,
+ OPT_SOUND_FILTERING,
+ OPT_SOUND_RECORD_DIR,
+ OPT_SYNCHRONIZE,
+ OPT_THREAD_PRIORITY,
+ OPT_VIDEO_OPTION,
+ OPT_WINDOW_POSITION_X,
+ OPT_WINDOW_POSITION_Y
+
+};
+
+#define SOUND_MAX_VOLUME 2.0
+#define SOUND_ECHO 0.2
+#define SOUND_STEREO 0.15
+
+#define REWIND_NUM 8
+#define REWIND_SIZE 400000
+
+char path[2048];
+
+dictionary* preferences;
+
+bool cpuIsMultiBoot = false;
+bool mirroringEnable = true;
+bool parseDebug = true;
+bool speedHack = false;
+bool speedup = false;
+char* aviRecordDir;
+char* batteryDir;
+char* biosFileNameGB;
+char* biosFileNameGBA;
+char* biosFileNameGBC;
+char* linkHostAddr;
+char* movieRecordDir;
+char* rewindMemory = NULL;
+char* romDirGB;
+char* romDirGBA;
+char* romDirGBC;
+char* saveDir;
+char* screenShotDir;
+char* soundRecordDir;
+int active = 1;
+int agbPrint;
+int autoFire;
+int autoFireMaxCount = 1;
+int autoFireToggle;
+int autoFrameSkip = 0;
+int autoLoadMostRecent;
+int autoPatch;
+int autoSaveLoadCheatList;
+int aviRecording;
+int captureFormat = 0;
+int cheatsEnabled = true;
+int cpuDisableSfx = false;
+int cpuSaveType = 0;
+int disableMMX;
+int disableStatusMessages = 0;
+int dsoundDisableHardwareAcceleration;
+int filterHeight;
+int filterMagnification;
+int filterMT; // enable multi-threading for pixel filters
+int filterType;
+int filterWidth;
+int frameSkip = 1;
+int frameskipadjust;
+int fsAdapter;
+int fsColorDepth;
+int fsForceChange;
+int fsFrequency;
+int fsHeight;
+int fsWidth;
+int fullScreen;
+int fullScreenStretch;
+int gdbBreakOnLoad;
+int gdbPort;
+int glFilter;
+int joypadDefault;
+int languageOption;
+int layerEnable = 0xff00;
+int layerSettings = 0xff00;
+int linkAuto;
+int linkHacks;
+int linkMode;
+int linkNumPlayers;
+int linkTimeout;
+int maxScale;
+int mouseCounter = 0;
+int movieFrame;
+int moviePlayFrame;
+int moviePlaying;
+int movieRecording;
+int openGL;
+int optFlashSize;
+int optPrintUsage;
+int paused;
+int pauseWhenInactive = 0;
+int preparedCheats = 0;
+int recentFreeze;
+int renderedFrames;
+int rewindCount;
+int rewindCounter;
+int rewindPos;
+int rewindSaveNeeded = 0;
+int rewindTimer = 0;
+int rewindTopPos;
+int rtcEnabled;
+int saveType = 0;
+int screenMessage;
+int sensorX;
+int sensorY;
+int showRenderedFrames;
+int showSpeed;
+int showSpeedTransparent;
+int sizeX;
+int sizeY;
+int skipBios = 0;
+int skipSaveGameBattery = false;
+int skipSaveGameCheats = false;
+int soundRecording;
+int speedupToggle;
+int sunBars;
+int surfaceSizeX;
+int surfaceSizeY;
+int synchronize = false;
+int threadPriority;
+int tripleBuffering;
+int useBios = 0;
+int useBiosFileGB;
+int useBiosFileGBA;
+int useBiosFileGBC;
+int videoOption;
+int vsync;
+int wasPaused = 0;
+int windowPositionX;
+int windowPositionY;
+int winFlashSize;
+int winGbBorderOn;
+int winGbPrinterEnabled;
+int winPauseNextFrame;
+int* rewindSerials = NULL;
+u32 autoFrameSkipLastTime;
+u32 movieLastJoypad;
+u32 movieNextJoypad;
+unsigned short throttle;
+
+const char* preparedCheatCodes[MAX_CHEATS];
+
+Filter filter = kStretch2x;
+FilterFunc filterFunction = 0;
+IFBFilterFunc ifbFunction = 0;
+int ifbType = kIFBNone;
+
+// allow up to 100 IPS/UPS/PPF patches given on commandline
+int patchNum = 0;
+char *(patchNames[PATCH_MAX_NUM]) = { NULL }; // and so on
+
+
+
+char* homeDir = NULL;
+char* arg0 = NULL;
+
+
+struct option argOptions[] = {
+
+ { "agb-print", required_argument, 0, OPT_AGB_PRINT },
+ { "auto-frame-skip", required_argument, 0, OPT_AUTO_FRAME_SKIP },
+ { "auto-load-most-recent", no_argument, &autoLoadMostRecent, 1 },
+ { "auto-patch", no_argument, &autoPatch, 1 },
+ { "auto-save-cheat-list", no_argument, &autoSaveLoadCheatList, 1 },
+ { "auto-save-load-cheat-list", no_argument, &autoSaveLoadCheatList, 1 },
+ { "autofire", required_argument, 0, OPT_AUTOFIRE },
+ { "avi-record-dir", required_argument, 0, OPT_AVI_RECORD_DIR },
+ { "battery-dir", required_argument, 0, OPT_BATTERY_DIR },
+ { "bios", required_argument, 0, 'b' },
+ { "bios-file-name-gb", required_argument, 0, OPT_BIOS_FILE_NAME_GB },
+ { "bios-file-name-gba", required_argument, 0, OPT_BIOS_FILE_NAME_GBA },
+ { "bios-file-name-gbc", required_argument, 0, OPT_BIOS_FILE_NAME_GBC },
+ { "border-automatic", no_argument, &gbBorderAutomatic, 1 },
+ { "border-on", no_argument, &gbBorderOn, 1 },
+ { "capture-format", required_argument, 0, OPT_CAPTURE_FORMAT },
+ { "cheat", required_argument, 0, OPT_CHEAT },
+ { "cheats-enabled", no_argument, &cheatsEnabled, 1 },
+ { "color-option", no_argument, &gbColorOption, 1 },
+ { "config", required_argument, 0, 'c' },
+ { "cpu-disable-sfx", no_argument, &cpuDisableSfx, 1 },
+ { "cpu-save-type", required_argument, 0, OPT_CPU_SAVE_TYPE },
+ { "debug", no_argument, 0, 'd' },
+ { "disable-mmx", no_argument, &disableMMX, 1 },
+ { "disable-sfx", no_argument, &cpuDisableSfx, 1 },
+ { "disable-status-messages", no_argument, &disableStatusMessages, 1 },
+ { "emulator-type", required_argument, 0, OPT_EMULATOR_TYPE },
+ { "filter", required_argument, 0, 'f' },
+ { "filter-enable-multi-threading", no_argument, &filterMT, 1 },
+ { "filter-mt", no_argument, &filterMT, 1 },
+ { "flash-128k", no_argument, &optFlashSize, 1 },
+ { "flash-64k", no_argument, &optFlashSize, 0 },
+ { "flash-size", required_argument, 0, 'S' },
+ { "frameskip", required_argument, 0, 's' },
+ { "fs-adapter", required_argument, 0, OPT_FS_ADAPTER },
+ { "fs-color-depth", required_argument, 0, OPT_FS_COLOR_DEPTH },
+ { "fs-frequency", required_argument, 0, OPT_FS_FREQUENCY },
+ { "fs-height", required_argument, 0, OPT_FS_HEIGHT },
+ { "fs-width", required_argument, 0, OPT_FS_WIDTH },
+ { "full-screen", no_argument, &fullScreen, 1 },
+ { "full-screen-stretch", no_argument, &fullScreenStretch, 1 },
+ { "gb-border-automatic", no_argument, &gbBorderAutomatic, 1 },
+ { "gb-border-on", no_argument, &gbBorderOn, 1 },
+ { "gb-color-option", no_argument, &gbColorOption, 1 },
+ { "gb-emulator-type", required_argument, 0, OPT_GB_EMULATOR_TYPE },
+ { "gb-frame-skip", required_argument, 0, OPT_GB_FRAME_SKIP },
+ { "gb-palette-option", required_argument, 0, OPT_GB_PALETTE_OPTION },
+ { "gb-printer", no_argument, &winGbPrinterEnabled, 1 },
+ { "gdb", required_argument, 0, 'G' },
+ { "gdb-break-on-load", no_argument, &gdbBreakOnLoad, 1 },
+ { "gdb-port", required_argument, 0, OPT_GDB_PORT },
+ { "gl-filter", required_argument, 0, OPT_GL_FILTER },
+ { "help", no_argument, &optPrintUsage, 1 },
+ { "ifb-filter", required_argument, 0, 'I' },
+ { "ifb-type", required_argument, 0, OPT_IFB_TYPE },
+ { "joypad-default", required_argument, 0, OPT_JOYPAD_DEFAULT },
+ { "language-option", required_argument, 0, OPT_LANGUAGE_OPTION },
+ { "link-auto", required_argument, 0, OPT_LINK_AUTO },
+ { "link-hacks", required_argument, 0, OPT_LINK_HACKS },
+ { "link-host-addr", required_argument, 0, OPT_LINK_HOST_ADDR },
+ { "link-mode", required_argument, 0, OPT_LINK_MODE },
+ { "link-num-players", required_argument, 0, OPT_LINK_NUM_PLAYERS },
+ { "link-timeout", required_argument, 0, OPT_LINK_TIMEOUT },
+ { "max-scale", required_argument, 0, OPT_MAX_SCALE },
+ { "movie-record-dir", required_argument, 0, OPT_MOVIE_RECORD_DIR },
+ { "no-agb-print", no_argument, &agbPrint, 0 },
+ { "no-auto-frameskip", no_argument, &autoFrameSkip, 0 },
+ { "no-debug", no_argument, 0, 'N' },
+ { "no-opengl", no_argument, &openGL, 0 },
+ { "no-patch", no_argument, &autoPatch, 0 },
+ { "no-pause-when-inactive", no_argument, &pauseWhenInactive, 0 },
+ { "no-rtc", no_argument, &rtcEnabled, 0 },
+ { "no-show-speed", no_argument, &showSpeed, 0 },
+ { "opengl", required_argument, 0, 'O' },
+ { "opengl-bilinear", no_argument, &openGL, 2 },
+ { "opengl-nearest", no_argument, &openGL, 1 },
+ { "opt-flash-size", required_argument, 0, OPT_OPT_FLASH_SIZE },
+ { "patch", required_argument, 0, 'i' },
+ { "pause-when-inactive", no_argument, &pauseWhenInactive, 1 },
+ { "profile", optional_argument, 0, 'p' },
+ { "recent-freeze", no_argument, &recentFreeze, 1 },
+ { "rewind-timer", required_argument, 0, OPT_REWIND_TIMER },
+ { "rom-dir-gb", required_argument, 0, OPT_ROM_DIR_GB },
+ { "rom-dir-gba", required_argument, 0, OPT_ROM_DIR_GBA },
+ { "rom-dir-gbc", required_argument, 0, OPT_ROM_DIR_GBC },
+ { "rtc", no_argument, &rtcEnabled, 1 },
+ { "rtc-enabled", required_argument, 0, OPT_RTC_ENABLED },
+ { "save-auto", no_argument, &cpuSaveType, 0 },
+ { "save-dir", required_argument, 0, OPT_SAVE_DIR },
+ { "save-eeprom", no_argument, &cpuSaveType, 1 },
+ { "save-flash", no_argument, &cpuSaveType, 3 },
+ { "save-none", no_argument, &cpuSaveType, 5 },
+ { "save-sensor", no_argument, &cpuSaveType, 4 },
+ { "save-sram", no_argument, &cpuSaveType, 2 },
+ { "save-type", required_argument, 0, 't' },
+ { "screen-shot-dir", required_argument, 0, OPT_SCREEN_SHOT_DIR },
+ { "show-speed", required_argument, 0, OPT_SHOW_SPEED },
+ { "show-speed-detailed", no_argument, &showSpeed, 2 },
+ { "show-speed-normal", no_argument, &showSpeed, 1 },
+ { "show-speed-transparent", required_argument, 0, OPT_SHOW_SPEED_TRANSPARENT },
+ { "skip-bios", no_argument, &skipBios, 1 },
+ { "skip-save-game-battery", no_argument, &skipSaveGameBattery, 1 },
+ { "skip-save-game-cheats", no_argument, &skipSaveGameCheats, 1 },
+ { "sound-filtering", required_argument, 0, OPT_SOUND_FILTERING },
+ { "sound-record-dir", required_argument, 0, OPT_SOUND_RECORD_DIR },
+ { "stretch", no_argument, &fullScreenStretch, 1 },
+ { "synchronize", required_argument, 0, OPT_SYNCHRONIZE },
+ { "thread-priority", required_argument, 0, OPT_THREAD_PRIORITY },
+ { "throttle", required_argument, 0, 'T' },
+ { "triple-buffering", no_argument, &tripleBuffering, 1 },
+ { "use-bios", no_argument, &useBios, 1 },
+ { "use-bios-file-gb", no_argument, &useBiosFileGB, 1 },
+ { "use-bios-file-gba", no_argument, &useBiosFileGBA, 1 },
+ { "use-bios-file-gbc", no_argument, &useBiosFileGBC, 1 },
+ { "verbose", required_argument, 0, 'v' },
+ { "video-option", required_argument, 0, OPT_VIDEO_OPTION },
+ { "vsync", no_argument, &vsync, 1 },
+ { "win-gb-printer-enabled", no_argument, &winGbPrinterEnabled, 1 },
+ { "window-position-x", required_argument, 0, OPT_WINDOW_POSITION_X },
+ { "window-position-y", required_argument, 0, OPT_WINDOW_POSITION_Y },
+
+
+ { NULL, no_argument, NULL, 0 }
+};
+
+
+u32 fromHex(char *s)
+{
+ if (!s)
+ return 0;
+ u32 value;
+ sscanf(s, "%x", &value);
+ return value;
+}
+
+u32 fromDec(char *s)
+{
+ if (!s)
+ return 0;
+ u32 value = 0;
+ sscanf(s, "%u", &value);
+ return value;
+}
+
+void SetHome(char *_arg0)
+{
+ arg0 = _arg0;
+}
+
+void OpenPreferences(const char *name)
+{
+ if (!preferences)
+ preferences = iniparser_load(name);
+}
+
+void LoadConfig()
+{
+
+ openGL = ReadPrefHex("openGL");
+ fullScreen = ReadPrefHex("fullScreen") ? 1 : 0;
+ useBios = ReadPrefHex("useBiosGBA") ? true : false;
+ skipBios = ReadPrefHex("skipBios") ? true : false;
+ disableStatusMessages = ReadPrefHex("disableStatus") ? true : false;
+ gbBorderOn = ReadPrefHex("borderOn") ? true : false;
+ gbBorderAutomatic = ReadPrefHex("borderAutomatic") ? true : false;
+ gbColorOption = ReadPrefHex("colorOption") ? true : false;
+ captureFormat = ReadPrefHex("captureFormat");
+ gbSoundSetDeclicking(ReadPrefHex("declicking") != 0);
+ showSpeedTransparent = ReadPrefHex("showSpeedTransparent");
+ autoFrameSkip = ReadPrefHex("autoFrameSkip");
+ pauseWhenInactive = ReadPrefHex("pauseWhenInactive") ? true : false;
+ agbPrint = ReadPrefHex("agbPrint");
+ rtcEnabled = ReadPrefHex("rtcEnabled");
+ synchronize = ReadPrefHex("synchronize");
+ videoOption = ReadPrefHex("video");
+
+ languageOption = ReadPref("language", 1);
+ frameSkip = ReadPref("frameSkip", 0);
+ gbFrameSkip = ReadPref("gbFrameSkip", 0);
+ autoFrameSkip = ReadPref("autoFrameSkip", 0) ? 1 : 0;
+ vsync = ReadPref("vsync", false) ? true : false;
+ synchronize = ReadPref("synchronize", 1) ? true : false;
+ fullScreenStretch = ReadPref("stretch", 0) ? true : false;
+ videoOption = ReadPref("video", 2); // VIDEO_3X = 2
+ fsAdapter = ReadPref("fsAdapter", 0);
+ fsWidth = ReadPref("fsWidth", 800);
+ fsHeight = ReadPref("fsHeight", 600);
+ fsColorDepth = ReadPref("fsColorDepth", 32);
+ fsFrequency = ReadPref("fsFrequency", 60);
+ windowPositionX = ReadPref("windowX", 0);
+ windowPositionY = ReadPref("windowY", 0);
+ useBiosFileGBA = (ReadPref("useBiosGBA", 0) == 1) ? true : false;
+ useBiosFileGBC = (ReadPref("useBiosGBC", 0) == 1) ? true : false;
+ useBiosFileGB = (ReadPref("useBiosGB", 0) == 1) ? true : false;
+ skipBios = ReadPref("skipBios", 0) ? true : false;
+ soundSetVolume((float)(ReadPref("soundVolume", 100)) / 100.0f);
+ gb_effects_config.enabled = 1 == ReadPref("gbSoundEffectsEnabled", 0);
+ gb_effects_config.surround = 1 == ReadPref("gbSoundEffectsSurround", 0);
+ gb_effects_config.echo = (float)ReadPref("gbSoundEffectsEcho", 20) / 100.0f;
+ gb_effects_config.stereo = (float)ReadPref("gbSoundEffectsStereo", 15) / 100.0f;
+ gbSoundSetDeclicking(1 == ReadPref("gbSoundDeclicking", 1));
+ soundInterpolation = 1 == ReadPref("gbaSoundInterpolation", 1);
+ soundFiltering = (float)ReadPref("gbaSoundFiltering", 50) / 100.0f;
+ tripleBuffering = ReadPref("tripleBuffering", false) ? true : false;
+ glFilter = ReadPref("glFilter", 1);
+ filterType = ReadPref("filter", 0);
+ filterMT = (1 == ReadPref("filterEnableMultiThreading", 0));
+ disableMMX = ReadPref("disableMMX", false) ? true : false;
+ showSpeed = ReadPref("showSpeed", 0);
+ showSpeedTransparent = ReadPref("showSpeedTransparent", 1) ? true : false;
+ winGbPrinterEnabled = ReadPref("gbPrinter", false) ? true : false;
+ pauseWhenInactive = ReadPref("pauseWhenInactive", 1) ? true : false;
+ captureFormat = ReadPref("captureFormat", 0);
+ recentFreeze = ReadPref("recentFreeze", false) ? true : false;
+ autoPatch = ReadPref("autoPatch", 1) == 1 ? true : false;
+ cpuDisableSfx = ReadPref("disableSfx", 0) ? true : false;
+ saveType = ReadPref("saveType", 0);
+ ifbType = ReadPref("ifbType", 0);
+ winFlashSize = ReadPref("flashSize", 0x10000);
+ agbPrintEnable(ReadPref("agbPrint", 0) ? true : false);
+ rtcEnabled = ReadPref("rtcEnabled", 0) ? true : false;
+ winGbBorderOn = ReadPref("borderOn", 0);
+ gbBorderAutomatic = ReadPref("borderAutomatic", 0);
+ gbEmulatorType = ReadPref("emulatorType", 1);
+ gbColorOption = ReadPref("colorOption", 0);
+ threadPriority = ReadPref("priority", 2);
+ autoSaveLoadCheatList = (1 == ReadPref("autoSaveCheatList", 1)) ? true : false;
+ gbPaletteOption = ReadPref("gbPaletteOption", 0);
+ rewindTimer = ReadPref("rewindTimer", 0);
+ joypadDefault = ReadPref("joypadDefault", 0);
+ autoLoadMostRecent = (1 == ReadPref("autoLoadMostRecent", 0)) ? true : false;
+ skipSaveGameBattery = (1 == ReadPref("skipSaveGameBattery", 0)) ? true : false;
+ skipSaveGameCheats = (1 == ReadPref("skipSaveGameCheats", 0)) ? true : false;
+ cheatsEnabled = ReadPref("cheatsEnabled", false) ? true : false;
+ maxScale = ReadPref("maxScale", 0);
+ linkTimeout = ReadPref("LinkTimeout", 1000);
+ linkMode = ReadPref("LinkMode", 0); // LINK_DISCONNECTED = 0
+ linkAuto = ReadPref("LinkAuto", true);
+ linkHacks = ReadPref("LinkHacks", false);
+ linkNumPlayers = ReadPref("LinkNumPlayers", 2);
+ gdbPort = ReadPref("gdbPort", 55555);
+ gdbBreakOnLoad = ReadPref("gdbBreakOnLoad", false) ? true : false;
+ //valueType = ReadPref("gbCheatsValueType", 0);
+ //searchType = ReadPref("gbCheatsSearchType",
+ //numberType = ReadPref("gbCheatsNumberType", 2);
+ //sizeType = ReadPref("gbCheatsSizeType", 0);
+ //updateValues = ReadPref("gbCheatsUpdate", 0);
+ //numberType = ReadPref("gbCheatsNumberType", 2);
+ //sizeType = ReadPref("gbCheatsSizeType", 0);
+ //int s = ReadPref("mapViewStretch", 0);
+ //m_size = ReadPref("memViewerDataSize", 0);
+ //m_stretch = ReadPref("GBOamViewStretch", 0);
+ //scale = ReadPref("printerScale", 0);
+ //m_stretch = ReadPref("tileViewStretch", 0);
+ //valueType = ReadPref("cheatsValueType", 0);
+ //searchType = ReadPref("cheatsSearchType", SEARCH_EQ);
+ //numberType = ReadPref("cheatsNumberType", 2);
+ //sizeType = ReadPref("cheatsSizeType", 0);
+ //updateValues = ReadPref("cheatsUpdate", 0);
+ //numberType = ReadPref("cheatsNumberType", 2);
+ //sizeType = ReadPref("cheatsSizeType", 0);
+ //restoreValues = ReadPref("cheatsRestore", 0) ?
+ //selectedFilter = ReadPref(("selectedFilter"), 0);
+ //int s = ReadPref("mapViewStretch", 0);
+ //m_size = ReadPref("memViewerDataSize", 0);
+ //m_stretch = ReadPref("tileViewStretch", 0);
+
+ gbEmulatorType = (ReadPrefHex("emulatorType"));
+ if (gbEmulatorType < 0 || gbEmulatorType > 5)
+ gbEmulatorType = 1;
+ frameSkip = (ReadPrefHex("frameSkip"));
+ if (frameSkip < 0 || frameSkip > 9)
+ frameSkip = 2;
+ gbFrameSkip = (ReadPrefHex("gbFrameSkip"));
+ if (gbFrameSkip < 0 || gbFrameSkip > 9)
+ gbFrameSkip = 0;
+ filter = (Filter)fromDec(ReadPrefString("filter"));
+ if (filter < kStretch1x || filter >= kInvalidFilter)
+ filter = kStretch2x;
+
+ biosFileNameGB = ReadPrefString("biosFileGB");
+ biosFileNameGBA = ReadPrefString("biosFileGBA");
+ biosFileNameGBC = ReadPrefString("biosFileGBC");
+
+ aviRecordDir = ReadPrefString("aviRecordDir");
+ movieRecordDir = ReadPrefString("movieRecordDir");
+ soundRecordDir = ReadPrefString("soundRecordDir");
+ screenShotDir = ReadPrefString("screenShotDir");
+ saveDir = ReadPrefString("saveDir");
+ batteryDir = ReadPrefString("batteryDir");
+
+ romDirGBC = ReadPrefString("romDirGBC");
+ romDirGB = ReadPrefString("romDirGB");
+ romDirGBA = ReadPrefString("romDirGBA");
+
+ linkHostAddr = ReadPrefString("LinkHostAddr", "localhost");
+
+ int soundQuality = (ReadPrefHex("soundQuality"));
+ switch (soundQuality) {
+ case 1:
+ case 2:
+ case 4:
+ break;
+ default:
+ fprintf(stdout, "Unknown sound quality %d. Defaulting to 22Khz\n",
+ soundQuality);
+ soundQuality = 2;
+ break;
+ }
+ soundSetSampleRate(44100 / soundQuality);
+ int res = (ReadPrefHex("soundEnable")) & 0x30f;
+ soundSetEnable(res);
+ if ((ReadPrefHex("soundStereo"))) {
+ gb_effects_config.stereo = SOUND_STEREO;
+ gb_effects_config.enabled = true;
+ }
+ if ((ReadPrefHex("soundEcho"))) {
+ gb_effects_config.echo = SOUND_ECHO;
+ gb_effects_config.enabled = true;
+ }
+ if ((ReadPrefHex("soundSurround"))) {
+ gb_effects_config.surround = true;
+ gb_effects_config.enabled = true;
+ }
+ float volume = fromDec(ReadPrefString("soundVolume")) / 100.0;
+ if (volume < 0.0 || volume > SOUND_MAX_VOLUME)
+ volume = 1.0;
+ soundSetVolume(volume);
+ cpuSaveType = (ReadPrefHex("saveType"));
+ if (cpuSaveType < 0 || cpuSaveType > 5)
+ cpuSaveType = 0;
+ optFlashSize = (ReadPrefHex("flashSize"));
+ if (optFlashSize != 0 && optFlashSize != 1)
+ optFlashSize = 0;
+ ifbType = (IFBFilter)(ReadPrefHex("ifbType"));
+ if (ifbType < kIFBNone || ifbType >= kInvalidIFBFilter)
+ ifbType = kIFBNone;
+ showSpeed = (ReadPrefHex("showSpeed"));
+ if (showSpeed < 0 || showSpeed > 2)
+ showSpeed = 1;
+ rewindTimer = (ReadPrefHex("rewindTimer"));
+ if (rewindTimer < 0 || rewindTimer > 600)
+ rewindTimer = 0;
+ rewindTimer *= 6; // convert ReadPref("rewindTimer") to 10 frames multiple
+ autoFireMaxCount = fromDec(ReadPrefString("autoFireMaxCount"));
+ if (autoFireMaxCount < 1)
+ autoFireMaxCount = 1;
+
+ if (rewindTimer) {
+ rewindMemory = (char *)malloc(REWIND_NUM*REWIND_SIZE);
+ rewindSerials = (int *)calloc(REWIND_NUM, sizeof(int)); // init to zeroes
+ }
+
+ if (optFlashSize == 0)
+ flashSetSize(0x10000);
+ else
+ flashSetSize(0x20000);
+
+ rtcEnable(rtcEnabled ? true : false);
+ agbPrintEnable(agbPrint ? true : false);
+
+ for (int i = 0; i < 24;) {
+ systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
+ systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);
+ systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
+ systemGbPalette[i++] = 0;
+ }
+
+ systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
+
+ optPrintUsage = 0;
+}
+
+void CloseConfig()
+{
+ if (preferences)
+ iniparser_freedict(preferences);
+}
+
+bool FileExists(const char *filename)
+{
+#ifdef _WIN32
+ return (_access(filename, 0) != -1);
+#else
+ struct stat buffer;
+ return (stat(filename, &buffer) == 0);
+#endif
+}
+
+char* FindConfigFile(char *name)
+{
+ char buffer[4096];
+
+#ifdef _WIN32
+#define PATH_SEP ";"
+#define FILE_SEP '\\'
+#define EXE_NAME "vbam.exe"
+#else // ! _WIN32
+#define PATH_SEP ":"
+#define FILE_SEP '/'
+#define EXE_NAME "vbam"
+#endif // ! _WIN32
+
+ log("Searching for file %s\n", name);
+
+ if (GETCWD(buffer, 2048)) {
+ log("Searching current directory: %s\n", buffer);
+ }
+
+ if (FileExists(name))
+ {
+ return name;
+ }
+
+ if (homeDir) {
+ log("Searching home directory: %s%c%s\n", homeDir, FILE_SEP, DOT_DIR);
+ sprintf(path, "%s%c%s%c%s", homeDir, FILE_SEP, DOT_DIR, FILE_SEP, name);
+ if (FileExists(path))
+ {
+ return path;
+ }
+ }
+
+#ifdef _WIN32
+ char *home = getenv("USERPROFILE");
+ if (home != NULL) {
+ log("Searching user profile directory: %s\n", home);
+ sprintf(path, "%s%c%s", home, FILE_SEP, name);
+ if (FileExists(path))
+ {
+ return path;
+ }
+ }
+
+ if (!strchr(arg0, '/') &&
+ !strchr(arg0, '\\')) {
+ char *path = getenv("PATH");
+
+ if (path != NULL) {
+ log("Searching PATH\n");
+ strncpy(buffer, path, 4096);
+ buffer[4095] = 0;
+ char *tok = strtok(buffer, PATH_SEP);
+
+ while (tok) {
+ sprintf(path, "%s%c%s", tok, FILE_SEP, EXE_NAME);
+ if (FileExists(path)) {
+ char path2[2048];
+ sprintf(path2, "%s%c%s", tok, FILE_SEP, name);
+ if (FileExists(path2)) {
+ return path2;
+ }
+ }
+ tok = strtok(NULL, PATH_SEP);
+ }
+ }
+ }
+ else {
+ // executable is relative to some directory
+ log("Searching executable directory\n");
+ strcpy(buffer, arg0);
+ char *p = strrchr(buffer, FILE_SEP);
+ if (p) {
+ *p = 0;
+ sprintf(path, "%s%c%s", buffer, FILE_SEP, name);
+ if (FileExists(path))
+ {
+ return path;
+ }
+ }
+ }
+#else // ! _WIN32
+ log("Searching data directory: %s\n", PKGDATADIR);
+ sprintf(path, "%s%c%s", PKGDATADIR, FILE_SEP, name);
+ if (FileExists(path))
+ {
+ return path;
+ }
+
+ log("Searching system config directory: %s\n", SYSCONFDIR);
+ sprintf(path, "%s%c%s", SYSCONFDIR, FILE_SEP, name);
+ if (FileExists(path))
+ {
+ return path;
+ }
+#endif // ! _WIN32
+ return 0;
+}
+
+void LoadConfigFile()
+{
+#ifndef _WIN32
+ // Get home dir
+ char buf[1024];
+ struct stat s;
+ homeDir = getenv("HOME");
+ snprintf(buf, 1024, "%s/%s", homeDir, DOT_DIR);
+ // Make dot dir if not existent
+ if (stat(buf, &s) == -1 || !S_ISDIR(s.st_mode))
+ mkdir(buf, 0755);
+#else
+ homeDir = 0;
+#endif
+
+ if (preferences == NULL)
+ {
+ char* configFile = FindConfigFile("vbam.ini");
+ OpenPreferences(configFile);
+ }
+
+ if (preferences == NULL)
+ {
+ char* configFile = FindConfigFile("vbam.cfg");
+ OpenPreferences(configFile);
+ }
+}
+
+void SaveConfigFile()
+{
+#ifndef _WIN32
+ // Get home dir
+ char buf[1024];
+ struct stat s;
+ homeDir = getenv("HOME");
+ snprintf(buf, 1024, "%s/%s", homeDir, DOT_DIR);
+ // Make dot dir if not existent
+ if (stat(buf, &s) == -1 || !S_ISDIR(s.st_mode))
+ mkdir(buf, 0755);
+#else
+ homeDir = 0;
+#endif
+
+ char* configFile = FindConfigFile("vbam.ini");
+
+ if (configFile == NULL)
+ {
+ configFile = FindConfigFile("vbam.cfg");
+ }
+
+ if (configFile != NULL)
+ {
+ FILE *f = fopen(configFile, "w");
+ // Needs mixed case version of the option name to add new options into the ini
+ //for (int i = 0; i < (sizeof(argOptions) / sizeof(option)); i++)
+ //{
+ // std::string pref = "preferences:";
+ // pref.append(argOptions[i].name);
+ // if (!iniparser_find_entry(preferences, pref.c_str()))
+ // {
+ // iniparser_set(preferences, pref.c_str(), NULL);
+ // }
+ //}
+ iniparser_dump_ini(preferences, f);
+ fclose(f);
+ }
+}
+
+u32 ReadPrefHex(char* pref_key)
+{
+ LoadConfigFile();
+ std::string pref = "preferences:";
+ pref.append(pref_key);
+ return fromHex(iniparser_getstring(preferences, pref.c_str(), 0));
+}
+
+u32 ReadPref(char* pref_key, int default_value)
+{
+ LoadConfigFile();
+ std::string pref = "preferences:";
+ pref.append(pref_key);
+ return iniparser_getint(preferences, pref.c_str(), default_value);
+}
+
+u32 ReadPref(char* pref_key)
+{
+ return ReadPref(pref_key, 0);
+}
+
+char* ReadPrefString(char* pref_key, char* default_value)
+{
+ LoadConfigFile();
+ std::string pref = "preferences:";
+ pref.append(pref_key);
+ return iniparser_getstring(preferences, pref.c_str(), default_value);
+}
+
+char* ReadPrefString(char* pref_key)
+{
+ return ReadPrefString(pref_key, "");
+}
+
+int ReadOpts(int argc, char ** argv)
+{
+ int op = -1;
+ while ((op = getopt_long(argc,
+ argv,
+ "FNO:T:Y:G:I:D:b:c:df:hi:p::s:t:v:",
+ argOptions,
+ NULL)) != -1) {
+ switch (op) {
+ case 0:
+ // long option already processed by getopt_long
+ break;
+ case OPT_CHEAT:
+ // --cheat
+ if (preparedCheats >= MAX_CHEATS) {
+ log("Warning: cannot add more than %d cheats.\n", MAX_CHEATS);
+ break;
+ }
+ {
+ //char* cpy;
+ //cpy = (char *)malloc(1 + strlen(optarg));
+ //strcpy(cpy, optarg);
+ //preparedCheatCodes[preparedCheats++] = cpy;
+ std::string cpy = optarg;
+ preparedCheatCodes[preparedCheats++] = cpy.c_str();
+ }
+ break;
+ case OPT_AUTOFIRE:
+ // --autofire
+ autoFireMaxCount = fromDec(optarg);
+ if (autoFireMaxCount < 1)
+ autoFireMaxCount = 1;
+ break;
+ case 'b':
+ useBios = true;
+ if (optarg == NULL) {
+ log("Missing BIOS file name\n");
+ break;
+ }
+ strcpy(biosFileNameGBA, optarg + 1);
+ break;
+ case 'c':
+ {
+ if (optarg == NULL) {
+ log("Missing config file name\n");
+ break;
+ }
+ FILE *f = fopen(optarg + 1, "r");
+ if (f == NULL) {
+ log("File not found %s\n", optarg + 1);
+ break;
+ }
+ preferences = NULL;
+ OpenPreferences(optarg + 1);
+ fclose(f);
+ }
+ break;
+ case 'd':
+ debugger = true;
+ break;
+ case 'h':
+ optPrintUsage = 1;
+ break;
+ case 'i':
+ if (optarg == NULL) {
+ log("Missing patch name\n");
+ break;
+ }
+ if (patchNum >= PATCH_MAX_NUM) {
+ log("Too many patches given at %s (max is %d). Ignoring.\n", optarg + 1, PATCH_MAX_NUM);
+ }
+ else {
+ patchNames[patchNum] = (char *)malloc(1 + strlen(optarg + 1));
+ strcpy(patchNames[patchNum], optarg + 1);
+ patchNum++;
+ }
+ break;
+ //case 'G':
+ // dbgMain = remoteStubMain;
+ // dbgSignal = remoteStubSignal;
+ // dbgOutput = remoteOutput;
+ // debugger = true;
+ // debuggerStub = true;
+ // if (optarg) {
+ // char *s = optarg;
+ // if (strncmp(s, "tcp:", 4) == 0) {
+ // s += 4;
+ // int port = atoi(s);
+ // remoteSetProtocol(0);
+ // remoteSetPort(port);
+ // }
+ // else if (strcmp(s, "tcp") == 0) {
+ // remoteSetProtocol(0);
+ // }
+ // else if (strcmp(s, "pipe") == 0) {
+ // remoteSetProtocol(1);
+ // }
+ // else {
+ // log("Unknown protocol %s\n", s);
+ // break;
+ // }
+ // }
+ // else {
+ // remoteSetProtocol(0);
+ // }
+ // break;
+ case 'N':
+ parseDebug = false;
+ break;
+ case 'D':
+ if (optarg) {
+ systemDebug = atoi(optarg + 1);
+ }
+ else {
+ systemDebug = 1;
+ }
+ break;
+ case 'F':
+ fullScreen = 1;
+ mouseCounter = 120;
+ break;
+ case 'f':
+ if (optarg) {
+ filter = (Filter)atoi(optarg + 1);
+ }
+ else {
+ filter = kStretch2x;
+ }
+ break;
+ case 'I':
+ if (optarg) {
+ ifbType = (IFBFilter)atoi(optarg + 1);
+ }
+ else {
+ ifbType = kIFBNone;
+ }
+ break;
+ case 'p':
+#ifdef PROFILING
+ if (optarg) {
+ cpuEnableProfiling(atoi(optarg));
+ }
+ else
+ cpuEnableProfiling(100);
+#endif
+ break;
+ case 'S':
+ optFlashSize = atoi(optarg + 1);
+ if (optFlashSize < 0 || optFlashSize > 1)
+ optFlashSize = 0;
+ break;
+ case 's':
+ if (optarg) {
+ int a = atoi(optarg + 1);
+ if (a >= 0 && a <= 9) {
+ gbFrameSkip = a;
+ frameSkip = a;
+ }
+ }
+ else {
+ frameSkip = 2;
+ gbFrameSkip = 0;
+ }
+ break;
+ case 't':
+ if (optarg) {
+ int a = atoi(optarg + 1);
+ if (a < 0 || a > 5)
+ a = 0;
+ cpuSaveType = a;
+ }
+ break;
+ case 'v':
+ if (optarg) {
+ systemVerbose = atoi(optarg + 1);
+ }
+ else
+ systemVerbose = 0;
+ break;
+ case '?':
+ optPrintUsage = 1;
+ break;
+ case 'O':
+ if (optarg) {
+ openGL = atoi(optarg + 1);
+ if (openGL < 0 || openGL > 2)
+ openGL = 1;
+ }
+ else
+ openGL = 0;
+ break;
+
+ case OPT_CAPTURE_FORMAT:
+ // --capture-format
+ if (optarg) {
+ captureFormat = atoi(optarg);
+ }
+ break;
+
+ case OPT_SHOW_SPEED_TRANSPARENT:
+ // --show-speed-transparent
+ if (optarg) {
+ showSpeedTransparent = atoi(optarg);
+ }
+ break;
+
+ case OPT_AUTO_FRAME_SKIP:
+ // --auto-frame-skip
+ if (optarg) {
+ autoFrameSkip = atoi(optarg);
+ }
+ break;
+
+ case OPT_AGB_PRINT:
+ // --agb-print
+ if (optarg) {
+ agbPrint = atoi(optarg);
+ }
+ break;
+
+ case OPT_RTC_ENABLED:
+ // --rtc-enabled
+ if (optarg) {
+ rtcEnabled = atoi(optarg);
+ }
+ break;
+
+ case OPT_SYNCHRONIZE:
+ // --synchronize
+ if (optarg) {
+ synchronize = atoi(optarg);
+ }
+ break;
+
+ case OPT_VIDEO_OPTION:
+ // --video-option
+ if (optarg) {
+ videoOption = atoi(optarg);
+ }
+ break;
+
+ case OPT_LANGUAGE_OPTION:
+ // --language-option
+ if (optarg) {
+ languageOption = atoi(optarg);
+ }
+ break;
+
+ case OPT_GB_FRAME_SKIP:
+ // --gb-frame-skip
+ if (optarg) {
+ gbFrameSkip = atoi(optarg);
+ }
+ break;
+
+ case OPT_FS_ADAPTER:
+ // --fs-adapter
+ if (optarg) {
+ fsAdapter = atoi(optarg);
+ }
+ break;
+
+ case OPT_FS_WIDTH:
+ // --fs-width
+ if (optarg) {
+ fsWidth = atoi(optarg);
+ }
+ break;
+
+ case OPT_FS_HEIGHT:
+ // --fs-height
+ if (optarg) {
+ fsHeight = atoi(optarg);
+ }
+ break;
+
+ case OPT_FS_COLOR_DEPTH:
+ // --fs-color-depth
+ if (optarg) {
+ fsColorDepth = atoi(optarg);
+ }
+ break;
+
+ case OPT_FS_FREQUENCY:
+ // --fs-frequency
+ if (optarg) {
+ fsFrequency = atoi(optarg);
+ }
+ break;
+
+ case OPT_WINDOW_POSITION_X:
+ // --window-position-x
+ if (optarg) {
+ windowPositionX = atoi(optarg);
+ }
+ break;
+
+ case OPT_WINDOW_POSITION_Y:
+ // --window-position-y
+ if (optarg) {
+ windowPositionY = atoi(optarg);
+ }
+ break;
+
+ case OPT_SOUND_FILTERING:
+ // --sound-filtering
+ if (optarg) {
+ soundFiltering = atoi(optarg);
+ }
+ break;
+
+ case OPT_GL_FILTER:
+ // --gl-filter
+ if (optarg) {
+ glFilter = atoi(optarg);
+ }
+ break;
+
+ case OPT_SHOW_SPEED:
+ // --show-speed
+ if (optarg) {
+ showSpeed = atoi(optarg);
+ }
+ break;
+
+ case OPT_IFB_TYPE:
+ // --ifb-type
+ if (optarg) {
+ ifbType = atoi(optarg);
+ }
+ break;
+
+ case OPT_GB_EMULATOR_TYPE:
+ // --gb-emulator-type
+ if (optarg) {
+ gbEmulatorType = atoi(optarg);
+ }
+ break;
+
+ case OPT_THREAD_PRIORITY:
+ // --thread-priority
+ if (optarg) {
+ threadPriority = atoi(optarg);
+ }
+ break;
+
+ case OPT_GB_PALETTE_OPTION:
+ // --gb-palette-option
+ if (optarg) {
+ gbPaletteOption = atoi(optarg);
+ }
+ break;
+
+ case OPT_REWIND_TIMER:
+ // --rewind-timer
+ if (optarg) {
+ rewindTimer = atoi(optarg);
+ }
+ break;
+
+ case OPT_JOYPAD_DEFAULT:
+ // --joypad-default
+ if (optarg) {
+ joypadDefault = atoi(optarg);
+ }
+ break;
+
+ case OPT_MAX_SCALE:
+ // --max-scale
+ if (optarg) {
+ maxScale = atoi(optarg);
+ }
+ break;
+
+ case OPT_LINK_TIMEOUT:
+ // --link-timeout
+ if (optarg) {
+ linkTimeout = atoi(optarg);
+ }
+ break;
+
+ case OPT_LINK_MODE:
+ // --link-mode
+ if (optarg) {
+ linkMode = atoi(optarg);
+ }
+ break;
+
+ case OPT_LINK_AUTO:
+ // --link-auto
+ if (optarg) {
+ linkAuto = atoi(optarg);
+ }
+ break;
+
+ case OPT_LINK_HACKS:
+ // --link-hacks
+ if (optarg) {
+ linkHacks = atoi(optarg);
+ }
+ break;
+
+ case OPT_LINK_NUM_PLAYERS:
+ // --link-num-players
+ if (optarg) {
+ linkNumPlayers = atoi(optarg);
+ }
+ break;
+
+ case OPT_GDB_PORT:
+ // --gdb-port
+ if (optarg) {
+ gdbPort = atoi(optarg);
+ }
+ break;
+
+ case OPT_BIOS_FILE_NAME_GB:
+ // --bios-file-name-gb
+ strcpy(biosFileNameGB, optarg);
+ break;
+
+ case OPT_BIOS_FILE_NAME_GBA:
+ // --bios-file-name-gba
+ strcpy(biosFileNameGBA, optarg);
+ break;
+
+ case OPT_BIOS_FILE_NAME_GBC:
+ // --bios-file-name-gbc
+ strcpy(biosFileNameGBC, optarg);
+ break;
+
+ case OPT_AVI_RECORD_DIR:
+ // --avi-record-dir
+ strcpy(aviRecordDir, optarg);
+ break;
+
+ case OPT_MOVIE_RECORD_DIR:
+ // --movie-record-dir
+ strcpy(movieRecordDir, optarg);
+ break;
+
+ case OPT_SOUND_RECORD_DIR:
+ // --sound-record-dir
+ strcpy(soundRecordDir, optarg);
+ break;
+
+ case OPT_SCREEN_SHOT_DIR:
+ // --screen-shot-dir
+ strcpy(screenShotDir, optarg);
+ break;
+
+ case OPT_SAVE_DIR:
+ // --save-dir
+ strcpy(saveDir, optarg);
+ break;
+
+ case OPT_BATTERY_DIR:
+ // --battery-dir
+ strcpy(batteryDir, optarg);
+ break;
+
+ case OPT_ROM_DIR_GBC:
+ // --rom-dir-gbc
+ strcpy(romDirGBC, optarg);
+ break;
+
+ case OPT_ROM_DIR_GB:
+ // --rom-dir-gb
+ strcpy(romDirGB, optarg);
+ break;
+
+ case OPT_ROM_DIR_GBA:
+ // --rom-dir-gba
+ strcpy(romDirGBA, optarg);
+ break;
+
+ case OPT_LINK_HOST_ADDR:
+ // --link-host-addr
+ strcpy(linkHostAddr, optarg);
+ break;
+
+ case OPT_CPU_SAVE_TYPE:
+ // --cpu-save-type
+ if (optarg) {
+ cpuSaveType = atoi(optarg);
+ }
+ break;
+
+ case OPT_OPT_FLASH_SIZE:
+ // --opt-flash-size
+ if (optarg) {
+ optFlashSize = atoi(optarg);
+ }
+ break;
+
+ }
+ }
+ return op;
+}
+
diff --git a/src/common/ConfigManager.h b/src/common/ConfigManager.h
new file mode 100644
index 00000000..0504689a
--- /dev/null
+++ b/src/common/ConfigManager.h
@@ -0,0 +1,175 @@
+#ifndef _CONFIGMANAGER_H
+#define _CONFIGMANAGER_H
+
+#pragma once
+#include
+#include "../sdl/filters.h"
+
+#ifndef __GNUC__
+# define HAVE_DECL_GETOPT 0
+# define __STDC__ 1
+# include "getopt.h"
+#else // ! __GNUC__
+# define HAVE_DECL_GETOPT 1
+# include
+#endif // ! __GNUC__
+
+extern bool cpuIsMultiBoot;
+extern bool mirroringEnable;
+extern bool parseDebug;
+extern bool speedHack;
+extern bool speedup;
+extern char* rewindMemory;
+extern char* aviRecordDir;
+extern char* biosFileNameGB;
+extern char* biosFileNameGBA;
+extern char* biosFileNameGBC;
+extern char* linkHostAddr;
+extern char* movieRecordDir;
+extern char* romDirGB;
+extern char* romDirGBA;
+extern char* romDirGBC;
+extern char* soundRecordDir;
+extern int* rewindSerials;
+extern int active;
+extern int agbPrint;
+extern int autoFire;
+extern int autoFireMaxCount;
+extern int autoFireToggle;
+extern int autoFrameSkip;
+extern int autoLoadMostRecent;
+extern int autoPatch;
+extern int autoSaveLoadCheatList;
+extern int aviRecording;
+extern int captureFormat;
+extern int cheatsEnabled;
+extern int cpuDisableSfx;
+extern int cpuSaveType;
+extern int dinputKeyFocus;
+extern int disableMMX;
+extern int disableStatusMessages;
+extern int dsoundDisableHardwareAcceleration;
+extern int filterHeight;
+extern int filterMagnification;
+extern int filterMT; // enable multi-threading for pixel filters
+extern int filterType;
+extern int filterWidth;
+extern int frameSkip;
+extern int frameskipadjust;
+extern int fsAdapter;
+extern int fsColorDepth;
+extern int fsForceChange;
+extern int fsFrequency;
+extern int fsHeight;
+extern int fsWidth;
+extern int fullScreen;
+extern int fullScreenStretch;
+extern int gdbBreakOnLoad;
+extern int gdbPort;
+extern int glFilter;
+extern int joypadDefault;
+extern int languageOption;
+extern int layerEnable;
+extern int layerSettings;
+extern int linkAuto;
+extern int linkHacks;
+extern int linkMode;
+extern int linkNumPlayers;
+extern int linkTimeout;
+extern int maxScale;
+extern int movieFrame;
+extern int moviePlayFrame;
+extern int moviePlaying;
+extern int movieRecording;
+extern int openGL;
+extern int autoPatch;
+extern int optFlashSize;
+extern int optPrintUsage;
+extern int paused;
+extern int pauseWhenInactive;
+extern int recentFreeze;
+extern int renderedFrames;
+extern int rewindCount;
+extern int rewindCounter;
+extern int rewindPos;
+extern int rewindSaveNeeded;
+extern int rewindTimer;
+extern int rewindTopPos;
+//extern int romSize;
+extern int rtcEnabled;
+extern int saveType;
+extern int screenMessage;
+extern int sensorX;
+extern int sensorY;
+extern int showRenderedFrames;
+extern int showSpeed;
+extern int showSpeedTransparent;
+extern int sizeX;
+extern int sizeY;
+extern int skipBios;
+extern int skipSaveGameBattery;
+extern int skipSaveGameCheats;
+extern int soundRecording;
+extern int speedupToggle;
+extern int sunBars;
+extern int surfaceSizeX;
+extern int surfaceSizeY;
+extern int synchronize;
+extern int threadPriority;
+extern int tripleBuffering;
+extern int useBios;
+extern int useBiosFileGB;
+extern int useBiosFileGBA;
+extern int useBiosFileGBC;
+extern int videoOption;
+extern int vsync;
+extern int wasPaused;
+extern int windowPositionX;
+extern int windowPositionY;
+extern int winFlashSize;
+extern int winGbBorderOn;
+extern int winGbPrinterEnabled;
+extern int winPauseNextFrame;
+extern u32 autoFrameSkipLastTime;
+extern u32 movieLastJoypad;
+extern u32 movieNextJoypad;
+extern unsigned short throttle;
+
+#define MAX_CHEATS 100
+extern int preparedCheats;
+extern const char* preparedCheatCodes[MAX_CHEATS];
+
+
+// allow up to 100 IPS/UPS/PPF patches given on commandline
+#define PATCH_MAX_NUM 100
+extern int patchNum;
+extern char *(patchNames[PATCH_MAX_NUM]); // and so on
+
+extern int mouseCounter;
+
+extern Filter filter;
+extern FilterFunc filterFunction;
+extern IFBFilterFunc ifbFunction;
+extern int ifbType;
+
+
+extern char* homeDir;
+extern char* screenShotDir;
+extern char* saveDir;
+extern char* batteryDir;
+
+// Directory within homedir to use for default save location.
+#define DOT_DIR ".vbam"
+
+void SetHome(char *_arg0);
+void SaveConfigFile();
+void CloseConfig();
+u32 ReadPrefHex(char* pref_key);
+u32 ReadPref(char* pref_key, int default_value);
+u32 ReadPref(char* pref_key);
+char* ReadPrefString(char* pref_key, char* default_value);
+char* ReadPrefString(char* pref_key);
+void LoadConfigFile(int argc, char ** argv);
+void LoadConfig();
+int ReadOpts(int argc, char ** argv);
+#endif
\ No newline at end of file
diff --git a/src/common/SoundSDL.cpp b/src/common/SoundSDL.cpp
index c06daf5e..77ec725e 100644
--- a/src/common/SoundSDL.cpp
+++ b/src/common/SoundSDL.cpp
@@ -16,9 +16,10 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "SoundSDL.h"
+#include "ConfigManager.h"
+#include "../gba/Globals.h"
extern int emulating;
-extern bool speedup;
// Hold up to 100 ms of data in the ring buffer
const float SoundSDL::_delay = 0.1f;
@@ -44,7 +45,7 @@ void SoundSDL::read(u16 * stream, int length)
/* since this is running in a different thread, speedup and
* throttle can change at any time; save the value so locks
* stay in sync */
- bool lock = (emulating && !speedup) ? true : false;
+ bool lock = (emulating && !speedup && synchronize && !gba_joybus_active) ? true : false;
if (lock)
SDL_SemWait (_semBufferFull);
@@ -73,7 +74,7 @@ void SoundSDL::write(u16 * finalWave, int length)
std::size_t avail;
while ((avail = _rbuf.avail() / 2) < samples)
{
- bool lock = (emulating && !speedup) ? true : false;
+ bool lock = (emulating && !speedup && synchronize && !gba_joybus_active) ? true : false;
_rbuf.write(finalWave, avail * 2);
diff --git a/src/common/dictionary.c b/src/common/dictionary.c
new file mode 100644
index 00000000..91a4a715
--- /dev/null
+++ b/src/common/dictionary.c
@@ -0,0 +1,398 @@
+/*-------------------------------------------------------------------------*/
+/**
+ @file dictionary.c
+ @author N. Devillard
+ @brief Implements a dictionary for string variables.
+
+ This module implements a simple dictionary object, i.e. a list
+ of string/string associations. This object is useful to store e.g.
+ informations retrieved from a configuration file (ini files).
+*/
+/*--------------------------------------------------------------------------*/
+
+/*---------------------------------------------------------------------------
+ Includes
+ ---------------------------------------------------------------------------*/
+#include "dictionary.h"
+
+#include
+#include
+#include
+//#include
+
+/** Maximum value size for integers and doubles. */
+#define MAXVALSZ 1024
+
+/** Minimal allocated number of entries in a dictionary */
+#define DICTMINSZ 128
+
+/** Invalid key token */
+#define DICT_INVALID_KEY ((char*)-1)
+
+/*---------------------------------------------------------------------------
+ Private functions
+ ---------------------------------------------------------------------------*/
+
+/* Doubles the allocated size associated to a pointer */
+/* 'size' is the current allocated size. */
+static void * mem_double(void * ptr, int size)
+{
+ void * newptr ;
+
+ newptr = calloc(2*size, 1);
+ if (newptr==NULL) {
+ return NULL ;
+ }
+ memcpy(newptr, ptr, size);
+ free(ptr);
+ return newptr ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Duplicate a string
+ @param s String to duplicate
+ @return Pointer to a newly allocated string, to be freed with free()
+
+ This is a replacement for strdup(). This implementation is provided
+ for systems that do not have it.
+ */
+/*--------------------------------------------------------------------------*/
+static char * xstrdup(const char * s)
+{
+ char * t ;
+ if (!s)
+ return NULL ;
+ t = (char*)malloc(strlen(s)+1) ;
+ if (t) {
+ strcpy(t,s);
+ }
+ return t ;
+}
+
+/*---------------------------------------------------------------------------
+ Function codes
+ ---------------------------------------------------------------------------*/
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Compute the hash key for a string.
+ @param key Character string to use for key.
+ @return 1 unsigned int on at least 32 bits.
+
+ This hash function has been taken from an Article in Dr Dobbs Journal.
+ This is normally a collision-free function, distributing keys evenly.
+ The key is stored anyway in the struct so that collision can be avoided
+ by comparing the key itself in last resort.
+ */
+/*--------------------------------------------------------------------------*/
+unsigned dictionary_hash(const char * key)
+{
+ int len ;
+ unsigned hash ;
+ int i ;
+
+ len = strlen(key);
+ for (hash=0, i=0 ; i>6) ;
+ }
+ hash += (hash <<3);
+ hash ^= (hash >>11);
+ hash += (hash <<15);
+ return hash ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Create a new dictionary object.
+ @param size Optional initial size of the dictionary.
+ @return 1 newly allocated dictionary objet.
+
+ This function allocates a new dictionary object of given size and returns
+ it. If you do not know in advance (roughly) the number of entries in the
+ dictionary, give size=0.
+ */
+/*--------------------------------------------------------------------------*/
+dictionary * dictionary_new(int size)
+{
+ dictionary * d ;
+
+ /* If no size was specified, allocate space for DICTMINSZ */
+ if (sizesize = size ;
+ d->val = (char **)calloc(size, sizeof(char*));
+ d->key = (char **)calloc(size, sizeof(char*));
+ d->hash = (unsigned int *)calloc(size, sizeof(unsigned));
+ return d ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete a dictionary object
+ @param d dictionary object to deallocate.
+ @return void
+
+ Deallocate a dictionary object and all memory associated to it.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_del(dictionary * d)
+{
+ int i ;
+
+ if (d==NULL) return ;
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]!=NULL)
+ free(d->key[i]);
+ if (d->val[i]!=NULL)
+ free(d->val[i]);
+ }
+ free(d->val);
+ free(d->key);
+ free(d->hash);
+ free(d);
+ return ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get a value from a dictionary.
+ @param d dictionary object to search.
+ @param key Key to look for in the dictionary.
+ @param def Default value to return if key not found.
+ @return 1 pointer to internally allocated character string.
+
+ This function locates a key in a dictionary and returns a pointer to its
+ value, or the passed 'def' pointer if no such key can be found in
+ dictionary. The returned character pointer points to data internal to the
+ dictionary object, you should not try to free it or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * dictionary_get(dictionary * d, const char * key, char * def)
+{
+ unsigned hash ;
+ int i ;
+
+ hash = dictionary_hash(key);
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ /* Compare hash */
+ if (hash==d->hash[i]) {
+ /* Compare string, to avoid hash collisions */
+ if (!strcmp(key, d->key[i])) {
+ return d->val[i] ;
+ }
+ }
+ }
+ return def ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Set a value in a dictionary.
+ @param d dictionary object to modify.
+ @param key Key to modify or add.
+ @param val Value to add.
+ @return int 0 if Ok, anything else otherwise
+
+ If the given key is found in the dictionary, the associated value is
+ replaced by the provided one. If the key cannot be found in the
+ dictionary, it is added to it.
+
+ It is Ok to provide a NULL value for val, but NULL values for the dictionary
+ or the key are considered as errors: the function will return immediately
+ in such a case.
+
+ Notice that if you dictionary_set a variable to NULL, a call to
+ dictionary_get will return a NULL value: the variable will be found, and
+ its value (NULL) is returned. In other words, setting the variable
+ content to NULL is equivalent to deleting the variable from the
+ dictionary. It is not possible (in this implementation) to have a key in
+ the dictionary without value.
+
+ This function returns non-zero in case of failure.
+ */
+/*--------------------------------------------------------------------------*/
+int dictionary_set(dictionary * d, const char * key, const char * val)
+{
+ int i ;
+ unsigned hash ;
+
+ if (d==NULL || key==NULL) return -1 ;
+
+ /* Compute hash for this key */
+ hash = dictionary_hash(key) ;
+ /* Find if value is already in dictionary */
+ if (d->n>0) {
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (hash==d->hash[i]) { /* Same hash value */
+ if (!strcmp(key, d->key[i])) { /* Same key */
+ /* Found a value: modify and return */
+ if (d->val[i]!=NULL)
+ free(d->val[i]);
+ d->val[i] = val ? xstrdup(val) : NULL ;
+ /* Value has been modified: return */
+ return 0 ;
+ }
+ }
+ }
+ }
+ /* Add a new value */
+ /* See if dictionary needs to grow */
+ if (d->n==d->size) {
+
+ /* Reached maximum size: reallocate dictionary */
+ d->val = (char **)mem_double(d->val, d->size * sizeof(char*)) ;
+ d->key = (char **)mem_double(d->key, d->size * sizeof(char*)) ;
+ d->hash = (unsigned int *)mem_double(d->hash, d->size * sizeof(unsigned)) ;
+ if ((d->val==NULL) || (d->key==NULL) || (d->hash==NULL)) {
+ /* Cannot grow dictionary */
+ return -1 ;
+ }
+ /* Double size */
+ d->size *= 2 ;
+ }
+
+ /* Insert key in the first empty slot. Start at d->n and wrap at
+ d->size. Because d->n < d->size this will necessarily
+ terminate. */
+ for (i=d->n ; d->key[i] ; ) {
+ if(++i == d->size) i = 0;
+ }
+ /* Copy key */
+ d->key[i] = xstrdup(key);
+ d->val[i] = val ? xstrdup(val) : NULL ;
+ d->hash[i] = hash;
+ d->n ++ ;
+ return 0 ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete a key in a dictionary
+ @param d dictionary object to modify.
+ @param key Key to remove.
+ @return void
+
+ This function deletes a key in a dictionary. Nothing is done if the
+ key cannot be found.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_unset(dictionary * d, const char * key)
+{
+ unsigned hash ;
+ int i ;
+
+ if (key == NULL) {
+ return;
+ }
+
+ hash = dictionary_hash(key);
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ /* Compare hash */
+ if (hash==d->hash[i]) {
+ /* Compare string, to avoid hash collisions */
+ if (!strcmp(key, d->key[i])) {
+ /* Found key */
+ break ;
+ }
+ }
+ }
+ if (i>=d->size)
+ /* Key not found */
+ return ;
+
+ free(d->key[i]);
+ d->key[i] = NULL ;
+ if (d->val[i]!=NULL) {
+ free(d->val[i]);
+ d->val[i] = NULL ;
+ }
+ d->hash[i] = 0 ;
+ d->n -- ;
+ return ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dump a dictionary to an opened file pointer.
+ @param d Dictionary to dump
+ @param f Opened file pointer.
+ @return void
+
+ Dumps a dictionary onto an opened file pointer. Key pairs are printed out
+ as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
+ output file pointers.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_dump(dictionary * d, FILE * out)
+{
+ int i ;
+
+ if (d==NULL || out==NULL) return ;
+ if (d->n<1) {
+ fprintf(out, "empty dictionary\n");
+ return ;
+ }
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]) {
+ fprintf(out, "%20s\t[%s]\n",
+ d->key[i],
+ d->val[i] ? d->val[i] : "UNDEF");
+ }
+ }
+ return ;
+}
+
+
+/* Test code */
+#ifdef TESTDIC
+#define NVALS 20000
+int main(int argc, char *argv[])
+{
+ dictionary * d ;
+ char * val ;
+ int i ;
+ char cval[90] ;
+
+ /* Allocate dictionary */
+ printf("allocating...\n");
+ d = dictionary_new(0);
+
+ /* Set values in dictionary */
+ printf("setting %d values...\n", NVALS);
+ for (i=0 ; in != 0) {
+ printf("error deleting values\n");
+ }
+ printf("deallocating...\n");
+ dictionary_del(d);
+ return 0 ;
+}
+#endif
+/* vim: set ts=4 et sw=4 tw=75 */
diff --git a/src/common/dictionary.h b/src/common/dictionary.h
new file mode 100644
index 00000000..f142cbce
--- /dev/null
+++ b/src/common/dictionary.h
@@ -0,0 +1,165 @@
+
+/*-------------------------------------------------------------------------*/
+/**
+ @file dictionary.h
+ @author N. Devillard
+ @brief Implements a dictionary for string variables.
+
+ This module implements a simple dictionary object, i.e. a list
+ of string/string associations. This object is useful to store e.g.
+ informations retrieved from a configuration file (ini files).
+*/
+/*--------------------------------------------------------------------------*/
+
+#ifndef _DICTIONARY_H_
+#define _DICTIONARY_H_
+
+/*---------------------------------------------------------------------------
+ Includes
+ ---------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+//#include
+
+/*---------------------------------------------------------------------------
+ New types
+ ---------------------------------------------------------------------------*/
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dictionary object
+
+ This object contains a list of string/string associations. Each
+ association is identified by a unique string key. Looking up values
+ in the dictionary is speeded up by the use of a (hopefully collision-free)
+ hash function.
+ */
+/*-------------------------------------------------------------------------*/
+typedef struct _dictionary_ {
+ int n ; /** Number of entries in dictionary */
+ int size ; /** Storage size */
+ char ** val ; /** List of string values */
+ char ** key ; /** List of string keys */
+ unsigned * hash ; /** List of hash values for keys */
+} dictionary ;
+
+
+/*---------------------------------------------------------------------------
+ Function prototypes
+ ---------------------------------------------------------------------------*/
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Compute the hash key for a string.
+ @param key Character string to use for key.
+ @return 1 unsigned int on at least 32 bits.
+
+ This hash function has been taken from an Article in Dr Dobbs Journal.
+ This is normally a collision-free function, distributing keys evenly.
+ The key is stored anyway in the struct so that collision can be avoided
+ by comparing the key itself in last resort.
+ */
+/*--------------------------------------------------------------------------*/
+unsigned dictionary_hash(const char * key);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Create a new dictionary object.
+ @param size Optional initial size of the dictionary.
+ @return 1 newly allocated dictionary objet.
+
+ This function allocates a new dictionary object of given size and returns
+ it. If you do not know in advance (roughly) the number of entries in the
+ dictionary, give size=0.
+ */
+/*--------------------------------------------------------------------------*/
+dictionary * dictionary_new(int size);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete a dictionary object
+ @param d dictionary object to deallocate.
+ @return void
+
+ Deallocate a dictionary object and all memory associated to it.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_del(dictionary * vd);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get a value from a dictionary.
+ @param d dictionary object to search.
+ @param key Key to look for in the dictionary.
+ @param def Default value to return if key not found.
+ @return 1 pointer to internally allocated character string.
+
+ This function locates a key in a dictionary and returns a pointer to its
+ value, or the passed 'def' pointer if no such key can be found in
+ dictionary. The returned character pointer points to data internal to the
+ dictionary object, you should not try to free it or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * dictionary_get(dictionary * d, const char * key, char * def);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Set a value in a dictionary.
+ @param d dictionary object to modify.
+ @param key Key to modify or add.
+ @param val Value to add.
+ @return int 0 if Ok, anything else otherwise
+
+ If the given key is found in the dictionary, the associated value is
+ replaced by the provided one. If the key cannot be found in the
+ dictionary, it is added to it.
+
+ It is Ok to provide a NULL value for val, but NULL values for the dictionary
+ or the key are considered as errors: the function will return immediately
+ in such a case.
+
+ Notice that if you dictionary_set a variable to NULL, a call to
+ dictionary_get will return a NULL value: the variable will be found, and
+ its value (NULL) is returned. In other words, setting the variable
+ content to NULL is equivalent to deleting the variable from the
+ dictionary. It is not possible (in this implementation) to have a key in
+ the dictionary without value.
+
+ This function returns non-zero in case of failure.
+ */
+/*--------------------------------------------------------------------------*/
+int dictionary_set(dictionary * vd, const char * key, const char * val);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete a key in a dictionary
+ @param d dictionary object to modify.
+ @param key Key to remove.
+ @return void
+
+ This function deletes a key in a dictionary. Nothing is done if the
+ key cannot be found.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_unset(dictionary * d, const char * key);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dump a dictionary to an opened file pointer.
+ @param d Dictionary to dump
+ @param f Opened file pointer.
+ @return void
+
+ Dumps a dictionary onto an opened file pointer. Key pairs are printed out
+ as @c [Key]=[Value], one per line. It is Ok to provide stdout or stderr as
+ output file pointers.
+ */
+/*--------------------------------------------------------------------------*/
+void dictionary_dump(dictionary * d, FILE * out);
+
+#endif
diff --git a/src/common/iniparser.c b/src/common/iniparser.c
new file mode 100644
index 00000000..44527543
--- /dev/null
+++ b/src/common/iniparser.c
@@ -0,0 +1,748 @@
+
+/*-------------------------------------------------------------------------*/
+/**
+ @file iniparser.c
+ @author N. Devillard
+ @brief Parser for ini files.
+*/
+/*--------------------------------------------------------------------------*/
+/*---------------------------- Includes ------------------------------------*/
+#include
+#include "iniparser.h"
+
+/*---------------------------- Defines -------------------------------------*/
+#define ASCIILINESZ (1024)
+#define INI_INVALID_KEY ((char*)-1)
+
+/*---------------------------------------------------------------------------
+ Private to this module
+ ---------------------------------------------------------------------------*/
+/**
+ * This enum stores the status for each parsed line (internal use only).
+ */
+typedef enum _line_status_ {
+ LINE_UNPROCESSED,
+ LINE_ERROR,
+ LINE_EMPTY,
+ LINE_COMMENT,
+ LINE_SECTION,
+ LINE_VALUE
+} line_status ;
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Convert a string to lowercase.
+ @param s String to convert.
+ @return ptr to statically allocated string.
+
+ This function returns a pointer to a statically allocated string
+ containing a lowercased version of the input string. Do not free
+ or modify the returned string! Since the returned string is statically
+ allocated, it will be modified at each function call (not re-entrant).
+ */
+/*--------------------------------------------------------------------------*/
+static char * strlwc(const char * s)
+{
+ static char l[ASCIILINESZ+1];
+ int i ;
+
+ if (s==NULL) return NULL ;
+ memset(l, 0, ASCIILINESZ+1);
+ i=0 ;
+ while (s[i] && i l) {
+ if (!isspace((int)*(last-1)))
+ break ;
+ last -- ;
+ }
+ *last = (char)0;
+ return (char*)l ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get number of sections in a dictionary
+ @param d Dictionary to examine
+ @return int Number of sections found in dictionary
+
+ This function returns the number of sections found in a dictionary.
+ The test to recognize sections is done on the string stored in the
+ dictionary: a section name is given as "section" whereas a key is
+ stored as "section:key", thus the test looks for entries that do not
+ contain a colon.
+
+ This clearly fails in the case a section name contains a colon, but
+ this should simply be avoided.
+
+ This function returns -1 in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getnsec(dictionary * d)
+{
+ int i ;
+ int nsec ;
+
+ if (d==NULL) return -1 ;
+ nsec=0 ;
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (strchr(d->key[i], ':')==NULL) {
+ nsec ++ ;
+ }
+ }
+ return nsec ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get name for section n in a dictionary.
+ @param d Dictionary to examine
+ @param n Section number (from 0 to nsec-1).
+ @return Pointer to char string
+
+ This function locates the n-th section in a dictionary and returns
+ its name as a pointer to a string statically allocated inside the
+ dictionary. Do not free or modify the returned string!
+
+ This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+char * iniparser_getsecname(dictionary * d, int n)
+{
+ int i ;
+ int foundsec ;
+
+ if (d==NULL || n<0) return NULL ;
+ foundsec=0 ;
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (strchr(d->key[i], ':')==NULL) {
+ foundsec++ ;
+ if (foundsec>n)
+ break ;
+ }
+ }
+ if (foundsec<=n) {
+ return NULL ;
+ }
+ return d->key[i] ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dump a dictionary to an opened file pointer.
+ @param d Dictionary to dump.
+ @param f Opened file pointer to dump to.
+ @return void
+
+ This function prints out the contents of a dictionary, one element by
+ line, onto the provided file pointer. It is OK to specify @c stderr
+ or @c stdout as output files. This function is meant for debugging
+ purposes mostly.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_dump(dictionary * d, FILE * f)
+{
+ int i ;
+
+ if (d==NULL || f==NULL) return ;
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ if (d->val[i]!=NULL) {
+ fprintf(f, "[%s]=[%s]\n", d->key[i], d->val[i]);
+ } else {
+ fprintf(f, "[%s]=UNDEF\n", d->key[i]);
+ }
+ }
+ return ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Save a dictionary to a loadable ini file
+ @param d Dictionary to dump
+ @param f Opened file pointer to dump to
+ @return void
+
+ This function dumps a given dictionary into a loadable ini file.
+ It is Ok to specify @c stderr or @c stdout as output files.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_dump_ini(dictionary * d, FILE * f)
+{
+ int i ;
+ int nsec ;
+ char * secname ;
+
+ if (d==NULL || f==NULL) return ;
+
+ nsec = iniparser_getnsec(d);
+ if (nsec<1) {
+ /* No section in file: dump all keys as they are */
+ for (i=0 ; isize ; i++) {
+ if (d->key[i]==NULL)
+ continue ;
+ fprintf(f, "%s=%s\n", d->key[i], d->val[i]);
+ }
+ return ;
+ }
+ for (i=0 ; isize ; j++) {
+ if (d->key[j]==NULL)
+ continue ;
+ if (!strncmp(d->key[j], keym, seclen+1)) {
+ fprintf(f,
+ "%s=%s\n",
+ d->key[j]+seclen+1,
+ d->val[j] ? d->val[j] : "");
+ }
+ }
+ fprintf(f, "\n");
+ return ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the number of keys in a section of a dictionary.
+ @param d Dictionary to examine
+ @param s Section name of dictionary to examine
+ @return Number of keys in section
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getsecnkeys(dictionary * d, char * s)
+{
+ int seclen, nkeys ;
+ char keym[ASCIILINESZ+1];
+ int j ;
+
+ nkeys = 0;
+
+ if (d==NULL) return nkeys;
+ if (! iniparser_find_entry(d, s)) return nkeys;
+
+ seclen = (int)strlen(s);
+ sprintf(keym, "%s:", s);
+
+ for (j=0 ; jsize ; j++) {
+ if (d->key[j]==NULL)
+ continue ;
+ if (!strncmp(d->key[j], keym, seclen+1))
+ nkeys++;
+ }
+
+ return nkeys;
+
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the number of keys in a section of a dictionary.
+ @param d Dictionary to examine
+ @param s Section name of dictionary to examine
+ @return pointer to statically allocated character strings
+
+ This function queries a dictionary and finds all keys in a given section.
+ Each pointer in the returned char pointer-to-pointer is pointing to
+ a string allocated in the dictionary; do not free or modify them.
+
+ This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+char ** iniparser_getseckeys(dictionary * d, char * s)
+{
+
+ char **keys;
+
+ int i, j ;
+ char keym[ASCIILINESZ+1];
+ int seclen, nkeys ;
+
+ keys = NULL;
+
+ if (d==NULL) return keys;
+ if (! iniparser_find_entry(d, s)) return keys;
+
+ nkeys = iniparser_getsecnkeys(d, s);
+
+ keys = (char**) malloc(nkeys*sizeof(char*));
+
+ seclen = (int)strlen(s);
+ sprintf(keym, "%s:", s);
+
+ i = 0;
+
+ for (j=0 ; jsize ; j++) {
+ if (d->key[j]==NULL)
+ continue ;
+ if (!strncmp(d->key[j], keym, seclen+1)) {
+ keys[i] = d->key[j];
+ i++;
+ }
+ }
+
+ return keys;
+
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param def Default value to return if key not found.
+ @return pointer to statically allocated character string
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the pointer passed as 'def' is returned.
+ The returned char pointer is pointing to a string allocated in
+ the dictionary, do not free or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * iniparser_getstring(dictionary * d, const char * key, char * def)
+{
+ char * lc_key ;
+ char * sval ;
+
+ if (d==NULL || key==NULL)
+ return def ;
+
+ lc_key = strlwc(key);
+ sval = dictionary_get(d, lc_key, def);
+ return sval ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to an int
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return integer
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+
+ Supported values for integers include the usual C notation
+ so decimal, octal (starting with 0) and hexadecimal (starting with 0x)
+ are supported. Examples:
+
+ "42" -> 42
+ "042" -> 34 (octal -> decimal)
+ "0x42" -> 66 (hexa -> decimal)
+
+ Warning: the conversion may overflow in various ways. Conversion is
+ totally outsourced to strtol(), see the associated man page for overflow
+ handling.
+
+ Credits: Thanks to A. Becker for suggesting strtol()
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getint(dictionary * d, const char * key, int notfound)
+{
+ char * str ;
+
+ str = iniparser_getstring(d, key, INI_INVALID_KEY);
+ if (str==INI_INVALID_KEY) return notfound ;
+ return (int)strtol(str, NULL, 0);
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to a double
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return double
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+ */
+/*--------------------------------------------------------------------------*/
+double iniparser_getdouble(dictionary * d, const char * key, double notfound)
+{
+ char * str ;
+
+ str = iniparser_getstring(d, key, INI_INVALID_KEY);
+ if (str==INI_INVALID_KEY) return notfound ;
+ return atof(str);
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to a boolean
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return integer
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+
+ A true boolean is found if one of the following is matched:
+
+ - A string starting with 'y'
+ - A string starting with 'Y'
+ - A string starting with 't'
+ - A string starting with 'T'
+ - A string starting with '1'
+
+ A false boolean is found if one of the following is matched:
+
+ - A string starting with 'n'
+ - A string starting with 'N'
+ - A string starting with 'f'
+ - A string starting with 'F'
+ - A string starting with '0'
+
+ The notfound value returned if no boolean is identified, does not
+ necessarily have to be 0 or 1.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getboolean(dictionary * d, const char * key, int notfound)
+{
+ char * c ;
+ int ret ;
+
+ c = iniparser_getstring(d, key, INI_INVALID_KEY);
+ if (c==INI_INVALID_KEY) return notfound ;
+ if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') {
+ ret = 1 ;
+ } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') {
+ ret = 0 ;
+ } else {
+ ret = notfound ;
+ }
+ return ret;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Finds out if a given entry exists in a dictionary
+ @param ini Dictionary to search
+ @param entry Name of the entry to look for
+ @return integer 1 if entry exists, 0 otherwise
+
+ Finds out if a given entry exists in the dictionary. Since sections
+ are stored as keys with NULL associated values, this is the only way
+ of querying for the presence of sections in a dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_find_entry(
+ dictionary * ini,
+ const char * entry
+)
+{
+ int found=0 ;
+ if (iniparser_getstring(ini, entry, INI_INVALID_KEY)!=INI_INVALID_KEY) {
+ found = 1 ;
+ }
+ return found ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Set an entry in a dictionary.
+ @param ini Dictionary to modify.
+ @param entry Entry to modify (entry name)
+ @param val New value to associate to the entry.
+ @return int 0 if Ok, -1 otherwise.
+
+ If the given entry can be found in the dictionary, it is modified to
+ contain the provided value. If it cannot be found, -1 is returned.
+ It is Ok to set val to NULL.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_set(dictionary * ini, const char * entry, const char * val)
+{
+ return dictionary_set(ini, strlwc(entry), val) ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete an entry in a dictionary
+ @param ini Dictionary to modify
+ @param entry Entry to delete (entry name)
+ @return void
+
+ If the given entry can be found, it is deleted from the dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_unset(dictionary * ini, const char * entry)
+{
+ dictionary_unset(ini, strlwc(entry));
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Load a single line from an INI file
+ @param input_line Input line, may be concatenated multi-line input
+ @param section Output space to store section
+ @param key Output space to store key
+ @param value Output space to store value
+ @return line_status value
+ */
+/*--------------------------------------------------------------------------*/
+static line_status iniparser_line(
+ const char * input_line,
+ char * section,
+ char * key,
+ char * value)
+{
+ line_status sta ;
+ char line[ASCIILINESZ+1];
+ int len ;
+
+ strcpy(line, strstrip(input_line));
+ len = (int)strlen(line);
+
+ sta = LINE_UNPROCESSED ;
+ if (len<1) {
+ /* Empty line */
+ sta = LINE_EMPTY ;
+ } else if (line[0]=='#' || line[0]==';') {
+ /* Comment line */
+ sta = LINE_COMMENT ;
+ } else if (line[0]=='[' && line[len-1]==']') {
+ /* Section name */
+ sscanf(line, "[%[^]]", section);
+ strcpy(section, strstrip(section));
+ strcpy(section, strlwc(section));
+ sta = LINE_SECTION ;
+ } else if (sscanf (line, "%[^=] = \"%[^\"]\"", key, value) == 2
+ || sscanf (line, "%[^=] = '%[^\']'", key, value) == 2
+ || sscanf (line, "%[^=] = %[^;#]", key, value) == 2) {
+ /* Usual key=value, with or without comments */
+ strcpy(key, strstrip(key));
+ strcpy(key, strlwc(key));
+ strcpy(value, strstrip(value));
+ /*
+ * sscanf cannot handle '' or "" as empty values
+ * this is done here
+ */
+ if (!strcmp(value, "\"\"") || (!strcmp(value, "''"))) {
+ value[0]=0 ;
+ }
+ sta = LINE_VALUE ;
+ } else if (sscanf(line, "%[^=] = %[;#]", key, value)==2
+ || sscanf(line, "%[^=] %[=]", key, value) == 2) {
+ /*
+ * Special cases:
+ * key=
+ * key=;
+ * key=#
+ */
+ strcpy(key, strstrip(key));
+ strcpy(key, strlwc(key));
+ value[0]=0 ;
+ sta = LINE_VALUE ;
+ } else {
+ /* Generate syntax error */
+ sta = LINE_ERROR ;
+ }
+ return sta ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Parse an ini file and return an allocated dictionary object
+ @param ininame Name of the ini file to read.
+ @return Pointer to newly allocated dictionary
+
+ This is the parser for ini files. This function is called, providing
+ the name of the file to be read. It returns a dictionary object that
+ should not be accessed directly, but through accessor functions
+ instead.
+
+ The returned dictionary must be freed using iniparser_freedict().
+ */
+/*--------------------------------------------------------------------------*/
+dictionary * iniparser_load(const char * ininame)
+{
+ FILE * in ;
+
+ char line [ASCIILINESZ+1] ;
+ char section [ASCIILINESZ+1] ;
+ char key [ASCIILINESZ+1] ;
+ char tmp [ASCIILINESZ+1] ;
+ char val [ASCIILINESZ+1] ;
+
+ int last=0 ;
+ int len ;
+ int lineno=0 ;
+ int errs=0;
+
+ dictionary * dict ;
+
+ if ((in=fopen(ininame, "r"))==NULL) {
+ fprintf(stderr, "iniparser: cannot open %s\n", ininame);
+ return NULL ;
+ }
+
+ dict = dictionary_new(0) ;
+ if (!dict) {
+ fclose(in);
+ return NULL ;
+ }
+
+ memset(line, 0, ASCIILINESZ);
+ memset(section, 0, ASCIILINESZ);
+ memset(key, 0, ASCIILINESZ);
+ memset(val, 0, ASCIILINESZ);
+ last=0 ;
+
+ while (fgets(line+last, ASCIILINESZ-last, in)!=NULL) {
+ lineno++ ;
+ len = (int)strlen(line)-1;
+ if (len==0)
+ continue;
+ /* Safety check against buffer overflows */
+ if (line[len]!='\n') {
+ fprintf(stderr,
+ "iniparser: input line too long in %s (%d)\n",
+ ininame,
+ lineno);
+ dictionary_del(dict);
+ fclose(in);
+ return NULL ;
+ }
+ /* Get rid of \n and spaces at end of line */
+ while ((len>=0) &&
+ ((line[len]=='\n') || (isspace(line[len])))) {
+ line[len]=0 ;
+ len-- ;
+ }
+ /* Detect multi-line */
+ if (line[len]=='\\') {
+ /* Multi-line value */
+ last=len ;
+ continue ;
+ } else {
+ last=0 ;
+ }
+ switch (iniparser_line(line, section, key, val)) {
+ case LINE_EMPTY:
+ case LINE_COMMENT:
+ break ;
+
+ case LINE_SECTION:
+ errs = dictionary_set(dict, section, NULL);
+ break ;
+
+ case LINE_VALUE:
+ sprintf(tmp, "%s:%s", section, key);
+ errs = dictionary_set(dict, tmp, val) ;
+ break ;
+
+ case LINE_ERROR:
+ fprintf(stderr, "iniparser: syntax error in %s (%d):\n",
+ ininame,
+ lineno);
+ fprintf(stderr, "-> %s\n", line);
+ errs++ ;
+ break;
+
+ default:
+ break ;
+ }
+ memset(line, 0, ASCIILINESZ);
+ last=0;
+ if (errs<0) {
+ fprintf(stderr, "iniparser: memory allocation failure\n");
+ break ;
+ }
+ }
+ if (errs) {
+ dictionary_del(dict);
+ dict = NULL ;
+ }
+ fclose(in);
+ return dict ;
+}
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Free all memory associated to an ini dictionary
+ @param d Dictionary to free
+ @return void
+
+ Free all memory associated to an ini dictionary.
+ It is mandatory to call this function before the dictionary object
+ gets out of the current context.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_freedict(dictionary * d)
+{
+ dictionary_del(d);
+}
+
+/* vim: set ts=4 et sw=4 tw=75 */
diff --git a/src/common/iniparser.h b/src/common/iniparser.h
new file mode 100644
index 00000000..ecd73bf9
--- /dev/null
+++ b/src/common/iniparser.h
@@ -0,0 +1,307 @@
+
+/*-------------------------------------------------------------------------*/
+/**
+ @file iniparser.h
+ @author N. Devillard
+ @brief Parser for ini files.
+*/
+/*--------------------------------------------------------------------------*/
+
+#ifndef _INIPARSER_H_
+#define _INIPARSER_H_
+
+/*---------------------------------------------------------------------------
+ Includes
+ ---------------------------------------------------------------------------*/
+
+#include
+#include
+#include
+
+/*
+ * The following #include is necessary on many Unixes but not Linux.
+ * It is not needed for Windows platforms.
+ * Uncomment it if needed.
+ */
+/* #include */
+
+#include "dictionary.h"
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get number of sections in a dictionary
+ @param d Dictionary to examine
+ @return int Number of sections found in dictionary
+
+ This function returns the number of sections found in a dictionary.
+ The test to recognize sections is done on the string stored in the
+ dictionary: a section name is given as "section" whereas a key is
+ stored as "section:key", thus the test looks for entries that do not
+ contain a colon.
+
+ This clearly fails in the case a section name contains a colon, but
+ this should simply be avoided.
+
+ This function returns -1 in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+
+int iniparser_getnsec(dictionary * d);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get name for section n in a dictionary.
+ @param d Dictionary to examine
+ @param n Section number (from 0 to nsec-1).
+ @return Pointer to char string
+
+ This function locates the n-th section in a dictionary and returns
+ its name as a pointer to a string statically allocated inside the
+ dictionary. Do not free or modify the returned string!
+
+ This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+
+char * iniparser_getsecname(dictionary * d, int n);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Save a dictionary to a loadable ini file
+ @param d Dictionary to dump
+ @param f Opened file pointer to dump to
+ @return void
+
+ This function dumps a given dictionary into a loadable ini file.
+ It is Ok to specify @c stderr or @c stdout as output files.
+ */
+/*--------------------------------------------------------------------------*/
+
+void iniparser_dump_ini(dictionary * d, FILE * f);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Save a dictionary section to a loadable ini file
+ @param d Dictionary to dump
+ @param s Section name of dictionary to dump
+ @param f Opened file pointer to dump to
+ @return void
+
+ This function dumps a given section of a given dictionary into a loadable ini
+ file. It is Ok to specify @c stderr or @c stdout as output files.
+ */
+/*--------------------------------------------------------------------------*/
+
+void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Dump a dictionary to an opened file pointer.
+ @param d Dictionary to dump.
+ @param f Opened file pointer to dump to.
+ @return void
+
+ This function prints out the contents of a dictionary, one element by
+ line, onto the provided file pointer. It is OK to specify @c stderr
+ or @c stdout as output files. This function is meant for debugging
+ purposes mostly.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_dump(dictionary * d, FILE * f);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the number of keys in a section of a dictionary.
+ @param d Dictionary to examine
+ @param s Section name of dictionary to examine
+ @return Number of keys in section
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getsecnkeys(dictionary * d, char * s);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the number of keys in a section of a dictionary.
+ @param d Dictionary to examine
+ @param s Section name of dictionary to examine
+ @return pointer to statically allocated character strings
+
+ This function queries a dictionary and finds all keys in a given section.
+ Each pointer in the returned char pointer-to-pointer is pointing to
+ a string allocated in the dictionary; do not free or modify them.
+
+ This function returns NULL in case of error.
+ */
+/*--------------------------------------------------------------------------*/
+char ** iniparser_getseckeys(dictionary * d, char * s);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param def Default value to return if key not found.
+ @return pointer to statically allocated character string
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the pointer passed as 'def' is returned.
+ The returned char pointer is pointing to a string allocated in
+ the dictionary, do not free or modify it.
+ */
+/*--------------------------------------------------------------------------*/
+char * iniparser_getstring(dictionary * d, const char * key, char * def);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to an int
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return integer
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+
+ Supported values for integers include the usual C notation
+ so decimal, octal (starting with 0) and hexadecimal (starting with 0x)
+ are supported. Examples:
+
+ - "42" -> 42
+ - "042" -> 34 (octal -> decimal)
+ - "0x42" -> 66 (hexa -> decimal)
+
+ Warning: the conversion may overflow in various ways. Conversion is
+ totally outsourced to strtol(), see the associated man page for overflow
+ handling.
+
+ Credits: Thanks to A. Becker for suggesting strtol()
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getint(dictionary * d, const char * key, int notfound);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to a double
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return double
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+ */
+/*--------------------------------------------------------------------------*/
+double iniparser_getdouble(dictionary * d, const char * key, double notfound);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Get the string associated to a key, convert to a boolean
+ @param d Dictionary to search
+ @param key Key string to look for
+ @param notfound Value to return in case of error
+ @return integer
+
+ This function queries a dictionary for a key. A key as read from an
+ ini file is given as "section:key". If the key cannot be found,
+ the notfound value is returned.
+
+ A true boolean is found if one of the following is matched:
+
+ - A string starting with 'y'
+ - A string starting with 'Y'
+ - A string starting with 't'
+ - A string starting with 'T'
+ - A string starting with '1'
+
+ A false boolean is found if one of the following is matched:
+
+ - A string starting with 'n'
+ - A string starting with 'N'
+ - A string starting with 'f'
+ - A string starting with 'F'
+ - A string starting with '0'
+
+ The notfound value returned if no boolean is identified, does not
+ necessarily have to be 0 or 1.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_getboolean(dictionary * d, const char * key, int notfound);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Set an entry in a dictionary.
+ @param ini Dictionary to modify.
+ @param entry Entry to modify (entry name)
+ @param val New value to associate to the entry.
+ @return int 0 if Ok, -1 otherwise.
+
+ If the given entry can be found in the dictionary, it is modified to
+ contain the provided value. If it cannot be found, -1 is returned.
+ It is Ok to set val to NULL.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_set(dictionary * ini, const char * entry, const char * val);
+
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Delete an entry in a dictionary
+ @param ini Dictionary to modify
+ @param entry Entry to delete (entry name)
+ @return void
+
+ If the given entry can be found, it is deleted from the dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_unset(dictionary * ini, const char * entry);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Finds out if a given entry exists in a dictionary
+ @param ini Dictionary to search
+ @param entry Name of the entry to look for
+ @return integer 1 if entry exists, 0 otherwise
+
+ Finds out if a given entry exists in the dictionary. Since sections
+ are stored as keys with NULL associated values, this is the only way
+ of querying for the presence of sections in a dictionary.
+ */
+/*--------------------------------------------------------------------------*/
+int iniparser_find_entry(dictionary * ini, const char * entry) ;
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Parse an ini file and return an allocated dictionary object
+ @param ininame Name of the ini file to read.
+ @return Pointer to newly allocated dictionary
+
+ This is the parser for ini files. This function is called, providing
+ the name of the file to be read. It returns a dictionary object that
+ should not be accessed directly, but through accessor functions
+ instead.
+
+ The returned dictionary must be freed using iniparser_freedict().
+ */
+/*--------------------------------------------------------------------------*/
+dictionary * iniparser_load(const char * ininame);
+
+/*-------------------------------------------------------------------------*/
+/**
+ @brief Free all memory associated to an ini dictionary
+ @param d Dictionary to free
+ @return void
+
+ Free all memory associated to an ini dictionary.
+ It is mandatory to call this function before the dictionary object
+ gets out of the current context.
+ */
+/*--------------------------------------------------------------------------*/
+void iniparser_freedict(dictionary * d);
+
+#endif
diff --git a/src/gb/GB.cpp b/src/gb/GB.cpp
index 2a0ecf55..f392b96c 100644
--- a/src/gb/GB.cpp
+++ b/src/gb/GB.cpp
@@ -15,13 +15,13 @@
#include "gbSound.h"
#include "../Util.h"
#include "../gba/GBALink.h"
+#include "../common/ConfigManager.h"
#ifdef __GNUC__
#define _stricmp strcasecmp
#endif
extern u8 *pix;
-extern bool speedup;
bool gbUpdateSizes();
bool inBios = false;
diff --git a/src/gb/gbCheats.cpp b/src/gb/gbCheats.cpp
index 444b052e..365ecc1f 100644
--- a/src/gb/gbCheats.cpp
+++ b/src/gb/gbCheats.cpp
@@ -10,14 +10,13 @@
#include "gbCheats.h"
#include "gbGlobals.h"
#include "gb.h"
+#include "../common/ConfigManager.h"
gbCheat gbCheatList[100];
int gbCheatNumber = 0;
int gbNextCheat = 0;
bool gbCheatMap[0x10000];
-extern bool cheatsEnabled;
-
#define GBCHEAT_IS_HEX(a) ( ((a)>='A' && (a) <='F') || ((a) >='0' && (a) <= '9'))
#define GBCHEAT_HEX_VALUE(a) ( (a) >= 'A' ? (a) - 'A' + 10 : (a) - '0')
diff --git a/src/gb/gbGlobals.h b/src/gb/gbGlobals.h
index d6c19b6c..c7b71d4e 100644
--- a/src/gb/gbGlobals.h
+++ b/src/gb/gbGlobals.h
@@ -7,11 +7,7 @@ extern int gbRamSize;
extern int gbRamSizeMask;
extern int gbTAMA5ramSize;
-extern bool useBios;
-extern bool skipBios;
extern u8 *bios;
-extern bool skipSaveGameBattery;
-extern bool skipSaveGameCheats;
extern u8 *gbRom;
extern u8 *gbRam;
diff --git a/src/gba/GBA-arm.cpp b/src/gba/GBA-arm.cpp
index b0633ca7..395df5d3 100644
--- a/src/gba/GBA-arm.cpp
+++ b/src/gba/GBA-arm.cpp
@@ -18,6 +18,7 @@
#include "elf.h"
#include "../Util.h"
#include "../System.h"
+#include "../common/ConfigManager.h"
#include "agbprint.h"
#include "remote.h"
diff --git a/src/gba/GBA-thumb.cpp b/src/gba/GBA-thumb.cpp
index d0dc71e3..de5cfed8 100644
--- a/src/gba/GBA-thumb.cpp
+++ b/src/gba/GBA-thumb.cpp
@@ -21,6 +21,7 @@
#include "elf.h"
#include "../Util.h"
#include "../System.h"
+#include "../common/ConfigManager.h"
#include "agbprint.h"
#include "remote.h"
diff --git a/src/gba/GBA.cpp b/src/gba/GBA.cpp
index 21c36f0e..a0a18e40 100644
--- a/src/gba/GBA.cpp
+++ b/src/gba/GBA.cpp
@@ -22,6 +22,7 @@
#include "elf.h"
#include "../Util.h"
#include "../common/Port.h"
+#include "../common/ConfigManager.h"
#include "../System.h"
#include "agbprint.h"
#include "ereader.h"
diff --git a/src/gba/Globals.cpp b/src/gba/Globals.cpp
index 2c6ce227..a28d0ecc 100644
--- a/src/gba/Globals.cpp
+++ b/src/gba/Globals.cpp
@@ -17,23 +17,6 @@ bool armIrqEnable = true;
u32 armNextPC = 0x00000000;
int armMode = 0x1f;
u32 stop = 0x08000568;
-int saveType = 0;
-bool useBios = false;
-bool skipBios = false;
-int frameSkip = 1;
-bool speedup = false;
-bool synchronize = true;
-bool cpuDisableSfx = false;
-bool cpuIsMultiBoot = false;
-bool parseDebug = true;
-int layerSettings = 0xff00;
-int layerEnable = 0xff00;
-bool speedHack = false;
-int cpuSaveType = 0;
-bool cheatsEnabled = true;
-bool mirroringEnable = true;
-bool skipSaveGameBattery = false;
-bool skipSaveGameCheats = false;
// this is an optional hack to change the backdrop/background color:
// -1: disabled
diff --git a/src/gba/Globals.h b/src/gba/Globals.h
index 8ca7f592..044a75e1 100644
--- a/src/gba/Globals.h
+++ b/src/gba/Globals.h
@@ -28,24 +28,12 @@ extern u32 armNextPC;
extern int armMode;
extern u32 stop;
extern int saveType;
-extern bool useBios;
-extern bool skipBios;
extern int frameSkip;
-extern bool speedup;
-extern bool synchronize;
extern bool gba_joybus_enabled;
extern bool gba_joybus_active;
-extern bool cpuDisableSfx;
-extern bool cpuIsMultiBoot;
-extern bool parseDebug;
extern int layerSettings;
extern int layerEnable;
-extern bool speedHack;
extern int cpuSaveType;
-extern bool cheatsEnabled;
-extern bool mirroringEnable;
-extern bool skipSaveGameBattery; // skip battery data when reading save states
-extern bool skipSaveGameCheats; // skip cheat list data when reading save states
extern int customBackdropColor;
extern u8 *bios;
diff --git a/src/gtk/main.cpp b/src/gtk/main.cpp
index cb078e39..c035ae38 100644
--- a/src/gtk/main.cpp
+++ b/src/gtk/main.cpp
@@ -27,6 +27,8 @@
#include "window.h"
#include "intl.h"
+int systemDebug = 0;
+
int main(int argc, char * argv[])
{
bool bShowVersion = false;
diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp
index 96b0803a..fc69903f 100644
--- a/src/gtk/window.cpp
+++ b/src/gtk/window.cpp
@@ -27,6 +27,7 @@
#include
+#include "../common/ConfigManager.h"
#include "../gba/GBA.h"
#include "../gba/RTC.h"
#include "../gba/Sound.h"
diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp
index 9396b99a..a497f7f6 100644
--- a/src/gtk/windowcallbacks.cpp
+++ b/src/gtk/windowcallbacks.cpp
@@ -25,6 +25,7 @@
#include
+#include "../common/ConfigManager.h"
#include "../gba/GBA.h"
#include "../gba/Sound.h"
#include "../gb/gb.h"
diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp
index 7e7d8b08..40af2021 100644
--- a/src/sdl/SDL.cpp
+++ b/src/sdl/SDL.cpp
@@ -45,6 +45,7 @@
#include
#include "../common/Patch.h"
+#include "../common/ConfigManager.h"
#include "../gba/GBA.h"
#include "../gba/agbprint.h"
#include "../gba/Flash.h"
@@ -123,59 +124,31 @@ int systemFrameSkip = 0;
int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
int srcPitch = 0;
-int srcWidth = 0;
-int srcHeight = 0;
int destWidth = 0;
int destHeight = 0;
int desktopWidth = 0;
int desktopHeight = 0;
-Filter filter = kStretch2x;
u8 *delta = NULL;
static const int delta_size = 322*242*4;
int filter_enlarge = 2;
-int sdlPrintUsage = 0;
-
int cartridgeType = 3;
-int captureFormat = 0;
-int openGL = 1;
int textureSize = 256;
GLuint screenTexture = 0;
u8 *filterPix = 0;
-int pauseWhenInactive = 0;
-int active = 1;
int emulating = 0;
int RGB_LOW_BITS_MASK=0x821;
u32 systemColorMap32[0x10000];
u16 systemColorMap16[0x10000];
u16 systemGbPalette[24];
-FilterFunc filterFunction = 0;
-IFBFilterFunc ifbFunction = 0;
-IFBFilter ifbType = kIFBNone;
+
char filename[2048];
-char biosFileName[2048];
-char gbBiosFileName[2048];
-char captureDir[2048];
-char saveDir[2048];
-char batteryDir[2048];
-char* homeDir = NULL;
-// Directory within homedir to use for default save location.
-#define DOT_DIR ".vbam"
-
-static char *rewindMemory = NULL;
-static int *rewindSerials = NULL;
-static int rewindPos = 0;
static int rewindSerial = 0;
-static int rewindTopPos = 0;
-static int rewindCounter = 0;
-static int rewindCount = 0;
-static bool rewindSaveNeeded = false;
-static int rewindTimer = 0;
static int sdlSaveKeysSwitch = 0;
// if 0, then SHIFT+F# saves, F# loads (old VBA, ...)
@@ -191,10 +164,6 @@ static int saveSlotPosition = 0; // default is the slot from normal F1
static int sdlOpenglScale = 1;
// will scale window on init by this much
static int sdlSoundToggledOff = 0;
-// allow up to 100 IPS/UPS/PPF patches given on commandline
-#define PATCH_MAX_NUM 100
-int sdl_patch_num = 0;
-char * (sdl_patch_names[PATCH_MAX_NUM]) = { NULL }; // and so on
extern int autoFireMaxCount;
@@ -202,100 +171,37 @@ extern int autoFireMaxCount;
#define REWIND_SIZE 400000
#define SYSMSG_BUFFER_SIZE 1024
+enum VIDEO_SIZE{
+ VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X, VIDEO_5X, VIDEO_6X,
+ VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_1024x768, VIDEO_1280x1024,
+ VIDEO_OTHER
+};
+
#define _stricmp strcasecmp
-bool wasPaused = false;
-int autoFrameSkip = 0;
-int frameskipadjust = 0;
-int showRenderedFrames = 0;
-int renderedFrames = 0;
-
u32 throttleLastTime = 0;
-u32 autoFrameSkipLastTime = 0;
-int showSpeed = 1;
-int showSpeedTransparent = 1;
-bool disableStatusMessages = false;
-bool paused = false;
bool pauseNextFrame = false;
bool debuggerStub = false;
-int fullscreen = 0;
-int sdlFlashSize = 0;
-int sdlAutoPatch = 1;
-int sdlRtcEnable = 0;
-int sdlAgbPrint = 0;
int sdlMirroringEnable = 0;
-static int ignore_first_resize_event = 0;
+static int ignore_first_resize_event = 0;
+void (*dbgMain)();
/* forward */
void systemConsoleMessage(const char*);
-void (*dbgMain)();
void (*dbgSignal)(int,int);
void (*dbgOutput)(const char *, u32);
-int mouseCounter = 0;
+char* home;
-bool screenMessage = false;
char screenMessageBuffer[21];
u32 screenMessageTime = 0;
-char *arg0;
-
-int sdlPreparedCheats = 0;
-#define MAX_CHEATS 100
-const char * sdlPreparedCheatCodes[MAX_CHEATS];
-
-#define SDL_SOUND_MAX_VOLUME 2.0
-#define SDL_SOUND_ECHO 0.2
-#define SDL_SOUND_STEREO 0.15
-
-struct option sdlOptions[] = {
- { "agb-print", no_argument, &sdlAgbPrint, 1 },
- { "auto-frameskip", no_argument, &autoFrameSkip, 1 },
- { "bios", required_argument, 0, 'b' },
- { "config", required_argument, 0, 'c' },
- { "debug", no_argument, 0, 'd' },
- { "filter", required_argument, 0, 'f' },
- { "ifb-filter", required_argument, 0, 'I' },
- { "flash-size", required_argument, 0, 'S' },
- { "flash-64k", no_argument, &sdlFlashSize, 0 },
- { "flash-128k", no_argument, &sdlFlashSize, 1 },
- { "frameskip", required_argument, 0, 's' },
- { "fullscreen", no_argument, &fullscreen, 1 },
- { "gdb", required_argument, 0, 'G' },
- { "help", no_argument, &sdlPrintUsage, 1 },
- { "patch", required_argument, 0, 'i' },
- { "no-agb-print", no_argument, &sdlAgbPrint, 0 },
- { "no-auto-frameskip", no_argument, &autoFrameSkip, 0 },
- { "no-debug", no_argument, 0, 'N' },
- { "no-patch", no_argument, &sdlAutoPatch, 0 },
- { "no-opengl", no_argument, &openGL, 0 },
- { "no-pause-when-inactive", no_argument, &pauseWhenInactive, 0 },
- { "no-rtc", no_argument, &sdlRtcEnable, 0 },
- { "no-show-speed", no_argument, &showSpeed, 0 },
- { "opengl", required_argument, 0, 'O' },
- { "opengl-nearest", no_argument, &openGL, 1 },
- { "opengl-bilinear", no_argument, &openGL, 2 },
- { "pause-when-inactive", no_argument, &pauseWhenInactive, 1 },
- { "profile", optional_argument, 0, 'p' },
- { "rtc", no_argument, &sdlRtcEnable, 1 },
- { "save-type", required_argument, 0, 't' },
- { "save-auto", no_argument, &cpuSaveType, 0 },
- { "save-eeprom", no_argument, &cpuSaveType, 1 },
- { "save-sram", no_argument, &cpuSaveType, 2 },
- { "save-flash", no_argument, &cpuSaveType, 3 },
- { "save-sensor", no_argument, &cpuSaveType, 4 },
- { "save-none", no_argument, &cpuSaveType, 5 },
- { "show-speed-normal", no_argument, &showSpeed, 1 },
- { "show-speed-detailed", no_argument, &showSpeed, 2 },
- { "throttle", required_argument, 0, 'T' },
- { "verbose", required_argument, 0, 'v' },
- { "cheat", required_argument, 0, 1000 },
- { "autofire", required_argument, 0, 1001 },
- { NULL, no_argument, NULL, 0 }
-};
+#define SOUND_MAX_VOLUME 2.0
+#define SOUND_ECHO 0.2
+#define SOUND_STEREO 0.15
static void sdlChangeVolume(float d)
{
@@ -303,7 +209,7 @@ static void sdlChangeVolume(float d)
float newVolume = oldVolume + d;
if (newVolume < 0.0) newVolume = 0.0;
- if (newVolume > SDL_SOUND_MAX_VOLUME) newVolume = SDL_SOUND_MAX_VOLUME;
+ if (newVolume > SOUND_MAX_VOLUME) newVolume = SOUND_MAX_VOLUME;
if (fabs(newVolume - oldVolume) > 0.001) {
char tmp[32];
@@ -363,20 +269,6 @@ void StopLirc(void)
#endif
-u32 sdlFromHex(char *s)
-{
- u32 value;
- sscanf(s, "%x", &value);
- return value;
-}
-
-u32 sdlFromDec(char *s)
-{
- u32 value = 0;
- sscanf(s, "%u", &value);
- return value;
-}
-
#ifdef __MSC__
#define stat _stat
#define S_IFDIR _S_IFDIR
@@ -384,6 +276,11 @@ u32 sdlFromDec(char *s)
void sdlCheckDirectory(char *dir)
{
+ if (!dir)
+ {
+ return;
+ }
+
struct stat buf;
int len = strlen(dir);
@@ -397,11 +294,9 @@ void sdlCheckDirectory(char *dir)
if(stat(dir, &buf) == 0) {
if(!(buf.st_mode & S_IFDIR)) {
fprintf(stderr, "Error: %s is not a directory\n", dir);
- dir[0] = 0;
}
} else {
fprintf(stderr, "Error: %s does not exist\n", dir);
- dir[0] = 0;
}
}
@@ -476,8 +371,8 @@ FILE *sdlFindFile(const char *name)
return f;
}
- if(!strchr(arg0, '/') &&
- !strchr(arg0, '\\')) {
+ if (!strchr(home, '/') &&
+ !strchr(home, '\\')) {
char *path = getenv("PATH");
if(path != NULL) {
@@ -505,7 +400,7 @@ FILE *sdlFindFile(const char *name)
} else {
// executable is relative to some directory
fprintf(stdout, "Searching executable directory\n");
- strcpy(buffer, arg0);
+ strcpy(buffer, home);
char *p = strrchr(buffer, FILE_SEP);
if(p) {
*p = 0;
@@ -530,293 +425,9 @@ FILE *sdlFindFile(const char *name)
#endif // ! _WIN32
return NULL;
-}
-
-void sdlReadPreferences(FILE *f)
+}void sdlOpenGLInit(int w, int h)
{
- char buffer[2048];
-
- while(1) {
- char *s = fgets(buffer, 2048, f);
-
- if(s == NULL)
- break;
-
- char *p = strchr(s, '#');
-
- if(p)
- *p = 0;
-
- char *token = strtok(s, " \t\n\r=");
-
- if(!token)
- continue;
-
- if(strlen(token) == 0)
- continue;
-
- char *key = token;
- char *value = strtok(NULL, "\t\n\r");
-
- if(value == NULL) {
- fprintf(stdout, "Empty value for key %s\n", key);
- continue;
- }
-
- if(!strcmp(key,"Joy0_Left")) {
- inputSetKeymap(PAD_1, KEY_LEFT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Right")) {
- inputSetKeymap(PAD_1, KEY_RIGHT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Up")) {
- inputSetKeymap(PAD_1, KEY_UP, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Down")) {
- inputSetKeymap(PAD_1, KEY_DOWN, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_A")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_B")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_L")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_L, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_R")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_R, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Start")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_START, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Select")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_SELECT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Speed")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_SPEED, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_Capture")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_CAPTURE, sdlFromHex(value));
- } else if(!strcmp(key,"Joy1_Left")) {
- inputSetKeymap(PAD_2, KEY_LEFT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Right")) {
- inputSetKeymap(PAD_2, KEY_RIGHT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Up")) {
- inputSetKeymap(PAD_2, KEY_UP, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Down")) {
- inputSetKeymap(PAD_2, KEY_DOWN, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_A")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_B")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_L")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_L, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_R")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_R, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Start")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_START, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Select")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_SELECT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Speed")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_SPEED, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_Capture")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_CAPTURE, sdlFromHex(value));
- } else if(!strcmp(key,"Joy2_Left")) {
- inputSetKeymap(PAD_3, KEY_LEFT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Right")) {
- inputSetKeymap(PAD_3, KEY_RIGHT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Up")) {
- inputSetKeymap(PAD_3, KEY_UP, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Down")) {
- inputSetKeymap(PAD_3, KEY_DOWN, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_A")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_B")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_L")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_L, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_R")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_R, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Start")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_START, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Select")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_SELECT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Speed")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_SPEED, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_Capture")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_CAPTURE, sdlFromHex(value));
- } else if(!strcmp(key,"Joy3_Left")) {
- inputSetKeymap(PAD_4, KEY_LEFT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Right")) {
- inputSetKeymap(PAD_4, KEY_RIGHT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Up")) {
- inputSetKeymap(PAD_4, KEY_UP, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Down")) {
- inputSetKeymap(PAD_4, KEY_DOWN, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_A")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_B")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_L")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_L, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_R")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_R, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Start")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_START, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Select")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_SELECT, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Speed")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_SPEED, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_Capture")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_CAPTURE, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_AutoA")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_AUTO_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy0_AutoB")) {
- inputSetKeymap(PAD_1, KEY_BUTTON_AUTO_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_AutoA")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_AUTO_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy1_AutoB")) {
- inputSetKeymap(PAD_2, KEY_BUTTON_AUTO_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_AutoA")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_AUTO_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy2_AutoB")) {
- inputSetKeymap(PAD_3, KEY_BUTTON_AUTO_B, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_AutoA")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_AUTO_A, sdlFromHex(value));
- } else if(!strcmp(key, "Joy3_AutoB")) {
- inputSetKeymap(PAD_4, KEY_BUTTON_AUTO_B, sdlFromHex(value));
- } else if(!strcmp(key, "openGL")) {
- openGL = sdlFromHex(value);
- } else if(!strcmp(key, "Motion_Left")) {
- inputSetMotionKeymap(KEY_LEFT, sdlFromHex(value));
- } else if(!strcmp(key, "Motion_Right")) {
- inputSetMotionKeymap(KEY_RIGHT, sdlFromHex(value));
- } else if(!strcmp(key, "Motion_Up")) {
- inputSetMotionKeymap(KEY_UP, sdlFromHex(value));
- } else if(!strcmp(key, "Motion_Down")) {
- inputSetMotionKeymap(KEY_DOWN, sdlFromHex(value));
- } else if(!strcmp(key, "frameSkip")) {
- frameSkip = sdlFromHex(value);
- if(frameSkip < 0 || frameSkip > 9)
- frameSkip = 2;
- } else if(!strcmp(key, "gbFrameSkip")) {
- gbFrameSkip = sdlFromHex(value);
- if(gbFrameSkip < 0 || gbFrameSkip > 9)
- gbFrameSkip = 0;
- } else if(!strcmp(key, "fullScreen")) {
- fullscreen = sdlFromHex(value) ? 1 : 0;
- } else if(!strcmp(key, "useBios")) {
- useBios = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "skipBios")) {
- skipBios = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "biosFile")) {
- strcpy(biosFileName, value);
- } else if(!strcmp(key, "gbBiosFile")) {
- strcpy(gbBiosFileName, value);
- } else if(!strcmp(key, "filter")) {
- filter = (Filter)sdlFromDec(value);
- if(filter < kStretch1x || filter >= kInvalidFilter)
- filter = kStretch2x;
- } else if(!strcmp(key, "disableStatus")) {
- disableStatusMessages = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "borderOn")) {
- gbBorderOn = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "borderAutomatic")) {
- gbBorderAutomatic = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "emulatorType")) {
- gbEmulatorType = sdlFromHex(value);
- if(gbEmulatorType < 0 || gbEmulatorType > 5)
- gbEmulatorType = 1;
- } else if(!strcmp(key, "colorOption")) {
- gbColorOption = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "captureDir")) {
- sdlCheckDirectory(value);
- strcpy(captureDir, value);
- } else if(!strcmp(key, "saveDir")) {
- sdlCheckDirectory(value);
- strcpy(saveDir, value);
- } else if(!strcmp(key, "batteryDir")) {
- sdlCheckDirectory(value);
- strcpy(batteryDir, value);
- } else if(!strcmp(key, "captureFormat")) {
- captureFormat = sdlFromHex(value);
- } else if(!strcmp(key, "soundQuality")) {
- int soundQuality = sdlFromHex(value);
- switch(soundQuality) {
- case 1:
- case 2:
- case 4:
- break;
- default:
- fprintf(stdout, "Unknown sound quality %d. Defaulting to 22Khz\n",
- soundQuality);
- soundQuality = 2;
- break;
- }
- soundSetSampleRate(44100 / soundQuality);
- } else if(!strcmp(key, "soundEnable")) {
- int res = sdlFromHex(value) & 0x30f;
- soundSetEnable(res);
- } else if(!strcmp(key, "soundStereo")) {
- if (sdlFromHex(value)) {
- gb_effects_config.stereo = SDL_SOUND_STEREO;
- gb_effects_config.enabled = true;
- }
- } else if(!strcmp(key, "soundEcho")) {
- if (sdlFromHex(value)) {
- gb_effects_config.echo = SDL_SOUND_ECHO;
- gb_effects_config.enabled = true;
- }
- } else if(!strcmp(key, "soundSurround")) {
- if (sdlFromHex(value)) {
- gb_effects_config.surround = true;
- gb_effects_config.enabled = true;
- }
- } else if(!strcmp(key, "declicking")) {
- gbSoundSetDeclicking(sdlFromHex(value) != 0);
- } else if(!strcmp(key, "soundVolume")) {
- float volume = sdlFromDec(value) / 100.0;
- if (volume < 0.0 || volume > SDL_SOUND_MAX_VOLUME)
- volume = 1.0;
- soundSetVolume(volume);
- } else if(!strcmp(key, "saveType")) {
- cpuSaveType = sdlFromHex(value);
- if(cpuSaveType < 0 || cpuSaveType > 5)
- cpuSaveType = 0;
- } else if(!strcmp(key, "flashSize")) {
- sdlFlashSize = sdlFromHex(value);
- if(sdlFlashSize != 0 && sdlFlashSize != 1)
- sdlFlashSize = 0;
- } else if(!strcmp(key, "ifbType")) {
- ifbType = (IFBFilter)sdlFromHex(value);
- if(ifbType < kIFBNone || ifbType >= kInvalidIFBFilter)
- ifbType = kIFBNone;
- } else if(!strcmp(key, "showSpeed")) {
- showSpeed = sdlFromHex(value);
- if(showSpeed < 0 || showSpeed > 2)
- showSpeed = 1;
- } else if(!strcmp(key, "showSpeedTransparent")) {
- showSpeedTransparent = sdlFromHex(value);
- } else if(!strcmp(key, "autoFrameSkip")) {
- autoFrameSkip = sdlFromHex(value);
- } else if(!strcmp(key, "pauseWhenInactive")) {
- pauseWhenInactive = sdlFromHex(value) ? true : false;
- } else if(!strcmp(key, "agbPrint")) {
- sdlAgbPrint = sdlFromHex(value);
- } else if(!strcmp(key, "rtcEnabled")) {
- sdlRtcEnable = sdlFromHex(value);
- } else if(!strcmp(key, "rewindTimer")) {
- rewindTimer = sdlFromHex(value);
- if(rewindTimer < 0 || rewindTimer > 600)
- rewindTimer = 0;
- rewindTimer *= 6; // convert value to 10 frames multiple
- } else if(!strcmp(key, "saveKeysSwitch")) {
- sdlSaveKeysSwitch = sdlFromHex(value);
- } else if(!strcmp(key, "openGLscale")) {
- sdlOpenglScale = sdlFromHex(value);
- } else if(!strcmp(key, "autoFireMaxCount")) {
- autoFireMaxCount = sdlFromDec(value);
- if(autoFireMaxCount < 1)
- autoFireMaxCount = 1;
- } else {
- fprintf(stderr, "Unknown configuration key %s\n", key);
- }
- }
-}
-
-void sdlOpenGLInit(int w, int h)
-{
- float screenAspect = (float) srcWidth / srcHeight,
+ float screenAspect = (float) sizeX / sizeY,
windowAspect = (float) w / h;
if(glIsTexture(screenTexture))
@@ -869,21 +480,6 @@ void sdlOpenGLInit(int w, int h)
glClear( GL_COLOR_BUFFER_BIT );
}
-void sdlReadPreferences()
-{
- FILE *f = sdlFindFile("vbam.cfg");
-
- if(f == NULL) {
- fprintf(stdout, "Configuration file NOT FOUND (using defaults)\n");
- return;
- } else
- fprintf(stdout, "Reading configuration file.\n");
-
- sdlReadPreferences(f);
-
- fclose(f);
-}
-
static void sdlApplyPerImagePreferences()
{
FILE *f = sdlFindFile("vba-over.ini");
@@ -991,7 +587,7 @@ static char * sdlStateName(int num)
{
static char stateName[2048];
- if(saveDir[0])
+ if(saveDir)
sprintf(stateName, "%s/%s%d.sgm", saveDir, sdlGetFilename(filename),
num+1);
else if (homeDir)
@@ -1099,7 +695,7 @@ void sdlWriteBattery()
{
char buffer[1048];
- if(batteryDir[0])
+ if(batteryDir)
sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
else if (homeDir)
sprintf(buffer, "%s/%s/%s.sav", homeDir, DOT_DIR, sdlGetFilename(filename));
@@ -1115,7 +711,7 @@ void sdlReadBattery()
{
char buffer[1048];
- if(batteryDir[0])
+ if(batteryDir)
sprintf(buffer, "%s/%s.sav", batteryDir, sdlGetFilename(filename));
else if (homeDir)
sprintf(buffer, "%s/%s/%s.sav", homeDir, DOT_DIR, sdlGetFilename(filename));
@@ -1143,17 +739,17 @@ void sdlInitVideo() {
filter_enlarge = getFilterEnlargeFactor(filter);
- destWidth = filter_enlarge * srcWidth;
- destHeight = filter_enlarge * srcHeight;
+ destWidth = filter_enlarge * sizeX;
+ destHeight = filter_enlarge * sizeY;
- flags = SDL_ANYFORMAT | (fullscreen ? SDL_FULLSCREEN : 0);
+ flags = SDL_ANYFORMAT | (fullScreen ? SDL_FULLSCREEN : 0);
if(openGL) {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
flags |= SDL_OPENGL | SDL_RESIZABLE;
} else
flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
- if (fullscreen && openGL) {
+ if (fullScreen && openGL) {
screenWidth = desktopWidth;
screenHeight = desktopHeight;
} else {
@@ -1201,12 +797,12 @@ void sdlInitVideo() {
systemColorDepth = surface->format->BitsPerPixel;
if(systemColorDepth == 16) {
- srcPitch = srcWidth*2 + 4;
+ srcPitch = sizeX*2 + 4;
} else {
if(systemColorDepth == 32)
- srcPitch = srcWidth*4 + 4;
+ srcPitch = sizeX*4 + 4;
else
- srcPitch = srcWidth*3;
+ srcPitch = sizeX*3;
}
if(openGL) {
@@ -1217,14 +813,14 @@ void sdlInitVideo() {
filterPix = (u8 *)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
sdlOpenGLInit(screenWidth, screenHeight);
- if ( (!fullscreen)
+ if ( (!fullScreen)
&& sdlOpenglScale > 1
&& scaledWidth < desktopWidth
&& scaledHeight < desktopHeight
) {
SDL_SetVideoMode(scaledWidth, scaledHeight, 0,
SDL_OPENGL | SDL_RESIZABLE |
- (fullscreen ? SDL_FULLSCREEN : 0));
+ (fullScreen ? SDL_FULLSCREEN : 0));
sdlOpenGLInit(scaledWidth, scaledHeight);
/* xKiv: it would seem that SDL_RESIZABLE causes the *previous* dimensions to be immediately
* reported back via the SDL_VIDEORESIZE event
@@ -1383,7 +979,7 @@ void sdlPollEvents()
{
SDL_SetVideoMode(event.resize.w, event.resize.h, 0,
SDL_OPENGL | SDL_RESIZABLE |
- (fullscreen ? SDL_FULLSCREEN : 0));
+ (fullScreen ? SDL_FULLSCREEN : 0));
sdlOpenGLInit(event.resize.w, event.resize.h);
}
break;
@@ -1409,7 +1005,7 @@ void sdlPollEvents()
case SDL_MOUSEMOTION:
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN:
- if(fullscreen) {
+ if(fullScreen) {
SDL_ShowCursor(SDL_ENABLE);
mouseCounter = 120;
}
@@ -1494,7 +1090,7 @@ void sdlPollEvents()
}
systemScreenMessage("Stereo off");
} else {
- gb_effects_config.stereo = SDL_SOUND_STEREO;
+ gb_effects_config.stereo = SOUND_STEREO;
gb_effects_config.enabled = true;
systemScreenMessage("Stereo on");
}
@@ -1507,7 +1103,7 @@ void sdlPollEvents()
}
systemScreenMessage("Echo off");
} else {
- gb_effects_config.echo = SDL_SOUND_ECHO;
+ gb_effects_config.echo = SOUND_ECHO;
gb_effects_config.enabled = true;
systemScreenMessage("Echo on");
}
@@ -1542,7 +1138,7 @@ void sdlPollEvents()
case SDLK_f:
if(!(event.key.keysym.mod & MOD_NOCTRL) &&
(event.key.keysym.mod & KMOD_CTRL)) {
- fullscreen = !fullscreen;
+ fullScreen = !fullScreen;
sdlInitVideo();
}
break;
@@ -1553,7 +1149,7 @@ void sdlPollEvents()
while (!filterFunction)
{
filter = (Filter)((filter + 1) % kInvalidFilter);
- filterFunction = initFilter(filter, systemColorDepth, srcWidth);
+ filterFunction = initFilter(filter, systemColorDepth, sizeX);
}
if (getFilterEnlargeFactor(filter) != filter_enlarge)
sdlInitVideo();
@@ -1883,13 +1479,8 @@ int main(int argc, char **argv)
{
fprintf(stdout, "VBA-M version %s [SDL]\n", SVN_REV_STR);
- arg0 = argv[0];
-
- captureDir[0] = 0;
- saveDir[0] = 0;
- batteryDir[0] = 0;
-
- int op = -1;
+ home = argv[0];
+ SetHome(home);
frameSkip = 2;
gbBorderOn = 0;
@@ -1901,236 +1492,91 @@ int main(int argc, char **argv)
gb_effects_config.surround = false;
gb_effects_config.enabled = false;
- char buf[1024];
- struct stat s;
+ inputSetKeymap(PAD_1, KEY_LEFT, ReadPrefHex("Joy0_Left"));
+ inputSetKeymap(PAD_1, KEY_RIGHT, ReadPrefHex("Joy0_Right"));
+ inputSetKeymap(PAD_1, KEY_UP, ReadPrefHex("Joy0_Up"));
+ inputSetKeymap(PAD_1, KEY_DOWN, ReadPrefHex("Joy0_Down"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_A, ReadPrefHex("Joy0_A"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_B, ReadPrefHex("Joy0_B"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_L, ReadPrefHex("Joy0_L"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_R, ReadPrefHex("Joy0_R"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_START, ReadPrefHex("Joy0_Start"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_SELECT, ReadPrefHex("Joy0_Select"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_SPEED, ReadPrefHex("Joy0_Speed"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_CAPTURE, ReadPrefHex("Joy0_Capture"));
+ inputSetKeymap(PAD_2, KEY_LEFT, ReadPrefHex("Joy1_Left"));
+ inputSetKeymap(PAD_2, KEY_RIGHT, ReadPrefHex("Joy1_Right"));
+ inputSetKeymap(PAD_2, KEY_UP, ReadPrefHex("Joy1_Up"));
+ inputSetKeymap(PAD_2, KEY_DOWN, ReadPrefHex("Joy1_Down"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_A, ReadPrefHex("Joy1_A"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_B, ReadPrefHex("Joy1_B"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_L, ReadPrefHex("Joy1_L"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_R, ReadPrefHex("Joy1_R"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_START, ReadPrefHex("Joy1_Start"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_SELECT, ReadPrefHex("Joy1_Select"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_SPEED, ReadPrefHex("Joy1_Speed"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_CAPTURE, ReadPrefHex("Joy1_Capture"));
+ inputSetKeymap(PAD_3, KEY_LEFT, ReadPrefHex("Joy2_Left"));
+ inputSetKeymap(PAD_3, KEY_RIGHT, ReadPrefHex("Joy2_Right"));
+ inputSetKeymap(PAD_3, KEY_UP, ReadPrefHex("Joy2_Up"));
+ inputSetKeymap(PAD_3, KEY_DOWN, ReadPrefHex("Joy2_Down"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_A, ReadPrefHex("Joy2_A"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_B, ReadPrefHex("Joy2_B"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_L, ReadPrefHex("Joy2_L"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_R, ReadPrefHex("Joy2_R"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_START, ReadPrefHex("Joy2_Start"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_SELECT, ReadPrefHex("Joy2_Select"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_SPEED, ReadPrefHex("Joy2_Speed"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_CAPTURE, ReadPrefHex("Joy2_Capture"));
+ inputSetKeymap(PAD_4, KEY_LEFT, ReadPrefHex("Joy3_Left"));
+ inputSetKeymap(PAD_4, KEY_RIGHT, ReadPrefHex("Joy3_Right"));
+ inputSetKeymap(PAD_4, KEY_UP, ReadPrefHex("Joy3_Up"));
+ inputSetKeymap(PAD_4, KEY_DOWN, ReadPrefHex("Joy3_Down"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_A, ReadPrefHex("Joy3_A"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_B, ReadPrefHex("Joy3_B"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_L, ReadPrefHex("Joy3_L"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_R, ReadPrefHex("Joy3_R"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_START, ReadPrefHex("Joy3_Start"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_SELECT, ReadPrefHex("Joy3_Select"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_SPEED, ReadPrefHex("Joy3_Speed"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_CAPTURE, ReadPrefHex("Joy3_Capture"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_AUTO_A, ReadPrefHex("Joy0_AutoA"));
+ inputSetKeymap(PAD_1, KEY_BUTTON_AUTO_B, ReadPrefHex("Joy0_AutoB"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_AUTO_A, ReadPrefHex("Joy1_AutoA"));
+ inputSetKeymap(PAD_2, KEY_BUTTON_AUTO_B, ReadPrefHex("Joy1_AutoB"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_AUTO_A, ReadPrefHex("Joy2_AutoA"));
+ inputSetKeymap(PAD_3, KEY_BUTTON_AUTO_B, ReadPrefHex("Joy2_AutoB"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_AUTO_A, ReadPrefHex("Joy3_AutoA"));
+ inputSetKeymap(PAD_4, KEY_BUTTON_AUTO_B, ReadPrefHex("Joy3_AutoB"));
+ inputSetMotionKeymap(KEY_LEFT, ReadPrefHex("Motion_Left"));
+ inputSetMotionKeymap(KEY_RIGHT, ReadPrefHex("Motion_Right"));
+ inputSetMotionKeymap(KEY_UP, ReadPrefHex("Motion_Up"));
+ inputSetMotionKeymap(KEY_DOWN, ReadPrefHex("Motion_Down"));
-#ifndef _WIN32
- // Get home dir
- homeDir = getenv("HOME");
- snprintf(buf, 1024, "%s/%s", homeDir, DOT_DIR);
- // Make dot dir if not existent
- if (stat(buf, &s) == -1 || !S_ISDIR(s.st_mode))
- mkdir(buf, 0755);
-#else
- homeDir = 0;
-#endif
+ LoadConfig(); // Parse command line arguments (overrides ini)
+ ReadOpts(argc, argv);
- sdlReadPreferences();
+ sdlCheckDirectory(screenShotDir);
+ sdlCheckDirectory(saveDir);
+ sdlCheckDirectory(batteryDir);
- sdlPrintUsage = 0;
+ sdlSaveKeysSwitch = (ReadPrefHex("saveKeysSwitch"));
+ sdlOpenglScale = (ReadPrefHex("openGLscale"));
- while((op = getopt_long(argc,
- argv,
- "FNO:T:Y:G:I:D:b:c:df:hi:p::s:t:v:",
- sdlOptions,
- NULL)) != -1) {
- switch(op) {
- case 0:
- // long option already processed by getopt_long
- break;
- case 1000:
- // --cheat
- if (sdlPreparedCheats >= MAX_CHEATS) {
- fprintf(stderr, "Warning: cannot add more than %d cheats.\n", MAX_CHEATS);
- break;
- }
- {
- char * cpy;
- cpy = (char *)malloc(1 + strlen(optarg));
- strcpy(cpy, optarg);
- sdlPreparedCheatCodes[sdlPreparedCheats++] = cpy;
- }
- break;
- case 1001:
- // --autofire
- autoFireMaxCount = sdlFromDec(optarg);
- if (autoFireMaxCount < 1)
- autoFireMaxCount = 1;
- break;
- case 'b':
- useBios = true;
- if(optarg == NULL) {
- fprintf(stderr, "Missing BIOS file name\n");
- exit(-1);
- }
- strcpy(biosFileName, optarg);
- break;
- case 'c':
- {
- if(optarg == NULL) {
- fprintf(stderr, "Missing config file name\n");
- exit(-1);
- }
- FILE *f = fopen(optarg, "r");
- if(f == NULL) {
- fprintf(stderr, "File not found %s\n", optarg);
- exit(-1);
- }
- sdlReadPreferences(f);
- fclose(f);
- }
- break;
- case 'd':
- debugger = true;
- break;
- case 'h':
- sdlPrintUsage = 1;
- break;
- case 'i':
- if(optarg == NULL) {
- fprintf(stderr, "Missing patch name\n");
- exit(-1);
- }
- if (sdl_patch_num >= PATCH_MAX_NUM) {
- fprintf(stderr, "Too many patches given at %s (max is %d). Ignoring.\n", optarg, PATCH_MAX_NUM);
- } else {
- sdl_patch_names[sdl_patch_num] = (char *)malloc(1 + strlen(optarg));
- strcpy(sdl_patch_names[sdl_patch_num], optarg);
- sdl_patch_num++;
- }
- break;
- case 'G':
- dbgMain = remoteStubMain;
- dbgSignal = remoteStubSignal;
- dbgOutput = remoteOutput;
- debugger = true;
- debuggerStub = true;
- if(optarg) {
- char *s = optarg;
- if(strncmp(s,"tcp:", 4) == 0) {
- s+=4;
- int port = atoi(s);
- remoteSetProtocol(0);
- remoteSetPort(port);
- } else if(strcmp(s,"tcp") == 0) {
- remoteSetProtocol(0);
- } else if(strcmp(s, "pipe") == 0) {
- remoteSetProtocol(1);
- } else {
- fprintf(stderr, "Unknown protocol %s\n", s);
- exit(-1);
- }
- } else {
- remoteSetProtocol(0);
- }
- break;
- case 'N':
- parseDebug = false;
- break;
- case 'D':
- if(optarg) {
- systemDebug = atoi(optarg);
- } else {
- systemDebug = 1;
- }
- break;
- case 'F':
- fullscreen = 1;
- mouseCounter = 120;
- break;
- case 'f':
- if(optarg) {
- filter = (Filter)atoi(optarg);
- } else {
- filter = kStretch2x;
- }
- break;
- case 'I':
- if(optarg) {
- ifbType = (IFBFilter)atoi(optarg);
- } else {
- ifbType = kIFBNone;
- }
- break;
- case 'p':
-#ifdef PROFILING
- if(optarg) {
- cpuEnableProfiling(atoi(optarg));
- } else
- cpuEnableProfiling(100);
-#endif
- break;
- case 'S':
- sdlFlashSize = atoi(optarg);
- if(sdlFlashSize < 0 || sdlFlashSize > 1)
- sdlFlashSize = 0;
- break;
- case 's':
- if(optarg) {
- int a = atoi(optarg);
- if(a >= 0 && a <= 9) {
- gbFrameSkip = a;
- frameSkip = a;
- }
- } else {
- frameSkip = 2;
- gbFrameSkip = 0;
- }
- break;
- case 't':
- if(optarg) {
- int a = atoi(optarg);
- if(a < 0 || a > 5)
- a = 0;
- cpuSaveType = a;
- }
- break;
- case 'v':
- if(optarg) {
- systemVerbose = atoi(optarg);
- } else
- systemVerbose = 0;
- break;
- case '?':
- sdlPrintUsage = 1;
- break;
- case 'O':
- if(optarg) {
- openGL = atoi(optarg);
- if (openGL < 0 || openGL > 2)
- openGL = 1;
- } else
- openGL = 0;
- break;
- }
- }
-
- if(sdlPrintUsage) {
+ if(optPrintUsage) {
usage(argv[0]);
exit(-1);
}
- if(rewindTimer) {
- rewindMemory = (char *)malloc(REWIND_NUM*REWIND_SIZE);
- rewindSerials = (int *)calloc(REWIND_NUM, sizeof(int)); // init to zeroes
+ if (!debuggerStub) {
+ if (optind >= argc) {
+ systemMessage(0, "Missing image name");
+ usage(argv[0]);
+ exit(-1);
+ }
}
- if(sdlFlashSize == 0)
- flashSetSize(0x10000);
- else
- flashSetSize(0x20000);
-
- rtcEnable(sdlRtcEnable ? true : false);
- agbPrintEnable(sdlAgbPrint ? true : false);
-
- if(!debuggerStub) {
- if(optind >= argc) {
- systemMessage(0,"Missing image name");
- usage(argv[0]);
- exit(-1);
- }
- }
-
- for(int i = 0; i < 24;) {
- systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10);
- systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10);
- systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10);
- systemGbPalette[i++] = 0;
- }
-
- systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
-
if(optind < argc) {
char *szFile = argv[optind];
u32 len = strlen(szFile);
@@ -2146,26 +1592,26 @@ int main(int argc, char **argv)
if(p)
*p = 0;
- if (sdlAutoPatch && sdl_patch_num == 0)
+ if (autoPatch && patchNum == 0)
{
char * tmp;
// no patch given yet - look for ROMBASENAME.ips
tmp = (char *)malloc(strlen(filename) + 4 + 1);
sprintf(tmp, "%s.ips", filename);
- sdl_patch_names[sdl_patch_num] = tmp;
- sdl_patch_num++;
+ patchNames[patchNum] = tmp;
+ patchNum++;
// no patch given yet - look for ROMBASENAME.ups
tmp = (char *)malloc(strlen(filename) + 4 + 1);
sprintf(tmp, "%s.ups", filename);
- sdl_patch_names[sdl_patch_num] = tmp;
- sdl_patch_num++;
+ patchNames[patchNum] = tmp;
+ patchNum++;
// no patch given yet - look for ROMBASENAME.ppf
tmp = (char *)malloc(strlen(filename) + 4 + 1);
sprintf(tmp, "%s.ppf", filename);
- sdl_patch_names[sdl_patch_num] = tmp;
- sdl_patch_num++;
+ patchNames[patchNum] = tmp;
+ patchNum++;
}
soundInit();
@@ -2187,14 +1633,14 @@ int main(int argc, char **argv)
// used for the handling of the gb Boot Rom
if (gbHardware & 7)
- gbCPUInit(gbBiosFileName, useBios);
+ gbCPUInit(biosFileNameGB, useBios);
cartridgeType = IMAGE_GB;
emulator = GBSystem;
int size = gbRomSize, patchnum;
- for (patchnum = 0; patchnum < sdl_patch_num; patchnum++) {
- fprintf(stdout, "Trying patch %s%s\n", sdl_patch_names[patchnum],
- applyPatch(sdl_patch_names[patchnum], &gbRom, &size) ? " [success]" : "");
+ for (patchnum = 0; patchnum < patchNum; patchnum++) {
+ fprintf(stdout, "Trying patch %s%s\n", patchNames[patchnum],
+ applyPatch(patchNames[patchnum], &gbRom, &size) ? " [success]" : "");
}
if(size != gbRomSize) {
extern bool gbUpdateSizes();
@@ -2214,11 +1660,11 @@ int main(int argc, char **argv)
cartridgeType = 0;
emulator = GBASystem;
- CPUInit(biosFileName, useBios);
+ CPUInit(biosFileNameGBA, useBios);
int patchnum;
- for (patchnum = 0; patchnum < sdl_patch_num; patchnum++) {
- fprintf(stdout, "Trying patch %s%s\n", sdl_patch_names[patchnum],
- applyPatch(sdl_patch_names[patchnum], &rom, &size) ? " [success]" : "");
+ for (patchnum = 0; patchnum < patchNum; patchnum++) {
+ fprintf(stdout, "Trying patch %s%s\n", patchNames[patchnum],
+ applyPatch(patchNames[patchnum], &rom, &size) ? " [success]" : "");
}
CPUReset();
}
@@ -2244,7 +1690,7 @@ int main(int argc, char **argv)
emulator = GBASystem;
- CPUInit(biosFileName, useBios);
+ CPUInit(biosFileNameGBA, useBios);
CPUReset();
}
@@ -2270,35 +1716,36 @@ int main(int argc, char **argv)
#endif
inputInitJoysticks();
- if(cartridgeType == 0) {
- srcWidth = 240;
- srcHeight = 160;
+ if (cartridgeType == IMAGE_GBA) {
+ sizeX = 240;
+ sizeY = 160;
systemFrameSkip = frameSkip;
- } else if (cartridgeType == 1) {
+ }
+ else if (cartridgeType == IMAGE_GB) {
if(gbBorderOn) {
- srcWidth = 256;
- srcHeight = 224;
+ sizeX = 256;
+ sizeY = 224;
gbBorderLineSkip = 256;
gbBorderColumnSkip = 48;
gbBorderRowSkip = 40;
} else {
- srcWidth = 160;
- srcHeight = 144;
+ sizeX = 160;
+ sizeY = 144;
gbBorderLineSkip = 160;
gbBorderColumnSkip = 0;
gbBorderRowSkip = 0;
}
systemFrameSkip = gbFrameSkip;
} else {
- srcWidth = 320;
- srcHeight = 240;
+ sizeX = 320;
+ sizeY = 240;
}
sdlReadDesktopVideoMode();
sdlInitVideo();
- filterFunction = initFilter(filter, systemColorDepth, srcWidth);
+ filterFunction = initFilter(filter, systemColorDepth, sizeX);
if (!filterFunction) {
fprintf(stderr,"Unable to init filter '%s'\n", getFilterName(filter));
exit(-1);
@@ -2334,10 +1781,10 @@ int main(int argc, char **argv)
// now we can enable cheats?
{
int i;
- for (i=0; i= VIDEO_320x240 );
+ dpp.Windowed = !( videoOption >= VIDEO_320x240 );
if( !dpp.Windowed ) {
- dpp.BackBufferFormat = (theApp.fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
+ dpp.BackBufferFormat = (fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
} else {
dpp.BackBufferFormat = mode.Format;
}
- dpp.BackBufferCount = theApp.tripleBuffering ? 2 : 1;
+ dpp.BackBufferCount = tripleBuffering ? 2 : 1;
dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
- dpp.BackBufferWidth = !dpp.Windowed ? theApp.fsWidth : theApp.surfaceSizeX;
- dpp.BackBufferHeight = !dpp.Windowed ? theApp.fsHeight : theApp.surfaceSizeY;
+ dpp.BackBufferWidth = !dpp.Windowed ? fsWidth : surfaceSizeX;
+ dpp.BackBufferHeight = !dpp.Windowed ? fsHeight : surfaceSizeY;
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
- dpp.FullScreen_RefreshRateInHz = ( dpp.Windowed == TRUE ) ? 0 : theApp.fsFrequency;
+ dpp.FullScreen_RefreshRateInHz = ( dpp.Windowed == TRUE ) ? 0 : fsFrequency;
dpp.Flags = 0;
- dpp.PresentationInterval = (theApp.vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
+ dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
// D3DPRESENT_INTERVAL_ONE means VSync ON
@@ -244,7 +244,7 @@ bool Direct3DDisplay::initialize()
return false;
}
- pD3D->GetAdapterDisplayMode(theApp.fsAdapter, &mode);
+ pD3D->GetAdapterDisplayMode(fsAdapter, &mode);
screenFormat = mode.Format;
switch(mode.Format) {
@@ -273,12 +273,12 @@ bool Direct3DDisplay::initialize()
DXTRACE_ERR_MSGBOX( _T("Unsupport D3D format"), 0 );
return false;
}
- theApp.fsColorDepth = systemColorDepth;
+ fsColorDepth = systemColorDepth;
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
#ifdef MMX
- if(!theApp.disableMMX) {
+ if(!disableMMX) {
cpu_mmx = theApp.detectMMX();
} else {
cpu_mmx = 0;
@@ -295,7 +295,7 @@ bool Direct3DDisplay::initialize()
prepareDisplayMode();
HRESULT hret = pD3D->CreateDevice(
- theApp.fsAdapter,
+ fsAdapter,
D3DDEVTYPE_HAL,
theApp.m_pMainWnd->GetSafeHwnd(),
D3DCREATE_FPU_PRESERVE |
@@ -388,16 +388,16 @@ void Direct3DDisplay::render()
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
return;
} else {
- u32 pitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
+ u32 pitch = sizeX * ( systemColorDepth >> 3 ) + 4;
if( theApp.filterFunction ) {
- if( theApp.filterMT ) {
+ if( filterMT ) {
u8 *start = pix + pitch;
- int src_height_per_thread = theApp.sizeY / nThreads;
- int src_height_remaining = theApp.sizeY - ( ( theApp.sizeY / nThreads ) * nThreads );
+ int src_height_per_thread = sizeY / nThreads;
+ int src_height_remaining = sizeY - ( ( sizeY / nThreads ) * nThreads );
u32 src_bytes_per_thread = pitch * src_height_per_thread;
- int dst_height_per_thread = src_height_per_thread * theApp.filterMagnification;
+ int dst_height_per_thread = src_height_per_thread * filterMagnification;
u32 dst_bytes_per_thread = lr.Pitch * dst_height_per_thread;
unsigned int i = nThreads - 1;
@@ -414,7 +414,7 @@ void Direct3DDisplay::render()
pfthread_data[i].deltaPointer = (u8*)theApp.delta; // TODO: check if thread-safe
pfthread_data[i].destPointer = ( (u8*)lr.pBits ) + ( i * dst_bytes_per_thread );
pfthread_data[i].destPitch = lr.Pitch;
- pfthread_data[i].width = theApp.sizeX;
+ pfthread_data[i].width = sizeX;
if( i == ( nThreads - 1 ) ) {
// last thread
@@ -454,8 +454,8 @@ void Direct3DDisplay::render()
(u8*)theApp.delta,
(u8*)lr.pBits,
lr.Pitch,
- theApp.sizeX,
- theApp.sizeY
+ sizeX,
+ sizeY
);
}
} else {
@@ -468,8 +468,8 @@ void Direct3DDisplay::render()
lr.Pitch,
pix + pitch,
pitch,
- theApp.sizeX,
- theApp.sizeY
+ sizeX,
+ sizeY
);
break;
case 16:
@@ -478,8 +478,8 @@ void Direct3DDisplay::render()
lr.Pitch,
pix + pitch,
pitch,
- theApp.sizeX,
- theApp.sizeY
+ sizeX,
+ sizeY
);
break;
}
@@ -524,24 +524,24 @@ void Direct3DDisplay::render()
r.right = dpp.BackBufferWidth - 1;
r.bottom = dpp.BackBufferHeight - 1;
- if( theApp.showSpeed && ( theApp.videoOption > VIDEO_6X ) ) {
- color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
+ if( showSpeed && ( videoOption > VIDEO_6X ) ) {
+ color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
char buffer[30];
- if( theApp.showSpeed == 1 ) {
+ if( showSpeed == 1 ) {
sprintf( buffer, "%3d%%", systemSpeed );
} else {
- sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, theApp.showRenderedFrames );
+ sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames );
}
pFont->DrawText( NULL, buffer, -1, &r, DT_CENTER | DT_TOP, color );
}
- if( theApp.screenMessage ) {
- color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
- if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.disableStatusMessage && pFont ) {
+ if( screenMessage ) {
+ color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
+ if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages && pFont ) {
pFont->DrawText( NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color );
} else {
- theApp.screenMessage = false;
+ screenMessage = false;
}
}
@@ -576,7 +576,7 @@ void Direct3DDisplay::resize( int w, int h )
if( (w != dpp.BackBufferWidth) ||
(h != dpp.BackBufferHeight) ||
- (theApp.videoOption > VIDEO_6X) ) {
+ (videoOption > VIDEO_6X) ) {
resetDevice();
calculateDestRect();
}
@@ -761,7 +761,7 @@ void Direct3DDisplay::destroyTexture()
void Direct3DDisplay::calculateDestRect()
{
- if( theApp.fullScreenStretch ) {
+ if( fullScreenStretch ) {
rectangleFillsScreen = true; // no clear() necessary
destRect.left = 0;
destRect.top = 0;
@@ -772,8 +772,8 @@ void Direct3DDisplay::calculateDestRect()
float scaleX = (float)dpp.BackBufferWidth / (float)width;
float scaleY = (float)dpp.BackBufferHeight / (float)height;
float min = (scaleX < scaleY) ? scaleX : scaleY;
- if( theApp.maxScale && (min > theApp.maxScale) ) {
- min = (float)theApp.maxScale;
+ if( maxScale && (min > maxScale) ) {
+ min = (float)maxScale;
}
destRect.left = 0;
destRect.top = 0;
diff --git a/src/win32/DirectInput.cpp b/src/win32/DirectInput.cpp
index afc87133..e5801b39 100644
--- a/src/win32/DirectInput.cpp
+++ b/src/win32/DirectInput.cpp
@@ -621,7 +621,7 @@ bool DirectInput::readDevices()
u32 DirectInput::readDevice(int which)
{
u32 res = 0;
- int i = theApp.joypadDefault;
+ int i = joypadDefault;
if(which >= 0 && which <= 3)
i = which;
@@ -649,11 +649,11 @@ u32 DirectInput::readDevice(int which)
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]))
res |= 4096;
- if(theApp.autoFire) {
- res &= (~theApp.autoFire);
- if(theApp.autoFireToggle)
- res |= theApp.autoFire;
- theApp.autoFireToggle = !theApp.autoFireToggle;
+ if(autoFire) {
+ res &= (~autoFire);
+ if(autoFireToggle)
+ res |= autoFire;
+ autoFireToggle = !autoFireToggle;
}
// disallow L+R or U+D of being pressed at the same time
@@ -662,24 +662,24 @@ u32 DirectInput::readDevice(int which)
if((res & 192) == 192)
res &= ~128;
- if(theApp.movieRecording) {
- if(i == theApp.joypadDefault) {
- if(res != theApp.movieLastJoypad) {
- fwrite(&theApp.movieFrame, 1, sizeof(theApp.movieFrame), theApp.movieFile);
+ if(movieRecording) {
+ if(i == joypadDefault) {
+ if(res != movieLastJoypad) {
+ fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
fwrite(&res, 1, sizeof(res), theApp.movieFile);
- theApp.movieLastJoypad = res;
+ movieLastJoypad = res;
}
}
}
- if(theApp.moviePlaying) {
- if(theApp.movieFrame == theApp.moviePlayFrame) {
- theApp.movieLastJoypad = theApp.movieNextJoypad;
+ if(moviePlaying) {
+ if(movieFrame == moviePlayFrame) {
+ movieLastJoypad = movieNextJoypad;
theApp.movieReadNext();
}
- res = theApp.movieLastJoypad;
+ res = movieLastJoypad;
}
// we don't record speed up or screen capture buttons
- if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]) || theApp.speedupToggle)
+ if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]) || speedupToggle)
res |= 1024;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
res |= 2048;
@@ -751,55 +751,55 @@ void DirectInput::checkKeys()
void DirectInput::checkMotionKeys()
{
if(checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
- theApp.sunBars--;
- if (theApp.sunBars < 1)
- theApp.sunBars = 1;
+ sunBars--;
+ if (sunBars < 1)
+ sunBars = 1;
- theApp.sensorX += 3;
- if(theApp.sensorX > 2197)
- theApp.sensorX = 2197;
- if(theApp.sensorX < 2047)
- theApp.sensorX = 2057;
+ sensorX += 3;
+ if(sensorX > 2197)
+ sensorX = 2197;
+ if(sensorX < 2047)
+ sensorX = 2057;
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
- theApp.sunBars++;
- if (theApp.sunBars > 100)
- theApp.sunBars = 100;
+ sunBars++;
+ if (sunBars > 100)
+ sunBars = 100;
- theApp.sensorX -= 3;
- if(theApp.sensorX < 1897)
- theApp.sensorX = 1897;
- if(theApp.sensorX > 2047)
- theApp.sensorX = 2037;
- } else if(theApp.sensorX > 2047) {
- theApp.sensorX -= 2;
- if(theApp.sensorX < 2047)
- theApp.sensorX = 2047;
+ sensorX -= 3;
+ if(sensorX < 1897)
+ sensorX = 1897;
+ if(sensorX > 2047)
+ sensorX = 2037;
+ } else if(sensorX > 2047) {
+ sensorX -= 2;
+ if(sensorX < 2047)
+ sensorX = 2047;
} else {
- theApp.sensorX += 2;
- if(theApp.sensorX > 2047)
- theApp.sensorX = 2047;
+ sensorX += 2;
+ if(sensorX > 2047)
+ sensorX = 2047;
}
if(checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
- theApp.sensorY += 3;
- if(theApp.sensorY > 2197)
- theApp.sensorY = 2197;
- if(theApp.sensorY < 2047)
- theApp.sensorY = 2057;
+ sensorY += 3;
+ if(sensorY > 2197)
+ sensorY = 2197;
+ if(sensorY < 2047)
+ sensorY = 2057;
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
- theApp.sensorY -= 3;
- if(theApp.sensorY < 1897)
- theApp.sensorY = 1897;
- if(theApp.sensorY > 2047)
- theApp.sensorY = 2037;
- } else if(theApp.sensorY > 2047) {
- theApp.sensorY -= 2;
- if(theApp.sensorY < 2047)
- theApp.sensorY = 2047;
+ sensorY -= 3;
+ if(sensorY < 1897)
+ sensorY = 1897;
+ if(sensorY > 2047)
+ sensorY = 2037;
+ } else if(sensorY > 2047) {
+ sensorY -= 2;
+ if(sensorY < 2047)
+ sensorY = 2047;
} else {
- theApp.sensorY += 2;
- if(theApp.sensorY > 2047)
- theApp.sensorY = 2047;
+ sensorY += 2;
+ if(sensorY > 2047)
+ sensorY = 2047;
}
}
diff --git a/src/win32/DirectSound.cpp b/src/win32/DirectSound.cpp
index de9b0bf0..c8c4fc27 100644
--- a/src/win32/DirectSound.cpp
+++ b/src/win32/DirectSound.cpp
@@ -117,7 +117,7 @@ bool DirectSound::init(long sampleRate)
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
- if( theApp.dsoundDisableHardwareAcceleration ) {
+ if( dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
@@ -151,7 +151,7 @@ bool DirectSound::init(long sampleRate)
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
- if( theApp.dsoundDisableHardwareAcceleration ) {
+ if( dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
dsbdesc.dwBufferBytes = soundBufferTotalLen;
@@ -240,7 +240,7 @@ void DirectSound::write(u16 * finalWave, int length)
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
- if( !speedup && synchronize && !theApp.throttle && !gba_joybus_active) {
+ if( !speedup && synchronize && !throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) {
if( !soundPaused ) {
diff --git a/src/win32/FileDlg.cpp b/src/win32/FileDlg.cpp
index bde34659..69c29faf 100644
--- a/src/win32/FileDlg.cpp
+++ b/src/win32/FileDlg.cpp
@@ -102,7 +102,7 @@ FileDlg::FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter,
*p++ = 0;
m_ofn.lpstrFilter = m_filter;
- if(theApp.videoOption == VIDEO_320x240) {
+ if(videoOption == VIDEO_320x240) {
m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENDLG);
m_ofn.lpfnHook = HookFuncOldStyle;
m_ofn.Flags |= OFN_ENABLETEMPLATE;
diff --git a/src/win32/GBMapView.cpp b/src/win32/GBMapView.cpp
index 51dcce97..7a14b6d5 100644
--- a/src/win32/GBMapView.cpp
+++ b/src/win32/GBMapView.cpp
@@ -236,7 +236,7 @@ void GBMapView::OnSave()
{
CString filename;
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
filename = "map.png";
else
filename = "map.bmp";
@@ -248,8 +248,8 @@ void GBMapView::OnSave()
FileDlg dlg(this,
filename,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
diff --git a/src/win32/GBOamView.cpp b/src/win32/GBOamView.cpp
index d2b07af3..63046956 100644
--- a/src/win32/GBOamView.cpp
+++ b/src/win32/GBOamView.cpp
@@ -367,7 +367,7 @@ void GBOamView::save()
{
CString captureBuffer;
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
captureBuffer = "oam.png";
else
captureBuffer = "oam.bmp";
@@ -380,8 +380,8 @@ void GBOamView::save()
FileDlg dlg(this,
captureBuffer,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
diff --git a/src/win32/GBPrinterDlg.cpp b/src/win32/GBPrinterDlg.cpp
index 9af2a738..fcb01f6b 100644
--- a/src/win32/GBPrinterDlg.cpp
+++ b/src/win32/GBPrinterDlg.cpp
@@ -243,7 +243,7 @@ void GBPrinterDlg::OnSave()
{
CString captureBuffer;
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
captureBuffer = "printer.png";
else
captureBuffer = "printer.bmp";
@@ -256,8 +256,8 @@ void GBPrinterDlg::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
diff --git a/src/win32/GBTileView.cpp b/src/win32/GBTileView.cpp
index 585f554d..6770eda2 100644
--- a/src/win32/GBTileView.cpp
+++ b/src/win32/GBTileView.cpp
@@ -242,7 +242,7 @@ void GBTileView::OnSave()
{
CString captureBuffer;
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
captureBuffer = "tiles.png";
else
captureBuffer = "tiles.bmp";
@@ -255,8 +255,8 @@ void GBTileView::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
@@ -268,7 +268,7 @@ void GBTileView::OnSave()
captureBuffer = dlg.GetPathName();
- if(theApp.captureFormat)
+ if(captureFormat)
saveBMP(captureBuffer);
else
savePNG(captureBuffer);
diff --git a/src/win32/GDBConnection.cpp b/src/win32/GDBConnection.cpp
index 673539d2..8b36cfa5 100644
--- a/src/win32/GDBConnection.cpp
+++ b/src/win32/GDBConnection.cpp
@@ -24,10 +24,10 @@ GDBPortDlg::GDBPortDlg(CWnd* pParent /*=NULL*/)
//{{AFX_DATA_INIT(GDBPortDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
- if (theApp.gdbPort == 0)
+ if (gdbPort == 0)
port = 55555;
else
- port = theApp.gdbPort;
+ port = gdbPort;
sock = INVALID_SOCKET;
if(!initialized) {
@@ -100,7 +100,7 @@ void GDBPortDlg::OnOk()
address.sin_port = htons(atoi(buffer));
port = ntohs(address.sin_port);
- theApp.gdbPort = port;
+ gdbPort = port;
EndDialog(TRUE);
}
diff --git a/src/win32/LinkOptions.cpp b/src/win32/LinkOptions.cpp
index c927df48..246b62ba 100644
--- a/src/win32/LinkOptions.cpp
+++ b/src/win32/LinkOptions.cpp
@@ -42,7 +42,7 @@ LinkOptions::LinkOptions(CWnd* pParent /*=NULL*/)
: CDialog(LinkOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(LinkOptions)
- m_type = theApp.linkMode;
+ m_type = linkMode;
m_server = FALSE;
//}}AFX_DATA_INIT
}
@@ -54,11 +54,11 @@ void LinkOptions::DoDataExchange(CDataExchange* pDX)
//{{AFX_DATA_MAP(LinkOptions)
DDX_CBData(pDX, IDC_LINK_MODE, m_type);
DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout);
- DDX_Check(pDX, IDC_AUTOLINK, theApp.linkAuto);
- DDX_Check(pDX, IDC_SSPEED, theApp.linkHacks);
+ DDX_Check(pDX, IDC_AUTOLINK, linkAuto);
+ DDX_Check(pDX, IDC_SSPEED, linkHacks);
DDX_Control(pDX, IDC_LINK_MODE, m_mode);
DDX_Control(pDX, IDC_SERVERIP, m_serverip);
- DDX_Radio(pDX, IDC_LINK2P, theApp.linkNumPlayers);
+ DDX_Radio(pDX, IDC_LINK2P, linkNumPlayers);
DDX_Radio(pDX, IDC_LINK_CLIENT, m_server);
//}}AFX_DATA_MAP
}
@@ -76,19 +76,19 @@ BOOL LinkOptions::OnInitDialog(){
AddMode("Wireless adapter - Network", LINK_RFU_SOCKET);
AddMode("Game Link (Game Boy) - Single Computer", LINK_GAMEBOY);
- sprintf(timeout, "%d", theApp.linkTimeout);
+ sprintf(timeout, "%d", linkTimeout);
m_timeout.LimitText(5);
m_timeout.SetWindowText(timeout);
m_serverip.SetWindowText(theApp.linkHostAddr);
- CheckDlgButton(IDC_AUTOLINK, theApp.linkAuto);
+ CheckDlgButton(IDC_AUTOLINK, linkAuto);
- CheckDlgButton(IDC_SSPEED, theApp.linkHacks);
+ CheckDlgButton(IDC_SSPEED, linkHacks);
int player_radio = 0;
- switch (theApp.linkNumPlayers)
+ switch (linkNumPlayers)
{
case 2:
player_radio = IDC_LINK2P;
@@ -156,8 +156,8 @@ void LinkOptions::OnOk()
LinkMode newMode = (LinkMode) m_type;
if (newMode == LINK_DISCONNECTED) {
- theApp.linkTimeout = timeout;
- theApp.linkMode = LINK_DISCONNECTED;
+ linkTimeout = timeout;
+ linkMode = LINK_DISCONNECTED;
theApp.linkHostAddr = host;
CDialog::OnOK();
return;
@@ -173,8 +173,8 @@ void LinkOptions::OnOk()
}
}
- EnableSpeedHacks(theApp.linkHacks);
- EnableLinkServer(m_server, theApp.linkNumPlayers + 1);
+ EnableSpeedHacks(linkHacks);
+ EnableLinkServer(m_server, linkNumPlayers + 1);
if (m_server) {
char localhost[length];
@@ -239,8 +239,8 @@ void LinkOptions::OnOk()
return;
}
- theApp.linkTimeout = timeout;
- theApp.linkMode = GetLinkMode();
+ linkTimeout = timeout;
+ linkMode = GetLinkMode();
theApp.linkHostAddr = host;
CDialog::OnOK();
diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp
index 8272e128..6498061d 100644
--- a/src/win32/MainWnd.cpp
+++ b/src/win32/MainWnd.cpp
@@ -421,7 +421,7 @@ bool MainWnd::FileRun()
{
// save battery file before we change the filename...
if(rom != NULL || gbRom != NULL) {
- if(theApp.autoSaveLoadCheatList)
+ if(autoSaveLoadCheatList)
winSaveCheatListDefault();
writeBatteryFile();
cheatSearchCleanup(&cheatSearchData);
@@ -488,30 +488,29 @@ bool MainWnd::FileRun()
gbGetHardwareType();
// used for the handling of the gb Boot Rom
- skipBios = theApp.skipBiosFile;
if (gbHardware & 5)
{
- gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
+ gbCPUInit(theApp.biosFileNameGB, useBiosFileGB);
}
else if (gbHardware & 2)
{
- gbCPUInit(theApp.biosFileNameGBC, theApp.useBiosFileGBC);
+ gbCPUInit(theApp.biosFileNameGBC, useBiosFileGBC);
}
gbReset();
theApp.emulator = GBSystem;
- gbBorderOn = theApp.winGbBorderOn;
- theApp.romSize = gbRomSize;
+ gbBorderOn = winGbBorderOn;
+ theApp.romSize = gbRomSize;
- if(theApp.autoPatch && !patchName.IsEmpty()) {
+ if(autoPatch && !patchName.IsEmpty()) {
int size = gbRomSize;
applyPatch(patchName, &gbRom, &size);
if(size != gbRomSize) {
extern bool gbUpdateSizes();
gbUpdateSizes();
gbReset();
- theApp.romSize = size;
+ theApp.romSize = size;
}
}
} else {
@@ -519,11 +518,11 @@ bool MainWnd::FileRun()
if(!size)
return false;
- theApp.romSize = size;
+ theApp.romSize = size;
- flashSetSize(theApp.winFlashSize);
- rtcEnable(theApp.winRtcEnable);
- cpuSaveType = theApp.winSaveType;
+ flashSetSize(winFlashSize);
+ rtcEnable(rtcEnabled);
+ cpuSaveType = saveType;
if (cpuSaveType == 0)
utilGBAFindSave(theApp.romSize);
@@ -569,7 +568,7 @@ bool MainWnd::FileRun()
theApp.emulator = GBASystem;
- if(theApp.autoPatch && !patchName.IsEmpty()) {
+ if(autoPatch && !patchName.IsEmpty()) {
int size = 0x2000000;
applyPatch(patchName, &rom, &size);
if(size != 0x2000000) {
@@ -585,7 +584,7 @@ bool MainWnd::FileRun()
soundReset();
} else {
soundInit();
- theApp.soundInitialized = true;
+ theApp.soundInitialized = true;
}
#ifdef APU_LOGGER_H
@@ -593,42 +592,41 @@ bool MainWnd::FileRun()
#endif
if(type == IMAGE_GBA) {
- skipBios = theApp.skipBiosFile;
- CPUInit(theApp.biosFileNameGBA.GetString(), theApp.useBiosFileGBA);
+ CPUInit(theApp.biosFileNameGBA.GetString(), useBiosFileGBA);
CPUReset();
}
readBatteryFile();
- if(theApp.autoSaveLoadCheatList)
+ if(autoSaveLoadCheatList)
winLoadCheatListDefault();
theApp.addRecentFile(theApp.szFile);
- theApp.updateWindowSize(theApp.videoOption);
+ theApp.updateWindowSize(videoOption);
theApp.updateFrameSkip();
emulating = true;
- if(theApp.autoLoadMostRecent)
+ if(autoLoadMostRecent)
OnFileLoadgameMostrecent();
- theApp.frameskipadjust = 0;
- theApp.renderedFrames = 0;
- theApp.autoFrameSkipLastTime = systemGetClock();
+ frameskipadjust = 0;
+ renderedFrames = 0;
+ autoFrameSkipLastTime = systemGetClock();
- theApp.rewindCount = 0;
- theApp.rewindCounter = 0;
- theApp.rewindSaveNeeded = false;
+ rewindCount = 0;
+ rewindCounter = 0;
+ rewindSaveNeeded = false;
toolsClearLog();
#ifndef NO_LINK
- if (theApp.linkAuto)
- BootLink(theApp.linkMode, theApp.linkHostAddr, theApp.linkTimeout, theApp.linkHacks, theApp.linkNumPlayers);
+ if (linkAuto)
+ BootLink(linkMode, theApp.linkHostAddr, linkTimeout, linkHacks, linkNumPlayers);
#endif
- if (theApp.gdbBreakOnLoad)
+ if (gdbBreakOnLoad)
OnToolsDebugBreak();
return true;
@@ -722,11 +720,11 @@ void MainWnd::OnMove(int x, int y)
RECT r;
GetWindowRect(&r);
- theApp.windowPositionX = r.left;
- theApp.windowPositionY = r.top;
+ windowPositionX = r.left;
+ windowPositionY = r.top;
theApp.adjustDestRect();
- regSetDwordValue("windowX", theApp.windowPositionX);
- regSetDwordValue("windowY", theApp.windowPositionY);
+ regSetDwordValue("windowX", windowPositionX);
+ regSetDwordValue("windowY", windowPositionY);
}
}
}
@@ -742,7 +740,7 @@ void MainWnd::OnSizing(UINT fwSide, LPRECT pRect)
}
// maintain minimal window size
- RECT size = { 0, 0, theApp.sizeX, theApp.sizeY };
+ RECT size = { 0, 0, sizeX, sizeY };
AdjustWindowRectEx(
&size,
WS_POPUP | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
@@ -767,7 +765,7 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
- bool redraw = ( ( cx < theApp.surfaceSizeX ) || ( cy < theApp.surfaceSizeY ) );
+ bool redraw = ( ( cx < surfaceSizeX ) || ( cy < surfaceSizeY ) );
if(!theApp.changingVideoSize) {
if(this) {
@@ -775,12 +773,12 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
if(theApp.iconic) {
if(emulating) {
soundResume();
- theApp.paused = false;
+ paused = false;
}
}
- if(theApp.videoOption <= VIDEO_6X) {
- theApp.surfaceSizeX = cx;
- theApp.surfaceSizeY = cy;
+ if(videoOption <= VIDEO_6X) {
+ surfaceSizeX = cx;
+ surfaceSizeY = cy;
theApp.adjustDestRect();
if(theApp.display)
theApp.display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top);
@@ -788,17 +786,17 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
theApp.painting = true;
systemDrawScreen();
theApp.painting = false;
- theApp.renderedFrames--;
+ renderedFrames--;
}
}
} else {
if(emulating) {
- if(!theApp.paused) {
- theApp.paused = true;
+ if(!paused) {
+ paused = true;
soundPause();
}
}
- theApp.iconic = true;
+ theApp.iconic = true;
}
}
}
@@ -1151,8 +1149,8 @@ void MainWnd::OnPaint()
if(emulating) {
theApp.painting = true;
systemDrawScreen();
- theApp.painting = false;
- theApp.renderedFrames--;
+ theApp.painting = false;
+ renderedFrames--;
}
}
@@ -1196,7 +1194,7 @@ void MainWnd::screenCapture(int captureNumber)
captureDir = getDirFromFile(theApp.filename);
LPCTSTR ext = "png";
- if(theApp.captureFormat != 0)
+ if(captureFormat != 0)
ext = "bmp";
if(isDriveRoot(captureDir))
@@ -1219,7 +1217,7 @@ void MainWnd::screenCapture(int captureNumber)
return;
}
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
theApp.emulator.emuWritePNG(buffer);
else
theApp.emulator.emuWriteBMP(buffer);
@@ -1231,10 +1229,10 @@ void MainWnd::screenCapture(int captureNumber)
void MainWnd::winMouseOn()
{
SetCursor(arrow);
- if(theApp.videoOption > VIDEO_6X) {
- theApp.mouseCounter = 10;
+ if(videoOption > VIDEO_6X) {
+ mouseCounter = 10;
} else
- theApp.mouseCounter = 0;
+ mouseCounter = 0;
}
void MainWnd::OnMouseMove(UINT nFlags, CPoint point)
@@ -1258,29 +1256,29 @@ void MainWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
bool a = (nState == WA_ACTIVE) || (nState == WA_CLICKACTIVE);
if(a && theApp.input) {
- theApp.active = a;
+ active = a;
theApp.input->activate();
- if(!theApp.paused && emulating) {
+ if(!paused && emulating) {
soundResume();
}
} else {
- theApp.wasPaused = true;
- if(theApp.pauseWhenInactive && !gba_joybus_active) {
+ wasPaused = true;
+ if(pauseWhenInactive && !gba_joybus_active) {
if(emulating) {
soundPause();
}
- theApp.active = a;
+ active = a;
}
memset(theApp.delta,255,sizeof(theApp.delta));
}
- if(theApp.paused && emulating)
+ if(paused && emulating)
{
theApp.painting = true;
systemDrawScreen();
theApp.painting = false;
- theApp.renderedFrames--;
+ renderedFrames--;
}
}
@@ -1306,7 +1304,7 @@ void MainWnd::OnDropFiles(HDROP hDropInfo)
LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam)
{
- if(emulating && !theApp.paused) {
+ if(emulating && !paused) {
if((wParam&0xFFF0) == SC_SCREENSAVE || (wParam&0xFFF0) == SC_MONITORPOWER)
return 0;
}
diff --git a/src/win32/MainWndCheats.cpp b/src/win32/MainWndCheats.cpp
index 31114b8f..3c6b9774 100644
--- a/src/win32/MainWndCheats.cpp
+++ b/src/win32/MainWndCheats.cpp
@@ -47,12 +47,12 @@ void MainWnd::OnUpdateCheatsCheatlist(CCmdUI* pCmdUI)
void MainWnd::OnCheatsAutomaticsaveloadcheats()
{
- theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList;
+ autoSaveLoadCheatList = !autoSaveLoadCheatList;
}
void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.autoSaveLoadCheatList);
+ pCmdUI->SetCheck(autoSaveLoadCheatList);
}
void MainWnd::OnCheatsLoadcheatlist()
diff --git a/src/win32/MainWndFile.cpp b/src/win32/MainWndFile.cpp
index cb9d7f57..e97a830d 100644
--- a/src/win32/MainWndFile.cpp
+++ b/src/win32/MainWndFile.cpp
@@ -48,10 +48,10 @@ void MainWnd::OnFileOpenGB()
void MainWnd::OnFilePause()
{
- theApp.paused = !theApp.paused;
+ paused = !paused;
if(emulating) {
- if(theApp.paused) {
- theApp.wasPaused = true;
+ if(paused) {
+ wasPaused = true;
soundPause();
} else {
soundResume();
@@ -61,20 +61,19 @@ void MainWnd::OnFilePause()
void MainWnd::OnUpdateFilePause(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.paused);
+ pCmdUI->SetCheck(paused);
}
void MainWnd::OnFileReset()
{
- skipBios = theApp.skipBiosFile;
if(emulating) {
if(theApp.cartridgeType == IMAGE_GB) {
gbGetHardwareType();
if (gbHardware & 5) {
- gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
+ gbCPUInit(theApp.biosFileNameGB, useBiosFileGB);
} else if (gbHardware & 2) {
- gbCPUInit(theApp.biosFileNameGBC, theApp.useBiosFileGBC);
+ gbCPUInit(theApp.biosFileNameGBC, useBiosFileGBC);
}
}
theApp.emulator.emuReset();
@@ -89,7 +88,7 @@ void MainWnd::OnUpdateFileReset(CCmdUI* pCmdUI)
void MainWnd::OnUpdateFileRecentFreeze(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.recentFreeze);
+ pCmdUI->SetCheck(recentFreeze);
if(pCmdUI->m_pMenu == NULL)
return;
@@ -139,7 +138,7 @@ void MainWnd::OnFileRecentReset()
void MainWnd::OnFileRecentFreeze()
{
- theApp.recentFreeze = !theApp.recentFreeze;
+ recentFreeze = !recentFreeze;
}
void MainWnd::OnFileExit()
@@ -151,7 +150,7 @@ void MainWnd::OnFileClose()
{
// save battery file before we change the filename...
if(rom != NULL || gbRom != NULL) {
- if(theApp.autoSaveLoadCheatList)
+ if(autoSaveLoadCheatList)
winSaveCheatListDefault();
writeBatteryFile();
soundPause();
@@ -209,9 +208,9 @@ void MainWnd::OnFileLoad()
if(dlg.DoModal() == IDOK) {
bool res = loadSaveGame(dlg.GetPathName());
- theApp.rewindCount = 0;
- theApp.rewindCounter = 0;
- theApp.rewindSaveNeeded = false;
+ rewindCount = 0;
+ rewindCounter = 0;
+ rewindSaveNeeded = false;
if(res)
systemScreenMessage(winResLoadString(IDS_LOADED_STATE));
@@ -262,16 +261,13 @@ BOOL MainWnd::OnFileLoadSlot(UINT nID)
bool res = loadSaveGame(filename);
- if (theApp.paused)
+ if (paused)
InterframeCleanup();
systemScreenMessage(buffer);
systemDrawScreen();
- //theApp.rewindCount = 0;
- //theApp.rewindCounter = 0;
- //theApp.rewindSaveNeeded = false;
return res;
}
@@ -628,7 +624,7 @@ void MainWnd::OnFileScreencapture()
CString ext = "png";
- if(theApp.captureFormat != 0)
+ if(captureFormat != 0)
ext = "bmp";
if(isDriveRoot(capdir))
@@ -644,8 +640,8 @@ void MainWnd::OnFileScreencapture()
FileDlg dlg(this,
filename,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
capdir,
title,
@@ -686,7 +682,7 @@ void MainWnd::OnUpdateFileRominformation(CCmdUI* pCmdUI)
//OnFileToggleFullscreen
void MainWnd::OnFileTogglemenu()
{
- if( theApp.videoOption <= VIDEO_6X ) {
+ if( videoOption <= VIDEO_6X ) {
// switch to full screen
toolsLoggingClose(); // close log dialog
theApp.updateWindowSize( theApp.lastFullscreen );
@@ -699,7 +695,7 @@ void MainWnd::OnFileTogglemenu()
void MainWnd::OnUpdateFileTogglemenu(CCmdUI* pCmdUI)
{
// HACK: when uncommented, Esc key will not be send to MainWnd
- //pCmdUI->Enable(theApp.videoOption > VIDEO_6X);
+ //pCmdUI->Enable(videoOption > VIDEO_6X);
}
bool MainWnd::fileImportGSACodeFile(CString& fileName)
@@ -977,12 +973,12 @@ void MainWnd::OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI)
void MainWnd::OnFileLoadgameAutoloadmostrecent()
{
- theApp.autoLoadMostRecent = !theApp.autoLoadMostRecent;
+ autoLoadMostRecent = !autoLoadMostRecent;
}
void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.autoLoadMostRecent);
+ pCmdUI->SetCheck(autoLoadMostRecent);
}
void MainWnd::OnLoadgameDonotchangebatterysave()
diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp
index 0fa6da87..57cb8ddb 100644
--- a/src/win32/MainWndOptions.cpp
+++ b/src/win32/MainWndOptions.cpp
@@ -39,72 +39,72 @@
void MainWnd::OnOptionsFrameskipThrottleNothrottle()
{
theApp.updateThrottle( 0 ); // disable
- theApp.autoFrameSkip = false;
+ autoFrameSkip = false;
}
void MainWnd::OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck( theApp.throttle == 0 );
+ pCmdUI->SetCheck( throttle == 0 );
}
void MainWnd::OnOptionsFrameskipThrottle25()
{
theApp.updateThrottle( 25 );
- theApp.autoFrameSkip = false;
+ autoFrameSkip = false;
}
void MainWnd::OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck( theApp.throttle == 25 );
+ pCmdUI->SetCheck( throttle == 25 );
}
void MainWnd::OnOptionsFrameskipThrottle50()
{
theApp.updateThrottle( 50 );
- theApp.autoFrameSkip = false;
+ autoFrameSkip = false;
}
void MainWnd::OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck( theApp.throttle == 50 );
+ pCmdUI->SetCheck( throttle == 50 );
}
void MainWnd::OnOptionsFrameskipThrottle100()
{
theApp.updateThrottle( 100 );
- theApp.autoFrameSkip = false;
+ autoFrameSkip = false;
}
void MainWnd::OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck( theApp.throttle == 100 );
+ pCmdUI->SetCheck( throttle == 100 );
}
void MainWnd::OnOptionsFrameskipThrottle150()
{
theApp.updateThrottle( 150 );
-theApp.autoFrameSkip = false;
+autoFrameSkip = false;
}
void MainWnd::OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck( theApp.throttle == 150 );
+ pCmdUI->SetCheck( throttle == 150 );
}
void MainWnd::OnOptionsFrameskipThrottle200()
{
theApp.updateThrottle( 200 );
- theApp.autoFrameSkip = false;
+ autoFrameSkip = false;
}
void MainWnd::OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck( theApp.throttle == 200 );
+ pCmdUI->SetCheck( throttle == 200 );
}
@@ -115,7 +115,7 @@ void MainWnd::OnOptionsFrameskipThrottleOther()
if( v ) {
theApp.updateThrottle( v );
- theApp.autoFrameSkip = false;
+ autoFrameSkip = false;
}
}
@@ -123,22 +123,22 @@ void MainWnd::OnOptionsFrameskipThrottleOther()
void MainWnd::OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(
- ( theApp.throttle != 0 ) &&
- ( theApp.throttle != 25 ) &&
- ( theApp.throttle != 50 ) &&
- ( theApp.throttle != 100 ) &&
- ( theApp.throttle != 150 ) &&
- ( theApp.throttle != 200 ) );
+ ( throttle != 0 ) &&
+ ( throttle != 25 ) &&
+ ( throttle != 50 ) &&
+ ( throttle != 100 ) &&
+ ( throttle != 150 ) &&
+ ( throttle != 200 ) );
}
void MainWnd::OnOptionsFrameskipAutomatic()
{
- theApp.autoFrameSkip = !theApp.autoFrameSkip;
- if(!theApp.autoFrameSkip && emulating)
+ autoFrameSkip = !autoFrameSkip;
+ if(!autoFrameSkip && emulating)
theApp.updateFrameSkip();
else
{
- theApp.throttle = false;
+ throttle = false;
frameSkip = 0;
systemFrameSkip = 0;
}
@@ -146,7 +146,7 @@ void MainWnd::OnOptionsFrameskipAutomatic()
void MainWnd::OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.autoFrameSkip);
+ pCmdUI->SetCheck(autoFrameSkip);
}
BOOL MainWnd::OnOptionsFrameskip(UINT nID)
@@ -239,46 +239,46 @@ void MainWnd::OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI)
void MainWnd::OnOptionsVideoVsync()
{
- theApp.vsync = !theApp.vsync;
+ vsync = !vsync;
if( theApp.display ) {
- theApp.display->setOption( _T("vsync"), theApp.vsync );
+ theApp.display->setOption( _T("vsync"), vsync );
}
}
void MainWnd::OnUpdateOptionsVideoVsync(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.vsync);
+ pCmdUI->SetCheck(vsync);
}
void MainWnd::OnUpdateOptionsVideoX1(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_1X);
+ pCmdUI->SetCheck(videoOption == VIDEO_1X);
}
void MainWnd::OnUpdateOptionsVideoX2(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_2X);
+ pCmdUI->SetCheck(videoOption == VIDEO_2X);
}
void MainWnd::OnUpdateOptionsVideoX3(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_3X);
+ pCmdUI->SetCheck(videoOption == VIDEO_3X);
}
void MainWnd::OnUpdateOptionsVideoX4(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_4X);
+ pCmdUI->SetCheck(videoOption == VIDEO_4X);
}
void MainWnd::OnUpdateOptionsVideoX5(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_5X);
+ pCmdUI->SetCheck(videoOption == VIDEO_5X);
}
void MainWnd::OnUpdateOptionsVideoX6(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_6X);
+ pCmdUI->SetCheck(videoOption == VIDEO_6X);
}
BOOL MainWnd::OnOptionVideoSize(UINT nID)
@@ -293,19 +293,19 @@ void MainWnd::OnOptionsVideoFullscreen()
ZeroMemory( &mode, sizeof(IDisplay::VIDEO_MODE) );
if( theApp.display->selectFullScreenMode( mode ) ) {
- if( ( mode.width != theApp.fsWidth ) ||
- ( mode.height != theApp.fsHeight ) ||
- ( mode.bitDepth != theApp.fsColorDepth ) ||
- ( mode.frequency != theApp.fsFrequency ) ||
- ( mode.adapter != theApp.fsAdapter ) ||
- ( theApp.videoOption != VIDEO_OTHER ) )
+ if( ( mode.width != fsWidth ) ||
+ ( mode.height != fsHeight ) ||
+ ( mode.bitDepth != fsColorDepth ) ||
+ ( mode.frequency != fsFrequency ) ||
+ ( mode.adapter != fsAdapter ) ||
+ ( videoOption != VIDEO_OTHER ) )
{
- theApp.fsForceChange = true;
- theApp.fsWidth = mode.width;
- theApp.fsHeight = mode.height;
- theApp.fsFrequency = mode.frequency;
- theApp.fsColorDepth = mode.bitDepth;
- theApp.fsAdapter = mode.adapter;
+ fsForceChange = true;
+ fsWidth = mode.width;
+ fsHeight = mode.height;
+ fsFrequency = mode.frequency;
+ fsColorDepth = mode.bitDepth;
+ fsAdapter = mode.adapter;
theApp.updateVideoSize( ID_OPTIONS_VIDEO_FULLSCREEN );
}
}
@@ -315,7 +315,7 @@ void MainWnd::OnOptionsVideoFullscreen()
void MainWnd::OnUpdateOptionsVideoFullscreen(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.videoOption == VIDEO_OTHER);
+ pCmdUI->SetCheck(videoOption == VIDEO_OTHER);
}
void MainWnd::OnOptionsVideoDisablesfx()
@@ -333,16 +333,16 @@ void MainWnd::OnUpdateOptionsVideoDisablesfx(CCmdUI* pCmdUI)
void MainWnd::OnOptionsVideoFullscreenstretchtofit()
{
- theApp.fullScreenStretch = !theApp.fullScreenStretch;
+ fullScreenStretch = !fullScreenStretch;
if( theApp.display ) {
- theApp.display->setOption( _T("fullScreenStretch"), theApp.fullScreenStretch );
+ theApp.display->setOption( _T("fullScreenStretch"), fullScreenStretch );
}
}
void MainWnd::OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.fullScreenStretch);
+ pCmdUI->SetCheck(fullScreenStretch);
}
BOOL MainWnd::OnVideoLayer(UINT nID)
@@ -463,16 +463,16 @@ void MainWnd::OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI)
void MainWnd::OnOptionsVideoTriplebuffering()
{
- theApp.tripleBuffering = !theApp.tripleBuffering;
+ tripleBuffering = !tripleBuffering;
if( theApp.display ) {
- theApp.display->setOption( _T("tripleBuffering"), theApp.tripleBuffering );
+ theApp.display->setOption( _T("tripleBuffering"), tripleBuffering );
}
}
void MainWnd::OnUpdateOptionsVideoTriplebuffering(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.tripleBuffering);
+ pCmdUI->SetCheck(tripleBuffering);
}
@@ -520,9 +520,9 @@ void MainWnd::OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI)
void MainWnd::OnOptionsVideoRenderoptionsGlnearest()
{
#ifndef NO_OGL
- theApp.glFilter = 0;
+ glFilter = 0;
if( theApp.display ) {
- theApp.display->setOption( _T("glFilter"), theApp.glFilter );
+ theApp.display->setOption( _T("glFilter"), glFilter );
}
#endif
}
@@ -531,7 +531,7 @@ void MainWnd::OnOptionsVideoRenderoptionsGlnearest()
void MainWnd::OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI)
{
#ifndef NO_OGL
- pCmdUI->SetCheck(theApp.glFilter == 0);
+ pCmdUI->SetCheck(glFilter == 0);
#else
pCmdUI->Enable( FALSE );
#endif
@@ -541,9 +541,9 @@ void MainWnd::OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI)
void MainWnd::OnOptionsVideoRenderoptionsGlbilinear()
{
#ifndef NO_OGL
- theApp.glFilter = 1;
+ glFilter = 1;
if( theApp.display ) {
- theApp.display->setOption( _T("glFilter"), theApp.glFilter );
+ theApp.display->setOption( _T("glFilter"), glFilter );
}
#endif
}
@@ -552,7 +552,7 @@ void MainWnd::OnOptionsVideoRenderoptionsGlbilinear()
void MainWnd::OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI)
{
#ifndef NO_OGL
- pCmdUI->SetCheck(theApp.glFilter == 1);
+ pCmdUI->SetCheck(glFilter == 1);
#else
pCmdUI->Enable( FALSE );
#endif
@@ -573,19 +573,19 @@ void MainWnd::OnOptionsEmulatorDirectories()
void MainWnd::OnOptionsEmulatorDisablestatusmessages()
{
- theApp.disableStatusMessage = !theApp.disableStatusMessage;
+ disableStatusMessages = !disableStatusMessages;
}
void MainWnd::OnUpdateOptionsEmulatorDisablestatusmessages(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.disableStatusMessage);
+ pCmdUI->SetCheck(disableStatusMessages);
}
void MainWnd::OnOptionsEmulatorSynchronize()
{
synchronize = !synchronize;
if (synchronize)
- theApp.throttle = false;
+ throttle = false;
}
void MainWnd::OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI)
@@ -595,32 +595,32 @@ void MainWnd::OnUpdateOptionsEmulatorSynchronize(CCmdUI* pCmdUI)
void MainWnd::OnOptionsEmulatorPausewheninactive()
{
- theApp.pauseWhenInactive = !theApp.pauseWhenInactive;
+ pauseWhenInactive = !pauseWhenInactive;
}
void MainWnd::OnUpdateOptionsEmulatorPausewheninactive(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.pauseWhenInactive);
+ pCmdUI->SetCheck(pauseWhenInactive);
}
void MainWnd::OnOptionsEmulatorSpeeduptoggle()
{
- theApp.speedupToggle = !theApp.speedupToggle;
+ speedupToggle = !speedupToggle;
}
void MainWnd::OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.speedupToggle);
+ pCmdUI->SetCheck(speedupToggle);
}
void MainWnd::OnOptionsEmulatorAutomaticallyApplyPatchFiles()
{
- theApp.autoPatch = !theApp.autoPatch;
+ autoPatch = !autoPatch;
}
void MainWnd::OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.autoPatch);
+ pCmdUI->SetCheck(autoPatch);
}
void MainWnd::OnOptionsEmulatorAgbprint()
@@ -635,30 +635,30 @@ void MainWnd::OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI)
void MainWnd::OnOptionsEmulatorRealtimeclock()
{
- theApp.winRtcEnable = !theApp.winRtcEnable;
+ rtcEnabled = !rtcEnabled;
}
void MainWnd::OnUpdateOptionsEmulatorRealtimeclock(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winRtcEnable);
+ pCmdUI->SetCheck(rtcEnabled);
}
void MainWnd::OnOptionsEmulatorRewindinterval()
{
- RewindInterval dlg(theApp.rewindTimer/6);
+ RewindInterval dlg(rewindTimer/6);
int v = (int)dlg.DoModal();
if( v >= 0 ) {
- theApp.rewindTimer = v*6; // convert to a multiple of 10 frames
+ rewindTimer = v*6; // convert to a multiple of 10 frames
regSetDwordValue("rewindTimer", v);
if(v == 0) {
if(theApp.rewindMemory) {
free(theApp.rewindMemory);
theApp.rewindMemory = NULL;
}
- theApp.rewindCount = 0;
- theApp.rewindCounter = 0;
- theApp.rewindSaveNeeded = false;
+ rewindCount = 0;
+ rewindCounter = 0;
+ rewindSaveNeeded = false;
} else {
if(theApp.rewindMemory == NULL) {
theApp.rewindMemory = (char *)malloc(8*REWIND_SIZE);
@@ -672,17 +672,17 @@ BOOL MainWnd::OnOptionsEmulatorShowSpeed(UINT nID)
{
switch(nID) {
case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE:
- theApp.showSpeed = 0;
+ showSpeed = 0;
systemSetTitle(VBA_NAME_AND_SUBVERSION);
break;
case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE:
- theApp.showSpeed = 1;
+ showSpeed = 1;
break;
case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED:
- theApp.showSpeed = 2;
+ showSpeed = 2;
break;
case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT:
- theApp.showSpeedTransparent = !theApp.showSpeedTransparent;
+ showSpeedTransparent = !showSpeedTransparent;
break;
default:
return FALSE;
@@ -694,89 +694,89 @@ void MainWnd::OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI)
{
switch(pCmdUI->m_nID) {
case ID_OPTIONS_EMULATOR_SHOWSPEED_NONE:
- pCmdUI->SetCheck(theApp.showSpeed == 0);
+ pCmdUI->SetCheck(showSpeed == 0);
break;
case ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE:
- pCmdUI->SetCheck(theApp.showSpeed == 1);
+ pCmdUI->SetCheck(showSpeed == 1);
break;
case ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED:
- pCmdUI->SetCheck(theApp.showSpeed == 2);
+ pCmdUI->SetCheck(showSpeed == 2);
break;
case ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT:
- pCmdUI->SetCheck(theApp.showSpeedTransparent);
+ pCmdUI->SetCheck(showSpeedTransparent);
break;
}
}
void MainWnd::OnOptionsEmulatorSavetypeAutomatic()
{
- theApp.winSaveType = 0;
+ saveType = 0;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winSaveType == 0);
+ pCmdUI->SetCheck(saveType == 0);
}
void MainWnd::OnOptionsEmulatorSavetypeEeprom()
{
- theApp.winSaveType = 1;
+ saveType = 1;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winSaveType == 1);
+ pCmdUI->SetCheck(saveType == 1);
}
void MainWnd::OnOptionsEmulatorSavetypeSram()
{
- theApp.winSaveType = 2;
+ saveType = 2;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeSram(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winSaveType == 2);
+ pCmdUI->SetCheck(saveType == 2);
}
void MainWnd::OnOptionsEmulatorSavetypeFlash()
{
- theApp.winSaveType = 3;
+ saveType = 3;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winSaveType == 3);
+ pCmdUI->SetCheck(saveType == 3);
}
void MainWnd::OnOptionsEmulatorSavetypeEepromsensor()
{
- theApp.winSaveType = 4;
+ saveType = 4;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winSaveType == 4);
+ pCmdUI->SetCheck(saveType == 4);
}
void MainWnd::OnOptionsEmulatorSavetypeNone()
{
- theApp.winSaveType = 5;
+ saveType = 5;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeNone(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winSaveType == 5);
+ pCmdUI->SetCheck(saveType == 5);
}
void MainWnd::OnOptionsEmulatorSavetypeFlash512k()
{
flashSetSize(0x10000);
- theApp.winFlashSize = 0x10000;
+ winFlashSize = 0x10000;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI)
{
- // changed theApp.winFlashSize to flashSize to reflect the actual
+ // changed winFlashSize to flashSize to reflect the actual
// flashsize value used by the emu (it can change upon battery loading)
pCmdUI->SetCheck(flashSize == 0x10000);
}
@@ -784,12 +784,12 @@ void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI)
void MainWnd::OnOptionsEmulatorSavetypeFlash1m()
{
flashSetSize(0x20000);
- theApp.winFlashSize = 0x20000;
+ winFlashSize = 0x20000;
}
void MainWnd::OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI)
{
- // changed theApp.winFlashSize to flashSize to reflect the actual
+ // changed winFlashSize to flashSize to reflect the actual
// flashsize value used by the emu (it can change upon battery loading)
pCmdUI->SetCheck(flashSize == 0x20000);
}
@@ -835,22 +835,22 @@ void MainWnd::OnUpdateOptionsEmulatorSavetypeDetectNow(CCmdUI* pCmdUI)
void MainWnd::OnOptionsEmulatorPngformat()
{
- theApp.captureFormat = 0;
+ captureFormat = 0;
}
void MainWnd::OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.captureFormat == 0);
+ pCmdUI->SetCheck(captureFormat == 0);
}
void MainWnd::OnOptionsEmulatorBmpformat()
{
- theApp.captureFormat = 1;
+ captureFormat = 1;
}
void MainWnd::OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.captureFormat == 1);
+ pCmdUI->SetCheck(captureFormat == 1);
}
void MainWnd::OnAudioCoreSettings()
@@ -895,7 +895,7 @@ void MainWnd::OnAudioCoreSettings()
void MainWnd::OnUpdateAudioCoreSettings(CCmdUI *pCmdUI)
{
- pCmdUI->Enable( ( !theApp.aviRecording && !theApp.soundRecording ) ? TRUE : FALSE );
+ pCmdUI->Enable( ( !aviRecording && !soundRecording ) ? TRUE : FALSE );
}
void MainWnd::updateSoundChannels(UINT id)
@@ -994,23 +994,23 @@ void MainWnd::OnUpdateOptionsSoundDirectsoundb(CCmdUI* pCmdUI)
void MainWnd::OnOptionsGameboyBorder()
{
- theApp.winGbBorderOn = !theApp.winGbBorderOn;
- gbBorderOn = theApp.winGbBorderOn;
+ winGbBorderOn = !winGbBorderOn;
+ gbBorderOn = winGbBorderOn;
if(emulating && theApp.cartridgeType == 1 && gbBorderOn) {
gbSgbRenderBorder();
}
- theApp.updateWindowSize(theApp.videoOption);
+ theApp.updateWindowSize(videoOption);
}
void MainWnd::OnUpdateOptionsGameboyBorder(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.winGbBorderOn);
+ pCmdUI->SetCheck(winGbBorderOn);
}
void MainWnd::OnOptionsGameboyPrinter()
{
- theApp.winGbPrinterEnabled = !theApp.winGbPrinterEnabled;
- if(theApp.winGbPrinterEnabled)
+ winGbPrinterEnabled = !winGbPrinterEnabled;
+ if(winGbPrinterEnabled)
gbSerialFunction = gbPrinterSend;
else
#ifndef NO_LINK
@@ -1030,7 +1030,7 @@ void MainWnd::OnOptionsGameboyBorderAutomatic()
gbBorderAutomatic = !gbBorderAutomatic;
if(emulating && theApp.cartridgeType == 1 && gbBorderOn) {
gbSgbRenderBorder();
- theApp.updateWindowSize(theApp.videoOption);
+ theApp.updateWindowSize(videoOption);
}
}
@@ -1138,16 +1138,16 @@ BOOL MainWnd::OnOptionsPriority(UINT nID)
{
switch(nID) {
case ID_OPTIONS_PRIORITY_HIGHEST:
- theApp.threadPriority = 0;
+ threadPriority = 0;
break;
case ID_OPTIONS_PRIORITY_ABOVENORMAL:
- theApp.threadPriority = 1;
+ threadPriority = 1;
break;
case ID_OPTIONS_PRIORITY_NORMAL:
- theApp.threadPriority = 2;
+ threadPriority = 2;
break;
case ID_OPTIONS_PRIORITY_BELOWNORMAL:
- theApp.threadPriority = 3;
+ threadPriority = 3;
break;
default:
return FALSE;
@@ -1161,16 +1161,16 @@ void MainWnd::OnUpdateOptionsPriority(CCmdUI *pCmdUI)
{
switch(pCmdUI->m_nID) {
case ID_OPTIONS_PRIORITY_HIGHEST:
- pCmdUI->SetCheck(theApp.threadPriority == 0);
+ pCmdUI->SetCheck(threadPriority == 0);
break;
case ID_OPTIONS_PRIORITY_ABOVENORMAL:
- pCmdUI->SetCheck(theApp.threadPriority == 1);
+ pCmdUI->SetCheck(threadPriority == 1);
break;
case ID_OPTIONS_PRIORITY_NORMAL:
- pCmdUI->SetCheck(theApp.threadPriority == 2);
+ pCmdUI->SetCheck(threadPriority == 2);
break;
case ID_OPTIONS_PRIORITY_BELOWNORMAL:
- pCmdUI->SetCheck(theApp.threadPriority == 3);
+ pCmdUI->SetCheck(threadPriority == 3);
break;
}
}
@@ -1180,74 +1180,74 @@ BOOL MainWnd::OnOptionsFilter(UINT nID)
switch(nID)
{
case ID_OPTIONS_FILTER_NORMAL:
- theApp.filterType = FILTER_NONE;
+ filterType = FILTER_NONE;
break;
case ID_OPTIONS_FILTER_TVMODE:
- theApp.filterType = FILTER_TVMODE;
+ filterType = FILTER_TVMODE;
break;
case ID_OPTIONS_FILTER_PLUGIN:
- theApp.filterType = FILTER_PLUGIN;
+ filterType = FILTER_PLUGIN;
if( strcmp( theApp.pluginName, "" ) == 0 ) {
// open select plugin dialog when none selected
OnOptionsSelectPlugin();
}
break;
case ID_OPTIONS_FILTER_2XSAI:
- theApp.filterType = FILTER_2XSAI;
+ filterType = FILTER_2XSAI;
break;
case ID_OPTIONS_FILTER_SUPER2XSAI:
- theApp.filterType = FILTER_SUPER2XSAI;
+ filterType = FILTER_SUPER2XSAI;
break;
case ID_OPTIONS_FILTER_SUPEREAGLE:
- theApp.filterType = FILTER_SUPEREAGLE;
+ filterType = FILTER_SUPEREAGLE;
break;
case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL:
- theApp.filterType = FILTER_PIXELATE;
+ filterType = FILTER_PIXELATE;
break;
case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X:
- theApp.filterType = FILTER_MAMESCALE2X;
+ filterType = FILTER_MAMESCALE2X;
break;
case ID_OPTIONS_FILTER16BIT_SIMPLE2X:
- theApp.filterType = FILTER_SIMPLE2X;
+ filterType = FILTER_SIMPLE2X;
break;
case ID_OPTIONS_FILTER_BILINEAR:
- theApp.filterType = FILTER_BILINEAR;
+ filterType = FILTER_BILINEAR;
break;
case ID_OPTIONS_FILTER_BILINEARPLUS:
- theApp.filterType = FILTER_BILINEARPLUS;
+ filterType = FILTER_BILINEARPLUS;
break;
case ID_OPTIONS_FILTER_SCANLINES:
- theApp.filterType = FILTER_SCANLINES;
+ filterType = FILTER_SCANLINES;
break;
case ID_OPTIONS_FILTER_HQ2X:
- theApp.filterType = FILTER_HQ2X;
+ filterType = FILTER_HQ2X;
break;
case ID_OPTIONS_FILTER_LQ2X:
- theApp.filterType = FILTER_LQ2X;
+ filterType = FILTER_LQ2X;
break;
case ID_OPTIONS_FILTER_SIMPLE3X:
- theApp.filterType = FILTER_SIMPLE3X;
+ filterType = FILTER_SIMPLE3X;
break;
case ID_OPTIONS_FILTER_SIMPLE4X:
- theApp.filterType = FILTER_SIMPLE4X;
+ filterType = FILTER_SIMPLE4X;
break;
case ID_OPTIONS_FILTER_HQ3X:
- theApp.filterType = FILTER_HQ3X;
+ filterType = FILTER_HQ3X;
break;
case ID_OPTIONS_FILTER_HQ4X:
- theApp.filterType = FILTER_HQ4X;
+ filterType = FILTER_HQ4X;
break;
case ID_OPTIONS_FILTER_XBRZ2X:
- theApp.filterType = FILTER_XBRZ2X;
+ filterType = FILTER_XBRZ2X;
break;
case ID_OPTIONS_FILTER_XBRZ3X:
- theApp.filterType = FILTER_XBRZ3X;
+ filterType = FILTER_XBRZ3X;
break;
case ID_OPTIONS_FILTER_XBRZ4X:
- theApp.filterType = FILTER_XBRZ4X;
+ filterType = FILTER_XBRZ4X;
break;
case ID_OPTIONS_FILTER_XBRZ5X:
- theApp.filterType = FILTER_XBRZ5X;
+ filterType = FILTER_XBRZ5X;
break;
default:
return FALSE;
@@ -1262,91 +1262,91 @@ void MainWnd::OnUpdateOptionsFilter(CCmdUI *pCmdUI)
switch(pCmdUI->m_nID) {
case ID_OPTIONS_FILTER_NORMAL:
- pCmdUI->SetCheck(theApp.filterType == FILTER_NONE);
+ pCmdUI->SetCheck(filterType == FILTER_NONE);
break;
case ID_OPTIONS_FILTER_TVMODE:
- pCmdUI->SetCheck(theApp.filterType == FILTER_TVMODE);
+ pCmdUI->SetCheck(filterType == FILTER_TVMODE);
break;
case ID_OPTIONS_FILTER_2XSAI:
- pCmdUI->SetCheck(theApp.filterType == FILTER_2XSAI);
+ pCmdUI->SetCheck(filterType == FILTER_2XSAI);
break;
case ID_OPTIONS_FILTER_SUPER2XSAI:
- pCmdUI->SetCheck(theApp.filterType == FILTER_SUPER2XSAI);
+ pCmdUI->SetCheck(filterType == FILTER_SUPER2XSAI);
break;
case ID_OPTIONS_FILTER_PLUGIN:
- pCmdUI->Enable( !theApp.filterMT );
- pCmdUI->SetCheck(theApp.filterType == FILTER_PLUGIN);
+ pCmdUI->Enable( !filterMT );
+ pCmdUI->SetCheck(filterType == FILTER_PLUGIN);
break;
case ID_OPTIONS_FILTER_SUPEREAGLE:
- pCmdUI->SetCheck(theApp.filterType == FILTER_SUPEREAGLE);
+ pCmdUI->SetCheck(filterType == FILTER_SUPEREAGLE);
break;
case ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL:
- pCmdUI->SetCheck(theApp.filterType == FILTER_PIXELATE);
+ pCmdUI->SetCheck(filterType == FILTER_PIXELATE);
break;
case ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_MAMESCALE2X);
+ pCmdUI->SetCheck(filterType == FILTER_MAMESCALE2X);
break;
case ID_OPTIONS_FILTER16BIT_SIMPLE2X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_SIMPLE2X);
+ pCmdUI->SetCheck(filterType == FILTER_SIMPLE2X);
break;
case ID_OPTIONS_FILTER_BILINEAR:
- pCmdUI->SetCheck(theApp.filterType == FILTER_BILINEAR);
+ pCmdUI->SetCheck(filterType == FILTER_BILINEAR);
break;
case ID_OPTIONS_FILTER_BILINEARPLUS:
- pCmdUI->SetCheck(theApp.filterType == FILTER_BILINEARPLUS);
+ pCmdUI->SetCheck(filterType == FILTER_BILINEARPLUS);
break;
case ID_OPTIONS_FILTER_SCANLINES:
- pCmdUI->SetCheck(theApp.filterType == FILTER_SCANLINES);
+ pCmdUI->SetCheck(filterType == FILTER_SCANLINES);
break;
case ID_OPTIONS_FILTER_HQ2X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_HQ2X);
+ pCmdUI->SetCheck(filterType == FILTER_HQ2X);
break;
case ID_OPTIONS_FILTER_LQ2X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_LQ2X);
+ pCmdUI->SetCheck(filterType == FILTER_LQ2X);
break;
case ID_OPTIONS_FILTER_SIMPLE3X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_SIMPLE3X);
+ pCmdUI->SetCheck(filterType == FILTER_SIMPLE3X);
break;
case ID_OPTIONS_FILTER_SIMPLE4X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_SIMPLE4X);
+ pCmdUI->SetCheck(filterType == FILTER_SIMPLE4X);
break;
case ID_OPTIONS_FILTER_HQ3X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_HQ3X);
+ pCmdUI->SetCheck(filterType == FILTER_HQ3X);
break;
case ID_OPTIONS_FILTER_HQ4X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_HQ4X);
+ pCmdUI->SetCheck(filterType == FILTER_HQ4X);
break;
case ID_OPTIONS_FILTER_XBRZ2X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_XBRZ2X);
+ pCmdUI->SetCheck(filterType == FILTER_XBRZ2X);
break;
case ID_OPTIONS_FILTER_XBRZ3X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_XBRZ3X);
+ pCmdUI->SetCheck(filterType == FILTER_XBRZ3X);
break;
case ID_OPTIONS_FILTER_XBRZ4X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_XBRZ4X);
+ pCmdUI->SetCheck(filterType == FILTER_XBRZ4X);
break;
case ID_OPTIONS_FILTER_XBRZ5X:
- pCmdUI->SetCheck(theApp.filterType == FILTER_XBRZ5X);
+ pCmdUI->SetCheck(filterType == FILTER_XBRZ5X);
break;
}
}
void MainWnd::OnUpdateOptionsSelectPlugin(CCmdUI *pCmdUI)
{
- pCmdUI->Enable( !theApp.filterMT );
+ pCmdUI->Enable( !filterMT );
}
BOOL MainWnd::OnOptionsFilterIFB(UINT nID)
{
switch(nID) {
case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE:
- theApp.ifbType = 0;
+ ifbType = kIFBNone;
break;
case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR:
- theApp.ifbType = 1;
+ ifbType = kIBMotionBlur;
break;
case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART:
- theApp.ifbType = 2;
+ ifbType = kIBSmart;
break;
default:
return FALSE;
@@ -1359,13 +1359,13 @@ void MainWnd::OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI)
{
switch(pCmdUI->m_nID) {
case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE:
- pCmdUI->SetCheck(theApp.ifbType == 0);
+ pCmdUI->SetCheck(ifbType == 0);
break;
case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR:
- pCmdUI->SetCheck(theApp.ifbType == 1);
+ pCmdUI->SetCheck(ifbType == 1);
break;
case ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART:
- pCmdUI->SetCheck(theApp.ifbType == 2);
+ pCmdUI->SetCheck(ifbType == 2);
break;
}
}
@@ -1373,8 +1373,8 @@ void MainWnd::OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI)
void MainWnd::OnOptionsFilterDisablemmx()
{
#ifdef MMX
- theApp.disableMMX = !theApp.disableMMX;
- if(!theApp.disableMMX)
+ disableMMX = !disableMMX;
+ if(!disableMMX)
cpu_mmx = theApp.detectMMX();
else
cpu_mmx = 0;
@@ -1383,7 +1383,7 @@ void MainWnd::OnOptionsFilterDisablemmx()
void MainWnd::OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.disableMMX);
+ pCmdUI->SetCheck(disableMMX);
}
void MainWnd::OnOptionsLanguageSystem()
@@ -1394,7 +1394,7 @@ void MainWnd::OnOptionsLanguageSystem()
void MainWnd::OnUpdateOptionsLanguageSystem(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.languageOption == 0);
+ pCmdUI->SetCheck(languageOption == 0);
}
void MainWnd::OnOptionsLanguageEnglish()
@@ -1405,7 +1405,7 @@ void MainWnd::OnOptionsLanguageEnglish()
void MainWnd::OnUpdateOptionsLanguageEnglish(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.languageOption == 1);
+ pCmdUI->SetCheck(languageOption == 1);
}
void MainWnd::OnOptionsLanguageOther()
@@ -1416,7 +1416,7 @@ void MainWnd::OnOptionsLanguageOther()
void MainWnd::OnUpdateOptionsLanguageOther(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.languageOption == 2);
+ pCmdUI->SetCheck(languageOption == 2);
}
@@ -1428,7 +1428,7 @@ void MainWnd::OnOptionsJoypadConfigure1()
void MainWnd::OnUpdateOptionsJoypadConfigure1(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
+ pCmdUI->Enable(videoOption != VIDEO_320x240);
}
void MainWnd::OnOptionsJoypadConfigure2()
@@ -1439,7 +1439,7 @@ void MainWnd::OnOptionsJoypadConfigure2()
void MainWnd::OnUpdateOptionsJoypadConfigure2(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
+ pCmdUI->Enable(videoOption != VIDEO_320x240);
}
void MainWnd::OnOptionsJoypadConfigure3()
@@ -1450,7 +1450,7 @@ void MainWnd::OnOptionsJoypadConfigure3()
void MainWnd::OnUpdateOptionsJoypadConfigure3(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
+ pCmdUI->Enable(videoOption != VIDEO_320x240);
}
void MainWnd::OnOptionsJoypadConfigure4()
@@ -1461,18 +1461,18 @@ void MainWnd::OnOptionsJoypadConfigure4()
void MainWnd::OnUpdateOptionsJoypadConfigure4(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
+ pCmdUI->Enable(videoOption != VIDEO_320x240);
}
BOOL MainWnd::OnOptionsJoypadDefault(UINT nID)
{
- theApp.joypadDefault = nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1;
+ joypadDefault = nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1;
return TRUE;
}
void MainWnd::OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI)
{
- pCmdUI->SetCheck(theApp.joypadDefault == (int)(pCmdUI->m_nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1));
+ pCmdUI->SetCheck(joypadDefault == (int)(pCmdUI->m_nID - ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1));
}
void MainWnd::OnOptionsJoypadMotionconfigure()
@@ -1483,45 +1483,45 @@ void MainWnd::OnOptionsJoypadMotionconfigure()
void MainWnd::OnUpdateOptionsJoypadMotionconfigure(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
+ pCmdUI->Enable(videoOption != VIDEO_320x240);
}
BOOL MainWnd::OnOptionsJoypadAutofire(UINT nID)
{
switch(nID) {
case ID_OPTIONS_JOYPAD_AUTOFIRE_A:
- if(theApp.autoFire & 1) {
- theApp.autoFire &= ~1;
+ if(autoFire & 1) {
+ autoFire &= ~1;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_A_DISABLED));
} else {
- theApp.autoFire |= 1;
+ autoFire |= 1;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_A));
}
break;
case ID_OPTIONS_JOYPAD_AUTOFIRE_B:
- if(theApp.autoFire & 2) {
- theApp.autoFire &= ~2;
+ if(autoFire & 2) {
+ autoFire &= ~2;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_B_DISABLED));
} else {
- theApp.autoFire |= 2;
+ autoFire |= 2;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_B));
}
break;
case ID_OPTIONS_JOYPAD_AUTOFIRE_L:
- if(theApp.autoFire & 512) {
- theApp.autoFire &= ~512;
+ if(autoFire & 512) {
+ autoFire &= ~512;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_L_DISABLED));
} else {
- theApp.autoFire |= 512;
+ autoFire |= 512;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_L));
}
break;
case ID_OPTIONS_JOYPAD_AUTOFIRE_R:
- if(theApp.autoFire & 256) {
- theApp.autoFire &= ~256;
+ if(autoFire & 256) {
+ autoFire &= ~256;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_R_DISABLED));
} else {
- theApp.autoFire |= 256;
+ autoFire |= 256;
systemScreenMessage(winResLoadString(IDS_AUTOFIRE_R));
}
break;
@@ -1536,16 +1536,16 @@ void MainWnd::OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI)
bool check = true;
switch(pCmdUI->m_nID) {
case ID_OPTIONS_JOYPAD_AUTOFIRE_A:
- check = (theApp.autoFire & 1) != 0;
+ check = (autoFire & 1) != 0;
break;
case ID_OPTIONS_JOYPAD_AUTOFIRE_B:
- check = (theApp.autoFire & 2) != 0;
+ check = (autoFire & 2) != 0;
break;
case ID_OPTIONS_JOYPAD_AUTOFIRE_L:
- check = (theApp.autoFire & 512) != 0;
+ check = (autoFire & 512) != 0;
break;
case ID_OPTIONS_JOYPAD_AUTOFIRE_R:
- check = (theApp.autoFire & 256) != 0;
+ check = (autoFire & 256) != 0;
break;
}
pCmdUI->SetCheck(check);
@@ -1558,7 +1558,7 @@ void MainWnd::OnOptionsVideoFullscreenmaxscale()
dlg.DoModal();
if( theApp.display ) {
- theApp.display->setOption( _T("maxScale"), theApp.maxScale );
+ theApp.display->setOption( _T("maxScale"), maxScale );
}
}
@@ -1589,14 +1589,14 @@ void MainWnd::OnUpdateOptionsEmulatorGameoverrides(CCmdUI* pCmdUI)
void MainWnd::OnOptionsSoundHardwareacceleration()
{
- theApp.dsoundDisableHardwareAcceleration = !theApp.dsoundDisableHardwareAcceleration;
+ dsoundDisableHardwareAcceleration = !dsoundDisableHardwareAcceleration;
soundShutdown();
soundInit();
}
void MainWnd::OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI)
{
- pCmdUI->SetCheck(!theApp.dsoundDisableHardwareAcceleration);
+ pCmdUI->SetCheck(!dsoundDisableHardwareAcceleration);
}
void MainWnd::OnOptionsSelectPlugin()
@@ -1605,7 +1605,7 @@ void MainWnd::OnOptionsSelectPlugin()
if (dlg.DoModal() == IDOK)
{
- theApp.filterType = FILTER_PLUGIN;
+ filterType = FILTER_PLUGIN;
theApp.updateFilter();
}
}
@@ -1623,7 +1623,7 @@ void MainWnd::OnOutputapiDirectsound()
void MainWnd::OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI)
{
pCmdUI->SetCheck( ( theApp.audioAPI == DIRECTSOUND ) ? 1 : 0 );
- pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
+ pCmdUI->Enable(!aviRecording && !soundRecording);
}
void MainWnd::OnOutputapiXaudio2()
@@ -1641,7 +1641,7 @@ void MainWnd::OnUpdateOutputapiXaudio2(CCmdUI *pCmdUI)
{
#ifndef NO_XAUDIO2
pCmdUI->SetCheck( ( theApp.audioAPI == XAUDIO2 ) ? 1 : 0 );
- pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
+ pCmdUI->Enable(!aviRecording && !soundRecording);
#else
pCmdUI->Enable( FALSE );
#endif
@@ -1662,7 +1662,7 @@ void MainWnd::OnUpdateOutputapiOpenal(CCmdUI *pCmdUI)
{
#ifndef NO_OAL
pCmdUI->SetCheck( ( theApp.audioAPI == OPENAL_SOUND ) ? 1 : 0 );
- pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
+ pCmdUI->Enable(!aviRecording && !soundRecording);
#else
pCmdUI->Enable( FALSE );
#endif
@@ -1698,7 +1698,7 @@ void MainWnd::OnOutputapiOalconfiguration()
void MainWnd::OnUpdateOutputapiOalconfiguration(CCmdUI *pCmdUI)
{
#ifndef NO_OAL
- pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
+ pCmdUI->Enable(!aviRecording && !soundRecording);
#else
pCmdUI->Enable( FALSE );
#endif
@@ -1728,7 +1728,7 @@ void MainWnd::OnOutputapiXaudio2config()
void MainWnd::OnUpdateOutputapiXaudio2config(CCmdUI *pCmdUI)
{
#ifndef NO_XAUDIO2
- pCmdUI->Enable(!theApp.aviRecording && !theApp.soundRecording);
+ pCmdUI->Enable(!aviRecording && !soundRecording);
#else
pCmdUI->Enable( FALSE );
#endif
@@ -1756,19 +1756,19 @@ void MainWnd::OnUpdateRenderapiD3dmotionblur(CCmdUI *pCmdUI)
void MainWnd::OnEmulatorBiosfiles()
{
BIOSDialog dlg;
- dlg.m_enableBIOS_GBA = theApp.useBiosFileGBA ? TRUE : FALSE;
- dlg.m_enableBIOS_GBC = theApp.useBiosFileGBC ? TRUE : FALSE;
- dlg.m_enableBIOS_GB = theApp.useBiosFileGB ? TRUE : FALSE;
- dlg.m_skipLogo = theApp.skipBiosFile ? TRUE : FALSE;
+ dlg.m_enableBIOS_GBA = useBiosFileGBA ? TRUE : FALSE;
+ dlg.m_enableBIOS_GBC = useBiosFileGBC ? TRUE : FALSE;
+ dlg.m_enableBIOS_GB = useBiosFileGB ? TRUE : FALSE;
+ dlg.m_skipLogo = skipBios ? TRUE : FALSE;
dlg.m_pathGBA = theApp.biosFileNameGBA;
dlg.m_pathGBC = theApp.biosFileNameGBC;
dlg.m_pathGB = theApp.biosFileNameGB;
if( IDOK == dlg.DoModal() ) {
- theApp.useBiosFileGBA = dlg.m_enableBIOS_GBA == TRUE;
- theApp.useBiosFileGBC = dlg.m_enableBIOS_GBC == TRUE;
- theApp.useBiosFileGB = dlg.m_enableBIOS_GB == TRUE;
- theApp.skipBiosFile = dlg.m_skipLogo == TRUE;
+ useBiosFileGBA = dlg.m_enableBIOS_GBA == TRUE;
+ useBiosFileGBC = dlg.m_enableBIOS_GBC == TRUE;
+ useBiosFileGB = dlg.m_enableBIOS_GB == TRUE;
+ skipBios = dlg.m_skipLogo == TRUE;
theApp.biosFileNameGBA = dlg.m_pathGBA;
theApp.biosFileNameGBC = dlg.m_pathGBC;
theApp.biosFileNameGB = dlg.m_pathGB;
@@ -1777,11 +1777,11 @@ void MainWnd::OnEmulatorBiosfiles()
void MainWnd::OnPixelfilterMultiThreading()
{
- theApp.filterMT = !theApp.filterMT;
+ filterMT = !filterMT;
}
void MainWnd::OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI)
{
- pCmdUI->Enable( theApp.filterType != FILTER_PLUGIN );
- pCmdUI->SetCheck( theApp.filterMT ? 1 : 0 );
+ pCmdUI->Enable( filterType != FILTER_PLUGIN );
+ pCmdUI->SetCheck( filterMT ? 1 : 0 );
}
diff --git a/src/win32/MainWndTools.cpp b/src/win32/MainWndTools.cpp
index 62a98a41..473ce7eb 100644
--- a/src/win32/MainWndTools.cpp
+++ b/src/win32/MainWndTools.cpp
@@ -55,7 +55,7 @@ void MainWnd::OnToolsDisassemble()
void MainWnd::OnUpdateToolsDisassemble(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsLogging()
@@ -65,7 +65,7 @@ void MainWnd::OnToolsLogging()
void MainWnd::OnUpdateToolsLogging(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsIoviewer()
@@ -77,7 +77,7 @@ void MainWnd::OnToolsIoviewer()
void MainWnd::OnUpdateToolsIoviewer(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && theApp.cartridgeType == 0);
+ pCmdUI->Enable(videoOption <= VIDEO_6X && theApp.cartridgeType == 0);
}
void MainWnd::OnToolsMapview()
@@ -95,7 +95,7 @@ void MainWnd::OnToolsMapview()
void MainWnd::OnUpdateToolsMapview(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsMemoryviewer()
@@ -113,7 +113,7 @@ void MainWnd::OnToolsMemoryviewer()
void MainWnd::OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsOamviewer()
@@ -131,7 +131,7 @@ void MainWnd::OnToolsOamviewer()
void MainWnd::OnUpdateToolsOamviewer(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsPaletteview()
@@ -149,7 +149,7 @@ void MainWnd::OnToolsPaletteview()
void MainWnd::OnUpdateToolsPaletteview(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsTileviewer()
@@ -167,14 +167,14 @@ void MainWnd::OnToolsTileviewer()
void MainWnd::OnUpdateToolsTileviewer(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
+ pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnDebugNextframe()
{
- if(theApp.paused)
- theApp.paused = false;
- theApp.winPauseNextFrame = true;
+ if(paused)
+ paused = false;
+ winPauseNextFrame = true;
}
void MainWnd::OnToolsDebugConfigurePort()
@@ -191,19 +191,19 @@ void MainWnd::OnUpdateToolsDebugConfigurePort(CCmdUI* pCmdUI)
void MainWnd::OnToolsDebugBreakOnLoad()
{
- theApp.gdbBreakOnLoad = !theApp.gdbBreakOnLoad;
+ gdbBreakOnLoad = !gdbBreakOnLoad;
}
void MainWnd::OnUpdateToolsDebugBreakOnLoad(CCmdUI* pCmdUI)
{
- pCmdUI->SetCheck(theApp.gdbBreakOnLoad);
+ pCmdUI->SetCheck(gdbBreakOnLoad);
}
void MainWnd::OnToolsDebugBreak()
{
GDBPortDlg dlg;
- int port = theApp.gdbPort;
+ int port = gdbPort;
if (port == 0)
{
if (dlg.DoModal()) {
@@ -238,7 +238,7 @@ void MainWnd::OnToolsDebugBreak()
void MainWnd::OnUpdateToolsDebugBreak(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && emulating != 0);
+ pCmdUI->Enable(videoOption <= VIDEO_6X && emulating != 0);
}
void MainWnd::OnToolsDebugDisconnect()
@@ -249,7 +249,7 @@ void MainWnd::OnToolsDebugDisconnect()
void MainWnd::OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && remoteSocket != -1);
+ pCmdUI->Enable(videoOption <= VIDEO_6X && remoteSocket != -1);
}
void MainWnd::OnOptionsSoundStartrecording()
@@ -273,7 +273,7 @@ void MainWnd::OnOptionsSoundStartrecording()
}
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
- theApp.soundRecording = true;
+ soundRecording = true;
if(dlg.m_ofn.nFileOffset > 0) {
captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset);
@@ -288,7 +288,7 @@ void MainWnd::OnOptionsSoundStartrecording()
void MainWnd::OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!theApp.soundRecording);
+ pCmdUI->Enable(!soundRecording);
}
void MainWnd::OnOptionsSoundStoprecording()
@@ -297,12 +297,12 @@ void MainWnd::OnOptionsSoundStoprecording()
delete theApp.soundRecorder;
theApp.soundRecorder = NULL;
}
- theApp.soundRecording = false;
+ soundRecording = false;
}
void MainWnd::OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.soundRecording);
+ pCmdUI->Enable(soundRecording);
}
@@ -328,7 +328,7 @@ void MainWnd::OnToolsRecordStartavirecording()
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
theApp.aviRecordName = captureBuffer;
- theApp.aviRecording = true;
+ aviRecording = true;
if( dlg.m_ofn.nFileOffset > 0 ) {
captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset );
@@ -358,14 +358,14 @@ void MainWnd::OnToolsRecordStartavirecording()
systemMessage( IDS_AVI_CANNOT_CREATE_AVI, "Cannot create AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
- theApp.aviRecording = false;
+ aviRecording = false;
return;
}
// add video stream
ret = theApp.aviRecorder->CreateVideoStream(
- theApp.sizeX,
- theApp.sizeY,
+ sizeX,
+ sizeY,
( systemColorDepth == 32 ) ? 24 : 16,
60,
this->GetSafeHwnd()
@@ -374,7 +374,7 @@ void MainWnd::OnToolsRecordStartavirecording()
systemMessage( IDS_AVI_CANNOT_CREATE_VIDEO, "Cannot create video stream in AVI file. Make sure the selected codec supports input in RGB24 color space!" );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
- theApp.aviRecording = false;
+ aviRecording = false;
return;
}
@@ -389,7 +389,7 @@ void MainWnd::OnToolsRecordStartavirecording()
systemMessage( IDS_AVI_CANNOT_CREATE_AUDIO, "Cannot create audio stream in AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
- theApp.aviRecording = false;
+ aviRecording = false;
return;
}
}
@@ -397,7 +397,7 @@ void MainWnd::OnToolsRecordStartavirecording()
void MainWnd::OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI)
{
- pCmdUI->Enable( !theApp.aviRecording && emulating );
+ pCmdUI->Enable( !aviRecording && emulating );
}
@@ -407,13 +407,13 @@ void MainWnd::OnToolsRecordStopavirecording()
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
}
- theApp.aviRecording = false;
+ aviRecording = false;
}
void MainWnd::OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI)
{
- pCmdUI->Enable( theApp.aviRecording );
+ pCmdUI->Enable( aviRecording );
}
void MainWnd::OnToolsRecordStartmovierecording()
@@ -464,10 +464,10 @@ void MainWnd::OnToolsRecordStartmovierecording()
movieName = movieName.Left(movieName.GetLength()-3) + "VM0";
if(writeSaveGame(movieName)) {
- theApp.movieFrame = 0;
- theApp.movieLastJoypad = 0;
- theApp.movieRecording = true;
- theApp.moviePlaying = false;
+ movieFrame = 0;
+ movieLastJoypad = 0;
+ movieRecording = true;
+ moviePlaying = false;
} else {
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
(const char *)movieName);
@@ -476,29 +476,29 @@ void MainWnd::OnToolsRecordStartmovierecording()
void MainWnd::OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!theApp.movieRecording && emulating);
+ pCmdUI->Enable(!movieRecording && emulating);
}
void MainWnd::OnToolsRecordStopmovierecording()
{
- if(theApp.movieRecording) {
+ if(movieRecording) {
if(theApp.movieFile != NULL) {
// record the last joypad change so that the correct time can be
// recorded
- fwrite(&theApp.movieFrame, 1, sizeof(int), theApp.movieFile);
- fwrite(&theApp.movieLastJoypad, 1, sizeof(u32), theApp.movieFile);
+ fwrite(&movieFrame, 1, sizeof(int), theApp.movieFile);
+ fwrite(&movieLastJoypad, 1, sizeof(u32), theApp.movieFile);
fclose(theApp.movieFile);
theApp.movieFile = NULL;
}
- theApp.movieRecording = false;
- theApp.moviePlaying = false;
- theApp.movieLastJoypad = 0;
+ movieRecording = false;
+ moviePlaying = false;
+ movieLastJoypad = 0;
}
}
void MainWnd::OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.movieRecording);
+ pCmdUI->Enable(movieRecording);
}
void MainWnd::OnToolsPlayStartmovieplaying()
@@ -554,10 +554,10 @@ void MainWnd::OnToolsPlayStartmovieplaying()
}
movieName = movieName.Left(movieName.GetLength()-3)+"VM0";
if(loadSaveGame(movieName)) {
- theApp.moviePlaying = true;
- theApp.movieFrame = 0;
- theApp.moviePlayFrame = 0;
- theApp.movieLastJoypad = 0;
+ moviePlaying = true;
+ movieFrame = 0;
+ moviePlayFrame = 0;
+ movieLastJoypad = 0;
theApp.movieReadNext();
} else {
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
@@ -567,39 +567,39 @@ void MainWnd::OnToolsPlayStartmovieplaying()
void MainWnd::OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(!theApp.moviePlaying && emulating);
+ pCmdUI->Enable(!moviePlaying && emulating);
}
void MainWnd::OnToolsPlayStopmovieplaying()
{
- if(theApp.moviePlaying) {
+ if(moviePlaying) {
if(theApp.movieFile != NULL) {
fclose(theApp.movieFile);
theApp.movieFile = NULL;
}
- theApp.moviePlaying = false;
- theApp.movieLastJoypad = 0;
+ moviePlaying = false;
+ movieLastJoypad = 0;
}
}
void MainWnd::OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.moviePlaying);
+ pCmdUI->Enable(moviePlaying);
}
void MainWnd::OnToolsRewind()
{
- if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && theApp.rewindCount) {
- theApp.rewindPos = --theApp.rewindPos & 7;
- theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*theApp.rewindPos], REWIND_SIZE);
- theApp.rewindCount--;
- theApp.rewindCounter = 0;
+ if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && rewindCount) {
+ rewindPos = --rewindPos & 7;
+ theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*rewindPos], REWIND_SIZE);
+ rewindCount--;
+ rewindCounter = 0;
}
}
void MainWnd::OnUpdateToolsRewind(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && theApp.rewindCount);
+ pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && rewindCount);
}
void MainWnd::OnToolsCustomize()
@@ -616,5 +616,5 @@ void MainWnd::OnToolsCustomize()
void MainWnd::OnUpdateToolsCustomize(CCmdUI* pCmdUI)
{
- pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
+ pCmdUI->Enable(videoOption != VIDEO_320x240);
}
diff --git a/src/win32/MapView.cpp b/src/win32/MapView.cpp
index dd14c4c5..9a122545 100644
--- a/src/win32/MapView.cpp
+++ b/src/win32/MapView.cpp
@@ -966,7 +966,7 @@ void MapView::OnSave()
{
CString filename;
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
filename = "map.png";
else
filename = "map.bmp";
@@ -979,8 +979,8 @@ void MapView::OnSave()
FileDlg dlg(this,
filename,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
diff --git a/src/win32/MaxScale.cpp b/src/win32/MaxScale.cpp
index 45d51d0f..bac284ed 100644
--- a/src/win32/MaxScale.cpp
+++ b/src/win32/MaxScale.cpp
@@ -49,7 +49,7 @@ void MaxScale::OnOk()
{
CString tmp;
m_value.GetWindowText(tmp);
- theApp.maxScale = atoi(tmp);
+ maxScale = atoi(tmp);
EndDialog(TRUE);
}
@@ -59,7 +59,7 @@ BOOL MaxScale::OnInitDialog()
CString temp;
- temp.Format("%d", theApp.maxScale);
+ temp.Format("%d", maxScale);
m_value.SetWindowText(temp);
diff --git a/src/win32/OamView.cpp b/src/win32/OamView.cpp
index dce22d78..db236234 100644
--- a/src/win32/OamView.cpp
+++ b/src/win32/OamView.cpp
@@ -549,7 +549,7 @@ void OamView::OnSave()
{
CString captureBuffer;
- if (theApp.captureFormat == 0)
+ if (captureFormat == 0)
captureBuffer = "oam.png";
else
captureBuffer = "oam.bmp";
@@ -562,8 +562,8 @@ void OamView::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
diff --git a/src/win32/OpenAL.cpp b/src/win32/OpenAL.cpp
index cf354ab0..4b390daf 100644
--- a/src/win32/OpenAL.cpp
+++ b/src/win32/OpenAL.cpp
@@ -2,7 +2,7 @@
//#define LOGALL
#include "stdafx.h"
-#include "VBA.h" // for 'theApp.throttle'
+#include "VBA.h" // for 'throttle'
#ifndef NO_OAL
@@ -273,7 +273,7 @@ void OpenAL::write(u16 * finalWave, int length)
if( nBuffersProcessed == theApp.oalBufferCount ) {
// we only want to know about it when we are emulating at full speed or faster:
- if( ( theApp.throttle >= 100 ) || ( theApp.throttle == 0 ) ) {
+ if( ( throttle >= 100 ) || ( throttle == 0 ) ) {
if( systemVerbose & VERBOSE_SOUNDOUTPUT ) {
static unsigned int i = 0;
log( "OpenAL: Buffers were not refilled fast enough (i=%i)\n", i++ );
@@ -281,7 +281,7 @@ void OpenAL::write(u16 * finalWave, int length)
}
}
- if( !speedup && synchronize && !theApp.throttle && !gba_joybus_active) {
+ if( !speedup && synchronize && !throttle && !gba_joybus_active) {
// wait until at least one buffer has finished
while( nBuffersProcessed == 0 ) {
winlog( " waiting...\n" );
diff --git a/src/win32/OpenGL.cpp b/src/win32/OpenGL.cpp
index e83fb1c6..9ce586c3 100644
--- a/src/win32/OpenGL.cpp
+++ b/src/win32/OpenGL.cpp
@@ -192,49 +192,49 @@ bool OpenGLDisplay::initialize()
switch( theApp.cartridgeType )
{
case IMAGE_GBA:
- theApp.sizeX = 240;
- theApp.sizeY = 160;
+ sizeX = 240;
+ sizeY = 160;
break;
case IMAGE_GB:
if ( gbBorderOn )
{
- theApp.sizeX = 256;
- theApp.sizeY = 224;
+ sizeX = 256;
+ sizeY = 224;
}
else
{
- theApp.sizeX = 160;
- theApp.sizeY = 144;
+ sizeX = 160;
+ sizeY = 144;
}
break;
}
- switch(theApp.videoOption)
+ switch(videoOption)
{
case VIDEO_1X:
- theApp.surfaceSizeX = theApp.sizeX;
- theApp.surfaceSizeY = theApp.sizeY;
+ surfaceSizeX = sizeX;
+ surfaceSizeY = sizeY;
break;
case VIDEO_2X:
- theApp.surfaceSizeX = theApp.sizeX * 2;
- theApp.surfaceSizeY = theApp.sizeY * 2;
+ surfaceSizeX = sizeX * 2;
+ surfaceSizeY = sizeY * 2;
break;
case VIDEO_3X:
- theApp.surfaceSizeX = theApp.sizeX * 3;
- theApp.surfaceSizeY = theApp.sizeY * 3;
+ surfaceSizeX = sizeX * 3;
+ surfaceSizeY = sizeY * 3;
break;
case VIDEO_4X:
- theApp.surfaceSizeX = theApp.sizeX * 4;
- theApp.surfaceSizeY = theApp.sizeY * 4;
+ surfaceSizeX = sizeX * 4;
+ surfaceSizeY = sizeY * 4;
break;
case VIDEO_5X:
- theApp.surfaceSizeX = theApp.sizeX * 5;
- theApp.surfaceSizeY = theApp.sizeY * 5;
+ surfaceSizeX = sizeX * 5;
+ surfaceSizeY = sizeY * 5;
break;
case VIDEO_6X:
- theApp.surfaceSizeX = theApp.sizeX * 6;
- theApp.surfaceSizeY = theApp.sizeY * 6;
+ surfaceSizeX = sizeX * 6;
+ surfaceSizeY = sizeY * 6;
break;
case VIDEO_320x240:
case VIDEO_640x480:
@@ -243,17 +243,17 @@ bool OpenGLDisplay::initialize()
case VIDEO_1280x1024:
case VIDEO_OTHER:
{
- if( theApp.fullScreenStretch ) {
- theApp.surfaceSizeX = theApp.fsWidth;
- theApp.surfaceSizeY = theApp.fsHeight;
+ if( fullScreenStretch ) {
+ surfaceSizeX = fsWidth;
+ surfaceSizeY = fsHeight;
} else {
- float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX;
- float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY;
+ float scaleX = (float)fsWidth / (float)sizeX;
+ float scaleY = (float)fsHeight / (float)sizeY;
float min = ( scaleX < scaleY ) ? scaleX : scaleY;
- if( theApp.maxScale )
- min = ( min > (float)theApp.maxScale ) ? (float)theApp.maxScale : min;
- theApp.surfaceSizeX = (int)((float)theApp.sizeX * min);
- theApp.surfaceSizeY = (int)((float)theApp.sizeY * min);
+ if( maxScale )
+ min = ( min > (float)maxScale ) ? (float)maxScale : min;
+ surfaceSizeX = (int)((float)sizeX * min);
+ surfaceSizeY = (int)((float)sizeY * min);
}
}
break;
@@ -261,23 +261,23 @@ bool OpenGLDisplay::initialize()
theApp.rect.left = 0;
theApp.rect.top = 0;
- theApp.rect.right = theApp.sizeX;
- theApp.rect.bottom = theApp.sizeY;
+ theApp.rect.right = sizeX;
+ theApp.rect.bottom = sizeY;
theApp.dest.left = 0;
theApp.dest.top = 0;
- theApp.dest.right = theApp.surfaceSizeX;
- theApp.dest.bottom = theApp.surfaceSizeY;
+ theApp.dest.right = surfaceSizeX;
+ theApp.dest.bottom = surfaceSizeY;
DWORD style = WS_POPUP | WS_VISIBLE;
DWORD styleEx = 0;
- if( theApp.videoOption <= VIDEO_6X )
+ if( videoOption <= VIDEO_6X )
style |= WS_OVERLAPPEDWINDOW;
else
styleEx = 0;
- if( theApp.videoOption <= VIDEO_6X )
+ if( videoOption <= VIDEO_6X )
AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
else
AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );
@@ -286,12 +286,12 @@ bool OpenGLDisplay::initialize()
int winSizeY = theApp.dest.bottom - theApp.dest.top;
int x = 0, y = 0;
- if( theApp.videoOption <= VIDEO_6X ) {
- x = theApp.windowPositionX;
- y = theApp.windowPositionY;
+ if( videoOption <= VIDEO_6X ) {
+ x = windowPositionX;
+ y = windowPositionY;
} else {
- winSizeX = theApp.fsWidth;
- winSizeY = theApp.fsHeight;
+ winSizeX = fsWidth;
+ winSizeY = fsHeight;
}
@@ -300,20 +300,20 @@ bool OpenGLDisplay::initialize()
theApp.adjustDestRect();
- currentAdapter = theApp.fsAdapter;
+ currentAdapter = fsAdapter;
DISPLAY_DEVICE dev;
ZeroMemory( &dev, sizeof(dev) );
dev.cb = sizeof(dev);
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
- if( theApp.videoOption >= VIDEO_320x240 ) {
+ if( videoOption >= VIDEO_320x240 ) {
// enter full screen mode
DEVMODE mode;
ZeroMemory( &mode, sizeof(mode) );
mode.dmSize = sizeof(mode);
- mode.dmBitsPerPel = theApp.fsColorDepth;
- mode.dmPelsWidth = theApp.fsWidth;
- mode.dmPelsHeight = theApp.fsHeight;
- mode.dmDisplayFrequency = theApp.fsFrequency;
+ mode.dmBitsPerPel = fsColorDepth;
+ mode.dmPelsWidth = fsWidth;
+ mode.dmPelsHeight = fsHeight;
+ mode.dmDisplayFrequency = fsFrequency;
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
LONG ret = ChangeDisplaySettingsEx( dev.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL );
if( ret != DISP_CHANGE_SUCCESSFUL ) {
@@ -334,12 +334,12 @@ bool OpenGLDisplay::initialize()
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );
+ initializeMatrices( surfaceSizeX, surfaceSizeY );
- setVSync( theApp.vsync && !gba_joybus_active );
+ setVSync( vsync && !gba_joybus_active );
#ifdef MMX
- if(!theApp.disableMMX)
+ if(!disableMMX)
cpu_mmx = theApp.detectMMX();
else
cpu_mmx = 0;
@@ -349,15 +349,15 @@ bool OpenGLDisplay::initialize()
systemGreenShift = 11;
systemBlueShift = 3;
systemColorDepth = 32;
- theApp.fsColorDepth = 32;
+ fsColorDepth = 32;
Init_2xSaI(32);
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
theApp.updateFilter();
theApp.updateIFB();
- pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
- data = pix + ( theApp.sizeX + 1 ) * 4;
+ pitch = filterWidth * (systemColorDepth>>3) + 4;
+ data = pix + ( sizeX + 1 ) * 4;
if(failed)
return false;
@@ -377,8 +377,8 @@ void OpenGLDisplay::render()
{
clear();
- pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
- data = pix + ( theApp.sizeX + 1 ) * 4;
+ pitch = filterWidth * (systemColorDepth>>3) + 4;
+ data = pix + ( sizeX + 1 ) * 4;
// apply pixel filter
if(theApp.filterFunction) {
@@ -389,8 +389,8 @@ void OpenGLDisplay::render()
(u8*)theApp.delta,
(u8*)filterData,
width * 4 ,
- theApp.filterWidth,
- theApp.filterHeight);
+ filterWidth,
+ filterHeight);
}
// Texturemap complete texture to surface
@@ -399,7 +399,7 @@ void OpenGLDisplay::render()
if( theApp.filterFunction ) {
glPixelStorei( GL_UNPACK_ROW_LENGTH, width);
} else {
- glPixelStorei( GL_UNPACK_ROW_LENGTH, theApp.sizeX + 1 );
+ glPixelStorei( GL_UNPACK_ROW_LENGTH, sizeX + 1 );
}
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_BGRA,GL_UNSIGNED_BYTE,data );
@@ -410,49 +410,49 @@ void OpenGLDisplay::render()
glVertex3i( 0, 0, 0 );
glTexCoord2f( (float)(width) / size, 0.0f );
- glVertex3i( theApp.surfaceSizeX, 0, 0 );
+ glVertex3i( surfaceSizeX, 0, 0 );
glTexCoord2f( (float)(width) / size, (float)(height) / size );
- glVertex3i( theApp.surfaceSizeX, theApp.surfaceSizeY, 0 );
+ glVertex3i( surfaceSizeX, surfaceSizeY, 0 );
glTexCoord2f( 0.0f, (float)(height) / size );
- glVertex3i( 0, theApp.surfaceSizeY, 0 );
+ glVertex3i( 0, surfaceSizeY, 0 );
glEnd();
- if( theApp.showSpeed ) { // && ( theApp.videoOption > VIDEO_6X ) ) {
+ if( showSpeed ) { // && ( videoOption > VIDEO_6X ) ) {
char buffer[30];
- if( theApp.showSpeed == 1 ) {
+ if( showSpeed == 1 ) {
sprintf( buffer, "%3d%%", systemSpeed );
} else {
- sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, theApp.showRenderedFrames );
+ sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames );
}
glFontBegin(&font);
glPushMatrix();
- float fontscale = (float)theApp.surfaceSizeX / 100.0f;
+ float fontscale = (float)surfaceSizeX / 100.0f;
glScalef(fontscale, fontscale, fontscale);
glColor4f(1.0f, 0.25f, 0.25f, 1.0f);
- glFontTextOut(buffer, (theApp.surfaceSizeX-(strlen(buffer)*11))/(fontscale*2), (theApp.surfaceSizeY-20)/fontscale, 0);
+ glFontTextOut(buffer, (surfaceSizeX-(strlen(buffer)*11))/(fontscale*2), (surfaceSizeY-20)/fontscale, 0);
glPopMatrix();
glFontEnd();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBindTexture( GL_TEXTURE_2D, texture );
}
- if( theApp.screenMessage ) {
- if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.disableStatusMessage ) {
+ if( screenMessage ) {
+ if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages ) {
glFontBegin(&font);
glPushMatrix();
- float fontscale = (float)theApp.surfaceSizeX / 100.0f;
+ float fontscale = (float)surfaceSizeX / 100.0f;
glScalef(fontscale, fontscale, fontscale);
glColor4f(1.0f, 0.25f, 0.25f, 1.0f);
- glFontTextOut((char *)((const char *)theApp.screenMessageBuffer), (theApp.surfaceSizeX-(theApp.screenMessageBuffer.GetLength()*11))/(fontscale*2), (theApp.surfaceSizeY-40)/fontscale, 0);
+ glFontTextOut((char *)((const char *)theApp.screenMessageBuffer), (surfaceSizeX-(theApp.screenMessageBuffer.GetLength()*11))/(fontscale*2), (surfaceSizeY-40)/fontscale, 0);
glPopMatrix();
glFontEnd();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBindTexture( GL_TEXTURE_2D, texture );
} else {
- theApp.screenMessage = false;
+ screenMessage = false;
}
}
@@ -491,7 +491,7 @@ void OpenGLDisplay::updateFiltering( int value )
//init projection matrixes and viewports
void OpenGLDisplay::initializeMatrices( int w, int h )
{
- if( theApp.fullScreenStretch ) {
+ if( fullScreenStretch ) {
glViewport( 0, 0, w, h );
} else {
calculateDestRect( w, h );
@@ -542,7 +542,7 @@ bool OpenGLDisplay::initializeTexture( int w, int h )
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
- updateFiltering( theApp.glFilter );
+ updateFiltering( glFilter );
glTexImage2D(
GL_TEXTURE_2D,
@@ -609,8 +609,8 @@ void OpenGLDisplay::calculateDestRect( int w, int h )
float scaleX = (float)w / (float)width;
float scaleY = (float)h / (float)height;
float min = (scaleX < scaleY) ? scaleX : scaleY;
- if( theApp.maxScale && (min > theApp.maxScale) ) {
- min = (float)theApp.maxScale;
+ if( maxScale && (min > maxScale) ) {
+ min = (float)maxScale;
}
destRect.left = 0;
destRect.top = 0;
diff --git a/src/win32/Reg.cpp b/src/win32/Reg.cpp
index 39dd7d4e..66905544 100644
--- a/src/win32/Reg.cpp
+++ b/src/win32/Reg.cpp
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "VBA.h"
#include "..\gba\GBALink.h"
+#include "..\common\ConfigManager.h"
static char buffer[2048];
static HKEY vbKey = NULL;
diff --git a/src/win32/TileView.cpp b/src/win32/TileView.cpp
index 7e3128d4..c12ab676 100644
--- a/src/win32/TileView.cpp
+++ b/src/win32/TileView.cpp
@@ -248,7 +248,7 @@ void TileView::OnSave()
{
CString captureBuffer;
- if(theApp.captureFormat == 0)
+ if(captureFormat == 0)
captureBuffer = "tiles.png";
else
captureBuffer = "tiles.bmp";
@@ -261,8 +261,8 @@ void TileView::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
- theApp.captureFormat ? 2 : 1,
- theApp.captureFormat ? "BMP" : "PNG",
+ captureFormat ? 2 : 1,
+ captureFormat ? "BMP" : "PNG",
exts,
"",
title,
diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp
index 33a00c46..8eb99568 100644
--- a/src/win32/VBA.cpp
+++ b/src/win32/VBA.cpp
@@ -35,6 +35,7 @@
#include "../gb/gbPrinter.h"
#include "../gb/gbSound.h"
#include "../common/SoundDriver.h"
+#include "../common/ConfigManager.h"
#include "../version.h"
@@ -206,7 +207,7 @@ VBA::VBA()
windowPositionY = 0;
filterFunction = NULL;
ifbFunction = NULL;
- ifbType = 0;
+ ifbType = kIFBNone;
filterType = FILTER_NONE;
filterWidth = 0;
filterHeight = 0;
@@ -223,7 +224,6 @@ VBA::VBA()
sizeY = 0;
videoOption = 0;
fullScreenStretch = false;
- disableStatusMessage = false;
showSpeed = 0;
showSpeedTransparent = true;
showRenderedFrames = 0;
@@ -237,7 +237,7 @@ VBA::VBA()
useBiosFileGBA = false;
useBiosFileGBC = false;
useBiosFileGB = false;
- skipBiosFile = false;
+ skipBios = false;
biosFileNameGBA = _T("");
biosFileNameGBC = _T("");
biosFileNameGB = _T("");
@@ -249,8 +249,8 @@ VBA::VBA()
autoPatch = true;
winGbBorderOn = 0;
winFlashSize = 0x20000;
- winRtcEnable = false;
- winSaveType = 0;
+ rtcEnabled = false;
+ saveType = 0;
rewindMemory = NULL;
rewindPos = 0;
rewindTopPos = 0;
@@ -857,8 +857,6 @@ void VBA::updateFilter()
void VBA::updateThrottle( unsigned short throttle )
{
- this->throttle = throttle;
-
if( throttle ) {
Sm60FPS::K_fCpuSpeed = (float)throttle;
Sm60FPS::K_fTargetFps = 60.0f * Sm60FPS::K_fCpuSpeed / 100;
@@ -943,7 +941,7 @@ void systemDrawScreen()
if(theApp.display == NULL)
return;
- theApp.renderedFrames++;
+ renderedFrames++;
if(theApp.updateCount) {
POSITION pos = theApp.updateList.GetHeadPosition();
@@ -956,38 +954,38 @@ void systemDrawScreen()
if (Sm60FPS_CanSkipFrame())
return;
- if( theApp.aviRecording ) {
- if( theApp.painting ) {
+ if( aviRecording ) {
+ if (theApp.painting) {
theApp.skipAudioFrames++;
} else {
unsigned char *bmp;
- unsigned short srcPitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
+ unsigned short srcPitch = sizeX * ( systemColorDepth >> 3 ) + 4;
switch( systemColorDepth )
{
case 16:
- bmp = new unsigned char[ theApp.sizeX * theApp.sizeY * 2 ];
- cpyImg16bmp( bmp, pix + srcPitch, srcPitch, theApp.sizeX, theApp.sizeY );
+ bmp = new unsigned char[ sizeX * sizeY * 2 ];
+ cpyImg16bmp( bmp, pix + srcPitch, srcPitch, sizeX, sizeY );
break;
case 32:
// use 24 bit colors to reduce video size
- bmp = new unsigned char[ theApp.sizeX * theApp.sizeY * 3 ];
- cpyImg32bmp( bmp, pix + srcPitch, srcPitch, theApp.sizeX, theApp.sizeY );
+ bmp = new unsigned char[ sizeX * sizeY * 3 ];
+ cpyImg32bmp( bmp, pix + srcPitch, srcPitch, sizeX, sizeY );
break;
}
if( false == theApp.aviRecorder->AddVideoFrame( bmp ) ) {
systemMessage( IDS_AVI_CANNOT_WRITE_VIDEO, "Cannot write video frame to AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
- theApp.aviRecording = false;
+ aviRecording = false;
}
delete [] bmp;
}
}
if( theApp.ifbFunction ) {
- theApp.ifbFunction( pix + (theApp.filterWidth * (systemColorDepth>>3)) + 4,
- (theApp.filterWidth * (systemColorDepth>>3)) + 4,
- theApp.filterWidth, theApp.filterHeight );
+ theApp.ifbFunction( pix + (filterWidth * (systemColorDepth>>3)) + 4,
+ (filterWidth * (systemColorDepth>>3)) + 4,
+ filterWidth, filterHeight );
}
if(!soundBufferLow)
@@ -1042,16 +1040,16 @@ void systemSetTitle(const char *title)
void systemShowSpeed(int speed)
{
systemSpeed = speed;
- theApp.showRenderedFrames = theApp.renderedFrames;
- theApp.renderedFrames = 0;
- if(theApp.videoOption <= VIDEO_6X && theApp.showSpeed) {
+ showRenderedFrames = renderedFrames;
+ renderedFrames = 0;
+ if(videoOption <= VIDEO_6X && showSpeed) {
CString buffer;
- if(theApp.showSpeed == 1)
+ if(showSpeed == 1)
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%", systemSpeed);
else
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%(%d, %d fps)", systemSpeed,
systemFrameSkip,
- theApp.showRenderedFrames);
+ showRenderedFrames);
systemSetTitle(buffer);
}
@@ -1060,8 +1058,8 @@ void systemShowSpeed(int speed)
void systemFrame()
{
- if( theApp.movieRecording || theApp.moviePlaying ) {
- theApp.movieFrame++;
+ if( movieRecording || moviePlaying ) {
+ movieFrame++;
}
#ifdef LOG_PERFORMANCE
@@ -1073,11 +1071,11 @@ void systemFrame()
void system10Frames(int rate)
{
- if( theApp.autoFrameSkip )
+ if( autoFrameSkip )
{
u32 time = systemGetClock();
- u32 diff = time - theApp.autoFrameSkipLastTime;
- theApp.autoFrameSkipLastTime = time;
+ u32 diff = time - autoFrameSkipLastTime;
+ autoFrameSkipLastTime = time;
if( diff ) {
// countermeasure against div/0 when debugging
Sm60FPS::nCurSpeed = (1000000/rate)/diff;
@@ -1088,9 +1086,9 @@ void system10Frames(int rate)
if(theApp.rewindMemory) {
- if(++theApp.rewindCounter >= (theApp.rewindTimer)) {
- theApp.rewindSaveNeeded = true;
- theApp.rewindCounter = 0;
+ if(++rewindCounter >= (rewindTimer)) {
+ rewindSaveNeeded = true;
+ rewindCounter = 0;
}
}
if(systemSaveUpdateCounter) {
@@ -1100,10 +1098,10 @@ void system10Frames(int rate)
}
}
- theApp.wasPaused = false;
+ wasPaused = false;
// Old autoframeskip crap... might be useful later. autoframeskip Ifdef above might be useless as well now
-// theApp.autoFrameSkipLastTime = time;
+// autoFrameSkipLastTime = time;
#ifdef LOG_PERFORMANCE
if( systemSpeedCounter >= PERFORMANCE_INTERVAL ) {
@@ -1121,7 +1119,7 @@ void system10Frames(int rate)
void systemScreenMessage(const char *msg)
{
- theApp.screenMessage = true;
+ screenMessage = true;
theApp.screenMessageTime = GetTickCount();
theApp.screenMessageBuffer = msg;
@@ -1132,7 +1130,7 @@ void systemScreenMessage(const char *msg)
void systemUpdateSolarSensor()
{
u8 sun = 0x0; //sun = 0xE8 - 0xE8 (case 0 and default)
- int level = theApp.sunBars / 10;
+ int level = sunBars / 10;
switch (level)
{
case 1:
@@ -1198,12 +1196,12 @@ void systemUpdateMotionSensor()
int systemGetSensorX()
{
- return theApp.sensorX;
+ return sensorX;
}
int systemGetSensorY()
{
- return theApp.sensorY;
+ return sensorY;
}
@@ -1230,8 +1228,8 @@ SoundDriver * systemSoundInit()
}
if( drv ) {
- if (theApp.throttle)
- drv->setThrottle( theApp.throttle );
+ if (throttle)
+ drv->setThrottle( throttle );
}
return drv;
@@ -1244,19 +1242,19 @@ void systemOnSoundShutdown()
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
}
- theApp.aviRecording = false;
+ aviRecording = false;
if( theApp.soundRecorder ) {
delete theApp.soundRecorder;
theApp.soundRecorder = NULL;
}
- theApp.soundRecording = false;
+ soundRecording = false;
}
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
{
- if( theApp.soundRecording ) {
+ if( soundRecording ) {
if( theApp.soundRecorder ) {
theApp.soundRecorder->AddSound( (const u8 *)finalWave, length );
} else {
@@ -1275,7 +1273,7 @@ void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
}
}
- if( theApp.aviRecording && theApp.aviRecorder ) {
+ if( aviRecording && theApp.aviRecorder ) {
if( theApp.skipAudioFrames ) {
theApp.skipAudioFrames--;
} else {
@@ -1283,7 +1281,7 @@ void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
systemMessage( IDS_AVI_CANNOT_WRITE_AUDIO, "Cannot write audio frame to AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
- theApp.aviRecording = false;
+ aviRecording = false;
}
}
}
@@ -1296,9 +1294,9 @@ bool systemCanChangeSoundQuality()
bool systemPauseOnFrame()
{
- if(theApp.winPauseNextFrame) {
- theApp.paused = true;
- theApp.winPauseNextFrame = false;
+ if(winPauseNextFrame) {
+ paused = true;
+ winPauseNextFrame = false;
return true;
}
return false;
@@ -1307,7 +1305,7 @@ bool systemPauseOnFrame()
void systemGbBorderOn()
{
if(emulating && theApp.cartridgeType == IMAGE_GB && gbBorderOn) {
- theApp.updateWindowSize(theApp.videoOption);
+ theApp.updateWindowSize(videoOption);
}
}
@@ -1485,7 +1483,7 @@ void VBA::loadSettings()
useBiosFileGB = ( regQueryDwordValue("useBiosGB", 0) == 1 ) ? true : false;
- skipBiosFile = regQueryDwordValue("skipBios", 0) ? true : false;
+ skipBios = regQueryDwordValue("skipBios", 0) ? true : false;
buffer = regQueryStringValue("biosFileGBA", "");
@@ -1546,7 +1544,7 @@ void VBA::loadSettings()
disableMMX = regQueryDwordValue("disableMMX", false) ? true: false;
- disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false;
+ disableStatusMessages = regQueryDwordValue("disableStatus", 0) ? true : false;
showSpeed = regQueryDwordValue("showSpeed", 0);
if(showSpeed < 0 || showSpeed > 2)
@@ -1576,23 +1574,22 @@ void VBA::loadSettings()
cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false;
- winSaveType = regQueryDwordValue("saveType", 0);
- if(winSaveType < 0 || winSaveType > 5)
- winSaveType = 0;
+ saveType = regQueryDwordValue("saveType", 0);
+ if(saveType < 0 || saveType > 5)
+ saveType = 0;
- ifbType = regQueryDwordValue("ifbType", 0);
+ ifbType = (IFBFilter)regQueryDwordValue("ifbType", 0);
if(ifbType < 0 || ifbType > 2)
- ifbType = 0;
+ ifbType = kIFBNone;
winFlashSize = regQueryDwordValue("flashSize", 0x10000);
if(winFlashSize != 0x10000 && winFlashSize != 0x20000)
winFlashSize = 0x10000;
- flashSize = winFlashSize;
agbPrintEnable(regQueryDwordValue("agbPrint", 0) ? true : false);
- winRtcEnable = regQueryDwordValue("rtcEnabled", 0) ? true : false;
- rtcEnable(winRtcEnable);
+ rtcEnabled = regQueryDwordValue("rtcEnabled", 0) ? true : false;
+ rtcEnable(rtcEnabled);
switch(videoOption) {
case VIDEO_320x240:
@@ -1973,8 +1970,8 @@ void VBA::updateWindowSize(int value)
winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
m_pMainWnd->SetWindowPos(
0, //HWND_TOPMOST,
- theApp.windowPositionX,
- theApp.windowPositionY,
+ windowPositionX,
+ windowPositionY,
winSizeX,
winSizeY,
SWP_NOMOVE | SWP_SHOWWINDOW);
@@ -2523,7 +2520,7 @@ void VBA::saveSettings()
regSetDwordValue("useBiosGB", useBiosFileGB);
- regSetDwordValue("skipBios", skipBiosFile);
+ regSetDwordValue("skipBios", skipBios);
if(!biosFileNameGBA.IsEmpty())
regSetStringValue("biosFileGBA", biosFileNameGBA);
@@ -2565,7 +2562,7 @@ void VBA::saveSettings()
regSetDwordValue("disableMMX", disableMMX);
- regSetDwordValue("disableStatus", disableStatusMessage);
+ regSetDwordValue("disableStatus", disableStatusMessages);
regSetDwordValue("showSpeed", showSpeed);
@@ -2581,7 +2578,7 @@ void VBA::saveSettings()
regSetDwordValue("disableSfx", cpuDisableSfx);
- regSetDwordValue("saveType", winSaveType);
+ regSetDwordValue("saveType", saveType);
regSetDwordValue("ifbType", ifbType);
@@ -2589,7 +2586,7 @@ void VBA::saveSettings()
regSetDwordValue("agbPrint", agbPrintIsEnabled());
- regSetDwordValue("rtcEnabled", winRtcEnable);
+ regSetDwordValue("rtcEnabled", rtcEnabled);
regSetDwordValue("borderOn", winGbBorderOn);
regSetDwordValue("borderAutomatic", gbBorderAutomatic);
@@ -2699,7 +2696,7 @@ void Sm60FPS_Init()
bool Sm60FPS_CanSkipFrame()
{
- if( theApp.autoFrameSkip ) {
+ if( autoFrameSkip ) {
if( Sm60FPS::nFrameCnt == 0 ) {
Sm60FPS::nFrameCnt = 0;
Sm60FPS::dwTimeElapse = 0;
@@ -2746,7 +2743,7 @@ bool Sm60FPS_CanSkipFrame()
void Sm60FPS_Sleep()
{
- if( theApp.autoFrameSkip ) {
+ if( autoFrameSkip ) {
u32 dwTimePass = Sm60FPS::dwTimeElapse + (GetTickCount() - Sm60FPS::dwTime0);
u32 dwTimeShould = (u32)(Sm60FPS::nFrameCnt * Sm60FPS::K_fDT);
if (dwTimeShould > dwTimePass && !gba_joybus_active) {
diff --git a/src/win32/VBA.h b/src/win32/VBA.h
index a51bfe7d..7e2afb15 100644
--- a/src/win32/VBA.h
+++ b/src/win32/VBA.h
@@ -11,6 +11,7 @@
#include "Input.h"
#include "IUpdate.h"
#include "../System.h"
+#include "common/ConfigManager.h"
#include "../Util.h"
/////////////////////////////////////////////////////////////////////////////
@@ -63,75 +64,40 @@ class VBA : public CWinApp
CMenu m_menu;
HMENU menu;
HMENU popup;
- unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect
- int windowPositionX;
- int windowPositionY;
- void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int);
- void (*ifbFunction)(u8*,u32,int,int);
- int ifbType;
- int filterType;
+
+ AVIWrite *aviRecorder;
+
+ char *rewindMemory;
char pluginName[MAX_PATH];
- int filterWidth;
- int filterHeight;
- int filterMagnification;
- bool filterMT; // enable multi-threading for pixel filters
- int fsWidth;
- int fsHeight;
- int fsColorDepth;
- int fsFrequency;
- int fsAdapter;
- bool fsForceChange;
- int sizeX;
- int sizeY;
- int surfaceSizeX;
- int surfaceSizeY;
- int videoOption;
- bool fullScreenStretch;
- bool disableStatusMessage;
- int showSpeed;
- BOOL showSpeedTransparent;
- int showRenderedFrames;
- bool screenMessage;
- CString screenMessageBuffer;
- DWORD screenMessageTime;
- u8 *delta[257*244*4];
- IDisplay *display;
- IMAGE_TYPE cartridgeType;
- bool soundInitialized;
- bool useBiosFileGBA;
- bool useBiosFileGBC;
- bool useBiosFileGB;
- bool skipBiosFile;
+ CString aviRecordName;
+ CString biosFileNameGB;
CString biosFileNameGBA;
CString biosFileNameGBC;
- CString biosFileNameGB;
- bool active;
- bool paused;
+ CString languageName;
+ CString linkHostAddr;
CString recentFiles[10];
- bool recentFreeze;
- bool autoSaveLoadCheatList;
- FILE *winout;
- bool autoPatch;
- int winGbBorderOn;
- int winFlashSize;
- bool winRtcEnable;
- int winSaveType;
- char *rewindMemory;
- int rewindPos;
- int rewindTopPos;
- int rewindCounter;
- int rewindCount;
- bool rewindSaveNeeded;
- int rewindTimer;
- bool gdbBreakOnLoad;
- int captureFormat;
- bool tripleBuffering;
- unsigned short throttle;
- u32 autoFrameSkipLastTime;
- bool autoFrameSkip;
- bool vsync;
- bool changingVideoSize;
+ CString screenMessageBuffer;
+ CString soundRecordName;
DISPLAY_TYPE renderMethod;
+ DWORD screenMessageTime;
+ FILE *movieFile;
+ FILE *winout;
+ HMODULE languageModule;
+ IDisplay *display;
+ IMAGE_TYPE cartridgeType;
+
+ bool soundInitialized;
+
+ Input *input;
+
+ u8 *delta[257 * 244 * 4];
+ unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect
+ unsigned int skipAudioFrames;
+ void(*filterFunction)(u8*, u32, u8*, u8*, u32, int, int);
+ void(*ifbFunction)(u8*, u32, int, int);
+ WavWriter *soundRecorder;
+
+ bool changingVideoSize;
AUDIO_API audioAPI;
#ifndef NO_OAL
TCHAR *oalDevice;
@@ -147,46 +113,7 @@ class VBA : public CWinApp
bool d3dMotionBlur;
#endif
bool iconic;
- int glFilter;
- bool dinputKeyFocus;
- bool pauseWhenInactive;
- bool speedupToggle;
- bool winGbPrinterEnabled;
- int threadPriority;
- bool disableMMX;
- int languageOption;
- CString languageName;
- HMODULE languageModule;
- int renderedFrames;
- Input *input;
- int joypadDefault;
- int autoFire;
- bool autoFireToggle;
- bool winPauseNextFrame;
- bool soundRecording;
- WavWriter *soundRecorder;
- CString soundRecordName;
- bool dsoundDisableHardwareAcceleration;
- bool aviRecording;
- AVIWrite *aviRecorder;
- CString aviRecordName;
bool painting;
- unsigned int skipAudioFrames;
- bool movieRecording;
- bool moviePlaying;
- int movieFrame;
- int moviePlayFrame;
- FILE *movieFile;
- u32 movieLastJoypad;
- u32 movieNextJoypad;
- int sensorX;
- int sensorY;
- int sunBars;
- int mouseCounter;
- bool wasPaused;
- int frameskipadjust;
- bool autoLoadMostRecent;
- int maxScale;
int romSize;
VIDEO_SIZE lastWindowed;
VIDEO_SIZE lastFullscreen;
@@ -211,15 +138,6 @@ class VBA : public CWinApp
CString wndClass;
- int linkTimeout;
- int linkMode;
- CString linkHostAddr;
- BOOL linkAuto;
- BOOL linkHacks;
- int linkNumPlayers;
-
- int gdbPort;
-
public:
VBA();
~VBA();
diff --git a/src/win32/XAudio2.cpp b/src/win32/XAudio2.cpp
index cd9dea3d..132608c6 100644
--- a/src/win32/XAudio2.cpp
+++ b/src/win32/XAudio2.cpp
@@ -451,7 +451,7 @@ void XAudio2_Output::write(u16 * finalWave, int length)
break;
} else {
// the maximum number of buffers is currently queued
- if( synchronize && !speedup && !theApp.throttle && !gba_joybus_active ) {
+ if( synchronize && !speedup && !throttle && !gba_joybus_active ) {
// wait for one buffer to finish playing
if (WaitForSingleObject( notify.hBufferEndEvent, 10000 ) == WAIT_TIMEOUT) {
device_changed = true;
diff --git a/src/wx/cmdevents.cpp b/src/wx/cmdevents.cpp
index 33d52bb7..62a0d673 100644
--- a/src/wx/cmdevents.cpp
+++ b/src/wx/cmdevents.cpp
@@ -16,6 +16,7 @@ extern "C" {
#include
}
#endif
+#include "../common/ConfigManager.h"
#include "../gb/gbPrinter.h"
#include "../gba/agbprint.h"
diff --git a/src/wx/guiinit.cpp b/src/wx/guiinit.cpp
index 9548ebe3..ccb55ee1 100644
--- a/src/wx/guiinit.cpp
+++ b/src/wx/guiinit.cpp
@@ -19,6 +19,8 @@
#include
#include "wx/checkedlistctrl.h"
#include
+
+#include "../common/ConfigManager.h"
#include "../gba/CheatSearch.h"
// The program icon, in case it's missing from .xrc (MSW gets it from .rc file)
@@ -2208,7 +2210,7 @@ bool MainFrame::InitMore(void)
for(int i = 0; i < checkable_mi.size(); i++) { \
if(checkable_mi[i].cmd != id) \
continue; \
- checkable_mi[i].boolopt = &f; \
+ checkable_mi[i].boolopt = (bool*)&f; \
checkable_mi[i].mi->Check(f); \
break; \
} \
diff --git a/src/wx/openal.cpp b/src/wx/openal.cpp
index 092c7032..ba90225d 100644
--- a/src/wx/openal.cpp
+++ b/src/wx/openal.cpp
@@ -8,6 +8,7 @@
#include "wxvbam.h"
// Interface
+#include "../common/ConfigManager.h"
#include "../common/SoundDriver.h"
// OpenAL
diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp
index 4fc66f35..f6de56d4 100644
--- a/src/wx/panel.cpp
+++ b/src/wx/panel.cpp
@@ -1,5 +1,6 @@
#include "wxvbam.h"
#include "drawing.h"
+#include "../common/ConfigManager.h"
#include "../gba/RTC.h"
#include "../gba/agbprint.h"
#include "../gb/gbPrinter.h"
diff --git a/src/wx/sys.cpp b/src/wx/sys.cpp
index ab815894..5ea1b1f3 100644
--- a/src/wx/sys.cpp
+++ b/src/wx/sys.cpp
@@ -1,5 +1,6 @@
#include
#include "wxvbam.h"
+#include "../common/ConfigManager.h"
#include "../common/SoundSDL.h"
#include
#include
@@ -99,7 +100,6 @@ wxFFile game_file;
bool game_recording, game_playback;
u32 game_frame;
u32 game_joypad;
-int sunBars = 500;
void systemStartGameRecording(const wxString &fname)
{
diff --git a/src/wx/widgets/sdljoy.cpp b/src/wx/widgets/sdljoy.cpp
index 09cd47a0..f792e47f 100644
--- a/src/wx/widgets/sdljoy.cpp
+++ b/src/wx/widgets/sdljoy.cpp
@@ -1,6 +1,6 @@
#include "wx/sdljoy.h"
-#include
-#include
+#include
+#include
#include
DEFINE_EVENT_TYPE(wxEVT_SDLJOY)
diff --git a/src/wx/wxvbam.cpp b/src/wx/wxvbam.cpp
index ae207de4..aa91d413 100644
--- a/src/wx/wxvbam.cpp
+++ b/src/wx/wxvbam.cpp
@@ -21,6 +21,8 @@
// The built-in vba-over.ini
#include "builtin-over.h"
+int systemDebug = 0;
+
IMPLEMENT_APP(wxvbamApp)
IMPLEMENT_DYNAMIC_CLASS(MainFrame, wxFrame)