pcsxr-1.9.92
[pcsx_rearmed.git] / plugins / peopsxgl / cfg.c
CommitLineData
ef79bbde
P
1/***************************************************************************\r
2 cfg.c - description\r
3 -------------------\r
4 begin : Sun Mar 08 2009\r
5 copyright : (C) 1999-2009 by Pete Bernert\r
6 web : www.pbernert.com \r
7 ***************************************************************************/\r
8\r
9/***************************************************************************\r
10 * *\r
11 * This program is free software; you can redistribute it and/or modify *\r
12 * it under the terms of the GNU General Public License as published by *\r
13 * the Free Software Foundation; either version 2 of the License, or *\r
14 * (at your option) any later version. See also the license.txt file for *\r
15 * additional informations. *\r
16 * *\r
17 ***************************************************************************/\r
18\r
19//*************************************************************************// \r
20// History of changes:\r
21//\r
22// 2009/03/08 - Pete \r
23// - generic cleanup for the Peops release\r
24//\r
25//*************************************************************************// \r
26\r
27#define _IN_CFG\r
28\r
29#include "stdafx.h"\r
30#include "externals.h"\r
31#include "cfg.h"\r
32\r
33char *pConfigFile = NULL;\r
34\r
35void ReadConfigFile()\r
36{\r
37 FILE *in = NULL;\r
38 int len;\r
39 char *pB, *p, t[256];\r
40\r
41 if (pConfigFile != NULL)\r
42 in = fopen(pConfigFile, "rb");\r
43 else\r
44 in = fopen("gpuPeopsMesaGL.cfg", "rb"); \r
45\r
46 if (in == NULL) return;\r
47\r
48 pB=(char *)malloc(32767); // buffer for reading config (32k)\r
49 memset(pB, 0, 32767);\r
50\r
51 len = fread(pB, 1, 32767, in); // read config in buffer\r
52 fclose(in); // close config file\r
53\r
54 strcpy(t,"\nResX");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
55 if(p) iResX=atoi(p+len);\r
56 if(iResX<10) iResX=10;\r
57\r
58 strcpy(t,"\nResY");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
59 if(p) iResY=atoi(p+len);\r
60 if(iResY<10) iResY=10;\r
61\r
62 strcpy(t,"\nKeepRatio");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
63 if(p) bKeepRatio=atoi(p+len);\r
64 if(bKeepRatio<0) bKeepRatio=0;\r
65 if(bKeepRatio>1) bKeepRatio=1;\r
66\r
67 strcpy(t,"\nScreenSmoothing");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
68 if(p) iBlurBuffer=atoi(p+len);\r
69 if(iBlurBuffer<0) iBlurBuffer=0;\r
70 if(iBlurBuffer>1) iBlurBuffer=1;\r
71\r
72 strcpy(t,"\nHiResTextures");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
73 if(p) iHiResTextures=atoi(p+len);\r
74 if(iHiResTextures<0) iHiResTextures=0;\r
75 if(iHiResTextures>2) iHiResTextures=2;\r
76\r
77 iSortTexCnt =0;\r
78 strcpy(t,"\nVRamSize");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
79 if(p) iVRamSize=atoi(p+len);\r
80 if(iVRamSize<0) iVRamSize=0;\r
81 if(iVRamSize>1024) iVRamSize=1024;\r
82\r
83 strcpy(t,"\nFullScreen");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
84 if(p) bFullScreen=atoi(p+len);\r
85 if(bFullScreen>1) bFullScreen=1;\r
86\r
87 strcpy(t,"\nScanLines");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
88 if(p) iUseScanLines=atoi(p+len);\r
89 if(iUseScanLines<0) iUseScanLines=0;\r
90 if(iUseScanLines>1) iUseScanLines=1;\r
91\r
92 strcpy(t,"\nScanLinesBlend");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
93 if(p) iScanBlend=atoi(p+len);\r
94 if(iScanBlend<-1) iScanBlend=-1;\r
95 if(iScanBlend>255) iScanBlend=255;\r
96\r
97 strcpy(t,"\nFrameTextures");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
98 if(p) iFrameTexType=atoi(p+len);\r
99 if(iFrameTexType<0) iFrameTexType=0;\r
100 if(iFrameTexType>3) iFrameTexType=3;\r
101\r
102 strcpy(t,"\nFrameAccess");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
103 if(p) iFrameReadType=atoi(p+len);\r
104 if(iFrameReadType<0) iFrameReadType=0;\r
105 if(iFrameReadType>4) iFrameReadType=4;\r
106 if(iFrameReadType==4) bFullVRam=TRUE;\r
107 else bFullVRam=FALSE;\r
108\r
109 strcpy(t,"\nTexFilter");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
110 if(p) iFilterType=atoi(p+len);\r
111 if(iFilterType<0) iFilterType=0;\r
112 if(iFilterType>6) iFilterType=6;\r
113\r
114 strcpy(t,"\nAdvancedBlend");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
115 if(p) bAdvancedBlend=atoi(p+len);\r
116 if(bAdvancedBlend<0) bAdvancedBlend=0;\r
117 if(bAdvancedBlend>1) bAdvancedBlend=1;\r
118\r
119 strcpy(t,"\nDithering");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
120 if(p) bDrawDither=atoi(p+len);\r
121 if(bDrawDither<0) bDrawDither=0;\r
122 if(bDrawDither>1) bDrawDither=1;\r
123\r
124 strcpy(t,"\nLineMode");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
125 if(p) bUseLines=atoi(p+len);\r
126 if(bUseLines<0) bUseLines=0;\r
127 if(bUseLines>1) bUseLines=1;\r
128\r
129 strcpy(t,"\nShowFPS");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
130 if(p) iShowFPS=atoi(p+len);\r
131 if(iShowFPS<0) iShowFPS=0;\r
132 if(iShowFPS>1) iShowFPS=1;\r
133\r
134 strcpy(t,"\nUseFrameLimit");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
135 if(p) bUseFrameLimit=atoi(p+len);\r
136 if(bUseFrameLimit<0) bUseFrameLimit=0;\r
137 if(bUseFrameLimit>1) bUseFrameLimit=1;\r
138\r
139 strcpy(t,"\nUseFrameSkip");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
140 if(p) bUseFrameSkip=atoi(p+len);\r
141 if(bUseFrameSkip<0) bUseFrameSkip=0;\r
142 if(bUseFrameSkip>1) bUseFrameSkip=1;\r
143\r
144 strcpy(t,"\nFPSDetection");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
145 if(p) iFrameLimit=atoi(p+len)+1;\r
146 if(iFrameLimit<1) iFrameLimit=1;\r
147 if(iFrameLimit>2) iFrameLimit=2;\r
148\r
149 strcpy(t,"\nFrameRate");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
150 if(p) fFrameRate=(float)atof(p+len);\r
151 if(fFrameRate<0.0f) fFrameRate=0.0f;\r
152 if(fFrameRate>1000.0f) fFrameRate=1000.0f;\r
153\r
154 strcpy(t,"\nOffscreenDrawing");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
155 if(p) iOffscreenDrawing=atoi(p+len);\r
156 if(iOffscreenDrawing<0) iOffscreenDrawing=0;\r
157 if(iOffscreenDrawing>4) iOffscreenDrawing=4;\r
158\r
159 strcpy(t,"\nOpaquePass");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
160 if(p) bOpaquePass=atoi(p+len);\r
161 if(bOpaquePass<0) bOpaquePass=0;\r
162 if(bOpaquePass>1) bOpaquePass=1;\r
163\r
164 strcpy(t,"\nAntiAlias");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
165 if(p) bUseAntiAlias=atoi(p+len);\r
166 if(bUseAntiAlias<0) bUseAntiAlias=0;\r
167 if(bUseAntiAlias>1) bUseAntiAlias=1;\r
168\r
169 strcpy(t,"\nTexQuality");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
170 if(p) iTexQuality=atoi(p+len);\r
171 if(iTexQuality<0) iTexQuality=0;\r
172 if(iTexQuality>4) iTexQuality=4;\r
173\r
174 strcpy(t,"\n15bitMdec");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
175 if(p) bUse15bitMdec=atoi(p+len);\r
176 if(bUse15bitMdec<0) bUse15bitMdec=0;\r
177 if(bUse15bitMdec>1) bUse15bitMdec=1;\r
178\r
179 strcpy(t,"\nMaskDetect");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
180 if(p) iUseMask=atoi(p+len);\r
181 if(iUseMask<0) iUseMask=0;\r
182 if(iUseMask>1) iUseMask=1;\r
183\r
184 strcpy(t,"\nFastMdec");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
185 if(p) bUseFastMdec=atoi(p+len);\r
186 if(bUseFastMdec<0) bUseFastMdec=0;\r
187 if(bUseFastMdec>1) bUseFastMdec=1;\r
188\r
189 strcpy(t,"\nCfgFixes");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
190 if(p) dwCfgFixes=atoi(p+len);\r
191\r
192 strcpy(t,"\nUseFixes");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
193 if(p) bUseFixes=atoi(p+len);\r
194 if(bUseFixes<0) bUseFixes=0;\r
195 if(bUseFixes>1) bUseFixes=1;\r
196\r
197 strcpy(t,"\nOGLExtensions");p=strstr(pB,t);if(p) {p=strstr(p,"=");len=1;}\r
198 if(p) iUseExts=atoi(p+len);\r
199 if(iUseExts>1) iUseExts=1;\r
200\r
201 free(pB);\r
202}\r
203\r
204void ReadConfig(void) // read config (linux file)\r
205{\r
206 iResX=640;\r
207 iResY=480;\r
208 iColDepth=16;\r
209 bChangeRes=FALSE;\r
210 bWindowMode=TRUE;\r
211 iUseScanLines=0;\r
212 bFullScreen=FALSE;\r
213 bFullVRam=FALSE;\r
214 iFilterType=0;\r
215 bAdvancedBlend=FALSE;\r
216 bDrawDither=FALSE;\r
217 bUseLines=FALSE;\r
218 bUseFrameLimit=TRUE;\r
219 bUseFrameSkip=FALSE;\r
220 iFrameLimit=2;\r
221 fFrameRate=200.0f;\r
222 iOffscreenDrawing=2;\r
223 bOpaquePass=TRUE;\r
224 bUseAntiAlias=FALSE;\r
225 iTexQuality=0;\r
226 iUseMask=0;\r
227 iZBufferDepth=0;\r
228 bUseFastMdec=TRUE;\r
229 dwCfgFixes=0;\r
230 bUseFixes=FALSE;\r
231 iFrameTexType=1;\r
232 iFrameReadType=0;\r
233 bUse15bitMdec=FALSE;\r
234 iShowFPS=0;\r
235 bKeepRatio=FALSE;\r
236 iScanBlend=0;\r
237 iVRamSize=0;\r
238 iTexGarbageCollection=1;\r
239 iBlurBuffer=0;\r
240 iHiResTextures=0;\r
241 iForceVSync=-1;\r
242\r
243 ReadConfigFile(); // read file\r
244\r
245 if(!iColDepth) iColDepth=32; // adjust color info\r
246 if(iUseMask) iZBufferDepth=16; // set zbuffer depth \r
247 else iZBufferDepth=0;\r
248 if(bUseFixes) dwActFixes=dwCfgFixes; // init game fix global\r
249}\r