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++)
92 videoWidget = new GLWidget(this);
93 setCentralWidget(videoWidget);
94 setWindowIcon(QIcon(":/res/vj-icon.png"));
96 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION ));
98 if (vjs.hardwareTypeAlpine)
99 title += QString(tr(" - Alpine Mode"));
101 setWindowTitle(title);
103 aboutWin = new AboutWindow(this);
104 helpWin = new HelpWindow(this);
105 filePickWin = new FilePickerWindow(this);
106 memBrowseWin = new MemoryBrowserWindow(this);
107 cpuBrowseWin = new CPUBrowserWindow(this);
108 opBrowseWin = new OPBrowserWindow(this);
109 m68kDasmBrowseWin = new M68KDasmBrowserWindow(this);
110 riscDasmBrowseWin = new RISCDasmBrowserWindow(this);
112 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
113 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
115 setUnifiedTitleAndToolBarOnMac(true);
119 quitAppAct = new QAction(tr("E&xit"), this);
120 // quitAppAct->setShortcuts(QKeySequence::Quit);
121 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
122 quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
123 quitAppAct->setShortcutContext(Qt::ApplicationShortcut);
124 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
125 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
127 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
128 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
129 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
130 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
132 // powerAct = new QAction(QIcon(":/res/power.png"), tr("&Power"), this);
133 powerAct = new QAction(powerGreen, tr("&Power"), this);
134 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
135 powerAct->setCheckable(true);
136 powerAct->setChecked(false);
137 // powerAct->setDisabled(true);
138 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
141 pauseIcon.addFile(":/res/pause-off", QSize(), QIcon::Normal, QIcon::Off);
142 pauseIcon.addFile(":/res/pause-on", QSize(), QIcon::Normal, QIcon::On);
143 // pauseAct = new QAction(QIcon(":/res/pause.png"), tr("Pause"), this);
144 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
145 pauseAct->setStatusTip(tr("Toggles the running state"));
146 pauseAct->setCheckable(true);
147 pauseAct->setDisabled(true);
148 pauseAct->setShortcut(QKeySequence(tr("Esc")));
149 pauseAct->setShortcutContext(Qt::ApplicationShortcut);
150 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
152 zoomActs = new QActionGroup(this);
154 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
155 x1Act->setStatusTip(tr("Set window zoom to 100%"));
156 x1Act->setCheckable(true);
157 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
159 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
160 x2Act->setStatusTip(tr("Set window zoom to 200%"));
161 x2Act->setCheckable(true);
162 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
164 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
165 x3Act->setStatusTip(tr("Set window zoom to 300%"));
166 x3Act->setCheckable(true);
167 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
169 tvTypeActs = new QActionGroup(this);
171 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
172 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
173 ntscAct->setCheckable(true);
174 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
176 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
177 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
178 palAct->setCheckable(true);
179 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
181 blurAct = new QAction(QIcon(":/res/blur.png"), tr("Blur"), this);
182 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
183 blurAct->setCheckable(true);
184 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
186 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
187 aboutAct->setStatusTip(tr("Blatant self-promotion"));
188 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
190 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
191 helpAct->setStatusTip(tr("Help is available, if you should need it"));
192 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
194 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
195 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
196 filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
197 filePickAct->setShortcutContext(Qt::ApplicationShortcut);
198 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
200 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
201 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
202 configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
203 configAct->setShortcutContext(Qt::ApplicationShortcut);
204 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
206 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
207 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
208 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
209 useCDAct->setCheckable(true);
210 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
212 frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
213 frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
214 frameAdvanceAct->setShortcutContext(Qt::ApplicationShortcut);
215 frameAdvanceAct->setDisabled(true);
216 connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
218 fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
219 fullScreenAct->setShortcut(QKeySequence(tr("F9")));
220 fullScreenAct->setShortcutContext(Qt::ApplicationShortcut);
221 fullScreenAct->setCheckable(true);
222 connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
225 memBrowseAct = new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
226 memBrowseAct->setStatusTip(tr("Shows the Jaguar memory browser window"));
227 // memBrowseAct->setCheckable(true);
228 connect(memBrowseAct, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
230 cpuBrowseAct = new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
231 cpuBrowseAct->setStatusTip(tr("Shows the Jaguar CPU browser window"));
232 // memBrowseAct->setCheckable(true);
233 connect(cpuBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
235 opBrowseAct = new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
236 opBrowseAct->setStatusTip(tr("Shows the Jaguar OP browser window"));
237 // memBrowseAct->setCheckable(true);
238 connect(opBrowseAct, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
240 m68kDasmBrowseAct = new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
241 m68kDasmBrowseAct->setStatusTip(tr("Shows the 68K disassembly browser window"));
242 // memBrowseAct->setCheckable(true);
243 connect(m68kDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
245 riscDasmBrowseAct = new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
246 riscDasmBrowseAct->setStatusTip(tr("Shows the RISC disassembly browser window"));
247 // memBrowseAct->setCheckable(true);
248 connect(riscDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
250 // Misc. connections...
251 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
252 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
254 // Create menus & toolbars
256 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
257 fileMenu->addAction(powerAct);
258 fileMenu->addAction(pauseAct);
259 // fileMenu->addAction(frameAdvanceAct);
260 fileMenu->addAction(filePickAct);
261 fileMenu->addAction(useCDAct);
262 fileMenu->addAction(configAct);
263 fileMenu->addAction(quitAppAct);
265 if (vjs.hardwareTypeAlpine)
267 debugMenu = menuBar()->addMenu(tr("&Debug"));
268 debugMenu->addAction(memBrowseAct);
269 debugMenu->addAction(cpuBrowseAct);
270 debugMenu->addAction(opBrowseAct);
271 debugMenu->addAction(m68kDasmBrowseAct);
272 debugMenu->addAction(riscDasmBrowseAct);
275 helpMenu = menuBar()->addMenu(tr("&Help"));
276 helpMenu->addAction(helpAct);
277 helpMenu->addAction(aboutAct);
279 toolbar = addToolBar(tr("Stuff"));
280 toolbar->addAction(powerAct);
281 toolbar->addAction(pauseAct);
282 toolbar->addAction(frameAdvanceAct);
283 toolbar->addAction(filePickAct);
284 toolbar->addAction(useCDAct);
285 toolbar->addSeparator();
286 toolbar->addAction(x1Act);
287 toolbar->addAction(x2Act);
288 toolbar->addAction(x3Act);
289 toolbar->addSeparator();
290 toolbar->addAction(ntscAct);
291 toolbar->addAction(palAct);
292 toolbar->addSeparator();
293 toolbar->addAction(blurAct);
294 toolbar->addAction(fullScreenAct);
296 if (vjs.hardwareTypeAlpine)
298 debugbar = addToolBar(tr("&Debug"));
299 debugbar->addAction(memBrowseAct);
300 debugbar->addAction(cpuBrowseAct);
301 debugbar->addAction(opBrowseAct);
302 debugbar->addAction(m68kDasmBrowseAct);
303 debugbar->addAction(riscDasmBrowseAct);
306 // Add actions to the main window, as hiding widgets with them
308 addAction(fullScreenAct);
309 addAction(quitAppAct);
310 addAction(configAct);
312 addAction(filePickAct);
313 addAction(frameAdvanceAct);
316 statusBar()->showMessage(tr("Ready"));
320 // Do this in case original size isn't correct (mostly for the first-run case)
323 // Create our test pattern bitmap
324 QImage tempImg(":/res/test-pattern.jpg");
325 QImage tempImgScaled = tempImg.scaled(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT_PAL, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
327 for(uint32_t y=0; y<VIRTUAL_SCREEN_HEIGHT_PAL; y++)
329 const QRgb * scanline = (QRgb *)tempImgScaled.constScanLine(y);
331 for(uint32_t x=0; x<VIRTUAL_SCREEN_WIDTH; x++)
333 uint32_t pixel = (qRed(scanline[x]) << 24) | (qGreen(scanline[x]) << 16) | (qBlue(scanline[x]) << 8) | 0xFF;
334 testPattern[(y * VIRTUAL_SCREEN_WIDTH) + x] = pixel;
338 // Set up timer based loop for animation...
339 timer = new QTimer(this);
340 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
342 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
343 // This is because it's discarding the 0.6666... on the end of the fraction.
344 // Alas, 6 doesn't divide cleanly into 10. :-P
345 //Should we defer this until SyncUI? Probably.
346 //No, it doesn't work, because it uses setInterval() instead of start()...
347 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
349 // We set this initially, to make VJ behave somewhat as it would if no
350 // cart were inserted and the BIOS was set as active...
351 jaguarCartInserted = true;
352 WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
353 WriteLog("VJ: Initializing jaguar subsystem...\n");
355 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
356 memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
358 // Prevent the file scanner from running if filename passed
359 // in on the command line...
363 // Load up the default ROM if in Alpine mode:
364 if (vjs.hardwareTypeAlpine)
366 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
368 // If regular load failed, try just a straight file load
369 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
371 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
374 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
376 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
378 // Attempt to load/run the ABS file...
379 LoadSoftware(vjs.absROMPath);
380 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
381 // Prevent the scanner from running...
385 // Run the scanner if nothing passed in and *not* Alpine mode...
386 // NB: Really need to look into caching the info scanned in here...
387 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
391 void MainWin::LoadFile(QString file)
397 void MainWin::SyncUI(void)
399 // Set toolbar buttons/menus based on settings read in (sync the UI)...
400 // (Really, this is to sync command line options passed in)
401 blurAct->setChecked(vjs.glFilter);
402 x1Act->setChecked(zoomLevel == 1);
403 x2Act->setChecked(zoomLevel == 2);
404 x3Act->setChecked(zoomLevel == 3);
405 // running = powerAct->isChecked();
406 ntscAct->setChecked(vjs.hardwareTypeNTSC);
407 palAct->setChecked(!vjs.hardwareTypeNTSC);
408 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
410 fullScreenAct->setChecked(vjs.fullscreen);
411 fullScreen = vjs.fullscreen;
412 SetFullScreen(fullScreen);
414 // Reset the timer to be what was set in the command line (if any):
415 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
416 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
420 void MainWin::closeEvent(QCloseEvent * event)
423 // This should only be done by the config dialog
426 event->accept(); // ignore() if can't close for some reason
430 void MainWin::keyPressEvent(QKeyEvent * e)
433 extern bool startM68KTracing;
435 // We ignore the Alt key for now, since it causes problems with the GUI
436 if (e->key() == Qt::Key_Alt)
441 else if (e->key() == Qt::Key_F11)
443 startM68KTracing = true;
449 if (e->key() == Qt::Key_F9)
459 void MainWin::keyReleaseEvent(QKeyEvent * e)
461 // We ignore the Alt key for now, since it causes problems with the GUI
462 if (e->key() == Qt::Key_Alt)
468 HandleKeys(e, false);
472 void MainWin::HandleKeys(QKeyEvent * e, bool state)
474 enum { P1LEFT = 0, P1RIGHT, P1UP, P1DOWN, P2LEFT, P2RIGHT, P2UP, P2DOWN };
475 // We kill bad key combos here, before they can get to the emulator...
476 // This also kills the illegal instruction problem that cropped up in Rayman!
477 // May want to do this by killing the old one instead of ignoring the new one...
478 // Seems to work better that way...
480 // The problem with this approach is that it causes bad results because it doesn't do
481 // any checking of previous states. Need to come up with something better because this
482 // causes problems where the keyboard acts as if it were unresponsive. :-P
484 if ((e->key() == vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
485 || (e->key() == vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
486 || (e->key() == vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
487 || (e->key() == vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U]))
491 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L] && joypad_0_buttons[BUTTON_R])
492 joypad_0_buttons[BUTTON_R] = 0;
493 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R] && joypad_0_buttons[BUTTON_L])
494 joypad_0_buttons[BUTTON_L] = 0;
495 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U] && joypad_0_buttons[BUTTON_D])
496 joypad_0_buttons[BUTTON_D] = 0;
497 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D] && joypad_0_buttons[BUTTON_U])
498 joypad_0_buttons[BUTTON_U] = 0;
500 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L] && joypad_1_buttons[BUTTON_R])
501 joypad_1_buttons[BUTTON_R] = 0;
502 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R] && joypad_1_buttons[BUTTON_L])
503 joypad_1_buttons[BUTTON_L] = 0;
504 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U] && joypad_1_buttons[BUTTON_D])
505 joypad_1_buttons[BUTTON_D] = 0;
506 if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D] && joypad_1_buttons[BUTTON_U])
507 joypad_1_buttons[BUTTON_U] = 0;
509 //hrm, this still has sticky state problems... Ugh!
510 // First, settle key states...
511 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L])
512 keyHeld[P1LEFT] = state;
513 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R])
514 keyHeld[P1RIGHT] = state;
515 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U])
516 keyHeld[P1UP] = state;
517 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D])
518 keyHeld[P1DOWN] = state;
519 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L])
520 keyHeld[P2LEFT] = state;
521 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R])
522 keyHeld[P2RIGHT] = state;
523 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U])
524 keyHeld[P2UP] = state;
525 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D])
526 keyHeld[P2DOWN] = state;
528 // Next, check for conflicts and bail out if there are any...
529 if ((keyHeld[P1LEFT] && keyHeld[P1RIGHT])
530 || (keyHeld[P1UP] && keyHeld[P1DOWN])
531 || (keyHeld[P2LEFT] && keyHeld[P2RIGHT])
532 || (keyHeld[P2UP] && keyHeld[P2DOWN]))
537 // No bad combos exist, let's stuff the emulator key buffers...!
538 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
540 if (e->key() == (int)vjs.p1KeyBindings[i])
541 // joypad_0_buttons[i] = (uint8)state;
542 joypad_0_buttons[i] = (state ? 0x01 : 0x00);
544 // Pad #2 is screwing up pad #1. Prolly a problem in joystick.cpp...
545 // So let's try to fix it there. :-P [DONE]
546 if (e->key() == (int)vjs.p2KeyBindings[i])
547 // joypad_1_buttons[i] = (uint8)state;
548 joypad_1_buttons[i] = (state ? 0x01 : 0x00);
553 void MainWin::HandleGamepads(void)
557 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
559 if (vjs.p1KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
560 joypad_0_buttons[i] = (Gamepad::GetState(0, vjs.p1KeyBindings[i]) ? 0x01 : 0x00);
562 if (vjs.p2KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
563 joypad_1_buttons[i] = (Gamepad::GetState(1, vjs.p2KeyBindings[i]) ? 0x01 : 0x00);
568 void MainWin::Open(void)
573 void MainWin::Configure(void)
575 // Call the configuration dialog and update settings
576 ConfigDialog dlg(this);
578 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
580 if (dlg.exec() == false)
583 QString before = vjs.ROMPath;
584 QString alpineBefore = vjs.alpineROMPath;
585 QString absBefore = vjs.absROMPath;
586 // bool audioBefore = vjs.audioEnabled;
587 bool audioBefore = vjs.DSPEnabled;
588 dlg.UpdateVJSettings();
589 QString after = vjs.ROMPath;
590 QString alpineAfter = vjs.alpineROMPath;
591 QString absAfter = vjs.absROMPath;
592 // bool audioAfter = vjs.audioEnabled;
593 bool audioAfter = vjs.DSPEnabled;
595 bool allowOld = allowUnknownSoftware;
597 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
599 // We rescan the "software" folder if the user either changed the path or
600 // checked/unchecked the "Allow unknown files" option in the config dialog.
601 if ((before != after) || (allowOld != allowUnknownSoftware))
602 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
604 // If the "Alpine" ROM is changed, then let's load it...
605 if (alpineBefore != alpineAfter)
607 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
609 // Oh crap, we couldn't get the file! Alert the media!
611 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
612 msg.setIcon(QMessageBox::Warning);
617 // If the "ABS" ROM is changed, then let's load it...
618 if (absBefore != absAfter)
620 if (!JaguarLoadFile(vjs.absROMPath))
622 // Oh crap, we couldn't get the file! Alert the media!
624 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
625 msg.setIcon(QMessageBox::Warning);
630 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
631 // since it's running in the host audio IRQ...
632 if (audioBefore != audioAfter)
638 // Just in case we crash before a clean exit...
644 // Here's the main emulator loop
646 void MainWin::Timer(void)
651 if (showUntunedTankCircuit)
653 // Some machines can't handle this, so we give them the option to disable it. :-)
654 if (!plzDontKillMyComputer)
656 // Random hash & trash
657 // We try to simulate an untuned tank circuit here... :-)
658 for(uint32_t x=0; x<videoWidget->rasterWidth; x++)
660 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
662 videoWidget->buffer[(y * videoWidget->textureWidth) + x]
663 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
670 // Otherwise, run the Jaguar simulation
673 videoWidget->HandleMouseHiding();
676 videoWidget->updateGL();
680 void MainWin::TogglePowerState(void)
682 powerButtonOn = !powerButtonOn;
685 // With the power off, we simulate white noise on the screen. :-)
688 // Restore the mouse pointer, if hidden:
689 videoWidget->CheckAndRestoreMouseCursor();
690 useCDAct->setDisabled(false);
691 palAct->setDisabled(false);
692 ntscAct->setDisabled(false);
693 pauseAct->setChecked(false);
694 pauseAct->setDisabled(true);
695 showUntunedTankCircuit = true;
696 DACPauseAudioThread();
697 // This is just in case the ROM we were playing was in a narrow or wide
698 // field mode, so the untuned tank sim doesn't look wrong. :-)
701 if (plzDontKillMyComputer)
703 // We have to do it line by line, because the texture pitch is not
704 // the same as the picture buffer's pitch.
705 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
707 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
713 useCDAct->setDisabled(true);
714 palAct->setDisabled(true);
715 ntscAct->setDisabled(true);
716 pauseAct->setChecked(false);
717 pauseAct->setDisabled(false);
718 showUntunedTankCircuit = false;
720 // Otherwise, we prepare for running regular software...
723 // Should check for cartridgeLoaded here as well...!
724 // We can clear it when toggling CDActive on, so that when we power cycle it
725 // does the expected thing. Otherwise, if we use the file picker to insert a
726 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
727 // works if the CD unit is active?
728 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
729 " - Now playing: Jaguar CD"));
732 WriteLog("GUI: Resetting Jaguar...\n");
734 DACPauseAudioThread(false);
739 void MainWin::ToggleRunState(void)
745 // Restore the mouse pointer, if hidden:
746 videoWidget->CheckAndRestoreMouseCursor();
747 frameAdvanceAct->setDisabled(false);
749 for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++)
751 uint32_t pixel = videoWidget->buffer[i];
752 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
753 pixel = ((r + g + b) / 3) & 0x00FF;
754 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
757 videoWidget->updateGL();
760 frameAdvanceAct->setDisabled(true);
762 // Pause/unpause any running/non-running threads...
763 DACPauseAudioThread(!running);
767 void MainWin::SetZoom100(void)
774 void MainWin::SetZoom200(void)
781 void MainWin::SetZoom300(void)
788 void MainWin::SetNTSC(void)
790 powerAct->setIcon(powerRed);
791 timer->setInterval(16);
792 vjs.hardwareTypeNTSC = true;
798 void MainWin::SetPAL(void)
800 powerAct->setIcon(powerGreen);
801 timer->setInterval(20);
802 vjs.hardwareTypeNTSC = false;
808 void MainWin::ToggleBlur(void)
810 vjs.glFilter = !vjs.glFilter;
815 void MainWin::ShowAboutWin(void)
821 void MainWin::ShowHelpWin(void)
827 void MainWin::InsertCart(void)
829 // If the emulator is running, we pause it here and unpause it later
830 // if we dismiss the file selector without choosing anything
831 if (running && powerButtonOn)
834 pauseForFileSelector = true;
841 void MainWin::Unpause(void)
843 // Here we unpause the emulator if it was paused when we went into the file selector
844 if (pauseForFileSelector)
846 pauseForFileSelector = false;
848 // Some nutter might have unpaused while in the file selector, so check for that
855 void MainWin::LoadSoftware(QString file)
857 running = false; // Prevent bad things(TM) from happening...
858 pauseForFileSelector = false; // Reset the file selector pause flag
860 char * biosPointer = jaguarBootROM;
862 if (vjs.hardwareTypeAlpine)
863 biosPointer = jaguarDevBootROM2;
865 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
867 powerAct->setDisabled(false);
868 powerAct->setChecked(true);
869 powerButtonOn = false;
871 // We have to load our software *after* the Jaguar RESET
872 cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
873 SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
875 // This is icky because we've already done it
877 if (!vjs.useJaguarBIOS)
878 SET32(jaguarMainRAM, 4, jaguarRunAddress);
882 if (!vjs.hardwareTypeAlpine && !loadAndGo)
884 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
885 .arg(filePickWin->GetSelectedPrettyName());
886 setWindowTitle(newTitle);
891 void MainWin::ToggleCDUsage(void)
893 CDActive = !CDActive;
895 // Set up the Jaguar CD for execution, otherwise, clear memory
897 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
899 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
903 void MainWin::FrameAdvance(void)
905 //printf("Frame Advance...\n");
906 // Execute 1 frame, then exit (only useful in Pause mode)
908 videoWidget->updateGL();
909 // Need to execute 1 frames' worth of DSP thread as well :-/
910 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
914 void MainWin::SetFullScreen(bool state/*= true*/)
918 mainWinPosition = pos();
927 // This is needed because the fullscreen may happen on a different
928 // screen than screen 0:
929 int screenNum = QApplication::desktop()->screenNumber(videoWidget);
930 // QRect r = QApplication::desktop()->availableGeometry(screenNum);
931 QRect r = QApplication::desktop()->screenGeometry(screenNum);
932 double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
933 targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
934 double aspectRatio = targetWidth / targetHeight;
935 // NOTE: Really should check here to see which dimension constrains the
936 // other. Right now, we assume that height is the constraint.
937 int newWidth = (int)(aspectRatio * (double)r.height());
938 videoWidget->offset = (r.width() - newWidth) / 2;
939 videoWidget->fullscreen = true;
940 videoWidget->outputWidth = newWidth;
941 videoWidget->setFixedSize(r.width(), r.height());
946 // Reset the video widget to windowed mode
947 videoWidget->offset = 0;
948 videoWidget->fullscreen = false;
958 move(mainWinPosition);
963 void MainWin::ToggleFullScreen(void)
965 fullScreen = !fullScreen;
966 SetFullScreen(fullScreen);
970 void MainWin::ShowMemoryBrowserWin(void)
972 memBrowseWin->show();
973 memBrowseWin->RefreshContents();
977 void MainWin::ShowCPUBrowserWin(void)
979 cpuBrowseWin->show();
980 cpuBrowseWin->RefreshContents();
984 void MainWin::ShowOPBrowserWin(void)
987 opBrowseWin->RefreshContents();
991 void MainWin::ShowM68KDasmBrowserWin(void)
993 m68kDasmBrowseWin->show();
994 m68kDasmBrowseWin->RefreshContents();
998 void MainWin::ShowRISCDasmBrowserWin(void)
1000 riscDasmBrowseWin->show();
1001 riscDasmBrowseWin->RefreshContents();
1005 void MainWin::ResizeMainWindow(void)
1007 videoWidget->setFixedSize(zoomLevel * VIRTUAL_SCREEN_WIDTH,
1008 zoomLevel * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
1010 // Show the test pattern if user requested plzDontKillMyComputer mode
1011 if (!powerButtonOn && plzDontKillMyComputer)
1013 for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
1015 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1021 for(int i=0; i<2; i++)
1025 QApplication::processEvents();
1030 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1031 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1032 void MainWin::ReadSettings(void)
1034 QSettings settings("Underground Software", "Virtual Jaguar");
1035 mainWinPosition = settings.value("pos", QPoint(200, 200)).toPoint();
1036 QSize size = settings.value("size", QSize(400, 400)).toSize();
1038 move(mainWinPosition);
1039 QPoint pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
1040 filePickWin->move(pos);
1042 zoomLevel = settings.value("zoom", 2).toInt();
1043 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
1045 vjs.useJoystick = settings.value("useJoystick", false).toBool();
1046 vjs.joyport = settings.value("joyport", 0).toInt();
1047 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
1048 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
1049 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
1050 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
1051 vjs.DSPEnabled = settings.value("DSPEnabled", false).toBool();
1052 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
1053 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
1054 vjs.fullscreen = settings.value("fullscreen", false).toBool();
1055 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
1056 vjs.glFilter = settings.value("glFilterType", 1).toInt();
1057 vjs.renderType = settings.value("renderType", 0).toInt();
1058 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
1059 vjs.biosType = settings.value("biosType", BT_M_SERIES).toInt();
1060 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
1061 strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
1062 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
1063 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
1065 WriteLog("MainWin: Paths\n");
1066 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
1067 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
1068 WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
1069 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
1070 WriteLog("Pipelined DSP = %s\n", (vjs.usePipelinedDSP ? "ON" : "off"));
1072 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1073 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
1074 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
1075 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
1076 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
1077 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
1078 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
1079 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
1080 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
1081 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
1082 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
1083 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
1084 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
1085 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
1086 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
1087 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
1088 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
1089 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
1090 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
1091 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
1092 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
1093 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
1095 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
1096 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
1097 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
1098 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
1099 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
1100 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
1101 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
1102 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
1103 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
1104 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
1105 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
1106 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
1107 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
1108 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
1109 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
1110 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
1111 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
1112 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
1113 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
1114 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
1115 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
1119 void MainWin::WriteSettings(void)
1121 QSettings settings("Underground Software", "Virtual Jaguar");
1122 settings.setValue("pos", pos());
1123 settings.setValue("size", size());
1124 settings.setValue("cartLoadPos", filePickWin->pos());
1126 settings.setValue("zoom", zoomLevel);
1127 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
1129 settings.setValue("useJoystick", vjs.useJoystick);
1130 settings.setValue("joyport", vjs.joyport);
1131 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
1132 settings.setValue("frameSkip", vjs.frameSkip);
1133 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
1134 settings.setValue("GPUEnabled", vjs.GPUEnabled);
1135 settings.setValue("DSPEnabled", vjs.DSPEnabled);
1136 settings.setValue("audioEnabled", vjs.audioEnabled);
1137 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
1138 settings.setValue("fullscreen", vjs.fullscreen);
1139 settings.setValue("useOpenGL", vjs.useOpenGL);
1140 settings.setValue("glFilterType", vjs.glFilter);
1141 settings.setValue("renderType", vjs.renderType);
1142 settings.setValue("writeROM", vjs.allowWritesToROM);
1143 settings.setValue("biosType", vjs.biosType);
1144 settings.setValue("JagBootROM", vjs.jagBootPath);
1145 settings.setValue("CDBootROM", vjs.CDBootPath);
1146 settings.setValue("EEPROMs", vjs.EEPROMPath);
1147 settings.setValue("ROMs", vjs.ROMPath);
1148 settings.setValue("DefaultROM", vjs.alpineROMPath);
1149 settings.setValue("DefaultABS", vjs.absROMPath);
1151 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
1152 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
1153 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
1154 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
1155 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
1156 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
1157 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
1158 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
1159 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
1160 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
1161 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
1162 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
1163 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
1164 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
1165 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
1166 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
1167 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
1168 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
1169 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
1170 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
1171 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
1173 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
1174 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
1175 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
1176 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
1177 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
1178 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
1179 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
1180 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
1181 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
1182 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
1183 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
1184 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
1185 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
1186 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
1187 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
1188 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
1189 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
1190 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
1191 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
1192 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
1193 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);
1197 void MainWin::WriteUISettings(void)
1199 QSettings settings("Underground Software", "Virtual Jaguar");
1200 settings.setValue("pos", pos());
1201 settings.setValue("size", size());
1202 settings.setValue("cartLoadPos", filePickWin->pos());
1204 settings.setValue("zoom", zoomLevel);