/[pcsx2_0.9.7]/trunk/pcsx2/gui/Panels/SpeedhacksPanel.cpp
ViewVC logotype

Contents of /trunk/pcsx2/gui/Panels/SpeedhacksPanel.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 1 month ago) by william
File size: 14735 byte(s)
re-commit (had local access denied errors when committing)
1 /* 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 #include "App.h"
18 #include "ConfigurationPanels.h"
19
20 using namespace pxSizerFlags;
21
22 const wxChar* Panels::SpeedHacksPanel::GetEEcycleSliderMsg( int val )
23 {
24 switch( val )
25 {
26 case 1:
27 return pxEt( "!Panel:Speedhacks:EECycleX1",
28 L"1 - Default cyclerate. This closely matches the actual speed of a real PS2 EmotionEngine."
29 );
30
31 case 2:
32 return pxEt( "!Panel:Speedhacks:EECycleX2",
33 L"2 - Reduces the EE's cyclerate by about 33%. Mild speedup for most games with high compatibility."
34 );
35
36 case 3:
37 return pxEt( "!Panel:Speedhacks:EECycleX3",
38 L"3 - Reduces the EE's cyclerate by about 50%. Moderate speedup, but *will* cause stuttering "
39 L"audio on many FMVs."
40 );
41
42 default:
43 break;
44 }
45
46 return L"Unreachable Warning Suppressor!!";
47 }
48
49 const wxChar* Panels::SpeedHacksPanel::GetVUcycleSliderMsg( int val )
50 {
51 switch( val )
52 {
53 case 0:
54 return pxEt( "!Panel:Speedhacks:VUCycleStealOff",
55 L"0 - Disables VU Cycle Stealing. Most compatible setting!"
56 );
57
58 case 1:
59 return pxEt( "!Panel:Speedhacks:VUCycleSteal1",
60 L"1 - Mild VU Cycle Stealing. Lower compatibility, but some speedup for most games."
61 );
62
63 case 2:
64 return pxEt( "!Panel:Speedhacks:VUCycleSteal2",
65 L"2 - Moderate VU Cycle Stealing. Even lower compatibility, but significant speedups in some games."
66 );
67
68 case 3:
69 // TODO: Mention specific games that benefit from this setting here.
70 return pxEt( "!Panel:Speedhacks:VUCycleSteal3",
71 L"3 - Maximum VU Cycle Stealing. Usefulness is limited, as this will cause flickering "
72 L"visuals or slowdown in most games."
73 );
74 default:
75 break;
76 }
77
78 return L"Unreachable Warning Suppressor!!";
79 }
80
81 void Panels::SpeedHacksPanel::SetEEcycleSliderMsg()
82 {
83 m_msg_eecycle->SetLabel( GetEEcycleSliderMsg(m_slider_eecycle->GetValue()) );
84 }
85
86 void Panels::SpeedHacksPanel::SetVUcycleSliderMsg()
87 {
88 m_msg_vustealer->SetLabel( GetVUcycleSliderMsg(m_slider_vustealer->GetValue()) );
89 }
90
91 Panels::SpeedHacksPanel::SpeedHacksPanel( wxWindow* parent )
92 : BaseApplicableConfigPanel( parent )
93 {
94 const wxSizerFlags sliderFlags( wxSizerFlags().Border( wxLEFT | wxRIGHT, 8 ).Expand() );
95
96 m_check_Enable = new pxCheckBox( this, _("Enable speedhacks"),
97 pxE( "!Panel:Speedhacks:Overview",
98 L"Speedhacks usually improve emulation speed, but can cause glitches, broken audio, and "
99 L"false FPS readings. When having emulation problems, disable this panel first."
100 )
101 );
102 m_check_Enable->SetToolTip(_("A safe and easy way to make sure that all speedhacks are completely disabled.")).SetSubPadding( 1 );
103
104 wxPanelWithHelpers* left = new wxPanelWithHelpers( this, wxVERTICAL );
105 wxPanelWithHelpers* right = new wxPanelWithHelpers( this, wxVERTICAL );
106
107 left->SetMinWidth( 300 );
108 right->SetMinWidth( 300 );
109
110 m_button_Defaults = new wxButton( right, wxID_DEFAULT, _("Restore Defaults") );
111 pxSetToolTip( m_button_Defaults, _("Resets all speedhack options to their defaults, which consequently turns them all OFF.") );
112
113 // ------------------------------------------------------------------------
114 // EE Cyclerate Hack Section:
115
116 // Misc help text that I might find a home for later:
117 // Cycle stealing works by 'fast-forwarding' the EE by an arbitrary number of cycles whenever VU1 micro-programs
118 // are run, which works as a rough-guess skipping of what would normally be idle time spent running on the EE.
119
120 wxPanelWithHelpers* eeSliderPanel = new wxPanelWithHelpers( left, wxVERTICAL, _("EE Cyclerate [Not Recommended]") );
121
122 m_slider_eecycle = new wxSlider( eeSliderPanel, wxID_ANY, 1, 1, 3,
123 wxDefaultPosition, wxDefaultSize, wxHORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS );
124
125 m_msg_eecycle = new pxStaticHeading( eeSliderPanel );
126 m_msg_eecycle->SetForegroundColour( wxColour( L"Red" ) );
127 m_msg_eecycle->SetHeight(3);
128
129 const wxChar* ee_tooltip = pxEt( "!ContextTip:Speedhacks:EECycleRate Slider",
130 L"Setting higher values on this slider effectively reduces the clock speed of the EmotionEngine's "
131 L"R5900 core cpu, and typically brings big speedups to games that fail to utilize "
132 L"the full potential of the real PS2 hardware."
133 );
134
135 pxSetToolTip( m_slider_eecycle, ee_tooltip );
136 pxSetToolTip( m_msg_eecycle, ee_tooltip );
137
138 // ------------------------------------------------------------------------
139 // VU Cycle Stealing Hack Section:
140
141 wxPanelWithHelpers* vuSliderPanel = new wxPanelWithHelpers( right, wxVERTICAL, _("VU Cycle Stealing [Not Recommended]") );
142
143 m_slider_vustealer = new wxSlider( vuSliderPanel, wxID_ANY, 0, 0, 3, wxDefaultPosition, wxDefaultSize,
144 wxHORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS );
145
146 m_msg_vustealer = new pxStaticHeading( vuSliderPanel );
147 m_msg_vustealer->SetForegroundColour( wxColour( L"Red" ) );
148 m_msg_vustealer->SetHeight(3);
149
150 const wxChar* vu_tooltip = pxEt( "!ContextTip:Speedhacks:VUCycleStealing Slider",
151 L"This slider controls the amount of cycles the VU unit steals from the EmotionEngine. Higher values increase the number of "
152 L"cycles stolen from the EE for each VU microprogram the game runs."
153 );
154
155 pxSetToolTip( m_slider_vustealer, vu_tooltip );
156 pxSetToolTip( m_msg_vustealer, vu_tooltip );
157
158 // ------------------------------------------------------------------------
159 // microVU Hacks Section:
160
161 wxPanelWithHelpers* vuHacksPanel = new wxPanelWithHelpers( right, wxVERTICAL, _("microVU Hacks") );
162
163 m_check_vuFlagHack = new pxCheckBox( vuHacksPanel, _("mVU Flag Hack"),
164 _("Good Speedup and High Compatibility; may cause garbage graphics, SPS, etc... [Recommended]") );
165
166 m_check_vuBlockHack = new pxCheckBox( vuHacksPanel, _("mVU Block Hack"),
167 _("Good Speedup and High Compatibility; may cause garbage graphics, SPS, etc...") );
168
169 m_check_vuMinMax = new pxCheckBox( vuHacksPanel, _("mVU Min/Max Hack"),
170 _("Small Speedup; may cause black screens, garbage graphics, SPS, etc... [Not Recommended]") );
171
172 m_check_vuFlagHack->SetToolTip( pxEt( "!ContextTip:Speedhacks:vuFlagHack",
173 L"Updates Status Flags only on blocks which will read them, instead of all the time. "
174 L"This is safe most of the time, and Super VU does something similar by default."
175 ) );
176
177 m_check_vuBlockHack->SetToolTip( pxEt( "!ContextTip:Speedhacks:vuBlockHack",
178 L"Assumes that very far into future blocks will not need old flag instance data. "
179 L"This should be pretty safe. It is unknown if this breaks any game..."
180 ) );
181
182 m_check_vuMinMax->SetToolTip( pxEt( "!ContextTip:Speedhacks:vuMinMax",
183 L"Uses SSE's Min/Max Floating Point Operations instead of custom logical Min/Max routines. "
184 L"Known to break Gran Turismo 4, Tekken 5."
185 ) );
186
187 // ------------------------------------------------------------------------
188 // All other hacks Section:
189
190 wxPanelWithHelpers* miscHacksPanel = new wxPanelWithHelpers( left, wxVERTICAL, _("Other Hacks") );
191
192 m_check_intc = new pxCheckBox( miscHacksPanel, _("Enable INTC Spin Detection"),
193 _("Huge speedup for some games, with almost no compatibility side effects. [Recommended]") );
194
195 m_check_waitloop = new pxCheckBox( miscHacksPanel, _("Enable Wait Loop Detection"),
196 _("Moderate speedup for some games, with no known side effects. [Recommended]" ) );
197
198 m_check_fastCDVD = new pxCheckBox( miscHacksPanel, _("Enable fast CDVD"),
199 _("Fast disc access, less loading times. [Not Recommended]") );
200
201
202 m_check_intc->SetToolTip( pxEt( "!ContextTip:Speedhacks:INTC",
203 L"This hack works best for games that use the INTC Status register to wait for vsyncs, which includes primarily non-3D "
204 L"RPG titles. Games that do not use this method of vsync will see little or no speedup from this hack."
205 ) );
206
207 m_check_waitloop->SetToolTip( pxEt( "!ContextTip:Speedhacks:BIFC0",
208 L"Primarily targetting the EE idle loop at address 0x81FC0 in the kernel, this hack attempts to "
209 L"detect loops whose bodies are guaranteed to result in the same machine state for every iteration "
210 L"until a scheduled event triggers emulation of another unit. After a single iteration of such loops, "
211 L"we advance to the time of the next event or the end of the processor's timeslice, whichever comes first."
212 ) );
213
214 m_check_fastCDVD->SetToolTip( pxEt( "!ContextTip:Speedhacks:fastCDVD",
215 L"Check HDLoader compatibility lists for known games that have issues with this. (Often marked as needing 'mode 1' or 'slow DVD'"
216 ) );
217
218 // ------------------------------------------------------------------------
219 // Layout and Size ---> (!!)
220
221 //wxFlexGridSizer& DefEnableSizer( *new wxFlexGridSizer( 3, 0, 12 ) );
222 //DefEnableSizer.AddGrowableCol( 1, 1 );
223 //DefEnableSizer.AddGrowableCol( 2, 10 );
224 //DefEnableSizer.AddGrowableCol( 1, 1 );
225 //DefEnableSizer += m_button_Defaults | StdSpace().Align( wxALIGN_LEFT );
226 //DefEnableSizer += pxStretchSpacer(1);
227 //DefEnableSizer += m_check_Enable | StdExpand().Align( wxALIGN_RIGHT );
228
229 *eeSliderPanel += m_slider_eecycle | sliderFlags;
230 *eeSliderPanel += m_msg_eecycle | sliderFlags;
231
232 *vuSliderPanel += m_slider_vustealer | sliderFlags;
233 *vuSliderPanel += m_msg_vustealer | sliderFlags;
234
235 *vuHacksPanel += m_check_vuFlagHack;
236 *vuHacksPanel += m_check_vuBlockHack;
237 *vuHacksPanel += m_check_vuMinMax;
238
239 *miscHacksPanel += m_check_intc;
240 *miscHacksPanel += m_check_waitloop;
241 *miscHacksPanel += m_check_fastCDVD;
242
243 *left += eeSliderPanel | StdExpand();
244 *left += miscHacksPanel | StdExpand();
245
246 *right += vuSliderPanel | StdExpand();
247 *right += vuHacksPanel | StdExpand();
248 *right += StdPadding;
249 *right += m_button_Defaults| StdButton();
250
251 s_table = new wxFlexGridSizer( 2 );
252 s_table->AddGrowableCol( 0, 1 );
253 s_table->AddGrowableCol( 1, 1 );
254 *s_table+= left | pxExpand;
255 *s_table+= right | pxExpand;
256
257 *this += m_check_Enable;
258 *this += new wxStaticLine( this ) | pxExpand.Border(wxLEFT | wxRIGHT, 20);
259 *this += StdPadding;
260 *this += s_table | pxExpand;
261
262 // ------------------------------------------------------------------------
263
264 Connect( wxEVT_SCROLL_PAGEUP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
265 Connect( wxEVT_SCROLL_PAGEDOWN, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
266 Connect( wxEVT_SCROLL_LINEUP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
267 Connect( wxEVT_SCROLL_LINEDOWN, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
268 Connect( wxEVT_SCROLL_TOP, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
269 Connect( wxEVT_SCROLL_BOTTOM, wxScrollEventHandler( SpeedHacksPanel::Slider_Click ) );
270
271 Connect( m_slider_eecycle->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( SpeedHacksPanel::EECycleRate_Scroll ) );
272 Connect( m_slider_vustealer->GetId(), wxEVT_SCROLL_CHANGED, wxScrollEventHandler( SpeedHacksPanel::VUCycleRate_Scroll ) );
273 Connect( m_check_Enable->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( SpeedHacksPanel::OnEnable_Toggled ) );
274 Connect( wxID_DEFAULT, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( SpeedHacksPanel::Defaults_Click ) );
275 }
276
277 void Panels::SpeedHacksPanel::EnableStuff()
278 {
279 wxSizerItemList& items( s_table->GetChildren() );
280
281 wxSizerItemList::iterator it = items.begin();
282 wxSizerItemList::iterator end = items.end();
283
284 while( it != end )
285 {
286 (*it)->GetWindow()->Enable( m_check_Enable->GetValue() );
287 ++it;
288 }
289 }
290
291 void Panels::SpeedHacksPanel::AppStatusEvent_OnSettingsApplied()
292 {
293 AppStatusEvent_OnSettingsApplied( g_Conf->EmuOptions.Speedhacks );
294 }
295
296 void Panels::SpeedHacksPanel::AppStatusEvent_OnSettingsApplied( const Pcsx2Config::SpeedhackOptions& opts )
297 {
298 const bool enabled = g_Conf->EnableSpeedHacks;
299
300 m_check_Enable ->SetValue( !!enabled );
301
302 m_slider_eecycle ->SetValue( opts.EECycleRate + 1 );
303 m_slider_vustealer ->SetValue( opts.VUCycleSteal );
304
305 SetEEcycleSliderMsg();
306 SetVUcycleSliderMsg();
307
308 m_check_vuFlagHack ->SetValue(opts.vuFlagHack);
309 m_check_vuBlockHack ->SetValue(opts.vuBlockHack);
310 m_check_vuMinMax ->SetValue(opts.vuMinMax);
311 m_check_intc ->SetValue(opts.IntcStat);
312 m_check_waitloop ->SetValue(opts.WaitLoop);
313 m_check_fastCDVD ->SetValue(opts.fastCDVD);
314
315 EnableStuff();
316
317 // Layout necessary to ensure changed slider text gets re-aligned properly
318 Layout();
319 }
320
321 void Panels::SpeedHacksPanel::Apply()
322 {
323 g_Conf->EnableSpeedHacks = m_check_Enable->GetValue();
324
325 Pcsx2Config::SpeedhackOptions& opts( g_Conf->EmuOptions.Speedhacks );
326
327 opts.EECycleRate = m_slider_eecycle->GetValue()-1;
328 opts.VUCycleSteal = m_slider_vustealer->GetValue();
329
330 opts.WaitLoop = m_check_waitloop->GetValue();
331 opts.fastCDVD = m_check_fastCDVD->GetValue();
332 opts.IntcStat = m_check_intc->GetValue();
333 opts.vuFlagHack = m_check_vuFlagHack->GetValue();
334 opts.vuBlockHack = m_check_vuBlockHack->GetValue();
335 opts.vuMinMax = m_check_vuMinMax->GetValue();
336
337 // If the user has a command line override specified, we need to disable it
338 // so that their changes take effect
339 wxGetApp().Overrides.DisableSpeedhacks = false;
340 }
341
342 void Panels::SpeedHacksPanel::OnEnable_Toggled( wxCommandEvent& evt )
343 {
344 EnableStuff();
345 evt.Skip();
346 }
347
348 void Panels::SpeedHacksPanel::Defaults_Click( wxCommandEvent& evt )
349 {
350 AppStatusEvent_OnSettingsApplied( Pcsx2Config::SpeedhackOptions() );
351 evt.Skip();
352 }
353
354 void Panels::SpeedHacksPanel::Slider_Click(wxScrollEvent &event) {
355 wxSlider* slider = (wxSlider*) event.GetEventObject();
356 int value = slider->GetValue();
357 int eventType = event.GetEventType();
358 if (eventType == wxEVT_SCROLL_PAGEUP || eventType == wxEVT_SCROLL_LINEUP) {
359 if (value > slider->GetMin()) {
360 slider->SetValue(value-1);
361 }
362 }
363 else if (eventType == wxEVT_SCROLL_TOP) {
364 slider->SetValue(slider->GetMin());
365 }
366 else if (eventType == wxEVT_SCROLL_PAGEDOWN || eventType == wxEVT_SCROLL_LINEDOWN) {
367 if (value < slider->GetMax()) {
368 slider->SetValue(value+1);
369 }
370 }
371 else if (eventType == wxEVT_SCROLL_BOTTOM) {
372 slider->SetValue(slider->GetMax());
373 }
374
375 event.Skip();
376 }
377
378 void Panels::SpeedHacksPanel::EECycleRate_Scroll(wxScrollEvent &event)
379 {
380 SetEEcycleSliderMsg();
381 event.Skip();
382 }
383
384 void Panels::SpeedHacksPanel::VUCycleRate_Scroll(wxScrollEvent &event)
385 {
386 SetVUcycleSliderMsg();
387 event.Skip();
388 }

  ViewVC Help
Powered by ViewVC 1.1.22