1 |
william |
31 |
/* PCSX2 - PS2 Emulator for PCs |
2 |
|
|
* Copyright (C) 2002-2010 PCSX2 Dev Team |
3 |
|
|
* |
4 |
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms |
5 |
|
|
* of the GNU Lesser General Public License as published by the Free Software Found- |
6 |
|
|
* ation, either version 3 of the License, or (at your option) any later version. |
7 |
|
|
* |
8 |
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
9 |
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
10 |
|
|
* PURPOSE. See the GNU General Public License for more details. |
11 |
|
|
* |
12 |
|
|
* You should have received a copy of the GNU General Public License along with PCSX2. |
13 |
|
|
* If not, see <http://www.gnu.org/licenses/>. |
14 |
|
|
*/ |
15 |
|
|
|
16 |
|
|
#include "PrecompiledHeader.h" |
17 |
|
|
|
18 |
|
|
#include <wx/fileconf.h> |
19 |
|
|
|
20 |
william |
62 |
#include "Utilities/IniInterface.h" |
21 |
william |
31 |
#include "Config.h" |
22 |
|
|
#include "GS.h" |
23 |
|
|
|
24 |
|
|
void TraceLogFilters::LoadSave( IniInterface& ini ) |
25 |
|
|
{ |
26 |
|
|
TraceLogFilters defaults; |
27 |
william |
62 |
ScopedIniGroup path( ini, L"TraceLog" ); |
28 |
william |
31 |
|
29 |
|
|
IniEntry( Enabled ); |
30 |
william |
62 |
|
31 |
william |
31 |
// Retaining backwards compat of the trace log enablers isn't really important, and |
32 |
|
|
// doing each one by hand would be murder. So let's cheat and just save it as an int: |
33 |
|
|
|
34 |
|
|
IniEntry( EE.bitset ); |
35 |
|
|
IniEntry( IOP.bitset ); |
36 |
|
|
} |
37 |
|
|
|
38 |
|
|
// all speedhacks are disabled by default |
39 |
|
|
Pcsx2Config::SpeedhackOptions::SpeedhackOptions() |
40 |
|
|
{ |
41 |
|
|
bitset = 0; |
42 |
|
|
EECycleRate = 0; |
43 |
|
|
VUCycleSteal = 0; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
void Pcsx2Config::SpeedhackOptions::LoadSave( IniInterface& ini ) |
47 |
|
|
{ |
48 |
|
|
SpeedhackOptions defaults; |
49 |
william |
62 |
ScopedIniGroup path( ini, L"Speedhacks" ); |
50 |
william |
31 |
|
51 |
|
|
IniBitfield( EECycleRate ); |
52 |
|
|
IniBitfield( VUCycleSteal ); |
53 |
william |
62 |
IniBitBool( fastCDVD ); |
54 |
william |
31 |
IniBitBool( IntcStat ); |
55 |
|
|
IniBitBool( WaitLoop ); |
56 |
|
|
IniBitBool( vuFlagHack ); |
57 |
william |
62 |
IniBitBool( vuBlockHack ); |
58 |
william |
31 |
IniBitBool( vuMinMax ); |
59 |
|
|
} |
60 |
|
|
|
61 |
|
|
void Pcsx2Config::ProfilerOptions::LoadSave( IniInterface& ini ) |
62 |
|
|
{ |
63 |
|
|
ProfilerOptions defaults; |
64 |
william |
62 |
ScopedIniGroup path( ini, L"Profiler" ); |
65 |
william |
31 |
|
66 |
|
|
IniBitBool( Enabled ); |
67 |
|
|
IniBitBool( RecBlocks_EE ); |
68 |
|
|
IniBitBool( RecBlocks_IOP ); |
69 |
|
|
IniBitBool( RecBlocks_VU0 ); |
70 |
|
|
IniBitBool( RecBlocks_VU1 ); |
71 |
|
|
} |
72 |
|
|
|
73 |
|
|
Pcsx2Config::RecompilerOptions::RecompilerOptions() |
74 |
|
|
{ |
75 |
|
|
bitset = 0; |
76 |
|
|
|
77 |
william |
62 |
//StackFrameChecks = false; |
78 |
|
|
//PreBlockCheckEE = false; |
79 |
william |
31 |
|
80 |
|
|
// All recs are enabled by default. |
81 |
|
|
|
82 |
|
|
EnableEE = true; |
83 |
|
|
EnableIOP = true; |
84 |
|
|
EnableVU0 = true; |
85 |
|
|
EnableVU1 = true; |
86 |
|
|
|
87 |
|
|
UseMicroVU0 = true; |
88 |
|
|
UseMicroVU1 = true; |
89 |
|
|
|
90 |
|
|
// vu and fpu clamping default to standard overflow. |
91 |
|
|
vuOverflow = true; |
92 |
|
|
//vuExtraOverflow = false; |
93 |
|
|
//vuSignOverflow = false; |
94 |
|
|
//vuUnderflow = false; |
95 |
|
|
|
96 |
|
|
fpuOverflow = true; |
97 |
|
|
//fpuExtraOverflow = false; |
98 |
|
|
//fpuFullMode = false; |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
void Pcsx2Config::RecompilerOptions::ApplySanityCheck() |
102 |
|
|
{ |
103 |
|
|
bool fpuIsRight = true; |
104 |
|
|
|
105 |
|
|
if( fpuExtraOverflow ) |
106 |
|
|
fpuIsRight = fpuOverflow; |
107 |
|
|
|
108 |
|
|
if( fpuFullMode ) |
109 |
|
|
fpuIsRight = fpuOverflow && fpuExtraOverflow; |
110 |
|
|
|
111 |
|
|
if( !fpuIsRight ) |
112 |
|
|
{ |
113 |
|
|
// Values are wonky; assume the defaults. |
114 |
|
|
fpuOverflow = RecompilerOptions().fpuOverflow; |
115 |
|
|
fpuExtraOverflow= RecompilerOptions().fpuExtraOverflow; |
116 |
|
|
fpuFullMode = RecompilerOptions().fpuFullMode; |
117 |
|
|
} |
118 |
|
|
|
119 |
|
|
bool vuIsOk = true; |
120 |
|
|
|
121 |
|
|
if( vuExtraOverflow ) vuIsOk = vuIsOk && vuOverflow; |
122 |
|
|
if( vuSignOverflow ) vuIsOk = vuIsOk && vuExtraOverflow; |
123 |
|
|
|
124 |
|
|
if( !vuIsOk ) |
125 |
|
|
{ |
126 |
|
|
// Values are wonky; assume the defaults. |
127 |
|
|
vuOverflow = RecompilerOptions().vuOverflow; |
128 |
|
|
vuExtraOverflow = RecompilerOptions().vuExtraOverflow; |
129 |
|
|
vuSignOverflow = RecompilerOptions().vuSignOverflow; |
130 |
|
|
vuUnderflow = RecompilerOptions().vuUnderflow; |
131 |
|
|
} |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
void Pcsx2Config::RecompilerOptions::LoadSave( IniInterface& ini ) |
135 |
|
|
{ |
136 |
|
|
RecompilerOptions defaults; |
137 |
william |
62 |
ScopedIniGroup path( ini, L"Recompiler" ); |
138 |
william |
31 |
|
139 |
|
|
IniBitBool( EnableEE ); |
140 |
|
|
IniBitBool( EnableIOP ); |
141 |
|
|
IniBitBool( EnableVU0 ); |
142 |
|
|
IniBitBool( EnableVU1 ); |
143 |
|
|
|
144 |
|
|
IniBitBool( UseMicroVU0 ); |
145 |
|
|
IniBitBool( UseMicroVU1 ); |
146 |
|
|
|
147 |
|
|
IniBitBool( vuOverflow ); |
148 |
|
|
IniBitBool( vuExtraOverflow ); |
149 |
|
|
IniBitBool( vuSignOverflow ); |
150 |
|
|
IniBitBool( vuUnderflow ); |
151 |
|
|
|
152 |
|
|
IniBitBool( fpuOverflow ); |
153 |
|
|
IniBitBool( fpuExtraOverflow ); |
154 |
|
|
IniBitBool( fpuFullMode ); |
155 |
|
|
|
156 |
|
|
IniBitBool( StackFrameChecks ); |
157 |
william |
62 |
IniBitBool( PreBlockCheckEE ); |
158 |
|
|
IniBitBool( PreBlockCheckIOP ); |
159 |
william |
31 |
} |
160 |
|
|
|
161 |
|
|
Pcsx2Config::CpuOptions::CpuOptions() |
162 |
|
|
{ |
163 |
|
|
sseMXCSR.bitmask = DEFAULT_sseMXCSR; |
164 |
|
|
sseVUMXCSR.bitmask = DEFAULT_sseVUMXCSR; |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
void Pcsx2Config::CpuOptions::ApplySanityCheck() |
168 |
|
|
{ |
169 |
|
|
sseMXCSR.ClearExceptionFlags().DisableExceptions(); |
170 |
|
|
sseVUMXCSR.ClearExceptionFlags().DisableExceptions(); |
171 |
|
|
|
172 |
|
|
Recompiler.ApplySanityCheck(); |
173 |
|
|
} |
174 |
|
|
|
175 |
|
|
void Pcsx2Config::CpuOptions::LoadSave( IniInterface& ini ) |
176 |
|
|
{ |
177 |
|
|
CpuOptions defaults; |
178 |
william |
62 |
ScopedIniGroup path( ini, L"CPU" ); |
179 |
william |
31 |
|
180 |
|
|
IniBitBoolEx( sseMXCSR.DenormalsAreZero, "FPU.DenormalsAreZero" ); |
181 |
|
|
IniBitBoolEx( sseMXCSR.FlushToZero, "FPU.FlushToZero" ); |
182 |
|
|
IniBitfieldEx( sseMXCSR.RoundingControl, "FPU.Roundmode" ); |
183 |
|
|
|
184 |
|
|
IniBitBoolEx( sseVUMXCSR.DenormalsAreZero, "VU.DenormalsAreZero" ); |
185 |
|
|
IniBitBoolEx( sseVUMXCSR.FlushToZero, "VU.FlushToZero" ); |
186 |
|
|
IniBitfieldEx( sseVUMXCSR.RoundingControl, "VU.Roundmode" ); |
187 |
|
|
|
188 |
|
|
Recompiler.LoadSave( ini ); |
189 |
|
|
} |
190 |
|
|
|
191 |
|
|
// Default GSOptions |
192 |
|
|
Pcsx2Config::GSOptions::GSOptions() |
193 |
|
|
{ |
194 |
|
|
FrameLimitEnable = true; |
195 |
|
|
FrameSkipEnable = false; |
196 |
|
|
VsyncEnable = false; |
197 |
|
|
|
198 |
|
|
SynchronousMTGS = false; |
199 |
|
|
DisableOutput = false; |
200 |
william |
62 |
VsyncQueueSize = 2; |
201 |
william |
31 |
|
202 |
|
|
DefaultRegionMode = Region_NTSC; |
203 |
|
|
FramesToDraw = 2; |
204 |
|
|
FramesToSkip = 2; |
205 |
|
|
|
206 |
|
|
LimitScalar = 1.0; |
207 |
|
|
FramerateNTSC = 59.94; |
208 |
|
|
FrameratePAL = 50.0; |
209 |
|
|
} |
210 |
|
|
|
211 |
|
|
void Pcsx2Config::GSOptions::LoadSave( IniInterface& ini ) |
212 |
|
|
{ |
213 |
|
|
GSOptions defaults; |
214 |
william |
62 |
ScopedIniGroup path( ini, L"GS" ); |
215 |
william |
31 |
|
216 |
|
|
IniEntry( SynchronousMTGS ); |
217 |
|
|
IniEntry( DisableOutput ); |
218 |
william |
62 |
IniEntry( VsyncQueueSize ); |
219 |
william |
31 |
|
220 |
|
|
IniEntry( FrameLimitEnable ); |
221 |
|
|
IniEntry( FrameSkipEnable ); |
222 |
|
|
IniEntry( VsyncEnable ); |
223 |
|
|
|
224 |
|
|
IniEntry( LimitScalar ); |
225 |
|
|
IniEntry( FramerateNTSC ); |
226 |
|
|
IniEntry( FrameratePAL ); |
227 |
|
|
|
228 |
|
|
static const wxChar * const ntsc_pal_str[2] = { L"ntsc", L"pal" }; |
229 |
|
|
ini.EnumEntry( L"DefaultRegionMode", DefaultRegionMode, ntsc_pal_str, defaults.DefaultRegionMode ); |
230 |
|
|
|
231 |
|
|
IniEntry( FramesToDraw ); |
232 |
|
|
IniEntry( FramesToSkip ); |
233 |
|
|
} |
234 |
|
|
|
235 |
william |
62 |
const wxChar *const tbl_GamefixNames[] = |
236 |
|
|
{ |
237 |
|
|
L"VuAddSub", |
238 |
|
|
L"VuClipFlag", |
239 |
|
|
L"FpuCompare", |
240 |
|
|
L"FpuMul", |
241 |
|
|
L"FpuNegDiv", |
242 |
|
|
L"XGKick", |
243 |
|
|
L"IpuWait", |
244 |
|
|
L"EETiming", |
245 |
|
|
L"SkipMpeg", |
246 |
|
|
L"OPHFlag" |
247 |
|
|
}; |
248 |
|
|
|
249 |
|
|
const __fi wxChar* EnumToString( GamefixId id ) |
250 |
|
|
{ |
251 |
|
|
return tbl_GamefixNames[id]; |
252 |
|
|
} |
253 |
|
|
|
254 |
|
|
// Enables a full list of gamefixes. The list can be either comma or pipe-delimited. |
255 |
|
|
// Example: "XGKick,IpuWait" or "EEtiming,FpuCompare" |
256 |
|
|
// If an unrecognized tag is encountered, a warning is printed to the console, but no error |
257 |
|
|
// is generated. This allows the system to function in the event that future versions of |
258 |
|
|
// PCSX2 remove old hacks once they become obsolete. |
259 |
|
|
void Pcsx2Config::GamefixOptions::Set( const wxString& list, bool enabled ) |
260 |
|
|
{ |
261 |
|
|
wxStringTokenizer izer( list, L",|", wxTOKEN_STRTOK ); |
262 |
|
|
|
263 |
|
|
while( izer.HasMoreTokens() ) |
264 |
|
|
{ |
265 |
|
|
wxString token( izer.GetNextToken() ); |
266 |
|
|
|
267 |
|
|
GamefixId i; |
268 |
|
|
for (i=GamefixId_FIRST; i < pxEnumEnd; ++i) |
269 |
|
|
{ |
270 |
|
|
if( token.CmpNoCase( EnumToString(i) ) == 0 ) break; |
271 |
|
|
} |
272 |
|
|
if( i < pxEnumEnd ) Set( i ); |
273 |
|
|
} |
274 |
|
|
} |
275 |
|
|
|
276 |
|
|
void Pcsx2Config::GamefixOptions::Set( GamefixId id, bool enabled ) |
277 |
|
|
{ |
278 |
|
|
EnumAssert( id ); |
279 |
|
|
switch(id) |
280 |
|
|
{ |
281 |
|
|
case Fix_VuAddSub: VuAddSubHack = enabled; break; |
282 |
|
|
case Fix_VuClipFlag: VuClipFlagHack = enabled; break; |
283 |
|
|
case Fix_FpuCompare: FpuCompareHack = enabled; break; |
284 |
|
|
case Fix_FpuMultiply: FpuMulHack = enabled; break; |
285 |
|
|
case Fix_FpuNegDiv: FpuNegDivHack = enabled; break; |
286 |
|
|
case Fix_XGKick: XgKickHack = enabled; break; |
287 |
|
|
case Fix_IpuWait: IPUWaitHack = enabled; break; |
288 |
|
|
case Fix_EETiming: EETimingHack = enabled; break; |
289 |
|
|
case Fix_SkipMpeg: SkipMPEGHack = enabled; break; |
290 |
|
|
case Fix_OPHFlag: OPHFlagHack = enabled; break; |
291 |
|
|
|
292 |
|
|
jNO_DEFAULT; |
293 |
|
|
} |
294 |
|
|
} |
295 |
|
|
|
296 |
|
|
bool Pcsx2Config::GamefixOptions::Get( GamefixId id ) const |
297 |
|
|
{ |
298 |
|
|
EnumAssert( id ); |
299 |
|
|
switch(id) |
300 |
|
|
{ |
301 |
|
|
case Fix_VuAddSub: return VuAddSubHack; |
302 |
|
|
case Fix_VuClipFlag: return VuClipFlagHack; |
303 |
|
|
case Fix_FpuCompare: return FpuCompareHack; |
304 |
|
|
case Fix_FpuMultiply: return FpuMulHack; |
305 |
|
|
case Fix_FpuNegDiv: return FpuNegDivHack; |
306 |
|
|
case Fix_XGKick: return XgKickHack; |
307 |
|
|
case Fix_IpuWait: return IPUWaitHack; |
308 |
|
|
case Fix_EETiming: return EETimingHack; |
309 |
|
|
case Fix_SkipMpeg: return SkipMPEGHack; |
310 |
|
|
case Fix_OPHFlag: return OPHFlagHack; |
311 |
|
|
|
312 |
|
|
jNO_DEFAULT |
313 |
|
|
} |
314 |
|
|
return false; // unreachable, but we still need to suppress warnings >_< |
315 |
|
|
} |
316 |
|
|
|
317 |
william |
31 |
void Pcsx2Config::GamefixOptions::LoadSave( IniInterface& ini ) |
318 |
|
|
{ |
319 |
|
|
GamefixOptions defaults; |
320 |
william |
62 |
ScopedIniGroup path( ini, L"Gamefixes" ); |
321 |
william |
31 |
|
322 |
|
|
IniBitBool( VuAddSubHack ); |
323 |
|
|
IniBitBool( VuClipFlagHack ); |
324 |
|
|
IniBitBool( FpuCompareHack ); |
325 |
|
|
IniBitBool( FpuMulHack ); |
326 |
|
|
IniBitBool( FpuNegDivHack ); |
327 |
|
|
IniBitBool( XgKickHack ); |
328 |
|
|
IniBitBool( IPUWaitHack ); |
329 |
|
|
IniBitBool( EETimingHack ); |
330 |
william |
62 |
IniBitBool( SkipMPEGHack ); |
331 |
|
|
IniBitBool( OPHFlagHack ); |
332 |
william |
31 |
} |
333 |
|
|
|
334 |
|
|
Pcsx2Config::Pcsx2Config() |
335 |
|
|
{ |
336 |
|
|
bitset = 0; |
337 |
|
|
McdEnableEjection = true; |
338 |
|
|
} |
339 |
|
|
|
340 |
|
|
void Pcsx2Config::LoadSave( IniInterface& ini ) |
341 |
|
|
{ |
342 |
|
|
Pcsx2Config defaults; |
343 |
william |
62 |
ScopedIniGroup path( ini, L"EmuCore" ); |
344 |
william |
31 |
|
345 |
|
|
IniBitBool( CdvdVerboseReads ); |
346 |
|
|
IniBitBool( CdvdDumpBlocks ); |
347 |
|
|
IniBitBool( EnablePatches ); |
348 |
|
|
IniBitBool( EnableCheats ); |
349 |
|
|
IniBitBool( ConsoleToStdio ); |
350 |
|
|
IniBitBool( HostFs ); |
351 |
|
|
|
352 |
|
|
IniBitBool( McdEnableEjection ); |
353 |
|
|
IniBitBool( MultitapPort0_Enabled ); |
354 |
|
|
IniBitBool( MultitapPort1_Enabled ); |
355 |
|
|
|
356 |
|
|
// Process various sub-components: |
357 |
|
|
|
358 |
|
|
Speedhacks .LoadSave( ini ); |
359 |
|
|
Cpu .LoadSave( ini ); |
360 |
|
|
GS .LoadSave( ini ); |
361 |
|
|
Gamefixes .LoadSave( ini ); |
362 |
|
|
Profiler .LoadSave( ini ); |
363 |
|
|
|
364 |
|
|
Trace .LoadSave( ini ); |
365 |
|
|
|
366 |
|
|
ini.Flush(); |
367 |
|
|
} |
368 |
|
|
|
369 |
|
|
bool Pcsx2Config::MultitapEnabled( uint port ) const |
370 |
|
|
{ |
371 |
|
|
pxAssert( port < 2 ); |
372 |
|
|
return (port==0) ? MultitapPort0_Enabled : MultitapPort1_Enabled; |
373 |
|
|
} |
374 |
|
|
|
375 |
|
|
void Pcsx2Config::Load( const wxString& srcfile ) |
376 |
|
|
{ |
377 |
|
|
//m_IsLoaded = true; |
378 |
|
|
|
379 |
|
|
// Note: Extra parenthesis resolves "I think this is a function" issues with C++. |
380 |
|
|
wxFileConfig cfg( srcfile ); |
381 |
|
|
IniLoader loader( (IniLoader( cfg )) ); |
382 |
|
|
LoadSave( loader ); |
383 |
|
|
} |
384 |
|
|
|
385 |
|
|
void Pcsx2Config::Save( const wxString& dstfile ) |
386 |
|
|
{ |
387 |
|
|
//if( !m_IsLoaded ) return; |
388 |
|
|
|
389 |
|
|
wxFileConfig cfg( dstfile ); |
390 |
|
|
IniSaver saver( (IniSaver( cfg )) ); |
391 |
|
|
LoadSave( saver ); |
392 |
|
|
} |