1 /* Copyright 2005 Guillaume Duhamel
2 Copyright 2005-2006, 2013 Theo Berkau
3 Copyright 2008 Filipe Azevedo <pasnox@gmail.com>
4
5 This file is part of Yabause.
6
7 Yabause is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 Yabause is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Yabause; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 #include "UIYabause.h"
22 #include "../Settings.h"
23 #include "../VolatileSettings.h"
24 #include "UISettings.h"
25 #include "UIBackupRam.h"
26 #include "UICheats.h"
27 #include "UICheatSearch.h"
28 #include "UIDebugSH2.h"
29 #include "UIDebugVDP1.h"
30 #include "UIDebugVDP2.h"
31 #include "UIDebugM68K.h"
32 #include "UIDebugSCUDSP.h"
33 #include "UIDebugSCSP.h"
34 #include "UIDebugSCSPChan.h"
35 #include "UIDebugSCSPDSP.h"
36 #include "UIMemoryEditor.h"
37 #include "UIMemoryTransfer.h"
38 #include "UIAbout.h"
39 #include "../YabauseGLProxy.h"
40 #include "../QtYabause.h"
41 #include "../CommonDialogs.h"
42
43 #include <QKeyEvent>
44 #include <QTextEdit>
45 #include <QDockWidget>
46 #include <QImageWriter>
47 #include <QUrl>
48 #include <QDesktopServices>
49 #include <QDateTime>
50 #include <QFile>
51
52 #include <QDebug>
53
54 extern "C" {
55 extern VideoInterface_struct *VIDCoreList[];
56 }
57
58 //#define USE_UNIFIED_TITLE_TOOLBAR
59
qAppendLog(const char * s)60 void qAppendLog( const char* s )
61 {
62 UIYabause* ui = QtYabause::mainWindow( false );
63
64 if ( ui ) {
65 ui->appendLog( s );
66 }
67 else {
68 qWarning( "%s", s );
69 }
70 }
71
UIYabause(QWidget * parent)72 UIYabause::UIYabause( QWidget* parent )
73 : QMainWindow( parent )
74 {
75 mInit = false;
76 search.clear();
77 searchType = 0;
78
79 // setup dialog
80 setupUi( this );
81 toolBar->insertAction( aFileSettings, mFileSaveState->menuAction() );
82 toolBar->insertAction( aFileSettings, mFileLoadState->menuAction() );
83 toolBar->insertSeparator( aFileSettings );
84 setAttribute( Qt::WA_DeleteOnClose );
85 #ifdef USE_UNIFIED_TITLE_TOOLBAR
86 setUnifiedTitleAndToolBarOnMac( true );
87 #endif
88 fSound->setParent( 0, Qt::Popup );
89 fVideoDriver->setParent( 0, Qt::Popup );
90 fSound->installEventFilter( this );
91 fVideoDriver->installEventFilter( this );
92 // Get Screen res list
93 getSupportedResolutions();
94 // fill combo driver
95 cbVideoDriver->blockSignals( true );
96 for ( int i = 0; VIDCoreList[i] != NULL; i++ )
97 cbVideoDriver->addItem( VIDCoreList[i]->Name, VIDCoreList[i]->id );
98 cbVideoDriver->blockSignals( false );
99 // create glcontext
100 mYabauseGL = new YabauseGLProxy( this );
101 // and set it as central application widget
102 setCentralWidget( mYabauseGL->getWidget() );
103 // create log widget
104 teLog = new QTextEdit( this );
105 teLog->setReadOnly( true );
106 teLog->setWordWrapMode( QTextOption::NoWrap );
107 teLog->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
108 teLog->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
109 mLogDock = new QDockWidget( this );
110 mLogDock->setWindowTitle( "Log" );
111 mLogDock->setWidget( teLog );
112 addDockWidget( Qt::BottomDockWidgetArea, mLogDock );
113 mLogDock->setVisible( false );
114 mCanLog = true;
115 oldMouseX = oldMouseY = 0;
116 mouseCaptured = false;
117
118 #ifndef SH2_TRACE
119 aTraceLogging->setVisible(false);
120 #endif
121
122 // create emulator thread
123 mYabauseThread = new YabauseThread( this );
124 // create hide mouse timer
125 hideMouseTimer = new QTimer();
126 // create mouse cursor timer
127 mouseCursorTimer = new QTimer();
128 // connections
129 connect( mYabauseThread, SIGNAL( requestSize( const QSize& ) ), this, SLOT( sizeRequested( const QSize& ) ) );
130 connect( mYabauseThread, SIGNAL( requestFullscreen( bool ) ), this, SLOT( fullscreenRequested( bool ) ) );
131 connect( mYabauseThread, SIGNAL( requestVolumeChange( int ) ), this, SLOT( on_sVolume_valueChanged( int ) ) );
132 connect( aViewLog, SIGNAL( toggled( bool ) ), mLogDock, SLOT( setVisible( bool ) ) );
133 connect( mLogDock->toggleViewAction(), SIGNAL( toggled( bool ) ), aViewLog, SLOT( setChecked( bool ) ) );
134 connect( mYabauseThread, SIGNAL( error( const QString&, bool ) ), this, SLOT( errorReceived( const QString&, bool ) ) );
135 connect( mYabauseThread, SIGNAL( pause( bool ) ), this, SLOT( pause( bool ) ) );
136 connect( mYabauseThread, SIGNAL( reset() ), this, SLOT( reset() ) );
137 connect( hideMouseTimer, SIGNAL( timeout() ), this, SLOT( hideMouse() ));
138 connect( mouseCursorTimer, SIGNAL( timeout() ), this, SLOT( cursorRestore() ));
139 connect( mYabauseThread, SIGNAL( toggleEmulateMouse( bool ) ), this, SLOT( toggleEmulateMouse( bool ) ) );
140 connect( mYabauseThread, SIGNAL( disableGL() ), this, SLOT( disableGL() ) );
141
142 // Load shortcuts
143 VolatileSettings* vs = QtYabause::volatileSettings();
144 QList<QAction *> actions = findChildren<QAction *>();
145 foreach ( QAction* action, actions )
146 {
147 if (action->text().isEmpty())
148 continue;
149
150 QString text = vs->value(QString("Shortcuts/") + action->text(), "").toString();
151 if (text.isEmpty())
152 continue;
153 action->setShortcut(text);
154 }
155
156 // retranslate widgets
157 QtYabause::retranslateWidget( this );
158
159 QList<QAction *> actionList = menubar->actions();
160 for(int i = 0;i < actionList.size();i++) {
161 addAction(actionList.at(i));
162 }
163
164 restoreGeometry( vs->value("General/Geometry" ).toByteArray() );
165 mYabauseGL->setMouseTracking(true);
166 setMouseTracking(true);
167 mouseXRatio = mouseYRatio = 1.0;
168 emulateMouse = false;
169 mouseSensitivity = vs->value( "Input/GunMouseSensitivity", 100 ).toInt();
170 showMenuBarHeight = menubar->height();
171 translations = QtYabause::getTranslationList();
172
173 VIDSoftSetBilinear(QtYabause::settings()->value( "Video/Bilinear", false ).toBool());
174 }
175
~UIYabause()176 UIYabause::~UIYabause()
177 {
178 mCanLog = false;
179 }
180
showEvent(QShowEvent * e)181 void UIYabause::showEvent( QShowEvent* e )
182 {
183 QMainWindow::showEvent( e );
184
185 if ( !mInit )
186 {
187 LogStart();
188 LogChangeOutput( DEBUG_CALLBACK, (char*)qAppendLog );
189 VolatileSettings* vs = QtYabause::volatileSettings();
190
191 if ( vs->value( "View/Menubar" ).toInt() == BD_ALWAYSHIDE )
192 menubar->hide();
193 if ( vs->value( "View/Toolbar" ).toInt() == BD_ALWAYSHIDE )
194 toolBar->hide();
195 if ( vs->value( "autostart" ).toBool() )
196 aEmulationRun->trigger();
197 aEmulationFrameSkipLimiter->setChecked( vs->value( "General/EnableFrameSkipLimiter" ).toBool() );
198 aViewFPS->setChecked( vs->value( "General/ShowFPS" ).toBool() );
199 mInit = true;
200 }
201 }
202
closeEvent(QCloseEvent * e)203 void UIYabause::closeEvent( QCloseEvent* e )
204 {
205 aEmulationPause->trigger();
206 LogStop();
207
208 if (isFullScreen())
209 // Need to switch out of full screen or the geometry settings get saved
210 fullscreenRequested( false );
211 Settings* vs = QtYabause::settings();
212 vs->setValue( "General/Geometry", saveGeometry() );
213 vs->sync();
214
215 QMainWindow::closeEvent( e );
216 }
217
keyPressEvent(QKeyEvent * e)218 void UIYabause::keyPressEvent( QKeyEvent* e )
219 {
220 if (emulateMouse && mouseCaptured && e->key() == Qt::Key_Escape)
221 mouseCaptured = false;
222 else
223 PerKeyDown( e->key() );
224 }
225
keyReleaseEvent(QKeyEvent * e)226 void UIYabause::keyReleaseEvent( QKeyEvent* e )
227 { PerKeyUp( e->key() ); }
228
leaveEvent(QEvent * e)229 void UIYabause::leaveEvent( QEvent* e )
230 {
231 if (emulateMouse && mouseCaptured)
232 {
233 // lock cursor to center
234 int midX = geometry().x()+(width()/2); // widget global x
235 int midY = geometry().y()+menubar->height()+toolBar->height()+(height()/2); // widget global y
236
237 QPoint newPos(midX, midY);
238 this->cursor().setPos(newPos);
239 }
240 }
241
mousePressEvent(QMouseEvent * e)242 void UIYabause::mousePressEvent( QMouseEvent* e )
243 {
244 if (emulateMouse && !mouseCaptured)
245 {
246 this->setCursor(Qt::BlankCursor);
247 mouseCaptured = true;
248 }
249 else
250 PerKeyDown( (1 << 31) | e->button() );
251 }
252
mouseReleaseEvent(QMouseEvent * e)253 void UIYabause::mouseReleaseEvent( QMouseEvent* e )
254 {
255 PerKeyUp( (1 << 31) | e->button() );
256 }
257
hideMouse()258 void UIYabause::hideMouse()
259 {
260 this->setCursor(Qt::BlankCursor);
261 hideMouseTimer->stop();
262 }
263
cursorRestore()264 void UIYabause::cursorRestore()
265 {
266 this->setCursor(Qt::ArrowCursor);
267 mouseCursorTimer->stop();
268 }
269
mouseMoveEvent(QMouseEvent * e)270 void UIYabause::mouseMoveEvent( QMouseEvent* e )
271 {
272 int midX = geometry().x()+(width()/2); // widget global x
273 int midY = geometry().y()+menubar->height()+toolBar->height()+(height()/2); // widget global y
274
275 int x = (e->x()-(width()/2))*mouseXRatio;
276 int y = ((menubar->height()+toolBar->height()+(height()/2))-e->y())*mouseYRatio;
277 int minAdj = mouseSensitivity/100;
278
279 // If minimum movement is less than x, wait until next pass to apply
280 if (abs(x) < minAdj) x = 0;
281 if (abs(y) < minAdj) y = 0;
282
283 if (mouseCaptured)
284 PerAxisMove((1 << 30), x, y);
285
286 VolatileSettings* vs = QtYabause::volatileSettings();
287
288 if (!isFullScreen())
289 {
290 if (emulateMouse && mouseCaptured)
291 {
292 // lock cursor to center
293 QPoint newPos(midX, midY);
294 this->cursor().setPos(newPos);
295 this->setCursor(Qt::BlankCursor);
296 return;
297 }
298 else
299 this->setCursor(Qt::ArrowCursor);
300 }
301 else
302 {
303 if (emulateMouse && mouseCaptured)
304 {
305 this->setCursor(Qt::BlankCursor);
306 return;
307 }
308 else if (vs->value( "View/Menubar" ).toInt() == BD_SHOWONFSHOVER)
309 {
310 if (e->y() < showMenuBarHeight)
311 menubar->show();
312 else
313 menubar->hide();
314 }
315
316 hideMouseTimer->start(3 * 1000);
317 this->setCursor(Qt::ArrowCursor);
318 }
319 }
320
resizeEvent(QResizeEvent * event)321 void UIYabause::resizeEvent( QResizeEvent* event )
322 {
323 if (event->oldSize().width() != event->size().width())
324 fixAspectRatio(event->size().width());
325
326 QMainWindow::resizeEvent( event );
327 }
328
adjustHeight(int & height)329 void UIYabause::adjustHeight(int & height)
330 {
331 // Compensate for menubar and toolbar
332 VolatileSettings* vs = QtYabause::volatileSettings();
333 if (vs->value("View/Menubar").toInt() != BD_ALWAYSHIDE)
334 height += menubar->height();
335 if (vs->value("View/Toolbar").toInt() != BD_ALWAYSHIDE)
336 height += toolBar->height();
337 }
338
resizeIntegerScaling()339 void UIYabause::resizeIntegerScaling()
340 {
341 if (!VIDCore || VIDCore->id != VIDCORE_SOFT)
342 return;
343
344 if (isFullScreen() || emulateMouse)
345 return;
346
347 VolatileSettings* vs = QtYabause::volatileSettings();
348
349 if (!vs->value("Video/EnableIntegerPixelScaling").toBool())
350 return;
351
352 int multiplier = vs->value("Video/IntegerPixelScalingMultiplier").toInt();
353
354 int vdp2width = 0;
355 int vdp2height = 0;
356 int vdp2interlace = 0;
357
358 if (!VIDCore->GetNativeResolution)
359 return;
360
361 VIDCore->GetNativeResolution(&vdp2width, &vdp2height, &vdp2interlace);
362
363 if (vdp2width == 0 || vdp2height == 0)
364 return;
365
366 int width = 0;
367 int height = 0;
368
369 if (vdp2width < 640)
370 width = vdp2width * multiplier;
371 else
372 width = vdp2width * (multiplier / 2.0);
373
374 if (!vdp2interlace)
375 height = vdp2height * multiplier;
376 else
377 height = vdp2height * (multiplier / 2.0);
378
379 mYabauseGL->resize(width, height);
380
381 adjustHeight(height);
382
383 setMinimumSize(width, height);
384 resize(width, height);
385 }
386
swapBuffers()387 void UIYabause::swapBuffers()
388 {
389 resizeIntegerScaling();
390 mYabauseGL->swapBuffers();
391 mYabauseGL->makeCurrent();
392 }
393
appendLog(const char * s)394 void UIYabause::appendLog( const char* s )
395 {
396 if (! mCanLog)
397 {
398 qWarning( "%s", s );
399 return;
400 }
401
402 teLog->moveCursor( QTextCursor::End );
403 teLog->append( s );
404
405 VolatileSettings* vs = QtYabause::volatileSettings();
406 if (( !mLogDock->isVisible( )) && ( vs->value( "View/LogWindow" ).toInt() == 1 )) {
407 mLogDock->setVisible( true );
408 }
409 }
410
eventFilter(QObject * o,QEvent * e)411 bool UIYabause::eventFilter( QObject* o, QEvent* e )
412 {
413 if ( e->type() == QEvent::Hide )
414 setFocus();
415 return QMainWindow::eventFilter( o, e );
416 }
417
errorReceived(const QString & error,bool internal)418 void UIYabause::errorReceived( const QString& error, bool internal )
419 {
420 if ( internal ) {
421 appendLog( error.toLocal8Bit().constData() );
422 }
423 else {
424 CommonDialogs::information( error );
425 }
426 }
427
sizeRequested(const QSize & s)428 void UIYabause::sizeRequested( const QSize& s )
429 {
430 int heightOffset = toolBar->height()+menubar->height();
431 int width, height;
432 if (s.isNull())
433 {
434 return;
435 }
436 else
437 {
438 width=s.width();
439 height=s.height();
440 }
441
442 mouseXRatio = 320.0 / (float)width * 2.0 * (float)mouseSensitivity / 100.0;
443 mouseYRatio = 240.0 / (float)height * 2.0 * (float)mouseSensitivity / 100.0;
444
445 // Compensate for menubar and toolbar
446 VolatileSettings* vs = QtYabause::volatileSettings();
447 if (vs->value( "View/Menubar" ).toInt() != BD_ALWAYSHIDE)
448 height += menubar->height();
449 if (vs->value( "View/Toolbar" ).toInt() != BD_ALWAYSHIDE)
450 height += toolBar->height();
451
452 resize( width, height );
453 }
454
fixAspectRatio(int width)455 void UIYabause::fixAspectRatio( int width )
456 {
457 int aspectRatio = QtYabause::volatileSettings()->value( "Video/AspectRatio").toInt();
458
459 switch( aspectRatio )
460 {
461 case 0:
462 setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
463 setMinimumSize( 0,0 );
464 break;
465 case 1:
466 case 2:
467 {
468 int heightOffset = toolBar->height()+menubar->height();
469 int height;
470
471 if ( aspectRatio == 1 )
472 height = 3 * ((float) width / 4);
473 else
474 height = 9 * ((float) width / 16);
475
476 mouseYRatio = 240.0 / (float)height * 2.0 * (float)mouseSensitivity / 100.0;
477
478 adjustHeight(height);
479
480 setFixedHeight( height );
481 break;
482 }
483 }
484 }
485
getSupportedResolutions()486 void UIYabause::getSupportedResolutions()
487 {
488 #if defined Q_OS_WIN
489 DEVMODE devMode;
490 BOOL result = TRUE;
491 DWORD currentSettings = 0;
492 devMode.dmSize = sizeof(DEVMODE);
493
494 supportedResolutions.clear();
495
496 while (result)
497 {
498 result = EnumDisplaySettings(NULL, currentSettings, &devMode);
499 if (result && devMode.dmBitsPerPel == 32)
500 {
501 supportedRes_struct res;
502 res.width = devMode.dmPelsWidth;
503 res.height = devMode.dmPelsHeight;
504 res.bpp = devMode.dmBitsPerPel;
505 res.freq = devMode.dmDisplayFrequency;
506
507 supportedResolutions.append(res);
508 }
509 currentSettings++;
510 }
511 #elif HAVE_LIBXRANDR
512 ResolutionList list;
513 supportedRes_struct res;
514
515 list = ScreenGetResolutions();
516
517 while(0 == ScreenNextResolution(list, &res))
518 supportedResolutions.append(res);
519 #endif
520 }
521
isResolutionValid(int width,int height,int bpp,int freq)522 int UIYabause::isResolutionValid( int width, int height, int bpp, int freq )
523 {
524 for (int i = 0; i < supportedResolutions.count(); i++)
525 {
526 if (supportedResolutions[i].width == width &&
527 supportedResolutions[i].height == height)
528 return i;
529 }
530
531 return -1;
532 }
533
findBestVideoFreq(int width,int height,int bpp,int videoFormat)534 int UIYabause::findBestVideoFreq( int width, int height, int bpp, int videoFormat )
535 {
536 // Try to use a frequency close to 60 hz for NTSC, 75 hz for PAL
537 if (videoFormat == VIDEOFORMATTYPE_PAL && isResolutionValid( width, height, bpp, 75 ) > 0)
538 return 75;
539 else if (videoFormat == VIDEOFORMATTYPE_NTSC && isResolutionValid( width, height, bpp, 60 ) > 0)
540 return 60;
541 else
542 {
543 // Since we can't use the frequency we want, use the first one available
544 int i=isResolutionValid( width, height, bpp, -1 );
545 if (i < 0)
546 return -1;
547 return supportedResolutions[i].freq;
548 }
549 }
550
toggleFullscreen(int width,int height,bool f,int videoFormat)551 void UIYabause::toggleFullscreen( int width, int height, bool f, int videoFormat )
552 {
553 // Make sure setting is valid
554 if (f && isResolutionValid( width, height, -1, -1 ) < 0)
555 return;
556
557 #if defined Q_OS_WIN
558 if (f)
559 {
560 DEVMODE dmScreenSettings;
561 memset (&dmScreenSettings, 0, sizeof (dmScreenSettings));
562
563 int freq = findBestVideoFreq( width, height, 32, videoFormat );
564
565 if (freq < 0)
566 return;
567
568 dmScreenSettings.dmSize = sizeof (dmScreenSettings);
569 dmScreenSettings.dmPelsWidth = width;
570 dmScreenSettings.dmPelsHeight = height;
571 dmScreenSettings.dmBitsPerPel = 32;
572 dmScreenSettings.dmDisplayFrequency = freq;
573 dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
574 ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
575 }
576 else
577 ChangeDisplaySettings(NULL, 0);
578
579 #elif HAVE_LIBXRANDR
580 if (f)
581 {
582 int i = isResolutionValid(width, height, 32, -1);
583 ScreenChangeResolution(&supportedResolutions[i]);
584 }
585 else
586 {
587 ScreenRestoreResolution();
588 }
589 #endif
590 }
591
fullscreenRequested(bool f)592 void UIYabause::fullscreenRequested( bool f )
593 {
594 if ( isFullScreen() && !f )
595 {
596 #ifdef USE_UNIFIED_TITLE_TOOLBAR
597 setUnifiedTitleAndToolBarOnMac( true );
598 #endif
599 toggleFullscreen(0, 0, false, -1 );
600 showNormal();
601
602 VolatileSettings* vs = QtYabause::volatileSettings();
603 int menubarHide = vs->value( "View/Menubar" ).toInt();
604 if ( menubarHide == BD_HIDEFS ||
605 menubarHide == BD_SHOWONFSHOVER)
606 menubar->show();
607 if ( vs->value( "View/Toolbar" ).toInt() == BD_HIDEFS )
608 toolBar->show();
609
610 setCursor(Qt::ArrowCursor);
611 hideMouseTimer->stop();
612 }
613 else if ( !isFullScreen() && f )
614 {
615 #ifdef USE_UNIFIED_TITLE_TOOLBAR
616 setUnifiedTitleAndToolBarOnMac( false );
617 #endif
618 VolatileSettings* vs = QtYabause::volatileSettings();
619
620 setMaximumSize( QWIDGETSIZE_MAX, QWIDGETSIZE_MAX );
621 setMinimumSize( 0,0 );
622
623 toggleFullscreen(vs->value("Video/FullscreenWidth").toInt(), vs->value("Video/FullscreenHeight").toInt(),
624 f, vs->value("Video/VideoFormat").toInt());
625
626 showFullScreen();
627
628 if ( vs->value( "View/Menubar" ).toInt() == BD_HIDEFS )
629 menubar->hide();
630 if ( vs->value( "View/Toolbar" ).toInt() == BD_HIDEFS )
631 toolBar->hide();
632
633 hideMouseTimer->start(3 * 1000);
634 }
635 if ( aViewFullscreen->isChecked() != f )
636 aViewFullscreen->setChecked( f );
637 aViewFullscreen->setIcon( QIcon( f ? ":/actions/no_fullscreen.png" : ":/actions/fullscreen.png" ) );
638 }
639
refreshStatesActions()640 void UIYabause::refreshStatesActions()
641 {
642 // reset save actions
643 foreach ( QAction* a, findChildren<QAction*>( QRegExp( "aFileSaveState*" ) ) )
644 {
645 if ( a == aFileSaveStateAs )
646 continue;
647 int i = a->objectName().remove( "aFileSaveState" ).toInt();
648 a->setText( QString( "%1 ... " ).arg( i ) );
649 a->setToolTip( a->text() );
650 a->setStatusTip( a->text() );
651 a->setData( i );
652 }
653 // reset load actions
654 foreach ( QAction* a, findChildren<QAction*>( QRegExp( "aFileLoadState*" ) ) )
655 {
656 if ( a == aFileLoadStateAs )
657 continue;
658 int i = a->objectName().remove( "aFileLoadState" ).toInt();
659 a->setText( QString( "%1 ... " ).arg( i ) );
660 a->setToolTip( a->text() );
661 a->setStatusTip( a->text() );
662 a->setData( i );
663 a->setEnabled( false );
664 }
665 // get states files of this game
666 const QString serial = QtYabause::getCurrentCdSerial();
667 const QString mask = QString( "%1_*.yss" ).arg( serial );
668 const QString statesPath = QtYabause::volatileSettings()->value( "General/SaveStates", getDataDirPath() ).toString();
669 QRegExp rx( QString( mask ).replace( '*', "(\\d+)") );
670 QDir d( statesPath );
671 foreach ( const QFileInfo& fi, d.entryInfoList( QStringList( mask ), QDir::Files | QDir::Readable, QDir::Name | QDir::IgnoreCase ) )
672 {
673 if ( rx.exactMatch( fi.fileName() ) )
674 {
675 int slot = rx.capturedTexts().value( 1 ).toInt();
676 const QString caption = QString( "%1 %2 " ).arg( slot ).arg( fi.lastModified().toString( Qt::SystemLocaleDate ) );
677 // update save state action
678 if ( QAction* a = findChild<QAction*>( QString( "aFileSaveState%1" ).arg( slot ) ) )
679 {
680 a->setText( caption );
681 a->setToolTip( caption );
682 a->setStatusTip( caption );
683 // update load state action
684 a = findChild<QAction*>( QString( "aFileLoadState%1" ).arg( slot ) );
685 a->setText( caption );
686 a->setToolTip( caption );
687 a->setStatusTip( caption );
688 a->setEnabled( true );
689 }
690 }
691 }
692 }
693
on_aFileSettings_triggered()694 void UIYabause::on_aFileSettings_triggered()
695 {
696 Settings *s = (QtYabause::settings());
697 QHash<QString, QVariant> hash;
698 const QStringList keys = s->allKeys();
699 Q_FOREACH(QString key, keys) {
700 hash[key] = s->value(key);
701 }
702
703 YabauseLocker locker( mYabauseThread );
704 if ( UISettings( &supportedResolutions, &translations, window() ).exec() )
705 {
706 VolatileSettings* vs = QtYabause::volatileSettings();
707 aEmulationFrameSkipLimiter->setChecked( vs->value( "General/EnableFrameSkipLimiter" ).toBool() );
708 aViewFPS->setChecked( vs->value( "General/ShowFPS" ).toBool() );
709 mouseSensitivity = vs->value( "Input/GunMouseSensitivity" ).toInt();
710
711 if(isFullScreen())
712 {
713 if ( vs->value( "View/Menubar" ).toInt() == BD_HIDEFS || vs->value( "View/Menubar" ).toInt() == BD_ALWAYSHIDE )
714 menubar->hide();
715 else
716 menubar->show();
717
718 if ( vs->value( "View/Toolbar" ).toInt() == BD_HIDEFS || vs->value( "View/Toolbar" ).toInt() == BD_ALWAYSHIDE )
719 toolBar->hide();
720 else
721 toolBar->show();
722 }
723 else
724 {
725 if ( vs->value( "View/Menubar" ).toInt() == BD_ALWAYSHIDE )
726 menubar->hide();
727 else
728 menubar->show();
729
730 if ( vs->value( "View/Toolbar" ).toInt() == BD_ALWAYSHIDE )
731 toolBar->hide();
732 else
733 toolBar->show();
734 }
735
736
737 //only reset if bios, region, cart, back up, mpeg, sh2, m68k are changed
738 Settings *ss = (QtYabause::settings());
739 QHash<QString, QVariant> newhash;
740 const QStringList newkeys = ss->allKeys();
741 Q_FOREACH(QString key, newkeys) {
742 newhash[key] = ss->value(key);
743 }
744 if(newhash["General/Bios"]!=hash["General/Bios"] ||
745 newhash["General/EnableEmulatedBios"]!=hash["General/EnableEmulatedBios"] ||
746 newhash["Advanced/Region"]!=hash["Advanced/Region"] ||
747 newhash["Cartridge/Type"]!=hash["Cartridge/Type"] ||
748 newhash["Memory/Path"]!=hash["Memory/Path"] ||
749 newhash["SH1ROM/Path"]!=hash["SH1ROM/Path"] ||
750 newhash["MpegROM/Path"]!=hash["MpegROM/Path" ] ||
751 newhash["Advanced/SH1Interpreter"]!=hash["Advanced/SH1Interpreter"] ||
752 newhash["Advanced/EnableCDBlockLLE"]!=hash["Advanced/EnableCDBlockLLE"] ||
753 newhash["Advanced/EnableSh2DmaTiming"] != hash["Advanced/EnableSh2DmaTiming"] ||
754 newhash["Advanced/EnableScuDmaTiming"] != hash["Advanced/EnableScuDmaTiming"] ||
755 newhash["Advanced/EnableSh2Cache"] != hash["Advanced/EnableSh2Cache"] ||
756 newhash["Advanced/SH2Interpreter"]!=hash["Advanced/SH2Interpreter"] ||
757 newhash["Advanced/68kCore"] != hash["Advanced/68kCore"] ||
758 newhash["General/CdRom"]!=hash["General/CdRom"] ||
759 newhash["General/CdRomISO"]!=hash["General/CdRomISO"] ||
760 newhash["General/ClockSync"]!=hash["General/ClockSync"] ||
761 newhash["General/FixedBaseTime"]!=hash["General/FixedBaseTime"] ||
762 newhash["Advanced/EnableScuDspDynarec"] != hash["Advanced/EnableScuDspDynarec"] ||
763 newhash["Sound/EnableScspDspDynarec"] != hash["Sound/EnableScspDspDynarec"]
764 )
765 {
766 if ( mYabauseThread->pauseEmulation( true, true ) )
767 refreshStatesActions();
768 return;
769 }
770 #ifdef HAVE_LIBMINI18N
771 if(newhash["General/Translation"] != hash["General/Translation"])
772 {
773 mini18n_close();
774 retranslateUi(this);
775 if ( QtYabause::setTranslationFile() == -1 )
776 qWarning( "Can't set translation file" );
777 QtYabause::retranslateApplication();
778 }
779 #endif
780 if(newhash["Video/VideoCore"] != hash["Video/VideoCore"])
781 on_cbVideoDriver_currentIndexChanged(newhash["Video/VideoCore"].toInt());
782
783 if(newhash["General/ShowFPS"] != hash["General/ShowFPS"])
784 SetOSDToggle(newhash["General/ShowFPS"].toBool());
785
786 if (newhash["General/EnableMultiThreading"] != hash["General/EnableMultiThreading"] ||
787 newhash["General/NumThreads"] != hash["General/NumThreads"])
788 {
789 if (newhash["General/EnableMultiThreading"].toBool())
790 {
791 int num = newhash["General/NumThreads"].toInt() < 1 ? 1 : newhash["General/NumThreads"].toInt();
792 VIDSoftSetVdp1ThreadEnable(num == 1 ? 0 : 1);
793 VIDSoftSetNumLayerThreads(num);
794 VIDSoftSetNumPriorityThreads(num);
795 }
796 else
797 {
798 VIDSoftSetVdp1ThreadEnable(0);
799 VIDSoftSetNumLayerThreads(1);
800 VIDSoftSetNumPriorityThreads(1);
801 }
802 }
803
804
805 if (newhash["Sound/SoundCore"] != hash["Sound/SoundCore"])
806 ScspChangeSoundCore(newhash["Sound/SoundCore"].toInt());
807
808 if (newhash["Sound/NewScsp"].toBool() != hash["Sound/NewScsp"])
809 scsp_set_use_new(newhash["Sound/NewScsp"].toInt());
810
811 if (newhash["Video/WindowWidth"] != hash["Video/WindowWidth"] || newhash["Video/WindowHeight"] != hash["Video/WindowHeight"] ||
812 newhash["View/Menubar"] != hash["View/Menubar"] || newhash["View/Toolbar"] != hash["View/Toolbar"] ||
813 newhash["Input/GunMouseSensitivity"] != hash["Input/GunMouseSensitivity"])
814 sizeRequested(QSize(newhash["Video/WindowWidth"].toInt(),newhash["Video/WindowHeight"].toInt()));
815 fixAspectRatio( rect().width() );
816
817 if (newhash["Video/FullscreenWidth"] != hash["Video/FullscreenWidth"] ||
818 newhash["Video/FullscreenHeight"] != hash["Video/FullscreenHeight"] ||
819 newhash["Video/Fullscreen"] != hash["Video/Fullscreen"])
820 {
821 bool f = isFullScreen();
822 if (f)
823 fullscreenRequested( false );
824 fullscreenRequested( f );
825 }
826
827 if (newhash["Video/VideoFormat"] != hash["Video/VideoFormat"])
828 YabauseSetVideoFormat(newhash["Video/VideoFormat"].toInt());
829
830 mYabauseThread->reloadControllers();
831 refreshStatesActions();
832 }
833 }
834
on_aFileOpenISO_triggered()835 void UIYabause::on_aFileOpenISO_triggered()
836 {
837 YabauseLocker locker( mYabauseThread );
838 const QString fn = CommonDialogs::getOpenFileName( QtYabause::volatileSettings()->value( "Recents/ISOs" ).toString(), QtYabause::translate( "Select your iso/cue/bin file" ), QtYabause::translate( "CD Images (*.iso *.cue *.bin *.mds *.ccd)" ) );
839 if ( !fn.isEmpty() )
840 {
841 VolatileSettings* vs = QtYabause::volatileSettings();
842 const int currentCDCore = vs->value( "General/CdRom" ).toInt();
843 const QString currentCdRomISO = vs->value( "General/CdRomISO" ).toString();
844
845 QtYabause::settings()->setValue( "Recents/ISOs", fn );
846
847 vs->setValue( "autostart", false );
848 vs->setValue( "General/CdRom", ISOCD.id );
849 vs->setValue( "General/CdRomISO", fn );
850 vs->setValue("General/PlaySSF", false);
851
852 mYabauseThread->pauseEmulation( false, true );
853
854 refreshStatesActions();
855 }
856 }
857
on_aFileOpenSSF_triggered()858 void UIYabause::on_aFileOpenSSF_triggered()
859 {
860 YabauseLocker locker(mYabauseThread);
861
862 const QString fn = CommonDialogs::getOpenFileName(
863 QtYabause::volatileSettings()->value("Recents/SSFs").toString(),
864 QtYabause::translate("Select your ssf file"),
865 QtYabause::translate("Sega Saturn Sound Format files (*.ssf *.minissf)"));
866
867 if (!fn.isEmpty())
868 {
869 VolatileSettings* vs = QtYabause::volatileSettings();
870
871 QtYabause::settings()->setValue("Recents/SSFs", fn);
872
873 vs->setValue("autostart", false);
874 vs->setValue("General/SSFPath", fn);
875 vs->setValue("General/PlaySSF", true);
876
877 mYabauseThread->pauseEmulation(false, true);
878
879 refreshStatesActions();
880 }
881 }
882
on_aFileOpenCDRom_triggered()883 void UIYabause::on_aFileOpenCDRom_triggered()
884 {
885 YabauseLocker locker( mYabauseThread );
886 QStringList list = getCdDriveList();
887 int current = list.indexOf(QtYabause::volatileSettings()->value( "Recents/CDs").toString());
888 QString fn = QInputDialog::getItem(this, QtYabause::translate("Open CD Rom"),
889 QtYabause::translate("Choose a cdrom drive/mount point") + ":",
890 list, current, false);
891 if (!fn.isEmpty())
892 {
893 VolatileSettings* vs = QtYabause::volatileSettings();
894 const int currentCDCore = vs->value( "General/CdRom" ).toInt();
895 const QString currentCdRomISO = vs->value( "General/CdRomISO" ).toString();
896
897 QtYabause::settings()->setValue( "Recents/CDs", fn );
898
899 vs->setValue( "autostart", false );
900 vs->setValue( "General/CdRom", QtYabause::defaultCDCore().id );
901 vs->setValue( "General/CdRomISO", fn );
902 vs->setValue("General/PlaySSF", false);
903
904 mYabauseThread->pauseEmulation( false, true );
905
906 refreshStatesActions();
907 }
908 }
909
on_mFileSaveState_triggered(QAction * a)910 void UIYabause::on_mFileSaveState_triggered( QAction* a )
911 {
912 if ( a == aFileSaveStateAs )
913 return;
914 YabauseLocker locker( mYabauseThread );
915 if ( YabSaveStateSlot( QFile::encodeName( QtYabause::volatileSettings()->value( "General/SaveStates", getDataDirPath() ).toString()).constData(), a->data().toInt() ) != 0 )
916 CommonDialogs::information( QtYabause::translate( "Couldn't save state file" ) );
917 else
918 refreshStatesActions();
919 }
920
on_mFileLoadState_triggered(QAction * a)921 void UIYabause::on_mFileLoadState_triggered( QAction* a )
922 {
923 if ( a == aFileLoadStateAs )
924 return;
925 YabauseLocker locker( mYabauseThread );
926 if ( YabLoadStateSlot( QFile::encodeName( QtYabause::volatileSettings()->value( "General/SaveStates", getDataDirPath() ).toString()).constData(), a->data().toInt() ) != 0 )
927 CommonDialogs::information( QtYabause::translate( "Couldn't load state file" ) );
928 }
929
on_aFileSaveStateAs_triggered()930 void UIYabause::on_aFileSaveStateAs_triggered()
931 {
932 YabauseLocker locker( mYabauseThread );
933 const QString fn = CommonDialogs::getSaveFileName( QtYabause::volatileSettings()->value( "General/SaveStates", getDataDirPath() ).toString(), QtYabause::translate( "Choose a file to save your state" ), QtYabause::translate( "Yabause Save State (*.yss)" ) );
934 if ( fn.isNull() )
935 return;
936 if ( YabSaveState( QFile::encodeName(fn).constData() ) != 0 )
937 CommonDialogs::information( QtYabause::translate( "Couldn't save state file" ) );
938 }
939
on_aFileLoadStateAs_triggered()940 void UIYabause::on_aFileLoadStateAs_triggered()
941 {
942 YabauseLocker locker( mYabauseThread );
943 const QString fn = CommonDialogs::getOpenFileName( QtYabause::volatileSettings()->value( "General/SaveStates", getDataDirPath() ).toString(), QtYabause::translate( "Select a file to load your state" ), QtYabause::translate( "Yabause Save State (*.yss)" ) );
944 if ( fn.isNull() )
945 return;
946 if ( YabLoadState( QFile::encodeName(fn).constData() ) != 0 )
947 CommonDialogs::information( QtYabause::translate( "Couldn't load state file" ) );
948 else
949 aEmulationRun->trigger();
950 }
951
on_aFileScreenshot_triggered()952 void UIYabause::on_aFileScreenshot_triggered()
953 {
954 YabauseLocker locker( mYabauseThread );
955 // images filter that qt can write
956 QStringList filters;
957 foreach ( QByteArray ba, QImageWriter::supportedImageFormats() )
958 if ( !filters.contains( ba, Qt::CaseInsensitive ) )
959 filters << QString( ba ).toLower();
960 for ( int i = 0; i < filters.count(); i++ )
961 filters[i] = QtYabause::translate( "%1 Images (*.%2)" ).arg( filters[i].toUpper() ).arg( filters[i] );
962
963 // take screenshot of gl view
964 QImage screenshot = mYabauseGL->grabFrameBuffer();
965
966 // request a file to save to to user
967 QString s = CommonDialogs::getSaveFileName( QString(), QtYabause::translate( "Choose a location for your screenshot" ), filters.join( ";;" ) );
968
969 // if the user didn't provide a filename extension, we force it to png
970 QFileInfo qfi( s );
971 if ( qfi.suffix().isEmpty() )
972 s += ".png";
973
974 // write image if ok
975 if ( !s.isEmpty() )
976 {
977 QImageWriter iw( s );
978 if ( !iw.write( screenshot ))
979 {
980 CommonDialogs::information( QtYabause::translate( "An error occur while writing the screenshot: " + iw.errorString()) );
981 }
982 }
983 }
984
on_aFileQuit_triggered()985 void UIYabause::on_aFileQuit_triggered()
986 { close(); }
987
on_aEmulationRun_triggered()988 void UIYabause::on_aEmulationRun_triggered()
989 {
990 if ( mYabauseThread->emulationPaused() )
991 {
992 mYabauseThread->pauseEmulation( false, false );
993 refreshStatesActions();
994 if (isFullScreen())
995 hideMouseTimer->start(3 * 1000);
996 }
997 }
998
on_aEmulationPause_triggered()999 void UIYabause::on_aEmulationPause_triggered()
1000 {
1001 if ( !mYabauseThread->emulationPaused() )
1002 mYabauseThread->pauseEmulation( true, false );
1003 }
1004
on_aEmulationReset_triggered()1005 void UIYabause::on_aEmulationReset_triggered()
1006 { mYabauseThread->resetEmulation(); }
1007
on_aEmulationFrameSkipLimiter_toggled(bool toggled)1008 void UIYabause::on_aEmulationFrameSkipLimiter_toggled( bool toggled )
1009 {
1010 Settings* vs = QtYabause::settings();
1011 vs->setValue( "General/EnableFrameSkipLimiter", toggled );
1012 vs->sync();
1013
1014 if ( toggled )
1015 EnableAutoFrameSkip();
1016 else
1017 DisableAutoFrameSkip();
1018 }
1019
on_aToolsBackupManager_triggered()1020 void UIYabause::on_aToolsBackupManager_triggered()
1021 {
1022 YabauseLocker locker( mYabauseThread );
1023 if ( mYabauseThread->init() < 0 )
1024 {
1025 CommonDialogs::information( QtYabause::translate( "Yabause is not initialized, can't manage backup ram." ) );
1026 return;
1027 }
1028 UIBackupRam( this ).exec();
1029 }
1030
on_aToolsCheatsList_triggered()1031 void UIYabause::on_aToolsCheatsList_triggered()
1032 {
1033 YabauseLocker locker( mYabauseThread );
1034 UICheats( this ).exec();
1035 }
1036
on_aToolsCheatSearch_triggered()1037 void UIYabause::on_aToolsCheatSearch_triggered()
1038 {
1039 YabauseLocker locker( mYabauseThread );
1040 UICheatSearch cs(this, &search, searchType);
1041
1042 cs.exec();
1043
1044 search = *cs.getSearchVariables( &searchType);
1045 }
1046
on_aToolsTransfer_triggered()1047 void UIYabause::on_aToolsTransfer_triggered()
1048 {
1049 YabauseLocker locker( mYabauseThread );
1050 UIMemoryTransfer( mYabauseThread, this ).exec();
1051 }
1052
on_aViewFPS_triggered(bool toggled)1053 void UIYabause::on_aViewFPS_triggered( bool toggled )
1054 {
1055 Settings* vs = QtYabause::settings();
1056 vs->setValue( "General/ShowFPS", toggled );
1057 vs->sync();
1058 SetOSDToggle(toggled ? 1 : 0);
1059 }
1060
on_aViewLayerVdp1_triggered()1061 void UIYabause::on_aViewLayerVdp1_triggered()
1062 { ToggleVDP1(); }
1063
on_aViewLayerNBG0_triggered()1064 void UIYabause::on_aViewLayerNBG0_triggered()
1065 { ToggleNBG0(); }
1066
on_aViewLayerNBG1_triggered()1067 void UIYabause::on_aViewLayerNBG1_triggered()
1068 { ToggleNBG1(); }
1069
on_aViewLayerNBG2_triggered()1070 void UIYabause::on_aViewLayerNBG2_triggered()
1071 { ToggleNBG2(); }
1072
on_aViewLayerNBG3_triggered()1073 void UIYabause::on_aViewLayerNBG3_triggered()
1074 { ToggleNBG3(); }
1075
on_aViewLayerRBG0_triggered()1076 void UIYabause::on_aViewLayerRBG0_triggered()
1077 { ToggleRBG0(); }
1078
on_aViewFullscreen_triggered(bool b)1079 void UIYabause::on_aViewFullscreen_triggered( bool b )
1080 {
1081 fullscreenRequested( b );
1082 }
1083
breakpointHandlerSH1(bool displayMessage)1084 void UIYabause::breakpointHandlerSH1(bool displayMessage)
1085 {
1086 YabauseLocker locker( mYabauseThread );
1087 if (displayMessage)
1088 CommonDialogs::information( QtYabause::translate( "Breakpoint Reached" ) );
1089 UIDebugSH2(UIDebugCPU::PROC_SH1, mYabauseThread, this ).exec();
1090 }
1091
breakpointHandlerMSH2(bool displayMessage)1092 void UIYabause::breakpointHandlerMSH2(bool displayMessage)
1093 {
1094 YabauseLocker locker( mYabauseThread );
1095 if (displayMessage)
1096 CommonDialogs::information( QtYabause::translate( "Breakpoint Reached" ) );
1097 UIDebugSH2(UIDebugCPU::PROC_MSH2, mYabauseThread, this ).exec();
1098 }
1099
breakpointHandlerSSH2(bool displayMessage)1100 void UIYabause::breakpointHandlerSSH2(bool displayMessage)
1101 {
1102 YabauseLocker locker( mYabauseThread );
1103 if (displayMessage)
1104 CommonDialogs::information( QtYabause::translate( "Breakpoint Reached" ) );
1105 UIDebugSH2(UIDebugCPU::PROC_SSH2, mYabauseThread, this ).exec();
1106 }
1107
breakpointHandlerM68K()1108 void UIYabause::breakpointHandlerM68K()
1109 {
1110 YabauseLocker locker( mYabauseThread );
1111 CommonDialogs::information( QtYabause::translate( "Breakpoint Reached" ) );
1112 UIDebugM68K( mYabauseThread, this ).exec();
1113 }
1114
breakpointHandlerSCUDSP()1115 void UIYabause::breakpointHandlerSCUDSP()
1116 {
1117 YabauseLocker locker( mYabauseThread );
1118 CommonDialogs::information( QtYabause::translate( "Breakpoint Reached" ) );
1119 UIDebugSCUDSP( mYabauseThread, this ).exec();
1120 }
1121
breakpointHandlerSCSPDSP()1122 void UIYabause::breakpointHandlerSCSPDSP()
1123 {
1124 YabauseLocker locker( mYabauseThread );
1125 CommonDialogs::information( QtYabause::translate( "Breakpoint Reached" ) );
1126 UIDebugSCSPDSP( mYabauseThread, this ).exec();
1127 }
1128
on_aViewDebugMSH2_triggered()1129 void UIYabause::on_aViewDebugMSH2_triggered()
1130 {
1131 YabauseLocker locker( mYabauseThread );
1132 UIDebugSH2( UIDebugCPU::PROC_MSH2, mYabauseThread, this ).exec();
1133 }
1134
on_aViewDebugSSH2_triggered()1135 void UIYabause::on_aViewDebugSSH2_triggered()
1136 {
1137 YabauseLocker locker( mYabauseThread );
1138 UIDebugSH2( UIDebugCPU::PROC_SSH2, mYabauseThread, this ).exec();
1139 }
1140
on_aViewDebugVDP1_triggered()1141 void UIYabause::on_aViewDebugVDP1_triggered()
1142 {
1143 YabauseLocker locker( mYabauseThread );
1144 UIDebugVDP1( this ).exec();
1145 }
1146
on_aViewDebugVDP2_triggered()1147 void UIYabause::on_aViewDebugVDP2_triggered()
1148 {
1149 YabauseLocker locker( mYabauseThread );
1150 UIDebugVDP2( this ).exec();
1151 }
1152
on_aViewDebugM68K_triggered()1153 void UIYabause::on_aViewDebugM68K_triggered()
1154 {
1155 YabauseLocker locker( mYabauseThread );
1156 UIDebugM68K( mYabauseThread, this ).exec();
1157 }
1158
on_aViewDebugSCUDSP_triggered()1159 void UIYabause::on_aViewDebugSCUDSP_triggered()
1160 {
1161 YabauseLocker locker( mYabauseThread );
1162 UIDebugSCUDSP( mYabauseThread, this ).exec();
1163 }
1164
on_aViewDebugSCSP_triggered()1165 void UIYabause::on_aViewDebugSCSP_triggered()
1166 {
1167 YabauseLocker locker( mYabauseThread );
1168 UIDebugSCSP( this ).exec();
1169 }
1170
on_aViewDebugSCSPChan_triggered()1171 void UIYabause::on_aViewDebugSCSPChan_triggered()
1172 {
1173 if (use_new_scsp)
1174 UIDebugSCSPChan(this).exec();
1175 else
1176 CommonDialogs::information( QtYabause::translate( "Only available with new scsp code(USE_NEW_SCSP=1)" ) );
1177 }
1178
on_aViewDebugSCSPDSP_triggered()1179 void UIYabause::on_aViewDebugSCSPDSP_triggered()
1180 {
1181 YabauseLocker locker( mYabauseThread );
1182 UIDebugSCSPDSP( mYabauseThread, this ).exec();
1183 }
1184
on_aViewDebugSH1_triggered()1185 void UIYabause::on_aViewDebugSH1_triggered()
1186 {
1187 YabauseLocker locker( mYabauseThread );
1188 UIDebugSH2( UIDebugCPU::PROC_SH1, mYabauseThread, this ).exec();
1189 }
1190
on_aViewDebugMemoryEditor_triggered()1191 void UIYabause::on_aViewDebugMemoryEditor_triggered()
1192 {
1193 YabauseLocker locker( mYabauseThread );
1194 UIMemoryEditor( UIDebugCPU::PROC_MSH2, mYabauseThread, this ).exec();
1195 }
1196
on_aTraceLogging_triggered(bool toggled)1197 void UIYabause::on_aTraceLogging_triggered( bool toggled )
1198 {
1199 #ifdef SH2_TRACE
1200 SH2SetInsTracing(toggled? 1 : 0);
1201 #endif
1202 return;
1203 }
1204
on_aHelpDocumentation_triggered()1205 void UIYabause::on_aHelpDocumentation_triggered()
1206 { QDesktopServices::openUrl( QUrl( aHelpDocumentation->statusTip() ) ); }
1207
on_aHelpCompatibilityList_triggered()1208 void UIYabause::on_aHelpCompatibilityList_triggered()
1209 { QDesktopServices::openUrl( QUrl( aHelpCompatibilityList->statusTip() ) ); }
1210
on_aHelpAbout_triggered()1211 void UIYabause::on_aHelpAbout_triggered()
1212 {
1213 YabauseLocker locker( mYabauseThread );
1214 UIAbout( window() ).exec();
1215 }
1216
on_aSound_triggered()1217 void UIYabause::on_aSound_triggered()
1218 {
1219 // show volume widget
1220 sVolume->setValue(QtYabause::volatileSettings()->value( "Sound/Volume").toInt());
1221 QWidget* ab = toolBar->widgetForAction( aSound );
1222 fSound->move( ab->mapToGlobal( ab->rect().bottomLeft() ) );
1223 fSound->show();
1224 }
1225
on_aVideoDriver_triggered()1226 void UIYabause::on_aVideoDriver_triggered()
1227 {
1228 // set current core the selected one in the combo list
1229 if ( VIDCore )
1230 {
1231 cbVideoDriver->blockSignals( true );
1232 for ( int i = 0; VIDCoreList[i] != NULL; i++ )
1233 {
1234 if ( VIDCoreList[i]->id == VIDCore->id )
1235 {
1236 cbVideoDriver->setCurrentIndex( cbVideoDriver->findData( VIDCore->id ) );
1237 break;
1238 }
1239 }
1240 cbVideoDriver->blockSignals( false );
1241 }
1242 // show video core widget
1243 QWidget* ab = toolBar->widgetForAction( aVideoDriver );
1244 fVideoDriver->move( ab->mapToGlobal( ab->rect().bottomLeft() ) );
1245 fVideoDriver->show();
1246 }
1247
on_cbSound_toggled(bool toggled)1248 void UIYabause::on_cbSound_toggled( bool toggled )
1249 {
1250 if ( toggled )
1251 ScspUnMuteAudio(SCSP_MUTE_USER);
1252 else
1253 ScspMuteAudio(SCSP_MUTE_USER);
1254 cbSound->setIcon( QIcon( toggled ? ":/actions/sound.png" : ":/actions/mute.png" ) );
1255 }
1256
on_sVolume_valueChanged(int value)1257 void UIYabause::on_sVolume_valueChanged( int value )
1258 {
1259 ScspSetVolume( value );
1260 Settings* vs = QtYabause::settings();
1261 vs->setValue("Sound/Volume", value );
1262 }
1263
on_cbVideoDriver_currentIndexChanged(int id)1264 void UIYabause::on_cbVideoDriver_currentIndexChanged( int id )
1265 {
1266 VideoInterface_struct* core = QtYabause::getVDICore( cbVideoDriver->itemData( id ).toInt() );
1267 if ( core )
1268 {
1269 if ( VideoChangeCore( core->id ) == 0 )
1270 mYabauseGL->updateView();
1271 }
1272 }
1273
pause(bool paused)1274 void UIYabause::pause( bool paused )
1275 {
1276 mYabauseGL->updateView();
1277
1278 aEmulationRun->setEnabled( paused );
1279 aEmulationPause->setEnabled( !paused );
1280 aEmulationReset->setEnabled( !paused );
1281 }
1282
reset()1283 void UIYabause::reset()
1284 {
1285 mYabauseGL->updateView();
1286 }
1287
toggleEmulateMouse(bool enable)1288 void UIYabause::toggleEmulateMouse( bool enable )
1289 {
1290 emulateMouse = enable;
1291 }
1292
disableGL()1293 void UIYabause::disableGL( )
1294 {
1295 mYabauseGL->select(this, YabauseGLProxy::SOFTWARE);
1296 setCentralWidget( mYabauseGL->getWidget() );
1297 }
1298