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

  ViewVC Help
Powered by ViewVC 1.1.22