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
20 // with 'R', etc) [DONE]
21 // - Controller configuration [DONE]
25 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
26 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
27 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
30 // SFDX CODE: S1E9T8H5M23YS
32 // Uncomment this for debugging...
34 //#define DEBUGFOO // Various tool debugging...
35 //#define DEBUGTP // Toolpalette debugging...
42 #include "configdialog.h"
43 #include "controllertab.h"
44 #include "filepicker.h"
46 #include "generaltab.h"
52 #include "debug/cpubrowser.h"
53 #include "debug/m68kdasmbrowser.h"
54 #include "debug/memorybrowser.h"
55 #include "debug/opbrowser.h"
56 #include "debug/riscdasmbrowser.h"
64 #include "jagcdbios.h"
65 #include "jagstub2bios.h"
67 #include "m68000/m68kinterface.h"
69 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
71 // Apparently on win32, usleep() is not pulled in by the usual suspects.
75 // The way BSNES controls things is by setting a timer with a zero
76 // timeout, sleeping if not emulating anything. Seems there has to be a
79 // It has a novel approach to plugging-in/using different video/audio/input
80 // methods, can we do something similar or should we just use the built-in
83 // We're going to try to use the built-in OpenGL support and see how it goes.
84 // We'll make the VJ core modular so that it doesn't matter what GUI is in
85 // use, we can drop it in anywhere and use it as-is.
87 MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
88 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
89 pauseForFileSelector(false), loadAndGo(autoRun), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
93 for(int i=0; i<8; i++)
97 for(int i=0; i<RING_BUFFER_SIZE; i++)
100 ringBufferPointer = RING_BUFFER_SIZE - 1;
102 videoWidget = new GLWidget(this);
103 setCentralWidget(videoWidget);
104 setWindowIcon(QIcon(":/res/vj-icon.png"));
106 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION ));
108 if (vjs.hardwareTypeAlpine)
109 title += QString(tr(" - Alpine Mode"));
111 setWindowTitle(title);
113 aboutWin = new AboutWindow(this);
114 helpWin = new HelpWindow(this);
115 filePickWin = new FilePickerWindow(this);
116 memBrowseWin = new MemoryBrowserWindow(this);
117 cpuBrowseWin = new CPUBrowserWindow(this);
118 opBrowseWin = new OPBrowserWindow(this);
119 m68kDasmBrowseWin = new M68KDasmBrowserWindow(this);
120 riscDasmBrowseWin = new RISCDasmBrowserWindow(this);
122 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
123 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
125 setUnifiedTitleAndToolBarOnMac(true);
129 quitAppAct = new QAction(tr("E&xit"), this);
130 // quitAppAct->setShortcuts(QKeySequence::Quit);
131 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
132 quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
133 quitAppAct->setShortcutContext(Qt::ApplicationShortcut);
134 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
135 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
137 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
138 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
139 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
140 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
142 // powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
143 powerAct = new QAction(powerGreen, tr("&Power"), this);
144 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
145 powerAct->setCheckable(true);
146 powerAct->setChecked(false);
147 // powerAct->setDisabled(true);
148 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
151 pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off);
152 pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On);
153 // pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
154 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
155 pauseAct->setStatusTip(tr("Toggles the running state"));
156 pauseAct->setCheckable(true);
157 pauseAct->setDisabled(true);
158 pauseAct->setShortcut(QKeySequence(tr("Esc")));
159 pauseAct->setShortcutContext(Qt::ApplicationShortcut);
160 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
162 zoomActs = new QActionGroup(this);
164 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
165 x1Act->setStatusTip(tr("Set window zoom to 100%"));
166 x1Act->setCheckable(true);
167 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
169 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
170 x2Act->setStatusTip(tr("Set window zoom to 200%"));
171 x2Act->setCheckable(true);
172 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
174 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
175 x3Act->setStatusTip(tr("Set window zoom to 300%"));
176 x3Act->setCheckable(true);
177 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
179 tvTypeActs = new QActionGroup(this);
181 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
182 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
183 ntscAct->setCheckable(true);
184 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
186 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
187 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
188 palAct->setCheckable(true);
189 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
191 blurAct = new QAction(QIcon(":/res/blur.png"), tr("Blur"), this);
192 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
193 blurAct->setCheckable(true);
194 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
196 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
197 aboutAct->setStatusTip(tr("Blatant self-promotion"));
198 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
200 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
201 helpAct->setStatusTip(tr("Help is available, if you should need it"));
202 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
204 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
205 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
206 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
207 filePickAct->setShortcutContext(Qt::ApplicationShortcut);
208 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
210 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
211 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
212 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
213 configAct->setShortcutContext(Qt::ApplicationShortcut);
214 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
216 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
217 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
218 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
219 useCDAct->setCheckable(true);
220 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
222 frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
223 frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
224 frameAdvanceAct->setShortcutContext(Qt::ApplicationShortcut);
225 frameAdvanceAct->setDisabled(true);
226 connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
228 fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
229 fullScreenAct->setShortcut(QKeySequence(tr("F9")));
230 fullScreenAct->setShortcutContext(Qt::ApplicationShortcut);
231 fullScreenAct->setCheckable(true);
232 connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
235 memBrowseAct = new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
236 memBrowseAct->setStatusTip(tr("Shows the Jaguar memory browser window"));
237 // memBrowseAct->setCheckable(true);
238 connect(memBrowseAct, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
240 cpuBrowseAct = new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
241 cpuBrowseAct->setStatusTip(tr("Shows the Jaguar CPU browser window"));
242 // memBrowseAct->setCheckable(true);
243 connect(cpuBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
245 opBrowseAct = new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
246 opBrowseAct->setStatusTip(tr("Shows the Jaguar OP browser window"));
247 // memBrowseAct->setCheckable(true);
248 connect(opBrowseAct, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
250 m68kDasmBrowseAct = new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
251 m68kDasmBrowseAct->setStatusTip(tr("Shows the 68K disassembly browser window"));
252 // memBrowseAct->setCheckable(true);
253 connect(m68kDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
255 riscDasmBrowseAct = new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
256 riscDasmBrowseAct->setStatusTip(tr("Shows the RISC disassembly browser window"));
257 // memBrowseAct->setCheckable(true);
258 connect(riscDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
260 // Misc. connections...
261 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
262 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
264 // Create menus & toolbars
266 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
267 fileMenu->addAction(powerAct);
268 fileMenu->addAction(pauseAct);
269 // fileMenu->addAction(frameAdvanceAct);
270 fileMenu->addAction(filePickAct);
271 fileMenu->addAction(useCDAct);
272 fileMenu->addAction(configAct);
273 fileMenu->addAction(quitAppAct);
275 if (vjs.hardwareTypeAlpine)
277 debugMenu = menuBar()->addMenu(tr("&Debug"));
278 debugMenu->addAction(memBrowseAct);
279 debugMenu->addAction(cpuBrowseAct);
280 debugMenu->addAction(opBrowseAct);
281 debugMenu->addAction(m68kDasmBrowseAct);
282 debugMenu->addAction(riscDasmBrowseAct);
285 helpMenu = menuBar()->addMenu(tr("&Help"));
286 helpMenu->addAction(helpAct);
287 helpMenu->addAction(aboutAct);
289 toolbar = addToolBar(tr("Stuff"));
290 toolbar->addAction(powerAct);
291 toolbar->addAction(pauseAct);
292 toolbar->addAction(frameAdvanceAct);
293 toolbar->addAction(filePickAct);
294 toolbar->addAction(useCDAct);
295 toolbar->addSeparator();
296 toolbar->addAction(x1Act);
297 toolbar->addAction(x2Act);
298 toolbar->addAction(x3Act);
299 toolbar->addSeparator();
300 toolbar->addAction(ntscAct);
301 toolbar->addAction(palAct);
302 toolbar->addSeparator();
303 toolbar->addAction(blurAct);
304 toolbar->addAction(fullScreenAct);
306 if (vjs.hardwareTypeAlpine)
308 debugbar = addToolBar(tr("&Debug"));
309 debugbar->addAction(memBrowseAct);
310 debugbar->addAction(cpuBrowseAct);
311 debugbar->addAction(opBrowseAct);
312 debugbar->addAction(m68kDasmBrowseAct);
313 debugbar->addAction(riscDasmBrowseAct);
316 // Add actions to the main window, as hiding widgets with them
318 addAction(fullScreenAct);
319 addAction(quitAppAct);
320 addAction(configAct);
322 addAction(filePickAct);
323 addAction(frameAdvanceAct);
326 statusBar()->showMessage(tr("Ready"));
330 // Do this in case original size isn't correct (mostly for the first-run case)
333 // Create our test pattern bitmap
334 QImage tempImg(":/res/test-pattern.jpg");
335 QImage tempImgScaled = tempImg.scaled(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT_PAL, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
337 for(uint32_t y=0; y<VIRTUAL_SCREEN_HEIGHT_PAL; y++)
339 const QRgb * scanline = (QRgb *)tempImgScaled.constScanLine(y);
341 for(uint32_t x=0; x<VIRTUAL_SCREEN_WIDTH; x++)
343 uint32_t pixel = (qRed(scanline[x]) << 24) | (qGreen(scanline[x]) << 16) | (qBlue(scanline[x]) << 8) | 0xFF;
344 testPattern[(y * VIRTUAL_SCREEN_WIDTH) + x] = pixel;
348 // Set up timer based loop for animation...
349 timer = new QTimer(this);
350 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
352 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
353 // This is because it's discarding the 0.6666... on the end of the fraction.
354 // Alas, 6 doesn't divide cleanly into 10. :-P
355 //Should we defer this until SyncUI? Probably.
356 //No, it doesn't work, because it uses setInterval() instead of start()...
357 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
359 // We set this initially, to make VJ behave somewhat as it would if no
360 // cart were inserted and the BIOS was set as active...
361 jaguarCartInserted = true;
362 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
363 WriteLog("VJ: Initializing jaguar subsystem...\n");
365 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
366 memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
368 // Prevent the file scanner from running if filename passed
369 // in on the command line...
373 // Load up the default ROM if in Alpine mode:
374 if (vjs.hardwareTypeAlpine)
376 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
378 // If regular load failed, try just a straight file load
379 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
381 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
384 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
386 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
388 // Attempt to load/run the ABS file...
389 LoadSoftware(vjs.absROMPath);
390 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
391 // Prevent the scanner from running...
395 // Run the scanner if nothing passed in and *not* Alpine mode...
396 // NB: Really need to look into caching the info scanned in here...
397 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
398 scannedSoftwareFolder = true;
402 void MainWin::LoadFile(QString file)
408 void MainWin::SyncUI(void)
410 // Set toolbar buttons/menus based on settings read in (sync the UI)...
411 // (Really, this is to sync command line options passed in)
412 blurAct->setChecked(vjs.glFilter);
413 x1Act->setChecked(zoomLevel == 1);
414 x2Act->setChecked(zoomLevel == 2);
415 x3Act->setChecked(zoomLevel == 3);
416 // running = powerAct->isChecked();
417 ntscAct->setChecked(vjs.hardwareTypeNTSC);
418 palAct->setChecked(!vjs.hardwareTypeNTSC);
419 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
421 fullScreenAct->setChecked(vjs.fullscreen);
422 fullScreen = vjs.fullscreen;
423 SetFullScreen(fullScreen);
425 // Reset the timer to be what was set in the command line (if any):
426 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
427 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
431 void MainWin::closeEvent(QCloseEvent * event)
434 // This should only be done by the config dialog
437 event->accept(); // ignore() if can't close for some reason
441 void MainWin::keyPressEvent(QKeyEvent * e)
444 extern bool startM68KTracing;
446 extern int blit_start_log;
448 extern bool startConciseBlitLogging;
451 // We ignore the Alt key for now, since it causes problems with the GUI
452 if (e->key() == Qt::Key_Alt)
457 else if (e->key() == Qt::Key_F11)
459 startM68KTracing = true;
463 else if (e->key() == Qt::Key_F12)
465 blit_start_log = true;
469 else if (e->key() == Qt::Key_F10)
471 startConciseBlitLogging = true;
475 else if (e->key() == Qt::Key_F8)
477 // ggn: For extra NYAN pleasure...
478 // ggn: There you go James :P
479 // Shamus: Thanks for the patch! :-D
480 WriteLog(" o + + +\n");
481 WriteLog("+ o o + o\n");
482 WriteLog("-_-_-_-_-_-_-_,------, o \n");
483 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
484 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
485 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
486 WriteLog("+ o o + o\n");
493 This is done now by a QAction...
494 if (e->key() == Qt::Key_F9)
504 void MainWin::keyReleaseEvent(QKeyEvent * e)
506 // We ignore the Alt key for now, since it causes problems with the GUI
507 if (e->key() == Qt::Key_Alt)
513 HandleKeys(e, false);
517 void MainWin::HandleKeys(QKeyEvent * e, bool state)
519 enum { P1LEFT = 0, P1RIGHT, P1UP, P1DOWN, P2LEFT, P2RIGHT, P2UP, P2DOWN };
520 // We kill bad key combos here, before they can get to the emulator...
521 // This also kills the illegal instruction problem that cropped up in
524 // First, settle key states...
525 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L])
526 keyHeld[P1LEFT] = state;
527 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R])
528 keyHeld[P1RIGHT] = state;
529 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U])
530 keyHeld[P1UP] = state;
531 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D])
532 keyHeld[P1DOWN] = state;
533 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L])
534 keyHeld[P2LEFT] = state;
535 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R])
536 keyHeld[P2RIGHT] = state;
537 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U])
538 keyHeld[P2UP] = state;
539 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D])
540 keyHeld[P2DOWN] = state;
542 // Next, check for conflicts and kill 'em if there are any...
543 if (keyHeld[P1LEFT] && keyHeld[P1RIGHT])
544 keyHeld[P1LEFT] = keyHeld[P1RIGHT] = false;
546 if (keyHeld[P1UP] && keyHeld[P1DOWN])
547 keyHeld[P1UP] = keyHeld[P1DOWN] = false;
549 if (keyHeld[P2LEFT] && keyHeld[P2RIGHT])
550 keyHeld[P2LEFT] = keyHeld[P2RIGHT] = false;
552 if (keyHeld[P2UP] && keyHeld[P2DOWN])
553 keyHeld[P2UP] = keyHeld[P2DOWN] = false;
555 // No bad combos exist now, let's stuff the emulator key buffers...!
556 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
558 if (e->key() == (int)vjs.p1KeyBindings[i])
559 joypad0Buttons[i] = (state ? 0x01 : 0x00);
561 if (e->key() == (int)vjs.p2KeyBindings[i])
562 joypad1Buttons[i] = (state ? 0x01 : 0x00);
568 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
570 void MainWin::HandleGamepads(void)
574 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
576 if (vjs.p1KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
577 joypad0Buttons[i] = (Gamepad::GetState(gamepadIDSlot1, vjs.p1KeyBindings[i]) ? 0x01 : 0x00);
579 if (vjs.p2KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
580 joypad1Buttons[i] = (Gamepad::GetState(gamepadIDSlot2, vjs.p2KeyBindings[i]) ? 0x01 : 0x00);
585 void MainWin::Open(void)
590 void MainWin::Configure(void)
592 // Call the configuration dialog and update settings
593 ConfigDialog dlg(this);
595 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
596 dlg.controllerTab1->profileNum = lastEditedProfile;
597 dlg.controllerTab1->SetupLastUsedProfile();
598 // maybe instead of this, we tell the controller tab to work on a copy that gets
599 // written if the user hits 'OK'.
600 SaveProfiles(); // Just in case user cancels
602 if (dlg.exec() == false)
608 QString before = vjs.ROMPath;
609 QString alpineBefore = vjs.alpineROMPath;
610 QString absBefore = vjs.absROMPath;
611 // bool audioBefore = vjs.audioEnabled;
612 bool audioBefore = vjs.DSPEnabled;
613 dlg.UpdateVJSettings();
614 QString after = vjs.ROMPath;
615 QString alpineAfter = vjs.alpineROMPath;
616 QString absAfter = vjs.absROMPath;
617 // bool audioAfter = vjs.audioEnabled;
618 bool audioAfter = vjs.DSPEnabled;
620 bool allowOld = allowUnknownSoftware;
622 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
623 lastEditedProfile = dlg.controllerTab1->profileNum;
624 AutoConnectProfiles();
626 // We rescan the "software" folder if the user either changed the path or
627 // checked/unchecked the "Allow unknown files" option in the config dialog.
628 if ((before != after) || (allowOld != allowUnknownSoftware))
629 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
631 // If the "Alpine" ROM is changed, then let's load it...
632 if (alpineBefore != alpineAfter)
634 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
636 // Oh crap, we couldn't get the file! Alert the media!
638 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
639 msg.setIcon(QMessageBox::Warning);
644 // If the "ABS" ROM is changed, then let's load it...
645 if (absBefore != absAfter)
647 if (!JaguarLoadFile(vjs.absROMPath))
649 // Oh crap, we couldn't get the file! Alert the media!
651 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
652 msg.setIcon(QMessageBox::Warning);
657 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
658 // since it's running in the host audio IRQ...
659 if (audioBefore != audioAfter)
665 // Just in case we crash before a clean exit...
671 // Here's the main emulator loop
673 void MainWin::Timer(void)
676 static uint32_t ntscTickCount;
677 if (vjs.hardwareTypeNTSC)
681 timer->start(16 + (ntscTickCount == 0 ? 1 : 0));
688 if (showUntunedTankCircuit)
690 // Some machines can't handle this, so we give them the option to disable it. :-)
691 if (!plzDontKillMyComputer)
693 // Random hash & trash
694 // We try to simulate an untuned tank circuit here... :-)
695 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
697 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
699 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
700 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
707 // Otherwise, run the Jaguar simulation
710 videoWidget->HandleMouseHiding();
713 videoWidget->updateGL();
716 // Approach: We use a ring buffer to store times (in ms) over a given
717 // amount of frames, then sum them to figure out the FPS.
718 uint32_t timestamp = SDL_GetTicks();
719 // This assumes the ring buffer size is a power of 2
720 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
721 // Doing it this way is better. Ring buffer size can be arbitrary then.
722 ringBufferPointer = (ringBufferPointer + 1) % RING_BUFFER_SIZE;
723 ringBuffer[ringBufferPointer] = timestamp - oldTimestamp;
724 uint32_t elapsedTime = 0;
726 for(uint32_t i=0; i<RING_BUFFER_SIZE; i++)
727 elapsedTime += ringBuffer[i];
729 // elapsedTime must be non-zero
730 if (elapsedTime == 0)
733 // This is in frames per 10 seconds, so we can have 1 decimal
734 uint32_t framesPerSecond = (uint32_t)(((float)RING_BUFFER_SIZE / (float)elapsedTime) * 10000.0);
735 uint32_t fpsIntegerPart = framesPerSecond / 10;
736 uint32_t fpsDecimalPart = framesPerSecond % 10;
737 // If this is updated too frequently to be useful, we can throttle it down
738 // so that it only updates every 10th frame or so
739 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart).arg(fpsDecimalPart));
740 oldTimestamp = timestamp;
744 void MainWin::TogglePowerState(void)
746 powerButtonOn = !powerButtonOn;
749 // With the power off, we simulate white noise on the screen. :-)
752 // Restore the mouse pointer, if hidden:
753 videoWidget->CheckAndRestoreMouseCursor();
754 useCDAct->setDisabled(false);
755 palAct->setDisabled(false);
756 ntscAct->setDisabled(false);
757 pauseAct->setChecked(false);
758 pauseAct->setDisabled(true);
759 showUntunedTankCircuit = true;
760 DACPauseAudioThread();
761 // This is just in case the ROM we were playing was in a narrow or wide
762 // field mode, so the untuned tank sim doesn't look wrong. :-)
765 if (plzDontKillMyComputer)
767 // We have to do it line by line, because the texture pitch is not
768 // the same as the picture buffer's pitch.
769 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
771 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
777 useCDAct->setDisabled(true);
778 palAct->setDisabled(true);
779 ntscAct->setDisabled(true);
780 pauseAct->setChecked(false);
781 pauseAct->setDisabled(false);
782 showUntunedTankCircuit = false;
784 // Otherwise, we prepare for running regular software...
787 // Should check for cartridgeLoaded here as well...!
788 // We can clear it when toggling CDActive on, so that when we power cycle it
789 // does the expected thing. Otherwise, if we use the file picker to insert a
790 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
791 // works if the CD unit is active?
792 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
793 " - Now playing: Jaguar CD"));
796 WriteLog("GUI: Resetting Jaguar...\n");
798 DACPauseAudioThread(false);
803 void MainWin::ToggleRunState(void)
809 // Restore the mouse pointer, if hidden:
810 videoWidget->CheckAndRestoreMouseCursor();
811 frameAdvanceAct->setDisabled(false);
813 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
815 uint32_t pixel = videoWidget->buffer[i];
816 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
817 pixel = ((r + g + b) / 3) & 0x00FF;
818 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
821 videoWidget->updateGL();
824 frameAdvanceAct->setDisabled(true);
826 // Pause/unpause any running/non-running threads...
827 DACPauseAudioThread(!running);
831 void MainWin::SetZoom100(void)
838 void MainWin::SetZoom200(void)
845 void MainWin::SetZoom300(void)
852 void MainWin::SetNTSC(void)
854 powerAct->setIcon(powerRed);
855 timer->setInterval(16);
856 vjs.hardwareTypeNTSC = true;
862 void MainWin::SetPAL(void)
864 powerAct->setIcon(powerGreen);
865 timer->setInterval(20);
866 vjs.hardwareTypeNTSC = false;
872 void MainWin::ToggleBlur(void)
874 vjs.glFilter = !vjs.glFilter;
879 void MainWin::ShowAboutWin(void)
885 void MainWin::ShowHelpWin(void)
891 void MainWin::InsertCart(void)
893 // Check to see if we did autorun, 'cause we didn't load anything in that
895 if (!scannedSoftwareFolder)
897 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
898 scannedSoftwareFolder = true;
901 // If the emulator is running, we pause it here and unpause it later
902 // if we dismiss the file selector without choosing anything
903 if (running && powerButtonOn)
906 pauseForFileSelector = true;
913 void MainWin::Unpause(void)
915 // Here we unpause the emulator if it was paused when we went into the file selector
916 if (pauseForFileSelector)
918 pauseForFileSelector = false;
920 // Some nutter might have unpaused while in the file selector, so check for that
927 void MainWin::LoadSoftware(QString file)
929 running = false; // Prevent bad things(TM) from happening...
930 pauseForFileSelector = false; // Reset the file selector pause flag
932 char * biosPointer = jaguarBootROM;
934 if (vjs.hardwareTypeAlpine)
935 biosPointer = jaguarDevBootROM2;
937 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
939 powerAct->setDisabled(false);
940 powerAct->setChecked(true);
941 powerButtonOn = false;
943 // We have to load our software *after* the Jaguar RESET
944 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
945 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
947 // This is icky because we've already done it
949 if (!vjs.useJaguarBIOS)
950 SET32(jaguarMainRAM, 4, jaguarRunAddress);
954 if (!vjs.hardwareTypeAlpine && !loadAndGo)
956 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
957 .arg(filePickWin->GetSelectedPrettyName());
958 setWindowTitle(newTitle);
963 void MainWin::ToggleCDUsage(void)
965 CDActive = !CDActive;
967 // Set up the Jaguar CD for execution, otherwise, clear memory
969 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
971 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
975 void MainWin::FrameAdvance(void)
977 //printf("Frame Advance...\n");
978 // Execute 1 frame, then exit (only useful in Pause mode)
980 videoWidget->updateGL();
981 // Need to execute 1 frames' worth of DSP thread as well :-/
982 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
986 void MainWin::SetFullScreen(bool state/*= true*/)
990 mainWinPosition = pos();
999 // This is needed because the fullscreen may happen on a different
1000 // screen than screen 0:
1001 int screenNum = QApplication::desktop()->screenNumber(videoWidget);
1002 // QRect r = QApplication::desktop()->availableGeometry(screenNum);
1003 QRect r = QApplication::desktop()->screenGeometry(screenNum);
1004 double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
1005 targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
1006 double aspectRatio = targetWidth / targetHeight;
1007 // NOTE: Really should check here to see which dimension constrains the
1008 // other. Right now, we assume that height is the constraint.
1009 int newWidth = (int)(aspectRatio * (double)r.height());
1010 videoWidget->offset = (r.width() - newWidth) / 2;
1011 videoWidget->fullscreen = true;
1012 videoWidget->outputWidth = newWidth;
1013 videoWidget->setFixedSize(r.width(), r.height());
1018 // Reset the video widget to windowed mode
1019 videoWidget->offset = 0;
1020 videoWidget->fullscreen = false;
1022 statusBar()->show();
1030 move(mainWinPosition);
1035 void MainWin::ToggleFullScreen(void)
1037 fullScreen = !fullScreen;
1038 SetFullScreen(fullScreen);
1042 void MainWin::ShowMemoryBrowserWin(void)
1044 memBrowseWin->show();
1045 memBrowseWin->RefreshContents();
1049 void MainWin::ShowCPUBrowserWin(void)
1051 cpuBrowseWin->show();
1052 cpuBrowseWin->RefreshContents();
1056 void MainWin::ShowOPBrowserWin(void)
1058 opBrowseWin->show();
1059 opBrowseWin->RefreshContents();
1063 void MainWin::ShowM68KDasmBrowserWin(void)
1065 m68kDasmBrowseWin->show();
1066 m68kDasmBrowseWin->RefreshContents();
1070 void MainWin::ShowRISCDasmBrowserWin(void)
1072 riscDasmBrowseWin->show();
1073 riscDasmBrowseWin->RefreshContents();
1077 void MainWin::ResizeMainWindow(void)
1079 videoWidget->setFixedSize(zoomLevel * VIRTUAL_SCREEN_WIDTH,
1080 zoomLevel * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
1082 // Show the test pattern if user requested plzDontKillMyComputer mode
1083 if (!powerButtonOn && plzDontKillMyComputer)
1085 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
1087 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1093 for(int i=0; i<2; i++)
1097 QApplication::processEvents();
1102 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1103 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1104 void MainWin::ReadSettings(void)
1106 QSettings settings("Underground Software", "Virtual Jaguar");
1107 mainWinPosition = settings.value("pos", QPoint(200, 200)).toPoint();
1108 QSize size = settings.value("size", QSize(400, 400)).toSize();
1110 move(mainWinPosition);
1111 QPoint pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
1112 filePickWin->move(pos);
1114 zoomLevel = settings.value("zoom", 2).toInt();
1115 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
1116 lastEditedProfile = settings.value("lastEditedProfile", 0).toInt();
1118 vjs.useJoystick = settings.value("useJoystick", false).toBool();
1119 vjs.joyport = settings.value("joyport", 0).toInt();
1120 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
1121 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
1122 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
1123 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
1124 vjs.DSPEnabled = settings.value("DSPEnabled", true).toBool();
1125 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
1126 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
1127 vjs.fullscreen = settings.value("fullscreen", false).toBool();
1128 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
1129 vjs.glFilter = settings.value("glFilterType", 1).toInt();
1130 vjs.renderType = settings.value("renderType", 0).toInt();
1131 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
1132 vjs.biosType = settings.value("biosType", BT_M_SERIES).toInt();
1133 vjs.useFastBlitter = settings.value("useFastBlitter", false).toBool();
1134 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", QDesktopServices::storageLocation(QDesktopServices::DataLocation).append("/eeproms/")).toString().toAscii().data());
1135 strcpy(vjs.ROMPath, settings.value("ROMs", QDesktopServices::storageLocation(QDesktopServices::DataLocation).append("/software/")).toString().toAscii().data());
1136 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
1137 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
1139 WriteLog("MainWin: Paths\n");
1140 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
1141 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
1142 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
1143 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
1144 WriteLog("Pipelined DSP = %s\n", (vjs.usePipelinedDSP ? "ON" : "off"));
1146 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1147 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
1148 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
1149 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
1150 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
1151 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
1152 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
1153 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
1154 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
1155 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
1156 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
1157 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
1158 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
1159 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
1160 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
1161 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
1162 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
1163 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
1164 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
1165 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
1166 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
1167 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
1169 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
1170 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
1171 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
1172 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
1173 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
1174 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
1175 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
1176 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
1177 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
1178 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
1179 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
1180 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
1181 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
1182 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
1183 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
1184 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
1185 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
1186 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
1187 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
1188 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
1189 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
1191 ReadProfiles(&settings);
1195 void MainWin::WriteSettings(void)
1197 QSettings settings("Underground Software", "Virtual Jaguar");
1198 settings.setValue("pos", pos());
1199 settings.setValue("size", size());
1200 settings.setValue("cartLoadPos", filePickWin->pos());
1202 settings.setValue("zoom", zoomLevel);
1203 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
1204 settings.setValue("lastEditedProfile", lastEditedProfile);
1206 settings.setValue("useJoystick", vjs.useJoystick);
1207 settings.setValue("joyport", vjs.joyport);
1208 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
1209 settings.setValue("frameSkip", vjs.frameSkip);
1210 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
1211 settings.setValue("GPUEnabled", vjs.GPUEnabled);
1212 settings.setValue("DSPEnabled", vjs.DSPEnabled);
1213 settings.setValue("audioEnabled", vjs.audioEnabled);
1214 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
1215 settings.setValue("fullscreen", vjs.fullscreen);
1216 settings.setValue("useOpenGL", vjs.useOpenGL);
1217 settings.setValue("glFilterType", vjs.glFilter);
1218 settings.setValue("renderType", vjs.renderType);
1219 settings.setValue("writeROM", vjs.allowWritesToROM);
1220 settings.setValue("biosType", vjs.biosType);
1221 settings.setValue("useFastBlitter", vjs.useFastBlitter);
1222 settings.setValue("JagBootROM", vjs.jagBootPath);
1223 settings.setValue("CDBootROM", vjs.CDBootPath);
1224 settings.setValue("EEPROMs", vjs.EEPROMPath);
1225 settings.setValue("ROMs", vjs.ROMPath);
1226 settings.setValue("DefaultROM", vjs.alpineROMPath);
1227 settings.setValue("DefaultABS", vjs.absROMPath);
1229 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
1230 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
1231 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
1232 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
1233 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
1234 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
1235 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
1236 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
1237 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
1238 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
1239 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
1240 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
1241 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
1242 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
1243 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
1244 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
1245 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
1246 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
1247 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
1248 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
1249 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
1251 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
1252 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
1253 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
1254 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
1255 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
1256 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
1257 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
1258 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
1259 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
1260 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
1261 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
1262 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
1263 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
1264 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
1265 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
1266 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
1267 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
1268 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
1269 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
1270 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
1271 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);
1273 WriteProfiles(&settings);
1277 void MainWin::WriteUISettings(void)
1279 QSettings settings("Underground Software", "Virtual Jaguar");
1280 settings.setValue("pos", pos());
1281 settings.setValue("size", size());
1282 settings.setValue("cartLoadPos", filePickWin->pos());
1284 settings.setValue("zoom", zoomLevel);