summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-05-12 03:03:58 +0000
committerSND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2010-05-12 03:03:58 +0000
commit0169e4968d17823b71c52961c52417ea8057130c (patch)
treefeae8d106164c1fbd43ddf9e7adc4ff4a3f70e84
parent34b2030516e8fcab81affc1e11a9b2f1a61761e4 (diff)
downloadpcsxr-0169e4968d17823b71c52961c52417ea8057130c.tar.gz
use boolean for where it should.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@47869 e17a0e51-4ae3-4d35-97c3-1a29b211df97
-rw-r--r--ChangeLog9
-rw-r--r--gui/ConfDlg.c4
-rw-r--r--gui/Config.c78
-rw-r--r--libpcsxcore/misc.c8
-rw-r--r--libpcsxcore/plugins.c6
-rw-r--r--libpcsxcore/psxcommon.h38
-rw-r--r--libpcsxcore/psxmem.c8
-rw-r--r--libpcsxcore/r3000a.c2
-rw-r--r--win32/gui/ConfigurePlugins.c6
9 files changed, 90 insertions, 69 deletions
diff --git a/ChangeLog b/ChangeLog
index 938a4f31..0c490211 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,15 @@ May 12, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
* libpcsxcore/sio.c: Erase CdromId and CdromLabel when net connection
closed.
+ * libpcsxcore/psxcommon.h: Use boolean type for config values.
+ * gui/Config.c: Use TRUE/FALSE for boolean values, enums for long values in
+ config.
+ * gui/ConfDlg.c: Likewise.
+ * win32/gui/ConfigurePlugins.c: Likewise.
+ * libpcsxcore/psxmem.c: Likewise.
+ * libpcsxcore/r3000a.c: Likewise.
+ * libpcsxcore/plugins.c: Likewise.
+ * libpcsxcore/misc.c: Likewise.
May 11, 2010 Wei Mingzhi <whistler_wmz@users.sf.net>
diff --git a/gui/ConfDlg.c b/gui/ConfDlg.c
index a9c2a0d5..a684efa2 100644
--- a/gui/ConfDlg.c
+++ b/gui/ConfDlg.c
@@ -813,7 +813,7 @@ void OnCpu_Clicked(GtkDialog *dialog, gint arg1, gpointer user_data) {
if (t != Config.Cpu) {
psxCpu->Shutdown();
#ifdef PSXREC
- if (Config.Cpu) {
+ if (Config.Cpu == CPU_INTERPRETER) {
psxCpu = &psxInt;
}
else psxCpu = &psxRec;
@@ -869,7 +869,7 @@ void OnConf_Cpu() {
g_signal_connect_data(GTK_OBJECT(glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), "toggled",
GTK_SIGNAL_FUNC(OnCpu_CpuClicked), xml, NULL, G_CONNECT_AFTER);
#else
- Config.Cpu = 1;
+ Config.Cpu = CPU_INTERPRETER;
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET (glade_xml_get_widget(xml, "GtkCheckButton_Cpu")), FALSE);
diff --git a/gui/Config.c b/gui/Config.c
index 97b2d0a4..bb7799e0 100644
--- a/gui/Config.c
+++ b/gui/Config.c
@@ -43,22 +43,32 @@ void GetValue(char *src, char *name, char *outvar) {
}
void GetValuel(char *src, char *name, long *var) {
- char *tmp = strstr(src, name);
- if (tmp != NULL) {
- tmp+=strlen(name);
- while ((*tmp == ' ') || (*tmp == '=')) tmp++;
- if (*tmp != '\n') sscanf(tmp, "%lx", var);
+ char *tmp = strstr(src, name);
+ if (tmp != NULL) {
+ tmp += strlen(name);
+ while ((*tmp == ' ') || (*tmp == '=')) tmp++;
+ if (*tmp != '\n') *var = atol(tmp);
+ }
+}
+
+void GetValueb(char *src, char *name, boolean *var) {
+ char *tmp = strstr(src, name);
+ if (tmp != NULL) {
+ tmp += strlen(name);
+ while ((*tmp == ' ') || (*tmp == '=')) tmp++;
+ if (*tmp != '\n') *var = (atoi(tmp) != 0);
}
- return;
}
#define SetValue(name, var) \
- fprintf (f,"%s = %s\n", name, var);
+ fprintf(f, "%s = %s\n", name, var);
#define SetValuel(name, var) \
- fprintf (f,"%s = %lx\n", name, var);
+ fprintf(f, "%s = %lx\n", name, var);
+
+#define SetValueb(name, var) \
+ fprintf(f, "%s = %d\n", name, (var) ? 1 : 0);
-/* TODO Use glib functions for filename handling, use constants, glib-key-value-file-parser */
int LoadConfig(PcsxConfig *Conf) {
struct stat buf;
FILE *f;
@@ -90,7 +100,7 @@ int LoadConfig(PcsxConfig *Conf) {
f = fopen(cfgfile, "r");
if (f == NULL) return -1;
- data = (char*)malloc(size + 1);
+ data = (char *)malloc(size + 1);
if (data == NULL) return -1;
fread(data, 1, buf.st_size, f);
@@ -109,18 +119,20 @@ int LoadConfig(PcsxConfig *Conf) {
GetValue(data, "Mcd2", Config.Mcd2);
GetValue(data, "BiosDir", Config.BiosDir);
GetValue(data, "PluginsDir", Config.PluginsDir);
- GetValuel(data, "Xa", &Config.Xa);
- GetValuel(data, "Sio", &Config.Sio);
- GetValuel(data, "Mdec", &Config.Mdec);
- GetValuel(data, "PsxAuto", &Config.PsxAuto);
- GetValuel(data, "PsxType", &Config.PsxType);
- GetValuel(data, "Cdda", &Config.Cdda);
+
+ GetValueb(data, "Xa", &Config.Xa);
+ GetValueb(data, "Sio", &Config.Sio);
+ GetValueb(data, "Mdec", &Config.Mdec);
+ GetValueb(data, "PsxAuto", &Config.PsxAuto);
+ GetValueb(data, "Cdda", &Config.Cdda);
+ GetValueb(data, "Dbg", &Config.Debug);
+ GetValueb(data, "PsxOut", &Config.PsxOut);
+ GetValueb(data, "SpuIrq", &Config.SpuIrq);
+ GetValueb(data, "RCntFix", &Config.RCntFix);
+ GetValueb(data, "VSyncWA", &Config.VSyncWA);
+
GetValuel(data, "Cpu", &Config.Cpu);
- GetValuel(data, "Dbg", &Config.Debug);
- GetValuel(data, "PsxOut", &Config.PsxOut);
- GetValuel(data, "SpuIrq", &Config.SpuIrq);
- GetValuel(data, "RCntFix", &Config.RCntFix);
- GetValuel(data, "VSyncWA", &Config.VSyncWA);
+ GetValuel(data, "PsxType", &Config.PsxType);
free(data);
@@ -147,18 +159,20 @@ void SaveConfig() {
SetValue("Mcd2", Config.Mcd2);
SetValue("BiosDir", Config.BiosDir);
SetValue("PluginsDir", Config.PluginsDir);
- SetValuel("Xa", Config.Xa);
- SetValuel("Sio", Config.Sio);
- SetValuel("Mdec", Config.Mdec);
- SetValuel("PsxAuto", Config.PsxAuto);
- SetValuel("PsxType", Config.PsxType);
- SetValuel("Cdda", Config.Cdda);
+
+ SetValueb("Xa", Config.Xa);
+ SetValueb("Sio", Config.Sio);
+ SetValueb("Mdec", Config.Mdec);
+ SetValueb("PsxAuto", Config.PsxAuto);
+ SetValueb("Cdda", Config.Cdda);
+ SetValueb("Dbg", Config.Debug);
+ SetValueb("PsxOut", Config.PsxOut);
+ SetValueb("SpuIrq", Config.SpuIrq);
+ SetValueb("RCntFix", Config.RCntFix);
+ SetValueb("VSyncWA", Config.VSyncWA);
+
SetValuel("Cpu", Config.Cpu);
- SetValuel("Dbg", Config.Debug);
- SetValuel("PsxOut", Config.PsxOut);
- SetValuel("SpuIrq", Config.SpuIrq);
- SetValuel("RCntFix", Config.RCntFix);
- SetValuel("VSyncWA", Config.VSyncWA);
+ SetValuel("PsxType", Config.PsxType);
fclose(f);
}
diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c
index 4d93cf29..439bde10 100644
--- a/libpcsxcore/misc.c
+++ b/libpcsxcore/misc.c
@@ -332,8 +332,8 @@ int CheckCdrom() {
if (Config.PsxAuto) { // autodetect system (pal or ntsc)
if (strstr(exename, "ES") != NULL)
- Config.PsxType = 1; // pal
- else Config.PsxType = 0; // ntsc
+ Config.PsxType = PSX_TYPE_PAL; // pal
+ else Config.PsxType = PSX_TYPE_NTSC; // ntsc
}
if (CdromLabel[0] == ' ') {
@@ -619,7 +619,6 @@ int RecvPcsxInfo() {
NET_recvData(&Config.SpuIrq, sizeof(Config.SpuIrq), PSE_NET_BLOCKING);
NET_recvData(&Config.RCntFix, sizeof(Config.RCntFix), PSE_NET_BLOCKING);
NET_recvData(&Config.PsxType, sizeof(Config.PsxType), PSE_NET_BLOCKING);
- //psxUpdateVSyncRate();
SysUpdate();
@@ -628,8 +627,7 @@ int RecvPcsxInfo() {
if (tmp != Config.Cpu) {
psxCpu->Shutdown();
#ifdef PSXREC
- if (Config.Cpu)
- psxCpu = &psxInt;
+ if (Config.Cpu == CPU_INTERPRETER) psxCpu = &psxInt;
else psxCpu = &psxRec;
#else
psxCpu = &psxInt;
diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c
index 59d14bb6..90db0961 100644
--- a/libpcsxcore/plugins.c
+++ b/libpcsxcore/plugins.c
@@ -480,11 +480,11 @@ int LoadPlugins() {
if (LoadPAD2plugin(Plugin) == -1) return -1;
if (strcmp("Disabled", Config.Net) == 0 || strcmp("", Config.Net) == 0)
- Config.UseNet = 0;
+ Config.UseNet = FALSE;
else {
- Config.UseNet = 1;
+ Config.UseNet = TRUE;
sprintf(Plugin, "%s/%s", Config.PluginsDir, Config.Net);
- if (LoadNETplugin(Plugin) == -1) Config.UseNet = 0;
+ if (LoadNETplugin(Plugin) == -1) Config.UseNet = FALSE;
}
ret = CDR_init();
diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h
index f37a2520..fb0cb7ec 100644
--- a/libpcsxcore/psxcommon.h
+++ b/libpcsxcore/psxcommon.h
@@ -114,20 +114,20 @@ typedef struct {
char BiosDir[MAXPATHLEN];
char PluginsDir[MAXPATHLEN];
char PatchesDir[MAXPATHLEN];
- long Xa;
- long Sio;
- long Mdec;
- long PsxAuto;
+ boolean Xa;
+ boolean Sio;
+ boolean Mdec;
+ boolean PsxAuto;
+ boolean Cdda;
+ boolean HLE;
+ boolean Debug;
+ boolean PsxOut;
+ boolean SpuIrq;
+ boolean RCntFix;
+ boolean UseNet;
+ boolean VSyncWA;
+ long Cpu; // CPU_DYNAREC or CPU_INTERPRETER
long PsxType; // PSX_TYPE_NTSC or PSX_TYPE_PAL
- long Cdda;
- long HLE;
- long Cpu;
- long Debug;
- long PsxOut;
- long SpuIrq;
- long RCntFix;
- long UseNet;
- long VSyncWA;
#ifdef _WIN32
char Lang[256];
#endif
@@ -145,14 +145,14 @@ extern boolean NetOpened;
#define PSXCLK 33868800 /* 33.8688 Mhz */
enum {
- BIOS_USER_DEFINED = 0,
- BIOS_HLE
-}; // BIOS Types
-
-enum {
PSX_TYPE_NTSC = 0,
PSX_TYPE_PAL
-}; // PSX Type
+}; // PSX Types
+
+enum {
+ CPU_DYNAREC = 0,
+ CPU_INTERPRETER
+}; // CPU Types
int EmuInit();
void EmuReset();
diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c
index ff053ca9..2f6f7409 100644
--- a/libpcsxcore/psxmem.c
+++ b/libpcsxcore/psxmem.c
@@ -111,15 +111,15 @@ void psxMemReset() {
f = fopen(bios, "rb");
if (f == NULL) {
- SysMessage (_("Could not open BIOS:\"%s\". Enabling HLE Bios!\n"), bios);
+ SysMessage(_("Could not open BIOS:\"%s\". Enabling HLE Bios!\n"), bios);
memset(psxR, 0, 0x80000);
- Config.HLE = BIOS_HLE;
+ Config.HLE = TRUE;
} else {
fread(psxR, 1, 0x80000, f);
fclose(f);
- Config.HLE = BIOS_USER_DEFINED;
+ Config.HLE = FALSE;
}
- } else Config.HLE = BIOS_HLE;
+ } else Config.HLE = TRUE;
}
void psxMemShutdown() {
diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c
index b569e5d7..d8b3255a 100644
--- a/libpcsxcore/r3000a.c
+++ b/libpcsxcore/r3000a.c
@@ -33,7 +33,7 @@ int psxInit() {
SysPrintf(_("Running PCSX Version %s (%s).\n"), PACKAGE_VERSION, __DATE__);
#ifdef PSXREC
- if (Config.Cpu) {
+ if (Config.Cpu == CPU_INTERPRETER) {
psxCpu = &psxInt;
} else psxCpu = &psxRec;
#else
diff --git a/win32/gui/ConfigurePlugins.c b/win32/gui/ConfigurePlugins.c
index a9951016..54b69b37 100644
--- a/win32/gui/ConfigurePlugins.c
+++ b/win32/gui/ConfigurePlugins.c
@@ -61,16 +61,16 @@ int LoadConfig() {
QueryKeyV(sizeof(Conf->Sio), "Sio", &Conf->Sio);
QueryKeyV(sizeof(Conf->Mdec), "Mdec", &Conf->Mdec);
QueryKeyV(sizeof(Conf->PsxAuto), "PsxAuto", &Conf->PsxAuto);
- QueryKeyV(sizeof(Conf->PsxType), "PsxType", &Conf->PsxType);
QueryKeyV(sizeof(Conf->Cdda), "Cdda", &Conf->Cdda);
- QueryKeyV(sizeof(Conf->Cpu), "Cpu", &Conf->Cpu);
QueryKeyV(sizeof(Conf->Debug), "Debug", &Conf->Debug);
QueryKeyV(sizeof(Conf->PsxOut), "PsxOut", &Conf->PsxOut);
QueryKeyV(sizeof(Conf->SpuIrq), "SpuIrq", &Conf->SpuIrq);
QueryKeyV(sizeof(Conf->RCntFix), "RCntFix", &Conf->RCntFix);
QueryKeyV(sizeof(Conf->VSyncWA), "VSyncWA", &Conf->VSyncWA);
+ QueryKeyV(sizeof(Conf->Cpu), "Cpu", &Conf->Cpu);
+ QueryKeyV(sizeof(Conf->PsxType), "PsxType", &Conf->PsxType);
- if (!Config.Cpu) {
+ if (Config.Cpu == CPU_DYNAREC) {
Config.Debug = 0; // don't enable debugger if using dynarec core
}