Created a common configuration system.

This commit is contained in:
skidau 2015-04-18 06:53:55 +00:00
parent 0e3d8a841d
commit 5a9015b3f0
63 changed files with 4056 additions and 1520 deletions

View File

@ -185,6 +185,9 @@ add_subdirectory (fex)
SET(SRC_MAIN
src/Util.cpp
src/common/ConfigManager.cpp
src/common/dictionary.c
src/common/iniparser.c
src/common/Patch.cpp
src/common/memgzio.c
src/common/SoundSDL.cpp

View File

@ -242,6 +242,7 @@
<ResourceCompile Include="..\..\src\win32\VBA.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c" />
<ClCompile Include="..\..\src\filters\2xSaI.cpp">
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</WholeProgramOptimization>
</ClCompile>

View File

@ -535,6 +535,9 @@
<ClCompile Include="..\..\src\win32\LinkOptions.cpp">
<Filter>MFC</Filter>
</ClCompile>
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c">
<Filter>Main</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<NASM Include="..\..\src\filters\2xSaImmx.asm">

View File

@ -150,6 +150,9 @@
</BuildLog>
</ItemDefinitionGroup>
<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\gbCheats.h" />
<ClInclude Include="..\..\src\gb\gbCodes.h" />
@ -201,6 +204,9 @@
<None Include="..\..\doc\ReadMe.MFC.txt" />
</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\gbCheats.cpp" />
<ClCompile Include="..\..\src\gb\gbDis.cpp" />

View File

@ -156,6 +156,15 @@
<ClInclude Include="..\..\src\gba\GBASockClient.h">
<Filter>Linking</Filter>
</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>
<None Include="..\..\doc\DevInfo.txt">
@ -313,5 +322,14 @@
<ClCompile Include="..\..\src\gba\GBASockClient.cpp">
<Filter>Linking</Filter>
</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>
</Project>

View File

@ -249,6 +249,7 @@
<ResourceCompile Include="..\..\src\win32\VBA.rc" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c" />
<ClCompile Include="..\..\src\filters\2xSaI.cpp">
<WholeProgramOptimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</WholeProgramOptimization>
</ClCompile>

View File

@ -535,6 +535,9 @@
<ClCompile Include="..\..\src\win32\LinkOptions.cpp">
<Filter>MFC</Filter>
</ClCompile>
<ClCompile Include="..\..\..\dependencies\msvc\getopt.c">
<Filter>Main</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<NASM Include="..\..\src\filters\2xSaImmx.asm">

View File

@ -156,6 +156,9 @@
</BuildLog>
</ItemDefinitionGroup>
<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\gbCheats.h" />
<ClInclude Include="..\..\src\gb\gbCodes.h" />
@ -207,6 +210,9 @@
<None Include="..\..\doc\ReadMe.MFC.txt" />
</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\gbCheats.cpp" />
<ClCompile Include="..\..\src\gb\gbDis.cpp" />

View File

@ -156,6 +156,15 @@
<ClInclude Include="..\..\src\gba\GBASockClient.h">
<Filter>Linking</Filter>
</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>
<None Include="..\..\doc\DevInfo.txt">
@ -313,5 +322,14 @@
<ClCompile Include="..\..\src\gba\GBASockClient.cpp">
<Filter>Linking</Filter>
</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>
</Project>

1349
src/common/ConfigManager.cpp Normal file

File diff suppressed because it is too large Load Diff

175
src/common/ConfigManager.h Normal file
View File

@ -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

View File

@ -16,9 +16,10 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "SoundSDL.h"
#include "ConfigManager.h"
#include "../gba/Globals.h"
extern int emulating;
extern bool speedup;
// Hold up to 100 ms of data in the ring buffer
const float SoundSDL::_delay = 0.1f;
@ -44,7 +45,7 @@ void SoundSDL::read(u16 * stream, int length)
/* since this is running in a different thread, speedup and
* throttle can change at any time; save the value so locks
* stay in sync */
bool lock = (emulating && !speedup) ? true : false;
bool lock = (emulating && !speedup && synchronize && !gba_joybus_active) ? true : false;
if (lock)
SDL_SemWait (_semBufferFull);
@ -73,7 +74,7 @@ void SoundSDL::write(u16 * finalWave, int length)
std::size_t avail;
while ((avail = _rbuf.avail() / 2) < samples)
{
bool lock = (emulating && !speedup) ? true : false;
bool lock = (emulating && !speedup && synchronize && !gba_joybus_active) ? true : false;
_rbuf.write(finalWave, avail * 2);

398
src/common/dictionary.c Normal file
View File

@ -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 */

165
src/common/dictionary.h Normal file
View File

@ -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

748
src/common/iniparser.c Normal file
View File

@ -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 */

307
src/common/iniparser.h Normal file
View File

@ -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

View File

@ -15,13 +15,13 @@
#include "gbSound.h"
#include "../Util.h"
#include "../gba/GBALink.h"
#include "../common/ConfigManager.h"
#ifdef __GNUC__
#define _stricmp strcasecmp
#endif
extern u8 *pix;
extern bool speedup;
bool gbUpdateSizes();
bool inBios = false;

View File

@ -10,14 +10,13 @@
#include "gbCheats.h"
#include "gbGlobals.h"
#include "gb.h"
#include "../common/ConfigManager.h"
gbCheat gbCheatList[100];
int gbCheatNumber = 0;
int gbNextCheat = 0;
bool gbCheatMap[0x10000];
extern bool cheatsEnabled;
#define GBCHEAT_IS_HEX(a) ( ((a)>='A' && (a) <='F') || ((a) >='0' && (a) <= '9'))
#define GBCHEAT_HEX_VALUE(a) ( (a) >= 'A' ? (a) - 'A' + 10 : (a) - '0')

View File

@ -7,11 +7,7 @@ extern int gbRamSize;
extern int gbRamSizeMask;
extern int gbTAMA5ramSize;
extern bool useBios;
extern bool skipBios;
extern u8 *bios;
extern bool skipSaveGameBattery;
extern bool skipSaveGameCheats;
extern u8 *gbRom;
extern u8 *gbRam;

View File

@ -18,6 +18,7 @@
#include "elf.h"
#include "../Util.h"
#include "../System.h"
#include "../common/ConfigManager.h"
#include "agbprint.h"
#include "remote.h"

View File

@ -21,6 +21,7 @@
#include "elf.h"
#include "../Util.h"
#include "../System.h"
#include "../common/ConfigManager.h"
#include "agbprint.h"
#include "remote.h"

View File

@ -22,6 +22,7 @@
#include "elf.h"
#include "../Util.h"
#include "../common/Port.h"
#include "../common/ConfigManager.h"
#include "../System.h"
#include "agbprint.h"
#include "ereader.h"

View File

@ -17,23 +17,6 @@ bool armIrqEnable = true;
u32 armNextPC = 0x00000000;
int armMode = 0x1f;
u32 stop = 0x08000568;
int saveType = 0;
bool useBios = false;
bool skipBios = false;
int frameSkip = 1;
bool speedup = false;
bool synchronize = true;
bool cpuDisableSfx = false;
bool cpuIsMultiBoot = false;
bool parseDebug = true;
int layerSettings = 0xff00;
int layerEnable = 0xff00;
bool speedHack = false;
int cpuSaveType = 0;
bool cheatsEnabled = true;
bool mirroringEnable = true;
bool skipSaveGameBattery = false;
bool skipSaveGameCheats = false;
// this is an optional hack to change the backdrop/background color:
// -1: disabled

View File

@ -28,24 +28,12 @@ extern u32 armNextPC;
extern int armMode;
extern u32 stop;
extern int saveType;
extern bool useBios;
extern bool skipBios;
extern int frameSkip;
extern bool speedup;
extern bool synchronize;
extern bool gba_joybus_enabled;
extern bool gba_joybus_active;
extern bool cpuDisableSfx;
extern bool cpuIsMultiBoot;
extern bool parseDebug;
extern int layerSettings;
extern int layerEnable;
extern bool speedHack;
extern int cpuSaveType;
extern bool cheatsEnabled;
extern bool mirroringEnable;
extern bool skipSaveGameBattery; // skip battery data when reading save states
extern bool skipSaveGameCheats; // skip cheat list data when reading save states
extern int customBackdropColor;
extern u8 *bios;

View File

@ -27,6 +27,8 @@
#include "window.h"
#include "intl.h"
int systemDebug = 0;
int main(int argc, char * argv[])
{
bool bShowVersion = false;

View File

@ -27,6 +27,7 @@
#include <SDL.h>
#include "../common/ConfigManager.h"
#include "../gba/GBA.h"
#include "../gba/RTC.h"
#include "../gba/Sound.h"

View File

@ -25,6 +25,7 @@
#include <SDL.h>
#include "../common/ConfigManager.h"
#include "../gba/GBA.h"
#include "../gba/Sound.h"
#include "../gb/gb.h"

File diff suppressed because it is too large Load Diff

View File

@ -180,7 +180,7 @@ const IFBFilterDesc IFBFilters[] = {
{ "Smart interframe blending", SmartIB, SmartIB32 }
};
IFBFilterFunc initIFBFilter(const IFBFilter f, const int colorDepth)
IFBFilterFunc initIFBFilter(const int f, const int colorDepth)
{
IFBFilterFunc func;

View File

@ -53,7 +53,7 @@ enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter };
typedef void(*IFBFilterFunc)(u8*, u32, int, int);
// 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
char* getIFBFilterName(const IFBFilter f);

View File

@ -16,6 +16,7 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "inputSDL.h"
#include "../common/ConfigManager.h"
#define SDLBUTTONS_NUM 14
@ -51,10 +52,7 @@ static SDL_Joystick **sdlDevices = NULL;
static EPad sdlDefaultJoypad = PAD_MAIN;
static int autoFire = 0;
static bool autoFireToggle = false;
static int autoFireCountdown = 0;
int autoFireMaxCount = 1;
static uint32_t joypad[5][SDLBUTTONS_NUM] = {
{ 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
};
static int sensorX = 2047;
static int sensorY = 2047;
static uint32_t sdlGetHatCode(const SDL_Event &event)
{

View File

@ -166,21 +166,21 @@ void Direct3DDisplay::prepareDisplayMode()
{
// Change display mode
memset(&dpp, 0, sizeof(dpp));
dpp.Windowed = !( theApp.videoOption >= VIDEO_320x240 );
dpp.Windowed = !( videoOption >= VIDEO_320x240 );
if( !dpp.Windowed ) {
dpp.BackBufferFormat = (theApp.fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
dpp.BackBufferFormat = (fsColorDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5;
} else {
dpp.BackBufferFormat = mode.Format;
}
dpp.BackBufferCount = theApp.tripleBuffering ? 2 : 1;
dpp.BackBufferCount = tripleBuffering ? 2 : 1;
dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
dpp.BackBufferWidth = !dpp.Windowed ? theApp.fsWidth : theApp.surfaceSizeX;
dpp.BackBufferHeight = !dpp.Windowed ? theApp.fsHeight : theApp.surfaceSizeY;
dpp.BackBufferWidth = !dpp.Windowed ? fsWidth : surfaceSizeX;
dpp.BackBufferHeight = !dpp.Windowed ? fsHeight : surfaceSizeY;
dpp.hDeviceWindow = theApp.m_pMainWnd->GetSafeHwnd();
dpp.FullScreen_RefreshRateInHz = ( dpp.Windowed == TRUE ) ? 0 : theApp.fsFrequency;
dpp.FullScreen_RefreshRateInHz = ( dpp.Windowed == TRUE ) ? 0 : fsFrequency;
dpp.Flags = 0;
dpp.PresentationInterval = (theApp.vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
dpp.PresentationInterval = (vsync && !gba_joybus_active) ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
// D3DPRESENT_INTERVAL_ONE means VSync ON
@ -244,7 +244,7 @@ bool Direct3DDisplay::initialize()
return false;
}
pD3D->GetAdapterDisplayMode(theApp.fsAdapter, &mode);
pD3D->GetAdapterDisplayMode(fsAdapter, &mode);
screenFormat = mode.Format;
switch(mode.Format) {
@ -273,12 +273,12 @@ bool Direct3DDisplay::initialize()
DXTRACE_ERR_MSGBOX( _T("Unsupport D3D format"), 0 );
return false;
}
theApp.fsColorDepth = systemColorDepth;
fsColorDepth = systemColorDepth;
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
#ifdef MMX
if(!theApp.disableMMX) {
if(!disableMMX) {
cpu_mmx = theApp.detectMMX();
} else {
cpu_mmx = 0;
@ -295,7 +295,7 @@ bool Direct3DDisplay::initialize()
prepareDisplayMode();
HRESULT hret = pD3D->CreateDevice(
theApp.fsAdapter,
fsAdapter,
D3DDEVTYPE_HAL,
theApp.m_pMainWnd->GetSafeHwnd(),
D3DCREATE_FPU_PRESERVE |
@ -388,16 +388,16 @@ void Direct3DDisplay::render()
DXTRACE_ERR_MSGBOX( _T("Can not lock texture"), hr );
return;
} else {
u32 pitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
u32 pitch = sizeX * ( systemColorDepth >> 3 ) + 4;
if( theApp.filterFunction ) {
if( theApp.filterMT ) {
if( filterMT ) {
u8 *start = pix + pitch;
int src_height_per_thread = theApp.sizeY / nThreads;
int src_height_remaining = theApp.sizeY - ( ( theApp.sizeY / nThreads ) * nThreads );
int src_height_per_thread = sizeY / nThreads;
int src_height_remaining = sizeY - ( ( sizeY / nThreads ) * nThreads );
u32 src_bytes_per_thread = pitch * src_height_per_thread;
int dst_height_per_thread = src_height_per_thread * theApp.filterMagnification;
int dst_height_per_thread = src_height_per_thread * filterMagnification;
u32 dst_bytes_per_thread = lr.Pitch * dst_height_per_thread;
unsigned int i = nThreads - 1;
@ -414,7 +414,7 @@ void Direct3DDisplay::render()
pfthread_data[i].deltaPointer = (u8*)theApp.delta; // TODO: check if thread-safe
pfthread_data[i].destPointer = ( (u8*)lr.pBits ) + ( i * dst_bytes_per_thread );
pfthread_data[i].destPitch = lr.Pitch;
pfthread_data[i].width = theApp.sizeX;
pfthread_data[i].width = sizeX;
if( i == ( nThreads - 1 ) ) {
// last thread
@ -454,8 +454,8 @@ void Direct3DDisplay::render()
(u8*)theApp.delta,
(u8*)lr.pBits,
lr.Pitch,
theApp.sizeX,
theApp.sizeY
sizeX,
sizeY
);
}
} else {
@ -468,8 +468,8 @@ void Direct3DDisplay::render()
lr.Pitch,
pix + pitch,
pitch,
theApp.sizeX,
theApp.sizeY
sizeX,
sizeY
);
break;
case 16:
@ -478,8 +478,8 @@ void Direct3DDisplay::render()
lr.Pitch,
pix + pitch,
pitch,
theApp.sizeX,
theApp.sizeY
sizeX,
sizeY
);
break;
}
@ -524,24 +524,24 @@ void Direct3DDisplay::render()
r.right = dpp.BackBufferWidth - 1;
r.bottom = dpp.BackBufferHeight - 1;
if( theApp.showSpeed && ( theApp.videoOption > VIDEO_6X ) ) {
color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
if( showSpeed && ( videoOption > VIDEO_6X ) ) {
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0x00, 0x00, 0xFF) : D3DCOLOR_ARGB(0xFF, 0x00, 0x00, 0xFF);
char buffer[30];
if( theApp.showSpeed == 1 ) {
if( showSpeed == 1 ) {
sprintf( buffer, "%3d%%", systemSpeed );
} else {
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, theApp.showRenderedFrames );
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames );
}
pFont->DrawText( NULL, buffer, -1, &r, DT_CENTER | DT_TOP, color );
}
if( theApp.screenMessage ) {
color = theApp.showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.disableStatusMessage && pFont ) {
if( screenMessage ) {
color = showSpeedTransparent ? D3DCOLOR_ARGB(0x7F, 0xFF, 0x00, 0x00) : D3DCOLOR_ARGB(0xFF, 0xFF, 0x00, 0x00);
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages && pFont ) {
pFont->DrawText( NULL, theApp.screenMessageBuffer, -1, &r, DT_CENTER | DT_BOTTOM, color );
} else {
theApp.screenMessage = false;
screenMessage = false;
}
}
@ -576,7 +576,7 @@ void Direct3DDisplay::resize( int w, int h )
if( (w != dpp.BackBufferWidth) ||
(h != dpp.BackBufferHeight) ||
(theApp.videoOption > VIDEO_6X) ) {
(videoOption > VIDEO_6X) ) {
resetDevice();
calculateDestRect();
}
@ -761,7 +761,7 @@ void Direct3DDisplay::destroyTexture()
void Direct3DDisplay::calculateDestRect()
{
if( theApp.fullScreenStretch ) {
if( fullScreenStretch ) {
rectangleFillsScreen = true; // no clear() necessary
destRect.left = 0;
destRect.top = 0;
@ -772,8 +772,8 @@ void Direct3DDisplay::calculateDestRect()
float scaleX = (float)dpp.BackBufferWidth / (float)width;
float scaleY = (float)dpp.BackBufferHeight / (float)height;
float min = (scaleX < scaleY) ? scaleX : scaleY;
if( theApp.maxScale && (min > theApp.maxScale) ) {
min = (float)theApp.maxScale;
if( maxScale && (min > maxScale) ) {
min = (float)maxScale;
}
destRect.left = 0;
destRect.top = 0;

View File

@ -621,7 +621,7 @@ bool DirectInput::readDevices()
u32 DirectInput::readDevice(int which)
{
u32 res = 0;
int i = theApp.joypadDefault;
int i = joypadDefault;
if(which >= 0 && which <= 3)
i = which;
@ -649,11 +649,11 @@ u32 DirectInput::readDevice(int which)
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_GS)]))
res |= 4096;
if(theApp.autoFire) {
res &= (~theApp.autoFire);
if(theApp.autoFireToggle)
res |= theApp.autoFire;
theApp.autoFireToggle = !theApp.autoFireToggle;
if(autoFire) {
res &= (~autoFire);
if(autoFireToggle)
res |= autoFire;
autoFireToggle = !autoFireToggle;
}
// disallow L+R or U+D of being pressed at the same time
@ -662,24 +662,24 @@ u32 DirectInput::readDevice(int which)
if((res & 192) == 192)
res &= ~128;
if(theApp.movieRecording) {
if(i == theApp.joypadDefault) {
if(res != theApp.movieLastJoypad) {
fwrite(&theApp.movieFrame, 1, sizeof(theApp.movieFrame), theApp.movieFile);
if(movieRecording) {
if(i == joypadDefault) {
if(res != movieLastJoypad) {
fwrite(&movieFrame, 1, sizeof(movieFrame), theApp.movieFile);
fwrite(&res, 1, sizeof(res), theApp.movieFile);
theApp.movieLastJoypad = res;
movieLastJoypad = res;
}
}
}
if(theApp.moviePlaying) {
if(theApp.movieFrame == theApp.moviePlayFrame) {
theApp.movieLastJoypad = theApp.movieNextJoypad;
if(moviePlaying) {
if(movieFrame == moviePlayFrame) {
movieLastJoypad = movieNextJoypad;
theApp.movieReadNext();
}
res = theApp.movieLastJoypad;
res = movieLastJoypad;
}
// we don't record speed up or screen capture buttons
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]) || theApp.speedupToggle)
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_SPEED)]) || speedupToggle)
res |= 1024;
if(checkKey(theApp.input->joypaddata[JOYPAD(i,KEY_BUTTON_CAPTURE)]))
res |= 2048;
@ -751,55 +751,55 @@ void DirectInput::checkKeys()
void DirectInput::checkMotionKeys()
{
if(checkKey(theApp.input->joypaddata[MOTION(KEY_LEFT)])) {
theApp.sunBars--;
if (theApp.sunBars < 1)
theApp.sunBars = 1;
sunBars--;
if (sunBars < 1)
sunBars = 1;
theApp.sensorX += 3;
if(theApp.sensorX > 2197)
theApp.sensorX = 2197;
if(theApp.sensorX < 2047)
theApp.sensorX = 2057;
sensorX += 3;
if(sensorX > 2197)
sensorX = 2197;
if(sensorX < 2047)
sensorX = 2057;
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_RIGHT)])) {
theApp.sunBars++;
if (theApp.sunBars > 100)
theApp.sunBars = 100;
sunBars++;
if (sunBars > 100)
sunBars = 100;
theApp.sensorX -= 3;
if(theApp.sensorX < 1897)
theApp.sensorX = 1897;
if(theApp.sensorX > 2047)
theApp.sensorX = 2037;
} else if(theApp.sensorX > 2047) {
theApp.sensorX -= 2;
if(theApp.sensorX < 2047)
theApp.sensorX = 2047;
sensorX -= 3;
if(sensorX < 1897)
sensorX = 1897;
if(sensorX > 2047)
sensorX = 2037;
} else if(sensorX > 2047) {
sensorX -= 2;
if(sensorX < 2047)
sensorX = 2047;
} else {
theApp.sensorX += 2;
if(theApp.sensorX > 2047)
theApp.sensorX = 2047;
sensorX += 2;
if(sensorX > 2047)
sensorX = 2047;
}
if(checkKey(theApp.input->joypaddata[MOTION(KEY_UP)])) {
theApp.sensorY += 3;
if(theApp.sensorY > 2197)
theApp.sensorY = 2197;
if(theApp.sensorY < 2047)
theApp.sensorY = 2057;
sensorY += 3;
if(sensorY > 2197)
sensorY = 2197;
if(sensorY < 2047)
sensorY = 2057;
} else if(checkKey(theApp.input->joypaddata[MOTION(KEY_DOWN)])) {
theApp.sensorY -= 3;
if(theApp.sensorY < 1897)
theApp.sensorY = 1897;
if(theApp.sensorY > 2047)
theApp.sensorY = 2037;
} else if(theApp.sensorY > 2047) {
theApp.sensorY -= 2;
if(theApp.sensorY < 2047)
theApp.sensorY = 2047;
sensorY -= 3;
if(sensorY < 1897)
sensorY = 1897;
if(sensorY > 2047)
sensorY = 2037;
} else if(sensorY > 2047) {
sensorY -= 2;
if(sensorY < 2047)
sensorY = 2047;
} else {
theApp.sensorY += 2;
if(theApp.sensorY > 2047)
theApp.sensorY = 2047;
sensorY += 2;
if(sensorY > 2047)
sensorY = 2047;
}
}

View File

@ -117,7 +117,7 @@ bool DirectSound::init(long sampleRate)
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_PRIMARYBUFFER;
if( theApp.dsoundDisableHardwareAcceleration ) {
if( dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
@ -151,7 +151,7 @@ bool DirectSound::init(long sampleRate)
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
if( theApp.dsoundDisableHardwareAcceleration ) {
if( dsoundDisableHardwareAcceleration ) {
dsbdesc.dwFlags |= DSBCAPS_LOCSOFTWARE;
}
dsbdesc.dwBufferBytes = soundBufferTotalLen;
@ -240,7 +240,7 @@ void DirectSound::write(u16 * finalWave, int length)
LPVOID lpvPtr2;
DWORD dwBytes2 = 0;
if( !speedup && synchronize && !theApp.throttle && !gba_joybus_active) {
if( !speedup && synchronize && !throttle && !gba_joybus_active) {
hr = dsbSecondary->GetStatus(&status);
if( status & DSBSTATUS_PLAYING ) {
if( !soundPaused ) {

View File

@ -102,7 +102,7 @@ FileDlg::FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter,
*p++ = 0;
m_ofn.lpstrFilter = m_filter;
if(theApp.videoOption == VIDEO_320x240) {
if(videoOption == VIDEO_320x240) {
m_ofn.lpTemplateName = MAKEINTRESOURCE(IDD_OPENDLG);
m_ofn.lpfnHook = HookFuncOldStyle;
m_ofn.Flags |= OFN_ENABLETEMPLATE;

View File

@ -236,7 +236,7 @@ void GBMapView::OnSave()
{
CString filename;
if(theApp.captureFormat == 0)
if(captureFormat == 0)
filename = "map.png";
else
filename = "map.bmp";
@ -248,8 +248,8 @@ void GBMapView::OnSave()
FileDlg dlg(this,
filename,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,

View File

@ -367,7 +367,7 @@ void GBOamView::save()
{
CString captureBuffer;
if(theApp.captureFormat == 0)
if(captureFormat == 0)
captureBuffer = "oam.png";
else
captureBuffer = "oam.bmp";
@ -380,8 +380,8 @@ void GBOamView::save()
FileDlg dlg(this,
captureBuffer,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,

View File

@ -243,7 +243,7 @@ void GBPrinterDlg::OnSave()
{
CString captureBuffer;
if(theApp.captureFormat == 0)
if(captureFormat == 0)
captureBuffer = "printer.png";
else
captureBuffer = "printer.bmp";
@ -256,8 +256,8 @@ void GBPrinterDlg::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,

View File

@ -242,7 +242,7 @@ void GBTileView::OnSave()
{
CString captureBuffer;
if(theApp.captureFormat == 0)
if(captureFormat == 0)
captureBuffer = "tiles.png";
else
captureBuffer = "tiles.bmp";
@ -255,8 +255,8 @@ void GBTileView::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,
@ -268,7 +268,7 @@ void GBTileView::OnSave()
captureBuffer = dlg.GetPathName();
if(theApp.captureFormat)
if(captureFormat)
saveBMP(captureBuffer);
else
savePNG(captureBuffer);

View File

@ -24,10 +24,10 @@ GDBPortDlg::GDBPortDlg(CWnd* pParent /*=NULL*/)
//{{AFX_DATA_INIT(GDBPortDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
if (theApp.gdbPort == 0)
if (gdbPort == 0)
port = 55555;
else
port = theApp.gdbPort;
port = gdbPort;
sock = INVALID_SOCKET;
if(!initialized) {
@ -100,7 +100,7 @@ void GDBPortDlg::OnOk()
address.sin_port = htons(atoi(buffer));
port = ntohs(address.sin_port);
theApp.gdbPort = port;
gdbPort = port;
EndDialog(TRUE);
}

View File

@ -42,7 +42,7 @@ LinkOptions::LinkOptions(CWnd* pParent /*=NULL*/)
: CDialog(LinkOptions::IDD, pParent)
{
//{{AFX_DATA_INIT(LinkOptions)
m_type = theApp.linkMode;
m_type = linkMode;
m_server = FALSE;
//}}AFX_DATA_INIT
}
@ -54,11 +54,11 @@ void LinkOptions::DoDataExchange(CDataExchange* pDX)
//{{AFX_DATA_MAP(LinkOptions)
DDX_CBData(pDX, IDC_LINK_MODE, m_type);
DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout);
DDX_Check(pDX, IDC_AUTOLINK, theApp.linkAuto);
DDX_Check(pDX, IDC_SSPEED, theApp.linkHacks);
DDX_Check(pDX, IDC_AUTOLINK, linkAuto);
DDX_Check(pDX, IDC_SSPEED, linkHacks);
DDX_Control(pDX, IDC_LINK_MODE, m_mode);
DDX_Control(pDX, IDC_SERVERIP, m_serverip);
DDX_Radio(pDX, IDC_LINK2P, theApp.linkNumPlayers);
DDX_Radio(pDX, IDC_LINK2P, linkNumPlayers);
DDX_Radio(pDX, IDC_LINK_CLIENT, m_server);
//}}AFX_DATA_MAP
}
@ -76,19 +76,19 @@ BOOL LinkOptions::OnInitDialog(){
AddMode("Wireless adapter - Network", LINK_RFU_SOCKET);
AddMode("Game Link (Game Boy) - Single Computer", LINK_GAMEBOY);
sprintf(timeout, "%d", theApp.linkTimeout);
sprintf(timeout, "%d", linkTimeout);
m_timeout.LimitText(5);
m_timeout.SetWindowText(timeout);
m_serverip.SetWindowText(theApp.linkHostAddr);
CheckDlgButton(IDC_AUTOLINK, theApp.linkAuto);
CheckDlgButton(IDC_AUTOLINK, linkAuto);
CheckDlgButton(IDC_SSPEED, theApp.linkHacks);
CheckDlgButton(IDC_SSPEED, linkHacks);
int player_radio = 0;
switch (theApp.linkNumPlayers)
switch (linkNumPlayers)
{
case 2:
player_radio = IDC_LINK2P;
@ -156,8 +156,8 @@ void LinkOptions::OnOk()
LinkMode newMode = (LinkMode) m_type;
if (newMode == LINK_DISCONNECTED) {
theApp.linkTimeout = timeout;
theApp.linkMode = LINK_DISCONNECTED;
linkTimeout = timeout;
linkMode = LINK_DISCONNECTED;
theApp.linkHostAddr = host;
CDialog::OnOK();
return;
@ -173,8 +173,8 @@ void LinkOptions::OnOk()
}
}
EnableSpeedHacks(theApp.linkHacks);
EnableLinkServer(m_server, theApp.linkNumPlayers + 1);
EnableSpeedHacks(linkHacks);
EnableLinkServer(m_server, linkNumPlayers + 1);
if (m_server) {
char localhost[length];
@ -239,8 +239,8 @@ void LinkOptions::OnOk()
return;
}
theApp.linkTimeout = timeout;
theApp.linkMode = GetLinkMode();
linkTimeout = timeout;
linkMode = GetLinkMode();
theApp.linkHostAddr = host;
CDialog::OnOK();

View File

@ -421,7 +421,7 @@ bool MainWnd::FileRun()
{
// save battery file before we change the filename...
if(rom != NULL || gbRom != NULL) {
if(theApp.autoSaveLoadCheatList)
if(autoSaveLoadCheatList)
winSaveCheatListDefault();
writeBatteryFile();
cheatSearchCleanup(&cheatSearchData);
@ -488,30 +488,29 @@ bool MainWnd::FileRun()
gbGetHardwareType();
// used for the handling of the gb Boot Rom
skipBios = theApp.skipBiosFile;
if (gbHardware & 5)
{
gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
gbCPUInit(theApp.biosFileNameGB, useBiosFileGB);
}
else if (gbHardware & 2)
{
gbCPUInit(theApp.biosFileNameGBC, theApp.useBiosFileGBC);
gbCPUInit(theApp.biosFileNameGBC, useBiosFileGBC);
}
gbReset();
theApp.emulator = GBSystem;
gbBorderOn = theApp.winGbBorderOn;
theApp.romSize = gbRomSize;
gbBorderOn = winGbBorderOn;
theApp.romSize = gbRomSize;
if(theApp.autoPatch && !patchName.IsEmpty()) {
if(autoPatch && !patchName.IsEmpty()) {
int size = gbRomSize;
applyPatch(patchName, &gbRom, &size);
if(size != gbRomSize) {
extern bool gbUpdateSizes();
gbUpdateSizes();
gbReset();
theApp.romSize = size;
theApp.romSize = size;
}
}
} else {
@ -519,11 +518,11 @@ bool MainWnd::FileRun()
if(!size)
return false;
theApp.romSize = size;
theApp.romSize = size;
flashSetSize(theApp.winFlashSize);
rtcEnable(theApp.winRtcEnable);
cpuSaveType = theApp.winSaveType;
flashSetSize(winFlashSize);
rtcEnable(rtcEnabled);
cpuSaveType = saveType;
if (cpuSaveType == 0)
utilGBAFindSave(theApp.romSize);
@ -569,7 +568,7 @@ bool MainWnd::FileRun()
theApp.emulator = GBASystem;
if(theApp.autoPatch && !patchName.IsEmpty()) {
if(autoPatch && !patchName.IsEmpty()) {
int size = 0x2000000;
applyPatch(patchName, &rom, &size);
if(size != 0x2000000) {
@ -585,7 +584,7 @@ bool MainWnd::FileRun()
soundReset();
} else {
soundInit();
theApp.soundInitialized = true;
theApp.soundInitialized = true;
}
#ifdef APU_LOGGER_H
@ -593,42 +592,41 @@ bool MainWnd::FileRun()
#endif
if(type == IMAGE_GBA) {
skipBios = theApp.skipBiosFile;
CPUInit(theApp.biosFileNameGBA.GetString(), theApp.useBiosFileGBA);
CPUInit(theApp.biosFileNameGBA.GetString(), useBiosFileGBA);
CPUReset();
}
readBatteryFile();
if(theApp.autoSaveLoadCheatList)
if(autoSaveLoadCheatList)
winLoadCheatListDefault();
theApp.addRecentFile(theApp.szFile);
theApp.updateWindowSize(theApp.videoOption);
theApp.updateWindowSize(videoOption);
theApp.updateFrameSkip();
emulating = true;
if(theApp.autoLoadMostRecent)
if(autoLoadMostRecent)
OnFileLoadgameMostrecent();
theApp.frameskipadjust = 0;
theApp.renderedFrames = 0;
theApp.autoFrameSkipLastTime = systemGetClock();
frameskipadjust = 0;
renderedFrames = 0;
autoFrameSkipLastTime = systemGetClock();
theApp.rewindCount = 0;
theApp.rewindCounter = 0;
theApp.rewindSaveNeeded = false;
rewindCount = 0;
rewindCounter = 0;
rewindSaveNeeded = false;
toolsClearLog();
#ifndef NO_LINK
if (theApp.linkAuto)
BootLink(theApp.linkMode, theApp.linkHostAddr, theApp.linkTimeout, theApp.linkHacks, theApp.linkNumPlayers);
if (linkAuto)
BootLink(linkMode, theApp.linkHostAddr, linkTimeout, linkHacks, linkNumPlayers);
#endif
if (theApp.gdbBreakOnLoad)
if (gdbBreakOnLoad)
OnToolsDebugBreak();
return true;
@ -722,11 +720,11 @@ void MainWnd::OnMove(int x, int y)
RECT r;
GetWindowRect(&r);
theApp.windowPositionX = r.left;
theApp.windowPositionY = r.top;
windowPositionX = r.left;
windowPositionY = r.top;
theApp.adjustDestRect();
regSetDwordValue("windowX", theApp.windowPositionX);
regSetDwordValue("windowY", theApp.windowPositionY);
regSetDwordValue("windowX", windowPositionX);
regSetDwordValue("windowY", windowPositionY);
}
}
}
@ -742,7 +740,7 @@ void MainWnd::OnSizing(UINT fwSide, LPRECT pRect)
}
// maintain minimal window size
RECT size = { 0, 0, theApp.sizeX, theApp.sizeY };
RECT size = { 0, 0, sizeX, sizeY };
AdjustWindowRectEx(
&size,
WS_POPUP | WS_VISIBLE | WS_OVERLAPPEDWINDOW,
@ -767,7 +765,7 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
{
CWnd::OnSize(nType, cx, cy);
bool redraw = ( ( cx < theApp.surfaceSizeX ) || ( cy < theApp.surfaceSizeY ) );
bool redraw = ( ( cx < surfaceSizeX ) || ( cy < surfaceSizeY ) );
if(!theApp.changingVideoSize) {
if(this) {
@ -775,12 +773,12 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
if(theApp.iconic) {
if(emulating) {
soundResume();
theApp.paused = false;
paused = false;
}
}
if(theApp.videoOption <= VIDEO_6X) {
theApp.surfaceSizeX = cx;
theApp.surfaceSizeY = cy;
if(videoOption <= VIDEO_6X) {
surfaceSizeX = cx;
surfaceSizeY = cy;
theApp.adjustDestRect();
if(theApp.display)
theApp.display->resize(theApp.dest.right-theApp.dest.left, theApp.dest.bottom-theApp.dest.top);
@ -788,17 +786,17 @@ void MainWnd::OnSize(UINT nType, int cx, int cy)
theApp.painting = true;
systemDrawScreen();
theApp.painting = false;
theApp.renderedFrames--;
renderedFrames--;
}
}
} else {
if(emulating) {
if(!theApp.paused) {
theApp.paused = true;
if(!paused) {
paused = true;
soundPause();
}
}
theApp.iconic = true;
theApp.iconic = true;
}
}
}
@ -1151,8 +1149,8 @@ void MainWnd::OnPaint()
if(emulating) {
theApp.painting = true;
systemDrawScreen();
theApp.painting = false;
theApp.renderedFrames--;
theApp.painting = false;
renderedFrames--;
}
}
@ -1196,7 +1194,7 @@ void MainWnd::screenCapture(int captureNumber)
captureDir = getDirFromFile(theApp.filename);
LPCTSTR ext = "png";
if(theApp.captureFormat != 0)
if(captureFormat != 0)
ext = "bmp";
if(isDriveRoot(captureDir))
@ -1219,7 +1217,7 @@ void MainWnd::screenCapture(int captureNumber)
return;
}
if(theApp.captureFormat == 0)
if(captureFormat == 0)
theApp.emulator.emuWritePNG(buffer);
else
theApp.emulator.emuWriteBMP(buffer);
@ -1231,10 +1229,10 @@ void MainWnd::screenCapture(int captureNumber)
void MainWnd::winMouseOn()
{
SetCursor(arrow);
if(theApp.videoOption > VIDEO_6X) {
theApp.mouseCounter = 10;
if(videoOption > VIDEO_6X) {
mouseCounter = 10;
} else
theApp.mouseCounter = 0;
mouseCounter = 0;
}
void MainWnd::OnMouseMove(UINT nFlags, CPoint point)
@ -1258,29 +1256,29 @@ void MainWnd::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
bool a = (nState == WA_ACTIVE) || (nState == WA_CLICKACTIVE);
if(a && theApp.input) {
theApp.active = a;
active = a;
theApp.input->activate();
if(!theApp.paused && emulating) {
if(!paused && emulating) {
soundResume();
}
} else {
theApp.wasPaused = true;
if(theApp.pauseWhenInactive && !gba_joybus_active) {
wasPaused = true;
if(pauseWhenInactive && !gba_joybus_active) {
if(emulating) {
soundPause();
}
theApp.active = a;
active = a;
}
memset(theApp.delta,255,sizeof(theApp.delta));
}
if(theApp.paused && emulating)
if(paused && emulating)
{
theApp.painting = true;
systemDrawScreen();
theApp.painting = false;
theApp.renderedFrames--;
renderedFrames--;
}
}
@ -1306,7 +1304,7 @@ void MainWnd::OnDropFiles(HDROP hDropInfo)
LRESULT MainWnd::OnMySysCommand(WPARAM wParam, LPARAM lParam)
{
if(emulating && !theApp.paused) {
if(emulating && !paused) {
if((wParam&0xFFF0) == SC_SCREENSAVE || (wParam&0xFFF0) == SC_MONITORPOWER)
return 0;
}

View File

@ -47,12 +47,12 @@ void MainWnd::OnUpdateCheatsCheatlist(CCmdUI* pCmdUI)
void MainWnd::OnCheatsAutomaticsaveloadcheats()
{
theApp.autoSaveLoadCheatList = !theApp.autoSaveLoadCheatList;
autoSaveLoadCheatList = !autoSaveLoadCheatList;
}
void MainWnd::OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.autoSaveLoadCheatList);
pCmdUI->SetCheck(autoSaveLoadCheatList);
}
void MainWnd::OnCheatsLoadcheatlist()

View File

@ -48,10 +48,10 @@ void MainWnd::OnFileOpenGB()
void MainWnd::OnFilePause()
{
theApp.paused = !theApp.paused;
paused = !paused;
if(emulating) {
if(theApp.paused) {
theApp.wasPaused = true;
if(paused) {
wasPaused = true;
soundPause();
} else {
soundResume();
@ -61,20 +61,19 @@ void MainWnd::OnFilePause()
void MainWnd::OnUpdateFilePause(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.paused);
pCmdUI->SetCheck(paused);
}
void MainWnd::OnFileReset()
{
skipBios = theApp.skipBiosFile;
if(emulating) {
if(theApp.cartridgeType == IMAGE_GB) {
gbGetHardwareType();
if (gbHardware & 5) {
gbCPUInit(theApp.biosFileNameGB, theApp.useBiosFileGB);
gbCPUInit(theApp.biosFileNameGB, useBiosFileGB);
} else if (gbHardware & 2) {
gbCPUInit(theApp.biosFileNameGBC, theApp.useBiosFileGBC);
gbCPUInit(theApp.biosFileNameGBC, useBiosFileGBC);
}
}
theApp.emulator.emuReset();
@ -89,7 +88,7 @@ void MainWnd::OnUpdateFileReset(CCmdUI* pCmdUI)
void MainWnd::OnUpdateFileRecentFreeze(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.recentFreeze);
pCmdUI->SetCheck(recentFreeze);
if(pCmdUI->m_pMenu == NULL)
return;
@ -139,7 +138,7 @@ void MainWnd::OnFileRecentReset()
void MainWnd::OnFileRecentFreeze()
{
theApp.recentFreeze = !theApp.recentFreeze;
recentFreeze = !recentFreeze;
}
void MainWnd::OnFileExit()
@ -151,7 +150,7 @@ void MainWnd::OnFileClose()
{
// save battery file before we change the filename...
if(rom != NULL || gbRom != NULL) {
if(theApp.autoSaveLoadCheatList)
if(autoSaveLoadCheatList)
winSaveCheatListDefault();
writeBatteryFile();
soundPause();
@ -209,9 +208,9 @@ void MainWnd::OnFileLoad()
if(dlg.DoModal() == IDOK) {
bool res = loadSaveGame(dlg.GetPathName());
theApp.rewindCount = 0;
theApp.rewindCounter = 0;
theApp.rewindSaveNeeded = false;
rewindCount = 0;
rewindCounter = 0;
rewindSaveNeeded = false;
if(res)
systemScreenMessage(winResLoadString(IDS_LOADED_STATE));
@ -262,16 +261,13 @@ BOOL MainWnd::OnFileLoadSlot(UINT nID)
bool res = loadSaveGame(filename);
if (theApp.paused)
if (paused)
InterframeCleanup();
systemScreenMessage(buffer);
systemDrawScreen();
//theApp.rewindCount = 0;
//theApp.rewindCounter = 0;
//theApp.rewindSaveNeeded = false;
return res;
}
@ -628,7 +624,7 @@ void MainWnd::OnFileScreencapture()
CString ext = "png";
if(theApp.captureFormat != 0)
if(captureFormat != 0)
ext = "bmp";
if(isDriveRoot(capdir))
@ -644,8 +640,8 @@ void MainWnd::OnFileScreencapture()
FileDlg dlg(this,
filename,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
capdir,
title,
@ -686,7 +682,7 @@ void MainWnd::OnUpdateFileRominformation(CCmdUI* pCmdUI)
//OnFileToggleFullscreen
void MainWnd::OnFileTogglemenu()
{
if( theApp.videoOption <= VIDEO_6X ) {
if( videoOption <= VIDEO_6X ) {
// switch to full screen
toolsLoggingClose(); // close log dialog
theApp.updateWindowSize( theApp.lastFullscreen );
@ -699,7 +695,7 @@ void MainWnd::OnFileTogglemenu()
void MainWnd::OnUpdateFileTogglemenu(CCmdUI* pCmdUI)
{
// HACK: when uncommented, Esc key will not be send to MainWnd
//pCmdUI->Enable(theApp.videoOption > VIDEO_6X);
//pCmdUI->Enable(videoOption > VIDEO_6X);
}
bool MainWnd::fileImportGSACodeFile(CString& fileName)
@ -977,12 +973,12 @@ void MainWnd::OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI)
void MainWnd::OnFileLoadgameAutoloadmostrecent()
{
theApp.autoLoadMostRecent = !theApp.autoLoadMostRecent;
autoLoadMostRecent = !autoLoadMostRecent;
}
void MainWnd::OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.autoLoadMostRecent);
pCmdUI->SetCheck(autoLoadMostRecent);
}
void MainWnd::OnLoadgameDonotchangebatterysave()

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ void MainWnd::OnToolsDisassemble()
void MainWnd::OnUpdateToolsDisassemble(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsLogging()
@ -65,7 +65,7 @@ void MainWnd::OnToolsLogging()
void MainWnd::OnUpdateToolsLogging(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsIoviewer()
@ -77,7 +77,7 @@ void MainWnd::OnToolsIoviewer()
void MainWnd::OnUpdateToolsIoviewer(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && theApp.cartridgeType == 0);
pCmdUI->Enable(videoOption <= VIDEO_6X && theApp.cartridgeType == 0);
}
void MainWnd::OnToolsMapview()
@ -95,7 +95,7 @@ void MainWnd::OnToolsMapview()
void MainWnd::OnUpdateToolsMapview(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsMemoryviewer()
@ -113,7 +113,7 @@ void MainWnd::OnToolsMemoryviewer()
void MainWnd::OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsOamviewer()
@ -131,7 +131,7 @@ void MainWnd::OnToolsOamviewer()
void MainWnd::OnUpdateToolsOamviewer(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsPaletteview()
@ -149,7 +149,7 @@ void MainWnd::OnToolsPaletteview()
void MainWnd::OnUpdateToolsPaletteview(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnToolsTileviewer()
@ -167,14 +167,14 @@ void MainWnd::OnToolsTileviewer()
void MainWnd::OnUpdateToolsTileviewer(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X);
pCmdUI->Enable(videoOption <= VIDEO_6X);
}
void MainWnd::OnDebugNextframe()
{
if(theApp.paused)
theApp.paused = false;
theApp.winPauseNextFrame = true;
if(paused)
paused = false;
winPauseNextFrame = true;
}
void MainWnd::OnToolsDebugConfigurePort()
@ -191,19 +191,19 @@ void MainWnd::OnUpdateToolsDebugConfigurePort(CCmdUI* pCmdUI)
void MainWnd::OnToolsDebugBreakOnLoad()
{
theApp.gdbBreakOnLoad = !theApp.gdbBreakOnLoad;
gdbBreakOnLoad = !gdbBreakOnLoad;
}
void MainWnd::OnUpdateToolsDebugBreakOnLoad(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(theApp.gdbBreakOnLoad);
pCmdUI->SetCheck(gdbBreakOnLoad);
}
void MainWnd::OnToolsDebugBreak()
{
GDBPortDlg dlg;
int port = theApp.gdbPort;
int port = gdbPort;
if (port == 0)
{
if (dlg.DoModal()) {
@ -238,7 +238,7 @@ void MainWnd::OnToolsDebugBreak()
void MainWnd::OnUpdateToolsDebugBreak(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && emulating != 0);
pCmdUI->Enable(videoOption <= VIDEO_6X && emulating != 0);
}
void MainWnd::OnToolsDebugDisconnect()
@ -249,7 +249,7 @@ void MainWnd::OnToolsDebugDisconnect()
void MainWnd::OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption <= VIDEO_6X && remoteSocket != -1);
pCmdUI->Enable(videoOption <= VIDEO_6X && remoteSocket != -1);
}
void MainWnd::OnOptionsSoundStartrecording()
@ -273,7 +273,7 @@ void MainWnd::OnOptionsSoundStartrecording()
}
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
theApp.soundRecording = true;
soundRecording = true;
if(dlg.m_ofn.nFileOffset > 0) {
captureBuffer = captureBuffer.Left(dlg.m_ofn.nFileOffset);
@ -288,7 +288,7 @@ void MainWnd::OnOptionsSoundStartrecording()
void MainWnd::OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!theApp.soundRecording);
pCmdUI->Enable(!soundRecording);
}
void MainWnd::OnOptionsSoundStoprecording()
@ -297,12 +297,12 @@ void MainWnd::OnOptionsSoundStoprecording()
delete theApp.soundRecorder;
theApp.soundRecorder = NULL;
}
theApp.soundRecording = false;
soundRecording = false;
}
void MainWnd::OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.soundRecording);
pCmdUI->Enable(soundRecording);
}
@ -328,7 +328,7 @@ void MainWnd::OnToolsRecordStartavirecording()
captureBuffer = theApp.soundRecordName = dlg.GetPathName();
theApp.aviRecordName = captureBuffer;
theApp.aviRecording = true;
aviRecording = true;
if( dlg.m_ofn.nFileOffset > 0 ) {
captureBuffer = captureBuffer.Left( dlg.m_ofn.nFileOffset );
@ -358,14 +358,14 @@ void MainWnd::OnToolsRecordStartavirecording()
systemMessage( IDS_AVI_CANNOT_CREATE_AVI, "Cannot create AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviRecording = false;
aviRecording = false;
return;
}
// add video stream
ret = theApp.aviRecorder->CreateVideoStream(
theApp.sizeX,
theApp.sizeY,
sizeX,
sizeY,
( systemColorDepth == 32 ) ? 24 : 16,
60,
this->GetSafeHwnd()
@ -374,7 +374,7 @@ void MainWnd::OnToolsRecordStartavirecording()
systemMessage( IDS_AVI_CANNOT_CREATE_VIDEO, "Cannot create video stream in AVI file. Make sure the selected codec supports input in RGB24 color space!" );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviRecording = false;
aviRecording = false;
return;
}
@ -389,7 +389,7 @@ void MainWnd::OnToolsRecordStartavirecording()
systemMessage( IDS_AVI_CANNOT_CREATE_AUDIO, "Cannot create audio stream in AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviRecording = false;
aviRecording = false;
return;
}
}
@ -397,7 +397,7 @@ void MainWnd::OnToolsRecordStartavirecording()
void MainWnd::OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI)
{
pCmdUI->Enable( !theApp.aviRecording && emulating );
pCmdUI->Enable( !aviRecording && emulating );
}
@ -407,13 +407,13 @@ void MainWnd::OnToolsRecordStopavirecording()
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
}
theApp.aviRecording = false;
aviRecording = false;
}
void MainWnd::OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI)
{
pCmdUI->Enable( theApp.aviRecording );
pCmdUI->Enable( aviRecording );
}
void MainWnd::OnToolsRecordStartmovierecording()
@ -464,10 +464,10 @@ void MainWnd::OnToolsRecordStartmovierecording()
movieName = movieName.Left(movieName.GetLength()-3) + "VM0";
if(writeSaveGame(movieName)) {
theApp.movieFrame = 0;
theApp.movieLastJoypad = 0;
theApp.movieRecording = true;
theApp.moviePlaying = false;
movieFrame = 0;
movieLastJoypad = 0;
movieRecording = true;
moviePlaying = false;
} else {
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
(const char *)movieName);
@ -476,29 +476,29 @@ void MainWnd::OnToolsRecordStartmovierecording()
void MainWnd::OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!theApp.movieRecording && emulating);
pCmdUI->Enable(!movieRecording && emulating);
}
void MainWnd::OnToolsRecordStopmovierecording()
{
if(theApp.movieRecording) {
if(movieRecording) {
if(theApp.movieFile != NULL) {
// record the last joypad change so that the correct time can be
// recorded
fwrite(&theApp.movieFrame, 1, sizeof(int), theApp.movieFile);
fwrite(&theApp.movieLastJoypad, 1, sizeof(u32), theApp.movieFile);
fwrite(&movieFrame, 1, sizeof(int), theApp.movieFile);
fwrite(&movieLastJoypad, 1, sizeof(u32), theApp.movieFile);
fclose(theApp.movieFile);
theApp.movieFile = NULL;
}
theApp.movieRecording = false;
theApp.moviePlaying = false;
theApp.movieLastJoypad = 0;
movieRecording = false;
moviePlaying = false;
movieLastJoypad = 0;
}
}
void MainWnd::OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.movieRecording);
pCmdUI->Enable(movieRecording);
}
void MainWnd::OnToolsPlayStartmovieplaying()
@ -554,10 +554,10 @@ void MainWnd::OnToolsPlayStartmovieplaying()
}
movieName = movieName.Left(movieName.GetLength()-3)+"VM0";
if(loadSaveGame(movieName)) {
theApp.moviePlaying = true;
theApp.movieFrame = 0;
theApp.moviePlayFrame = 0;
theApp.movieLastJoypad = 0;
moviePlaying = true;
movieFrame = 0;
moviePlayFrame = 0;
movieLastJoypad = 0;
theApp.movieReadNext();
} else {
systemMessage(IDS_CANNOT_OPEN_FILE, "Cannot open file %s",
@ -567,39 +567,39 @@ void MainWnd::OnToolsPlayStartmovieplaying()
void MainWnd::OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!theApp.moviePlaying && emulating);
pCmdUI->Enable(!moviePlaying && emulating);
}
void MainWnd::OnToolsPlayStopmovieplaying()
{
if(theApp.moviePlaying) {
if(moviePlaying) {
if(theApp.movieFile != NULL) {
fclose(theApp.movieFile);
theApp.movieFile = NULL;
}
theApp.moviePlaying = false;
theApp.movieLastJoypad = 0;
moviePlaying = false;
movieLastJoypad = 0;
}
}
void MainWnd::OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.moviePlaying);
pCmdUI->Enable(moviePlaying);
}
void MainWnd::OnToolsRewind()
{
if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && theApp.rewindCount) {
theApp.rewindPos = --theApp.rewindPos & 7;
theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*theApp.rewindPos], REWIND_SIZE);
theApp.rewindCount--;
theApp.rewindCounter = 0;
if(emulating && theApp.emulator.emuReadMemState && theApp.rewindMemory && rewindCount) {
rewindPos = --rewindPos & 7;
theApp.emulator.emuReadMemState(&theApp.rewindMemory[REWIND_SIZE*rewindPos], REWIND_SIZE);
rewindCount--;
rewindCounter = 0;
}
}
void MainWnd::OnUpdateToolsRewind(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && theApp.rewindCount);
pCmdUI->Enable(theApp.rewindMemory != NULL && emulating && rewindCount);
}
void MainWnd::OnToolsCustomize()
@ -616,5 +616,5 @@ void MainWnd::OnToolsCustomize()
void MainWnd::OnUpdateToolsCustomize(CCmdUI* pCmdUI)
{
pCmdUI->Enable(theApp.videoOption != VIDEO_320x240);
pCmdUI->Enable(videoOption != VIDEO_320x240);
}

View File

@ -966,7 +966,7 @@ void MapView::OnSave()
{
CString filename;
if(theApp.captureFormat == 0)
if(captureFormat == 0)
filename = "map.png";
else
filename = "map.bmp";
@ -979,8 +979,8 @@ void MapView::OnSave()
FileDlg dlg(this,
filename,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,

View File

@ -49,7 +49,7 @@ void MaxScale::OnOk()
{
CString tmp;
m_value.GetWindowText(tmp);
theApp.maxScale = atoi(tmp);
maxScale = atoi(tmp);
EndDialog(TRUE);
}
@ -59,7 +59,7 @@ BOOL MaxScale::OnInitDialog()
CString temp;
temp.Format("%d", theApp.maxScale);
temp.Format("%d", maxScale);
m_value.SetWindowText(temp);

View File

@ -549,7 +549,7 @@ void OamView::OnSave()
{
CString captureBuffer;
if (theApp.captureFormat == 0)
if (captureFormat == 0)
captureBuffer = "oam.png";
else
captureBuffer = "oam.bmp";
@ -562,8 +562,8 @@ void OamView::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,

View File

@ -2,7 +2,7 @@
//#define LOGALL
#include "stdafx.h"
#include "VBA.h" // for 'theApp.throttle'
#include "VBA.h" // for 'throttle'
#ifndef NO_OAL
@ -273,7 +273,7 @@ void OpenAL::write(u16 * finalWave, int length)
if( nBuffersProcessed == theApp.oalBufferCount ) {
// we only want to know about it when we are emulating at full speed or faster:
if( ( theApp.throttle >= 100 ) || ( theApp.throttle == 0 ) ) {
if( ( throttle >= 100 ) || ( throttle == 0 ) ) {
if( systemVerbose & VERBOSE_SOUNDOUTPUT ) {
static unsigned int i = 0;
log( "OpenAL: Buffers were not refilled fast enough (i=%i)\n", i++ );
@ -281,7 +281,7 @@ void OpenAL::write(u16 * finalWave, int length)
}
}
if( !speedup && synchronize && !theApp.throttle && !gba_joybus_active) {
if( !speedup && synchronize && !throttle && !gba_joybus_active) {
// wait until at least one buffer has finished
while( nBuffersProcessed == 0 ) {
winlog( " waiting...\n" );

View File

@ -192,49 +192,49 @@ bool OpenGLDisplay::initialize()
switch( theApp.cartridgeType )
{
case IMAGE_GBA:
theApp.sizeX = 240;
theApp.sizeY = 160;
sizeX = 240;
sizeY = 160;
break;
case IMAGE_GB:
if ( gbBorderOn )
{
theApp.sizeX = 256;
theApp.sizeY = 224;
sizeX = 256;
sizeY = 224;
}
else
{
theApp.sizeX = 160;
theApp.sizeY = 144;
sizeX = 160;
sizeY = 144;
}
break;
}
switch(theApp.videoOption)
switch(videoOption)
{
case VIDEO_1X:
theApp.surfaceSizeX = theApp.sizeX;
theApp.surfaceSizeY = theApp.sizeY;
surfaceSizeX = sizeX;
surfaceSizeY = sizeY;
break;
case VIDEO_2X:
theApp.surfaceSizeX = theApp.sizeX * 2;
theApp.surfaceSizeY = theApp.sizeY * 2;
surfaceSizeX = sizeX * 2;
surfaceSizeY = sizeY * 2;
break;
case VIDEO_3X:
theApp.surfaceSizeX = theApp.sizeX * 3;
theApp.surfaceSizeY = theApp.sizeY * 3;
surfaceSizeX = sizeX * 3;
surfaceSizeY = sizeY * 3;
break;
case VIDEO_4X:
theApp.surfaceSizeX = theApp.sizeX * 4;
theApp.surfaceSizeY = theApp.sizeY * 4;
surfaceSizeX = sizeX * 4;
surfaceSizeY = sizeY * 4;
break;
case VIDEO_5X:
theApp.surfaceSizeX = theApp.sizeX * 5;
theApp.surfaceSizeY = theApp.sizeY * 5;
surfaceSizeX = sizeX * 5;
surfaceSizeY = sizeY * 5;
break;
case VIDEO_6X:
theApp.surfaceSizeX = theApp.sizeX * 6;
theApp.surfaceSizeY = theApp.sizeY * 6;
surfaceSizeX = sizeX * 6;
surfaceSizeY = sizeY * 6;
break;
case VIDEO_320x240:
case VIDEO_640x480:
@ -243,17 +243,17 @@ bool OpenGLDisplay::initialize()
case VIDEO_1280x1024:
case VIDEO_OTHER:
{
if( theApp.fullScreenStretch ) {
theApp.surfaceSizeX = theApp.fsWidth;
theApp.surfaceSizeY = theApp.fsHeight;
if( fullScreenStretch ) {
surfaceSizeX = fsWidth;
surfaceSizeY = fsHeight;
} else {
float scaleX = (float)theApp.fsWidth / (float)theApp.sizeX;
float scaleY = (float)theApp.fsHeight / (float)theApp.sizeY;
float scaleX = (float)fsWidth / (float)sizeX;
float scaleY = (float)fsHeight / (float)sizeY;
float min = ( scaleX < scaleY ) ? scaleX : scaleY;
if( theApp.maxScale )
min = ( min > (float)theApp.maxScale ) ? (float)theApp.maxScale : min;
theApp.surfaceSizeX = (int)((float)theApp.sizeX * min);
theApp.surfaceSizeY = (int)((float)theApp.sizeY * min);
if( maxScale )
min = ( min > (float)maxScale ) ? (float)maxScale : min;
surfaceSizeX = (int)((float)sizeX * min);
surfaceSizeY = (int)((float)sizeY * min);
}
}
break;
@ -261,23 +261,23 @@ bool OpenGLDisplay::initialize()
theApp.rect.left = 0;
theApp.rect.top = 0;
theApp.rect.right = theApp.sizeX;
theApp.rect.bottom = theApp.sizeY;
theApp.rect.right = sizeX;
theApp.rect.bottom = sizeY;
theApp.dest.left = 0;
theApp.dest.top = 0;
theApp.dest.right = theApp.surfaceSizeX;
theApp.dest.bottom = theApp.surfaceSizeY;
theApp.dest.right = surfaceSizeX;
theApp.dest.bottom = surfaceSizeY;
DWORD style = WS_POPUP | WS_VISIBLE;
DWORD styleEx = 0;
if( theApp.videoOption <= VIDEO_6X )
if( videoOption <= VIDEO_6X )
style |= WS_OVERLAPPEDWINDOW;
else
styleEx = 0;
if( theApp.videoOption <= VIDEO_6X )
if( videoOption <= VIDEO_6X )
AdjustWindowRectEx( &theApp.dest, style, TRUE, styleEx );
else
AdjustWindowRectEx( &theApp.dest, style, FALSE, styleEx );
@ -286,12 +286,12 @@ bool OpenGLDisplay::initialize()
int winSizeY = theApp.dest.bottom - theApp.dest.top;
int x = 0, y = 0;
if( theApp.videoOption <= VIDEO_6X ) {
x = theApp.windowPositionX;
y = theApp.windowPositionY;
if( videoOption <= VIDEO_6X ) {
x = windowPositionX;
y = windowPositionY;
} else {
winSizeX = theApp.fsWidth;
winSizeY = theApp.fsHeight;
winSizeX = fsWidth;
winSizeY = fsHeight;
}
@ -300,20 +300,20 @@ bool OpenGLDisplay::initialize()
theApp.adjustDestRect();
currentAdapter = theApp.fsAdapter;
currentAdapter = fsAdapter;
DISPLAY_DEVICE dev;
ZeroMemory( &dev, sizeof(dev) );
dev.cb = sizeof(dev);
EnumDisplayDevices( NULL, currentAdapter, &dev, 0 );
if( theApp.videoOption >= VIDEO_320x240 ) {
if( videoOption >= VIDEO_320x240 ) {
// enter full screen mode
DEVMODE mode;
ZeroMemory( &mode, sizeof(mode) );
mode.dmSize = sizeof(mode);
mode.dmBitsPerPel = theApp.fsColorDepth;
mode.dmPelsWidth = theApp.fsWidth;
mode.dmPelsHeight = theApp.fsHeight;
mode.dmDisplayFrequency = theApp.fsFrequency;
mode.dmBitsPerPel = fsColorDepth;
mode.dmPelsWidth = fsWidth;
mode.dmPelsHeight = fsHeight;
mode.dmDisplayFrequency = fsFrequency;
mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
LONG ret = ChangeDisplaySettingsEx( dev.DeviceName, &mode, NULL, CDS_FULLSCREEN, NULL );
if( ret != DISP_CHANGE_SUCCESSFUL ) {
@ -334,12 +334,12 @@ bool OpenGLDisplay::initialize()
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
initializeMatrices( theApp.surfaceSizeX, theApp.surfaceSizeY );
initializeMatrices( surfaceSizeX, surfaceSizeY );
setVSync( theApp.vsync && !gba_joybus_active );
setVSync( vsync && !gba_joybus_active );
#ifdef MMX
if(!theApp.disableMMX)
if(!disableMMX)
cpu_mmx = theApp.detectMMX();
else
cpu_mmx = 0;
@ -349,15 +349,15 @@ bool OpenGLDisplay::initialize()
systemGreenShift = 11;
systemBlueShift = 3;
systemColorDepth = 32;
theApp.fsColorDepth = 32;
fsColorDepth = 32;
Init_2xSaI(32);
utilUpdateSystemColorMaps(theApp.cartridgeType == IMAGE_GBA && gbColorOption == 1);
theApp.updateFilter();
theApp.updateIFB();
pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
data = pix + ( theApp.sizeX + 1 ) * 4;
pitch = filterWidth * (systemColorDepth>>3) + 4;
data = pix + ( sizeX + 1 ) * 4;
if(failed)
return false;
@ -377,8 +377,8 @@ void OpenGLDisplay::render()
{
clear();
pitch = theApp.filterWidth * (systemColorDepth>>3) + 4;
data = pix + ( theApp.sizeX + 1 ) * 4;
pitch = filterWidth * (systemColorDepth>>3) + 4;
data = pix + ( sizeX + 1 ) * 4;
// apply pixel filter
if(theApp.filterFunction) {
@ -389,8 +389,8 @@ void OpenGLDisplay::render()
(u8*)theApp.delta,
(u8*)filterData,
width * 4 ,
theApp.filterWidth,
theApp.filterHeight);
filterWidth,
filterHeight);
}
// Texturemap complete texture to surface
@ -399,7 +399,7 @@ void OpenGLDisplay::render()
if( theApp.filterFunction ) {
glPixelStorei( GL_UNPACK_ROW_LENGTH, width);
} else {
glPixelStorei( GL_UNPACK_ROW_LENGTH, theApp.sizeX + 1 );
glPixelStorei( GL_UNPACK_ROW_LENGTH, sizeX + 1 );
}
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_BGRA,GL_UNSIGNED_BYTE,data );
@ -410,49 +410,49 @@ void OpenGLDisplay::render()
glVertex3i( 0, 0, 0 );
glTexCoord2f( (float)(width) / size, 0.0f );
glVertex3i( theApp.surfaceSizeX, 0, 0 );
glVertex3i( surfaceSizeX, 0, 0 );
glTexCoord2f( (float)(width) / size, (float)(height) / size );
glVertex3i( theApp.surfaceSizeX, theApp.surfaceSizeY, 0 );
glVertex3i( surfaceSizeX, surfaceSizeY, 0 );
glTexCoord2f( 0.0f, (float)(height) / size );
glVertex3i( 0, theApp.surfaceSizeY, 0 );
glVertex3i( 0, surfaceSizeY, 0 );
glEnd();
if( theApp.showSpeed ) { // && ( theApp.videoOption > VIDEO_6X ) ) {
if( showSpeed ) { // && ( videoOption > VIDEO_6X ) ) {
char buffer[30];
if( theApp.showSpeed == 1 ) {
if( showSpeed == 1 ) {
sprintf( buffer, "%3d%%", systemSpeed );
} else {
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, theApp.showRenderedFrames );
sprintf( buffer, "%3d%%(%d, %d fps)", systemSpeed, systemFrameSkip, showRenderedFrames );
}
glFontBegin(&font);
glPushMatrix();
float fontscale = (float)theApp.surfaceSizeX / 100.0f;
float fontscale = (float)surfaceSizeX / 100.0f;
glScalef(fontscale, fontscale, fontscale);
glColor4f(1.0f, 0.25f, 0.25f, 1.0f);
glFontTextOut(buffer, (theApp.surfaceSizeX-(strlen(buffer)*11))/(fontscale*2), (theApp.surfaceSizeY-20)/fontscale, 0);
glFontTextOut(buffer, (surfaceSizeX-(strlen(buffer)*11))/(fontscale*2), (surfaceSizeY-20)/fontscale, 0);
glPopMatrix();
glFontEnd();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBindTexture( GL_TEXTURE_2D, texture );
}
if( theApp.screenMessage ) {
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !theApp.disableStatusMessage ) {
if( screenMessage ) {
if( ( ( GetTickCount() - theApp.screenMessageTime ) < 3000 ) && !disableStatusMessages ) {
glFontBegin(&font);
glPushMatrix();
float fontscale = (float)theApp.surfaceSizeX / 100.0f;
float fontscale = (float)surfaceSizeX / 100.0f;
glScalef(fontscale, fontscale, fontscale);
glColor4f(1.0f, 0.25f, 0.25f, 1.0f);
glFontTextOut((char *)((const char *)theApp.screenMessageBuffer), (theApp.surfaceSizeX-(theApp.screenMessageBuffer.GetLength()*11))/(fontscale*2), (theApp.surfaceSizeY-40)/fontscale, 0);
glFontTextOut((char *)((const char *)theApp.screenMessageBuffer), (surfaceSizeX-(theApp.screenMessageBuffer.GetLength()*11))/(fontscale*2), (surfaceSizeY-40)/fontscale, 0);
glPopMatrix();
glFontEnd();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glBindTexture( GL_TEXTURE_2D, texture );
} else {
theApp.screenMessage = false;
screenMessage = false;
}
}
@ -491,7 +491,7 @@ void OpenGLDisplay::updateFiltering( int value )
//init projection matrixes and viewports
void OpenGLDisplay::initializeMatrices( int w, int h )
{
if( theApp.fullScreenStretch ) {
if( fullScreenStretch ) {
glViewport( 0, 0, w, h );
} else {
calculateDestRect( w, h );
@ -542,7 +542,7 @@ bool OpenGLDisplay::initializeTexture( int w, int h )
glGenTextures( 1, &texture );
glBindTexture( GL_TEXTURE_2D, texture );
updateFiltering( theApp.glFilter );
updateFiltering( glFilter );
glTexImage2D(
GL_TEXTURE_2D,
@ -609,8 +609,8 @@ void OpenGLDisplay::calculateDestRect( int w, int h )
float scaleX = (float)w / (float)width;
float scaleY = (float)h / (float)height;
float min = (scaleX < scaleY) ? scaleX : scaleY;
if( theApp.maxScale && (min > theApp.maxScale) ) {
min = (float)theApp.maxScale;
if( maxScale && (min > maxScale) ) {
min = (float)maxScale;
}
destRect.left = 0;
destRect.top = 0;

View File

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "VBA.h"
#include "..\gba\GBALink.h"
#include "..\common\ConfigManager.h"
static char buffer[2048];
static HKEY vbKey = NULL;

View File

@ -248,7 +248,7 @@ void TileView::OnSave()
{
CString captureBuffer;
if(theApp.captureFormat == 0)
if(captureFormat == 0)
captureBuffer = "tiles.png";
else
captureBuffer = "tiles.bmp";
@ -261,8 +261,8 @@ void TileView::OnSave()
FileDlg dlg(this,
captureBuffer,
filter,
theApp.captureFormat ? 2 : 1,
theApp.captureFormat ? "BMP" : "PNG",
captureFormat ? 2 : 1,
captureFormat ? "BMP" : "PNG",
exts,
"",
title,

View File

@ -35,6 +35,7 @@
#include "../gb/gbPrinter.h"
#include "../gb/gbSound.h"
#include "../common/SoundDriver.h"
#include "../common/ConfigManager.h"
#include "../version.h"
@ -206,7 +207,7 @@ VBA::VBA()
windowPositionY = 0;
filterFunction = NULL;
ifbFunction = NULL;
ifbType = 0;
ifbType = kIFBNone;
filterType = FILTER_NONE;
filterWidth = 0;
filterHeight = 0;
@ -223,7 +224,6 @@ VBA::VBA()
sizeY = 0;
videoOption = 0;
fullScreenStretch = false;
disableStatusMessage = false;
showSpeed = 0;
showSpeedTransparent = true;
showRenderedFrames = 0;
@ -237,7 +237,7 @@ VBA::VBA()
useBiosFileGBA = false;
useBiosFileGBC = false;
useBiosFileGB = false;
skipBiosFile = false;
skipBios = false;
biosFileNameGBA = _T("");
biosFileNameGBC = _T("");
biosFileNameGB = _T("");
@ -249,8 +249,8 @@ VBA::VBA()
autoPatch = true;
winGbBorderOn = 0;
winFlashSize = 0x20000;
winRtcEnable = false;
winSaveType = 0;
rtcEnabled = false;
saveType = 0;
rewindMemory = NULL;
rewindPos = 0;
rewindTopPos = 0;
@ -857,8 +857,6 @@ void VBA::updateFilter()
void VBA::updateThrottle( unsigned short throttle )
{
this->throttle = throttle;
if( throttle ) {
Sm60FPS::K_fCpuSpeed = (float)throttle;
Sm60FPS::K_fTargetFps = 60.0f * Sm60FPS::K_fCpuSpeed / 100;
@ -943,7 +941,7 @@ void systemDrawScreen()
if(theApp.display == NULL)
return;
theApp.renderedFrames++;
renderedFrames++;
if(theApp.updateCount) {
POSITION pos = theApp.updateList.GetHeadPosition();
@ -956,38 +954,38 @@ void systemDrawScreen()
if (Sm60FPS_CanSkipFrame())
return;
if( theApp.aviRecording ) {
if( theApp.painting ) {
if( aviRecording ) {
if (theApp.painting) {
theApp.skipAudioFrames++;
} else {
unsigned char *bmp;
unsigned short srcPitch = theApp.sizeX * ( systemColorDepth >> 3 ) + 4;
unsigned short srcPitch = sizeX * ( systemColorDepth >> 3 ) + 4;
switch( systemColorDepth )
{
case 16:
bmp = new unsigned char[ theApp.sizeX * theApp.sizeY * 2 ];
cpyImg16bmp( bmp, pix + srcPitch, srcPitch, theApp.sizeX, theApp.sizeY );
bmp = new unsigned char[ sizeX * sizeY * 2 ];
cpyImg16bmp( bmp, pix + srcPitch, srcPitch, sizeX, sizeY );
break;
case 32:
// use 24 bit colors to reduce video size
bmp = new unsigned char[ theApp.sizeX * theApp.sizeY * 3 ];
cpyImg32bmp( bmp, pix + srcPitch, srcPitch, theApp.sizeX, theApp.sizeY );
bmp = new unsigned char[ sizeX * sizeY * 3 ];
cpyImg32bmp( bmp, pix + srcPitch, srcPitch, sizeX, sizeY );
break;
}
if( false == theApp.aviRecorder->AddVideoFrame( bmp ) ) {
systemMessage( IDS_AVI_CANNOT_WRITE_VIDEO, "Cannot write video frame to AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviRecording = false;
aviRecording = false;
}
delete [] bmp;
}
}
if( theApp.ifbFunction ) {
theApp.ifbFunction( pix + (theApp.filterWidth * (systemColorDepth>>3)) + 4,
(theApp.filterWidth * (systemColorDepth>>3)) + 4,
theApp.filterWidth, theApp.filterHeight );
theApp.ifbFunction( pix + (filterWidth * (systemColorDepth>>3)) + 4,
(filterWidth * (systemColorDepth>>3)) + 4,
filterWidth, filterHeight );
}
if(!soundBufferLow)
@ -1042,16 +1040,16 @@ void systemSetTitle(const char *title)
void systemShowSpeed(int speed)
{
systemSpeed = speed;
theApp.showRenderedFrames = theApp.renderedFrames;
theApp.renderedFrames = 0;
if(theApp.videoOption <= VIDEO_6X && theApp.showSpeed) {
showRenderedFrames = renderedFrames;
renderedFrames = 0;
if(videoOption <= VIDEO_6X && showSpeed) {
CString buffer;
if(theApp.showSpeed == 1)
if(showSpeed == 1)
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%", systemSpeed);
else
buffer.Format(VBA_NAME_AND_SUBVERSION "-%3d%%(%d, %d fps)", systemSpeed,
systemFrameSkip,
theApp.showRenderedFrames);
showRenderedFrames);
systemSetTitle(buffer);
}
@ -1060,8 +1058,8 @@ void systemShowSpeed(int speed)
void systemFrame()
{
if( theApp.movieRecording || theApp.moviePlaying ) {
theApp.movieFrame++;
if( movieRecording || moviePlaying ) {
movieFrame++;
}
#ifdef LOG_PERFORMANCE
@ -1073,11 +1071,11 @@ void systemFrame()
void system10Frames(int rate)
{
if( theApp.autoFrameSkip )
if( autoFrameSkip )
{
u32 time = systemGetClock();
u32 diff = time - theApp.autoFrameSkipLastTime;
theApp.autoFrameSkipLastTime = time;
u32 diff = time - autoFrameSkipLastTime;
autoFrameSkipLastTime = time;
if( diff ) {
// countermeasure against div/0 when debugging
Sm60FPS::nCurSpeed = (1000000/rate)/diff;
@ -1088,9 +1086,9 @@ void system10Frames(int rate)
if(theApp.rewindMemory) {
if(++theApp.rewindCounter >= (theApp.rewindTimer)) {
theApp.rewindSaveNeeded = true;
theApp.rewindCounter = 0;
if(++rewindCounter >= (rewindTimer)) {
rewindSaveNeeded = true;
rewindCounter = 0;
}
}
if(systemSaveUpdateCounter) {
@ -1100,10 +1098,10 @@ void system10Frames(int rate)
}
}
theApp.wasPaused = false;
wasPaused = false;
// Old autoframeskip crap... might be useful later. autoframeskip Ifdef above might be useless as well now
// theApp.autoFrameSkipLastTime = time;
// autoFrameSkipLastTime = time;
#ifdef LOG_PERFORMANCE
if( systemSpeedCounter >= PERFORMANCE_INTERVAL ) {
@ -1121,7 +1119,7 @@ void system10Frames(int rate)
void systemScreenMessage(const char *msg)
{
theApp.screenMessage = true;
screenMessage = true;
theApp.screenMessageTime = GetTickCount();
theApp.screenMessageBuffer = msg;
@ -1132,7 +1130,7 @@ void systemScreenMessage(const char *msg)
void systemUpdateSolarSensor()
{
u8 sun = 0x0; //sun = 0xE8 - 0xE8 (case 0 and default)
int level = theApp.sunBars / 10;
int level = sunBars / 10;
switch (level)
{
case 1:
@ -1198,12 +1196,12 @@ void systemUpdateMotionSensor()
int systemGetSensorX()
{
return theApp.sensorX;
return sensorX;
}
int systemGetSensorY()
{
return theApp.sensorY;
return sensorY;
}
@ -1230,8 +1228,8 @@ SoundDriver * systemSoundInit()
}
if( drv ) {
if (theApp.throttle)
drv->setThrottle( theApp.throttle );
if (throttle)
drv->setThrottle( throttle );
}
return drv;
@ -1244,19 +1242,19 @@ void systemOnSoundShutdown()
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
}
theApp.aviRecording = false;
aviRecording = false;
if( theApp.soundRecorder ) {
delete theApp.soundRecorder;
theApp.soundRecorder = NULL;
}
theApp.soundRecording = false;
soundRecording = false;
}
void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
{
if( theApp.soundRecording ) {
if( soundRecording ) {
if( theApp.soundRecorder ) {
theApp.soundRecorder->AddSound( (const u8 *)finalWave, length );
} else {
@ -1275,7 +1273,7 @@ void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
}
}
if( theApp.aviRecording && theApp.aviRecorder ) {
if( aviRecording && theApp.aviRecorder ) {
if( theApp.skipAudioFrames ) {
theApp.skipAudioFrames--;
} else {
@ -1283,7 +1281,7 @@ void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length)
systemMessage( IDS_AVI_CANNOT_WRITE_AUDIO, "Cannot write audio frame to AVI file." );
delete theApp.aviRecorder;
theApp.aviRecorder = NULL;
theApp.aviRecording = false;
aviRecording = false;
}
}
}
@ -1296,9 +1294,9 @@ bool systemCanChangeSoundQuality()
bool systemPauseOnFrame()
{
if(theApp.winPauseNextFrame) {
theApp.paused = true;
theApp.winPauseNextFrame = false;
if(winPauseNextFrame) {
paused = true;
winPauseNextFrame = false;
return true;
}
return false;
@ -1307,7 +1305,7 @@ bool systemPauseOnFrame()
void systemGbBorderOn()
{
if(emulating && theApp.cartridgeType == IMAGE_GB && gbBorderOn) {
theApp.updateWindowSize(theApp.videoOption);
theApp.updateWindowSize(videoOption);
}
}
@ -1485,7 +1483,7 @@ void VBA::loadSettings()
useBiosFileGB = ( regQueryDwordValue("useBiosGB", 0) == 1 ) ? true : false;
skipBiosFile = regQueryDwordValue("skipBios", 0) ? true : false;
skipBios = regQueryDwordValue("skipBios", 0) ? true : false;
buffer = regQueryStringValue("biosFileGBA", "");
@ -1546,7 +1544,7 @@ void VBA::loadSettings()
disableMMX = regQueryDwordValue("disableMMX", false) ? true: false;
disableStatusMessage = regQueryDwordValue("disableStatus", 0) ? true : false;
disableStatusMessages = regQueryDwordValue("disableStatus", 0) ? true : false;
showSpeed = regQueryDwordValue("showSpeed", 0);
if(showSpeed < 0 || showSpeed > 2)
@ -1576,23 +1574,22 @@ void VBA::loadSettings()
cpuDisableSfx = regQueryDwordValue("disableSfx", 0) ? true : false;
winSaveType = regQueryDwordValue("saveType", 0);
if(winSaveType < 0 || winSaveType > 5)
winSaveType = 0;
saveType = regQueryDwordValue("saveType", 0);
if(saveType < 0 || saveType > 5)
saveType = 0;
ifbType = regQueryDwordValue("ifbType", 0);
ifbType = (IFBFilter)regQueryDwordValue("ifbType", 0);
if(ifbType < 0 || ifbType > 2)
ifbType = 0;
ifbType = kIFBNone;
winFlashSize = regQueryDwordValue("flashSize", 0x10000);
if(winFlashSize != 0x10000 && winFlashSize != 0x20000)
winFlashSize = 0x10000;
flashSize = winFlashSize;
agbPrintEnable(regQueryDwordValue("agbPrint", 0) ? true : false);
winRtcEnable = regQueryDwordValue("rtcEnabled", 0) ? true : false;
rtcEnable(winRtcEnable);
rtcEnabled = regQueryDwordValue("rtcEnabled", 0) ? true : false;
rtcEnable(rtcEnabled);
switch(videoOption) {
case VIDEO_320x240:
@ -1973,8 +1970,8 @@ void VBA::updateWindowSize(int value)
winSizeY += (info.rcBar.bottom - info.rcBar.top) - menuHeight + 1;
m_pMainWnd->SetWindowPos(
0, //HWND_TOPMOST,
theApp.windowPositionX,
theApp.windowPositionY,
windowPositionX,
windowPositionY,
winSizeX,
winSizeY,
SWP_NOMOVE | SWP_SHOWWINDOW);
@ -2523,7 +2520,7 @@ void VBA::saveSettings()
regSetDwordValue("useBiosGB", useBiosFileGB);
regSetDwordValue("skipBios", skipBiosFile);
regSetDwordValue("skipBios", skipBios);
if(!biosFileNameGBA.IsEmpty())
regSetStringValue("biosFileGBA", biosFileNameGBA);
@ -2565,7 +2562,7 @@ void VBA::saveSettings()
regSetDwordValue("disableMMX", disableMMX);
regSetDwordValue("disableStatus", disableStatusMessage);
regSetDwordValue("disableStatus", disableStatusMessages);
regSetDwordValue("showSpeed", showSpeed);
@ -2581,7 +2578,7 @@ void VBA::saveSettings()
regSetDwordValue("disableSfx", cpuDisableSfx);
regSetDwordValue("saveType", winSaveType);
regSetDwordValue("saveType", saveType);
regSetDwordValue("ifbType", ifbType);
@ -2589,7 +2586,7 @@ void VBA::saveSettings()
regSetDwordValue("agbPrint", agbPrintIsEnabled());
regSetDwordValue("rtcEnabled", winRtcEnable);
regSetDwordValue("rtcEnabled", rtcEnabled);
regSetDwordValue("borderOn", winGbBorderOn);
regSetDwordValue("borderAutomatic", gbBorderAutomatic);
@ -2699,7 +2696,7 @@ void Sm60FPS_Init()
bool Sm60FPS_CanSkipFrame()
{
if( theApp.autoFrameSkip ) {
if( autoFrameSkip ) {
if( Sm60FPS::nFrameCnt == 0 ) {
Sm60FPS::nFrameCnt = 0;
Sm60FPS::dwTimeElapse = 0;
@ -2746,7 +2743,7 @@ bool Sm60FPS_CanSkipFrame()
void Sm60FPS_Sleep()
{
if( theApp.autoFrameSkip ) {
if( autoFrameSkip ) {
u32 dwTimePass = Sm60FPS::dwTimeElapse + (GetTickCount() - Sm60FPS::dwTime0);
u32 dwTimeShould = (u32)(Sm60FPS::nFrameCnt * Sm60FPS::K_fDT);
if (dwTimeShould > dwTimePass && !gba_joybus_active) {

View File

@ -11,6 +11,7 @@
#include "Input.h"
#include "IUpdate.h"
#include "../System.h"
#include "common/ConfigManager.h"
#include "../Util.h"
/////////////////////////////////////////////////////////////////////////////
@ -63,75 +64,40 @@ class VBA : public CWinApp
CMenu m_menu;
HMENU menu;
HMENU popup;
unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect
int windowPositionX;
int windowPositionY;
void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int);
void (*ifbFunction)(u8*,u32,int,int);
int ifbType;
int filterType;
AVIWrite *aviRecorder;
char *rewindMemory;
char pluginName[MAX_PATH];
int filterWidth;
int filterHeight;
int filterMagnification;
bool filterMT; // enable multi-threading for pixel filters
int fsWidth;
int fsHeight;
int fsColorDepth;
int fsFrequency;
int fsAdapter;
bool fsForceChange;
int sizeX;
int sizeY;
int surfaceSizeX;
int surfaceSizeY;
int videoOption;
bool fullScreenStretch;
bool disableStatusMessage;
int showSpeed;
BOOL showSpeedTransparent;
int showRenderedFrames;
bool screenMessage;
CString screenMessageBuffer;
DWORD screenMessageTime;
u8 *delta[257*244*4];
IDisplay *display;
IMAGE_TYPE cartridgeType;
bool soundInitialized;
bool useBiosFileGBA;
bool useBiosFileGBC;
bool useBiosFileGB;
bool skipBiosFile;
CString aviRecordName;
CString biosFileNameGB;
CString biosFileNameGBA;
CString biosFileNameGBC;
CString biosFileNameGB;
bool active;
bool paused;
CString languageName;
CString linkHostAddr;
CString recentFiles[10];
bool recentFreeze;
bool autoSaveLoadCheatList;
FILE *winout;
bool autoPatch;
int winGbBorderOn;
int winFlashSize;
bool winRtcEnable;
int winSaveType;
char *rewindMemory;
int rewindPos;
int rewindTopPos;
int rewindCounter;
int rewindCount;
bool rewindSaveNeeded;
int rewindTimer;
bool gdbBreakOnLoad;
int captureFormat;
bool tripleBuffering;
unsigned short throttle;
u32 autoFrameSkipLastTime;
bool autoFrameSkip;
bool vsync;
bool changingVideoSize;
CString screenMessageBuffer;
CString soundRecordName;
DISPLAY_TYPE renderMethod;
DWORD screenMessageTime;
FILE *movieFile;
FILE *winout;
HMODULE languageModule;
IDisplay *display;
IMAGE_TYPE cartridgeType;
bool soundInitialized;
Input *input;
u8 *delta[257 * 244 * 4];
unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect
unsigned int skipAudioFrames;
void(*filterFunction)(u8*, u32, u8*, u8*, u32, int, int);
void(*ifbFunction)(u8*, u32, int, int);
WavWriter *soundRecorder;
bool changingVideoSize;
AUDIO_API audioAPI;
#ifndef NO_OAL
TCHAR *oalDevice;
@ -147,46 +113,7 @@ class VBA : public CWinApp
bool d3dMotionBlur;
#endif
bool iconic;
int glFilter;
bool dinputKeyFocus;
bool pauseWhenInactive;
bool speedupToggle;
bool winGbPrinterEnabled;
int threadPriority;
bool disableMMX;
int languageOption;
CString languageName;
HMODULE languageModule;
int renderedFrames;
Input *input;
int joypadDefault;
int autoFire;
bool autoFireToggle;
bool winPauseNextFrame;
bool soundRecording;
WavWriter *soundRecorder;
CString soundRecordName;
bool dsoundDisableHardwareAcceleration;
bool aviRecording;
AVIWrite *aviRecorder;
CString aviRecordName;
bool painting;
unsigned int skipAudioFrames;
bool movieRecording;
bool moviePlaying;
int movieFrame;
int moviePlayFrame;
FILE *movieFile;
u32 movieLastJoypad;
u32 movieNextJoypad;
int sensorX;
int sensorY;
int sunBars;
int mouseCounter;
bool wasPaused;
int frameskipadjust;
bool autoLoadMostRecent;
int maxScale;
int romSize;
VIDEO_SIZE lastWindowed;
VIDEO_SIZE lastFullscreen;
@ -211,15 +138,6 @@ class VBA : public CWinApp
CString wndClass;
int linkTimeout;
int linkMode;
CString linkHostAddr;
BOOL linkAuto;
BOOL linkHacks;
int linkNumPlayers;
int gdbPort;
public:
VBA();
~VBA();

View File

@ -451,7 +451,7 @@ void XAudio2_Output::write(u16 * finalWave, int length)
break;
} else {
// the maximum number of buffers is currently queued
if( synchronize && !speedup && !theApp.throttle && !gba_joybus_active ) {
if( synchronize && !speedup && !throttle && !gba_joybus_active ) {
// wait for one buffer to finish playing
if (WaitForSingleObject( notify.hBufferEndEvent, 10000 ) == WAIT_TIMEOUT) {
device_changed = true;

View File

@ -16,6 +16,7 @@ extern "C" {
#include <libavformat/avformat.h>
}
#endif
#include "../common/ConfigManager.h"
#include "../gb/gbPrinter.h"
#include "../gba/agbprint.h"

View File

@ -19,6 +19,8 @@
#include <wx/tokenzr.h>
#include "wx/checkedlistctrl.h"
#include <wx/progdlg.h>
#include "../common/ConfigManager.h"
#include "../gba/CheatSearch.h"
// The program icon, in case it's missing from .xrc (MSW gets it from .rc file)
@ -2208,7 +2210,7 @@ bool MainFrame::InitMore(void)
for(int i = 0; i < checkable_mi.size(); i++) { \
if(checkable_mi[i].cmd != id) \
continue; \
checkable_mi[i].boolopt = &f; \
checkable_mi[i].boolopt = (bool*)&f; \
checkable_mi[i].mi->Check(f); \
break; \
} \

View File

@ -8,6 +8,7 @@
#include "wxvbam.h"
// Interface
#include "../common/ConfigManager.h"
#include "../common/SoundDriver.h"
// OpenAL

View File

@ -1,5 +1,6 @@
#include "wxvbam.h"
#include "drawing.h"
#include "../common/ConfigManager.h"
#include "../gba/RTC.h"
#include "../gba/agbprint.h"
#include "../gb/gbPrinter.h"

View File

@ -1,5 +1,6 @@
#include <SDL.h>
#include "wxvbam.h"
#include "../common/ConfigManager.h"
#include "../common/SoundSDL.h"
#include <wx/ffile.h>
#include <wx/print.h>
@ -99,7 +100,6 @@ wxFFile game_file;
bool game_recording, game_playback;
u32 game_frame;
u32 game_joypad;
int sunBars = 500;
void systemStartGameRecording(const wxString &fname)
{

View File

@ -1,6 +1,6 @@
#include "wx/sdljoy.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_joystick.h>
#include <SDL/SDL.h>
#include <SDL/SDL_joystick.h>
#include <wx/window.h>
DEFINE_EVENT_TYPE(wxEVT_SDLJOY)

View File

@ -21,6 +21,8 @@
// The built-in vba-over.ini
#include "builtin-over.h"
int systemDebug = 0;
IMPLEMENT_APP(wxvbamApp)
IMPLEMENT_DYNAMIC_CLASS(MainFrame, wxFrame)