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 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
25 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
26 // - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't)
28 // SFDX CODE: S1E9T8H5M23YS
30 // Uncomment this for debugging...
32 //#define DEBUGFOO // Various tool debugging...
33 //#define DEBUGTP // Toolpalette debugging...
40 #include "configdialog.h"
41 #include "controllertab.h"
42 #include "filepicker.h"
44 #include "generaltab.h"
50 #include "debug/cpubrowser.h"
51 #include "debug/m68kdasmbrowser.h"
52 #include "debug/memorybrowser.h"
53 #include "debug/opbrowser.h"
54 #include "debug/riscdasmbrowser.h"
62 #include "jagcdbios.h"
63 #include "jagstub2bios.h"
65 #include "m68000/m68kinterface.h"
67 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
69 // Apparently on win32, usleep() is not pulled in by the usual suspects.
73 // The way BSNES controls things is by setting a timer with a zero
74 // timeout, sleeping if not emulating anything. Seems there has to be a
77 // It has a novel approach to plugging-in/using different video/audio/input
78 // methods, can we do something similar or should we just use the built-in
81 // We're going to try to use the built-in OpenGL support and see how it goes.
82 // We'll make the VJ core modular so that it doesn't matter what GUI is in
83 // use, we can drop it in anywhere and use it as-is.
85 MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
86 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
87 pauseForFileSelector(false), loadAndGo(autoRun), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
91 for(int i=0; i<8; i++)
95 for(int i=0; i<RING_BUFFER_SIZE; i++)
98 ringBufferPointer = RING_BUFFER_SIZE - 1;
100 videoWidget = new GLWidget(this);
101 setCentralWidget(videoWidget);
102 setWindowIcon(QIcon(":/res/vj-icon.png"));
104 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION ));
106 if (vjs.hardwareTypeAlpine)
107 title += QString(tr(" - Alpine Mode"));
109 setWindowTitle(title);
111 aboutWin = new AboutWindow(this);
112 helpWin = new HelpWindow(this);
113 filePickWin = new FilePickerWindow(this);
114 memBrowseWin = new MemoryBrowserWindow(this);
115 cpuBrowseWin = new CPUBrowserWindow(this);
116 opBrowseWin = new OPBrowserWindow(this);
117 m68kDasmBrowseWin = new M68KDasmBrowserWindow(this);
118 riscDasmBrowseWin = new RISCDasmBrowserWindow(this);
120 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
121 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
123 setUnifiedTitleAndToolBarOnMac(true);
127 quitAppAct = new QAction(tr("E&xit"), this);
128 // quitAppAct->setShortcuts(QKeySequence::Quit);
129 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
130 quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
131 quitAppAct->setShortcutContext(Qt::ApplicationShortcut);
132 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
133 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
135 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
136 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
137 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
138 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
140 // powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
141 powerAct = new QAction(powerGreen, tr("&Power"), this);
142 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
143 powerAct->setCheckable(true);
144 powerAct->setChecked(false);
145 // powerAct->setDisabled(true);
146 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
149 pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off);
150 pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On);
151 // pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
152 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
153 pauseAct->setStatusTip(tr("Toggles the running state"));
154 pauseAct->setCheckable(true);
155 pauseAct->setDisabled(true);
156 pauseAct->setShortcut(QKeySequence(tr("Esc")));
157 pauseAct->setShortcutContext(Qt::ApplicationShortcut);
158 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
160 zoomActs = new QActionGroup(this);
162 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
163 x1Act->setStatusTip(tr("Set window zoom to 100%"));
164 x1Act->setCheckable(true);
165 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
167 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
168 x2Act->setStatusTip(tr("Set window zoom to 200%"));
169 x2Act->setCheckable(true);
170 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
172 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
173 x3Act->setStatusTip(tr("Set window zoom to 300%"));
174 x3Act->setCheckable(true);
175 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
177 tvTypeActs = new QActionGroup(this);
179 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
180 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
181 ntscAct->setCheckable(true);
182 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
184 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
185 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
186 palAct->setCheckable(true);
187 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
189 blurAct = new QAction(QIcon(":/res/blur.png"), tr("Blur"), this);
190 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
191 blurAct->setCheckable(true);
192 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
194 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
195 aboutAct->setStatusTip(tr("Blatant self-promotion"));
196 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
198 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
199 helpAct->setStatusTip(tr("Help is available, if you should need it"));
200 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
202 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
203 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
204 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
205 filePickAct->setShortcutContext(Qt::ApplicationShortcut);
206 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
208 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
209 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
210 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
211 configAct->setShortcutContext(Qt::ApplicationShortcut);
212 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
214 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
215 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
216 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
217 useCDAct->setCheckable(true);
218 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
220 frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
221 frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
222 frameAdvanceAct->setShortcutContext(Qt::ApplicationShortcut);
223 frameAdvanceAct->setDisabled(true);
224 connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
226 fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
227 fullScreenAct->setShortcut(QKeySequence(tr("F9")));
228 fullScreenAct->setShortcutContext(Qt::ApplicationShortcut);
229 fullScreenAct->setCheckable(true);
230 connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
233 memBrowseAct = new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
234 memBrowseAct->setStatusTip(tr("Shows the Jaguar memory browser window"));
235 // memBrowseAct->setCheckable(true);
236 connect(memBrowseAct, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
238 cpuBrowseAct = new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
239 cpuBrowseAct->setStatusTip(tr("Shows the Jaguar CPU browser window"));
240 // memBrowseAct->setCheckable(true);
241 connect(cpuBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
243 opBrowseAct = new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
244 opBrowseAct->setStatusTip(tr("Shows the Jaguar OP browser window"));
245 // memBrowseAct->setCheckable(true);
246 connect(opBrowseAct, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
248 m68kDasmBrowseAct = new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
249 m68kDasmBrowseAct->setStatusTip(tr("Shows the 68K disassembly browser window"));
250 // memBrowseAct->setCheckable(true);
251 connect(m68kDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
253 riscDasmBrowseAct = new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
254 riscDasmBrowseAct->setStatusTip(tr("Shows the RISC disassembly browser window"));
255 // memBrowseAct->setCheckable(true);
256 connect(riscDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
258 // Misc. connections...
259 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
260 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
262 // Create menus & toolbars
264 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
265 fileMenu->addAction(powerAct);
266 fileMenu->addAction(pauseAct);
267 // fileMenu->addAction(frameAdvanceAct);
268 fileMenu->addAction(filePickAct);
269 fileMenu->addAction(useCDAct);
270 fileMenu->addAction(configAct);
271 fileMenu->addAction(quitAppAct);
273 if (vjs.hardwareTypeAlpine)
275 debugMenu = menuBar()->addMenu(tr("&Debug"));
276 debugMenu->addAction(memBrowseAct);
277 debugMenu->addAction(cpuBrowseAct);
278 debugMenu->addAction(opBrowseAct);
279 debugMenu->addAction(m68kDasmBrowseAct);
280 debugMenu->addAction(riscDasmBrowseAct);
283 helpMenu = menuBar()->addMenu(tr("&Help"));
284 helpMenu->addAction(helpAct);
285 helpMenu->addAction(aboutAct);
287 toolbar = addToolBar(tr("Stuff"));
288 toolbar->addAction(powerAct);
289 toolbar->addAction(pauseAct);
290 toolbar->addAction(frameAdvanceAct);
291 toolbar->addAction(filePickAct);
292 toolbar->addAction(useCDAct);
293 toolbar->addSeparator();
294 toolbar->addAction(x1Act);
295 toolbar->addAction(x2Act);
296 toolbar->addAction(x3Act);
297 toolbar->addSeparator();
298 toolbar->addAction(ntscAct);
299 toolbar->addAction(palAct);
300 toolbar->addSeparator();
301 toolbar->addAction(blurAct);
302 toolbar->addAction(fullScreenAct);
304 if (vjs.hardwareTypeAlpine)
306 debugbar = addToolBar(tr("&Debug"));
307 debugbar->addAction(memBrowseAct);
308 debugbar->addAction(cpuBrowseAct);
309 debugbar->addAction(opBrowseAct);
310 debugbar->addAction(m68kDasmBrowseAct);
311 debugbar->addAction(riscDasmBrowseAct);
314 // Add actions to the main window, as hiding widgets with them
316 addAction(fullScreenAct);
317 addAction(quitAppAct);
318 addAction(configAct);
320 addAction(filePickAct);
321 addAction(frameAdvanceAct);
324 statusBar()->showMessage(tr("Ready"));
328 // Do this in case original size isn't correct (mostly for the first-run case)
331 // Create our test pattern bitmap
332 QImage tempImg(":/res/test-pattern.jpg");
333 QImage tempImgScaled = tempImg.scaled(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT_PAL, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
335 for(uint32_t y=0; y<VIRTUAL_SCREEN_HEIGHT_PAL; y++)
337 const QRgb * scanline = (QRgb *)tempImgScaled.constScanLine(y);
339 for(uint32_t x=0; x<VIRTUAL_SCREEN_WIDTH; x++)
341 uint32_t pixel = (qRed(scanline[x]) << 24) | (qGreen(scanline[x]) << 16) | (qBlue(scanline[x]) << 8) | 0xFF;
342 testPattern[(y * VIRTUAL_SCREEN_WIDTH) + x] = pixel;
346 // Set up timer based loop for animation...
347 timer = new QTimer(this);
348 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
350 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
351 // This is because it's discarding the 0.6666... on the end of the fraction.
352 // Alas, 6 doesn't divide cleanly into 10. :-P
353 //Should we defer this until SyncUI? Probably.
354 //No, it doesn't work, because it uses setInterval() instead of start()...
355 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
357 // We set this initially, to make VJ behave somewhat as it would if no
358 // cart were inserted and the BIOS was set as active...
359 jaguarCartInserted = true;
360 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
361 WriteLog("VJ: Initializing jaguar subsystem...\n");
363 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
364 memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
366 // Prevent the file scanner from running if filename passed
367 // in on the command line...
371 // Load up the default ROM if in Alpine mode:
372 if (vjs.hardwareTypeAlpine)
374 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
376 // If regular load failed, try just a straight file load
377 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
379 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
382 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
384 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
386 // Attempt to load/run the ABS file...
387 LoadSoftware(vjs.absROMPath);
388 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
389 // Prevent the scanner from running...
393 // Run the scanner if nothing passed in and *not* Alpine mode...
394 // NB: Really need to look into caching the info scanned in here...
395 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
396 scannedSoftwareFolder = true;
400 void MainWin::LoadFile(QString file)
406 void MainWin::SyncUI(void)
408 // Set toolbar buttons/menus based on settings read in (sync the UI)...
409 // (Really, this is to sync command line options passed in)
410 blurAct->setChecked(vjs.glFilter);
411 x1Act->setChecked(zoomLevel == 1);
412 x2Act->setChecked(zoomLevel == 2);
413 x3Act->setChecked(zoomLevel == 3);
414 // running = powerAct->isChecked();
415 ntscAct->setChecked(vjs.hardwareTypeNTSC);
416 palAct->setChecked(!vjs.hardwareTypeNTSC);
417 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
419 fullScreenAct->setChecked(vjs.fullscreen);
420 fullScreen = vjs.fullscreen;
421 SetFullScreen(fullScreen);
423 // Reset the timer to be what was set in the command line (if any):
424 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
425 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
429 void MainWin::closeEvent(QCloseEvent * event)
432 // This should only be done by the config dialog
435 event->accept(); // ignore() if can't close for some reason
439 void MainWin::keyPressEvent(QKeyEvent * e)
442 extern bool startM68KTracing;
444 extern int blit_start_log;
446 extern bool startConciseBlitLogging;
449 // We ignore the Alt key for now, since it causes problems with the GUI
450 if (e->key() == Qt::Key_Alt)
455 else if (e->key() == Qt::Key_F11)
457 startM68KTracing = true;
461 else if (e->key() == Qt::Key_F12)
463 blit_start_log = true;
467 else if (e->key() == Qt::Key_F10)
469 startConciseBlitLogging = true;
473 else if (e->key() == Qt::Key_F8)
475 // ggn: For extra NYAN pleasure...
476 // ggn: There you go James :P
477 // Shamus: Thanks for the patch! :-D
478 WriteLog(" o + + +\n");
479 WriteLog("+ o o + o\n");
480 WriteLog("-_-_-_-_-_-_-_,------, o \n");
481 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
482 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
483 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
484 WriteLog("+ o o + o\n");
491 This is done now by a QAction...
492 if (e->key() == Qt::Key_F9)
502 void MainWin::keyReleaseEvent(QKeyEvent * e)
504 // We ignore the Alt key for now, since it causes problems with the GUI
505 if (e->key() == Qt::Key_Alt)
511 HandleKeys(e, false);
515 void MainWin::HandleKeys(QKeyEvent * e, bool state)
517 enum { P1LEFT = 0, P1RIGHT, P1UP, P1DOWN, P2LEFT, P2RIGHT, P2UP, P2DOWN };
518 // We kill bad key combos here, before they can get to the emulator...
519 // This also kills the illegal instruction problem that cropped up in
522 // First, settle key states...
523 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L])
524 keyHeld[P1LEFT] = state;
525 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R])
526 keyHeld[P1RIGHT] = state;
527 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U])
528 keyHeld[P1UP] = state;
529 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D])
530 keyHeld[P1DOWN] = state;
531 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L])
532 keyHeld[P2LEFT] = state;
533 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R])
534 keyHeld[P2RIGHT] = state;
535 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U])
536 keyHeld[P2UP] = state;
537 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D])
538 keyHeld[P2DOWN] = state;
540 // Next, check for conflicts and kill 'em if there are any...
541 if (keyHeld[P1LEFT] && keyHeld[P1RIGHT])
542 keyHeld[P1LEFT] = keyHeld[P1RIGHT] = false;
544 if (keyHeld[P1UP] && keyHeld[P1DOWN])
545 keyHeld[P1UP] = keyHeld[P1DOWN] = false;
547 if (keyHeld[P2LEFT] && keyHeld[P2RIGHT])
548 keyHeld[P2LEFT] = keyHeld[P2RIGHT] = false;
550 if (keyHeld[P2UP] && keyHeld[P2DOWN])
551 keyHeld[P2UP] = keyHeld[P2DOWN] = false;
553 // No bad combos exist now, let's stuff the emulator key buffers...!
554 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
556 if (e->key() == (int)vjs.p1KeyBindings[i])
557 joypad0Buttons[i] = (state ? 0x01 : 0x00);
559 if (e->key() == (int)vjs.p2KeyBindings[i])
560 joypad1Buttons[i] = (state ? 0x01 : 0x00);
565 void MainWin::HandleGamepads(void)
569 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
571 if (vjs.p1KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
572 joypad0Buttons[i] = (Gamepad::GetState(0, vjs.p1KeyBindings[i]) ? 0x01 : 0x00);
574 if (vjs.p1KeyBindings[i] & JOY_AXIS)
575 printf("Axis state (HandleGamepads): %i\n", joypad0Buttons[i]);
577 if (vjs.p2KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
578 joypad1Buttons[i] = (Gamepad::GetState(1, vjs.p2KeyBindings[i]) ? 0x01 : 0x00);
583 void MainWin::Open(void)
588 void MainWin::Configure(void)
590 // Call the configuration dialog and update settings
591 ConfigDialog dlg(this);
593 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
594 dlg.controllerTab1->profileNum = lastEditedProfile;
595 dlg.controllerTab1->SetupLastUsedProfile();
597 if (dlg.exec() == false)
600 QString before = vjs.ROMPath;
601 QString alpineBefore = vjs.alpineROMPath;
602 QString absBefore = vjs.absROMPath;
603 // bool audioBefore = vjs.audioEnabled;
604 bool audioBefore = vjs.DSPEnabled;
605 dlg.UpdateVJSettings();
606 QString after = vjs.ROMPath;
607 QString alpineAfter = vjs.alpineROMPath;
608 QString absAfter = vjs.absROMPath;
609 // bool audioAfter = vjs.audioEnabled;
610 bool audioAfter = vjs.DSPEnabled;
612 bool allowOld = allowUnknownSoftware;
614 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
615 lastEditedProfile = dlg.controllerTab1->profileNum;
617 // We rescan the "software" folder if the user either changed the path or
618 // checked/unchecked the "Allow unknown files" option in the config dialog.
619 if ((before != after) || (allowOld != allowUnknownSoftware))
620 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
622 // If the "Alpine" ROM is changed, then let's load it...
623 if (alpineBefore != alpineAfter)
625 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
627 // Oh crap, we couldn't get the file! Alert the media!
629 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
630 msg.setIcon(QMessageBox::Warning);
635 // If the "ABS" ROM is changed, then let's load it...
636 if (absBefore != absAfter)
638 if (!JaguarLoadFile(vjs.absROMPath))
640 // Oh crap, we couldn't get the file! Alert the media!
642 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
643 msg.setIcon(QMessageBox::Warning);
648 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
649 // since it's running in the host audio IRQ...
650 if (audioBefore != audioAfter)
656 // Just in case we crash before a clean exit...
662 // Here's the main emulator loop
664 void MainWin::Timer(void)
669 if (showUntunedTankCircuit)
671 // Some machines can't handle this, so we give them the option to disable it. :-)
672 if (!plzDontKillMyComputer)
674 // Random hash & trash
675 // We try to simulate an untuned tank circuit here... :-)
676 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
678 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
680 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
681 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
688 // Otherwise, run the Jaguar simulation
691 videoWidget->HandleMouseHiding();
694 videoWidget->updateGL();
697 // Approach: We use a ring buffer to store times (in ms) over a given
698 // amount of frames, then sum them to figure out the FPS.
699 uint32_t timestamp = SDL_GetTicks();
700 // This assumes the ring buffer size is a power of 2
701 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
702 // Doing it this way is better. Ring buffer size can be arbitrary then.
703 ringBufferPointer = (ringBufferPointer + 1) % RING_BUFFER_SIZE;
704 ringBuffer[ringBufferPointer] = timestamp - oldTimestamp;
705 uint32_t elapsedTime = 0;
707 for(uint32_t i=0; i<RING_BUFFER_SIZE; i++)
708 elapsedTime += ringBuffer[i];
710 // elapsedTime must be non-zero
711 if (elapsedTime == 0)
714 // This is in frames per 10 seconds, so we can have 1 decimal
715 uint32_t framesPerSecond = (uint32_t)(((float)RING_BUFFER_SIZE / (float)elapsedTime) * 10000.0);
716 uint32_t fpsIntegerPart = framesPerSecond / 10;
717 uint32_t fpsDecimalPart = framesPerSecond % 10;
718 // If this is updated too frequently to be useful, we can throttle it down
719 // so that it only updates every 10th frame or so
720 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart).arg(fpsDecimalPart));
721 oldTimestamp = timestamp;
725 void MainWin::TogglePowerState(void)
727 powerButtonOn = !powerButtonOn;
730 // With the power off, we simulate white noise on the screen. :-)
733 // Restore the mouse pointer, if hidden:
734 videoWidget->CheckAndRestoreMouseCursor();
735 useCDAct->setDisabled(false);
736 palAct->setDisabled(false);
737 ntscAct->setDisabled(false);
738 pauseAct->setChecked(false);
739 pauseAct->setDisabled(true);
740 showUntunedTankCircuit = true;
741 DACPauseAudioThread();
742 // This is just in case the ROM we were playing was in a narrow or wide
743 // field mode, so the untuned tank sim doesn't look wrong. :-)
746 if (plzDontKillMyComputer)
748 // We have to do it line by line, because the texture pitch is not
749 // the same as the picture buffer's pitch.
750 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
752 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
758 useCDAct->setDisabled(true);
759 palAct->setDisabled(true);
760 ntscAct->setDisabled(true);
761 pauseAct->setChecked(false);
762 pauseAct->setDisabled(false);
763 showUntunedTankCircuit = false;
765 // Otherwise, we prepare for running regular software...
768 // Should check for cartridgeLoaded here as well...!
769 // We can clear it when toggling CDActive on, so that when we power cycle it
770 // does the expected thing. Otherwise, if we use the file picker to insert a
771 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
772 // works if the CD unit is active?
773 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
774 " - Now playing: Jaguar CD"));
777 WriteLog("GUI: Resetting Jaguar...\n");
779 DACPauseAudioThread(false);
784 void MainWin::ToggleRunState(void)
790 // Restore the mouse pointer, if hidden:
791 videoWidget->CheckAndRestoreMouseCursor();
792 frameAdvanceAct->setDisabled(false);
794 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
796 uint32_t pixel = videoWidget->buffer[i];
797 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
798 pixel = ((r + g + b) / 3) & 0x00FF;
799 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
802 videoWidget->updateGL();
805 frameAdvanceAct->setDisabled(true);
807 // Pause/unpause any running/non-running threads...
808 DACPauseAudioThread(!running);
812 void MainWin::SetZoom100(void)
819 void MainWin::SetZoom200(void)
826 void MainWin::SetZoom300(void)
833 void MainWin::SetNTSC(void)
835 powerAct->setIcon(powerRed);
836 timer->setInterval(16);
837 vjs.hardwareTypeNTSC = true;
843 void MainWin::SetPAL(void)
845 powerAct->setIcon(powerGreen);
846 timer->setInterval(20);
847 vjs.hardwareTypeNTSC = false;
853 void MainWin::ToggleBlur(void)
855 vjs.glFilter = !vjs.glFilter;
860 void MainWin::ShowAboutWin(void)
866 void MainWin::ShowHelpWin(void)
872 void MainWin::InsertCart(void)
874 // Check to see if we did autorun, 'cause we didn't load anything in that
876 if (!scannedSoftwareFolder)
878 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
879 scannedSoftwareFolder = true;
882 // If the emulator is running, we pause it here and unpause it later
883 // if we dismiss the file selector without choosing anything
884 if (running && powerButtonOn)
887 pauseForFileSelector = true;
894 void MainWin::Unpause(void)
896 // Here we unpause the emulator if it was paused when we went into the file selector
897 if (pauseForFileSelector)
899 pauseForFileSelector = false;
901 // Some nutter might have unpaused while in the file selector, so check for that
908 void MainWin::LoadSoftware(QString file)
910 running = false; // Prevent bad things(TM) from happening...
911 pauseForFileSelector = false; // Reset the file selector pause flag
913 char * biosPointer = jaguarBootROM;
915 if (vjs.hardwareTypeAlpine)
916 biosPointer = jaguarDevBootROM2;
918 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
920 powerAct->setDisabled(false);
921 powerAct->setChecked(true);
922 powerButtonOn = false;
924 // We have to load our software *after* the Jaguar RESET
925 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
926 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
928 // This is icky because we've already done it
930 if (!vjs.useJaguarBIOS)
931 SET32(jaguarMainRAM, 4, jaguarRunAddress);
935 if (!vjs.hardwareTypeAlpine && !loadAndGo)
937 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
938 .arg(filePickWin->GetSelectedPrettyName());
939 setWindowTitle(newTitle);
944 void MainWin::ToggleCDUsage(void)
946 CDActive = !CDActive;
948 // Set up the Jaguar CD for execution, otherwise, clear memory
950 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
952 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
956 void MainWin::FrameAdvance(void)
958 //printf("Frame Advance...\n");
959 // Execute 1 frame, then exit (only useful in Pause mode)
961 videoWidget->updateGL();
962 // Need to execute 1 frames' worth of DSP thread as well :-/
963 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
967 void MainWin::SetFullScreen(bool state/*= true*/)
971 mainWinPosition = pos();
980 // This is needed because the fullscreen may happen on a different
981 // screen than screen 0:
982 int screenNum = QApplication::desktop()->screenNumber(videoWidget);
983 // QRect r = QApplication::desktop()->availableGeometry(screenNum);
984 QRect r = QApplication::desktop()->screenGeometry(screenNum);
985 double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
986 targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
987 double aspectRatio = targetWidth / targetHeight;
988 // NOTE: Really should check here to see which dimension constrains the
989 // other. Right now, we assume that height is the constraint.
990 int newWidth = (int)(aspectRatio * (double)r.height());
991 videoWidget->offset = (r.width() - newWidth) / 2;
992 videoWidget->fullscreen = true;
993 videoWidget->outputWidth = newWidth;
994 videoWidget->setFixedSize(r.width(), r.height());
999 // Reset the video widget to windowed mode
1000 videoWidget->offset = 0;
1001 videoWidget->fullscreen = false;
1003 statusBar()->show();
1011 move(mainWinPosition);
1016 void MainWin::ToggleFullScreen(void)
1018 fullScreen = !fullScreen;
1019 SetFullScreen(fullScreen);
1023 void MainWin::ShowMemoryBrowserWin(void)
1025 memBrowseWin->show();
1026 memBrowseWin->RefreshContents();
1030 void MainWin::ShowCPUBrowserWin(void)
1032 cpuBrowseWin->show();
1033 cpuBrowseWin->RefreshContents();
1037 void MainWin::ShowOPBrowserWin(void)
1039 opBrowseWin->show();
1040 opBrowseWin->RefreshContents();
1044 void MainWin::ShowM68KDasmBrowserWin(void)
1046 m68kDasmBrowseWin->show();
1047 m68kDasmBrowseWin->RefreshContents();
1051 void MainWin::ShowRISCDasmBrowserWin(void)
1053 riscDasmBrowseWin->show();
1054 riscDasmBrowseWin->RefreshContents();
1058 void MainWin::ResizeMainWindow(void)
1060 videoWidget->setFixedSize(zoomLevel * VIRTUAL_SCREEN_WIDTH,
1061 zoomLevel * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
1063 // Show the test pattern if user requested plzDontKillMyComputer mode
1064 if (!powerButtonOn && plzDontKillMyComputer)
1066 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
1068 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1074 for(int i=0; i<2; i++)
1078 QApplication::processEvents();
1083 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1084 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1085 void MainWin::ReadSettings(void)
1087 QSettings settings("Underground Software", "Virtual Jaguar");
1088 mainWinPosition = settings.value("pos", QPoint(200, 200)).toPoint();
1089 QSize size = settings.value("size", QSize(400, 400)).toSize();
1091 move(mainWinPosition);
1092 QPoint pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
1093 filePickWin->move(pos);
1095 zoomLevel = settings.value("zoom", 2).toInt();
1096 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
1097 lastEditedProfile = settings.value("lastEditedProfile", 0).toInt();
1099 vjs.useJoystick = settings.value("useJoystick", false).toBool();
1100 vjs.joyport = settings.value("joyport", 0).toInt();
1101 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
1102 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
1103 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
1104 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
1105 vjs.DSPEnabled = settings.value("DSPEnabled", true).toBool();
1106 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
1107 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
1108 vjs.fullscreen = settings.value("fullscreen", false).toBool();
1109 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
1110 vjs.glFilter = settings.value("glFilterType", 1).toInt();
1111 vjs.renderType = settings.value("renderType", 0).toInt();
1112 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
1113 vjs.biosType = settings.value("biosType", BT_M_SERIES).toInt();
1114 vjs.useFastBlitter = settings.value("useFastBlitter", false).toBool();
1115 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
1116 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
1117 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
1118 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
1120 WriteLog("MainWin: Paths\n");
1121 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
1122 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
1123 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
1124 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
1125 WriteLog("Pipelined DSP = %s\n", (vjs.usePipelinedDSP ? "ON" : "off"));
1127 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1128 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
1129 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
1130 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
1131 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
1132 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
1133 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
1134 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
1135 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
1136 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
1137 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
1138 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
1139 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
1140 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
1141 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
1142 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
1143 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
1144 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
1145 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
1146 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
1147 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
1148 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
1150 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
1151 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
1152 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
1153 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
1154 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
1155 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
1156 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
1157 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
1158 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
1159 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
1160 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
1161 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
1162 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
1163 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
1164 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
1165 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
1166 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
1167 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
1168 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
1169 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
1170 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
1172 ReadProfiles(&settings);
1176 void MainWin::WriteSettings(void)
1178 QSettings settings("Underground Software", "Virtual Jaguar");
1179 settings.setValue("pos", pos());
1180 settings.setValue("size", size());
1181 settings.setValue("cartLoadPos", filePickWin->pos());
1183 settings.setValue("zoom", zoomLevel);
1184 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
1185 settings.setValue("lastEditedProfile", lastEditedProfile);
1187 settings.setValue("useJoystick", vjs.useJoystick);
1188 settings.setValue("joyport", vjs.joyport);
1189 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
1190 settings.setValue("frameSkip", vjs.frameSkip);
1191 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
1192 settings.setValue("GPUEnabled", vjs.GPUEnabled);
1193 settings.setValue("DSPEnabled", vjs.DSPEnabled);
1194 settings.setValue("audioEnabled", vjs.audioEnabled);
1195 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
1196 settings.setValue("fullscreen", vjs.fullscreen);
1197 settings.setValue("useOpenGL", vjs.useOpenGL);
1198 settings.setValue("glFilterType", vjs.glFilter);
1199 settings.setValue("renderType", vjs.renderType);
1200 settings.setValue("writeROM", vjs.allowWritesToROM);
1201 settings.setValue("biosType", vjs.biosType);
1202 settings.setValue("useFastBlitter", vjs.useFastBlitter);
1203 settings.setValue("JagBootROM", vjs.jagBootPath);
1204 settings.setValue("CDBootROM", vjs.CDBootPath);
1205 settings.setValue("EEPROMs", vjs.EEPROMPath);
1206 settings.setValue("ROMs", vjs.ROMPath);
1207 settings.setValue("DefaultROM", vjs.alpineROMPath);
1208 settings.setValue("DefaultABS", vjs.absROMPath);
1210 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
1211 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
1212 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
1213 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
1214 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
1215 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
1216 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
1217 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
1218 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
1219 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
1220 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
1221 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
1222 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
1223 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
1224 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
1225 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
1226 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
1227 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
1228 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
1229 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
1230 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
1232 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
1233 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
1234 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
1235 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
1236 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
1237 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
1238 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
1239 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
1240 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
1241 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
1242 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
1243 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
1244 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
1245 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
1246 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
1247 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
1248 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
1249 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
1250 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
1251 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
1252 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);
1254 WriteProfiles(&settings);
1258 void MainWin::WriteUISettings(void)
1260 QSettings settings("Underground Software", "Virtual Jaguar");
1261 settings.setValue("pos", pos());
1262 settings.setValue("size", size());
1263 settings.setValue("cartLoadPos", filePickWin->pos());
1265 settings.setValue("zoom", zoomLevel);