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");
263 memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
265 // Check for filename passed in on the command line...
266 if (!filenameToRun.isEmpty())
269 // Attempt to load/run the file the user passed in...
270 LoadSoftware(filenameToRun);
271 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
272 // Prevent the scanner from running...
276 // Load up the default ROM if in Alpine mode:
277 if (vjs.hardwareTypeAlpine)
279 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
281 // If regular load failed, try just a straight file load
282 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
284 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
287 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
289 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
291 // Attempt to load/run the ABS file...
292 LoadSoftware(vjs.absROMPath);
293 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
294 // Prevent the scanner from running...
298 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS
300 // Run the scanner if nothing passed in and *not* Alpine mode...
301 // NB: Really need to look into caching the info scanned in here...
302 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
305 void MainWin::closeEvent(QCloseEvent * event)
309 event->accept(); // ignore() if can't close for some reason
312 void MainWin::keyPressEvent(QKeyEvent * e)
314 // We ignore the Alt key for now, since it causes problems with the GUI
315 if (e->key() == Qt::Key_Alt)
324 void MainWin::keyReleaseEvent(QKeyEvent * e)
326 // We ignore the Alt key for now, since it causes problems with the GUI
327 if (e->key() == Qt::Key_Alt)
333 HandleKeys(e, false);
336 void MainWin::HandleKeys(QKeyEvent * e, bool state)
338 // We kill bad key combos here, before they can get to the emulator...
339 // This also kills the illegal instruction problem that cropped up in Rayman!
340 // May want to do this by killing the old one instead of ignoring the new one...
341 // Seems to work better that way...
343 if ((e->key() == vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
344 || (e->key() == vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
345 || (e->key() == vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
346 || (e->key() == vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U]))
349 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
350 joypad_0_buttons[BUTTON_R] = 0;
351 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
352 joypad_0_buttons[BUTTON_L] = 0;
353 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
354 joypad_0_buttons[BUTTON_D] = 0;
355 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
356 joypad_0_buttons[BUTTON_U] = 0;
358 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
359 joypad_1_buttons[BUTTON_R] = 0;
360 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
361 joypad_1_buttons[BUTTON_L] = 0;
362 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
363 joypad_1_buttons[BUTTON_D] = 0;
364 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
365 joypad_1_buttons[BUTTON_U] = 0;
368 // No bad combos exist, let's stuff the emulator key buffers...!
369 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
371 if (e->key() == (int)vjs.p1KeyBindings[i])
372 // joypad_0_buttons[i] = (uint8)state;
373 joypad_0_buttons[i] = (state ? 0x01 : 0x00);
375 // Pad #2 is screwing up pad #1. Prolly a problem in joystick.cpp...
376 // So let's try to fix it there. :-P [DONE]
377 if (e->key() == (int)vjs.p2KeyBindings[i])
378 // joypad_1_buttons[i] = (uint8)state;
379 joypad_1_buttons[i] = (state ? 0x01 : 0x00);
383 void MainWin::Open(void)
387 void MainWin::Configure(void)
389 // Call the configuration dialog and update settings
390 ConfigDialog dlg(this);
392 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
394 if (dlg.exec() == false)
397 QString before = vjs.ROMPath;
398 QString alpineBefore = vjs.alpineROMPath;
399 QString absBefore = vjs.absROMPath;
400 bool audioBefore = vjs.audioEnabled;
401 dlg.UpdateVJSettings();
402 QString after = vjs.ROMPath;
403 QString alpineAfter = vjs.alpineROMPath;
404 QString absAfter = vjs.absROMPath;
405 bool audioAfter = vjs.audioEnabled;
407 bool allowOld = allowUnknownSoftware;
409 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
411 // We rescan the "software" folder if the user either changed the path or
412 // checked/unchecked the "Allow unknown files" option in the config dialog.
413 if ((before != after) || (allowOld != allowUnknownSoftware))
414 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
416 // If the "Alpine" ROM is changed, then let's load it...
417 if (alpineBefore != alpineAfter)
419 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
421 // Oh crap, we couldn't get the file! Alert the media!
423 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
424 msg.setIcon(QMessageBox::Warning);
429 // If the "ABS" ROM is changed, then let's load it...
430 if (absBefore != absAfter)
432 if (!JaguarLoadFile(vjs.absROMPath))
434 // Oh crap, we couldn't get the file! Alert the media!
436 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
437 msg.setIcon(QMessageBox::Warning);
442 // If the "Enable audio" checkbox changed, then we have to re-init the DAC...
443 if (audioBefore != audioAfter)
449 // Just in case we crash before a clean exit...
454 // Here's the main emulator loop
456 void MainWin::Timer(void)
461 if (showUntunedTankCircuit)
463 // Some machines can't handle this, so we give them the option to disable it. :-)
464 if (!plzDontKillMyComputer)
466 // Random hash & trash
467 // We try to simulate an untuned tank circuit here... :-)
468 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
470 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
472 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
473 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
480 // Otherwise, run the Jaguar simulation
484 videoWidget->updateGL();
487 void MainWin::TogglePowerState(void)
489 powerButtonOn = !powerButtonOn;
492 // With the power off, we simulate white noise on the screen. :-)
495 useCDAct->setDisabled(false);
496 palAct->setDisabled(false);
497 ntscAct->setDisabled(false);
498 pauseAct->setChecked(false);
499 pauseAct->setDisabled(true);
500 showUntunedTankCircuit = true;
501 // This is just in case the ROM we were playing was in a narrow or wide field mode,
502 // so the untuned tank sim doesn't look wrong. :-)
507 useCDAct->setDisabled(true);
508 palAct->setDisabled(true);
509 ntscAct->setDisabled(true);
510 pauseAct->setChecked(false);
511 pauseAct->setDisabled(false);
512 showUntunedTankCircuit = false;
514 // Otherwise, we prepare for running regular software...
517 // Should check for cartridgeLoaded here as well...!
518 // We can clear it when toggling CDActive on, so that when we power cycle it does the
519 // expected thing. Otherwise, if we use the file picker to insert a cart, we expect
520 // to run the cart! Maybe have a RemoveCart function that only works if the CD unit
522 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
523 " - Now playing: Jaguar CD"));
526 WriteLog("GUI: Resetting Jaguar...\n");
531 void MainWin::ToggleRunState(void)
537 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
539 uint32_t pixel = videoWidget->buffer[i];
540 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
541 pixel = ((r + g + b) / 3) & 0x00FF;
542 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
545 videoWidget->updateGL();
549 void MainWin::SetZoom100(void)
555 void MainWin::SetZoom200(void)
561 void MainWin::SetZoom300(void)
567 void MainWin::SetNTSC(void)
569 powerAct->setIcon(powerRed);
570 timer->setInterval(16);
571 vjs.hardwareTypeNTSC = true;
575 void MainWin::SetPAL(void)
577 powerAct->setIcon(powerGreen);
578 timer->setInterval(20);
579 vjs.hardwareTypeNTSC = false;
583 void MainWin::ToggleBlur(void)
585 vjs.glFilter = !vjs.glFilter;
588 void MainWin::ShowAboutWin(void)
593 void MainWin::ShowHelpWin(void)
598 void MainWin::InsertCart(void)
600 // If the emulator is running, we pause it here and unpause it later
601 // if we dismiss the file selector without choosing anything
602 if (running && powerButtonOn)
605 pauseForFileSelector = true;
611 void MainWin::Unpause(void)
613 // Here we unpause the emulator if it was paused when we went into the file selector
614 if (pauseForFileSelector)
616 pauseForFileSelector = false;
618 // Some nutter might have unpaused while in the file selector, so check for that
624 void MainWin::LoadSoftware(QString file)
626 running = false; // Prevent bad things(TM) from happening...
627 pauseForFileSelector = false; // Reset the file selector pause flag
628 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
629 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
631 char * biosPointer = jaguarBootROM;
633 if (vjs.hardwareTypeAlpine)
634 biosPointer = jaguarDevBootROM2;
636 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
638 powerAct->setDisabled(false);
639 powerAct->setChecked(true);
640 powerButtonOn = false;
643 if (!vjs.hardwareTypeAlpine && !loadAndGo)
645 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
646 .arg(filePickWin->GetSelectedPrettyName());
647 setWindowTitle(newTitle);
651 void MainWin::ToggleCDUsage(void)
653 CDActive = !CDActive;
658 powerAct->setDisabled(false);
662 powerAct->setDisabled(true);
665 // Set up the Jaguar CD for execution, otherwise, clear memory
667 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
669 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
673 void MainWin::FrameAdvance(void)
675 //printf("Frame Advance...\n");
676 // Execute 1 frame, then exit (only useful in Pause mode)
678 videoWidget->updateGL();
681 void MainWin::ResizeMainWindow(void)
683 videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256));
686 for(int i=0; i<2; i++)
690 QApplication::processEvents();
694 void MainWin::ReadSettings(void)
696 QSettings settings("Underground Software", "Virtual Jaguar");
697 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
698 QSize size = settings.value("size", QSize(400, 400)).toSize();
701 pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
702 filePickWin->move(pos);
704 zoomLevel = settings.value("zoom", 2).toInt();
705 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
707 vjs.useJoystick = settings.value("useJoystick", false).toBool();
708 vjs.joyport = settings.value("joyport", 0).toInt();
709 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
710 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
711 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
712 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
713 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
714 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
715 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
716 vjs.fullscreen = settings.value("fullscreen", false).toBool();
717 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
718 vjs.glFilter = settings.value("glFilterType", 1).toInt();
719 vjs.renderType = settings.value("renderType", 0).toInt();
720 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
721 // strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data());
722 // strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data());
723 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
724 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
725 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
726 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
727 WriteLog("MainWin: Paths\n");
728 //WriteLog(" jagBootPath = \"%s\"\n", vjs.jagBootPath);
729 //WriteLog(" CDBootPath = \"%s\"\n", vjs.CDBootPath);
730 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
731 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
732 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
733 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
735 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
736 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
737 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
738 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
739 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
740 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
741 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
742 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
743 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
744 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
745 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
746 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
747 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
748 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
749 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
750 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
751 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
752 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
753 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
754 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
755 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
756 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
758 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
759 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
760 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
761 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
762 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
763 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
764 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
765 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
766 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
767 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
768 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
769 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
770 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
771 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
772 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
773 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
774 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
775 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
776 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
777 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
778 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
781 void MainWin::WriteSettings(void)
783 QSettings settings("Underground Software", "Virtual Jaguar");
784 settings.setValue("pos", pos());
785 settings.setValue("size", size());
786 settings.setValue("cartLoadPos", filePickWin->pos());
788 settings.setValue("zoom", zoomLevel);
789 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
791 settings.setValue("useJoystick", vjs.useJoystick);
792 settings.setValue("joyport", vjs.joyport);
793 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
794 settings.setValue("frameSkip", vjs.frameSkip);
795 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
796 settings.setValue("GPUEnabled", vjs.GPUEnabled);
797 settings.setValue("DSPEnabled", vjs.DSPEnabled);
798 settings.setValue("audioEnabled", vjs.audioEnabled);
799 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
800 settings.setValue("fullscreen", vjs.fullscreen);
801 settings.setValue("useOpenGL", vjs.useOpenGL);
802 settings.setValue("glFilterType", vjs.glFilter);
803 settings.setValue("renderType", vjs.renderType);
804 settings.setValue("writeROM", vjs.allowWritesToROM);
805 settings.setValue("JagBootROM", vjs.jagBootPath);
806 settings.setValue("CDBootROM", vjs.CDBootPath);
807 settings.setValue("EEPROMs", vjs.EEPROMPath);
808 settings.setValue("ROMs", vjs.ROMPath);
809 settings.setValue("DefaultROM", vjs.alpineROMPath);
810 settings.setValue("DefaultABS", vjs.absROMPath);
812 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
813 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
814 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
815 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
816 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
817 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
818 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
819 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
820 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
821 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
822 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
823 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
824 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
825 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
826 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
827 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
828 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
829 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
830 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
831 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
832 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
834 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
835 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
836 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
837 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
838 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
839 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
840 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
841 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
842 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
843 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
844 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
845 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
846 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
847 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
848 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
849 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
850 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
851 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
852 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
853 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
854 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);