/[pcsx2_0.9.7]/trunk/pcsx2/Pcsx2Config.cpp
ViewVC logotype

Annotation of /trunk/pcsx2/Pcsx2Config.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (hide annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 1 month ago) by william
File size: 10384 byte(s)
re-commit (had local access denied errors when committing)
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     Pcsx2Config::SpeedhackOptions::SpeedhackOptions()
39     {
40 william 273 DisableAll();
41    
42     // Set recommended speedhacks to enabled by default. They'll still be off globally on resets.
43     WaitLoop = true;
44     IntcStat = true;
45     vuFlagHack = true;
46     }
47    
48     Pcsx2Config::SpeedhackOptions& Pcsx2Config::SpeedhackOptions::DisableAll()
49     {
50 william 31 bitset = 0;
51     EECycleRate = 0;
52     VUCycleSteal = 0;
53 william 273
54     return *this;
55 william 31 }
56    
57     void Pcsx2Config::SpeedhackOptions::LoadSave( IniInterface& ini )
58     {
59     SpeedhackOptions defaults;
60 william 62 ScopedIniGroup path( ini, L"Speedhacks" );
61 william 31
62     IniBitfield( EECycleRate );
63     IniBitfield( VUCycleSteal );
64 william 62 IniBitBool( fastCDVD );
65 william 31 IniBitBool( IntcStat );
66     IniBitBool( WaitLoop );
67     IniBitBool( vuFlagHack );
68 william 62 IniBitBool( vuBlockHack );
69 william 31 IniBitBool( vuMinMax );
70     }
71    
72     void Pcsx2Config::ProfilerOptions::LoadSave( IniInterface& ini )
73     {
74     ProfilerOptions defaults;
75 william 62 ScopedIniGroup path( ini, L"Profiler" );
76 william 31
77     IniBitBool( Enabled );
78     IniBitBool( RecBlocks_EE );
79     IniBitBool( RecBlocks_IOP );
80     IniBitBool( RecBlocks_VU0 );
81     IniBitBool( RecBlocks_VU1 );
82     }
83    
84     Pcsx2Config::RecompilerOptions::RecompilerOptions()
85     {
86     bitset = 0;
87    
88 william 62 //StackFrameChecks = false;
89 william 273 //PreBlockCheckEE = false;
90 william 31
91     // All recs are enabled by default.
92    
93     EnableEE = true;
94     EnableIOP = true;
95     EnableVU0 = true;
96     EnableVU1 = true;
97    
98     UseMicroVU0 = true;
99     UseMicroVU1 = true;
100    
101     // vu and fpu clamping default to standard overflow.
102     vuOverflow = true;
103     //vuExtraOverflow = false;
104     //vuSignOverflow = false;
105     //vuUnderflow = false;
106    
107     fpuOverflow = true;
108     //fpuExtraOverflow = false;
109     //fpuFullMode = false;
110     }
111    
112     void Pcsx2Config::RecompilerOptions::ApplySanityCheck()
113     {
114     bool fpuIsRight = true;
115    
116     if( fpuExtraOverflow )
117     fpuIsRight = fpuOverflow;
118    
119     if( fpuFullMode )
120     fpuIsRight = fpuOverflow && fpuExtraOverflow;
121    
122     if( !fpuIsRight )
123     {
124     // Values are wonky; assume the defaults.
125     fpuOverflow = RecompilerOptions().fpuOverflow;
126     fpuExtraOverflow= RecompilerOptions().fpuExtraOverflow;
127     fpuFullMode = RecompilerOptions().fpuFullMode;
128     }
129    
130     bool vuIsOk = true;
131    
132     if( vuExtraOverflow ) vuIsOk = vuIsOk && vuOverflow;
133     if( vuSignOverflow ) vuIsOk = vuIsOk && vuExtraOverflow;
134    
135     if( !vuIsOk )
136     {
137     // Values are wonky; assume the defaults.
138     vuOverflow = RecompilerOptions().vuOverflow;
139     vuExtraOverflow = RecompilerOptions().vuExtraOverflow;
140     vuSignOverflow = RecompilerOptions().vuSignOverflow;
141     vuUnderflow = RecompilerOptions().vuUnderflow;
142     }
143     }
144    
145     void Pcsx2Config::RecompilerOptions::LoadSave( IniInterface& ini )
146     {
147     RecompilerOptions defaults;
148 william 62 ScopedIniGroup path( ini, L"Recompiler" );
149 william 31
150     IniBitBool( EnableEE );
151     IniBitBool( EnableIOP );
152     IniBitBool( EnableVU0 );
153     IniBitBool( EnableVU1 );
154    
155     IniBitBool( UseMicroVU0 );
156     IniBitBool( UseMicroVU1 );
157    
158     IniBitBool( vuOverflow );
159     IniBitBool( vuExtraOverflow );
160     IniBitBool( vuSignOverflow );
161     IniBitBool( vuUnderflow );
162    
163     IniBitBool( fpuOverflow );
164     IniBitBool( fpuExtraOverflow );
165     IniBitBool( fpuFullMode );
166    
167     IniBitBool( StackFrameChecks );
168 william 62 IniBitBool( PreBlockCheckEE );
169     IniBitBool( PreBlockCheckIOP );
170 william 31 }
171    
172     Pcsx2Config::CpuOptions::CpuOptions()
173     {
174     sseMXCSR.bitmask = DEFAULT_sseMXCSR;
175     sseVUMXCSR.bitmask = DEFAULT_sseVUMXCSR;
176     }
177    
178     void Pcsx2Config::CpuOptions::ApplySanityCheck()
179     {
180     sseMXCSR.ClearExceptionFlags().DisableExceptions();
181     sseVUMXCSR.ClearExceptionFlags().DisableExceptions();
182    
183     Recompiler.ApplySanityCheck();
184     }
185    
186     void Pcsx2Config::CpuOptions::LoadSave( IniInterface& ini )
187     {
188     CpuOptions defaults;
189 william 62 ScopedIniGroup path( ini, L"CPU" );
190 william 31
191     IniBitBoolEx( sseMXCSR.DenormalsAreZero, "FPU.DenormalsAreZero" );
192     IniBitBoolEx( sseMXCSR.FlushToZero, "FPU.FlushToZero" );
193     IniBitfieldEx( sseMXCSR.RoundingControl, "FPU.Roundmode" );
194    
195     IniBitBoolEx( sseVUMXCSR.DenormalsAreZero, "VU.DenormalsAreZero" );
196     IniBitBoolEx( sseVUMXCSR.FlushToZero, "VU.FlushToZero" );
197     IniBitfieldEx( sseVUMXCSR.RoundingControl, "VU.Roundmode" );
198    
199     Recompiler.LoadSave( ini );
200     }
201    
202     // Default GSOptions
203     Pcsx2Config::GSOptions::GSOptions()
204     {
205     FrameLimitEnable = true;
206     FrameSkipEnable = false;
207     VsyncEnable = false;
208    
209     SynchronousMTGS = false;
210     DisableOutput = false;
211 william 62 VsyncQueueSize = 2;
212 william 31
213     DefaultRegionMode = Region_NTSC;
214     FramesToDraw = 2;
215     FramesToSkip = 2;
216    
217     LimitScalar = 1.0;
218     FramerateNTSC = 59.94;
219     FrameratePAL = 50.0;
220     }
221    
222     void Pcsx2Config::GSOptions::LoadSave( IniInterface& ini )
223     {
224     GSOptions defaults;
225 william 62 ScopedIniGroup path( ini, L"GS" );
226 william 31
227     IniEntry( SynchronousMTGS );
228     IniEntry( DisableOutput );
229 william 62 IniEntry( VsyncQueueSize );
230 william 31
231     IniEntry( FrameLimitEnable );
232     IniEntry( FrameSkipEnable );
233     IniEntry( VsyncEnable );
234    
235     IniEntry( LimitScalar );
236     IniEntry( FramerateNTSC );
237     IniEntry( FrameratePAL );
238    
239     static const wxChar * const ntsc_pal_str[2] = { L"ntsc", L"pal" };
240     ini.EnumEntry( L"DefaultRegionMode", DefaultRegionMode, ntsc_pal_str, defaults.DefaultRegionMode );
241    
242     IniEntry( FramesToDraw );
243     IniEntry( FramesToSkip );
244     }
245    
246 william 62 const wxChar *const tbl_GamefixNames[] =
247     {
248     L"VuAddSub",
249     L"VuClipFlag",
250     L"FpuCompare",
251     L"FpuMul",
252     L"FpuNegDiv",
253     L"XGKick",
254     L"IpuWait",
255     L"EETiming",
256     L"SkipMpeg",
257     L"OPHFlag"
258     };
259    
260     const __fi wxChar* EnumToString( GamefixId id )
261     {
262     return tbl_GamefixNames[id];
263     }
264    
265 william 273 // all gamefixes are disabled by default.
266     Pcsx2Config::GamefixOptions::GamefixOptions()
267     {
268     DisableAll();
269     }
270    
271     Pcsx2Config::GamefixOptions& Pcsx2Config::GamefixOptions::DisableAll()
272     {
273     bitset = 0;
274     return *this;
275     }
276    
277 william 62 // Enables a full list of gamefixes. The list can be either comma or pipe-delimited.
278     // Example: "XGKick,IpuWait" or "EEtiming,FpuCompare"
279     // If an unrecognized tag is encountered, a warning is printed to the console, but no error
280     // is generated. This allows the system to function in the event that future versions of
281     // PCSX2 remove old hacks once they become obsolete.
282     void Pcsx2Config::GamefixOptions::Set( const wxString& list, bool enabled )
283     {
284     wxStringTokenizer izer( list, L",|", wxTOKEN_STRTOK );
285    
286     while( izer.HasMoreTokens() )
287     {
288     wxString token( izer.GetNextToken() );
289    
290     GamefixId i;
291     for (i=GamefixId_FIRST; i < pxEnumEnd; ++i)
292     {
293     if( token.CmpNoCase( EnumToString(i) ) == 0 ) break;
294     }
295     if( i < pxEnumEnd ) Set( i );
296     }
297     }
298    
299     void Pcsx2Config::GamefixOptions::Set( GamefixId id, bool enabled )
300     {
301     EnumAssert( id );
302     switch(id)
303     {
304     case Fix_VuAddSub: VuAddSubHack = enabled; break;
305     case Fix_VuClipFlag: VuClipFlagHack = enabled; break;
306     case Fix_FpuCompare: FpuCompareHack = enabled; break;
307     case Fix_FpuMultiply: FpuMulHack = enabled; break;
308     case Fix_FpuNegDiv: FpuNegDivHack = enabled; break;
309     case Fix_XGKick: XgKickHack = enabled; break;
310     case Fix_IpuWait: IPUWaitHack = enabled; break;
311     case Fix_EETiming: EETimingHack = enabled; break;
312     case Fix_SkipMpeg: SkipMPEGHack = enabled; break;
313     case Fix_OPHFlag: OPHFlagHack = enabled; break;
314    
315     jNO_DEFAULT;
316     }
317     }
318    
319     bool Pcsx2Config::GamefixOptions::Get( GamefixId id ) const
320     {
321     EnumAssert( id );
322     switch(id)
323     {
324     case Fix_VuAddSub: return VuAddSubHack;
325     case Fix_VuClipFlag: return VuClipFlagHack;
326     case Fix_FpuCompare: return FpuCompareHack;
327     case Fix_FpuMultiply: return FpuMulHack;
328     case Fix_FpuNegDiv: return FpuNegDivHack;
329     case Fix_XGKick: return XgKickHack;
330     case Fix_IpuWait: return IPUWaitHack;
331     case Fix_EETiming: return EETimingHack;
332     case Fix_SkipMpeg: return SkipMPEGHack;
333     case Fix_OPHFlag: return OPHFlagHack;
334    
335     jNO_DEFAULT
336     }
337     return false; // unreachable, but we still need to suppress warnings >_<
338     }
339    
340 william 31 void Pcsx2Config::GamefixOptions::LoadSave( IniInterface& ini )
341     {
342     GamefixOptions defaults;
343 william 62 ScopedIniGroup path( ini, L"Gamefixes" );
344 william 31
345     IniBitBool( VuAddSubHack );
346     IniBitBool( VuClipFlagHack );
347     IniBitBool( FpuCompareHack );
348     IniBitBool( FpuMulHack );
349     IniBitBool( FpuNegDivHack );
350     IniBitBool( XgKickHack );
351     IniBitBool( IPUWaitHack );
352     IniBitBool( EETimingHack );
353 william 62 IniBitBool( SkipMPEGHack );
354     IniBitBool( OPHFlagHack );
355 william 31 }
356    
357     Pcsx2Config::Pcsx2Config()
358     {
359     bitset = 0;
360 william 273 // Set defaults for fresh installs / reset settings
361 william 31 McdEnableEjection = true;
362 william 273 EnablePatches = true;
363 william 31 }
364    
365     void Pcsx2Config::LoadSave( IniInterface& ini )
366     {
367     Pcsx2Config defaults;
368 william 62 ScopedIniGroup path( ini, L"EmuCore" );
369 william 31
370     IniBitBool( CdvdVerboseReads );
371     IniBitBool( CdvdDumpBlocks );
372     IniBitBool( EnablePatches );
373     IniBitBool( EnableCheats );
374     IniBitBool( ConsoleToStdio );
375     IniBitBool( HostFs );
376    
377 william 280 IniBitBool( BackupSavestate );
378 william 31 IniBitBool( McdEnableEjection );
379     IniBitBool( MultitapPort0_Enabled );
380     IniBitBool( MultitapPort1_Enabled );
381    
382     // Process various sub-components:
383    
384     Speedhacks .LoadSave( ini );
385     Cpu .LoadSave( ini );
386     GS .LoadSave( ini );
387     Gamefixes .LoadSave( ini );
388     Profiler .LoadSave( ini );
389    
390     Trace .LoadSave( ini );
391    
392     ini.Flush();
393     }
394    
395     bool Pcsx2Config::MultitapEnabled( uint port ) const
396     {
397     pxAssert( port < 2 );
398     return (port==0) ? MultitapPort0_Enabled : MultitapPort1_Enabled;
399     }
400    
401     void Pcsx2Config::Load( const wxString& srcfile )
402     {
403     //m_IsLoaded = true;
404    
405     // Note: Extra parenthesis resolves "I think this is a function" issues with C++.
406     wxFileConfig cfg( srcfile );
407     IniLoader loader( (IniLoader( cfg )) );
408     LoadSave( loader );
409     }
410    
411     void Pcsx2Config::Save( const wxString& dstfile )
412     {
413     //if( !m_IsLoaded ) return;
414    
415     wxFileConfig cfg( dstfile );
416     IniSaver saver( (IniSaver( cfg )) );
417     LoadSave( saver );
418     }

  ViewVC Help
Powered by ViewVC 1.1.22