summaryrefslogtreecommitdiff
path: root/PcsxSrc/Linux/Config.c
diff options
context:
space:
mode:
authorPixel <Pixel>2002-09-21 18:47:46 +0000
committerPixel <Pixel>2002-09-21 18:47:46 +0000
commit60c1003845035ad4cd0e9ea50862bad7626faf0e (patch)
treecf3f6e0015ede7b11112de87914734c02616dfa4 /PcsxSrc/Linux/Config.c
parent259110b90336240ce6cdde0201d05ce03a1f73fe (diff)
Added the Pcsx source.
Diffstat (limited to 'PcsxSrc/Linux/Config.c')
-rw-r--r--PcsxSrc/Linux/Config.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/PcsxSrc/Linux/Config.c b/PcsxSrc/Linux/Config.c
new file mode 100644
index 0000000..be8cfb3
--- /dev/null
+++ b/PcsxSrc/Linux/Config.c
@@ -0,0 +1,125 @@
+/* Pcsx - Pc Psx Emulator
+ * Copyright (C) 1999-2002 Pcsx Team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "Linux.h"
+
+#define GetValue(name, var) \
+ tmp = strstr(data, name); \
+ if (tmp != NULL) { \
+ tmp+=strlen(name); \
+ while ((*tmp == ' ') || (*tmp == '=')) tmp++; \
+ if (*tmp != '\n') sscanf(tmp, "%s", var); \
+ }
+
+#define GetValuel(name, var) \
+ tmp = strstr(data, name); \
+ if (tmp != NULL) { \
+ tmp+=strlen(name); \
+ while ((*tmp == ' ') || (*tmp == '=')) tmp++; \
+ if (*tmp != '\n') sscanf(tmp, "%lx", &var); \
+ }
+
+#define SetValue(name, var) \
+ fprintf (f,"%s = %s\n", name, var);
+
+#define SetValuel(name, var) \
+ fprintf (f,"%s = %lx\n", name, var);
+
+int LoadConfig(PcsxConfig *Conf) {
+ struct stat buf;
+ FILE *f;
+ int size;
+ char *data,*tmp;
+
+ if (stat(cfgfile, &buf) == -1) return -1;
+ size = buf.st_size;
+
+ f = fopen(cfgfile,"r");
+ if (f == NULL) return -1;
+
+ data = (char*)malloc(size);
+ if (data == NULL) return -1;
+
+ fread(data, 1, size, f);
+ fclose(f);
+
+ GetValue("Bios", Config.Bios);
+ GetValue("Gpu", Config.Gpu);
+ GetValue("Spu", Config.Spu);
+ GetValue("Cdr", Config.Cdr);
+ GetValue("Pad1", Config.Pad1);
+ GetValue("Pad2", Config.Pad2);
+ GetValue("Mcd1", Config.Mcd1);
+ GetValue("Mcd2", Config.Mcd2);
+ GetValue("PluginsDir", Config.PluginsDir);
+ GetValue("BiosDir", Config.BiosDir);
+ GetValuel("Xa", Config.Xa);
+ GetValuel("Sio", Config.Sio);
+ GetValuel("Mdec", Config.Mdec);
+ GetValuel("PsxAuto", Config.PsxAuto);
+ GetValuel("PsxType", Config.PsxType);
+ GetValuel("Cdda", Config.Cdda);
+ GetValuel("Cpu", Config.Cpu);
+ GetValuel("PsxOut", Config.PsxOut);
+ GetValuel("SpuIrq", Config.SpuIrq);
+ GetValuel("CdTiming",Config.CdTiming);
+
+ free(data);
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////
+
+void SaveConfig() {
+ FILE *f;
+
+ f = fopen(cfgfile,"w");
+ if (f == NULL) return;
+
+ SetValue("Bios", Config.Bios);
+ SetValue("Gpu", Config.Gpu);
+ SetValue("Spu", Config.Spu);
+ SetValue("Cdr", Config.Cdr);
+ SetValue("Pad1", Config.Pad1);
+ SetValue("Pad2", Config.Pad2);
+ SetValue("Mcd1", Config.Mcd1);
+ SetValue("Mcd2", Config.Mcd2);
+ SetValue("PluginsDir", Config.PluginsDir);
+ SetValue("BiosDir", Config.BiosDir);
+ SetValuel("Xa", Config.Xa);
+ SetValuel("Sio", Config.Sio);
+ SetValuel("Mdec", Config.Mdec);
+ SetValuel("PsxAuto", Config.PsxAuto);
+ SetValuel("PsxType", Config.PsxType);
+ SetValuel("Cdda", Config.Cdda);
+ SetValuel("Cpu", Config.Cpu);
+ SetValuel("PsxOut", Config.PsxOut);
+ SetValuel("SpuIrq", Config.SpuIrq);
+ SetValuel("CdTiming",Config.CdTiming);
+
+ fclose(f);
+
+ return;
+}