2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James Hammons <jlhamm@acm.org>
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 12/23/2009 Created this file
12 // JLH 12/20/2010 Added settings, menus & toolbars
13 // JLH 07/05/2011 Added CD BIOS functionality to GUI
14 // JPM 06/06/2016 Visual Studio support
15 // JPM 06/19/2016 Soft debugger integration
16 // JPM 01/11/2017 Added stack browser
17 // JPM 01/02/2017 Added GPU disassembly
18 // JPM 02/02/2017 Added DSP disassembly
19 // JPM 07/12/2017 Added all Watch browser window
20 // JPM 08/01/2017 Added heap allocator browser window
21 // JPM 08/07/2017 Added memories window browser
22 // JPM 08/10/2017 Added a restart feature
23 // JPM 08/31/2017 Added breakpoints winndow
24 // JPM 09/01/2017 Save position & visibility windows status in the settings
25 // JPM 09/02/2017 Save size windows in the settings
26 // JPM 09/05/2017 Added Exception Vector Table window
27 // JPM 09/06/2017 Added the 'Rx' word to the emulator window name
28 // JPM 09/12/2017 Added the keybindings in the settings
33 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
34 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
35 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
36 // with 'R', etc) [DONE]
37 // - Controller configuration [DONE]
41 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
42 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
43 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
46 // SFDX CODE: S1E9T8H5M23YS
48 // Uncomment this for debugging...
50 //#define DEBUGFOO // Various tool debugging... but not used
51 //#define DEBUGTP // Toolpalette debugging... but not used
58 #include "configdialog.h"
59 #include "controllertab.h"
60 #include "keybindingstab.h"
61 #include "filepicker.h"
63 #include "generaltab.h"
69 #include "emustatus.h"
70 #include "debug/cpubrowser.h"
71 #include "debug/m68kdasmbrowser.h"
72 #include "debug/memorybrowser.h"
73 #include "debug/stackbrowser.h"
74 #include "debug/opbrowser.h"
75 #include "debug/riscdasmbrowser.h"
77 #include "debugger/allwatchbrowser.h"
78 #include "debugger/heapallocatorbrowser.h"
86 #include "jagcdbios.h"
87 #include "jagstub2bios.h"
89 #include "m68000/m68kinterface.h"
91 #include "debugger/VideoWin.h"
92 #include "debugger/DasmWin.h"
93 #include "debugger/m68KDasmWin.h"
94 #include "debugger/GPUDasmWin.h"
95 #include "debugger/DSPDasmWin.h"
96 #include "debugger/memory1browser.h"
97 #include "debugger/brkWin.h"
98 #include "debugger/exceptionvectortablebrowser.h"
100 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
101 //#ifdef __GCCWIN32__
102 // Apparently on win32, usleep() is not pulled in by the usual suspects.
106 #include "_MSC_VER/unistd.h"
110 // The way BSNES controls things is by setting a timer with a zero
111 // timeout, sleeping if not emulating anything. Seems there has to be a
114 // It has a novel approach to plugging-in/using different video/audio/input
115 // methods, can we do something similar or should we just use the built-in
118 // We're going to try to use the built-in OpenGL support and see how it goes.
119 // We'll make the VJ core modular so that it doesn't matter what GUI is in
120 // use, we can drop it in anywhere and use it as-is.
122 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
123 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
124 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
130 for(int i
=0; i
<8; i
++)
134 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
137 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
140 //if (vjs.softTypeDebugger)
142 // mainWindowCentrale = new QMdiArea;
143 // setCentralWidget(mainWindowCentrale);
147 videoWidget
= new GLWidget(this);
148 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
150 // set central output window
151 if (!vjs
.softTypeDebugger
)
153 setCentralWidget(videoWidget
);
157 mainWindowCentrale
= new QMdiArea(this);
158 setCentralWidget(mainWindowCentrale
);
161 setWindowIcon(QIcon(":/res/vj-icon.png"));
163 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
165 if (vjs
.hardwareTypeAlpine
)
166 title
+= QString(tr(" - Alpine Mode"));
168 if (vjs
.softTypeDebugger
)
169 title
+= QString(tr(" - Debugger Mode"));
171 setWindowTitle(title
);
173 aboutWin
= new AboutWindow(this);
174 helpWin
= new HelpWindow(this);
175 filePickWin
= new FilePickerWindow(this);
176 memBrowseWin
= new MemoryBrowserWindow(this);
177 stackBrowseWin
= new StackBrowserWindow(this);
178 emuStatusWin
= new EmuStatusWindow(this);
179 cpuBrowseWin
= new CPUBrowserWindow(this);
180 opBrowseWin
= new OPBrowserWindow(this);
181 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
182 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
183 if (vjs
.softTypeDebugger
)
185 VideoOutputWin
= new VideoOutputWindow(this);
186 //VideoOutputWin->setCentralWidget()
187 //DasmWin = new DasmWindow();
188 DasmWin
= new DasmWindow(this);
189 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
190 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
191 brkWin
= new BrkWindow(this);
192 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
194 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
196 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
198 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
200 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
202 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
205 dasmtabWidget
= new QTabWidget(this);
206 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
207 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
208 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
209 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
210 ////dasmtabWidget->addTab(m68kDasmBrowseWin, tr("M68000"));
211 setCentralWidget(dasmtabWidget
);
214 QDockWidget
*shapesDockWidget
= new QDockWidget(tr("Shapes"));
215 shapesDockWidget
->setObjectName("shapesDockWidget");
216 shapesDockWidget
->setWidget(m68kDasmWin
);
217 //shapesDockWidget->setWidget(treeWidget);
218 shapesDockWidget
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
219 addDockWidget(Qt::LeftDockWidgetArea
, shapesDockWidget
);
223 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
224 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
226 setUnifiedTitleAndToolBarOnMac(true);
230 quitAppAct
= new QAction(tr("E&xit"), this);
231 // quitAppAct->setShortcuts(QKeySequence::Quit);
232 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
233 //quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
234 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
235 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
236 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
237 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
239 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
240 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
241 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
242 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
244 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
245 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
246 powerAct
->setCheckable(true);
247 powerAct
->setChecked(false);
248 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
251 pauseIcon
.addFile(":/res/pause-off", QSize(), QIcon::Normal
, QIcon::Off
);
252 pauseIcon
.addFile(":/res/pause-on", QSize(), QIcon::Normal
, QIcon::On
);
253 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
254 pauseAct
->setStatusTip(tr("Toggles the running state"));
255 pauseAct
->setCheckable(true);
256 pauseAct
->setDisabled(true);
257 //pauseAct->setShortcut(QKeySequence(tr("Esc")));
258 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
259 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
260 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
262 zoomActs
= new QActionGroup(this);
264 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
265 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
266 x1Act
->setCheckable(true);
267 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
269 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
270 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
271 x2Act
->setCheckable(true);
272 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
274 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
275 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
276 x3Act
->setCheckable(true);
277 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
279 tvTypeActs
= new QActionGroup(this);
281 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
282 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
283 ntscAct
->setCheckable(true);
284 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
286 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
287 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
288 palAct
->setCheckable(true);
289 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
291 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
292 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
294 blurAct
= new QAction(blur
, tr("Blur"), this);
295 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
296 blurAct
->setCheckable(true);
297 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
299 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
300 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
301 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
303 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
304 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
305 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
307 if (!vjs
.softTypeDebugger
)
309 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
310 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
314 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
315 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
317 //filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
318 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
319 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
320 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
322 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
323 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
324 //configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
325 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
326 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
327 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
329 emustatusAct
= new QAction(QIcon(""), tr("&Status"), this);
330 emustatusAct
->setStatusTip(tr("Emulator status"));
331 //emustatusAct->setShortcut(QKeySequence(tr("Ctrl+s")));
332 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
333 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
334 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
336 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
337 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
338 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
339 useCDAct
->setCheckable(true);
340 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
342 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
343 //frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
344 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
345 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
346 frameAdvanceAct
->setDisabled(true);
347 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
349 if (vjs
.softTypeDebugger
)
351 restartAct
= new QAction(QIcon(":/res/Restart.png"), tr("&Restart"), this);
352 //restartAct->setShortcut(QKeySequence(tr("Ctrl+Shift+F5")));
353 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
354 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
355 restartAct
->setCheckable(false);
356 restartAct
->setDisabled(true);
357 connect(restartAct
, SIGNAL(triggered()), this, SLOT(Restart()));
359 traceStepOverAct
= new QAction(QIcon(":/res/StepOver.png"), tr("&Step Over"), this);
360 //traceStepOverAct->setShortcut(QKeySequence(tr("F10")));
361 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
362 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
363 traceStepOverAct
->setCheckable(false);
364 traceStepOverAct
->setDisabled(true);
365 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(TraceStepOver()));
367 traceStepIntoAct
= new QAction(QIcon(":/res/StepInto.png"), tr("&Step Into"), this);
368 //traceStepIntoAct->setShortcut(QKeySequence(tr("F11")));
369 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
370 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
371 traceStepIntoAct
->setCheckable(false);
372 traceStepIntoAct
->setDisabled(true);
373 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(TraceStepInto()));
375 newBreakpointFunctionAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
376 newBreakpointFunctionAct
->setShortcut(QKeySequence(tr("Ctrl+B")));
377 connect(newBreakpointFunctionAct
, SIGNAL(triggered()), this, SLOT(NewBreakpointFunction()));
380 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
381 //fullScreenAct->setShortcut(QKeySequence(tr("F9")));
382 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
383 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
384 fullScreenAct
->setCheckable(true);
385 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
388 if (vjs
.softTypeDebugger
)
390 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
391 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
392 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
394 allWatchBrowseAct
= new QAction(QIcon(":/res/Watch.png"), tr("All Watch"), this);
395 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
396 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
398 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
399 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
400 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
402 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
403 QSignalMapper
*signalMapper
= new QSignalMapper(this);
405 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
407 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
409 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
412 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
413 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/tool-memory.png"), tr(MB
), this);
414 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
416 //connect(mem1BrowseAct[0], SIGNAL(triggered()), this, SLOT(ShowMemory1BrowserWin(size_t(0))));
417 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
418 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
419 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
423 // Debugger Browser Actions
424 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
425 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
426 // memBrowseAct->setCheckable(true);
427 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
429 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
430 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
431 // memBrowseAct->setCheckable(true);
432 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
434 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
435 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
436 // memBrowseAct->setCheckable(true);
437 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
439 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
440 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
441 // memBrowseAct->setCheckable(true);
442 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
444 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
445 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
446 // memBrowseAct->setCheckable(true);
447 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
449 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
450 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
451 // memBrowseAct->setCheckable(true);
452 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
454 if (vjs
.softTypeDebugger
)
456 VideoOutputAct
= new QAction(tr("Output Video"), this);
457 VideoOutputAct
->setStatusTip(tr("Shows the output video window"));
458 connect(VideoOutputAct
, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
460 DasmAct
= new QAction(tr("Disassembly"), this);
461 DasmAct
->setStatusTip(tr("Shows the disassembly window"));
462 connect(DasmAct
, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
465 // Misc. connections...
466 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
467 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
471 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
472 fileMenu
->addAction(powerAct
);
473 if (!vjs
.softTypeDebugger
)
475 fileMenu
->addAction(pauseAct
);
476 // fileMenu->addAction(frameAdvanceAct);
478 fileMenu
->addAction(filePickAct
);
479 fileMenu
->addAction(useCDAct
);
480 fileMenu
->addAction(configAct
);
481 fileMenu
->addAction(emustatusAct
);
482 fileMenu
->addSeparator();
483 fileMenu
->addAction(quitAppAct
);
485 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
487 debugMenu
= menuBar()->addMenu(tr("&Debug"));
488 if (vjs
.softTypeDebugger
)
490 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
491 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
492 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
493 debugWindowsMenu
->addSeparator();
495 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
496 debugWindowOutputMenu
->addAction(VideoOutputAct
);
497 debugWindowsMenu
->addSeparator();
499 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
500 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
501 debugWindowsMenu
->addSeparator();
502 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
503 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
504 debugWindowsMemoryMenu
->addSeparator();
505 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
507 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
509 debugWindowsMenu
->addSeparator();
510 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
511 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
512 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
513 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
514 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
515 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
516 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
517 debugMenu
->addSeparator();
518 debugMenu
->addAction(pauseAct
);
519 debugMenu
->addAction(frameAdvanceAct
);
520 debugMenu
->addAction(restartAct
);
521 debugMenu
->addSeparator();
522 debugMenu
->addAction(traceStepIntoAct
);
523 debugMenu
->addAction(traceStepOverAct
);
525 debugMenu
->addSeparator();
526 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
527 debugNewBreakpointMenu
->addAction(newBreakpointFunctionAct
);
529 //debugMenu->addSeparator();
530 //debugMenu->addAction(DasmAct);
534 debugMenu
->addAction(memBrowseAct
);
535 debugMenu
->addAction(stackBrowseAct
);
536 debugMenu
->addAction(cpuBrowseAct
);
537 debugMenu
->addAction(opBrowseAct
);
538 debugMenu
->addAction(m68kDasmBrowseAct
);
539 debugMenu
->addAction(riscDasmBrowseAct
);
543 helpMenu
= menuBar()->addMenu(tr("&Help"));
544 helpMenu
->addAction(helpAct
);
545 helpMenu
->addAction(aboutAct
);
549 toolbar
= addToolBar(tr("Stuff"));
550 toolbar
->addAction(powerAct
);
551 if (!vjs
.softTypeDebugger
)
553 toolbar
->addAction(pauseAct
);
554 toolbar
->addAction(frameAdvanceAct
);
556 toolbar
->addAction(filePickAct
);
557 toolbar
->addAction(useCDAct
);
558 toolbar
->addSeparator();
559 if (!vjs
.softTypeDebugger
)
561 toolbar
->addAction(x1Act
);
562 toolbar
->addAction(x2Act
);
563 toolbar
->addAction(x3Act
);
564 toolbar
->addSeparator();
565 toolbar
->addAction(ntscAct
);
566 toolbar
->addAction(palAct
);
567 toolbar
->addSeparator();
568 toolbar
->addAction(blurAct
);
569 toolbar
->addAction(fullScreenAct
);
573 debuggerbar
= addToolBar(tr("&Debugger"));
574 debuggerbar
->addAction(pauseAct
);
575 debuggerbar
->addAction(frameAdvanceAct
);
576 debuggerbar
->addAction(restartAct
);
577 debuggerbar
->addSeparator();
578 debuggerbar
->addAction(traceStepIntoAct
);
579 debuggerbar
->addAction(traceStepOverAct
);
582 if (vjs
.hardwareTypeAlpine
)
584 debugbar
= addToolBar(tr("&Debug"));
585 debugbar
->addAction(memBrowseAct
);
586 debugbar
->addAction(stackBrowseAct
);
587 debugbar
->addAction(cpuBrowseAct
);
588 debugbar
->addAction(opBrowseAct
);
589 debugbar
->addAction(m68kDasmBrowseAct
);
590 debugbar
->addAction(riscDasmBrowseAct
);
593 // Add actions to the main window, as hiding widgets with them
595 addAction(fullScreenAct
);
596 addAction(quitAppAct
);
597 addAction(configAct
);
598 addAction(emustatusAct
);
600 addAction(filePickAct
);
601 addAction(frameAdvanceAct
);
604 statusBar()->showMessage(tr("Ready"));
606 // Do this in case original size isn't correct (mostly for the first-run
610 // Create our test pattern bitmaps
611 QImage
tempImg(":/res/test-pattern.jpg");
612 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
614 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
616 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
618 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
620 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
621 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
625 QImage
tempImg2(":/res/test-pattern-pal");
626 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
628 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
630 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
632 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
634 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
635 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
639 // Set up timer based loop for animation...
640 timer
= new QTimer(this);
641 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
643 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
644 // This is because it's discarding the 0.6666... on the end of the fraction.
645 // Alas, 6 doesn't divide cleanly into 10. :-P
646 //Should we defer this until SyncUI? Probably.
647 //No, it doesn't work, because it uses setInterval() instead of start()...
648 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
650 // We set this initially, to make VJ behave somewhat as it would if no
651 // cart were inserted and the BIOS was set as active...
652 jaguarCartInserted
= true;
653 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
654 WriteLog("VJ: Initializing jaguar subsystem...\n");
656 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
657 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
659 // Prevent the file scanner from running if filename passed
660 // in on the command line...
664 // Load up the default ROM if in Alpine mode:
665 if (vjs
.hardwareTypeAlpine
)
667 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
669 // If regular load failed, try just a straight file load
670 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
672 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
675 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
677 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
679 // Attempt to load/run the ABS file...
680 LoadSoftware(vjs
.absROMPath
);
681 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
682 // Prevent the scanner from running...
686 // Load up the default ROM if in Debugger mode:
687 if (vjs
.softTypeDebugger
)
689 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
691 // If regular load failed, try just a straight file load
692 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
694 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
697 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
699 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
701 // Attempt to load/run the ABS file...
702 LoadSoftware(vjs
.absROMPath
);
703 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
704 // Prevent the scanner from running...
708 // Run the scanner if nothing passed in and *not* Alpine mode...
709 // NB: Really need to look into caching the info scanned in here...
710 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
711 scannedSoftwareFolder
= true;
715 void MainWin::LoadFile(QString file
)
721 void MainWin::SyncUI(void)
723 // Set toolbar buttons/menus based on settings read in (sync the UI)...
724 // (Really, this is to sync command line options passed in)
725 blurAct
->setChecked(vjs
.glFilter
);
726 x1Act
->setChecked(zoomLevel
== 1);
727 x2Act
->setChecked(zoomLevel
== 2);
728 x3Act
->setChecked(zoomLevel
== 3);
729 // running = powerAct->isChecked();
730 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
731 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
732 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
734 fullScreenAct
->setChecked(vjs
.fullscreen
);
735 fullScreen
= vjs
.fullscreen
;
736 SetFullScreen(fullScreen
);
738 // Reset the timer to be what was set in the command line (if any):
739 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
740 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
744 void MainWin::closeEvent(QCloseEvent
* event
)
747 // This should only be done by the config dialog
750 event
->accept(); // ignore() if can't close for some reason
754 void MainWin::keyPressEvent(QKeyEvent
* e
)
756 #ifndef VJ_REMOVE_DEV_CODE
758 //extern bool startM68KTracing; // moved to jaguar.h
760 extern int blit_start_log
;
762 extern bool startConciseBlitLogging
;
765 // We ignore the Alt key for now, since it causes problems with the GUI
766 if (e
->key() == Qt::Key_Alt
)
771 // Bar this shite from release versions kthxbai
772 #ifndef VJ_REMOVE_DEV_CODE
773 else if (e
->key() == Qt::Key_F11
)
775 startM68KTracing
= true;
779 else if (e
->key() == Qt::Key_F12
)
781 blit_start_log
= true;
785 else if (e
->key() == Qt::Key_F10
)
787 startConciseBlitLogging
= true;
792 else if (e
->key() == Qt::Key_F8
)
794 // ggn: For extra NYAN pleasure...
795 // ggn: There you go James :P
796 // Shamus: Thanks for the patch! :-D
797 WriteLog(" o + + +\n");
798 WriteLog("+ o o + o\n");
799 WriteLog("-_-_-_-_-_-_-_,------, o \n");
800 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
801 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
802 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
803 WriteLog("+ o o + o\n");
810 This is done now by a QAction...
811 if (e->key() == Qt::Key_F9)
821 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
823 // We ignore the Alt key for now, since it causes problems with the GUI
824 if (e
->key() == Qt::Key_Alt
)
830 HandleKeys(e
, false);
834 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
836 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
837 // We kill bad key combos here, before they can get to the emulator...
838 // This also kills the illegal instruction problem that cropped up in
841 // First, settle key states...
842 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
843 keyHeld
[P1LEFT
] = state
;
844 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
845 keyHeld
[P1RIGHT
] = state
;
846 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
847 keyHeld
[P1UP
] = state
;
848 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
849 keyHeld
[P1DOWN
] = state
;
850 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
851 keyHeld
[P2LEFT
] = state
;
852 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
853 keyHeld
[P2RIGHT
] = state
;
854 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
855 keyHeld
[P2UP
] = state
;
856 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
857 keyHeld
[P2DOWN
] = state
;
859 // Next, check for conflicts and kill 'em if there are any...
860 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
861 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
863 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
864 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
866 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
867 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
869 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
870 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
872 // No bad combos exist now, let's stuff the emulator key buffers...!
873 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
875 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
876 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
878 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
879 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
885 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
887 void MainWin::HandleGamepads(void)
891 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
893 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
894 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
896 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
897 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
902 void MainWin::Open(void)
907 void MainWin::Configure(void)
909 // Call the configuration dialog and update settings
910 ConfigDialog
dlg(this);
912 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
913 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
914 dlg
.controllerTab1
->SetupLastUsedProfile();
915 // maybe instead of this, we tell the controller tab to work on a copy that gets
916 // written if the user hits 'OK'.
917 SaveProfiles(); // Just in case user cancels
919 if (dlg
.exec() == false)
925 QString before
= vjs
.ROMPath
;
926 QString alpineBefore
= vjs
.alpineROMPath
;
927 QString absBefore
= vjs
.absROMPath
;
928 // bool audioBefore = vjs.audioEnabled;
929 bool audioBefore
= vjs
.DSPEnabled
;
930 dlg
.UpdateVJSettings();
931 QString after
= vjs
.ROMPath
;
932 QString alpineAfter
= vjs
.alpineROMPath
;
933 QString absAfter
= vjs
.absROMPath
;
934 // bool audioAfter = vjs.audioEnabled;
935 bool audioAfter
= vjs
.DSPEnabled
;
937 bool allowOld
= allowUnknownSoftware
;
939 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
940 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
941 AutoConnectProfiles();
943 // We rescan the "software" folder if the user either changed the path or
944 // checked/unchecked the "Allow unknown files" option in the config dialog.
945 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
946 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
948 // If the "Alpine" ROM is changed, then let's load it...
949 if (alpineBefore
!= alpineAfter
)
951 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
953 // Oh crap, we couldn't get the file! Alert the media!
955 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
956 msg
.setIcon(QMessageBox::Warning
);
961 // If the "ABS" ROM is changed, then let's load it...
962 if (absBefore
!= absAfter
)
964 if (!JaguarLoadFile(vjs
.absROMPath
))
966 // Oh crap, we couldn't get the file! Alert the media!
968 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
969 msg
.setIcon(QMessageBox::Warning
);
974 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
975 // since it's running in the host audio IRQ...
976 if (audioBefore
!= audioAfter
)
982 // Just in case we crash before a clean exit...
985 RefreshDebuggerWindows();
990 // Here's the main emulator loop
992 void MainWin::Timer(void)
995 static uint32_t ntscTickCount
;
996 if (vjs
.hardwareTypeNTSC
)
1000 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1007 if (showUntunedTankCircuit
)
1009 // Some machines can't handle this, so we give them the option to disable it. :-)
1010 if (!plzDontKillMyComputer
)
1012 // if (!vjs.softTypeDebugger)
1014 // Random hash & trash
1015 // We try to simulate an untuned tank circuit here... :-)
1016 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1018 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1020 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
]
1021 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1029 // Otherwise, run the Jaguar simulation
1032 if (!vjs
.softTypeDebugger
)
1033 videoWidget
->HandleMouseHiding();
1035 static uint32_t refresh
= 0;
1036 // Do autorefresh on debug windows
1037 // Have to be careful, too much causes the emulator to slow way down!
1038 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1040 if (refresh
== vjs
.refresh
)
1042 RefreshAlpineWindows();
1043 //memBrowseWin->RefreshContents();
1044 //cpuBrowseWin->RefreshContents();
1052 //if (!vjs.softTypeDebugger)
1053 videoWidget
->updateGL();
1056 // Approach: We use a ring buffer to store times (in ms) over a given
1057 // amount of frames, then sum them to figure out the FPS.
1058 uint32_t timestamp
= SDL_GetTicks();
1059 // This assumes the ring buffer size is a power of 2
1060 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1061 // Doing it this way is better. Ring buffer size can be arbitrary then.
1062 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1063 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1064 uint32_t elapsedTime
= 0;
1066 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1067 elapsedTime
+= ringBuffer
[i
];
1069 // elapsedTime must be non-zero
1070 if (elapsedTime
== 0)
1073 // This is in frames per 10 seconds, so we can have 1 decimal
1074 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1075 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1076 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1077 // If this is updated too frequently to be useful, we can throttle it down
1078 // so that it only updates every 10th frame or so
1079 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1080 oldTimestamp
= timestamp
;
1082 if (M68KDebugHaltStatus())
1087 void MainWin::TogglePowerState(void)
1089 powerButtonOn
= !powerButtonOn
;
1092 // With the power off, we simulate white noise on the screen. :-)
1095 // Restore the mouse pointer, if hidden:
1096 if (!vjs
.softTypeDebugger
)
1097 videoWidget
->CheckAndRestoreMouseCursor();
1098 useCDAct
->setDisabled(false);
1099 palAct
->setDisabled(false);
1100 ntscAct
->setDisabled(false);
1101 pauseAct
->setChecked(false);
1102 pauseAct
->setDisabled(true);
1103 showUntunedTankCircuit
= true;
1104 DACPauseAudioThread();
1105 // This is just in case the ROM we were playing was in a narrow or wide
1106 // field mode, so the untuned tank sim doesn't look wrong. :-)
1109 if (plzDontKillMyComputer
)
1111 //if (!vjs.softTypeDebugger)
1113 // We have to do it line by line, because the texture pitch is not
1114 // the same as the picture buffer's pitch.
1115 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1117 if (vjs
.hardwareTypeNTSC
)
1118 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1120 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1127 useCDAct
->setDisabled(true);
1128 palAct
->setDisabled(true);
1129 ntscAct
->setDisabled(true);
1130 pauseAct
->setChecked(false);
1131 pauseAct
->setDisabled(false);
1132 showUntunedTankCircuit
= false;
1134 // Otherwise, we prepare for running regular software...
1137 // Should check for cartridgeLoaded here as well...!
1138 // We can clear it when toggling CDActive on, so that when we power cycle it
1139 // does the expected thing. Otherwise, if we use the file picker to insert a
1140 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1141 // works if the CD unit is active?
1142 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
1143 " Rx - Now playing: Jaguar CD"));
1146 WriteLog("GUI: Resetting Jaguar...\n");
1148 DACPauseAudioThread(false);
1153 void MainWin::ToggleRunState(void)
1155 startM68KTracing
= running
;
1160 frameAdvanceAct
->setDisabled(false);
1161 pauseAct
->setChecked(true);
1162 pauseAct
->setDisabled(false);
1163 if (vjs
.softTypeDebugger
)
1165 traceStepIntoAct
->setDisabled(false);
1166 traceStepOverAct
->setDisabled(false);
1167 restartAct
->setDisabled(false);
1168 m68kDasmWin
->Use68KPCAddress();
1169 GPUDasmWin
->UseGPUPCAddress();
1170 DSPDasmWin
->UseDSPPCAddress();
1173 //if (!vjs.softTypeDebugger)
1175 // Restore the mouse pointer, if hidden:
1176 videoWidget
->CheckAndRestoreMouseCursor();
1177 // frameAdvanceAct->setDisabled(false);
1179 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1181 uint32_t pixel
= videoWidget
->buffer
[i
];
1182 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1183 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1184 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1187 videoWidget
->updateGL();
1189 cpuBrowseWin
->HoldBPM();
1190 cpuBrowseWin
->HandleBPMContinue();
1191 RefreshDebuggerWindows();
1196 frameAdvanceAct
->setDisabled(true);
1197 pauseAct
->setChecked(false);
1198 pauseAct
->setDisabled(false);
1199 if (vjs
.softTypeDebugger
)
1201 traceStepIntoAct
->setDisabled(true);
1202 traceStepOverAct
->setDisabled(true);
1203 restartAct
->setDisabled(true);
1206 cpuBrowseWin
->UnholdBPM();
1209 // Pause/unpause any running/non-running threads...
1210 DACPauseAudioThread(!running
);
1214 void MainWin::SetZoom100(void)
1221 void MainWin::SetZoom200(void)
1228 void MainWin::SetZoom300(void)
1235 void MainWin::SetNTSC(void)
1237 powerAct
->setIcon(powerRed
);
1238 timer
->setInterval(16);
1239 vjs
.hardwareTypeNTSC
= true;
1245 void MainWin::SetPAL(void)
1247 powerAct
->setIcon(powerGreen
);
1248 timer
->setInterval(20);
1249 vjs
.hardwareTypeNTSC
= false;
1255 void MainWin::ToggleBlur(void)
1257 vjs
.glFilter
= !vjs
.glFilter
;
1262 void MainWin::ShowAboutWin(void)
1268 void MainWin::ShowHelpWin(void)
1274 void MainWin::InsertCart(void)
1276 // Check to see if we did autorun, 'cause we didn't load anything in that
1278 if (!scannedSoftwareFolder
)
1280 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1281 scannedSoftwareFolder
= true;
1284 // If the emulator is running, we pause it here and unpause it later
1285 // if we dismiss the file selector without choosing anything
1286 if (running
&& powerButtonOn
)
1289 pauseForFileSelector
= true;
1292 filePickWin
->show();
1296 void MainWin::Unpause(void)
1298 // Here we unpause the emulator if it was paused when we went into the file selector
1299 if (pauseForFileSelector
)
1301 pauseForFileSelector
= false;
1303 // Some nutter might have unpaused while in the file selector, so check for that
1310 void MainWin::LoadSoftware(QString file
)
1312 running
= false; // Prevent bad things(TM) from happening...
1313 pauseForFileSelector
= false; // Reset the file selector pause flag
1315 uint8_t * biosPointer
= jaguarBootROM
;
1317 if (vjs
.hardwareTypeAlpine
)
1318 biosPointer
= jaguarDevBootROM2
;
1320 if (vjs
.softTypeDebugger
)
1321 biosPointer
= jaguarDevBootROM2
;
1323 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1325 powerAct
->setDisabled(false);
1326 powerAct
->setChecked(true);
1327 powerButtonOn
= false;
1330 // We have to load our software *after* the Jaguar RESET
1331 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1332 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set top of stack...
1334 // This is icky because we've already done it
1335 // it gets worse :-P
1336 if (!vjs
.useJaguarBIOS
)
1337 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1341 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1342 if (vjs
.softTypeDebugger
)
1344 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1345 //pauseAct->setDisabled(false);
1346 //pauseAct->setChecked(true);
1352 if (vjs
.hardwareTypeAlpine
&& !jaguarRunAddress
)
1358 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1360 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1")
1361 .arg(filePickWin
->GetSelectedPrettyName());
1362 setWindowTitle(newTitle
);
1367 void MainWin::ToggleCDUsage(void)
1369 CDActive
= !CDActive
;
1371 // Set up the Jaguar CD for execution, otherwise, clear memory
1373 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1375 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1380 void MainWin::NewBreakpointFunction(void)
1383 brkWin
->RefreshContents();
1388 void MainWin::TraceStepInto(void)
1391 videoWidget
->updateGL();
1392 RefreshDebuggerWindows();
1394 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1396 #warning "!!! Need to verify the Step Into function !!!"
1402 void MainWin::Restart(void)
1404 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1405 //m68kDasmWin->SetAddress(jaguarRunAddress);
1406 RefreshDebuggerWindows();
1408 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1410 #warning "!!! Need to verify the Restart function !!!"
1416 void MainWin::TraceStepOver(void)
1419 videoWidget
->updateGL();
1420 RefreshDebuggerWindows();
1422 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1424 #warning "!!! Need to verify the Step Over function !!!"
1429 // Advance / Execute for one frame
1430 void MainWin::FrameAdvance(void)
1432 //printf("Frame Advance...\n");
1434 // Execute 1 frame, then exit (only useful in Pause mode)
1436 //if (!vjs.softTypeDebugger)
1437 videoWidget
->updateGL();
1439 // Need to execute 1 frames' worth of DSP thread as well :-/
1441 //m68kDasmWin->Use68KPCAddress();
1444 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1446 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1451 void MainWin::SetFullScreen(bool state
/*= true*/)
1453 if (!vjs
.softTypeDebugger
)
1457 mainWinPosition
= pos();
1459 statusBar()->hide();
1465 // This is needed because the fullscreen may happen on a different
1466 // screen than screen 0:
1467 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1468 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1469 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1470 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1471 double aspectRatio
= targetWidth
/ targetHeight
;
1472 // NOTE: Really should check here to see which dimension constrains the
1473 // other. Right now, we assume that height is the constraint.
1474 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1475 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1476 videoWidget
->fullscreen
= true;
1477 videoWidget
->outputWidth
= newWidth
;
1478 videoWidget
->setFixedSize(r
.width(), r
.height());
1483 // Seems Qt is fussy about this: showNormal() has to go first, or it
1484 // will keep the window stuck in a psuedo-fullscreen mode with no way
1485 // to get out of it (except closing the app).
1488 // Reset the video widget to windowed mode
1489 videoWidget
->offset
= 0;
1490 videoWidget
->fullscreen
= false;
1492 statusBar()->show();
1499 move(mainWinPosition
);
1505 void MainWin::ToggleFullScreen(void)
1507 fullScreen
= !fullScreen
;
1508 SetFullScreen(fullScreen
);
1512 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1514 exceptionvectortableBrowseWin
->show();
1515 exceptionvectortableBrowseWin
->RefreshContents();
1519 void MainWin::ShowAllWatchBrowserWin(void)
1521 allWatchBrowseWin
->show();
1522 allWatchBrowseWin
->RefreshContents();
1526 void MainWin::ShowHeapAllocatorBrowserWin(void)
1528 heapallocatorBrowseWin
->show();
1529 heapallocatorBrowseWin
->RefreshContents();
1533 void MainWin::ShowMemoryBrowserWin(void)
1535 memBrowseWin
->show();
1536 memBrowseWin
->RefreshContents();
1540 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1542 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1544 mem1BrowseWin
[NumWin
]->show();
1545 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1550 void MainWin::ShowEmuStatusWin(void)
1552 emuStatusWin
->show();
1553 emuStatusWin
->RefreshContents();
1557 void MainWin::ShowStackBrowserWin(void)
1559 stackBrowseWin
->show();
1560 stackBrowseWin
->RefreshContents();
1564 void MainWin::ShowCPUBrowserWin(void)
1566 cpuBrowseWin
->show();
1567 cpuBrowseWin
->RefreshContents();
1571 void MainWin::ShowOPBrowserWin(void)
1573 opBrowseWin
->show();
1574 opBrowseWin
->RefreshContents();
1578 void MainWin::ShowM68KDasmBrowserWin(void)
1580 m68kDasmBrowseWin
->show();
1581 m68kDasmBrowseWin
->RefreshContents();
1585 void MainWin::ShowRISCDasmBrowserWin(void)
1587 riscDasmBrowseWin
->show();
1588 riscDasmBrowseWin
->RefreshContents();
1592 void MainWin::ShowDasmWin(void)
1595 // DasmWin->RefreshContents();
1599 void MainWin::ShowVideoOutputWin(void)
1601 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1602 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1603 //VideoOutputWindowCentrale->show();
1604 //memBrowseWin->show();
1605 VideoOutputWin
->show();
1606 //VideoOutputWin->RefreshContents(videoWidget);
1610 void MainWin::ResizeMainWindow(void)
1612 if (!vjs
.softTypeDebugger
)
1614 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
,
1615 zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1617 // Show the test pattern if user requested plzDontKillMyComputer mode
1618 if (!powerButtonOn
&& plzDontKillMyComputer
)
1620 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1622 if (vjs
.hardwareTypeNTSC
)
1623 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1625 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1635 void MainWin::ReadSettings(void)
1639 QSettings
settings("Underground Software", "Virtual Jaguar");
1641 zoomLevel
= settings
.value("zoom", 2).toInt();
1642 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1643 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1645 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1646 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1647 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1648 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1649 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1650 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1651 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1652 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1653 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1654 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1655 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1656 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1657 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1658 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1659 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1660 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1661 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1663 // Read settings from the Debugger mode
1664 settings
.beginGroup("debugger");
1665 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1666 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1667 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1668 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1669 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1670 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1671 settings
.endGroup();
1673 // Read settings from the Alpine mode
1674 settings
.beginGroup("alpine");
1675 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1676 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1677 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1678 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1679 settings
.endGroup();
1681 // Read settings from the Keybindings
1682 settings
.beginGroup("keybindings");
1683 for (i
= 0; i
< KB_END
; i
++)
1685 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1687 settings
.endGroup();
1689 // Write important settings to the log file
1690 WriteLog("MainWin: Paths\n");
1691 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1692 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1693 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1694 WriteLog("DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1695 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1696 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1699 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1700 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1701 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1702 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1703 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1704 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1705 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1706 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1707 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1708 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1709 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1710 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1711 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1712 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1713 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1714 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1715 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1716 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1717 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1718 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1719 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1720 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1722 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1723 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1724 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1725 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1726 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1727 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1728 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1729 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1730 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1731 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1732 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1733 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1734 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1735 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1736 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1737 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1738 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1739 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1740 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1741 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1742 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1745 ReadProfiles(&settings
);
1750 // Default values will be used in case of no settings can be found
1752 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1754 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1756 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1757 void MainWin::ReadUISettings(void)
1764 // Point on the emulator settings
1765 QSettings
settings("Underground Software", "Virtual Jaguar");
1766 settings
.beginGroup("ui");
1768 // Emulator main window UI information
1769 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1770 size
= settings
.value("size", QSize(400, 400)).toSize();
1772 move(mainWinPosition
);
1773 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1774 filePickWin
->move(pos
);
1776 // Alpine debug UI information (also needed by the Debugger)
1777 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1779 // CPU registers UI information
1780 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1781 cpuBrowseWin
->move(pos
);
1782 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1784 // Memory browser UI information
1785 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1786 memBrowseWin
->move(pos
);
1787 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1789 // Stack browser UI information
1790 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1791 stackBrowseWin
->move(pos
);
1792 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1793 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1794 stackBrowseWin
->resize(size
);
1796 // Emulator status UI information
1797 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1798 emuStatusWin
->move(pos
);
1799 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1801 // OP (Object Processor) UI information
1802 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1803 opBrowseWin
->move(pos
);
1804 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1805 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1806 opBrowseWin
->resize(size
);
1808 // RISC disassembly UI information
1809 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1810 riscDasmBrowseWin
->move(pos
);
1811 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
1813 // M68k disassembly UI information
1814 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1815 m68kDasmBrowseWin
->move(pos
);
1816 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
1818 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
1820 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
1824 // Debugger UI information
1825 if (vjs
.softTypeDebugger
)
1828 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
1829 m68kDasmWin
->move(pos
);
1830 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
1831 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
1832 GPUDasmWin
->move(pos
);
1833 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
1834 DSPDasmWin
->move(pos
);
1836 // All watch browser UI information
1837 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
1838 allWatchBrowseWin
->move(pos
);
1839 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
1840 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
1841 allWatchBrowseWin
->resize(size
);
1843 // Heap memory allocation browser UI information
1844 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
1845 heapallocatorBrowseWin
->move(pos
);
1846 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
1847 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
1848 heapallocatorBrowseWin
->resize(size
);
1850 // Exception Vector Table UI Information
1851 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
1852 exceptionvectortableBrowseWin
->move(pos
);
1853 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
1854 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
1855 exceptionvectortableBrowseWin
->resize(size
);
1857 // Memories browser UI information
1858 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
1860 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
1861 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
1862 mem1BrowseWin
[i
]->move(pos
);
1863 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
1864 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
1865 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
1866 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
1867 mem1BrowseWin
[i
]->resize(size
);
1871 settings
.endGroup();
1875 // Save the settings
1876 void MainWin::WriteSettings(void)
1880 // Point on the emulator settings
1881 QSettings
settings("Underground Software", "Virtual Jaguar");
1882 //settings.setValue("pos", pos());
1883 //settings.setValue("size", size());
1884 //settings.setValue("cartLoadPos", filePickWin->pos());
1886 settings
.setValue("zoom", zoomLevel
);
1887 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
1888 settings
.setValue("lastEditedProfile", lastEditedProfile
);
1890 settings
.setValue("useJoystick", vjs
.useJoystick
);
1891 settings
.setValue("joyport", vjs
.joyport
);
1892 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
1893 settings
.setValue("frameSkip", vjs
.frameSkip
);
1894 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
1895 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
1896 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
1897 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
1898 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
1899 settings
.setValue("fullscreen", vjs
.fullscreen
);
1900 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
1901 settings
.setValue("glFilterType", vjs
.glFilter
);
1902 settings
.setValue("renderType", vjs
.renderType
);
1903 settings
.setValue("biosType", vjs
.biosType
);
1904 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
1905 settings
.setValue("JagBootROM", vjs
.jagBootPath
);
1906 settings
.setValue("CDBootROM", vjs
.CDBootPath
);
1907 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
1908 settings
.setValue("ROMs", vjs
.ROMPath
);
1910 // Write settings from the Alpine mode
1911 settings
.beginGroup("alpine");
1912 settings
.setValue("refresh", vjs
.refresh
);
1913 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
1914 settings
.setValue("DefaultABS", vjs
.absROMPath
);
1915 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
1916 settings
.endGroup();
1918 // Write settings from the Debugger mode
1919 settings
.beginGroup("debugger");
1920 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
1921 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
1922 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
1923 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
1924 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
1925 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
1926 settings
.endGroup();
1928 // Write settings from the Keybindings
1929 settings
.beginGroup("keybindings");
1930 for (i
= 0; i
< KB_END
; i
++)
1932 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
1934 settings
.endGroup();
1937 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
1938 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
1939 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
1940 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
1941 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
1942 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
1943 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
1944 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
1945 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
1946 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
1947 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
1948 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
1949 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
1950 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
1951 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
1952 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
1953 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
1954 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
1955 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
1956 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
1957 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
1959 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
1960 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
1961 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
1962 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
1963 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
1964 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
1965 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
1966 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
1967 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
1968 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
1969 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
1970 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
1971 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
1972 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
1973 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
1974 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
1975 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
1976 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
1977 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
1978 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
1979 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
1982 WriteProfiles(&settings
);
1986 // Save the UI settings
1987 void MainWin::WriteUISettings(void)
1992 // Point on the emulator settings
1993 QSettings
settings("Underground Software", "Virtual Jaguar");
1994 settings
.beginGroup("ui");
1996 // Emulator UI information
1997 settings
.setValue("pos", pos());
1998 settings
.setValue("size", size());
1999 settings
.setValue("cartLoadPos", filePickWin
->pos());
2000 settings
.setValue("zoom", zoomLevel
);
2002 // Alpine debug UI information (also needed by the Debugger)
2003 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2005 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2006 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2007 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2008 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2009 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2010 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2011 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2012 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2013 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2014 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2015 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2016 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2017 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2018 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2019 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2020 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2023 // Debugger UI information
2024 if (vjs
.softTypeDebugger
)
2027 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2028 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2029 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2030 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2032 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2033 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2034 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2035 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2036 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2037 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2038 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2039 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2040 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2041 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2043 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2044 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2045 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2046 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2047 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2048 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2052 settings
.endGroup();
2056 // Refresh alpine debug windows
2057 void MainWin::RefreshAlpineWindows(void)
2059 cpuBrowseWin
->RefreshContents();
2060 memBrowseWin
->RefreshContents();
2061 stackBrowseWin
->RefreshContents();
2062 emuStatusWin
->RefreshContents();
2063 opBrowseWin
->RefreshContents();
2064 riscDasmBrowseWin
->RefreshContents();
2065 m68kDasmBrowseWin
->RefreshContents();
2069 // Refresh soft debugger & alpine debug windows
2070 void MainWin::RefreshDebuggerWindows(void)
2074 if (vjs
.softTypeDebugger
)
2076 m68kDasmWin
->RefreshContents();
2077 GPUDasmWin
->RefreshContents();
2078 DSPDasmWin
->RefreshContents();
2079 allWatchBrowseWin
->RefreshContents();
2080 heapallocatorBrowseWin
->RefreshContents();
2081 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2083 mem1BrowseWin
[i
]->RefreshContents(i
);
2086 RefreshAlpineWindows();