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 powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
107 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
108 powerAct->setCheckable(true);
109 powerAct->setChecked(false);
110 // powerAct->setDisabled(true);
111 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
113 pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
114 pauseAct->setStatusTip(tr("Toggles the running state"));
115 pauseAct->setCheckable(true);
116 pauseAct->setDisabled(true);
117 pauseAct->setShortcut(QKeySequence(tr("Esc")));
118 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
120 zoomActs = new QActionGroup(this);
122 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
123 x1Act->setStatusTip(tr("Set window zoom to 100%"));
124 x1Act->setCheckable(true);
125 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
127 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
128 x2Act->setStatusTip(tr("Set window zoom to 200%"));
129 x2Act->setCheckable(true);
130 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
132 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
133 x3Act->setStatusTip(tr("Set window zoom to 300%"));
134 x3Act->setCheckable(true);
135 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
137 tvTypeActs = new QActionGroup(this);
139 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
140 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
141 ntscAct->setCheckable(true);
142 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
144 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
145 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
146 palAct->setCheckable(true);
147 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
149 blurAct = new QAction(QIcon(":/res/generic.png"), tr("Blur"), this);
150 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
151 blurAct->setCheckable(true);
152 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
154 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
155 aboutAct->setStatusTip(tr("Blatant self-promotion"));
156 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
158 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
159 helpAct->setStatusTip(tr("Help is available, if you should need it"));
160 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
162 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
163 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
164 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
165 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
167 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
168 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
169 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
170 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
172 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
173 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
174 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
175 useCDAct->setCheckable(true);
176 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
178 // Misc. connections...
179 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
180 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
182 // Create menus & toolbars
184 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
185 fileMenu->addAction(powerAct);
186 fileMenu->addAction(pauseAct);
187 fileMenu->addAction(filePickAct);
188 fileMenu->addAction(useCDAct);
189 fileMenu->addAction(configAct);
190 fileMenu->addAction(quitAppAct);
192 helpMenu = menuBar()->addMenu(tr("&Help"));
193 helpMenu->addAction(helpAct);
194 helpMenu->addAction(aboutAct);
196 toolbar = addToolBar(tr("Stuff"));
197 toolbar->addAction(powerAct);
198 toolbar->addAction(pauseAct);
199 toolbar->addAction(filePickAct);
200 toolbar->addAction(useCDAct);
201 toolbar->addSeparator();
202 toolbar->addAction(x1Act);
203 toolbar->addAction(x2Act);
204 toolbar->addAction(x3Act);
205 toolbar->addSeparator();
206 toolbar->addAction(ntscAct);
207 toolbar->addAction(palAct);
208 toolbar->addSeparator();
209 toolbar->addAction(blurAct);
212 statusBar()->showMessage(tr("Ready"));
216 // Set toolbar buttons/menus based on settings read in (sync the UI)...
217 blurAct->setChecked(vjs.glFilter);
218 x1Act->setChecked(zoomLevel == 1);
219 x2Act->setChecked(zoomLevel == 2);
220 x3Act->setChecked(zoomLevel == 3);
221 // running = powerAct->isChecked();
222 ntscAct->setChecked(vjs.hardwareTypeNTSC);
223 palAct->setChecked(!vjs.hardwareTypeNTSC);
225 // Do this in case original size isn't correct (mostly for the first-run case)
228 // Set up timer based loop for animation...
229 timer = new QTimer(this);
230 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
231 //This is only correct for PAL. !!! FIX !!! [DONE]
232 //Use timer->setInterval( int msec ) to fix this on the fly
234 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
235 // This is because it's discarding the 0.6666... on the end of the fraction.
236 // Alas, 6 doesn't divide cleanly into 10. :-P
237 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
239 // We set this initially, to make VJ behave somewhat as it would if no
240 // cart were inserted and the BIOS was set as active...
241 jaguarCartInserted = true;
242 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
243 WriteLog("VJ: Initializing jaguar subsystem...\n");
246 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
248 // Load up the default ROM if in Alpine mode:
249 if (vjs.hardwareTypeAlpine)
251 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
253 // If regular load failed, try just a straight file load
254 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
256 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
259 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
261 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
263 // Attempt to load/run the ABS file...
264 LoadSoftware(vjs.absROMPath);
265 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
268 memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS
271 void MainWin::closeEvent(QCloseEvent * event)
275 event->accept(); // ignore() if can't close for some reason
278 void MainWin::keyPressEvent(QKeyEvent * e)
280 // We ignore the Alt key for now, since it causes problems with the GUI
281 if (e->key() == Qt::Key_Alt)
290 void MainWin::keyReleaseEvent(QKeyEvent * e)
292 // We ignore the Alt key for now, since it causes problems with the GUI
293 if (e->key() == Qt::Key_Alt)
299 HandleKeys(e, false);
302 void MainWin::HandleKeys(QKeyEvent * e, bool state)
304 // We kill bad key combos here, before they can get to the emulator...
305 // This also kills the illegal instruction problem that cropped up in Rayman!
306 // May want to do this by killing the old one instead of ignoring the new one...
307 // Seems to work better that way...
309 if ((e->key() == vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
310 || (e->key() == vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
311 || (e->key() == vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
312 || (e->key() == vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U]))
315 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
316 joypad_0_buttons[BUTTON_R] = 0;
317 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
318 joypad_0_buttons[BUTTON_L] = 0;
319 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
320 joypad_0_buttons[BUTTON_D] = 0;
321 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
322 joypad_0_buttons[BUTTON_U] = 0;
324 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
325 joypad_1_buttons[BUTTON_R] = 0;
326 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
327 joypad_1_buttons[BUTTON_L] = 0;
328 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
329 joypad_1_buttons[BUTTON_D] = 0;
330 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
331 joypad_1_buttons[BUTTON_U] = 0;
334 // No bad combos exist, let's stuff the emulator key buffers...!
335 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
337 if (e->key() == (int)vjs.p1KeyBindings[i])
338 // joypad_0_buttons[i] = (uint8)state;
339 joypad_0_buttons[i] = (state ? 0x01 : 0x00);
341 // Pad #2 is screwing up pad #1. Prolly a problem in joystick.cpp...
342 // So let's try to fix it there. :-P [DONE]
343 if (e->key() == (int)vjs.p2KeyBindings[i])
344 // joypad_1_buttons[i] = (uint8)state;
345 joypad_1_buttons[i] = (state ? 0x01 : 0x00);
349 void MainWin::Open(void)
353 void MainWin::Configure(void)
355 // Call the configuration dialog and update settings
356 ConfigDialog dlg(this);
358 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
360 if (dlg.exec() == false)
363 QString before = vjs.ROMPath;
364 QString alpineBefore = vjs.alpineROMPath;
365 QString absBefore = vjs.absROMPath;
366 bool audioBefore = vjs.audioEnabled;
367 dlg.UpdateVJSettings();
368 QString after = vjs.ROMPath;
369 QString alpineAfter = vjs.alpineROMPath;
370 QString absAfter = vjs.absROMPath;
371 bool audioAfter = vjs.audioEnabled;
373 bool allowOld = allowUnknownSoftware;
375 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
377 // We rescan the "software" folder if the user either changed the path or
378 // checked/unchecked the "Allow unknown files" option in the config dialog.
379 if ((before != after) || (allowOld != allowUnknownSoftware))
380 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
382 // If the "Alpine" ROM is changed, then let's load it...
383 if (alpineBefore != alpineAfter)
385 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
387 // Oh crap, we couldn't get the file! Alert the media!
389 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
390 msg.setIcon(QMessageBox::Warning);
395 // If the "ABS" ROM is changed, then let's load it...
396 if (absBefore != absAfter)
398 if (!JaguarLoadFile(vjs.absROMPath))
400 // Oh crap, we couldn't get the file! Alert the media!
402 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
403 msg.setIcon(QMessageBox::Warning);
408 // If the "Enable audio" checkbox changed, then we have to re-init the DAC...
409 if (audioBefore != audioAfter)
415 // Just in case we crash before a clean exit...
420 // Here's the main emulator loop
422 void MainWin::Timer(void)
427 if (showUntunedTankCircuit)
429 // Random hash & trash
430 // We try to simulate an untuned tank circuit here... :-)
431 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
433 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
435 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
436 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
442 // Otherwise, run the Jaguar simulation
446 videoWidget->updateGL();
449 void MainWin::TogglePowerState(void)
451 powerButtonOn = !powerButtonOn;
454 // With the power off, we simulate white noise on the screen. :-)
457 useCDAct->setDisabled(false);
458 palAct->setDisabled(false);
459 ntscAct->setDisabled(false);
460 pauseAct->setChecked(false);
461 pauseAct->setDisabled(true);
462 showUntunedTankCircuit = true;
463 // This is just in case the ROM we were playing was in a narrow or wide field mode,
464 // so the untuned tank sim doesn't look wrong. :-)
469 useCDAct->setDisabled(true);
470 palAct->setDisabled(true);
471 ntscAct->setDisabled(true);
472 pauseAct->setChecked(false);
473 pauseAct->setDisabled(false);
474 showUntunedTankCircuit = false;
476 // Otherwise, we prepare for running regular software...
479 // Should check for cartridgeLoaded here as well...!
480 // We can clear it when toggling CDActive on, so that when we power cycle it does the
481 // expected thing. Otherwise, if we use the file picker to insert a cart, we expect
482 // to run the cart! Maybe have a RemoveCart function that only works if the CD unit
484 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
485 " - Now playing: Jaguar CD"));
488 WriteLog("GUI: Resetting Jaguar...\n");
493 void MainWin::ToggleRunState(void)
499 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
501 uint32_t pixel = videoWidget->buffer[i];
502 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
503 pixel = ((r + g + b) / 3) & 0x00FF;
504 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
507 videoWidget->updateGL();
511 void MainWin::SetZoom100(void)
517 void MainWin::SetZoom200(void)
523 void MainWin::SetZoom300(void)
529 void MainWin::SetNTSC(void)
531 timer->setInterval(16);
532 vjs.hardwareTypeNTSC = true;
536 void MainWin::SetPAL(void)
538 timer->setInterval(20);
539 vjs.hardwareTypeNTSC = false;
543 void MainWin::ToggleBlur(void)
545 vjs.glFilter = !vjs.glFilter;
548 void MainWin::ShowAboutWin(void)
553 void MainWin::ShowHelpWin(void)
558 void MainWin::InsertCart(void)
560 // If the emulator is running, we pause it here and unpause it later
561 // if we dismiss the file selector without choosing anything
562 if (running && powerButtonOn)
565 pauseForFileSelector = true;
571 void MainWin::Unpause(void)
573 // Here we unpause the emulator if it was paused when we went into the file selector
574 if (pauseForFileSelector)
576 pauseForFileSelector = false;
581 void MainWin::LoadSoftware(QString file)
583 running = false; // Prevent bad things(TM) from happening...
584 pauseForFileSelector = false; // Reset the file selector pause flag
585 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
586 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
588 char * biosPointer = jaguarBootROM;
590 if (vjs.hardwareTypeAlpine)
591 biosPointer = jaguarDevBootROM2;
593 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
595 powerAct->setDisabled(false);
596 powerAct->setChecked(true);
597 powerButtonOn = false;
600 if (!vjs.hardwareTypeAlpine)
602 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
603 .arg(filePickWin->GetSelectedPrettyName());
604 setWindowTitle(newTitle);
608 void MainWin::ToggleCDUsage(void)
610 CDActive = !CDActive;
615 powerAct->setDisabled(false);
619 powerAct->setDisabled(true);
622 // Set up the Jaguar CD for execution, otherwise, clear memory
624 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
626 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
630 void MainWin::ResizeMainWindow(void)
632 videoWidget->setFixedSize(zoomLevel * 320, zoomLevel * (vjs.hardwareTypeNTSC ? 240 : 256));
635 for(int i=0; i<2; i++)
639 QApplication::processEvents();
643 void MainWin::ReadSettings(void)
645 QSettings settings("Underground Software", "Virtual Jaguar");
646 QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
647 QSize size = settings.value("size", QSize(400, 400)).toSize();
650 pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
651 filePickWin->move(pos);
653 zoomLevel = settings.value("zoom", 2).toInt();
654 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
656 vjs.useJoystick = settings.value("useJoystick", false).toBool();
657 vjs.joyport = settings.value("joyport", 0).toInt();
658 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
659 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
660 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
661 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
662 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
663 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
664 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
665 vjs.fullscreen = settings.value("fullscreen", false).toBool();
666 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
667 vjs.glFilter = settings.value("glFilterType", 1).toInt();
668 vjs.renderType = settings.value("renderType", 0).toInt();
669 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
670 // strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data());
671 // strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data());
672 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
673 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
674 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
675 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
676 WriteLog("MainWin: Paths\n");
677 //WriteLog(" jagBootPath = \"%s\"\n", vjs.jagBootPath);
678 //WriteLog(" CDBootPath = \"%s\"\n", vjs.CDBootPath);
679 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
680 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
681 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
682 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
684 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
685 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
686 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
687 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
688 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
689 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
690 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
691 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
692 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
693 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
694 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
695 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
696 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
697 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
698 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
699 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
700 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
701 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
702 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
703 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
704 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
705 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
707 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
708 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
709 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
710 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
711 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
712 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
713 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
714 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
715 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
716 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
717 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
718 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
719 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
720 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
721 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
722 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
723 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
724 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
725 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
726 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
727 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
730 void MainWin::WriteSettings(void)
732 QSettings settings("Underground Software", "Virtual Jaguar");
733 settings.setValue("pos", pos());
734 settings.setValue("size", size());
735 settings.setValue("cartLoadPos", filePickWin->pos());
737 settings.setValue("zoom", zoomLevel);
738 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
740 settings.setValue("useJoystick", vjs.useJoystick);
741 settings.setValue("joyport", vjs.joyport);
742 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
743 settings.setValue("frameSkip", vjs.frameSkip);
744 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
745 settings.setValue("GPUEnabled", vjs.GPUEnabled);
746 settings.setValue("DSPEnabled", vjs.DSPEnabled);
747 settings.setValue("audioEnabled", vjs.audioEnabled);
748 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
749 settings.setValue("fullscreen", vjs.fullscreen);
750 settings.setValue("useOpenGL", vjs.useOpenGL);
751 settings.setValue("glFilterType", vjs.glFilter);
752 settings.setValue("renderType", vjs.renderType);
753 settings.setValue("writeROM", vjs.allowWritesToROM);
754 settings.setValue("JagBootROM", vjs.jagBootPath);
755 settings.setValue("CDBootROM", vjs.CDBootPath);
756 settings.setValue("EEPROMs", vjs.EEPROMPath);
757 settings.setValue("ROMs", vjs.ROMPath);
758 settings.setValue("DefaultROM", vjs.alpineROMPath);
759 settings.setValue("DefaultABS", vjs.absROMPath);
761 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
762 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
763 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
764 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
765 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
766 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
767 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
768 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
769 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
770 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
771 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
772 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
773 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
774 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
775 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
776 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
777 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
778 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
779 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
780 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
781 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
783 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
784 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
785 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
786 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
787 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
788 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
789 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
790 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
791 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
792 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
793 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
794 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
795 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
796 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
797 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
798 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
799 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
800 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
801 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
802 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
803 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);