2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James L. Hammons <jlhamm@acm.org>
9 // --- ---------- -------------------------------------------------------------
10 // JLH 12/23/2009 Created this file
11 // JLH 12/20/2010 Added settings, menus & toolbars
12 // JLH 07/05/2011 Added CD BIOS functionality to GUI
17 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
18 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
19 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting with 'R', etc) [DONE]
20 // - Controller configuration [DONE]
24 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
25 // - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't)
27 // SFDX CODE: 9XF9TUHFM2359
29 // Uncomment this for debugging...
31 //#define DEBUGFOO // Various tool debugging...
32 //#define DEBUGTP // Toolpalette debugging...
41 #include "filepicker.h"
42 #include "configdialog.h"
43 #include "generaltab.h"
52 #include "jagcdbios.h"
53 #include "jagstub2bios.h"
57 // Apparently on win32, usleep() is not pulled in by the usual suspects.
61 // The way BSNES controls things is by setting a timer with a zero
62 // timeout, sleeping if not emulating anything. Seems there has to be a
65 // It has a novel approach to plugging-in/using different video/audio/input
66 // methods, can we do something similar or should we just use the built-in
69 // We're going to try to use the built-in OpenGL support and see how it goes.
70 // We'll make the VJ core modular so that it doesn't matter what GUI is in
71 // use, we can drop it in anywhere and use it as-is.
73 MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit(true),
74 cartridgeLoaded(false), CDActive(false),//, alpineLoadSuccessful(false),
75 pauseForFileSelector(false)
77 videoWidget = new GLWidget(this);
78 setCentralWidget(videoWidget);
79 setWindowIcon(QIcon(":/res/vj-icon.png"));
81 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION ));
83 if (vjs.hardwareTypeAlpine)
84 title += QString(tr(" - Alpine Mode"));
86 setWindowTitle(title);
88 aboutWin = new AboutWindow(this);
89 helpWin = new HelpWindow(this);
90 filePickWin = new FilePickerWindow(this);
92 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
95 setUnifiedTitleAndToolBarOnMac(true);
99 quitAppAct = new QAction(tr("E&xit"), this);
100 // quitAppAct->setShortcuts(QKeySequence::Quit);
101 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
102 quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
103 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
104 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
106 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
107 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
108 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
109 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
111 // powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
112 powerAct = new QAction(powerGreen, tr("&Power"), this);
113 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
114 powerAct->setCheckable(true);
115 powerAct->setChecked(false);
116 // powerAct->setDisabled(true);
117 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
120 pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off);
121 pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On);
122 // pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
123 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
124 pauseAct->setStatusTip(tr("Toggles the running state"));
125 pauseAct->setCheckable(true);
126 pauseAct->setDisabled(true);
127 pauseAct->setShortcut(QKeySequence(tr("Esc")));
128 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
130 zoomActs = new QActionGroup(this);
132 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
133 x1Act->setStatusTip(tr("Set window zoom to 100%"));
134 x1Act->setCheckable(true);
135 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
137 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
138 x2Act->setStatusTip(tr("Set window zoom to 200%"));
139 x2Act->setCheckable(true);
140 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
142 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
143 x3Act->setStatusTip(tr("Set window zoom to 300%"));
144 x3Act->setCheckable(true);
145 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
147 tvTypeActs = new QActionGroup(this);
149 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
150 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
151 ntscAct->setCheckable(true);
152 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
154 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
155 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
156 palAct->setCheckable(true);
157 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
159 blurAct = new QAction(QIcon(":/res/generic.png"), tr("Blur"), this);
160 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
161 blurAct->setCheckable(true);
162 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
164 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
165 aboutAct->setStatusTip(tr("Blatant self-promotion"));
166 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
168 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
169 helpAct->setStatusTip(tr("Help is available, if you should need it"));
170 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
172 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
173 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
174 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
175 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
177 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
178 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
179 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
180 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
182 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
183 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
184 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
185 useCDAct->setCheckable(true);
186 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
188 // Misc. connections...
189 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
190 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
192 // Create menus & toolbars
194 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
195 fileMenu->addAction(powerAct);
196 fileMenu->addAction(pauseAct);
197 fileMenu->addAction(filePickAct);
198 fileMenu->addAction(useCDAct);
199 fileMenu->addAction(configAct);
200 fileMenu->addAction(quitAppAct);
202 helpMenu = menuBar()->addMenu(tr("&Help"));
203 helpMenu->addAction(helpAct);
204 helpMenu->addAction(aboutAct);
206 toolbar = addToolBar(tr("Stuff"));
207 toolbar->addAction(powerAct);
208 toolbar->addAction(pauseAct);
209 toolbar->addAction(filePickAct);
210 toolbar->addAction(useCDAct);
211 toolbar->addSeparator();
212 toolbar->addAction(x1Act);
213 toolbar->addAction(x2Act);
214 toolbar->addAction(x3Act);
215 toolbar->addSeparator();
216 toolbar->addAction(ntscAct);
217 toolbar->addAction(palAct);
218 toolbar->addSeparator();
219 toolbar->addAction(blurAct);
222 statusBar()->showMessage(tr("Ready"));
226 // Set toolbar buttons/menus based on settings read in (sync the UI)...
227 blurAct->setChecked(vjs.glFilter);
228 x1Act->setChecked(zoomLevel == 1);
229 x2Act->setChecked(zoomLevel == 2);
230 x3Act->setChecked(zoomLevel == 3);
231 // running = powerAct->isChecked();
232 ntscAct->setChecked(vjs.hardwareTypeNTSC);
233 palAct->setChecked(!vjs.hardwareTypeNTSC);
234 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
236 // Do this in case original size isn't correct (mostly for the first-run case)
239 // Set up timer based loop for animation...
240 timer = new QTimer(this);
241 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
242 //This is only correct for PAL. !!! FIX !!! [DONE]
243 //Use timer->setInterval( int msec ) to fix this on the fly
245 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
246 // This is because it's discarding the 0.6666... on the end of the fraction.
247 // Alas, 6 doesn't divide cleanly into 10. :-P
248 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
250 // We set this initially, to make VJ behave somewhat as it would if no
251 // cart were inserted and the BIOS was set as active...
252 jaguarCartInserted = true;
253 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
254 WriteLog("VJ: Initializing jaguar subsystem...\n");
257 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
259 // Load up the default ROM if in Alpine mode:
260 if (vjs.hardwareTypeAlpine)
262 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
264 // If regular load failed, try just a straight file load
265 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
267 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
270 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
272 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
274 // Attempt to load/run the ABS file...
275 LoadSoftware(vjs.absROMPath);
276 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
279 memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS
282 void MainWin::closeEvent(QCloseEvent * event)
286 event->accept(); // ignore() if can't close for some reason
289 void MainWin::keyPressEvent(QKeyEvent * e)
291 // We ignore the Alt key for now, since it causes problems with the GUI
292 if (e->key() == Qt::Key_Alt)
301 void MainWin::keyReleaseEvent(QKeyEvent * e)
303 // We ignore the Alt key for now, since it causes problems with the GUI
304 if (e->key() == Qt::Key_Alt)
310 HandleKeys(e, false);
313 void MainWin::HandleKeys(QKeyEvent * e, bool state)
315 // We kill bad key combos here, before they can get to the emulator...
316 // This also kills the illegal instruction problem that cropped up in Rayman!
317 // May want to do this by killing the old one instead of ignoring the new one...
318 // Seems to work better that way...
320 if ((e->key() == vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
321 || (e->key() == vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
322 || (e->key() == vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
323 || (e->key() == vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U]))
326 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
327 joypad_0_buttons[BUTTON_R] = 0;
328 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
329 joypad_0_buttons[BUTTON_L] = 0;
330 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
331 joypad_0_buttons[BUTTON_D] = 0;
332 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
333 joypad_0_buttons[BUTTON_U] = 0;
335 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
336 joypad_1_buttons[BUTTON_R] = 0;
337 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
338 joypad_1_buttons[BUTTON_L] = 0;
339 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
340 joypad_1_buttons[BUTTON_D] = 0;
341 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
342 joypad_1_buttons[BUTTON_U] = 0;
345 // No bad combos exist, let's stuff the emulator key buffers...!
346 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
348 if (e->key() == (int)vjs.p1KeyBindings[i])
349 // joypad_0_buttons[i] = (uint8)state;
350 joypad_0_buttons[i] = (state ? 0x01 : 0x00);
352 // Pad #2 is screwing up pad #1. Prolly a problem in joystick.cpp...
353 // So let's try to fix it there. :-P [DONE]
354 if (e->key() == (int)vjs.p2KeyBindings[i])
355 // joypad_1_buttons[i] = (uint8)state;
356 joypad_1_buttons[i] = (state ? 0x01 : 0x00);
360 void MainWin::Open(void)
364 void MainWin::Configure(void)
366 // Call the configuration dialog and update settings
367 ConfigDialog dlg(this);
369 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
371 if (dlg.exec() == false)
374 QString before = vjs.ROMPath;
375 QString alpineBefore = vjs.alpineROMPath;
376 QString absBefore = vjs.absROMPath;
377 bool audioBefore = vjs.audioEnabled;
378 dlg.UpdateVJSettings();
379 QString after = vjs.ROMPath;
380 QString alpineAfter = vjs.alpineROMPath;
381 QString absAfter = vjs.absROMPath;
382 bool audioAfter = vjs.audioEnabled;
384 bool allowOld = allowUnknownSoftware;
386 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
388 // We rescan the "software" folder if the user either changed the path or
389 // checked/unchecked the "Allow unknown files" option in the config dialog.
390 if ((before != after) || (allowOld != allowUnknownSoftware))
391 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
393 // If the "Alpine" ROM is changed, then let's load it...
394 if (alpineBefore != alpineAfter)
396 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
398 // Oh crap, we couldn't get the file! Alert the media!
400 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
401 msg.setIcon(QMessageBox::Warning);
406 // If the "ABS" ROM is changed, then let's load it...
407 if (absBefore != absAfter)
409 if (!JaguarLoadFile(vjs.absROMPath))
411 // Oh crap, we couldn't get the file! Alert the media!
413 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
414 msg.setIcon(QMessageBox::Warning);
419 // If the "Enable audio" checkbox changed, then we have to re-init the DAC...
420 if (audioBefore != audioAfter)
426 // Just in case we crash before a clean exit...
431 // Here's the main emulator loop
433 void MainWin::Timer(void)
438 if (showUntunedTankCircuit)
440 // Random hash & trash
441 // We try to simulate an untuned tank circuit here... :-)
442 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
444 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
446 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
447 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
453 // Otherwise, run the Jaguar simulation
457 videoWidget->updateGL();
460 void MainWin::TogglePowerState(void)
462 powerButtonOn = !powerButtonOn;
465 // With the power off, we simulate white noise on the screen. :-)
468 useCDAct->setDisabled(false);
469 palAct->setDisabled(false);
470 ntscAct->setDisabled(false);
471 pauseAct->setChecked(false);
472 pauseAct->setDisabled(true);
473 showUntunedTankCircuit = true;
474 // This is just in case the ROM we were playing was in a narrow or wide field mode,
475 // so the untuned tank sim doesn't look wrong. :-)
480 useCDAct->setDisabled(true);
481 palAct->setDisabled(true);
482 ntscAct->setDisabled(true);
483 pauseAct->setChecked(false);
484 pauseAct->setDisabled(false);
485 showUntunedTankCircuit = false;
487 // Otherwise, we prepare for running regular software...
490 // Should check for cartridgeLoaded here as well...!
491 // We can clear it when toggling CDActive on, so that when we power cycle it does the
492 // expected thing. Otherwise, if we use the file picker to insert a cart, we expect
493 // to run the cart! Maybe have a RemoveCart function that only works if the CD unit
495 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
496 " - Now playing: Jaguar CD"));
499 WriteLog("GUI: Resetting Jaguar...\n");
504 void MainWin::ToggleRunState(void)
510 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
512 uint32_t pixel = videoWidget->buffer[i];
513 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
514 pixel = ((r + g + b) / 3) & 0x00FF;
515 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
518 videoWidget->updateGL();
522 void MainWin::SetZoom100(void)
528 void MainWin::SetZoom200(void)
534 void MainWin::SetZoom300(void)
540 void MainWin::SetNTSC(void)
542 powerAct->setIcon(powerRed);
543 timer->setInterval(16);
544 vjs.hardwareTypeNTSC = true;
548 void MainWin::SetPAL(void)
550 powerAct->setIcon(powerGreen);
551 timer->setInterval(20);
552 vjs.hardwareTypeNTSC = false;
556 void MainWin::ToggleBlur(void)
558 vjs.glFilter = !vjs.glFilter;
561 void MainWin::ShowAboutWin(void)
566 void MainWin::ShowHelpWin(void)
571 void MainWin::InsertCart(void)
573 // If the emulator is running, we pause it here and unpause it later
574 // if we dismiss the file selector without choosing anything
575 if (running && powerButtonOn)
578 pauseForFileSelector = true;
584 void MainWin::Unpause(void)
586 // Here we unpause the emulator if it was paused when we went into the file selector
587 if (pauseForFileSelector)
589 pauseForFileSelector = false;
594 void MainWin::LoadSoftware(QString file)
596 running = false; // Prevent bad things(TM) from happening...
597 pauseForFileSelector = false; // Reset the file selector pause flag
598 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
599 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
601 char * biosPointer = jaguarBootROM;
603 if (vjs.hardwareTypeAlpine)
604 biosPointer = jaguarDevBootROM2;
606 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
608 powerAct->setDisabled(false);
609 powerAct->setChecked(true);
610 powerButtonOn = false;
613 if (!vjs.hardwareTypeAlpine)
615 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
616 .arg(filePickWin->GetSelectedPrettyName());
617 setWindowTitle(newTitle);
621 void MainWin::ToggleCDUsage(void)
623 CDActive = !CDActive;
628 powerAct->setDisabled(false);
632 powerAct->setDisabled(true);
635 // Set up the Jaguar CD for execution, otherwise, clear memory
637 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
639 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
643 void MainWin::ResizeMainWindow(void)
645 videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256));
648 for(int i=0; i<2; i++)
652 QApplication::processEvents();
656 void MainWin::ReadSettings(void)
658 QSettings settings("Underground Software", "Virtual Jaguar");
659 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
660 QSize size = settings.value("size", QSize(400, 400)).toSize();
663 pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
664 filePickWin->move(pos);
666 zoomLevel = settings.value("zoom", 2).toInt();
667 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
669 vjs.useJoystick = settings.value("useJoystick", false).toBool();
670 vjs.joyport = settings.value("joyport", 0).toInt();
671 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
672 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
673 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
674 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
675 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
676 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
677 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
678 vjs.fullscreen = settings.value("fullscreen", false).toBool();
679 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
680 vjs.glFilter = settings.value("glFilterType", 1).toInt();
681 vjs.renderType = settings.value("renderType", 0).toInt();
682 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
683 // strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data());
684 // strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data());
685 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
686 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
687 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
688 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
689 WriteLog("MainWin: Paths\n");
690 //WriteLog(" jagBootPath = \"%s\"\n", vjs.jagBootPath);
691 //WriteLog(" CDBootPath = \"%s\"\n", vjs.CDBootPath);
692 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
693 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
694 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
695 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
697 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
698 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
699 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
700 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
701 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
702 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
703 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
704 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
705 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
706 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
707 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
708 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
709 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
710 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
711 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
712 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
713 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
714 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
715 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
716 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
717 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
718 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
720 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
721 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
722 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
723 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
724 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
725 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
726 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
727 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
728 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
729 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
730 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
731 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
732 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
733 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
734 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
735 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
736 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
737 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
738 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
739 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
740 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
743 void MainWin::WriteSettings(void)
745 QSettings settings("Underground Software", "Virtual Jaguar");
746 settings.setValue("pos", pos());
747 settings.setValue("size", size());
748 settings.setValue("cartLoadPos", filePickWin->pos());
750 settings.setValue("zoom", zoomLevel);
751 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
753 settings.setValue("useJoystick", vjs.useJoystick);
754 settings.setValue("joyport", vjs.joyport);
755 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
756 settings.setValue("frameSkip", vjs.frameSkip);
757 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
758 settings.setValue("GPUEnabled", vjs.GPUEnabled);
759 settings.setValue("DSPEnabled", vjs.DSPEnabled);
760 settings.setValue("audioEnabled", vjs.audioEnabled);
761 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
762 settings.setValue("fullscreen", vjs.fullscreen);
763 settings.setValue("useOpenGL", vjs.useOpenGL);
764 settings.setValue("glFilterType", vjs.glFilter);
765 settings.setValue("renderType", vjs.renderType);
766 settings.setValue("writeROM", vjs.allowWritesToROM);
767 settings.setValue("JagBootROM", vjs.jagBootPath);
768 settings.setValue("CDBootROM", vjs.CDBootPath);
769 settings.setValue("EEPROMs", vjs.EEPROMPath);
770 settings.setValue("ROMs", vjs.ROMPath);
771 settings.setValue("DefaultROM", vjs.alpineROMPath);
772 settings.setValue("DefaultABS", vjs.absROMPath);
774 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
775 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
776 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
777 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
778 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
779 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
780 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
781 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
782 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
783 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
784 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
785 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
786 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
787 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
788 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
789 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
790 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
791 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
792 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
793 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
794 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
796 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
797 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
798 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
799 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
800 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
801 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
802 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
803 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
804 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
805 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
806 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
807 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
808 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
809 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
810 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
811 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
812 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
813 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
814 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
815 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
816 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);