1 /***************************************************************************
4 begin : Sun Oct 28 2001
5 copyright : (C) 2001 by Pete Bernert
6 email : BlackDove@addcom.de
7 ***************************************************************************/
8 /***************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. See also the license.txt file for *
14 * additional informations. *
16 ***************************************************************************/
26 #define MAKELONG(low,high) ((unsigned long)(((unsigned short)(low)) | (((unsigned long)((unsigned short)(high))) << 16)))
28 #include "externals.h"
32 char * pConfigFile = NULL;
34 // CONFIG FILE helpers....
35 // some helper macros:
37 #define GetValue(name, var) \
38 p = strstr(pB, name); \
41 while ((*p == ' ') || (*p == '=')) p++; \
42 if (*p != '\n') var = atoi(p); \
45 #define GetFloatValue(name, var) \
46 p = strstr(pB, name); \
49 while ((*p == ' ') || (*p == '=')) p++; \
50 if (*p != '\n') var = (float)atof(p); \
53 #define SetValue(name, var) \
54 p = strstr(pB, name); \
57 while ((*p == ' ') || (*p == '=')) p++; \
59 len = sprintf(t1, "%d", var); \
60 strncpy(p, t1, len); \
61 if (p[len] != ' ' && p[len] != '\n' && p[len] != 0) p[len] = ' '; \
65 size+=sprintf(pB+size, "%s = %d\n", name, var); \
68 #define SetFloatValue(name, var) \
69 p = strstr(pB, name); \
72 while ((*p == ' ') || (*p == '=')) p++; \
74 len = sprintf(t1, "%.1f", (double)var); \
75 strncpy(p, t1, len); \
76 if (p[len] != ' ' && p[len] != '\n' && p[len] != 0) p[len] = ' '; \
80 size+=sprintf(pB+size, "%s = %.1f\n", name, (double)var); \
83 static void ReadConfigFile()
86 FILE *in;char t[256];int len, size;
90 strcpy(t,pConfigFile);
93 strcpy(t,"dfxvideo.cfg");
97 strcpy(t,"cfg/dfxvideo.cfg");
99 if(!in) sprintf(t,"%s/.pcsx/plugins/dfxvideo.cfg",getenv("HOME"));
105 if (stat(t, &buf) == -1) return;
111 pB=(char *)malloc(size + 1);
112 memset(pB,0,size + 1);
114 len = fread(pB, 1, size, in);
117 GetValue("ResX", iResX);
118 if(iResX<20) iResX=20;
121 GetValue("ResY", iResY);
122 if(iResY<20) iResY=20;
125 iWinSize=MAKELONG(iResX,iResY);
127 GetValue("NoStretch", iUseNoStretchBlt);
129 GetValue("Dithering", iUseDither);
131 GetValue("FullScreen", iWindowMode);
132 if(iWindowMode!=0) iWindowMode=0;
135 GetValue("ShowFPS", iShowFPS);
136 if(iShowFPS<0) iShowFPS=0;
137 if(iShowFPS>1) iShowFPS=1;
139 GetValue("Maintain43", iMaintainAspect);
140 if(iMaintainAspect<0) iMaintainAspect=0;
141 if(iMaintainAspect>1) iMaintainAspect=1;
143 GetValue("UseFrameLimit", UseFrameLimit);
144 if(UseFrameLimit<0) UseFrameLimit=0;
145 if(UseFrameLimit>1) UseFrameLimit=1;
147 GetValue("UseFrameSkip", UseFrameSkip);
148 if(UseFrameSkip<0) UseFrameSkip=0;
149 if(UseFrameSkip>1) UseFrameSkip=1;
151 GetValue("FPSDetection", iFrameLimit);
152 if(iFrameLimit<1) iFrameLimit=1;
153 if(iFrameLimit>2) iFrameLimit=2;
155 GetFloatValue("FrameRate", fFrameRate);
157 if(fFrameRate<10.0f) fFrameRate=10.0f;
158 if(fFrameRate>1000.0f) fFrameRate=1000.0f;
160 GetValue("CfgFixes", dwCfgFixes);
162 GetValue("UseFixes", iUseFixes);
163 if(iUseFixes<0) iUseFixes=0;
164 if(iUseFixes>1) iUseFixes=1;
169 void ExecCfg(char *arg) {
173 strcpy(cfg, "./cfgDFXVideo");
174 if (stat(cfg, &buf) != -1) {
176 execl(cfg, "cfgDFXVideo", arg, NULL);
182 strcpy(cfg, "./cfg/cfgDFXVideo");
183 if (stat(cfg, &buf) != -1) {
185 execl(cfg, "cfgDFXVideo", arg, NULL);
191 sprintf(cfg, "%s/.pcsx/plugins/cfg/cfgDFXVideo", getenv("HOME"));
192 if (stat(cfg, &buf) != -1) {
194 execl(cfg, "cfgDFXVideo", arg, NULL);
200 printf("ERROR: cfgDFXVideo file not found!\n");
203 void SoftDlgProc(void)
208 void AboutDlgProc(void)
212 sprintf(args, "ABOUT");
216 void ReadConfigGPU(void)
220 iWinSize=MAKELONG(iResX,iResY);
238 if(!iColDepth) iColDepth=32;
239 if(iUseFixes) dwActFixes=dwCfgFixes;
243 void WriteConfig(void) {
246 FILE *out;char t[256];int len, size;
247 char * pB, * p; char t1[8];
250 strcpy(t,pConfigFile);
253 strcpy(t,"dfxvideo.cfg");
257 strcpy(t,"cfg/dfxvideo.cfg");
259 if(!out) sprintf(t,"%s/.pcsx/plugins/dfxvideo.cfg",getenv("HOME"));
265 if (stat(t, &buf) != -1) size = buf.st_size;
286 pB=(char *)malloc(4096);
290 pB=(char *)malloc(size+4096);
291 memset(pB,0,size+4096);
293 len = fread(pB, 1, size, out);
297 SetValue("ResX", iResX);
298 SetValue("ResY", iResY);
299 SetValue("NoStretch", iUseNoStretchBlt);
300 SetValue("Dithering", iUseDither);
301 SetValue("FullScreen", !iWindowMode);
302 SetValue("ShowFPS", iShowFPS);
303 SetValue("Maintain43", iMaintainAspect);
304 SetValue("UseFrameLimit", UseFrameLimit);
305 SetValue("UseFrameSkip", UseFrameSkip);
306 SetValue("FPSDetection", iFrameLimit);
307 SetFloatValue("FrameRate", fFrameRate);
308 SetValue("CfgFixes", (unsigned int)dwCfgFixes);
309 SetValue("UseFixes", iUseFixes);
314 len = fwrite(pB, 1, size, out);