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 "filepicker.h"
43 #include "generaltab.h"
48 #include "debug/cpubrowser.h"
49 #include "debug/m68kdasmbrowser.h"
50 #include "debug/memorybrowser.h"
51 #include "debug/opbrowser.h"
52 #include "debug/riscdasmbrowser.h"
60 #include "jagcdbios.h"
61 #include "jagstub2bios.h"
63 #include "m68000/m68kinterface.h"
65 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
67 // Apparently on win32, usleep() is not pulled in by the usual suspects.
71 // The way BSNES controls things is by setting a timer with a zero
72 // timeout, sleeping if not emulating anything. Seems there has to be a
75 // It has a novel approach to plugging-in/using different video/audio/input
76 // methods, can we do something similar or should we just use the built-in
79 // We're going to try to use the built-in OpenGL support and see how it goes.
80 // We'll make the VJ core modular so that it doesn't matter what GUI is in
81 // use, we can drop it in anywhere and use it as-is.
83 MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
84 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
85 pauseForFileSelector(false), loadAndGo(autoRun), plzDontKillMyComputer(false)
89 for(int i=0; i<8; i++)
93 for(int i=0; i<RING_BUFFER_SIZE; i++)
96 ringBufferPointer = RING_BUFFER_SIZE - 1;
98 videoWidget = new GLWidget(this);
99 setCentralWidget(videoWidget);
100 setWindowIcon(QIcon(":/res/vj-icon.png"));
102 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION ));
104 if (vjs.hardwareTypeAlpine)
105 title += QString(tr(" - Alpine Mode"));
107 setWindowTitle(title);
109 aboutWin = new AboutWindow(this);
110 helpWin = new HelpWindow(this);
111 filePickWin = new FilePickerWindow(this);
112 memBrowseWin = new MemoryBrowserWindow(this);
113 cpuBrowseWin = new CPUBrowserWindow(this);
114 opBrowseWin = new OPBrowserWindow(this);
115 m68kDasmBrowseWin = new M68KDasmBrowserWindow(this);
116 riscDasmBrowseWin = new RISCDasmBrowserWindow(this);
118 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
119 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
121 setUnifiedTitleAndToolBarOnMac(true);
125 quitAppAct = new QAction(tr("E&xit"), this);
126 // quitAppAct->setShortcuts(QKeySequence::Quit);
127 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
128 quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
129 quitAppAct->setShortcutContext(Qt::ApplicationShortcut);
130 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
131 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
133 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
134 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
135 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
136 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
138 // powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
139 powerAct = new QAction(powerGreen, tr("&Power"), this);
140 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
141 powerAct->setCheckable(true);
142 powerAct->setChecked(false);
143 // powerAct->setDisabled(true);
144 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
147 pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off);
148 pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On);
149 // pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
150 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
151 pauseAct->setStatusTip(tr("Toggles the running state"));
152 pauseAct->setCheckable(true);
153 pauseAct->setDisabled(true);
154 pauseAct->setShortcut(QKeySequence(tr("Esc")));
155 pauseAct->setShortcutContext(Qt::ApplicationShortcut);
156 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
158 zoomActs = new QActionGroup(this);
160 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
161 x1Act->setStatusTip(tr("Set window zoom to 100%"));
162 x1Act->setCheckable(true);
163 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
165 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
166 x2Act->setStatusTip(tr("Set window zoom to 200%"));
167 x2Act->setCheckable(true);
168 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
170 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
171 x3Act->setStatusTip(tr("Set window zoom to 300%"));
172 x3Act->setCheckable(true);
173 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
175 tvTypeActs = new QActionGroup(this);
177 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
178 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
179 ntscAct->setCheckable(true);
180 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
182 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
183 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
184 palAct->setCheckable(true);
185 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
187 blurAct = new QAction(QIcon(":/res/blur.png"), tr("Blur"), this);
188 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
189 blurAct->setCheckable(true);
190 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
192 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
193 aboutAct->setStatusTip(tr("Blatant self-promotion"));
194 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
196 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
197 helpAct->setStatusTip(tr("Help is available, if you should need it"));
198 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
200 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
201 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
202 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
203 filePickAct->setShortcutContext(Qt::ApplicationShortcut);
204 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
206 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
207 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
208 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
209 configAct->setShortcutContext(Qt::ApplicationShortcut);
210 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
212 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
213 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
214 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
215 useCDAct->setCheckable(true);
216 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
218 frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
219 frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
220 frameAdvanceAct->setShortcutContext(Qt::ApplicationShortcut);
221 frameAdvanceAct->setDisabled(true);
222 connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
224 fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
225 fullScreenAct->setShortcut(QKeySequence(tr("F9")));
226 fullScreenAct->setShortcutContext(Qt::ApplicationShortcut);
227 fullScreenAct->setCheckable(true);
228 connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
231 memBrowseAct = new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
232 memBrowseAct->setStatusTip(tr("Shows the Jaguar memory browser window"));
233 // memBrowseAct->setCheckable(true);
234 connect(memBrowseAct, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
236 cpuBrowseAct = new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
237 cpuBrowseAct->setStatusTip(tr("Shows the Jaguar CPU browser window"));
238 // memBrowseAct->setCheckable(true);
239 connect(cpuBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
241 opBrowseAct = new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
242 opBrowseAct->setStatusTip(tr("Shows the Jaguar OP browser window"));
243 // memBrowseAct->setCheckable(true);
244 connect(opBrowseAct, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
246 m68kDasmBrowseAct = new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
247 m68kDasmBrowseAct->setStatusTip(tr("Shows the 68K disassembly browser window"));
248 // memBrowseAct->setCheckable(true);
249 connect(m68kDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
251 riscDasmBrowseAct = new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
252 riscDasmBrowseAct->setStatusTip(tr("Shows the RISC disassembly browser window"));
253 // memBrowseAct->setCheckable(true);
254 connect(riscDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
256 // Misc. connections...
257 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
258 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
260 // Create menus & toolbars
262 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
263 fileMenu->addAction(powerAct);
264 fileMenu->addAction(pauseAct);
265 // fileMenu->addAction(frameAdvanceAct);
266 fileMenu->addAction(filePickAct);
267 fileMenu->addAction(useCDAct);
268 fileMenu->addAction(configAct);
269 fileMenu->addAction(quitAppAct);
271 if (vjs.hardwareTypeAlpine)
273 debugMenu = menuBar()->addMenu(tr("&Debug"));
274 debugMenu->addAction(memBrowseAct);
275 debugMenu->addAction(cpuBrowseAct);
276 debugMenu->addAction(opBrowseAct);
277 debugMenu->addAction(m68kDasmBrowseAct);
278 debugMenu->addAction(riscDasmBrowseAct);
281 helpMenu = menuBar()->addMenu(tr("&Help"));
282 helpMenu->addAction(helpAct);
283 helpMenu->addAction(aboutAct);
285 toolbar = addToolBar(tr("Stuff"));
286 toolbar->addAction(powerAct);
287 toolbar->addAction(pauseAct);
288 toolbar->addAction(frameAdvanceAct);
289 toolbar->addAction(filePickAct);
290 toolbar->addAction(useCDAct);
291 toolbar->addSeparator();
292 toolbar->addAction(x1Act);
293 toolbar->addAction(x2Act);
294 toolbar->addAction(x3Act);
295 toolbar->addSeparator();
296 toolbar->addAction(ntscAct);
297 toolbar->addAction(palAct);
298 toolbar->addSeparator();
299 toolbar->addAction(blurAct);
300 toolbar->addAction(fullScreenAct);
302 if (vjs.hardwareTypeAlpine)
304 debugbar = addToolBar(tr("&Debug"));
305 debugbar->addAction(memBrowseAct);
306 debugbar->addAction(cpuBrowseAct);
307 debugbar->addAction(opBrowseAct);
308 debugbar->addAction(m68kDasmBrowseAct);
309 debugbar->addAction(riscDasmBrowseAct);
312 // Add actions to the main window, as hiding widgets with them
314 addAction(fullScreenAct);
315 addAction(quitAppAct);
316 addAction(configAct);
318 addAction(filePickAct);
319 addAction(frameAdvanceAct);
322 statusBar()->showMessage(tr("Ready"));
326 // Do this in case original size isn't correct (mostly for the first-run case)
329 // Create our test pattern bitmap
330 QImage tempImg(":/res/test-pattern.jpg");
331 QImage tempImgScaled = tempImg.scaled(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT_PAL, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
333 for(uint32_t y=0; y<VIRTUAL_SCREEN_HEIGHT_PAL; y++)
335 const QRgb * scanline = (QRgb *)tempImgScaled.constScanLine(y);
337 for(uint32_t x=0; x<VIRTUAL_SCREEN_WIDTH; x++)
339 uint32_t pixel = (qRed(scanline[x]) << 24) | (qGreen(scanline[x]) << 16) | (qBlue(scanline[x]) << 8) | 0xFF;
340 testPattern[(y * VIRTUAL_SCREEN_WIDTH) + x] = pixel;
344 // Set up timer based loop for animation...
345 timer = new QTimer(this);
346 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
348 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
349 // This is because it's discarding the 0.6666... on the end of the fraction.
350 // Alas, 6 doesn't divide cleanly into 10. :-P
351 //Should we defer this until SyncUI? Probably.
352 //No, it doesn't work, because it uses setInterval() instead of start()...
353 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
355 // We set this initially, to make VJ behave somewhat as it would if no
356 // cart were inserted and the BIOS was set as active...
357 jaguarCartInserted = true;
358 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
359 WriteLog("VJ: Initializing jaguar subsystem...\n");
361 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
362 memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
364 // Prevent the file scanner from running if filename passed
365 // in on the command line...
369 // Load up the default ROM if in Alpine mode:
370 if (vjs.hardwareTypeAlpine)
372 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
374 // If regular load failed, try just a straight file load
375 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
377 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
380 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
382 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
384 // Attempt to load/run the ABS file...
385 LoadSoftware(vjs.absROMPath);
386 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
387 // Prevent the scanner from running...
391 // Run the scanner if nothing passed in and *not* Alpine mode...
392 // NB: Really need to look into caching the info scanned in here...
393 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
397 void MainWin::LoadFile(QString file)
403 void MainWin::SyncUI(void)
405 // Set toolbar buttons/menus based on settings read in (sync the UI)...
406 // (Really, this is to sync command line options passed in)
407 blurAct->setChecked(vjs.glFilter);
408 x1Act->setChecked(zoomLevel == 1);
409 x2Act->setChecked(zoomLevel == 2);
410 x3Act->setChecked(zoomLevel == 3);
411 // running = powerAct->isChecked();
412 ntscAct->setChecked(vjs.hardwareTypeNTSC);
413 palAct->setChecked(!vjs.hardwareTypeNTSC);
414 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
416 fullScreenAct->setChecked(vjs.fullscreen);
417 fullScreen = vjs.fullscreen;
418 SetFullScreen(fullScreen);
420 // Reset the timer to be what was set in the command line (if any):
421 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
422 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
426 void MainWin::closeEvent(QCloseEvent * event)
429 // This should only be done by the config dialog
432 event->accept(); // ignore() if can't close for some reason
436 void MainWin::keyPressEvent(QKeyEvent * e)
439 extern bool startM68KTracing;
441 // We ignore the Alt key for now, since it causes problems with the GUI
442 if (e->key() == Qt::Key_Alt)
447 else if (e->key() == Qt::Key_F11)
449 startM68KTracing = true;
455 if (e->key() == Qt::Key_F9)
465 void MainWin::keyReleaseEvent(QKeyEvent * e)
467 // We ignore the Alt key for now, since it causes problems with the GUI
468 if (e->key() == Qt::Key_Alt)
474 HandleKeys(e, false);
478 void MainWin::HandleKeys(QKeyEvent * e, bool state)
480 enum { P1LEFT = 0, P1RIGHT, P1UP, P1DOWN, P2LEFT, P2RIGHT, P2UP, P2DOWN };
481 // We kill bad key combos here, before they can get to the emulator...
482 // This also kills the illegal instruction problem that cropped up in Rayman!
483 // May want to do this by killing the old one instead of ignoring the new one...
484 // Seems to work better that way...
486 // The problem with this approach is that it causes bad results because it doesn't do
487 // any checking of previous states. Need to come up with something better because this
488 // causes problems where the keyboard acts as if it were unresponsive. :-P
490 if ((e->key() == vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
491 || (e->key() == vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
492 || (e->key() == vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
493 || (e->key() == vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U]))
497 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
498 joypad_0_buttons[BUTTON_R] = 0;
499 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
500 joypad_0_buttons[BUTTON_L] = 0;
501 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
502 joypad_0_buttons[BUTTON_D] = 0;
503 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
504 joypad_0_buttons[BUTTON_U] = 0;
506 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
507 joypad_1_buttons[BUTTON_R] = 0;
508 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
509 joypad_1_buttons[BUTTON_L] = 0;
510 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
511 joypad_1_buttons[BUTTON_D] = 0;
512 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
513 joypad_1_buttons[BUTTON_U] = 0;
515 //hrm, this still has sticky state problems... Ugh!
516 // First, settle key states...
517 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L])
518 keyHeld[P1LEFT] = state;
519 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R])
520 keyHeld[P1RIGHT] = state;
521 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U])
522 keyHeld[P1UP] = state;
523 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D])
524 keyHeld[P1DOWN] = state;
525 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L])
526 keyHeld[P2LEFT] = state;
527 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R])
528 keyHeld[P2RIGHT] = state;
529 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U])
530 keyHeld[P2UP] = state;
531 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D])
532 keyHeld[P2DOWN] = state;
534 // Next, check for conflicts and bail out if there are any...
535 if ((keyHeld[P1LEFT] && keyHeld[P1RIGHT])
536 || (keyHeld[P1UP] && keyHeld[P1DOWN])
537 || (keyHeld[P2LEFT] && keyHeld[P2RIGHT])
538 || (keyHeld[P2UP] && keyHeld[P2DOWN]))
543 // No bad combos exist, let's stuff the emulator key buffers...!
544 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
546 if (e->key() == (int)vjs.p1KeyBindings[i])
547 // joypad_0_buttons[i] = (uint8)state;
548 joypad0Buttons[i] = (state ? 0x01 : 0x00);
550 // Pad #2 is screwing up pad #1. Prolly a problem in joystick.cpp...
551 // So let's try to fix it there. :-P [DONE]
552 if (e->key() == (int)vjs.p2KeyBindings[i])
553 // joypad_1_buttons[i] = (uint8)state;
554 joypad1Buttons[i] = (state ? 0x01 : 0x00);
559 void MainWin::HandleGamepads(void)
563 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
565 if (vjs.p1KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
566 joypad0Buttons[i] = (Gamepad::GetState(0, vjs.p1KeyBindings[i]) ? 0x01 : 0x00);
568 if (vjs.p2KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
569 joypad1Buttons[i] = (Gamepad::GetState(1, vjs.p2KeyBindings[i]) ? 0x01 : 0x00);
574 void MainWin::Open(void)
579 void MainWin::Configure(void)
581 // Call the configuration dialog and update settings
582 ConfigDialog dlg(this);
584 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
586 if (dlg.exec() == false)
589 QString before = vjs.ROMPath;
590 QString alpineBefore = vjs.alpineROMPath;
591 QString absBefore = vjs.absROMPath;
592 // bool audioBefore = vjs.audioEnabled;
593 bool audioBefore = vjs.DSPEnabled;
594 dlg.UpdateVJSettings();
595 QString after = vjs.ROMPath;
596 QString alpineAfter = vjs.alpineROMPath;
597 QString absAfter = vjs.absROMPath;
598 // bool audioAfter = vjs.audioEnabled;
599 bool audioAfter = vjs.DSPEnabled;
601 bool allowOld = allowUnknownSoftware;
603 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
605 // We rescan the "software" folder if the user either changed the path or
606 // checked/unchecked the "Allow unknown files" option in the config dialog.
607 if ((before != after) || (allowOld != allowUnknownSoftware))
608 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
610 // If the "Alpine" ROM is changed, then let's load it...
611 if (alpineBefore != alpineAfter)
613 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
615 // Oh crap, we couldn't get the file! Alert the media!
617 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
618 msg.setIcon(QMessageBox::Warning);
623 // If the "ABS" ROM is changed, then let's load it...
624 if (absBefore != absAfter)
626 if (!JaguarLoadFile(vjs.absROMPath))
628 // Oh crap, we couldn't get the file! Alert the media!
630 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
631 msg.setIcon(QMessageBox::Warning);
636 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
637 // since it's running in the host audio IRQ...
638 if (audioBefore != audioAfter)
644 // Just in case we crash before a clean exit...
650 // Here's the main emulator loop
652 void MainWin::Timer(void)
657 if (showUntunedTankCircuit)
659 // Some machines can't handle this, so we give them the option to disable it. :-)
660 if (!plzDontKillMyComputer)
662 // Random hash & trash
663 // We try to simulate an untuned tank circuit here... :-)
664 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
666 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
668 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
669 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
676 // Otherwise, run the Jaguar simulation
679 videoWidget->HandleMouseHiding();
682 videoWidget->updateGL();
686 // Approach: We use a ring buffer to store timestamps over a given amount
687 // of frames, then sum them to figure out the FPS.
688 uint32_t timestamp = SDL_GetTicks();
689 // This assumes the ring buffer size is a power of 2
690 ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
691 ringBuffer[ringBufferPointer] = timestamp - oldTimestamp;
692 uint32_t elapsedTime = 0;
694 for(uint32_t i=0; i<RING_BUFFER_SIZE; i++)
695 elapsedTime += ringBuffer[i];
697 // elapsedTime must be non-zero
698 if (elapsedTime == 0)
702 float framesPerSecond = ((float)RING_BUFFER_SIZE / (float)elapsedTime) * 1000.0;
703 statusBar()->showMessage(QString("%1 FPS").arg(framesPerSecond));
705 // This is in frames per 10 seconds, so we can have 1 decimal
706 uint32_t framesPerSecond = (uint32_t)(((float)RING_BUFFER_SIZE / (float)elapsedTime) * 10000.0);
707 uint32_t fpsIntegerPart = framesPerSecond / 10;
708 uint32_t fpsDecimalPart = framesPerSecond % 10;
709 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart).arg(fpsDecimalPart));
711 oldTimestamp = timestamp;
716 void MainWin::TogglePowerState(void)
718 powerButtonOn = !powerButtonOn;
721 // With the power off, we simulate white noise on the screen. :-)
724 // Restore the mouse pointer, if hidden:
725 videoWidget->CheckAndRestoreMouseCursor();
726 useCDAct->setDisabled(false);
727 palAct->setDisabled(false);
728 ntscAct->setDisabled(false);
729 pauseAct->setChecked(false);
730 pauseAct->setDisabled(true);
731 showUntunedTankCircuit = true;
732 DACPauseAudioThread();
733 // This is just in case the ROM we were playing was in a narrow or wide
734 // field mode, so the untuned tank sim doesn't look wrong. :-)
737 if (plzDontKillMyComputer)
739 // We have to do it line by line, because the texture pitch is not
740 // the same as the picture buffer's pitch.
741 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
743 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
749 useCDAct->setDisabled(true);
750 palAct->setDisabled(true);
751 ntscAct->setDisabled(true);
752 pauseAct->setChecked(false);
753 pauseAct->setDisabled(false);
754 showUntunedTankCircuit = false;
756 // Otherwise, we prepare for running regular software...
759 // Should check for cartridgeLoaded here as well...!
760 // We can clear it when toggling CDActive on, so that when we power cycle it
761 // does the expected thing. Otherwise, if we use the file picker to insert a
762 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
763 // works if the CD unit is active?
764 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
765 " - Now playing: Jaguar CD"));
768 WriteLog("GUI: Resetting Jaguar...\n");
770 DACPauseAudioThread(false);
775 void MainWin::ToggleRunState(void)
781 // Restore the mouse pointer, if hidden:
782 videoWidget->CheckAndRestoreMouseCursor();
783 frameAdvanceAct->setDisabled(false);
785 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
787 uint32_t pixel = videoWidget->buffer[i];
788 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
789 pixel = ((r + g + b) / 3) & 0x00FF;
790 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
793 videoWidget->updateGL();
796 frameAdvanceAct->setDisabled(true);
798 // Pause/unpause any running/non-running threads...
799 DACPauseAudioThread(!running);
803 void MainWin::SetZoom100(void)
810 void MainWin::SetZoom200(void)
817 void MainWin::SetZoom300(void)
824 void MainWin::SetNTSC(void)
826 powerAct->setIcon(powerRed);
827 timer->setInterval(16);
828 vjs.hardwareTypeNTSC = true;
834 void MainWin::SetPAL(void)
836 powerAct->setIcon(powerGreen);
837 timer->setInterval(20);
838 vjs.hardwareTypeNTSC = false;
844 void MainWin::ToggleBlur(void)
846 vjs.glFilter = !vjs.glFilter;
851 void MainWin::ShowAboutWin(void)
857 void MainWin::ShowHelpWin(void)
863 void MainWin::InsertCart(void)
865 // If the emulator is running, we pause it here and unpause it later
866 // if we dismiss the file selector without choosing anything
867 if (running && powerButtonOn)
870 pauseForFileSelector = true;
877 void MainWin::Unpause(void)
879 // Here we unpause the emulator if it was paused when we went into the file selector
880 if (pauseForFileSelector)
882 pauseForFileSelector = false;
884 // Some nutter might have unpaused while in the file selector, so check for that
891 void MainWin::LoadSoftware(QString file)
893 running = false; // Prevent bad things(TM) from happening...
894 pauseForFileSelector = false; // Reset the file selector pause flag
896 char * biosPointer = jaguarBootROM;
898 if (vjs.hardwareTypeAlpine)
899 biosPointer = jaguarDevBootROM2;
901 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
903 powerAct->setDisabled(false);
904 powerAct->setChecked(true);
905 powerButtonOn = false;
907 // We have to load our software *after* the Jaguar RESET
908 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
909 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
911 // This is icky because we've already done it
913 if (!vjs.useJaguarBIOS)
914 SET32(jaguarMainRAM, 4, jaguarRunAddress);
918 if (!vjs.hardwareTypeAlpine && !loadAndGo)
920 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
921 .arg(filePickWin->GetSelectedPrettyName());
922 setWindowTitle(newTitle);
927 void MainWin::ToggleCDUsage(void)
929 CDActive = !CDActive;
931 // Set up the Jaguar CD for execution, otherwise, clear memory
933 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
935 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
939 void MainWin::FrameAdvance(void)
941 //printf("Frame Advance...\n");
942 // Execute 1 frame, then exit (only useful in Pause mode)
944 videoWidget->updateGL();
945 // Need to execute 1 frames' worth of DSP thread as well :-/
946 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
950 void MainWin::SetFullScreen(bool state/*= true*/)
954 mainWinPosition = pos();
963 // This is needed because the fullscreen may happen on a different
964 // screen than screen 0:
965 int screenNum = QApplication::desktop()->screenNumber(videoWidget);
966 // QRect r = QApplication::desktop()->availableGeometry(screenNum);
967 QRect r = QApplication::desktop()->screenGeometry(screenNum);
968 double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
969 targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
970 double aspectRatio = targetWidth / targetHeight;
971 // NOTE: Really should check here to see which dimension constrains the
972 // other. Right now, we assume that height is the constraint.
973 int newWidth = (int)(aspectRatio * (double)r.height());
974 videoWidget->offset = (r.width() - newWidth) / 2;
975 videoWidget->fullscreen = true;
976 videoWidget->outputWidth = newWidth;
977 videoWidget->setFixedSize(r.width(), r.height());
982 // Reset the video widget to windowed mode
983 videoWidget->offset = 0;
984 videoWidget->fullscreen = false;
994 move(mainWinPosition);
999 void MainWin::ToggleFullScreen(void)
1001 fullScreen = !fullScreen;
1002 SetFullScreen(fullScreen);
1006 void MainWin::ShowMemoryBrowserWin(void)
1008 memBrowseWin->show();
1009 memBrowseWin->RefreshContents();
1013 void MainWin::ShowCPUBrowserWin(void)
1015 cpuBrowseWin->show();
1016 cpuBrowseWin->RefreshContents();
1020 void MainWin::ShowOPBrowserWin(void)
1022 opBrowseWin->show();
1023 opBrowseWin->RefreshContents();
1027 void MainWin::ShowM68KDasmBrowserWin(void)
1029 m68kDasmBrowseWin->show();
1030 m68kDasmBrowseWin->RefreshContents();
1034 void MainWin::ShowRISCDasmBrowserWin(void)
1036 riscDasmBrowseWin->show();
1037 riscDasmBrowseWin->RefreshContents();
1041 void MainWin::ResizeMainWindow(void)
1043 videoWidget->setFixedSize(zoomLevel * VIRTUAL_SCREEN_WIDTH,
1044 zoomLevel * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
1046 // Show the test pattern if user requested plzDontKillMyComputer mode
1047 if (!powerButtonOn && plzDontKillMyComputer)
1049 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
1051 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1057 for(int i=0; i<2; i++)
1061 QApplication::processEvents();
1066 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1067 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1068 void MainWin::ReadSettings(void)
1070 QSettings settings("Underground Software", "Virtual Jaguar");
1071 mainWinPosition = settings.value("pos", QPoint(200, 200)).toPoint();
1072 QSize size = settings.value("size", QSize(400, 400)).toSize();
1074 move(mainWinPosition);
1075 QPoint pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
1076 filePickWin->move(pos);
1078 zoomLevel = settings.value("zoom", 2).toInt();
1079 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
1081 vjs.useJoystick = settings.value("useJoystick", false).toBool();
1082 vjs.joyport = settings.value("joyport", 0).toInt();
1083 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
1084 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
1085 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
1086 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
1087 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
1088 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
1089 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
1090 vjs.fullscreen = settings.value("fullscreen", false).toBool();
1091 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
1092 vjs.glFilter = settings.value("glFilterType", 1).toInt();
1093 vjs.renderType = settings.value("renderType", 0).toInt();
1094 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
1095 vjs.biosType = settings.value("biosType", BT_M_SERIES).toInt();
1096 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
1097 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
1098 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
1099 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
1101 WriteLog("MainWin: Paths\n");
1102 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
1103 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
1104 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
1105 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
1106 WriteLog("Pipelined DSP = %s\n", (vjs.usePipelinedDSP ? "ON" : "off"));
1108 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1109 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
1110 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
1111 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
1112 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
1113 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
1114 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
1115 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
1116 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
1117 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
1118 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
1119 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
1120 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
1121 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
1122 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
1123 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
1124 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
1125 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
1126 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
1127 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
1128 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
1129 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
1131 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
1132 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
1133 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
1134 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
1135 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
1136 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
1137 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
1138 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
1139 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
1140 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
1141 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
1142 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
1143 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
1144 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
1145 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
1146 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
1147 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
1148 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
1149 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
1150 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
1151 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
1155 void MainWin::WriteSettings(void)
1157 QSettings settings("Underground Software", "Virtual Jaguar");
1158 settings.setValue("pos", pos());
1159 settings.setValue("size", size());
1160 settings.setValue("cartLoadPos", filePickWin->pos());
1162 settings.setValue("zoom", zoomLevel);
1163 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
1165 settings.setValue("useJoystick", vjs.useJoystick);
1166 settings.setValue("joyport", vjs.joyport);
1167 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
1168 settings.setValue("frameSkip", vjs.frameSkip);
1169 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
1170 settings.setValue("GPUEnabled", vjs.GPUEnabled);
1171 settings.setValue("DSPEnabled", vjs.DSPEnabled);
1172 settings.setValue("audioEnabled", vjs.audioEnabled);
1173 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
1174 settings.setValue("fullscreen", vjs.fullscreen);
1175 settings.setValue("useOpenGL", vjs.useOpenGL);
1176 settings.setValue("glFilterType", vjs.glFilter);
1177 settings.setValue("renderType", vjs.renderType);
1178 settings.setValue("writeROM", vjs.allowWritesToROM);
1179 settings.setValue("biosType", vjs.biosType);
1180 settings.setValue("JagBootROM", vjs.jagBootPath);
1181 settings.setValue("CDBootROM", vjs.CDBootPath);
1182 settings.setValue("EEPROMs", vjs.EEPROMPath);
1183 settings.setValue("ROMs", vjs.ROMPath);
1184 settings.setValue("DefaultROM", vjs.alpineROMPath);
1185 settings.setValue("DefaultABS", vjs.absROMPath);
1187 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
1188 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
1189 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
1190 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
1191 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
1192 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
1193 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
1194 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
1195 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
1196 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
1197 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
1198 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
1199 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
1200 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
1201 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
1202 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
1203 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
1204 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
1205 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
1206 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
1207 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
1209 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
1210 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
1211 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
1212 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
1213 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
1214 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
1215 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
1216 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
1217 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
1218 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
1219 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
1220 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
1221 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
1222 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
1223 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
1224 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
1225 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
1226 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
1227 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
1228 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
1229 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);
1233 void MainWin::WriteUISettings(void)
1235 QSettings settings("Underground Software", "Virtual Jaguar");
1236 settings.setValue("pos", pos());
1237 settings.setValue("size", size());
1238 settings.setValue("cartLoadPos", filePickWin->pos());
1240 settings.setValue("zoom", zoomLevel);