2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James 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...
42 #include "filepicker.h"
43 #include "configdialog.h"
44 #include "generaltab.h"
53 #include "jagcdbios.h"
54 #include "jagstub2bios.h"
58 // Apparently on win32, usleep() is not pulled in by the usual suspects.
62 // The way BSNES controls things is by setting a timer with a zero
63 // timeout, sleeping if not emulating anything. Seems there has to be a
66 // It has a novel approach to plugging-in/using different video/audio/input
67 // methods, can we do something similar or should we just use the built-in
70 // We're going to try to use the built-in OpenGL support and see how it goes.
71 // We'll make the VJ core modular so that it doesn't matter what GUI is in
72 // use, we can drop it in anywhere and use it as-is.
74 MainWin::MainWin(QString filenameToRun): running(true), powerButtonOn(false),
75 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
76 //, alpineLoadSuccessful(false),
77 pauseForFileSelector(false), loadAndGo(false), plzDontKillMyComputer(false)
79 videoWidget = new GLWidget(this);
80 setCentralWidget(videoWidget);
81 setWindowIcon(QIcon(":/res/vj-icon.png"));
83 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION ));
85 if (vjs.hardwareTypeAlpine)
86 title += QString(tr(" - Alpine Mode"));
88 setWindowTitle(title);
90 aboutWin = new AboutWindow(this);
91 helpWin = new HelpWindow(this);
92 filePickWin = new FilePickerWindow(this);
94 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
95 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
97 setUnifiedTitleAndToolBarOnMac(true);
101 quitAppAct = new QAction(tr("E&xit"), this);
102 // quitAppAct->setShortcuts(QKeySequence::Quit);
103 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
104 quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
105 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
106 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
108 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
109 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
110 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
111 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
113 // powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
114 powerAct = new QAction(powerGreen, tr("&Power"), this);
115 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
116 powerAct->setCheckable(true);
117 powerAct->setChecked(false);
118 // powerAct->setDisabled(true);
119 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
122 pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off);
123 pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On);
124 // pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
125 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
126 pauseAct->setStatusTip(tr("Toggles the running state"));
127 pauseAct->setCheckable(true);
128 pauseAct->setDisabled(true);
129 pauseAct->setShortcut(QKeySequence(tr("Esc")));
130 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
132 zoomActs = new QActionGroup(this);
134 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
135 x1Act->setStatusTip(tr("Set window zoom to 100%"));
136 x1Act->setCheckable(true);
137 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
139 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
140 x2Act->setStatusTip(tr("Set window zoom to 200%"));
141 x2Act->setCheckable(true);
142 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
144 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
145 x3Act->setStatusTip(tr("Set window zoom to 300%"));
146 x3Act->setCheckable(true);
147 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
149 tvTypeActs = new QActionGroup(this);
151 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
152 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
153 ntscAct->setCheckable(true);
154 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
156 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
157 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
158 palAct->setCheckable(true);
159 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
161 blurAct = new QAction(QIcon(":/res/generic.png"), tr("Blur"), this);
162 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
163 blurAct->setCheckable(true);
164 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
166 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
167 aboutAct->setStatusTip(tr("Blatant self-promotion"));
168 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
170 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
171 helpAct->setStatusTip(tr("Help is available, if you should need it"));
172 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
174 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
175 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
176 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
177 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
179 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
180 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
181 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
182 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
184 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
185 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
186 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
187 useCDAct->setCheckable(true);
188 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
190 frameAdvanceAct = new QAction(QIcon(":/res/generic.png"), tr("&Frame Advance"), this);
191 frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
192 connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
194 // Misc. connections...
195 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
196 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
198 // Create menus & toolbars
200 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
201 fileMenu->addAction(powerAct);
202 fileMenu->addAction(pauseAct);
203 fileMenu->addAction(frameAdvanceAct);
204 fileMenu->addAction(filePickAct);
205 fileMenu->addAction(useCDAct);
206 fileMenu->addAction(configAct);
207 fileMenu->addAction(quitAppAct);
209 helpMenu = menuBar()->addMenu(tr("&Help"));
210 helpMenu->addAction(helpAct);
211 helpMenu->addAction(aboutAct);
213 toolbar = addToolBar(tr("Stuff"));
214 toolbar->addAction(powerAct);
215 toolbar->addAction(pauseAct);
216 toolbar->addAction(filePickAct);
217 toolbar->addAction(useCDAct);
218 toolbar->addSeparator();
219 toolbar->addAction(x1Act);
220 toolbar->addAction(x2Act);
221 toolbar->addAction(x3Act);
222 toolbar->addSeparator();
223 toolbar->addAction(ntscAct);
224 toolbar->addAction(palAct);
225 toolbar->addSeparator();
226 toolbar->addAction(blurAct);
229 statusBar()->showMessage(tr("Ready"));
233 // Set toolbar buttons/menus based on settings read in (sync the UI)...
234 blurAct->setChecked(vjs.glFilter);
235 x1Act->setChecked(zoomLevel == 1);
236 x2Act->setChecked(zoomLevel == 2);
237 x3Act->setChecked(zoomLevel == 3);
238 // running = powerAct->isChecked();
239 ntscAct->setChecked(vjs.hardwareTypeNTSC);
240 palAct->setChecked(!vjs.hardwareTypeNTSC);
241 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
243 // Do this in case original size isn't correct (mostly for the first-run case)
246 // Set up timer based loop for animation...
247 timer = new QTimer(this);
248 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
249 //This is only correct for PAL. !!! FIX !!! [DONE]
250 //Use timer->setInterval( int msec ) to fix this on the fly
252 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
253 // This is because it's discarding the 0.6666... on the end of the fraction.
254 // Alas, 6 doesn't divide cleanly into 10. :-P
255 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
257 // We set this initially, to make VJ behave somewhat as it would if no
258 // cart were inserted and the BIOS was set as active...
259 jaguarCartInserted = true;
260 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
261 WriteLog("VJ: Initializing jaguar subsystem...\n");
264 if (!filenameToRun.isEmpty())
267 // Attempt to load/run the file the user passed in...
268 LoadSoftware(filenameToRun);
269 memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
270 // Prevent the scanner from running...
274 // Load up the default ROM if in Alpine mode:
275 if (vjs.hardwareTypeAlpine)
277 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
279 // If regular load failed, try just a straight file load
280 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
282 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
285 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
287 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
289 // Attempt to load/run the ABS file...
290 LoadSoftware(vjs.absROMPath);
291 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
292 // Prevent the scanner from running...
296 memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS
298 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
301 void MainWin::closeEvent(QCloseEvent * event)
305 event->accept(); // ignore() if can't close for some reason
308 void MainWin::keyPressEvent(QKeyEvent * e)
310 // We ignore the Alt key for now, since it causes problems with the GUI
311 if (e->key() == Qt::Key_Alt)
320 void MainWin::keyReleaseEvent(QKeyEvent * e)
322 // We ignore the Alt key for now, since it causes problems with the GUI
323 if (e->key() == Qt::Key_Alt)
329 HandleKeys(e, false);
332 void MainWin::HandleKeys(QKeyEvent * e, bool state)
334 // We kill bad key combos here, before they can get to the emulator...
335 // This also kills the illegal instruction problem that cropped up in Rayman!
336 // May want to do this by killing the old one instead of ignoring the new one...
337 // Seems to work better that way...
339 if ((e->key() == vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
340 || (e->key() == vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
341 || (e->key() == vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
342 || (e->key() == vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U]))
345 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
346 joypad_0_buttons[BUTTON_R] = 0;
347 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
348 joypad_0_buttons[BUTTON_L] = 0;
349 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
350 joypad_0_buttons[BUTTON_D] = 0;
351 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
352 joypad_0_buttons[BUTTON_U] = 0;
354 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
355 joypad_1_buttons[BUTTON_R] = 0;
356 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
357 joypad_1_buttons[BUTTON_L] = 0;
358 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
359 joypad_1_buttons[BUTTON_D] = 0;
360 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
361 joypad_1_buttons[BUTTON_U] = 0;
364 // No bad combos exist, let's stuff the emulator key buffers...!
365 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
367 if (e->key() == (int)vjs.p1KeyBindings[i])
368 // joypad_0_buttons[i] = (uint8)state;
369 joypad_0_buttons[i] = (state ? 0x01 : 0x00);
371 // Pad #2 is screwing up pad #1. Prolly a problem in joystick.cpp...
372 // So let's try to fix it there. :-P [DONE]
373 if (e->key() == (int)vjs.p2KeyBindings[i])
374 // joypad_1_buttons[i] = (uint8)state;
375 joypad_1_buttons[i] = (state ? 0x01 : 0x00);
379 void MainWin::Open(void)
383 void MainWin::Configure(void)
385 // Call the configuration dialog and update settings
386 ConfigDialog dlg(this);
388 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
390 if (dlg.exec() == false)
393 QString before = vjs.ROMPath;
394 QString alpineBefore = vjs.alpineROMPath;
395 QString absBefore = vjs.absROMPath;
396 bool audioBefore = vjs.audioEnabled;
397 dlg.UpdateVJSettings();
398 QString after = vjs.ROMPath;
399 QString alpineAfter = vjs.alpineROMPath;
400 QString absAfter = vjs.absROMPath;
401 bool audioAfter = vjs.audioEnabled;
403 bool allowOld = allowUnknownSoftware;
405 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
407 // We rescan the "software" folder if the user either changed the path or
408 // checked/unchecked the "Allow unknown files" option in the config dialog.
409 if ((before != after) || (allowOld != allowUnknownSoftware))
410 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
412 // If the "Alpine" ROM is changed, then let's load it...
413 if (alpineBefore != alpineAfter)
415 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
417 // Oh crap, we couldn't get the file! Alert the media!
419 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
420 msg.setIcon(QMessageBox::Warning);
425 // If the "ABS" ROM is changed, then let's load it...
426 if (absBefore != absAfter)
428 if (!JaguarLoadFile(vjs.absROMPath))
430 // Oh crap, we couldn't get the file! Alert the media!
432 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
433 msg.setIcon(QMessageBox::Warning);
438 // If the "Enable audio" checkbox changed, then we have to re-init the DAC...
439 if (audioBefore != audioAfter)
445 // Just in case we crash before a clean exit...
450 // Here's the main emulator loop
452 void MainWin::Timer(void)
457 if (showUntunedTankCircuit)
459 // Some machines can't handle this, so we give them the option to disable it. :-)
460 if (!plzDontKillMyComputer)
462 // Random hash & trash
463 // We try to simulate an untuned tank circuit here... :-)
464 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
466 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
468 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
469 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
476 // Otherwise, run the Jaguar simulation
480 videoWidget->updateGL();
483 void MainWin::TogglePowerState(void)
485 powerButtonOn = !powerButtonOn;
488 // With the power off, we simulate white noise on the screen. :-)
491 useCDAct->setDisabled(false);
492 palAct->setDisabled(false);
493 ntscAct->setDisabled(false);
494 pauseAct->setChecked(false);
495 pauseAct->setDisabled(true);
496 showUntunedTankCircuit = true;
497 // This is just in case the ROM we were playing was in a narrow or wide field mode,
498 // so the untuned tank sim doesn't look wrong. :-)
503 useCDAct->setDisabled(true);
504 palAct->setDisabled(true);
505 ntscAct->setDisabled(true);
506 pauseAct->setChecked(false);
507 pauseAct->setDisabled(false);
508 showUntunedTankCircuit = false;
510 // Otherwise, we prepare for running regular software...
513 // Should check for cartridgeLoaded here as well...!
514 // We can clear it when toggling CDActive on, so that when we power cycle it does the
515 // expected thing. Otherwise, if we use the file picker to insert a cart, we expect
516 // to run the cart! Maybe have a RemoveCart function that only works if the CD unit
518 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
519 " - Now playing: Jaguar CD"));
522 WriteLog("GUI: Resetting Jaguar...\n");
527 void MainWin::ToggleRunState(void)
533 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
535 uint32_t pixel = videoWidget->buffer[i];
536 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
537 pixel = ((r + g + b) / 3) & 0x00FF;
538 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
541 videoWidget->updateGL();
545 void MainWin::SetZoom100(void)
551 void MainWin::SetZoom200(void)
557 void MainWin::SetZoom300(void)
563 void MainWin::SetNTSC(void)
565 powerAct->setIcon(powerRed);
566 timer->setInterval(16);
567 vjs.hardwareTypeNTSC = true;
571 void MainWin::SetPAL(void)
573 powerAct->setIcon(powerGreen);
574 timer->setInterval(20);
575 vjs.hardwareTypeNTSC = false;
579 void MainWin::ToggleBlur(void)
581 vjs.glFilter = !vjs.glFilter;
584 void MainWin::ShowAboutWin(void)
589 void MainWin::ShowHelpWin(void)
594 void MainWin::InsertCart(void)
596 // If the emulator is running, we pause it here and unpause it later
597 // if we dismiss the file selector without choosing anything
598 if (running && powerButtonOn)
601 pauseForFileSelector = true;
607 void MainWin::Unpause(void)
609 // Here we unpause the emulator if it was paused when we went into the file selector
610 if (pauseForFileSelector)
612 pauseForFileSelector = false;
614 // Some nutter might have unpaused while in the file selector, so check for that
620 void MainWin::LoadSoftware(QString file)
622 running = false; // Prevent bad things(TM) from happening...
623 pauseForFileSelector = false; // Reset the file selector pause flag
624 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
625 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
627 char * biosPointer = jaguarBootROM;
629 if (vjs.hardwareTypeAlpine)
630 biosPointer = jaguarDevBootROM2;
632 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
634 powerAct->setDisabled(false);
635 powerAct->setChecked(true);
636 powerButtonOn = false;
639 if (!vjs.hardwareTypeAlpine && !loadAndGo)
641 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
642 .arg(filePickWin->GetSelectedPrettyName());
643 setWindowTitle(newTitle);
647 void MainWin::ToggleCDUsage(void)
649 CDActive = !CDActive;
654 powerAct->setDisabled(false);
658 powerAct->setDisabled(true);
661 // Set up the Jaguar CD for execution, otherwise, clear memory
663 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
665 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
669 void MainWin::FrameAdvance(void)
671 //printf("Frame Advance...\n");
672 // Execute 1 frame, then exit (only useful in Pause mode)
674 videoWidget->updateGL();
677 void MainWin::ResizeMainWindow(void)
679 videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256));
682 for(int i=0; i<2; i++)
686 QApplication::processEvents();
690 void MainWin::ReadSettings(void)
692 QSettings settings("Underground Software", "Virtual Jaguar");
693 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
694 QSize size = settings.value("size", QSize(400, 400)).toSize();
697 pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
698 filePickWin->move(pos);
700 zoomLevel = settings.value("zoom", 2).toInt();
701 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
703 vjs.useJoystick = settings.value("useJoystick", false).toBool();
704 vjs.joyport = settings.value("joyport", 0).toInt();
705 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
706 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
707 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
708 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
709 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
710 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
711 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
712 vjs.fullscreen = settings.value("fullscreen", false).toBool();
713 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
714 vjs.glFilter = settings.value("glFilterType", 1).toInt();
715 vjs.renderType = settings.value("renderType", 0).toInt();
716 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
717 // strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data());
718 // strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data());
719 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
720 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
721 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
722 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
723 WriteLog("MainWin: Paths\n");
724 //WriteLog(" jagBootPath = \"%s\"\n", vjs.jagBootPath);
725 //WriteLog(" CDBootPath = \"%s\"\n", vjs.CDBootPath);
726 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
727 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
728 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
729 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
731 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
732 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
733 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
734 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
735 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
736 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
737 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
738 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
739 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
740 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
741 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
742 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
743 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
744 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
745 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
746 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
747 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
748 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
749 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
750 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
751 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
752 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
754 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
755 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
756 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
757 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
758 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
759 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
760 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
761 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
762 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
763 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
764 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
765 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
766 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
767 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
768 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
769 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
770 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
771 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
772 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
773 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
774 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
777 void MainWin::WriteSettings(void)
779 QSettings settings("Underground Software", "Virtual Jaguar");
780 settings.setValue("pos", pos());
781 settings.setValue("size", size());
782 settings.setValue("cartLoadPos", filePickWin->pos());
784 settings.setValue("zoom", zoomLevel);
785 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
787 settings.setValue("useJoystick", vjs.useJoystick);
788 settings.setValue("joyport", vjs.joyport);
789 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
790 settings.setValue("frameSkip", vjs.frameSkip);
791 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
792 settings.setValue("GPUEnabled", vjs.GPUEnabled);
793 settings.setValue("DSPEnabled", vjs.DSPEnabled);
794 settings.setValue("audioEnabled", vjs.audioEnabled);
795 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
796 settings.setValue("fullscreen", vjs.fullscreen);
797 settings.setValue("useOpenGL", vjs.useOpenGL);
798 settings.setValue("glFilterType", vjs.glFilter);
799 settings.setValue("renderType", vjs.renderType);
800 settings.setValue("writeROM", vjs.allowWritesToROM);
801 settings.setValue("JagBootROM", vjs.jagBootPath);
802 settings.setValue("CDBootROM", vjs.CDBootPath);
803 settings.setValue("EEPROMs", vjs.EEPROMPath);
804 settings.setValue("ROMs", vjs.ROMPath);
805 settings.setValue("DefaultROM", vjs.alpineROMPath);
806 settings.setValue("DefaultABS", vjs.absROMPath);
808 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
809 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
810 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
811 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
812 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
813 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
814 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
815 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
816 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
817 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
818 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
819 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
820 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
821 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
822 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
823 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
824 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
825 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
826 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
827 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
828 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
830 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
831 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
832 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
833 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
834 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
835 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
836 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
837 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
838 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
839 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
840 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
841 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
842 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
843 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
844 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
845 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
846 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
847 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
848 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
849 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
850 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);