Created a common configuration system.
git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1347 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
3bc0150d2c
commit
18e9b71e41
|
@ -185,6 +185,9 @@ add_subdirectory (fex)
|
||||||
|
|
||||||
SET(SRC_MAIN
|
SET(SRC_MAIN
|
||||||
src/Util.cpp
|
src/Util.cpp
|
||||||
|
src/common/ConfigManager.cpp
|
||||||
|
src/common/dictionary.c
|
||||||
|
src/common/iniparser.c
|
||||||
src/common/Patch.cpp
|
src/common/Patch.cpp
|
||||||
src/common/memgzio.c
|
src/common/memgzio.c
|
||||||
src/common/SoundSDL.cpp
|
src/common/SoundSDL.cpp
|
||||||
|
|
|
@ -242,6 +242,7 @@
|
||||||
<ResourceCompile Include="..\..\src\win32\VBA.rc" />
|
<ResourceCompile Include="..\..\src\win32\VBA.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c" />
|
||||||
<ClCompile Include="..\..\src\filters\2xSaI.cpp">
|
<ClCompile Include="..\..\src\filters\2xSaI.cpp">
|
||||||
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</WholeProgramOptimization>
|
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</WholeProgramOptimization>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -535,6 +535,9 @@
|
||||||
<ClCompile Include="..\..\src\win32\LinkOptions.cpp">
|
<ClCompile Include="..\..\src\win32\LinkOptions.cpp">
|
||||||
<Filter>MFC</Filter>
|
<Filter>MFC</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c">
|
||||||
|
<Filter>Main</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<NASM Include="..\..\src\filters\2xSaImmx.asm">
|
<NASM Include="..\..\src\filters\2xSaImmx.asm">
|
||||||
|
|
|
@ -150,6 +150,9 @@
|
||||||
</BuildLog>
|
</BuildLog>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\src\common\ConfigManager.h" />
|
||||||
|
<ClInclude Include="..\..\src\common\dictionary.h" />
|
||||||
|
<ClInclude Include="..\..\src\common\iniparser.h" />
|
||||||
<ClInclude Include="..\..\src\gb\gb.h" />
|
<ClInclude Include="..\..\src\gb\gb.h" />
|
||||||
<ClInclude Include="..\..\src\gb\gbCheats.h" />
|
<ClInclude Include="..\..\src\gb\gbCheats.h" />
|
||||||
<ClInclude Include="..\..\src\gb\gbCodes.h" />
|
<ClInclude Include="..\..\src\gb\gbCodes.h" />
|
||||||
|
@ -201,6 +204,9 @@
|
||||||
<None Include="..\..\doc\ReadMe.MFC.txt" />
|
<None Include="..\..\doc\ReadMe.MFC.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\src\common\ConfigManager.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\common\dictionary.c" />
|
||||||
|
<ClCompile Include="..\..\src\common\iniparser.c" />
|
||||||
<ClCompile Include="..\..\src\gb\gb.cpp" />
|
<ClCompile Include="..\..\src\gb\gb.cpp" />
|
||||||
<ClCompile Include="..\..\src\gb\gbCheats.cpp" />
|
<ClCompile Include="..\..\src\gb\gbCheats.cpp" />
|
||||||
<ClCompile Include="..\..\src\gb\gbDis.cpp" />
|
<ClCompile Include="..\..\src\gb\gbDis.cpp" />
|
||||||
|
|
|
@ -156,6 +156,15 @@
|
||||||
<ClInclude Include="..\..\src\gba\GBASockClient.h">
|
<ClInclude Include="..\..\src\gba\GBASockClient.h">
|
||||||
<Filter>Linking</Filter>
|
<Filter>Linking</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\common\dictionary.h">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\common\iniparser.h">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\common\ConfigManager.h">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\doc\DevInfo.txt">
|
<None Include="..\..\doc\DevInfo.txt">
|
||||||
|
@ -313,5 +322,14 @@
|
||||||
<ClCompile Include="..\..\src\gba\GBASockClient.cpp">
|
<ClCompile Include="..\..\src\gba\GBASockClient.cpp">
|
||||||
<Filter>Linking</Filter>
|
<Filter>Linking</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\common\dictionary.c">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\common\iniparser.c">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\common\ConfigManager.cpp">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -249,6 +249,7 @@
|
||||||
<ResourceCompile Include="..\..\src\win32\VBA.rc" />
|
<ResourceCompile Include="..\..\src\win32\VBA.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c" />
|
||||||
<ClCompile Include="..\..\src\filters\2xSaI.cpp">
|
<ClCompile Include="..\..\src\filters\2xSaI.cpp">
|
||||||
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</WholeProgramOptimization>
|
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</WholeProgramOptimization>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -535,6 +535,9 @@
|
||||||
<ClCompile Include="..\..\src\win32\LinkOptions.cpp">
|
<ClCompile Include="..\..\src\win32\LinkOptions.cpp">
|
||||||
<Filter>MFC</Filter>
|
<Filter>MFC</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c">
|
||||||
|
<Filter>Main</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<NASM Include="..\..\src\filters\2xSaImmx.asm">
|
<NASM Include="..\..\src\filters\2xSaImmx.asm">
|
||||||
|
|
|
@ -156,6 +156,9 @@
|
||||||
</BuildLog>
|
</BuildLog>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\src\common\ConfigManager.h" />
|
||||||
|
<ClInclude Include="..\..\src\common\dictionary.h" />
|
||||||
|
<ClInclude Include="..\..\src\common\iniparser.h" />
|
||||||
<ClInclude Include="..\..\src\gb\gb.h" />
|
<ClInclude Include="..\..\src\gb\gb.h" />
|
||||||
<ClInclude Include="..\..\src\gb\gbCheats.h" />
|
<ClInclude Include="..\..\src\gb\gbCheats.h" />
|
||||||
<ClInclude Include="..\..\src\gb\gbCodes.h" />
|
<ClInclude Include="..\..\src\gb\gbCodes.h" />
|
||||||
|
@ -207,6 +210,9 @@
|
||||||
<None Include="..\..\doc\ReadMe.MFC.txt" />
|
<None Include="..\..\doc\ReadMe.MFC.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\src\common\ConfigManager.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\common\dictionary.c" />
|
||||||
|
<ClCompile Include="..\..\src\common\iniparser.c" />
|
||||||
<ClCompile Include="..\..\src\gb\gb.cpp" />
|
<ClCompile Include="..\..\src\gb\gb.cpp" />
|
||||||
<ClCompile Include="..\..\src\gb\gbCheats.cpp" />
|
<ClCompile Include="..\..\src\gb\gbCheats.cpp" />
|
||||||
<ClCompile Include="..\..\src\gb\gbDis.cpp" />
|
<ClCompile Include="..\..\src\gb\gbDis.cpp" />
|
||||||
|
|
|
@ -156,6 +156,15 @@
|
||||||
<ClInclude Include="..\..\src\gba\GBASockClient.h">
|
<ClInclude Include="..\..\src\gba\GBASockClient.h">
|
||||||
<Filter>Linking</Filter>
|
<Filter>Linking</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\common\ConfigManager.h">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\common\dictionary.h">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\common\iniparser.h">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\doc\DevInfo.txt">
|
<None Include="..\..\doc\DevInfo.txt">
|
||||||
|
@ -313,5 +322,14 @@
|
||||||
<ClCompile Include="..\..\src\gba\GBASockClient.cpp">
|
<ClCompile Include="..\..\src\gba\GBASockClient.cpp">
|
||||||
<Filter>Linking</Filter>
|
<Filter>Linking</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\common\ConfigManager.cpp">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\common\iniparser.c">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\common\dictionary.c">
|
||||||
|
<Filter>Functionality</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,175 @@
|
||||||
|
#ifndef _CONFIGMANAGER_H
|
||||||
|
#define _CONFIGMANAGER_H
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <stdio.h>
|
||||||
|
#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 <getopt.h>
|
||||||
|
#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
|
|
@ -16,9 +16,10 @@
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "SoundSDL.h"
|
#include "SoundSDL.h"
|
||||||
|
#include "ConfigManager.h"
|
||||||
|
#include "../gba/Globals.h"
|
||||||
|
|
||||||
extern int emulating;
|
extern int emulating;
|
||||||
extern bool speedup;
|
|
||||||
|
|
||||||
// Hold up to 100 ms of data in the ring buffer
|
// Hold up to 100 ms of data in the ring buffer
|
||||||
const float SoundSDL::_delay = 0.1f;
|
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
|
/* since this is running in a different thread, speedup and
|
||||||
* throttle can change at any time; save the value so locks
|
* throttle can change at any time; save the value so locks
|
||||||
* stay in sync */
|
* stay in sync */
|
||||||
bool lock = (emulating && !speedup) ? true : false;
|
bool lock = (emulating && !speedup && synchronize && !gba_joybus_active) ? true : false;
|
||||||
|
|
||||||
if (lock)
|
if (lock)
|
||||||
SDL_SemWait (_semBufferFull);
|
SDL_SemWait (_semBufferFull);
|
||||||
|
@ -73,7 +74,7 @@ void SoundSDL::write(u16 * finalWave, int length)
|
||||||
std::size_t avail;
|
std::size_t avail;
|
||||||
while ((avail = _rbuf.avail() / 2) < samples)
|
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);
|
_rbuf.write(finalWave, avail * 2);
|
||||||
|
|
||||||
|
|
|
@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
|
||||||
|
/** 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<len ; i++) {
|
||||||
|
hash += (unsigned)key[i] ;
|
||||||
|
hash += (hash<<10);
|
||||||
|
hash ^= (hash>>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 (size<DICTMINSZ) size=DICTMINSZ ;
|
||||||
|
|
||||||
|
if (!(d = (dictionary *)calloc(1, sizeof(dictionary)))) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
d->size = 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 ; i<d->size ; 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 ; i<d->size ; 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 ; i<d->size ; 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 ; i<d->size ; 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 ; i<d->size ; 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 ; i<NVALS ; i++) {
|
||||||
|
sprintf(cval, "%04d", i);
|
||||||
|
dictionary_set(d, cval, "salut");
|
||||||
|
}
|
||||||
|
printf("getting %d values...\n", NVALS);
|
||||||
|
for (i=0 ; i<NVALS ; i++) {
|
||||||
|
sprintf(cval, "%04d", i);
|
||||||
|
val = dictionary_get(d, cval, DICT_INVALID_KEY);
|
||||||
|
if (val==DICT_INVALID_KEY) {
|
||||||
|
printf("cannot get value for key [%s]\n", cval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("unsetting %d values...\n", NVALS);
|
||||||
|
for (i=0 ; i<NVALS ; i++) {
|
||||||
|
sprintf(cval, "%04d", i);
|
||||||
|
dictionary_unset(d, cval);
|
||||||
|
}
|
||||||
|
if (d->n != 0) {
|
||||||
|
printf("error deleting values\n");
|
||||||
|
}
|
||||||
|
printf("deallocating...\n");
|
||||||
|
dictionary_del(d);
|
||||||
|
return 0 ;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* vim: set ts=4 et sw=4 tw=75 */
|
|
@ -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 <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
//#include <unistd.h>
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
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
|
|
@ -0,0 +1,748 @@
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
@file iniparser.c
|
||||||
|
@author N. Devillard
|
||||||
|
@brief Parser for ini files.
|
||||||
|
*/
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
/*---------------------------- Includes ------------------------------------*/
|
||||||
|
#include <ctype.h>
|
||||||
|
#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<ASCIILINESZ) {
|
||||||
|
//l[i] = (char)tolower((int)s[i]);
|
||||||
|
l[i] = (char)((int)s[i]);
|
||||||
|
i++ ;
|
||||||
|
}
|
||||||
|
l[ASCIILINESZ]=(char)0;
|
||||||
|
return l ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
@brief Remove blanks at the beginning and the end of a string.
|
||||||
|
@param s String to parse.
|
||||||
|
@return ptr to statically allocated string.
|
||||||
|
|
||||||
|
This function returns a pointer to a statically allocated string,
|
||||||
|
which is identical to the input string, except that all blank
|
||||||
|
characters at the end and the beg. of the string have been removed.
|
||||||
|
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 * strstrip(const char * s)
|
||||||
|
{
|
||||||
|
static char l[ASCIILINESZ+1];
|
||||||
|
char * last ;
|
||||||
|
|
||||||
|
if (s==NULL) return NULL ;
|
||||||
|
|
||||||
|
while (isspace((int)*s) && *s) s++;
|
||||||
|
memset(l, 0, ASCIILINESZ+1);
|
||||||
|
strcpy(l, s);
|
||||||
|
last = l + strlen(l);
|
||||||
|
while (last > 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 ; i<d->size ; 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 ; i<d->size ; 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 ; i<d->size ; 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 ; i<d->size ; i++) {
|
||||||
|
if (d->key[i]==NULL)
|
||||||
|
continue ;
|
||||||
|
fprintf(f, "%s=%s\n", d->key[i], d->val[i]);
|
||||||
|
}
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
for (i=0 ; i<nsec ; i++) {
|
||||||
|
secname = iniparser_getsecname(d, i) ;
|
||||||
|
iniparser_dumpsection_ini(d, secname, 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)
|
||||||
|
{
|
||||||
|
int j ;
|
||||||
|
char keym[ASCIILINESZ+1];
|
||||||
|
int seclen ;
|
||||||
|
|
||||||
|
if (d==NULL || f==NULL) return ;
|
||||||
|
if (! iniparser_find_entry(d, s)) return ;
|
||||||
|
|
||||||
|
seclen = (int)strlen(s);
|
||||||
|
//fprintf(f, "\n[%s]\n", s);
|
||||||
|
fprintf(f, "[%s]\n", s);
|
||||||
|
sprintf(keym, "%s:", s);
|
||||||
|
for (j=0 ; j<d->size ; 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 ; j<d->size ; 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 ; j<d->size ; 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 */
|
|
@ -0,0 +1,307 @@
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
@file iniparser.h
|
||||||
|
@author N. Devillard
|
||||||
|
@brief Parser for ini files.
|
||||||
|
*/
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef _INIPARSER_H_
|
||||||
|
#define _INIPARSER_H_
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------
|
||||||
|
Includes
|
||||||
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following #include is necessary on many Unixes but not Linux.
|
||||||
|
* It is not needed for Windows platforms.
|
||||||
|
* Uncomment it if needed.
|
||||||
|
*/
|
||||||
|
/* #include <unistd.h> */
|
||||||
|
|
||||||
|
#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
|
|
@ -15,13 +15,13 @@
|
||||||
#include "gbSound.h"
|
#include "gbSound.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../gba/GBALink.h"
|
#include "../gba/GBALink.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define _stricmp strcasecmp
|
#define _stricmp strcasecmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern u8 *pix;
|
extern u8 *pix;
|
||||||
extern bool speedup;
|
|
||||||
bool gbUpdateSizes();
|
bool gbUpdateSizes();
|
||||||
bool inBios = false;
|
bool inBios = false;
|
||||||
|
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
#include "gbCheats.h"
|
#include "gbCheats.h"
|
||||||
#include "gbGlobals.h"
|
#include "gbGlobals.h"
|
||||||
#include "gb.h"
|
#include "gb.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
|
||||||
gbCheat gbCheatList[100];
|
gbCheat gbCheatList[100];
|
||||||
int gbCheatNumber = 0;
|
int gbCheatNumber = 0;
|
||||||
int gbNextCheat = 0;
|
int gbNextCheat = 0;
|
||||||
bool gbCheatMap[0x10000];
|
bool gbCheatMap[0x10000];
|
||||||
|
|
||||||
extern bool cheatsEnabled;
|
|
||||||
|
|
||||||
#define GBCHEAT_IS_HEX(a) ( ((a)>='A' && (a) <='F') || ((a) >='0' && (a) <= '9'))
|
#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')
|
#define GBCHEAT_HEX_VALUE(a) ( (a) >= 'A' ? (a) - 'A' + 10 : (a) - '0')
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,7 @@ extern int gbRamSize;
|
||||||
extern int gbRamSizeMask;
|
extern int gbRamSizeMask;
|
||||||
extern int gbTAMA5ramSize;
|
extern int gbTAMA5ramSize;
|
||||||
|
|
||||||
extern bool useBios;
|
|
||||||
extern bool skipBios;
|
|
||||||
extern u8 *bios;
|
extern u8 *bios;
|
||||||
extern bool skipSaveGameBattery;
|
|
||||||
extern bool skipSaveGameCheats;
|
|
||||||
|
|
||||||
extern u8 *gbRom;
|
extern u8 *gbRom;
|
||||||
extern u8 *gbRam;
|
extern u8 *gbRam;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "agbprint.h"
|
#include "agbprint.h"
|
||||||
#include "remote.h"
|
#include "remote.h"
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "agbprint.h"
|
#include "agbprint.h"
|
||||||
#include "remote.h"
|
#include "remote.h"
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
#include "../common/Port.h"
|
#include "../common/Port.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
#include "agbprint.h"
|
#include "agbprint.h"
|
||||||
#include "ereader.h"
|
#include "ereader.h"
|
||||||
|
|
|
@ -17,23 +17,6 @@ bool armIrqEnable = true;
|
||||||
u32 armNextPC = 0x00000000;
|
u32 armNextPC = 0x00000000;
|
||||||
int armMode = 0x1f;
|
int armMode = 0x1f;
|
||||||
u32 stop = 0x08000568;
|
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:
|
// this is an optional hack to change the backdrop/background color:
|
||||||
// -1: disabled
|
// -1: disabled
|
||||||
|
|
|
@ -28,24 +28,12 @@ extern u32 armNextPC;
|
||||||
extern int armMode;
|
extern int armMode;
|
||||||
extern u32 stop;
|
extern u32 stop;
|
||||||
extern int saveType;
|
extern int saveType;
|
||||||
extern bool useBios;
|
|
||||||
extern bool skipBios;
|
|
||||||
extern int frameSkip;
|
extern int frameSkip;
|
||||||
extern bool speedup;
|
|
||||||
extern bool synchronize;
|
|
||||||
extern bool gba_joybus_enabled;
|
extern bool gba_joybus_enabled;
|
||||||
extern bool gba_joybus_active;
|
extern bool gba_joybus_active;
|
||||||
extern bool cpuDisableSfx;
|
|
||||||
extern bool cpuIsMultiBoot;
|
|
||||||
extern bool parseDebug;
|
|
||||||
extern int layerSettings;
|
extern int layerSettings;
|
||||||
extern int layerEnable;
|
extern int layerEnable;
|
||||||
extern bool speedHack;
|
|
||||||
extern int cpuSaveType;
|
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 int customBackdropColor;
|
||||||
|
|
||||||
extern u8 *bios;
|
extern u8 *bios;
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "intl.h"
|
#include "intl.h"
|
||||||
|
|
||||||
|
int systemDebug = 0;
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
bool bShowVersion = false;
|
bool bShowVersion = false;
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../gba/GBA.h"
|
#include "../gba/GBA.h"
|
||||||
#include "../gba/RTC.h"
|
#include "../gba/RTC.h"
|
||||||
#include "../gba/Sound.h"
|
#include "../gba/Sound.h"
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../gba/GBA.h"
|
#include "../gba/GBA.h"
|
||||||
#include "../gba/Sound.h"
|
#include "../gba/Sound.h"
|
||||||
#include "../gb/gb.h"
|
#include "../gb/gb.h"
|
||||||
|
|
888
src/sdl/SDL.cpp
888
src/sdl/SDL.cpp
File diff suppressed because it is too large
Load Diff
|
@ -180,7 +180,7 @@ const IFBFilterDesc IFBFilters[] = {
|
||||||
{ "Smart interframe blending", SmartIB, SmartIB32 }
|
{ "Smart interframe blending", SmartIB, SmartIB32 }
|
||||||
};
|
};
|
||||||
|
|
||||||
IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth)
|
IFBFilterFunc initIFBFilter(const int f, const int colorDepth)
|
||||||
{
|
{
|
||||||
IFBFilterFunc func;
|
IFBFilterFunc func;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter };
|
||||||
typedef void(*IFBFilterFunc)(u8*, u32, int, int);
|
typedef void(*IFBFilterFunc)(u8*, u32, int, int);
|
||||||
|
|
||||||
// Initialize an IFB filter and get the corresponding filter function pointer
|
// Initialize an IFB filter and get the corresponding filter function pointer
|
||||||
IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth);
|
IFBFilterFunc initIFBFilter(const int f, const int colorDepth);
|
||||||
|
|
||||||
// Get the display name for an IFB filter
|
// Get the display name for an IFB filter
|
||||||
char* getIFBFilterName(const IFBFilter f);
|
char* getIFBFilterName(const IFBFilter f);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "inputSDL.h"
|
#include "inputSDL.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
|
||||||
#define SDLBUTTONS_NUM 14
|
#define SDLBUTTONS_NUM 14
|
||||||
|
|
||||||
|
@ -51,10 +52,7 @@ static SDL_Joystick **sdlDevices = NULL;
|
||||||
|
|
||||||
static EPad sdlDefaultJoypad = PAD_MAIN;
|
static EPad sdlDefaultJoypad = PAD_MAIN;
|
||||||
|
|
||||||
static int autoFire = 0;
|
|
||||||
static bool autoFireToggle = false;
|
|
||||||
static int autoFireCountdown = 0;
|
static int autoFireCountdown = 0;
|
||||||
int autoFireMaxCount = 1;
|
|
||||||
|
|
||||||
static uint32_t joypad[5][SDLBUTTONS_NUM] = {
|
static uint32_t joypad[5][SDLBUTTONS_NUM] = {
|
||||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
|
||||||
|
@ -79,8 +77,6 @@ static uint32_t defaultMotion[4] = {
|
||||||
SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2
|
SDLK_KP4, SDLK_KP6, SDLK_KP8, SDLK_KP2
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sensorX = 2047;
|
|
||||||
static int sensorY = 2047;
|
|
||||||
|
|
||||||
static uint32_t sdlGetHatCode(const SDL_Event &event)
|
static uint32_t sdlGetHatCode(const SDL_Event &event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,21 +166,21 @@ void Direct3DDisplay::prepareDisplayMode()
|
||||||
{
|
{
|
||||||
// Change display mode
|
// Change display mode
|
||||||
memset(&dpp, 0, sizeof(dpp));
|
memset(&dpp, 0, sizeof(dpp));
|
||||||
dpp.Windowed = !( theApp.videoOption >= VIDEO_320x240 );
|
dpp.Windowed = !( videoOption >= VIDEO_320x240 );
|
||||||
if( !dpp.Windowed ) {
|
if( !dpp.Windowed ) {
|
||||||
dpp.BackBufferFormat = (theApp.fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
|
dpp.BackBufferFormat = (fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
|
||||||
} else {
|
} else {
|
||||||
dpp.BackBufferFormat = mode.Format;
|
dpp.BackBufferFormat = mode.Format;
|
||||||
}
|
}
|
||||||
dpp.BackBufferCount = theApp.tripleBuffering ? 2 : 1;
|
dpp.BackBufferCount = tripleBuffering ? 2 : 1;
|
||||||
dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||||
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||||
dpp.BackBufferWidth = !dpp.Windowed ? theApp.fsWidth : theApp.surfaceSizeX;
|
dpp.BackBufferWidth = !dpp.Windowed ? fsWidth : surfaceSizeX;
|
||||||
dpp.BackBufferHeight = !dpp.Windowed ? theApp.fsHeight : theApp.surfaceSizeY;
|
dpp.BackBufferHeight = !dpp.Windowed ? fsHeight : surfaceSizeY;
|
||||||
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
|
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.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
|
// D3DPRESENT_INTERVAL_ONE means VSync ON
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ bool Direct3DDisplay::initialize()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
pD3D->GetAdapterDisplayMode(theApp.fsAdapter, &mode);
|
pD3D->GetAdapterDisplayMode(fsAdapter, &mode);
|
||||||
screenFormat = mode.Format;
|
screenFormat = mode.Format;
|
||||||
|
|
||||||
switch(mode.Format) {
|
switch(mode.Format) {
|
||||||
|
@ -273,12 +273,12 @@ bool Direct3DDisplay::initialize()
|
||||||
DXTRACE_ERR_MSGBOX( _T("Unsupport D3D format"), 0 );
|
DXTRACE_ERR_MSGBOX( _T("Unsupport D3D format"), 0 );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
theApp.fsColorDepth = systemColorDepth;
|
fsColorDepth = systemColorDepth;
|
||||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||||
|
|
||||||
|
|
||||||
#ifdef MMX
|
#ifdef MMX
|
||||||
if(!theApp.disableMMX) {
|
if(!disableMMX) {
|
||||||
cpu_mmx = theApp.detectMMX();
|
cpu_mmx = theApp.detectMMX();
|
||||||
} else {
|
} else {
|
||||||
cpu_mmx = 0;
|
cpu_mmx = 0;
|
||||||
|
@ -295,7 +295,7 @@ bool Direct3DDisplay::initialize()
|
||||||
prepareDisplayMode();
|
prepareDisplayMode();
|
||||||
|
|
||||||
HRESULT hret = pD3D->CreateDevice(
|
HRESULT hret = pD3D->CreateDevice(
|
||||||
theApp.fsAdapter,
|
fsAdapter,
|
||||||
D3DDEVTYPE_HAL,
|
D3DDEVTYPE_HAL,
|
||||||
theApp.m_pMainWnd->GetSafeHwnd(),
|
theApp.m_pMainWnd->GetSafeHwnd(),
|
||||||
D3DCREATE_FPU_PRESERVE |
|
D3DCREATE_FPU_PRESERVE |
|
||||||
|
@ -388,16 +388,16 @@ void Direct3DDisplay::render()
|
||||||
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
|
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
u32 pitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
|
u32 pitch = sizeX * ( systemColorDepth >> 3 ) + 4;
|
||||||
|
|
||||||
if( theApp.filterFunction ) {
|
if( theApp.filterFunction ) {
|
||||||
if( theApp.filterMT ) {
|
if( filterMT ) {
|
||||||
u8 *start = pix + pitch;
|
u8 *start = pix + pitch;
|
||||||
int src_height_per_thread = theApp.sizeY / nThreads;
|
int src_height_per_thread = sizeY / nThreads;
|
||||||
int src_height_remaining = theApp.sizeY - ( ( theApp.sizeY / nThreads ) * nThreads );
|
int src_height_remaining = sizeY - ( ( sizeY / nThreads ) * nThreads );
|
||||||
u32 src_bytes_per_thread = pitch * src_height_per_thread;
|
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;
|
u32 dst_bytes_per_thread = lr.Pitch * dst_height_per_thread;
|
||||||
|
|
||||||
unsigned int i = nThreads - 1;
|
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].deltaPointer = (u8*)theApp.delta; // TODO: check if thread-safe
|
||||||
pfthread_data[i].destPointer = ( (u8*)lr.pBits ) + ( i * dst_bytes_per_thread );
|
pfthread_data[i].destPointer = ( (u8*)lr.pBits ) + ( i * dst_bytes_per_thread );
|
||||||
pfthread_data[i].destPitch = lr.Pitch;
|
pfthread_data[i].destPitch = lr.Pitch;
|
||||||
pfthread_data[i].width = theApp.sizeX;
|
pfthread_data[i].width = sizeX;
|
||||||
|
|
||||||
if( i == ( nThreads - 1 ) ) {
|
if( i == ( nThreads - 1 ) ) {
|
||||||
// last thread
|
// last thread
|
||||||
|
@ -454,8 +454,8 @@ void Direct3DDisplay::render()
|
||||||
(u8*)theApp.delta,
|
(u8*)theApp.delta,
|
||||||
(u8*)lr.pBits,
|
(u8*)lr.pBits,
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
theApp.sizeX,
|
sizeX,
|
||||||
theApp.sizeY
|
sizeY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -468,8 +468,8 @@ void Direct3DDisplay::render()
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
pix + pitch,
|
pix + pitch,
|
||||||
pitch,
|
pitch,
|
||||||
theApp.sizeX,
|
sizeX,
|
||||||
theApp.sizeY
|
sizeY
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
@ -478,8 +478,8 @@ void Direct3DDisplay::render()
|
||||||
lr.Pitch,
|
lr.Pitch,
|
||||||
pix + pitch,
|
pix + pitch,
|
||||||
pitch,
|
pitch,
|
||||||
theApp.sizeX,
|
sizeX,
|
||||||
theApp.sizeY
|
sizeY
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -524,24 +524,24 @@ void Direct3DDisplay::render()
|
||||||
r.right = dpp.BackBufferWidth - 1;
|
r.right = dpp.BackBufferWidth - 1;
|
||||||
r.bottom = dpp.BackBufferHeight - 1;
|
r.bottom = dpp.BackBufferHeight - 1;
|
||||||
|
|
||||||
if( theApp.showSpeed && ( theApp.videoOption > VIDEO_6X ) ) {
|
if( showSpeed && ( videoOption > VIDEO_6X ) ) {
|
||||||
color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
|
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
if( theApp.showSpeed == 1 ) {
|
if( showSpeed == 1 ) {
|
||||||
sprintf( buffer, "%3d%%", systemSpeed );
|
sprintf( buffer, "%3d%%", systemSpeed );
|
||||||
} else {
|
} 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 );
|
pFont->DrawText( NULL, buffer, -1, &r, DT_CENTER | DT_TOP, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( theApp.screenMessage ) {
|
if( screenMessage ) {
|
||||||
color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
|
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
|
||||||
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.disableStatusMessage && pFont ) {
|
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages && pFont ) {
|
||||||
pFont->DrawText( NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color );
|
pFont->DrawText( NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color );
|
||||||
} else {
|
} else {
|
||||||
theApp.screenMessage = false;
|
screenMessage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ void Direct3DDisplay::resize( int w, int h )
|
||||||
|
|
||||||
if( (w != dpp.BackBufferWidth) ||
|
if( (w != dpp.BackBufferWidth) ||
|
||||||
(h != dpp.BackBufferHeight) ||
|
(h != dpp.BackBufferHeight) ||
|
||||||
(theApp.videoOption > VIDEO_6X) ) {
|
(videoOption > VIDEO_6X) ) {
|
||||||
resetDevice();
|
resetDevice();
|
||||||
calculateDestRect();
|
calculateDestRect();
|
||||||
}
|
}
|
||||||
|
@ -761,7 +761,7 @@ void Direct3DDisplay::destroyTexture()
|
||||||
|
|
||||||
void Direct3DDisplay::calculateDestRect()
|
void Direct3DDisplay::calculateDestRect()
|
||||||
{
|
{
|
||||||
if( theApp.fullScreenStretch ) {
|
if( fullScreenStretch ) {
|
||||||
rectangleFillsScreen = true; // no clear() necessary
|
rectangleFillsScreen = true; // no clear() necessary
|
||||||
destRect.left = 0;
|
destRect.left = 0;
|
||||||
destRect.top = 0;
|
destRect.top = 0;
|
||||||
|
@ -772,8 +772,8 @@ void Direct3DDisplay::calculateDestRect()
|
||||||
float scaleX = (float)dpp.BackBufferWidth / (float)width;
|
float scaleX = (float)dpp.BackBufferWidth / (float)width;
|
||||||
float scaleY = (float)dpp.BackBufferHeight / (float)height;
|
float scaleY = (float)dpp.BackBufferHeight / (float)height;
|
||||||
float min = (scaleX < scaleY) ? scaleX : scaleY;
|
float min = (scaleX < scaleY) ? scaleX : scaleY;
|
||||||
if( theApp.maxScale && (min > theApp.maxScale) ) {
|
if( maxScale && (min > maxScale) ) {
|
||||||
min = (float)theApp.maxScale;
|
min = (float)maxScale;
|
||||||
}
|
}
|
||||||
destRect.left = 0;
|
destRect.left = 0;
|
||||||
destRect.top = 0;
|
destRect.top = 0;
|
||||||
|
|
|
@ -621,7 +621,7 @@ bool DirectInput::readDevices()
|
||||||
u32 DirectInput::readDevice(int which)
|
u32 DirectInput::readDevice(int which)
|
||||||
{
|
{
|
||||||
u32 res = 0;
|
u32 res = 0;
|
||||||
int i = theApp.joypadDefault;
|
int i = joypadDefault;
|
||||||
if(which >= 0 && which <= 3)
|
if(which >= 0 && which <= 3)
|
||||||
i = which;
|
i = which;
|
||||||
|
|
||||||
|
@ -649,11 +649,11 @@ u32 DirectInput::readDevice(int which)
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]))
|
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]))
|
||||||
res |= 4096;
|
res |= 4096;
|
||||||
|
|
||||||
if(theApp.autoFire) {
|
if(autoFire) {
|
||||||
res &= (~theApp.autoFire);
|
res &= (~autoFire);
|
||||||
if(theApp.autoFireToggle)
|
if(autoFireToggle)
|
||||||
res |= theApp.autoFire;
|
res |= autoFire;
|
||||||
theApp.autoFireToggle = !theApp.autoFireToggle;
|
autoFireToggle = !autoFireToggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// disallow L+R or U+D of being pressed at the same time
|
// 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)
|
if((res & 192) == 192)
|
||||||
res &= ~128;
|
res &= ~128;
|
||||||
|
|
||||||
if(theApp.movieRecording) {
|
if(movieRecording) {
|
||||||
if(i == theApp.joypadDefault) {
|
if(i == joypadDefault) {
|
||||||
if(res != theApp.movieLastJoypad) {
|
if(res != movieLastJoypad) {
|
||||||
fwrite(&theApp.movieFrame, 1, sizeof(theApp.movieFrame), theApp.movieFile);
|
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
|
||||||
fwrite(&res, 1, sizeof(res), theApp.movieFile);
|
fwrite(&res, 1, sizeof(res), theApp.movieFile);
|
||||||
theApp.movieLastJoypad = res;
|
movieLastJoypad = res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(theApp.moviePlaying) {
|
if(moviePlaying) {
|
||||||
if(theApp.movieFrame == theApp.moviePlayFrame) {
|
if(movieFrame == moviePlayFrame) {
|
||||||
theApp.movieLastJoypad = theApp.movieNextJoypad;
|
movieLastJoypad = movieNextJoypad;
|
||||||
theApp.movieReadNext();
|
theApp.movieReadNext();
|
||||||
}
|
}
|
||||||
res = theApp.movieLastJoypad;
|
res = movieLastJoypad;
|
||||||
}
|
}
|
||||||
// we don't record speed up or screen capture buttons
|
// 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;
|
res |= 1024;
|
||||||
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
|
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
|
||||||
res |= 2048;
|
res |= 2048;
|
||||||
|
@ -751,55 +751,55 @@ void DirectInput::checkKeys()
|
||||||
void DirectInput::checkMotionKeys()
|
void DirectInput::checkMotionKeys()
|
||||||
{
|
{
|
||||||
if(checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
|
if(checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
|
||||||
theApp.sunBars--;
|
sunBars--;
|
||||||
if (theApp.sunBars < 1)
|
if (sunBars < 1)
|
||||||
theApp.sunBars = 1;
|
sunBars = 1;
|
||||||
|
|
||||||
theApp.sensorX += 3;
|
sensorX += 3;
|
||||||
if(theApp.sensorX > 2197)
|
if(sensorX > 2197)
|
||||||
theApp.sensorX = 2197;
|
sensorX = 2197;
|
||||||
if(theApp.sensorX < 2047)
|
if(sensorX < 2047)
|
||||||
theApp.sensorX = 2057;
|
sensorX = 2057;
|
||||||
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
|
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
|
||||||
theApp.sunBars++;
|
sunBars++;
|
||||||
if (theApp.sunBars > 100)
|
if (sunBars > 100)
|
||||||
theApp.sunBars = 100;
|
sunBars = 100;
|
||||||
|
|
||||||
theApp.sensorX -= 3;
|
sensorX -= 3;
|
||||||
if(theApp.sensorX < 1897)
|
if(sensorX < 1897)
|
||||||
theApp.sensorX = 1897;
|
sensorX = 1897;
|
||||||
if(theApp.sensorX > 2047)
|
if(sensorX > 2047)
|
||||||
theApp.sensorX = 2037;
|
sensorX = 2037;
|
||||||
} else if(theApp.sensorX > 2047) {
|
} else if(sensorX > 2047) {
|
||||||
theApp.sensorX -= 2;
|
sensorX -= 2;
|
||||||
if(theApp.sensorX < 2047)
|
if(sensorX < 2047)
|
||||||
theApp.sensorX = 2047;
|
sensorX = 2047;
|
||||||
} else {
|
} else {
|
||||||
theApp.sensorX += 2;
|
sensorX += 2;
|
||||||
if(theApp.sensorX > 2047)
|
if(sensorX > 2047)
|
||||||
theApp.sensorX = 2047;
|
sensorX = 2047;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
|
if(checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
|
||||||
theApp.sensorY += 3;
|
sensorY += 3;
|
||||||
if(theApp.sensorY > 2197)
|
if(sensorY > 2197)
|
||||||
theApp.sensorY = 2197;
|
sensorY = 2197;
|
||||||
if(theApp.sensorY < 2047)
|
if(sensorY < 2047)
|
||||||
theApp.sensorY = 2057;
|
sensorY = 2057;
|
||||||
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
|
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
|
||||||
theApp.sensorY -= 3;
|
sensorY -= 3;
|
||||||
if(theApp.sensorY < 1897)
|
if(sensorY < 1897)
|
||||||
theApp.sensorY = 1897;
|
sensorY = 1897;
|
||||||
if(theApp.sensorY > 2047)
|
if(sensorY > 2047)
|
||||||
theApp.sensorY = 2037;
|
sensorY = 2037;
|
||||||
} else if(theApp.sensorY > 2047) {
|
} else if(sensorY > 2047) {
|
||||||
theApp.sensorY -= 2;
|
sensorY -= 2;
|
||||||
if(theApp.sensorY < 2047)
|
if(sensorY < 2047)
|
||||||
theApp.sensorY = 2047;
|
sensorY = 2047;
|
||||||
} else {
|
} else {
|
||||||
theApp.sensorY += 2;
|
sensorY += 2;
|
||||||
if(theApp.sensorY > 2047)
|
if(sensorY > 2047)
|
||||||
theApp.sensorY = 2047;
|
sensorY = 2047;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ bool DirectSound::init(long sampleRate)
|
||||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||||
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||||
if( theApp.dsoundDisableHardwareAcceleration ) {
|
if( dsoundDisableHardwareAcceleration ) {
|
||||||
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ bool DirectSound::init(long sampleRate)
|
||||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||||
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
|
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
|
||||||
if( theApp.dsoundDisableHardwareAcceleration ) {
|
if( dsoundDisableHardwareAcceleration ) {
|
||||||
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
|
||||||
}
|
}
|
||||||
dsbdesc.dwBufferBytes = soundBufferTotalLen;
|
dsbdesc.dwBufferBytes = soundBufferTotalLen;
|
||||||
|
@ -240,7 +240,7 @@ void DirectSound::write(u16 * finalWave, int length)
|
||||||
LPVOID lpvPtr2;
|
LPVOID lpvPtr2;
|
||||||
DWORD dwBytes2 = 0;
|
DWORD dwBytes2 = 0;
|
||||||
|
|
||||||
if( !speedup && synchronize && !theApp.throttle && !gba_joybus_active) {
|
if( !speedup && synchronize && !throttle && !gba_joybus_active) {
|
||||||
hr = dsbSecondary->GetStatus(&status);
|
hr = dsbSecondary->GetStatus(&status);
|
||||||
if( status & DSBSTATUS_PLAYING ) {
|
if( status & DSBSTATUS_PLAYING ) {
|
||||||
if( !soundPaused ) {
|
if( !soundPaused ) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ FileDlg::FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter,
|
||||||
*p++ = 0;
|
*p++ = 0;
|
||||||
m_ofn.lpstrFilter = m_filter;
|
m_ofn.lpstrFilter = m_filter;
|
||||||
|
|
||||||
if(theApp.videoOption == VIDEO_320x240) {
|
if(videoOption == VIDEO_320x240) {
|
||||||
m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENDLG);
|
m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENDLG);
|
||||||
m_ofn.lpfnHook = HookFuncOldStyle;
|
m_ofn.lpfnHook = HookFuncOldStyle;
|
||||||
m_ofn.Flags |= OFN_ENABLETEMPLATE;
|
m_ofn.Flags |= OFN_ENABLETEMPLATE;
|
||||||
|
|
|
@ -236,7 +236,7 @@ void GBMapView::OnSave()
|
||||||
{
|
{
|
||||||
CString filename;
|
CString filename;
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
filename = "map.png";
|
filename = "map.png";
|
||||||
else
|
else
|
||||||
filename = "map.bmp";
|
filename = "map.bmp";
|
||||||
|
@ -248,8 +248,8 @@ void GBMapView::OnSave()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
filename,
|
filename,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -367,7 +367,7 @@ void GBOamView::save()
|
||||||
{
|
{
|
||||||
CString captureBuffer;
|
CString captureBuffer;
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
captureBuffer = "oam.png";
|
captureBuffer = "oam.png";
|
||||||
else
|
else
|
||||||
captureBuffer = "oam.bmp";
|
captureBuffer = "oam.bmp";
|
||||||
|
@ -380,8 +380,8 @@ void GBOamView::save()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
captureBuffer,
|
captureBuffer,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -243,7 +243,7 @@ void GBPrinterDlg::OnSave()
|
||||||
{
|
{
|
||||||
CString captureBuffer;
|
CString captureBuffer;
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
captureBuffer = "printer.png";
|
captureBuffer = "printer.png";
|
||||||
else
|
else
|
||||||
captureBuffer = "printer.bmp";
|
captureBuffer = "printer.bmp";
|
||||||
|
@ -256,8 +256,8 @@ void GBPrinterDlg::OnSave()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
captureBuffer,
|
captureBuffer,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -242,7 +242,7 @@ void GBTileView::OnSave()
|
||||||
{
|
{
|
||||||
CString captureBuffer;
|
CString captureBuffer;
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
captureBuffer = "tiles.png";
|
captureBuffer = "tiles.png";
|
||||||
else
|
else
|
||||||
captureBuffer = "tiles.bmp";
|
captureBuffer = "tiles.bmp";
|
||||||
|
@ -255,8 +255,8 @@ void GBTileView::OnSave()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
captureBuffer,
|
captureBuffer,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
@ -268,7 +268,7 @@ void GBTileView::OnSave()
|
||||||
|
|
||||||
captureBuffer = dlg.GetPathName();
|
captureBuffer = dlg.GetPathName();
|
||||||
|
|
||||||
if(theApp.captureFormat)
|
if(captureFormat)
|
||||||
saveBMP(captureBuffer);
|
saveBMP(captureBuffer);
|
||||||
else
|
else
|
||||||
savePNG(captureBuffer);
|
savePNG(captureBuffer);
|
||||||
|
|
|
@ -24,10 +24,10 @@ GDBPortDlg::GDBPortDlg(CWnd* pParent /*=NULL*/)
|
||||||
//{{AFX_DATA_INIT(GDBPortDlg)
|
//{{AFX_DATA_INIT(GDBPortDlg)
|
||||||
// NOTE: the ClassWizard will add member initialization here
|
// NOTE: the ClassWizard will add member initialization here
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
if (theApp.gdbPort == 0)
|
if (gdbPort == 0)
|
||||||
port = 55555;
|
port = 55555;
|
||||||
else
|
else
|
||||||
port = theApp.gdbPort;
|
port = gdbPort;
|
||||||
sock = INVALID_SOCKET;
|
sock = INVALID_SOCKET;
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
|
@ -100,7 +100,7 @@ void GDBPortDlg::OnOk()
|
||||||
address.sin_port = htons(atoi(buffer));
|
address.sin_port = htons(atoi(buffer));
|
||||||
port = ntohs(address.sin_port);
|
port = ntohs(address.sin_port);
|
||||||
|
|
||||||
theApp.gdbPort = port;
|
gdbPort = port;
|
||||||
EndDialog(TRUE);
|
EndDialog(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ LinkOptions::LinkOptions(CWnd* pParent /*=NULL*/)
|
||||||
: CDialog(LinkOptions::IDD, pParent)
|
: CDialog(LinkOptions::IDD, pParent)
|
||||||
{
|
{
|
||||||
//{{AFX_DATA_INIT(LinkOptions)
|
//{{AFX_DATA_INIT(LinkOptions)
|
||||||
m_type = theApp.linkMode;
|
m_type = linkMode;
|
||||||
m_server = FALSE;
|
m_server = FALSE;
|
||||||
//}}AFX_DATA_INIT
|
//}}AFX_DATA_INIT
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,11 @@ void LinkOptions::DoDataExchange(CDataExchange* pDX)
|
||||||
//{{AFX_DATA_MAP(LinkOptions)
|
//{{AFX_DATA_MAP(LinkOptions)
|
||||||
DDX_CBData(pDX, IDC_LINK_MODE, m_type);
|
DDX_CBData(pDX, IDC_LINK_MODE, m_type);
|
||||||
DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout);
|
DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout);
|
||||||
DDX_Check(pDX, IDC_AUTOLINK, theApp.linkAuto);
|
DDX_Check(pDX, IDC_AUTOLINK, linkAuto);
|
||||||
DDX_Check(pDX, IDC_SSPEED, theApp.linkHacks);
|
DDX_Check(pDX, IDC_SSPEED, linkHacks);
|
||||||
DDX_Control(pDX, IDC_LINK_MODE, m_mode);
|
DDX_Control(pDX, IDC_LINK_MODE, m_mode);
|
||||||
DDX_Control(pDX, IDC_SERVERIP, m_serverip);
|
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);
|
DDX_Radio(pDX, IDC_LINK_CLIENT, m_server);
|
||||||
//}}AFX_DATA_MAP
|
//}}AFX_DATA_MAP
|
||||||
}
|
}
|
||||||
|
@ -76,19 +76,19 @@ BOOL LinkOptions::OnInitDialog(){
|
||||||
AddMode("Wireless adapter - Network", LINK_RFU_SOCKET);
|
AddMode("Wireless adapter - Network", LINK_RFU_SOCKET);
|
||||||
AddMode("Game Link (Game Boy) - Single Computer", LINK_GAMEBOY);
|
AddMode("Game Link (Game Boy) - Single Computer", LINK_GAMEBOY);
|
||||||
|
|
||||||
sprintf(timeout, "%d", theApp.linkTimeout);
|
sprintf(timeout, "%d", linkTimeout);
|
||||||
|
|
||||||
m_timeout.LimitText(5);
|
m_timeout.LimitText(5);
|
||||||
m_timeout.SetWindowText(timeout);
|
m_timeout.SetWindowText(timeout);
|
||||||
|
|
||||||
m_serverip.SetWindowText(theApp.linkHostAddr);
|
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;
|
int player_radio = 0;
|
||||||
switch (theApp.linkNumPlayers)
|
switch (linkNumPlayers)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
player_radio = IDC_LINK2P;
|
player_radio = IDC_LINK2P;
|
||||||
|
@ -156,8 +156,8 @@ void LinkOptions::OnOk()
|
||||||
LinkMode newMode = (LinkMode) m_type;
|
LinkMode newMode = (LinkMode) m_type;
|
||||||
|
|
||||||
if (newMode == LINK_DISCONNECTED) {
|
if (newMode == LINK_DISCONNECTED) {
|
||||||
theApp.linkTimeout = timeout;
|
linkTimeout = timeout;
|
||||||
theApp.linkMode = LINK_DISCONNECTED;
|
linkMode = LINK_DISCONNECTED;
|
||||||
theApp.linkHostAddr = host;
|
theApp.linkHostAddr = host;
|
||||||
CDialog::OnOK();
|
CDialog::OnOK();
|
||||||
return;
|
return;
|
||||||
|
@ -173,8 +173,8 @@ void LinkOptions::OnOk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EnableSpeedHacks(theApp.linkHacks);
|
EnableSpeedHacks(linkHacks);
|
||||||
EnableLinkServer(m_server, theApp.linkNumPlayers + 1);
|
EnableLinkServer(m_server, linkNumPlayers + 1);
|
||||||
|
|
||||||
if (m_server) {
|
if (m_server) {
|
||||||
char localhost[length];
|
char localhost[length];
|
||||||
|
@ -239,8 +239,8 @@ void LinkOptions::OnOk()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
theApp.linkTimeout = timeout;
|
linkTimeout = timeout;
|
||||||
theApp.linkMode = GetLinkMode();
|
linkMode = GetLinkMode();
|
||||||
theApp.linkHostAddr = host;
|
theApp.linkHostAddr = host;
|
||||||
|
|
||||||
CDialog::OnOK();
|
CDialog::OnOK();
|
||||||
|
|
|
@ -421,7 +421,7 @@ bool MainWnd::FileRun()
|
||||||
{
|
{
|
||||||
// save battery file before we change the filename...
|
// save battery file before we change the filename...
|
||||||
if(rom != NULL || gbRom != NULL) {
|
if(rom != NULL || gbRom != NULL) {
|
||||||
if(theApp.autoSaveLoadCheatList)
|
if(autoSaveLoadCheatList)
|
||||||
winSaveCheatListDefault();
|
winSaveCheatListDefault();
|
||||||
writeBatteryFile();
|
writeBatteryFile();
|
||||||
cheatSearchCleanup(&cheatSearchData);
|
cheatSearchCleanup(&cheatSearchData);
|
||||||
|
@ -488,30 +488,29 @@ bool MainWnd::FileRun()
|
||||||
gbGetHardwareType();
|
gbGetHardwareType();
|
||||||
|
|
||||||
// used for the handling of the gb Boot Rom
|
// used for the handling of the gb Boot Rom
|
||||||
skipBios = theApp.skipBiosFile;
|
|
||||||
if (gbHardware & 5)
|
if (gbHardware & 5)
|
||||||
{
|
{
|
||||||
gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
|
gbCPUInit(theApp.biosFileNameGB, useBiosFileGB);
|
||||||
}
|
}
|
||||||
else if (gbHardware & 2)
|
else if (gbHardware & 2)
|
||||||
{
|
{
|
||||||
gbCPUInit(theApp.biosFileNameGBC, theApp.useBiosFileGBC);
|
gbCPUInit(theApp.biosFileNameGBC, useBiosFileGBC);
|
||||||
}
|
}
|
||||||
|
|
||||||
gbReset();
|
gbReset();
|
||||||
theApp.emulator = GBSystem;
|
theApp.emulator = GBSystem;
|
||||||
gbBorderOn = theApp.winGbBorderOn;
|
gbBorderOn = winGbBorderOn;
|
||||||
theApp.romSize = gbRomSize;
|
theApp.romSize = gbRomSize;
|
||||||
|
|
||||||
|
|
||||||
if(theApp.autoPatch && !patchName.IsEmpty()) {
|
if(autoPatch && !patchName.IsEmpty()) {
|
||||||
int size = gbRomSize;
|
int size = gbRomSize;
|
||||||
applyPatch(patchName, &gbRom, &size);
|
applyPatch(patchName, &gbRom, &size);
|
||||||
if(size != gbRomSize) {
|
if(size != gbRomSize) {
|
||||||
extern bool gbUpdateSizes();
|
extern bool gbUpdateSizes();
|
||||||
gbUpdateSizes();
|
gbUpdateSizes();
|
||||||
gbReset();
|
gbReset();
|
||||||
theApp.romSize = size;
|
theApp.romSize = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -519,11 +518,11 @@ bool MainWnd::FileRun()
|
||||||
if(!size)
|
if(!size)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
theApp.romSize = size;
|
theApp.romSize = size;
|
||||||
|
|
||||||
flashSetSize(theApp.winFlashSize);
|
flashSetSize(winFlashSize);
|
||||||
rtcEnable(theApp.winRtcEnable);
|
rtcEnable(rtcEnabled);
|
||||||
cpuSaveType = theApp.winSaveType;
|
cpuSaveType = saveType;
|
||||||
|
|
||||||
if (cpuSaveType == 0)
|
if (cpuSaveType == 0)
|
||||||
utilGBAFindSave(theApp.romSize);
|
utilGBAFindSave(theApp.romSize);
|
||||||
|
@ -569,7 +568,7 @@ bool MainWnd::FileRun()
|
||||||
|
|
||||||
theApp.emulator = GBASystem;
|
theApp.emulator = GBASystem;
|
||||||
|
|
||||||
if(theApp.autoPatch && !patchName.IsEmpty()) {
|
if(autoPatch && !patchName.IsEmpty()) {
|
||||||
int size = 0x2000000;
|
int size = 0x2000000;
|
||||||
applyPatch(patchName, &rom, &size);
|
applyPatch(patchName, &rom, &size);
|
||||||
if(size != 0x2000000) {
|
if(size != 0x2000000) {
|
||||||
|
@ -585,7 +584,7 @@ bool MainWnd::FileRun()
|
||||||
soundReset();
|
soundReset();
|
||||||
} else {
|
} else {
|
||||||
soundInit();
|
soundInit();
|
||||||
theApp.soundInitialized = true;
|
theApp.soundInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef APU_LOGGER_H
|
#ifdef APU_LOGGER_H
|
||||||
|
@ -593,42 +592,41 @@ bool MainWnd::FileRun()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(type == IMAGE_GBA) {
|
if(type == IMAGE_GBA) {
|
||||||
skipBios = theApp.skipBiosFile;
|
CPUInit(theApp.biosFileNameGBA.GetString(), useBiosFileGBA);
|
||||||
CPUInit(theApp.biosFileNameGBA.GetString(), theApp.useBiosFileGBA);
|
|
||||||
CPUReset();
|
CPUReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
readBatteryFile();
|
readBatteryFile();
|
||||||
|
|
||||||
if(theApp.autoSaveLoadCheatList)
|
if(autoSaveLoadCheatList)
|
||||||
winLoadCheatListDefault();
|
winLoadCheatListDefault();
|
||||||
|
|
||||||
theApp.addRecentFile(theApp.szFile);
|
theApp.addRecentFile(theApp.szFile);
|
||||||
|
|
||||||
theApp.updateWindowSize(theApp.videoOption);
|
theApp.updateWindowSize(videoOption);
|
||||||
|
|
||||||
theApp.updateFrameSkip();
|
theApp.updateFrameSkip();
|
||||||
|
|
||||||
emulating = true;
|
emulating = true;
|
||||||
|
|
||||||
if(theApp.autoLoadMostRecent)
|
if(autoLoadMostRecent)
|
||||||
OnFileLoadgameMostrecent();
|
OnFileLoadgameMostrecent();
|
||||||
|
|
||||||
theApp.frameskipadjust = 0;
|
frameskipadjust = 0;
|
||||||
theApp.renderedFrames = 0;
|
renderedFrames = 0;
|
||||||
theApp.autoFrameSkipLastTime = systemGetClock();
|
autoFrameSkipLastTime = systemGetClock();
|
||||||
|
|
||||||
theApp.rewindCount = 0;
|
rewindCount = 0;
|
||||||
theApp.rewindCounter = 0;
|
rewindCounter = 0;
|
||||||
theApp.rewindSaveNeeded = false;
|
rewindSaveNeeded = false;
|
||||||
|
|
||||||
toolsClearLog();
|
toolsClearLog();
|
||||||
#ifndef NO_LINK
|
#ifndef NO_LINK
|
||||||
if (theApp.linkAuto)
|
if (linkAuto)
|
||||||
BootLink(theApp.linkMode, theApp.linkHostAddr, theApp.linkTimeout, theApp.linkHacks, theApp.linkNumPlayers);
|
BootLink(linkMode, theApp.linkHostAddr, linkTimeout, linkHacks, linkNumPlayers);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (theApp.gdbBreakOnLoad)
|
if (gdbBreakOnLoad)
|
||||||
OnToolsDebugBreak();
|
OnToolsDebugBreak();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -722,11 +720,11 @@ void MainWnd::OnMove(int x, int y)
|
||||||
RECT r;
|
RECT r;
|
||||||
|
|
||||||
GetWindowRect(&r);
|
GetWindowRect(&r);
|
||||||
theApp.windowPositionX = r.left;
|
windowPositionX = r.left;
|
||||||
theApp.windowPositionY = r.top;
|
windowPositionY = r.top;
|
||||||
theApp.adjustDestRect();
|
theApp.adjustDestRect();
|
||||||
regSetDwordValue("windowX", theApp.windowPositionX);
|
regSetDwordValue("windowX", windowPositionX);
|
||||||
regSetDwordValue("windowY", theApp.windowPositionY);
|
regSetDwordValue("windowY", windowPositionY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -742,7 +740,7 @@ void MainWnd::OnSizing(UINT fwSide, LPRECT pRect)
|
||||||
}
|
}
|
||||||
|
|
||||||
// maintain minimal window size
|
// maintain minimal window size
|
||||||
RECT size = { 0, 0, theApp.sizeX, theApp.sizeY };
|
RECT size = { 0, 0, sizeX, sizeY };
|
||||||
AdjustWindowRectEx(
|
AdjustWindowRectEx(
|
||||||
&size,
|
&size,
|
||||||
WS_POPUP | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
|
WS_POPUP | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
|
||||||
|
@ -767,7 +765,7 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
|
||||||
{
|
{
|
||||||
CWnd::OnSize(nType, cx, cy);
|
CWnd::OnSize(nType, cx, cy);
|
||||||
|
|
||||||
bool redraw = ( ( cx < theApp.surfaceSizeX ) || ( cy < theApp.surfaceSizeY ) );
|
bool redraw = ( ( cx < surfaceSizeX ) || ( cy < surfaceSizeY ) );
|
||||||
|
|
||||||
if(!theApp.changingVideoSize) {
|
if(!theApp.changingVideoSize) {
|
||||||
if(this) {
|
if(this) {
|
||||||
|
@ -775,12 +773,12 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
|
||||||
if(theApp.iconic) {
|
if(theApp.iconic) {
|
||||||
if(emulating) {
|
if(emulating) {
|
||||||
soundResume();
|
soundResume();
|
||||||
theApp.paused = false;
|
paused = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(theApp.videoOption <= VIDEO_6X) {
|
if(videoOption <= VIDEO_6X) {
|
||||||
theApp.surfaceSizeX = cx;
|
surfaceSizeX = cx;
|
||||||
theApp.surfaceSizeY = cy;
|
surfaceSizeY = cy;
|
||||||
theApp.adjustDestRect();
|
theApp.adjustDestRect();
|
||||||
if(theApp.display)
|
if(theApp.display)
|
||||||
theApp.display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top);
|
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;
|
theApp.painting = true;
|
||||||
systemDrawScreen();
|
systemDrawScreen();
|
||||||
theApp.painting = false;
|
theApp.painting = false;
|
||||||
theApp.renderedFrames--;
|
renderedFrames--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(emulating) {
|
if(emulating) {
|
||||||
if(!theApp.paused) {
|
if(!paused) {
|
||||||
theApp.paused = true;
|
paused = true;
|
||||||
soundPause();
|
soundPause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
theApp.iconic = true;
|
theApp.iconic = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1151,8 +1149,8 @@ void MainWnd::OnPaint()
|
||||||
if(emulating) {
|
if(emulating) {
|
||||||
theApp.painting = true;
|
theApp.painting = true;
|
||||||
systemDrawScreen();
|
systemDrawScreen();
|
||||||
theApp.painting = false;
|
theApp.painting = false;
|
||||||
theApp.renderedFrames--;
|
renderedFrames--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,7 +1194,7 @@ void MainWnd::screenCapture(int captureNumber)
|
||||||
captureDir = getDirFromFile(theApp.filename);
|
captureDir = getDirFromFile(theApp.filename);
|
||||||
|
|
||||||
LPCTSTR ext = "png";
|
LPCTSTR ext = "png";
|
||||||
if(theApp.captureFormat != 0)
|
if(captureFormat != 0)
|
||||||
ext = "bmp";
|
ext = "bmp";
|
||||||
|
|
||||||
if(isDriveRoot(captureDir))
|
if(isDriveRoot(captureDir))
|
||||||
|
@ -1219,7 +1217,7 @@ void MainWnd::screenCapture(int captureNumber)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
theApp.emulator.emuWritePNG(buffer);
|
theApp.emulator.emuWritePNG(buffer);
|
||||||
else
|
else
|
||||||
theApp.emulator.emuWriteBMP(buffer);
|
theApp.emulator.emuWriteBMP(buffer);
|
||||||
|
@ -1231,10 +1229,10 @@ void MainWnd::screenCapture(int captureNumber)
|
||||||
void MainWnd::winMouseOn()
|
void MainWnd::winMouseOn()
|
||||||
{
|
{
|
||||||
SetCursor(arrow);
|
SetCursor(arrow);
|
||||||
if(theApp.videoOption > VIDEO_6X) {
|
if(videoOption > VIDEO_6X) {
|
||||||
theApp.mouseCounter = 10;
|
mouseCounter = 10;
|
||||||
} else
|
} else
|
||||||
theApp.mouseCounter = 0;
|
mouseCounter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnMouseMove(UINT nFlags, CPoint point)
|
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);
|
bool a = (nState == WA_ACTIVE) || (nState == WA_CLICKACTIVE);
|
||||||
|
|
||||||
if(a && theApp.input) {
|
if(a && theApp.input) {
|
||||||
theApp.active = a;
|
active = a;
|
||||||
theApp.input->activate();
|
theApp.input->activate();
|
||||||
if(!theApp.paused && emulating) {
|
if(!paused && emulating) {
|
||||||
soundResume();
|
soundResume();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
theApp.wasPaused = true;
|
wasPaused = true;
|
||||||
if(theApp.pauseWhenInactive && !gba_joybus_active) {
|
if(pauseWhenInactive && !gba_joybus_active) {
|
||||||
if(emulating) {
|
if(emulating) {
|
||||||
soundPause();
|
soundPause();
|
||||||
}
|
}
|
||||||
theApp.active = a;
|
active = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(theApp.delta,255,sizeof(theApp.delta));
|
memset(theApp.delta,255,sizeof(theApp.delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(theApp.paused && emulating)
|
if(paused && emulating)
|
||||||
{
|
{
|
||||||
theApp.painting = true;
|
theApp.painting = true;
|
||||||
systemDrawScreen();
|
systemDrawScreen();
|
||||||
theApp.painting = false;
|
theApp.painting = false;
|
||||||
theApp.renderedFrames--;
|
renderedFrames--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,7 +1304,7 @@ void MainWnd::OnDropFiles(HDROP hDropInfo)
|
||||||
|
|
||||||
LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam)
|
LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if(emulating && !theApp.paused) {
|
if(emulating && !paused) {
|
||||||
if((wParam&0xFFF0) == SC_SCREENSAVE || (wParam&0xFFF0) == SC_MONITORPOWER)
|
if((wParam&0xFFF0) == SC_SCREENSAVE || (wParam&0xFFF0) == SC_MONITORPOWER)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,12 @@ void MainWnd::OnUpdateCheatsCheatlist(CCmdUI* pCmdUI)
|
||||||
|
|
||||||
void MainWnd::OnCheatsAutomaticsaveloadcheats()
|
void MainWnd::OnCheatsAutomaticsaveloadcheats()
|
||||||
{
|
{
|
||||||
theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList;
|
autoSaveLoadCheatList = !autoSaveLoadCheatList;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->SetCheck(theApp.autoSaveLoadCheatList);
|
pCmdUI->SetCheck(autoSaveLoadCheatList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnCheatsLoadcheatlist()
|
void MainWnd::OnCheatsLoadcheatlist()
|
||||||
|
|
|
@ -48,10 +48,10 @@ void MainWnd::OnFileOpenGB()
|
||||||
|
|
||||||
void MainWnd::OnFilePause()
|
void MainWnd::OnFilePause()
|
||||||
{
|
{
|
||||||
theApp.paused = !theApp.paused;
|
paused = !paused;
|
||||||
if(emulating) {
|
if(emulating) {
|
||||||
if(theApp.paused) {
|
if(paused) {
|
||||||
theApp.wasPaused = true;
|
wasPaused = true;
|
||||||
soundPause();
|
soundPause();
|
||||||
} else {
|
} else {
|
||||||
soundResume();
|
soundResume();
|
||||||
|
@ -61,20 +61,19 @@ void MainWnd::OnFilePause()
|
||||||
|
|
||||||
void MainWnd::OnUpdateFilePause(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateFilePause(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->SetCheck(theApp.paused);
|
pCmdUI->SetCheck(paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnFileReset()
|
void MainWnd::OnFileReset()
|
||||||
{
|
{
|
||||||
skipBios = theApp.skipBiosFile;
|
|
||||||
|
|
||||||
if(emulating) {
|
if(emulating) {
|
||||||
if(theApp.cartridgeType == IMAGE_GB) {
|
if(theApp.cartridgeType == IMAGE_GB) {
|
||||||
gbGetHardwareType();
|
gbGetHardwareType();
|
||||||
if (gbHardware & 5) {
|
if (gbHardware & 5) {
|
||||||
gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
|
gbCPUInit(theApp.biosFileNameGB, useBiosFileGB);
|
||||||
} else if (gbHardware & 2) {
|
} else if (gbHardware & 2) {
|
||||||
gbCPUInit(theApp.biosFileNameGBC, theApp.useBiosFileGBC);
|
gbCPUInit(theApp.biosFileNameGBC, useBiosFileGBC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
theApp.emulator.emuReset();
|
theApp.emulator.emuReset();
|
||||||
|
@ -89,7 +88,7 @@ void MainWnd::OnUpdateFileReset(CCmdUI* pCmdUI)
|
||||||
|
|
||||||
void MainWnd::OnUpdateFileRecentFreeze(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateFileRecentFreeze(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->SetCheck(theApp.recentFreeze);
|
pCmdUI->SetCheck(recentFreeze);
|
||||||
|
|
||||||
if(pCmdUI->m_pMenu == NULL)
|
if(pCmdUI->m_pMenu == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -139,7 +138,7 @@ void MainWnd::OnFileRecentReset()
|
||||||
|
|
||||||
void MainWnd::OnFileRecentFreeze()
|
void MainWnd::OnFileRecentFreeze()
|
||||||
{
|
{
|
||||||
theApp.recentFreeze = !theApp.recentFreeze;
|
recentFreeze = !recentFreeze;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnFileExit()
|
void MainWnd::OnFileExit()
|
||||||
|
@ -151,7 +150,7 @@ void MainWnd::OnFileClose()
|
||||||
{
|
{
|
||||||
// save battery file before we change the filename...
|
// save battery file before we change the filename...
|
||||||
if(rom != NULL || gbRom != NULL) {
|
if(rom != NULL || gbRom != NULL) {
|
||||||
if(theApp.autoSaveLoadCheatList)
|
if(autoSaveLoadCheatList)
|
||||||
winSaveCheatListDefault();
|
winSaveCheatListDefault();
|
||||||
writeBatteryFile();
|
writeBatteryFile();
|
||||||
soundPause();
|
soundPause();
|
||||||
|
@ -209,9 +208,9 @@ void MainWnd::OnFileLoad()
|
||||||
if(dlg.DoModal() == IDOK) {
|
if(dlg.DoModal() == IDOK) {
|
||||||
bool res = loadSaveGame(dlg.GetPathName());
|
bool res = loadSaveGame(dlg.GetPathName());
|
||||||
|
|
||||||
theApp.rewindCount = 0;
|
rewindCount = 0;
|
||||||
theApp.rewindCounter = 0;
|
rewindCounter = 0;
|
||||||
theApp.rewindSaveNeeded = false;
|
rewindSaveNeeded = false;
|
||||||
|
|
||||||
if(res)
|
if(res)
|
||||||
systemScreenMessage(winResLoadString(IDS_LOADED_STATE));
|
systemScreenMessage(winResLoadString(IDS_LOADED_STATE));
|
||||||
|
@ -262,16 +261,13 @@ BOOL MainWnd::OnFileLoadSlot(UINT nID)
|
||||||
|
|
||||||
bool res = loadSaveGame(filename);
|
bool res = loadSaveGame(filename);
|
||||||
|
|
||||||
if (theApp.paused)
|
if (paused)
|
||||||
InterframeCleanup();
|
InterframeCleanup();
|
||||||
|
|
||||||
systemScreenMessage(buffer);
|
systemScreenMessage(buffer);
|
||||||
|
|
||||||
systemDrawScreen();
|
systemDrawScreen();
|
||||||
|
|
||||||
//theApp.rewindCount = 0;
|
|
||||||
//theApp.rewindCounter = 0;
|
|
||||||
//theApp.rewindSaveNeeded = false;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -628,7 +624,7 @@ void MainWnd::OnFileScreencapture()
|
||||||
|
|
||||||
CString ext = "png";
|
CString ext = "png";
|
||||||
|
|
||||||
if(theApp.captureFormat != 0)
|
if(captureFormat != 0)
|
||||||
ext = "bmp";
|
ext = "bmp";
|
||||||
|
|
||||||
if(isDriveRoot(capdir))
|
if(isDriveRoot(capdir))
|
||||||
|
@ -644,8 +640,8 @@ void MainWnd::OnFileScreencapture()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
filename,
|
filename,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
capdir,
|
capdir,
|
||||||
title,
|
title,
|
||||||
|
@ -686,7 +682,7 @@ void MainWnd::OnUpdateFileRominformation(CCmdUI* pCmdUI)
|
||||||
//OnFileToggleFullscreen
|
//OnFileToggleFullscreen
|
||||||
void MainWnd::OnFileTogglemenu()
|
void MainWnd::OnFileTogglemenu()
|
||||||
{
|
{
|
||||||
if( theApp.videoOption <= VIDEO_6X ) {
|
if( videoOption <= VIDEO_6X ) {
|
||||||
// switch to full screen
|
// switch to full screen
|
||||||
toolsLoggingClose(); // close log dialog
|
toolsLoggingClose(); // close log dialog
|
||||||
theApp.updateWindowSize( theApp.lastFullscreen );
|
theApp.updateWindowSize( theApp.lastFullscreen );
|
||||||
|
@ -699,7 +695,7 @@ void MainWnd::OnFileTogglemenu()
|
||||||
void MainWnd::OnUpdateFileTogglemenu(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateFileTogglemenu(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
// HACK: when uncommented, Esc key will not be send to MainWnd
|
// 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)
|
bool MainWnd::fileImportGSACodeFile(CString& fileName)
|
||||||
|
@ -977,12 +973,12 @@ void MainWnd::OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI)
|
||||||
|
|
||||||
void MainWnd::OnFileLoadgameAutoloadmostrecent()
|
void MainWnd::OnFileLoadgameAutoloadmostrecent()
|
||||||
{
|
{
|
||||||
theApp.autoLoadMostRecent = !theApp.autoLoadMostRecent;
|
autoLoadMostRecent = !autoLoadMostRecent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->SetCheck(theApp.autoLoadMostRecent);
|
pCmdUI->SetCheck(autoLoadMostRecent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnLoadgameDonotchangebatterysave()
|
void MainWnd::OnLoadgameDonotchangebatterysave()
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -55,7 +55,7 @@ void MainWnd::OnToolsDisassemble()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsDisassemble(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsDisassemble(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsLogging()
|
void MainWnd::OnToolsLogging()
|
||||||
|
@ -65,7 +65,7 @@ void MainWnd::OnToolsLogging()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsLogging(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsLogging(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsIoviewer()
|
void MainWnd::OnToolsIoviewer()
|
||||||
|
@ -77,7 +77,7 @@ void MainWnd::OnToolsIoviewer()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsIoviewer(CCmdUI* pCmdUI)
|
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()
|
void MainWnd::OnToolsMapview()
|
||||||
|
@ -95,7 +95,7 @@ void MainWnd::OnToolsMapview()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsMapview(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsMapview(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsMemoryviewer()
|
void MainWnd::OnToolsMemoryviewer()
|
||||||
|
@ -113,7 +113,7 @@ void MainWnd::OnToolsMemoryviewer()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsOamviewer()
|
void MainWnd::OnToolsOamviewer()
|
||||||
|
@ -131,7 +131,7 @@ void MainWnd::OnToolsOamviewer()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsOamviewer(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsOamviewer(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsPaletteview()
|
void MainWnd::OnToolsPaletteview()
|
||||||
|
@ -149,7 +149,7 @@ void MainWnd::OnToolsPaletteview()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsPaletteview(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsPaletteview(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsTileviewer()
|
void MainWnd::OnToolsTileviewer()
|
||||||
|
@ -167,14 +167,14 @@ void MainWnd::OnToolsTileviewer()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsTileviewer(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsTileviewer(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
|
pCmdUI->Enable(videoOption <= VIDEO_6X);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnDebugNextframe()
|
void MainWnd::OnDebugNextframe()
|
||||||
{
|
{
|
||||||
if(theApp.paused)
|
if(paused)
|
||||||
theApp.paused = false;
|
paused = false;
|
||||||
theApp.winPauseNextFrame = true;
|
winPauseNextFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsDebugConfigurePort()
|
void MainWnd::OnToolsDebugConfigurePort()
|
||||||
|
@ -191,19 +191,19 @@ void MainWnd::OnUpdateToolsDebugConfigurePort(CCmdUI* pCmdUI)
|
||||||
|
|
||||||
void MainWnd::OnToolsDebugBreakOnLoad()
|
void MainWnd::OnToolsDebugBreakOnLoad()
|
||||||
{
|
{
|
||||||
theApp.gdbBreakOnLoad = !theApp.gdbBreakOnLoad;
|
gdbBreakOnLoad = !gdbBreakOnLoad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsDebugBreakOnLoad(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsDebugBreakOnLoad(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->SetCheck(theApp.gdbBreakOnLoad);
|
pCmdUI->SetCheck(gdbBreakOnLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsDebugBreak()
|
void MainWnd::OnToolsDebugBreak()
|
||||||
{
|
{
|
||||||
GDBPortDlg dlg;
|
GDBPortDlg dlg;
|
||||||
|
|
||||||
int port = theApp.gdbPort;
|
int port = gdbPort;
|
||||||
if (port == 0)
|
if (port == 0)
|
||||||
{
|
{
|
||||||
if (dlg.DoModal()) {
|
if (dlg.DoModal()) {
|
||||||
|
@ -238,7 +238,7 @@ void MainWnd::OnToolsDebugBreak()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsDebugBreak(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsDebugBreak(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && emulating != 0);
|
pCmdUI->Enable(videoOption <= VIDEO_6X && emulating != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsDebugDisconnect()
|
void MainWnd::OnToolsDebugDisconnect()
|
||||||
|
@ -249,7 +249,7 @@ void MainWnd::OnToolsDebugDisconnect()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && remoteSocket != -1);
|
pCmdUI->Enable(videoOption <= VIDEO_6X && remoteSocket != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnOptionsSoundStartrecording()
|
void MainWnd::OnOptionsSoundStartrecording()
|
||||||
|
@ -273,7 +273,7 @@ void MainWnd::OnOptionsSoundStartrecording()
|
||||||
}
|
}
|
||||||
|
|
||||||
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
|
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
|
||||||
theApp.soundRecording = true;
|
soundRecording = true;
|
||||||
|
|
||||||
if(dlg.m_ofn.nFileOffset > 0) {
|
if(dlg.m_ofn.nFileOffset > 0) {
|
||||||
captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset);
|
captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset);
|
||||||
|
@ -288,7 +288,7 @@ void MainWnd::OnOptionsSoundStartrecording()
|
||||||
|
|
||||||
void MainWnd::OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(!theApp.soundRecording);
|
pCmdUI->Enable(!soundRecording);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnOptionsSoundStoprecording()
|
void MainWnd::OnOptionsSoundStoprecording()
|
||||||
|
@ -297,12 +297,12 @@ void MainWnd::OnOptionsSoundStoprecording()
|
||||||
delete theApp.soundRecorder;
|
delete theApp.soundRecorder;
|
||||||
theApp.soundRecorder = NULL;
|
theApp.soundRecorder = NULL;
|
||||||
}
|
}
|
||||||
theApp.soundRecording = false;
|
soundRecording = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.soundRecording);
|
pCmdUI->Enable(soundRecording);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ void MainWnd::OnToolsRecordStartavirecording()
|
||||||
|
|
||||||
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
|
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
|
||||||
theApp.aviRecordName = captureBuffer;
|
theApp.aviRecordName = captureBuffer;
|
||||||
theApp.aviRecording = true;
|
aviRecording = true;
|
||||||
|
|
||||||
if( dlg.m_ofn.nFileOffset > 0 ) {
|
if( dlg.m_ofn.nFileOffset > 0 ) {
|
||||||
captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset );
|
captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset );
|
||||||
|
@ -358,14 +358,14 @@ void MainWnd::OnToolsRecordStartavirecording()
|
||||||
systemMessage( IDS_AVI_CANNOT_CREATE_AVI, "Cannot create AVI file." );
|
systemMessage( IDS_AVI_CANNOT_CREATE_AVI, "Cannot create AVI file." );
|
||||||
delete theApp.aviRecorder;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add video stream
|
// add video stream
|
||||||
ret = theApp.aviRecorder->CreateVideoStream(
|
ret = theApp.aviRecorder->CreateVideoStream(
|
||||||
theApp.sizeX,
|
sizeX,
|
||||||
theApp.sizeY,
|
sizeY,
|
||||||
( systemColorDepth == 32 ) ? 24 : 16,
|
( systemColorDepth == 32 ) ? 24 : 16,
|
||||||
60,
|
60,
|
||||||
this->GetSafeHwnd()
|
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!" );
|
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;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ void MainWnd::OnToolsRecordStartavirecording()
|
||||||
systemMessage( IDS_AVI_CANNOT_CREATE_AUDIO, "Cannot create audio stream in AVI file." );
|
systemMessage( IDS_AVI_CANNOT_CREATE_AUDIO, "Cannot create audio stream in AVI file." );
|
||||||
delete theApp.aviRecorder;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ void MainWnd::OnToolsRecordStartavirecording()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable( !theApp.aviRecording && emulating );
|
pCmdUI->Enable( !aviRecording && emulating );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -407,13 +407,13 @@ void MainWnd::OnToolsRecordStopavirecording()
|
||||||
delete theApp.aviRecorder;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
}
|
}
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable( theApp.aviRecording );
|
pCmdUI->Enable( aviRecording );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsRecordStartmovierecording()
|
void MainWnd::OnToolsRecordStartmovierecording()
|
||||||
|
@ -464,10 +464,10 @@ void MainWnd::OnToolsRecordStartmovierecording()
|
||||||
movieName = movieName.Left(movieName.GetLength()-3) + "VM0";
|
movieName = movieName.Left(movieName.GetLength()-3) + "VM0";
|
||||||
|
|
||||||
if(writeSaveGame(movieName)) {
|
if(writeSaveGame(movieName)) {
|
||||||
theApp.movieFrame = 0;
|
movieFrame = 0;
|
||||||
theApp.movieLastJoypad = 0;
|
movieLastJoypad = 0;
|
||||||
theApp.movieRecording = true;
|
movieRecording = true;
|
||||||
theApp.moviePlaying = false;
|
moviePlaying = false;
|
||||||
} else {
|
} else {
|
||||||
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
|
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
|
||||||
(const char *)movieName);
|
(const char *)movieName);
|
||||||
|
@ -476,29 +476,29 @@ void MainWnd::OnToolsRecordStartmovierecording()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(!theApp.movieRecording && emulating);
|
pCmdUI->Enable(!movieRecording && emulating);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsRecordStopmovierecording()
|
void MainWnd::OnToolsRecordStopmovierecording()
|
||||||
{
|
{
|
||||||
if(theApp.movieRecording) {
|
if(movieRecording) {
|
||||||
if(theApp.movieFile != NULL) {
|
if(theApp.movieFile != NULL) {
|
||||||
// record the last joypad change so that the correct time can be
|
// record the last joypad change so that the correct time can be
|
||||||
// recorded
|
// recorded
|
||||||
fwrite(&theApp.movieFrame, 1, sizeof(int), theApp.movieFile);
|
fwrite(&movieFrame, 1, sizeof(int), theApp.movieFile);
|
||||||
fwrite(&theApp.movieLastJoypad, 1, sizeof(u32), theApp.movieFile);
|
fwrite(&movieLastJoypad, 1, sizeof(u32), theApp.movieFile);
|
||||||
fclose(theApp.movieFile);
|
fclose(theApp.movieFile);
|
||||||
theApp.movieFile = NULL;
|
theApp.movieFile = NULL;
|
||||||
}
|
}
|
||||||
theApp.movieRecording = false;
|
movieRecording = false;
|
||||||
theApp.moviePlaying = false;
|
moviePlaying = false;
|
||||||
theApp.movieLastJoypad = 0;
|
movieLastJoypad = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.movieRecording);
|
pCmdUI->Enable(movieRecording);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsPlayStartmovieplaying()
|
void MainWnd::OnToolsPlayStartmovieplaying()
|
||||||
|
@ -554,10 +554,10 @@ void MainWnd::OnToolsPlayStartmovieplaying()
|
||||||
}
|
}
|
||||||
movieName = movieName.Left(movieName.GetLength()-3)+"VM0";
|
movieName = movieName.Left(movieName.GetLength()-3)+"VM0";
|
||||||
if(loadSaveGame(movieName)) {
|
if(loadSaveGame(movieName)) {
|
||||||
theApp.moviePlaying = true;
|
moviePlaying = true;
|
||||||
theApp.movieFrame = 0;
|
movieFrame = 0;
|
||||||
theApp.moviePlayFrame = 0;
|
moviePlayFrame = 0;
|
||||||
theApp.movieLastJoypad = 0;
|
movieLastJoypad = 0;
|
||||||
theApp.movieReadNext();
|
theApp.movieReadNext();
|
||||||
} else {
|
} else {
|
||||||
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
|
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
|
||||||
|
@ -567,39 +567,39 @@ void MainWnd::OnToolsPlayStartmovieplaying()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(!theApp.moviePlaying && emulating);
|
pCmdUI->Enable(!moviePlaying && emulating);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsPlayStopmovieplaying()
|
void MainWnd::OnToolsPlayStopmovieplaying()
|
||||||
{
|
{
|
||||||
if(theApp.moviePlaying) {
|
if(moviePlaying) {
|
||||||
if(theApp.movieFile != NULL) {
|
if(theApp.movieFile != NULL) {
|
||||||
fclose(theApp.movieFile);
|
fclose(theApp.movieFile);
|
||||||
theApp.movieFile = NULL;
|
theApp.movieFile = NULL;
|
||||||
}
|
}
|
||||||
theApp.moviePlaying = false;
|
moviePlaying = false;
|
||||||
theApp.movieLastJoypad = 0;
|
movieLastJoypad = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.moviePlaying);
|
pCmdUI->Enable(moviePlaying);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsRewind()
|
void MainWnd::OnToolsRewind()
|
||||||
{
|
{
|
||||||
if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && theApp.rewindCount) {
|
if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && rewindCount) {
|
||||||
theApp.rewindPos = --theApp.rewindPos & 7;
|
rewindPos = --rewindPos & 7;
|
||||||
theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*theApp.rewindPos], REWIND_SIZE);
|
theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*rewindPos], REWIND_SIZE);
|
||||||
theApp.rewindCount--;
|
rewindCount--;
|
||||||
theApp.rewindCounter = 0;
|
rewindCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsRewind(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsRewind(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && theApp.rewindCount);
|
pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && rewindCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWnd::OnToolsCustomize()
|
void MainWnd::OnToolsCustomize()
|
||||||
|
@ -616,5 +616,5 @@ void MainWnd::OnToolsCustomize()
|
||||||
|
|
||||||
void MainWnd::OnUpdateToolsCustomize(CCmdUI* pCmdUI)
|
void MainWnd::OnUpdateToolsCustomize(CCmdUI* pCmdUI)
|
||||||
{
|
{
|
||||||
pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
|
pCmdUI->Enable(videoOption != VIDEO_320x240);
|
||||||
}
|
}
|
||||||
|
|
|
@ -966,7 +966,7 @@ void MapView::OnSave()
|
||||||
{
|
{
|
||||||
CString filename;
|
CString filename;
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
filename = "map.png";
|
filename = "map.png";
|
||||||
else
|
else
|
||||||
filename = "map.bmp";
|
filename = "map.bmp";
|
||||||
|
@ -979,8 +979,8 @@ void MapView::OnSave()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
filename,
|
filename,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -49,7 +49,7 @@ void MaxScale::OnOk()
|
||||||
{
|
{
|
||||||
CString tmp;
|
CString tmp;
|
||||||
m_value.GetWindowText(tmp);
|
m_value.GetWindowText(tmp);
|
||||||
theApp.maxScale = atoi(tmp);
|
maxScale = atoi(tmp);
|
||||||
EndDialog(TRUE);
|
EndDialog(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ BOOL MaxScale::OnInitDialog()
|
||||||
|
|
||||||
CString temp;
|
CString temp;
|
||||||
|
|
||||||
temp.Format("%d", theApp.maxScale);
|
temp.Format("%d", maxScale);
|
||||||
|
|
||||||
m_value.SetWindowText(temp);
|
m_value.SetWindowText(temp);
|
||||||
|
|
||||||
|
|
|
@ -549,7 +549,7 @@ void OamView::OnSave()
|
||||||
{
|
{
|
||||||
CString captureBuffer;
|
CString captureBuffer;
|
||||||
|
|
||||||
if (theApp.captureFormat == 0)
|
if (captureFormat == 0)
|
||||||
captureBuffer = "oam.png";
|
captureBuffer = "oam.png";
|
||||||
else
|
else
|
||||||
captureBuffer = "oam.bmp";
|
captureBuffer = "oam.bmp";
|
||||||
|
@ -562,8 +562,8 @@ void OamView::OnSave()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
captureBuffer,
|
captureBuffer,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
//#define LOGALL
|
//#define LOGALL
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "VBA.h" // for 'theApp.throttle'
|
#include "VBA.h" // for 'throttle'
|
||||||
|
|
||||||
#ifndef NO_OAL
|
#ifndef NO_OAL
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ void OpenAL::write(u16 * finalWave, int length)
|
||||||
|
|
||||||
if( nBuffersProcessed == theApp.oalBufferCount ) {
|
if( nBuffersProcessed == theApp.oalBufferCount ) {
|
||||||
// we only want to know about it when we are emulating at full speed or faster:
|
// 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 ) {
|
if( systemVerbose & VERBOSE_SOUNDOUTPUT ) {
|
||||||
static unsigned int i = 0;
|
static unsigned int i = 0;
|
||||||
log( "OpenAL: Buffers were not refilled fast enough (i=%i)\n", i++ );
|
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
|
// wait until at least one buffer has finished
|
||||||
while( nBuffersProcessed == 0 ) {
|
while( nBuffersProcessed == 0 ) {
|
||||||
winlog( " waiting...\n" );
|
winlog( " waiting...\n" );
|
||||||
|
|
|
@ -192,49 +192,49 @@ bool OpenGLDisplay::initialize()
|
||||||
switch( theApp.cartridgeType )
|
switch( theApp.cartridgeType )
|
||||||
{
|
{
|
||||||
case IMAGE_GBA:
|
case IMAGE_GBA:
|
||||||
theApp.sizeX = 240;
|
sizeX = 240;
|
||||||
theApp.sizeY = 160;
|
sizeY = 160;
|
||||||
break;
|
break;
|
||||||
case IMAGE_GB:
|
case IMAGE_GB:
|
||||||
if ( gbBorderOn )
|
if ( gbBorderOn )
|
||||||
{
|
{
|
||||||
theApp.sizeX = 256;
|
sizeX = 256;
|
||||||
theApp.sizeY = 224;
|
sizeY = 224;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
theApp.sizeX = 160;
|
sizeX = 160;
|
||||||
theApp.sizeY = 144;
|
sizeY = 144;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch(theApp.videoOption)
|
switch(videoOption)
|
||||||
{
|
{
|
||||||
case VIDEO_1X:
|
case VIDEO_1X:
|
||||||
theApp.surfaceSizeX = theApp.sizeX;
|
surfaceSizeX = sizeX;
|
||||||
theApp.surfaceSizeY = theApp.sizeY;
|
surfaceSizeY = sizeY;
|
||||||
break;
|
break;
|
||||||
case VIDEO_2X:
|
case VIDEO_2X:
|
||||||
theApp.surfaceSizeX = theApp.sizeX * 2;
|
surfaceSizeX = sizeX * 2;
|
||||||
theApp.surfaceSizeY = theApp.sizeY * 2;
|
surfaceSizeY = sizeY * 2;
|
||||||
break;
|
break;
|
||||||
case VIDEO_3X:
|
case VIDEO_3X:
|
||||||
theApp.surfaceSizeX = theApp.sizeX * 3;
|
surfaceSizeX = sizeX * 3;
|
||||||
theApp.surfaceSizeY = theApp.sizeY * 3;
|
surfaceSizeY = sizeY * 3;
|
||||||
break;
|
break;
|
||||||
case VIDEO_4X:
|
case VIDEO_4X:
|
||||||
theApp.surfaceSizeX = theApp.sizeX * 4;
|
surfaceSizeX = sizeX * 4;
|
||||||
theApp.surfaceSizeY = theApp.sizeY * 4;
|
surfaceSizeY = sizeY * 4;
|
||||||
break;
|
break;
|
||||||
case VIDEO_5X:
|
case VIDEO_5X:
|
||||||
theApp.surfaceSizeX = theApp.sizeX * 5;
|
surfaceSizeX = sizeX * 5;
|
||||||
theApp.surfaceSizeY = theApp.sizeY * 5;
|
surfaceSizeY = sizeY * 5;
|
||||||
break;
|
break;
|
||||||
case VIDEO_6X:
|
case VIDEO_6X:
|
||||||
theApp.surfaceSizeX = theApp.sizeX * 6;
|
surfaceSizeX = sizeX * 6;
|
||||||
theApp.surfaceSizeY = theApp.sizeY * 6;
|
surfaceSizeY = sizeY * 6;
|
||||||
break;
|
break;
|
||||||
case VIDEO_320x240:
|
case VIDEO_320x240:
|
||||||
case VIDEO_640x480:
|
case VIDEO_640x480:
|
||||||
|
@ -243,17 +243,17 @@ bool OpenGLDisplay::initialize()
|
||||||
case VIDEO_1280x1024:
|
case VIDEO_1280x1024:
|
||||||
case VIDEO_OTHER:
|
case VIDEO_OTHER:
|
||||||
{
|
{
|
||||||
if( theApp.fullScreenStretch ) {
|
if( fullScreenStretch ) {
|
||||||
theApp.surfaceSizeX = theApp.fsWidth;
|
surfaceSizeX = fsWidth;
|
||||||
theApp.surfaceSizeY = theApp.fsHeight;
|
surfaceSizeY = fsHeight;
|
||||||
} else {
|
} else {
|
||||||
float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX;
|
float scaleX = (float)fsWidth / (float)sizeX;
|
||||||
float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY;
|
float scaleY = (float)fsHeight / (float)sizeY;
|
||||||
float min = ( scaleX < scaleY ) ? scaleX : scaleY;
|
float min = ( scaleX < scaleY ) ? scaleX : scaleY;
|
||||||
if( theApp.maxScale )
|
if( maxScale )
|
||||||
min = ( min > (float)theApp.maxScale ) ? (float)theApp.maxScale : min;
|
min = ( min > (float)maxScale ) ? (float)maxScale : min;
|
||||||
theApp.surfaceSizeX = (int)((float)theApp.sizeX * min);
|
surfaceSizeX = (int)((float)sizeX * min);
|
||||||
theApp.surfaceSizeY = (int)((float)theApp.sizeY * min);
|
surfaceSizeY = (int)((float)sizeY * min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -261,23 +261,23 @@ bool OpenGLDisplay::initialize()
|
||||||
|
|
||||||
theApp.rect.left = 0;
|
theApp.rect.left = 0;
|
||||||
theApp.rect.top = 0;
|
theApp.rect.top = 0;
|
||||||
theApp.rect.right = theApp.sizeX;
|
theApp.rect.right = sizeX;
|
||||||
theApp.rect.bottom = theApp.sizeY;
|
theApp.rect.bottom = sizeY;
|
||||||
|
|
||||||
theApp.dest.left = 0;
|
theApp.dest.left = 0;
|
||||||
theApp.dest.top = 0;
|
theApp.dest.top = 0;
|
||||||
theApp.dest.right = theApp.surfaceSizeX;
|
theApp.dest.right = surfaceSizeX;
|
||||||
theApp.dest.bottom = theApp.surfaceSizeY;
|
theApp.dest.bottom = surfaceSizeY;
|
||||||
|
|
||||||
DWORD style = WS_POPUP | WS_VISIBLE;
|
DWORD style = WS_POPUP | WS_VISIBLE;
|
||||||
DWORD styleEx = 0;
|
DWORD styleEx = 0;
|
||||||
|
|
||||||
if( theApp.videoOption <= VIDEO_6X )
|
if( videoOption <= VIDEO_6X )
|
||||||
style |= WS_OVERLAPPEDWINDOW;
|
style |= WS_OVERLAPPEDWINDOW;
|
||||||
else
|
else
|
||||||
styleEx = 0;
|
styleEx = 0;
|
||||||
|
|
||||||
if( theApp.videoOption <= VIDEO_6X )
|
if( videoOption <= VIDEO_6X )
|
||||||
AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
|
AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
|
||||||
else
|
else
|
||||||
AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );
|
AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );
|
||||||
|
@ -286,12 +286,12 @@ bool OpenGLDisplay::initialize()
|
||||||
int winSizeY = theApp.dest.bottom - theApp.dest.top;
|
int winSizeY = theApp.dest.bottom - theApp.dest.top;
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
|
|
||||||
if( theApp.videoOption <= VIDEO_6X ) {
|
if( videoOption <= VIDEO_6X ) {
|
||||||
x = theApp.windowPositionX;
|
x = windowPositionX;
|
||||||
y = theApp.windowPositionY;
|
y = windowPositionY;
|
||||||
} else {
|
} else {
|
||||||
winSizeX = theApp.fsWidth;
|
winSizeX = fsWidth;
|
||||||
winSizeY = theApp.fsHeight;
|
winSizeY = fsHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,20 +300,20 @@ bool OpenGLDisplay::initialize()
|
||||||
|
|
||||||
theApp.adjustDestRect();
|
theApp.adjustDestRect();
|
||||||
|
|
||||||
currentAdapter = theApp.fsAdapter;
|
currentAdapter = fsAdapter;
|
||||||
DISPLAY_DEVICE dev;
|
DISPLAY_DEVICE dev;
|
||||||
ZeroMemory( &dev, sizeof(dev) );
|
ZeroMemory( &dev, sizeof(dev) );
|
||||||
dev.cb = sizeof(dev);
|
dev.cb = sizeof(dev);
|
||||||
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
|
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
|
||||||
if( theApp.videoOption >= VIDEO_320x240 ) {
|
if( videoOption >= VIDEO_320x240 ) {
|
||||||
// enter full screen mode
|
// enter full screen mode
|
||||||
DEVMODE mode;
|
DEVMODE mode;
|
||||||
ZeroMemory( &mode, sizeof(mode) );
|
ZeroMemory( &mode, sizeof(mode) );
|
||||||
mode.dmSize = sizeof(mode);
|
mode.dmSize = sizeof(mode);
|
||||||
mode.dmBitsPerPel = theApp.fsColorDepth;
|
mode.dmBitsPerPel = fsColorDepth;
|
||||||
mode.dmPelsWidth = theApp.fsWidth;
|
mode.dmPelsWidth = fsWidth;
|
||||||
mode.dmPelsHeight = theApp.fsHeight;
|
mode.dmPelsHeight = fsHeight;
|
||||||
mode.dmDisplayFrequency = theApp.fsFrequency;
|
mode.dmDisplayFrequency = fsFrequency;
|
||||||
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
||||||
LONG ret = ChangeDisplaySettingsEx( dev.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL );
|
LONG ret = ChangeDisplaySettingsEx( dev.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL );
|
||||||
if( ret != DISP_CHANGE_SUCCESSFUL ) {
|
if( ret != DISP_CHANGE_SUCCESSFUL ) {
|
||||||
|
@ -334,12 +334,12 @@ bool OpenGLDisplay::initialize()
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
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
|
#ifdef MMX
|
||||||
if(!theApp.disableMMX)
|
if(!disableMMX)
|
||||||
cpu_mmx = theApp.detectMMX();
|
cpu_mmx = theApp.detectMMX();
|
||||||
else
|
else
|
||||||
cpu_mmx = 0;
|
cpu_mmx = 0;
|
||||||
|
@ -349,15 +349,15 @@ bool OpenGLDisplay::initialize()
|
||||||
systemGreenShift = 11;
|
systemGreenShift = 11;
|
||||||
systemBlueShift = 3;
|
systemBlueShift = 3;
|
||||||
systemColorDepth = 32;
|
systemColorDepth = 32;
|
||||||
theApp.fsColorDepth = 32;
|
fsColorDepth = 32;
|
||||||
|
|
||||||
Init_2xSaI(32);
|
Init_2xSaI(32);
|
||||||
|
|
||||||
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
|
||||||
theApp.updateFilter();
|
theApp.updateFilter();
|
||||||
theApp.updateIFB();
|
theApp.updateIFB();
|
||||||
pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
pitch = filterWidth * (systemColorDepth>>3) + 4;
|
||||||
data = pix + ( theApp.sizeX + 1 ) * 4;
|
data = pix + ( sizeX + 1 ) * 4;
|
||||||
|
|
||||||
if(failed)
|
if(failed)
|
||||||
return false;
|
return false;
|
||||||
|
@ -377,8 +377,8 @@ void OpenGLDisplay::render()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
|
pitch = filterWidth * (systemColorDepth>>3) + 4;
|
||||||
data = pix + ( theApp.sizeX + 1 ) * 4;
|
data = pix + ( sizeX + 1 ) * 4;
|
||||||
|
|
||||||
// apply pixel filter
|
// apply pixel filter
|
||||||
if(theApp.filterFunction) {
|
if(theApp.filterFunction) {
|
||||||
|
@ -389,8 +389,8 @@ void OpenGLDisplay::render()
|
||||||
(u8*)theApp.delta,
|
(u8*)theApp.delta,
|
||||||
(u8*)filterData,
|
(u8*)filterData,
|
||||||
width * 4 ,
|
width * 4 ,
|
||||||
theApp.filterWidth,
|
filterWidth,
|
||||||
theApp.filterHeight);
|
filterHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Texturemap complete texture to surface
|
// Texturemap complete texture to surface
|
||||||
|
@ -399,7 +399,7 @@ void OpenGLDisplay::render()
|
||||||
if( theApp.filterFunction ) {
|
if( theApp.filterFunction ) {
|
||||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, width);
|
glPixelStorei( GL_UNPACK_ROW_LENGTH, width);
|
||||||
} else {
|
} 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 );
|
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 );
|
glVertex3i( 0, 0, 0 );
|
||||||
|
|
||||||
glTexCoord2f( (float)(width) / size, 0.0f );
|
glTexCoord2f( (float)(width) / size, 0.0f );
|
||||||
glVertex3i( theApp.surfaceSizeX, 0, 0 );
|
glVertex3i( surfaceSizeX, 0, 0 );
|
||||||
|
|
||||||
glTexCoord2f( (float)(width) / size, (float)(height) / size );
|
glTexCoord2f( (float)(width) / size, (float)(height) / size );
|
||||||
glVertex3i( theApp.surfaceSizeX, theApp.surfaceSizeY, 0 );
|
glVertex3i( surfaceSizeX, surfaceSizeY, 0 );
|
||||||
|
|
||||||
glTexCoord2f( 0.0f, (float)(height) / size );
|
glTexCoord2f( 0.0f, (float)(height) / size );
|
||||||
glVertex3i( 0, theApp.surfaceSizeY, 0 );
|
glVertex3i( 0, surfaceSizeY, 0 );
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
if( theApp.showSpeed ) { // && ( theApp.videoOption > VIDEO_6X ) ) {
|
if( showSpeed ) { // && ( videoOption > VIDEO_6X ) ) {
|
||||||
char buffer[30];
|
char buffer[30];
|
||||||
if( theApp.showSpeed == 1 ) {
|
if( showSpeed == 1 ) {
|
||||||
sprintf( buffer, "%3d%%", systemSpeed );
|
sprintf( buffer, "%3d%%", systemSpeed );
|
||||||
} else {
|
} else {
|
||||||
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, theApp.showRenderedFrames );
|
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames );
|
||||||
}
|
}
|
||||||
glFontBegin(&font);
|
glFontBegin(&font);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
float fontscale = (float)theApp.surfaceSizeX / 100.0f;
|
float fontscale = (float)surfaceSizeX / 100.0f;
|
||||||
glScalef(fontscale, fontscale, fontscale);
|
glScalef(fontscale, fontscale, fontscale);
|
||||||
glColor4f(1.0f, 0.25f, 0.25f, 1.0f);
|
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();
|
glPopMatrix();
|
||||||
glFontEnd();
|
glFontEnd();
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
glBindTexture( GL_TEXTURE_2D, texture );
|
glBindTexture( GL_TEXTURE_2D, texture );
|
||||||
}
|
}
|
||||||
if( theApp.screenMessage ) {
|
if( screenMessage ) {
|
||||||
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.disableStatusMessage ) {
|
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages ) {
|
||||||
glFontBegin(&font);
|
glFontBegin(&font);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
float fontscale = (float)theApp.surfaceSizeX / 100.0f;
|
float fontscale = (float)surfaceSizeX / 100.0f;
|
||||||
glScalef(fontscale, fontscale, fontscale);
|
glScalef(fontscale, fontscale, fontscale);
|
||||||
glColor4f(1.0f, 0.25f, 0.25f, 1.0f);
|
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();
|
glPopMatrix();
|
||||||
glFontEnd();
|
glFontEnd();
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
glBindTexture( GL_TEXTURE_2D, texture );
|
glBindTexture( GL_TEXTURE_2D, texture );
|
||||||
} else {
|
} else {
|
||||||
theApp.screenMessage = false;
|
screenMessage = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +491,7 @@ void OpenGLDisplay::updateFiltering( int value )
|
||||||
//init projection matrixes and viewports
|
//init projection matrixes and viewports
|
||||||
void OpenGLDisplay::initializeMatrices( int w, int h )
|
void OpenGLDisplay::initializeMatrices( int w, int h )
|
||||||
{
|
{
|
||||||
if( theApp.fullScreenStretch ) {
|
if( fullScreenStretch ) {
|
||||||
glViewport( 0, 0, w, h );
|
glViewport( 0, 0, w, h );
|
||||||
} else {
|
} else {
|
||||||
calculateDestRect( w, h );
|
calculateDestRect( w, h );
|
||||||
|
@ -542,7 +542,7 @@ bool OpenGLDisplay::initializeTexture( int w, int h )
|
||||||
|
|
||||||
glGenTextures( 1, &texture );
|
glGenTextures( 1, &texture );
|
||||||
glBindTexture( GL_TEXTURE_2D, texture );
|
glBindTexture( GL_TEXTURE_2D, texture );
|
||||||
updateFiltering( theApp.glFilter );
|
updateFiltering( glFilter );
|
||||||
|
|
||||||
glTexImage2D(
|
glTexImage2D(
|
||||||
GL_TEXTURE_2D,
|
GL_TEXTURE_2D,
|
||||||
|
@ -609,8 +609,8 @@ void OpenGLDisplay::calculateDestRect( int w, int h )
|
||||||
float scaleX = (float)w / (float)width;
|
float scaleX = (float)w / (float)width;
|
||||||
float scaleY = (float)h / (float)height;
|
float scaleY = (float)h / (float)height;
|
||||||
float min = (scaleX < scaleY) ? scaleX : scaleY;
|
float min = (scaleX < scaleY) ? scaleX : scaleY;
|
||||||
if( theApp.maxScale && (min > theApp.maxScale) ) {
|
if( maxScale && (min > maxScale) ) {
|
||||||
min = (float)theApp.maxScale;
|
min = (float)maxScale;
|
||||||
}
|
}
|
||||||
destRect.left = 0;
|
destRect.left = 0;
|
||||||
destRect.top = 0;
|
destRect.top = 0;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "VBA.h"
|
#include "VBA.h"
|
||||||
#include "..\gba\GBALink.h"
|
#include "..\gba\GBALink.h"
|
||||||
|
#include "..\common\ConfigManager.h"
|
||||||
|
|
||||||
static char buffer[2048];
|
static char buffer[2048];
|
||||||
static HKEY vbKey = NULL;
|
static HKEY vbKey = NULL;
|
||||||
|
|
|
@ -248,7 +248,7 @@ void TileView::OnSave()
|
||||||
{
|
{
|
||||||
CString captureBuffer;
|
CString captureBuffer;
|
||||||
|
|
||||||
if(theApp.captureFormat == 0)
|
if(captureFormat == 0)
|
||||||
captureBuffer = "tiles.png";
|
captureBuffer = "tiles.png";
|
||||||
else
|
else
|
||||||
captureBuffer = "tiles.bmp";
|
captureBuffer = "tiles.bmp";
|
||||||
|
@ -261,8 +261,8 @@ void TileView::OnSave()
|
||||||
FileDlg dlg(this,
|
FileDlg dlg(this,
|
||||||
captureBuffer,
|
captureBuffer,
|
||||||
filter,
|
filter,
|
||||||
theApp.captureFormat ? 2 : 1,
|
captureFormat ? 2 : 1,
|
||||||
theApp.captureFormat ? "BMP" : "PNG",
|
captureFormat ? "BMP" : "PNG",
|
||||||
exts,
|
exts,
|
||||||
"",
|
"",
|
||||||
title,
|
title,
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "../gb/gbPrinter.h"
|
#include "../gb/gbPrinter.h"
|
||||||
#include "../gb/gbSound.h"
|
#include "../gb/gbSound.h"
|
||||||
#include "../common/SoundDriver.h"
|
#include "../common/SoundDriver.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
|
|
||||||
#include "../version.h"
|
#include "../version.h"
|
||||||
|
|
||||||
|
@ -206,7 +207,7 @@ VBA::VBA()
|
||||||
windowPositionY = 0;
|
windowPositionY = 0;
|
||||||
filterFunction = NULL;
|
filterFunction = NULL;
|
||||||
ifbFunction = NULL;
|
ifbFunction = NULL;
|
||||||
ifbType = 0;
|
ifbType = kIFBNone;
|
||||||
filterType = FILTER_NONE;
|
filterType = FILTER_NONE;
|
||||||
filterWidth = 0;
|
filterWidth = 0;
|
||||||
filterHeight = 0;
|
filterHeight = 0;
|
||||||
|
@ -223,7 +224,6 @@ VBA::VBA()
|
||||||
sizeY = 0;
|
sizeY = 0;
|
||||||
videoOption = 0;
|
videoOption = 0;
|
||||||
fullScreenStretch = false;
|
fullScreenStretch = false;
|
||||||
disableStatusMessage = false;
|
|
||||||
showSpeed = 0;
|
showSpeed = 0;
|
||||||
showSpeedTransparent = true;
|
showSpeedTransparent = true;
|
||||||
showRenderedFrames = 0;
|
showRenderedFrames = 0;
|
||||||
|
@ -237,7 +237,7 @@ VBA::VBA()
|
||||||
useBiosFileGBA = false;
|
useBiosFileGBA = false;
|
||||||
useBiosFileGBC = false;
|
useBiosFileGBC = false;
|
||||||
useBiosFileGB = false;
|
useBiosFileGB = false;
|
||||||
skipBiosFile = false;
|
skipBios = false;
|
||||||
biosFileNameGBA = _T("");
|
biosFileNameGBA = _T("");
|
||||||
biosFileNameGBC = _T("");
|
biosFileNameGBC = _T("");
|
||||||
biosFileNameGB = _T("");
|
biosFileNameGB = _T("");
|
||||||
|
@ -249,8 +249,8 @@ VBA::VBA()
|
||||||
autoPatch = true;
|
autoPatch = true;
|
||||||
winGbBorderOn = 0;
|
winGbBorderOn = 0;
|
||||||
winFlashSize = 0x20000;
|
winFlashSize = 0x20000;
|
||||||
winRtcEnable = false;
|
rtcEnabled = false;
|
||||||
winSaveType = 0;
|
saveType = 0;
|
||||||
rewindMemory = NULL;
|
rewindMemory = NULL;
|
||||||
rewindPos = 0;
|
rewindPos = 0;
|
||||||
rewindTopPos = 0;
|
rewindTopPos = 0;
|
||||||
|
@ -857,8 +857,6 @@ void VBA::updateFilter()
|
||||||
|
|
||||||
void VBA::updateThrottle( unsigned short throttle )
|
void VBA::updateThrottle( unsigned short throttle )
|
||||||
{
|
{
|
||||||
this->throttle = throttle;
|
|
||||||
|
|
||||||
if( throttle ) {
|
if( throttle ) {
|
||||||
Sm60FPS::K_fCpuSpeed = (float)throttle;
|
Sm60FPS::K_fCpuSpeed = (float)throttle;
|
||||||
Sm60FPS::K_fTargetFps = 60.0f * Sm60FPS::K_fCpuSpeed / 100;
|
Sm60FPS::K_fTargetFps = 60.0f * Sm60FPS::K_fCpuSpeed / 100;
|
||||||
|
@ -943,7 +941,7 @@ void systemDrawScreen()
|
||||||
if(theApp.display == NULL)
|
if(theApp.display == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
theApp.renderedFrames++;
|
renderedFrames++;
|
||||||
|
|
||||||
if(theApp.updateCount) {
|
if(theApp.updateCount) {
|
||||||
POSITION pos = theApp.updateList.GetHeadPosition();
|
POSITION pos = theApp.updateList.GetHeadPosition();
|
||||||
|
@ -956,38 +954,38 @@ void systemDrawScreen()
|
||||||
if (Sm60FPS_CanSkipFrame())
|
if (Sm60FPS_CanSkipFrame())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( theApp.aviRecording ) {
|
if( aviRecording ) {
|
||||||
if( theApp.painting ) {
|
if (theApp.painting) {
|
||||||
theApp.skipAudioFrames++;
|
theApp.skipAudioFrames++;
|
||||||
} else {
|
} else {
|
||||||
unsigned char *bmp;
|
unsigned char *bmp;
|
||||||
unsigned short srcPitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
|
unsigned short srcPitch = sizeX * ( systemColorDepth >> 3 ) + 4;
|
||||||
switch( systemColorDepth )
|
switch( systemColorDepth )
|
||||||
{
|
{
|
||||||
case 16:
|
case 16:
|
||||||
bmp = new unsigned char[ theApp.sizeX * theApp.sizeY * 2 ];
|
bmp = new unsigned char[ sizeX * sizeY * 2 ];
|
||||||
cpyImg16bmp( bmp, pix + srcPitch, srcPitch, theApp.sizeX, theApp.sizeY );
|
cpyImg16bmp( bmp, pix + srcPitch, srcPitch, sizeX, sizeY );
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
// use 24 bit colors to reduce video size
|
// use 24 bit colors to reduce video size
|
||||||
bmp = new unsigned char[ theApp.sizeX * theApp.sizeY * 3 ];
|
bmp = new unsigned char[ sizeX * sizeY * 3 ];
|
||||||
cpyImg32bmp( bmp, pix + srcPitch, srcPitch, theApp.sizeX, theApp.sizeY );
|
cpyImg32bmp( bmp, pix + srcPitch, srcPitch, sizeX, sizeY );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( false == theApp.aviRecorder->AddVideoFrame( bmp ) ) {
|
if( false == theApp.aviRecorder->AddVideoFrame( bmp ) ) {
|
||||||
systemMessage( IDS_AVI_CANNOT_WRITE_VIDEO, "Cannot write video frame to AVI file." );
|
systemMessage( IDS_AVI_CANNOT_WRITE_VIDEO, "Cannot write video frame to AVI file." );
|
||||||
delete theApp.aviRecorder;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
}
|
}
|
||||||
delete [] bmp;
|
delete [] bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( theApp.ifbFunction ) {
|
if( theApp.ifbFunction ) {
|
||||||
theApp.ifbFunction( pix + (theApp.filterWidth * (systemColorDepth>>3)) + 4,
|
theApp.ifbFunction( pix + (filterWidth * (systemColorDepth>>3)) + 4,
|
||||||
(theApp.filterWidth * (systemColorDepth>>3)) + 4,
|
(filterWidth * (systemColorDepth>>3)) + 4,
|
||||||
theApp.filterWidth, theApp.filterHeight );
|
filterWidth, filterHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!soundBufferLow)
|
if(!soundBufferLow)
|
||||||
|
@ -1042,16 +1040,16 @@ void systemSetTitle(const char *title)
|
||||||
void systemShowSpeed(int speed)
|
void systemShowSpeed(int speed)
|
||||||
{
|
{
|
||||||
systemSpeed = speed;
|
systemSpeed = speed;
|
||||||
theApp.showRenderedFrames = theApp.renderedFrames;
|
showRenderedFrames = renderedFrames;
|
||||||
theApp.renderedFrames = 0;
|
renderedFrames = 0;
|
||||||
if(theApp.videoOption <= VIDEO_6X && theApp.showSpeed) {
|
if(videoOption <= VIDEO_6X && showSpeed) {
|
||||||
CString buffer;
|
CString buffer;
|
||||||
if(theApp.showSpeed == 1)
|
if(showSpeed == 1)
|
||||||
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%", systemSpeed);
|
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%", systemSpeed);
|
||||||
else
|
else
|
||||||
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%(%d, %d fps)", systemSpeed,
|
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%(%d, %d fps)", systemSpeed,
|
||||||
systemFrameSkip,
|
systemFrameSkip,
|
||||||
theApp.showRenderedFrames);
|
showRenderedFrames);
|
||||||
|
|
||||||
systemSetTitle(buffer);
|
systemSetTitle(buffer);
|
||||||
}
|
}
|
||||||
|
@ -1060,8 +1058,8 @@ void systemShowSpeed(int speed)
|
||||||
|
|
||||||
void systemFrame()
|
void systemFrame()
|
||||||
{
|
{
|
||||||
if( theApp.movieRecording || theApp.moviePlaying ) {
|
if( movieRecording || moviePlaying ) {
|
||||||
theApp.movieFrame++;
|
movieFrame++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LOG_PERFORMANCE
|
#ifdef LOG_PERFORMANCE
|
||||||
|
@ -1073,11 +1071,11 @@ void systemFrame()
|
||||||
void system10Frames(int rate)
|
void system10Frames(int rate)
|
||||||
{
|
{
|
||||||
|
|
||||||
if( theApp.autoFrameSkip )
|
if( autoFrameSkip )
|
||||||
{
|
{
|
||||||
u32 time = systemGetClock();
|
u32 time = systemGetClock();
|
||||||
u32 diff = time - theApp.autoFrameSkipLastTime;
|
u32 diff = time - autoFrameSkipLastTime;
|
||||||
theApp.autoFrameSkipLastTime = time;
|
autoFrameSkipLastTime = time;
|
||||||
if( diff ) {
|
if( diff ) {
|
||||||
// countermeasure against div/0 when debugging
|
// countermeasure against div/0 when debugging
|
||||||
Sm60FPS::nCurSpeed = (1000000/rate)/diff;
|
Sm60FPS::nCurSpeed = (1000000/rate)/diff;
|
||||||
|
@ -1088,9 +1086,9 @@ void system10Frames(int rate)
|
||||||
|
|
||||||
|
|
||||||
if(theApp.rewindMemory) {
|
if(theApp.rewindMemory) {
|
||||||
if(++theApp.rewindCounter >= (theApp.rewindTimer)) {
|
if(++rewindCounter >= (rewindTimer)) {
|
||||||
theApp.rewindSaveNeeded = true;
|
rewindSaveNeeded = true;
|
||||||
theApp.rewindCounter = 0;
|
rewindCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(systemSaveUpdateCounter) {
|
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
|
// Old autoframeskip crap... might be useful later. autoframeskip Ifdef above might be useless as well now
|
||||||
// theApp.autoFrameSkipLastTime = time;
|
// autoFrameSkipLastTime = time;
|
||||||
|
|
||||||
#ifdef LOG_PERFORMANCE
|
#ifdef LOG_PERFORMANCE
|
||||||
if( systemSpeedCounter >= PERFORMANCE_INTERVAL ) {
|
if( systemSpeedCounter >= PERFORMANCE_INTERVAL ) {
|
||||||
|
@ -1121,7 +1119,7 @@ void system10Frames(int rate)
|
||||||
|
|
||||||
void systemScreenMessage(const char *msg)
|
void systemScreenMessage(const char *msg)
|
||||||
{
|
{
|
||||||
theApp.screenMessage = true;
|
screenMessage = true;
|
||||||
theApp.screenMessageTime = GetTickCount();
|
theApp.screenMessageTime = GetTickCount();
|
||||||
theApp.screenMessageBuffer = msg;
|
theApp.screenMessageBuffer = msg;
|
||||||
|
|
||||||
|
@ -1132,7 +1130,7 @@ void systemScreenMessage(const char *msg)
|
||||||
void systemUpdateSolarSensor()
|
void systemUpdateSolarSensor()
|
||||||
{
|
{
|
||||||
u8 sun = 0x0; //sun = 0xE8 - 0xE8 (case 0 and default)
|
u8 sun = 0x0; //sun = 0xE8 - 0xE8 (case 0 and default)
|
||||||
int level = theApp.sunBars / 10;
|
int level = sunBars / 10;
|
||||||
switch (level)
|
switch (level)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -1198,12 +1196,12 @@ void systemUpdateMotionSensor()
|
||||||
|
|
||||||
int systemGetSensorX()
|
int systemGetSensorX()
|
||||||
{
|
{
|
||||||
return theApp.sensorX;
|
return sensorX;
|
||||||
}
|
}
|
||||||
|
|
||||||
int systemGetSensorY()
|
int systemGetSensorY()
|
||||||
{
|
{
|
||||||
return theApp.sensorY;
|
return sensorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1230,8 +1228,8 @@ SoundDriver * systemSoundInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
if( drv ) {
|
if( drv ) {
|
||||||
if (theApp.throttle)
|
if (throttle)
|
||||||
drv->setThrottle( theApp.throttle );
|
drv->setThrottle( throttle );
|
||||||
}
|
}
|
||||||
|
|
||||||
return drv;
|
return drv;
|
||||||
|
@ -1244,19 +1242,19 @@ void systemOnSoundShutdown()
|
||||||
delete theApp.aviRecorder;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
}
|
}
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
|
|
||||||
|
|
||||||
if( theApp.soundRecorder ) {
|
if( theApp.soundRecorder ) {
|
||||||
delete theApp.soundRecorder;
|
delete theApp.soundRecorder;
|
||||||
theApp.soundRecorder = NULL;
|
theApp.soundRecorder = NULL;
|
||||||
}
|
}
|
||||||
theApp.soundRecording = false;
|
soundRecording = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
|
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
|
||||||
{
|
{
|
||||||
if( theApp.soundRecording ) {
|
if( soundRecording ) {
|
||||||
if( theApp.soundRecorder ) {
|
if( theApp.soundRecorder ) {
|
||||||
theApp.soundRecorder->AddSound( (const u8 *)finalWave, length );
|
theApp.soundRecorder->AddSound( (const u8 *)finalWave, length );
|
||||||
} else {
|
} else {
|
||||||
|
@ -1275,7 +1273,7 @@ void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( theApp.aviRecording && theApp.aviRecorder ) {
|
if( aviRecording && theApp.aviRecorder ) {
|
||||||
if( theApp.skipAudioFrames ) {
|
if( theApp.skipAudioFrames ) {
|
||||||
theApp.skipAudioFrames--;
|
theApp.skipAudioFrames--;
|
||||||
} else {
|
} 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." );
|
systemMessage( IDS_AVI_CANNOT_WRITE_AUDIO, "Cannot write audio frame to AVI file." );
|
||||||
delete theApp.aviRecorder;
|
delete theApp.aviRecorder;
|
||||||
theApp.aviRecorder = NULL;
|
theApp.aviRecorder = NULL;
|
||||||
theApp.aviRecording = false;
|
aviRecording = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1296,9 +1294,9 @@ bool systemCanChangeSoundQuality()
|
||||||
|
|
||||||
bool systemPauseOnFrame()
|
bool systemPauseOnFrame()
|
||||||
{
|
{
|
||||||
if(theApp.winPauseNextFrame) {
|
if(winPauseNextFrame) {
|
||||||
theApp.paused = true;
|
paused = true;
|
||||||
theApp.winPauseNextFrame = false;
|
winPauseNextFrame = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1307,7 +1305,7 @@ bool systemPauseOnFrame()
|
||||||
void systemGbBorderOn()
|
void systemGbBorderOn()
|
||||||
{
|
{
|
||||||
if(emulating && theApp.cartridgeType == IMAGE_GB && gbBorderOn) {
|
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;
|
useBiosFileGB = ( regQueryDwordValue("useBiosGB", 0) == 1 ) ? true : false;
|
||||||
|
|
||||||
skipBiosFile = regQueryDwordValue("skipBios", 0) ? true : false;
|
skipBios = regQueryDwordValue("skipBios", 0) ? true : false;
|
||||||
|
|
||||||
buffer = regQueryStringValue("biosFileGBA", "");
|
buffer = regQueryStringValue("biosFileGBA", "");
|
||||||
|
|
||||||
|
@ -1546,7 +1544,7 @@ void VBA::loadSettings()
|
||||||
|
|
||||||
disableMMX = regQueryDwordValue("disableMMX", false) ? true: false;
|
disableMMX = regQueryDwordValue("disableMMX", false) ? true: false;
|
||||||
|
|
||||||
disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false;
|
disableStatusMessages = regQueryDwordValue("disableStatus", 0) ? true : false;
|
||||||
|
|
||||||
showSpeed = regQueryDwordValue("showSpeed", 0);
|
showSpeed = regQueryDwordValue("showSpeed", 0);
|
||||||
if(showSpeed < 0 || showSpeed > 2)
|
if(showSpeed < 0 || showSpeed > 2)
|
||||||
|
@ -1576,23 +1574,22 @@ void VBA::loadSettings()
|
||||||
|
|
||||||
cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false;
|
cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false;
|
||||||
|
|
||||||
winSaveType = regQueryDwordValue("saveType", 0);
|
saveType = regQueryDwordValue("saveType", 0);
|
||||||
if(winSaveType < 0 || winSaveType > 5)
|
if(saveType < 0 || saveType > 5)
|
||||||
winSaveType = 0;
|
saveType = 0;
|
||||||
|
|
||||||
ifbType = regQueryDwordValue("ifbType", 0);
|
ifbType = (IFBFilter)regQueryDwordValue("ifbType", 0);
|
||||||
if(ifbType < 0 || ifbType > 2)
|
if(ifbType < 0 || ifbType > 2)
|
||||||
ifbType = 0;
|
ifbType = kIFBNone;
|
||||||
|
|
||||||
winFlashSize = regQueryDwordValue("flashSize", 0x10000);
|
winFlashSize = regQueryDwordValue("flashSize", 0x10000);
|
||||||
if(winFlashSize != 0x10000 && winFlashSize != 0x20000)
|
if(winFlashSize != 0x10000 && winFlashSize != 0x20000)
|
||||||
winFlashSize = 0x10000;
|
winFlashSize = 0x10000;
|
||||||
flashSize = winFlashSize;
|
|
||||||
|
|
||||||
agbPrintEnable(regQueryDwordValue("agbPrint", 0) ? true : false);
|
agbPrintEnable(regQueryDwordValue("agbPrint", 0) ? true : false);
|
||||||
|
|
||||||
winRtcEnable = regQueryDwordValue("rtcEnabled", 0) ? true : false;
|
rtcEnabled = regQueryDwordValue("rtcEnabled", 0) ? true : false;
|
||||||
rtcEnable(winRtcEnable);
|
rtcEnable(rtcEnabled);
|
||||||
|
|
||||||
switch(videoOption) {
|
switch(videoOption) {
|
||||||
case VIDEO_320x240:
|
case VIDEO_320x240:
|
||||||
|
@ -1973,8 +1970,8 @@ void VBA::updateWindowSize(int value)
|
||||||
winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
|
winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
|
||||||
m_pMainWnd->SetWindowPos(
|
m_pMainWnd->SetWindowPos(
|
||||||
0, //HWND_TOPMOST,
|
0, //HWND_TOPMOST,
|
||||||
theApp.windowPositionX,
|
windowPositionX,
|
||||||
theApp.windowPositionY,
|
windowPositionY,
|
||||||
winSizeX,
|
winSizeX,
|
||||||
winSizeY,
|
winSizeY,
|
||||||
SWP_NOMOVE | SWP_SHOWWINDOW);
|
SWP_NOMOVE | SWP_SHOWWINDOW);
|
||||||
|
@ -2523,7 +2520,7 @@ void VBA::saveSettings()
|
||||||
|
|
||||||
regSetDwordValue("useBiosGB", useBiosFileGB);
|
regSetDwordValue("useBiosGB", useBiosFileGB);
|
||||||
|
|
||||||
regSetDwordValue("skipBios", skipBiosFile);
|
regSetDwordValue("skipBios", skipBios);
|
||||||
|
|
||||||
if(!biosFileNameGBA.IsEmpty())
|
if(!biosFileNameGBA.IsEmpty())
|
||||||
regSetStringValue("biosFileGBA", biosFileNameGBA);
|
regSetStringValue("biosFileGBA", biosFileNameGBA);
|
||||||
|
@ -2565,7 +2562,7 @@ void VBA::saveSettings()
|
||||||
|
|
||||||
regSetDwordValue("disableMMX", disableMMX);
|
regSetDwordValue("disableMMX", disableMMX);
|
||||||
|
|
||||||
regSetDwordValue("disableStatus", disableStatusMessage);
|
regSetDwordValue("disableStatus", disableStatusMessages);
|
||||||
|
|
||||||
regSetDwordValue("showSpeed", showSpeed);
|
regSetDwordValue("showSpeed", showSpeed);
|
||||||
|
|
||||||
|
@ -2581,7 +2578,7 @@ void VBA::saveSettings()
|
||||||
|
|
||||||
regSetDwordValue("disableSfx", cpuDisableSfx);
|
regSetDwordValue("disableSfx", cpuDisableSfx);
|
||||||
|
|
||||||
regSetDwordValue("saveType", winSaveType);
|
regSetDwordValue("saveType", saveType);
|
||||||
|
|
||||||
regSetDwordValue("ifbType", ifbType);
|
regSetDwordValue("ifbType", ifbType);
|
||||||
|
|
||||||
|
@ -2589,7 +2586,7 @@ void VBA::saveSettings()
|
||||||
|
|
||||||
regSetDwordValue("agbPrint", agbPrintIsEnabled());
|
regSetDwordValue("agbPrint", agbPrintIsEnabled());
|
||||||
|
|
||||||
regSetDwordValue("rtcEnabled", winRtcEnable);
|
regSetDwordValue("rtcEnabled", rtcEnabled);
|
||||||
|
|
||||||
regSetDwordValue("borderOn", winGbBorderOn);
|
regSetDwordValue("borderOn", winGbBorderOn);
|
||||||
regSetDwordValue("borderAutomatic", gbBorderAutomatic);
|
regSetDwordValue("borderAutomatic", gbBorderAutomatic);
|
||||||
|
@ -2699,7 +2696,7 @@ void Sm60FPS_Init()
|
||||||
|
|
||||||
bool Sm60FPS_CanSkipFrame()
|
bool Sm60FPS_CanSkipFrame()
|
||||||
{
|
{
|
||||||
if( theApp.autoFrameSkip ) {
|
if( autoFrameSkip ) {
|
||||||
if( Sm60FPS::nFrameCnt == 0 ) {
|
if( Sm60FPS::nFrameCnt == 0 ) {
|
||||||
Sm60FPS::nFrameCnt = 0;
|
Sm60FPS::nFrameCnt = 0;
|
||||||
Sm60FPS::dwTimeElapse = 0;
|
Sm60FPS::dwTimeElapse = 0;
|
||||||
|
@ -2746,7 +2743,7 @@ bool Sm60FPS_CanSkipFrame()
|
||||||
|
|
||||||
void Sm60FPS_Sleep()
|
void Sm60FPS_Sleep()
|
||||||
{
|
{
|
||||||
if( theApp.autoFrameSkip ) {
|
if( autoFrameSkip ) {
|
||||||
u32 dwTimePass = Sm60FPS::dwTimeElapse + (GetTickCount() - Sm60FPS::dwTime0);
|
u32 dwTimePass = Sm60FPS::dwTimeElapse + (GetTickCount() - Sm60FPS::dwTime0);
|
||||||
u32 dwTimeShould = (u32)(Sm60FPS::nFrameCnt * Sm60FPS::K_fDT);
|
u32 dwTimeShould = (u32)(Sm60FPS::nFrameCnt * Sm60FPS::K_fDT);
|
||||||
if (dwTimeShould > dwTimePass && !gba_joybus_active) {
|
if (dwTimeShould > dwTimePass && !gba_joybus_active) {
|
||||||
|
|
142
src/win32/VBA.h
142
src/win32/VBA.h
|
@ -11,6 +11,7 @@
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "IUpdate.h"
|
#include "IUpdate.h"
|
||||||
#include "../System.h"
|
#include "../System.h"
|
||||||
|
#include "common/ConfigManager.h"
|
||||||
#include "../Util.h"
|
#include "../Util.h"
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -63,75 +64,40 @@ class VBA : public CWinApp
|
||||||
CMenu m_menu;
|
CMenu m_menu;
|
||||||
HMENU menu;
|
HMENU menu;
|
||||||
HMENU popup;
|
HMENU popup;
|
||||||
unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect
|
|
||||||
int windowPositionX;
|
AVIWrite *aviRecorder;
|
||||||
int windowPositionY;
|
|
||||||
void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int);
|
char *rewindMemory;
|
||||||
void (*ifbFunction)(u8*,u32,int,int);
|
|
||||||
int ifbType;
|
|
||||||
int filterType;
|
|
||||||
char pluginName[MAX_PATH];
|
char pluginName[MAX_PATH];
|
||||||
int filterWidth;
|
CString aviRecordName;
|
||||||
int filterHeight;
|
CString biosFileNameGB;
|
||||||
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 biosFileNameGBA;
|
CString biosFileNameGBA;
|
||||||
CString biosFileNameGBC;
|
CString biosFileNameGBC;
|
||||||
CString biosFileNameGB;
|
CString languageName;
|
||||||
bool active;
|
CString linkHostAddr;
|
||||||
bool paused;
|
|
||||||
CString recentFiles[10];
|
CString recentFiles[10];
|
||||||
bool recentFreeze;
|
CString screenMessageBuffer;
|
||||||
bool autoSaveLoadCheatList;
|
CString soundRecordName;
|
||||||
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;
|
|
||||||
DISPLAY_TYPE renderMethod;
|
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;
|
AUDIO_API audioAPI;
|
||||||
#ifndef NO_OAL
|
#ifndef NO_OAL
|
||||||
TCHAR *oalDevice;
|
TCHAR *oalDevice;
|
||||||
|
@ -147,46 +113,7 @@ class VBA : public CWinApp
|
||||||
bool d3dMotionBlur;
|
bool d3dMotionBlur;
|
||||||
#endif
|
#endif
|
||||||
bool iconic;
|
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;
|
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;
|
int romSize;
|
||||||
VIDEO_SIZE lastWindowed;
|
VIDEO_SIZE lastWindowed;
|
||||||
VIDEO_SIZE lastFullscreen;
|
VIDEO_SIZE lastFullscreen;
|
||||||
|
@ -211,15 +138,6 @@ class VBA : public CWinApp
|
||||||
|
|
||||||
CString wndClass;
|
CString wndClass;
|
||||||
|
|
||||||
int linkTimeout;
|
|
||||||
int linkMode;
|
|
||||||
CString linkHostAddr;
|
|
||||||
BOOL linkAuto;
|
|
||||||
BOOL linkHacks;
|
|
||||||
int linkNumPlayers;
|
|
||||||
|
|
||||||
int gdbPort;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VBA();
|
VBA();
|
||||||
~VBA();
|
~VBA();
|
||||||
|
|
|
@ -451,7 +451,7 @@ void XAudio2_Output::write(u16 * finalWave, int length)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
// the maximum number of buffers is currently queued
|
// 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
|
// wait for one buffer to finish playing
|
||||||
if (WaitForSingleObject( notify.hBufferEndEvent, 10000 ) == WAIT_TIMEOUT) {
|
if (WaitForSingleObject( notify.hBufferEndEvent, 10000 ) == WAIT_TIMEOUT) {
|
||||||
device_changed = true;
|
device_changed = true;
|
||||||
|
|
|
@ -16,6 +16,7 @@ extern "C" {
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../gb/gbPrinter.h"
|
#include "../gb/gbPrinter.h"
|
||||||
#include "../gba/agbprint.h"
|
#include "../gba/agbprint.h"
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <wx/tokenzr.h>
|
#include <wx/tokenzr.h>
|
||||||
#include "wx/checkedlistctrl.h"
|
#include "wx/checkedlistctrl.h"
|
||||||
#include <wx/progdlg.h>
|
#include <wx/progdlg.h>
|
||||||
|
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../gba/CheatSearch.h"
|
#include "../gba/CheatSearch.h"
|
||||||
|
|
||||||
// The program icon, in case it's missing from .xrc (MSW gets it from .rc file)
|
// 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++) { \
|
for(int i = 0; i < checkable_mi.size(); i++) { \
|
||||||
if(checkable_mi[i].cmd != id) \
|
if(checkable_mi[i].cmd != id) \
|
||||||
continue; \
|
continue; \
|
||||||
checkable_mi[i].boolopt = &f; \
|
checkable_mi[i].boolopt = (bool*)&f; \
|
||||||
checkable_mi[i].mi->Check(f); \
|
checkable_mi[i].mi->Check(f); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "wxvbam.h"
|
#include "wxvbam.h"
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../common/SoundDriver.h"
|
#include "../common/SoundDriver.h"
|
||||||
|
|
||||||
// OpenAL
|
// OpenAL
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "wxvbam.h"
|
#include "wxvbam.h"
|
||||||
#include "drawing.h"
|
#include "drawing.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../gba/RTC.h"
|
#include "../gba/RTC.h"
|
||||||
#include "../gba/agbprint.h"
|
#include "../gba/agbprint.h"
|
||||||
#include "../gb/gbPrinter.h"
|
#include "../gb/gbPrinter.h"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include "wxvbam.h"
|
#include "wxvbam.h"
|
||||||
|
#include "../common/ConfigManager.h"
|
||||||
#include "../common/SoundSDL.h"
|
#include "../common/SoundSDL.h"
|
||||||
#include <wx/ffile.h>
|
#include <wx/ffile.h>
|
||||||
#include <wx/print.h>
|
#include <wx/print.h>
|
||||||
|
@ -99,7 +100,6 @@ wxFFile game_file;
|
||||||
bool game_recording, game_playback;
|
bool game_recording, game_playback;
|
||||||
u32 game_frame;
|
u32 game_frame;
|
||||||
u32 game_joypad;
|
u32 game_joypad;
|
||||||
int sunBars = 500;
|
|
||||||
|
|
||||||
void systemStartGameRecording(const wxString &fname)
|
void systemStartGameRecording(const wxString &fname)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "wx/sdljoy.h"
|
#include "wx/sdljoy.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <SDL2/SDL_joystick.h>
|
#include <SDL/SDL_joystick.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
DEFINE_EVENT_TYPE(wxEVT_SDLJOY)
|
DEFINE_EVENT_TYPE(wxEVT_SDLJOY)
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
// The built-in vba-over.ini
|
// The built-in vba-over.ini
|
||||||
#include "builtin-over.h"
|
#include "builtin-over.h"
|
||||||
|
|
||||||
|
int systemDebug = 0;
|
||||||
|
|
||||||
IMPLEMENT_APP(wxvbamApp)
|
IMPLEMENT_APP(wxvbamApp)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(MainFrame, wxFrame)
|
IMPLEMENT_DYNAMIC_CLASS(MainFrame, wxFrame)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue