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 case)
609 // Create our test pattern bitmaps
610 QImage
tempImg(":/res/test-pattern.jpg");
611 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
613 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
615 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
617 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
619 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
620 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
624 QImage
tempImg2(":/res/test-pattern-pal");
625 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
627 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
629 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
631 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
633 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
634 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
638 // Set up timer based loop for animation...
639 timer
= new QTimer(this);
640 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
642 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
643 // This is because it's discarding the 0.6666... on the end of the fraction.
644 // Alas, 6 doesn't divide cleanly into 10. :-P
645 //Should we defer this until SyncUI? Probably.
646 //No, it doesn't work, because it uses setInterval() instead of start()...
647 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
649 // We set this initially, to make VJ behave somewhat as it would if no
650 // cart were inserted and the BIOS was set as active...
651 jaguarCartInserted
= true;
652 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
653 WriteLog("VJ: Initializing jaguar subsystem...\n");
655 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
656 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
658 // Prevent the file scanner from running if filename passed
659 // in on the command line...
663 // Load up the default ROM if in Alpine mode:
664 if (vjs
.hardwareTypeAlpine
)
666 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
668 // If regular load failed, try just a straight file load
669 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
671 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
674 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
676 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
678 // Attempt to load/run the ABS file...
679 LoadSoftware(vjs
.absROMPath
);
680 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
681 // Prevent the scanner from running...
685 // Load up the default ROM if in Debugger mode:
686 if (vjs
.softTypeDebugger
)
688 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
690 // If regular load failed, try just a straight file load
691 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
693 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
696 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
698 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
700 // Attempt to load/run the ABS file...
701 LoadSoftware(vjs
.absROMPath
);
702 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
703 // Prevent the scanner from running...
707 // Run the scanner if nothing passed in and *not* Alpine mode...
708 // NB: Really need to look into caching the info scanned in here...
709 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
710 scannedSoftwareFolder
= true;
714 void MainWin::LoadFile(QString file
)
720 void MainWin::SyncUI(void)
722 // Set toolbar buttons/menus based on settings read in (sync the UI)...
723 // (Really, this is to sync command line options passed in)
724 blurAct
->setChecked(vjs
.glFilter
);
725 x1Act
->setChecked(zoomLevel
== 1);
726 x2Act
->setChecked(zoomLevel
== 2);
727 x3Act
->setChecked(zoomLevel
== 3);
728 // running = powerAct->isChecked();
729 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
730 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
731 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
733 fullScreenAct
->setChecked(vjs
.fullscreen
);
734 fullScreen
= vjs
.fullscreen
;
735 SetFullScreen(fullScreen
);
737 // Reset the timer to be what was set in the command line (if any):
738 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
739 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
743 void MainWin::closeEvent(QCloseEvent
* event
)
746 // This should only be done by the config dialog
749 event
->accept(); // ignore() if can't close for some reason
753 void MainWin::keyPressEvent(QKeyEvent
* e
)
755 #ifndef VJ_REMOVE_DEV_CODE
757 //extern bool startM68KTracing; // moved to jaguar.h
759 extern int blit_start_log
;
761 extern bool startConciseBlitLogging
;
764 // We ignore the Alt key for now, since it causes problems with the GUI
765 if (e
->key() == Qt::Key_Alt
)
770 // Bar this shite from release versions kthxbai
771 #ifndef VJ_REMOVE_DEV_CODE
772 else if (e
->key() == Qt::Key_F11
)
774 startM68KTracing
= true;
778 else if (e
->key() == Qt::Key_F12
)
780 blit_start_log
= true;
784 else if (e
->key() == Qt::Key_F10
)
786 startConciseBlitLogging
= true;
791 else if (e
->key() == Qt::Key_F8
)
793 // ggn: For extra NYAN pleasure...
794 // ggn: There you go James :P
795 // Shamus: Thanks for the patch! :-D
796 WriteLog(" o + + +\n");
797 WriteLog("+ o o + o\n");
798 WriteLog("-_-_-_-_-_-_-_,------, o \n");
799 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
800 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
801 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
802 WriteLog("+ o o + o\n");
809 This is done now by a QAction...
810 if (e->key() == Qt::Key_F9)
820 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
822 // We ignore the Alt key for now, since it causes problems with the GUI
823 if (e
->key() == Qt::Key_Alt
)
829 HandleKeys(e
, false);
833 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
835 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
836 // We kill bad key combos here, before they can get to the emulator...
837 // This also kills the illegal instruction problem that cropped up in
840 // First, settle key states...
841 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
842 keyHeld
[P1LEFT
] = state
;
843 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
844 keyHeld
[P1RIGHT
] = state
;
845 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
846 keyHeld
[P1UP
] = state
;
847 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
848 keyHeld
[P1DOWN
] = state
;
849 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
850 keyHeld
[P2LEFT
] = state
;
851 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
852 keyHeld
[P2RIGHT
] = state
;
853 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
854 keyHeld
[P2UP
] = state
;
855 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
856 keyHeld
[P2DOWN
] = state
;
858 // Next, check for conflicts and kill 'em if there are any...
859 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
860 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
862 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
863 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
865 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
866 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
868 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
869 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
871 // No bad combos exist now, let's stuff the emulator key buffers...!
872 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
874 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
875 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
877 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
878 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
884 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
886 void MainWin::HandleGamepads(void)
890 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
892 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
893 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
895 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
896 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
901 void MainWin::Open(void)
906 void MainWin::Configure(void)
908 // Call the configuration dialog and update settings
909 ConfigDialog
dlg(this);
911 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
912 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
913 dlg
.controllerTab1
->SetupLastUsedProfile();
914 // maybe instead of this, we tell the controller tab to work on a copy that gets
915 // written if the user hits 'OK'.
916 SaveProfiles(); // Just in case user cancels
918 if (dlg
.exec() == false)
924 QString before
= vjs
.ROMPath
;
925 QString alpineBefore
= vjs
.alpineROMPath
;
926 QString absBefore
= vjs
.absROMPath
;
927 // bool audioBefore = vjs.audioEnabled;
928 bool audioBefore
= vjs
.DSPEnabled
;
929 dlg
.UpdateVJSettings();
930 QString after
= vjs
.ROMPath
;
931 QString alpineAfter
= vjs
.alpineROMPath
;
932 QString absAfter
= vjs
.absROMPath
;
933 // bool audioAfter = vjs.audioEnabled;
934 bool audioAfter
= vjs
.DSPEnabled
;
936 bool allowOld
= allowUnknownSoftware
;
938 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
939 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
940 AutoConnectProfiles();
942 // We rescan the "software" folder if the user either changed the path or
943 // checked/unchecked the "Allow unknown files" option in the config dialog.
944 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
945 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
947 // If the "Alpine" ROM is changed, then let's load it...
948 if (alpineBefore
!= alpineAfter
)
950 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
952 // Oh crap, we couldn't get the file! Alert the media!
954 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
955 msg
.setIcon(QMessageBox::Warning
);
960 // If the "ABS" ROM is changed, then let's load it...
961 if (absBefore
!= absAfter
)
963 if (!JaguarLoadFile(vjs
.absROMPath
))
965 // Oh crap, we couldn't get the file! Alert the media!
967 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
968 msg
.setIcon(QMessageBox::Warning
);
973 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
974 // since it's running in the host audio IRQ...
975 if (audioBefore
!= audioAfter
)
981 // Just in case we crash before a clean exit...
984 RefreshDebuggerWindows();
989 // Here's the main emulator loop
991 void MainWin::Timer(void)
994 static uint32_t ntscTickCount
;
995 if (vjs
.hardwareTypeNTSC
)
999 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1006 if (showUntunedTankCircuit
)
1008 // Some machines can't handle this, so we give them the option to disable it. :-)
1009 if (!plzDontKillMyComputer
)
1011 // if (!vjs.softTypeDebugger)
1013 // Random hash & trash
1014 // We try to simulate an untuned tank circuit here... :-)
1015 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1017 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1019 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
]
1020 = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1028 // Otherwise, run the Jaguar simulation
1031 if (!vjs
.softTypeDebugger
)
1032 videoWidget
->HandleMouseHiding();
1034 static uint32_t refresh
= 0;
1035 // Do autorefresh on debug windows
1036 // Have to be careful, too much causes the emulator to slow way down!
1037 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1039 if (refresh
== vjs
.refresh
)
1041 RefreshAlpineWindows();
1042 //memBrowseWin->RefreshContents();
1043 //cpuBrowseWin->RefreshContents();
1051 //if (!vjs.softTypeDebugger)
1052 videoWidget
->updateGL();
1055 // Approach: We use a ring buffer to store times (in ms) over a given
1056 // amount of frames, then sum them to figure out the FPS.
1057 uint32_t timestamp
= SDL_GetTicks();
1058 // This assumes the ring buffer size is a power of 2
1059 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1060 // Doing it this way is better. Ring buffer size can be arbitrary then.
1061 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1062 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1063 uint32_t elapsedTime
= 0;
1065 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1066 elapsedTime
+= ringBuffer
[i
];
1068 // elapsedTime must be non-zero
1069 if (elapsedTime
== 0)
1072 // This is in frames per 10 seconds, so we can have 1 decimal
1073 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1074 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1075 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1076 // If this is updated too frequently to be useful, we can throttle it down
1077 // so that it only updates every 10th frame or so
1078 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1079 oldTimestamp
= timestamp
;
1081 if (M68KDebugHaltStatus())
1086 void MainWin::TogglePowerState(void)
1088 powerButtonOn
= !powerButtonOn
;
1091 // With the power off, we simulate white noise on the screen. :-)
1094 // Restore the mouse pointer, if hidden:
1095 if (!vjs
.softTypeDebugger
)
1096 videoWidget
->CheckAndRestoreMouseCursor();
1097 useCDAct
->setDisabled(false);
1098 palAct
->setDisabled(false);
1099 ntscAct
->setDisabled(false);
1100 pauseAct
->setChecked(false);
1101 pauseAct
->setDisabled(true);
1102 showUntunedTankCircuit
= true;
1103 DACPauseAudioThread();
1104 // This is just in case the ROM we were playing was in a narrow or wide
1105 // field mode, so the untuned tank sim doesn't look wrong. :-)
1108 if (plzDontKillMyComputer
)
1110 //if (!vjs.softTypeDebugger)
1112 // We have to do it line by line, because the texture pitch is not
1113 // the same as the picture buffer's pitch.
1114 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1116 if (vjs
.hardwareTypeNTSC
)
1117 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1119 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1126 useCDAct
->setDisabled(true);
1127 palAct
->setDisabled(true);
1128 ntscAct
->setDisabled(true);
1129 pauseAct
->setChecked(false);
1130 pauseAct
->setDisabled(false);
1131 showUntunedTankCircuit
= false;
1133 // Otherwise, we prepare for running regular software...
1136 // Should check for cartridgeLoaded here as well...!
1137 // We can clear it when toggling CDActive on, so that when we power cycle it
1138 // does the expected thing. Otherwise, if we use the file picker to insert a
1139 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1140 // works if the CD unit is active?
1141 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
1142 " Rx - Now playing: Jaguar CD"));
1145 WriteLog("GUI: Resetting Jaguar...\n");
1147 DACPauseAudioThread(false);
1152 void MainWin::ToggleRunState(void)
1154 startM68KTracing
= running
;
1159 frameAdvanceAct
->setDisabled(false);
1160 pauseAct
->setChecked(true);
1161 pauseAct
->setDisabled(false);
1162 if (vjs
.softTypeDebugger
)
1164 traceStepIntoAct
->setDisabled(false);
1165 traceStepOverAct
->setDisabled(false);
1166 restartAct
->setDisabled(false);
1167 m68kDasmWin
->Use68KPCAddress();
1168 GPUDasmWin
->UseGPUPCAddress();
1169 DSPDasmWin
->UseDSPPCAddress();
1172 //if (!vjs.softTypeDebugger)
1174 // Restore the mouse pointer, if hidden:
1175 videoWidget
->CheckAndRestoreMouseCursor();
1176 // frameAdvanceAct->setDisabled(false);
1178 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1180 uint32_t pixel
= videoWidget
->buffer
[i
];
1181 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1182 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1183 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1186 videoWidget
->updateGL();
1188 cpuBrowseWin
->HoldBPM();
1189 cpuBrowseWin
->HandleBPMContinue();
1190 RefreshDebuggerWindows();
1195 frameAdvanceAct
->setDisabled(true);
1196 pauseAct
->setChecked(false);
1197 pauseAct
->setDisabled(false);
1198 if (vjs
.softTypeDebugger
)
1200 traceStepIntoAct
->setDisabled(true);
1201 traceStepOverAct
->setDisabled(true);
1202 restartAct
->setDisabled(true);
1205 cpuBrowseWin
->UnholdBPM();
1208 // Pause/unpause any running/non-running threads...
1209 DACPauseAudioThread(!running
);
1213 void MainWin::SetZoom100(void)
1220 void MainWin::SetZoom200(void)
1227 void MainWin::SetZoom300(void)
1234 void MainWin::SetNTSC(void)
1236 powerAct
->setIcon(powerRed
);
1237 timer
->setInterval(16);
1238 vjs
.hardwareTypeNTSC
= true;
1244 void MainWin::SetPAL(void)
1246 powerAct
->setIcon(powerGreen
);
1247 timer
->setInterval(20);
1248 vjs
.hardwareTypeNTSC
= false;
1254 void MainWin::ToggleBlur(void)
1256 vjs
.glFilter
= !vjs
.glFilter
;
1261 void MainWin::ShowAboutWin(void)
1267 void MainWin::ShowHelpWin(void)
1273 void MainWin::InsertCart(void)
1275 // Check to see if we did autorun, 'cause we didn't load anything in that
1277 if (!scannedSoftwareFolder
)
1279 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1280 scannedSoftwareFolder
= true;
1283 // If the emulator is running, we pause it here and unpause it later
1284 // if we dismiss the file selector without choosing anything
1285 if (running
&& powerButtonOn
)
1288 pauseForFileSelector
= true;
1291 filePickWin
->show();
1295 void MainWin::Unpause(void)
1297 // Here we unpause the emulator if it was paused when we went into the file selector
1298 if (pauseForFileSelector
)
1300 pauseForFileSelector
= false;
1302 // Some nutter might have unpaused while in the file selector, so check for that
1309 void MainWin::LoadSoftware(QString file
)
1311 running
= false; // Prevent bad things(TM) from happening...
1312 pauseForFileSelector
= false; // Reset the file selector pause flag
1314 uint8_t * biosPointer
= jaguarBootROM
;
1316 if (vjs
.hardwareTypeAlpine
)
1317 biosPointer
= jaguarDevBootROM2
;
1319 if (vjs
.softTypeDebugger
)
1320 biosPointer
= jaguarDevBootROM2
;
1322 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1324 powerAct
->setDisabled(false);
1325 powerAct
->setChecked(true);
1326 powerButtonOn
= false;
1329 // We have to load our software *after* the Jaguar RESET
1330 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1331 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set top of stack...
1333 // This is icky because we've already done it
1334 // it gets worse :-P
1335 if (!vjs
.useJaguarBIOS
)
1336 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1340 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1341 if (vjs
.softTypeDebugger
)
1343 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1344 //pauseAct->setDisabled(false);
1345 //pauseAct->setChecked(true);
1351 if (vjs
.hardwareTypeAlpine
&& !jaguarRunAddress
)
1357 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1359 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1")
1360 .arg(filePickWin
->GetSelectedPrettyName());
1361 setWindowTitle(newTitle
);
1366 void MainWin::ToggleCDUsage(void)
1368 CDActive
= !CDActive
;
1370 // Set up the Jaguar CD for execution, otherwise, clear memory
1372 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1374 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1379 void MainWin::NewBreakpointFunction(void)
1382 brkWin
->RefreshContents();
1387 void MainWin::TraceStepInto(void)
1390 videoWidget
->updateGL();
1391 RefreshDebuggerWindows();
1393 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1395 #warning "!!! Need to verify the Step Into function !!!"
1401 void MainWin::Restart(void)
1403 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1404 //m68kDasmWin->SetAddress(jaguarRunAddress);
1405 RefreshDebuggerWindows();
1407 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1409 #warning "!!! Need to verify the Restart function !!!"
1415 void MainWin::TraceStepOver(void)
1418 videoWidget
->updateGL();
1419 RefreshDebuggerWindows();
1421 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1423 #warning "!!! Need to verify the Step Over function !!!"
1428 // Advance / Execute for one frame
1429 void MainWin::FrameAdvance(void)
1431 //printf("Frame Advance...\n");
1433 // Execute 1 frame, then exit (only useful in Pause mode)
1435 //if (!vjs.softTypeDebugger)
1436 videoWidget
->updateGL();
1438 // Need to execute 1 frames' worth of DSP thread as well :-/
1440 //m68kDasmWin->Use68KPCAddress();
1443 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1445 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1450 void MainWin::SetFullScreen(bool state
/*= true*/)
1452 if (!vjs
.softTypeDebugger
)
1456 mainWinPosition
= pos();
1458 statusBar()->hide();
1464 // This is needed because the fullscreen may happen on a different
1465 // screen than screen 0:
1466 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1467 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1468 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1469 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1470 double aspectRatio
= targetWidth
/ targetHeight
;
1471 // NOTE: Really should check here to see which dimension constrains the
1472 // other. Right now, we assume that height is the constraint.
1473 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1474 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1475 videoWidget
->fullscreen
= true;
1476 videoWidget
->outputWidth
= newWidth
;
1477 videoWidget
->setFixedSize(r
.width(), r
.height());
1482 // Seems Qt is fussy about this: showNormal() has to go first, or it
1483 // will keep the window stuck in a psuedo-fullscreen mode with no way
1484 // to get out of it (except closing the app).
1487 // Reset the video widget to windowed mode
1488 videoWidget
->offset
= 0;
1489 videoWidget
->fullscreen
= false;
1491 statusBar()->show();
1498 move(mainWinPosition
);
1504 void MainWin::ToggleFullScreen(void)
1506 fullScreen
= !fullScreen
;
1507 SetFullScreen(fullScreen
);
1511 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1513 exceptionvectortableBrowseWin
->show();
1514 exceptionvectortableBrowseWin
->RefreshContents();
1518 void MainWin::ShowAllWatchBrowserWin(void)
1520 allWatchBrowseWin
->show();
1521 allWatchBrowseWin
->RefreshContents();
1525 void MainWin::ShowHeapAllocatorBrowserWin(void)
1527 heapallocatorBrowseWin
->show();
1528 heapallocatorBrowseWin
->RefreshContents();
1532 void MainWin::ShowMemoryBrowserWin(void)
1534 memBrowseWin
->show();
1535 memBrowseWin
->RefreshContents();
1539 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1541 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1543 mem1BrowseWin
[NumWin
]->show();
1544 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1549 void MainWin::ShowEmuStatusWin(void)
1551 emuStatusWin
->show();
1552 emuStatusWin
->RefreshContents();
1556 void MainWin::ShowStackBrowserWin(void)
1558 stackBrowseWin
->show();
1559 stackBrowseWin
->RefreshContents();
1563 void MainWin::ShowCPUBrowserWin(void)
1565 cpuBrowseWin
->show();
1566 cpuBrowseWin
->RefreshContents();
1570 void MainWin::ShowOPBrowserWin(void)
1572 opBrowseWin
->show();
1573 opBrowseWin
->RefreshContents();
1577 void MainWin::ShowM68KDasmBrowserWin(void)
1579 m68kDasmBrowseWin
->show();
1580 m68kDasmBrowseWin
->RefreshContents();
1584 void MainWin::ShowRISCDasmBrowserWin(void)
1586 riscDasmBrowseWin
->show();
1587 riscDasmBrowseWin
->RefreshContents();
1591 void MainWin::ShowDasmWin(void)
1594 // DasmWin->RefreshContents();
1598 void MainWin::ShowVideoOutputWin(void)
1600 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1601 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1602 //VideoOutputWindowCentrale->show();
1603 //memBrowseWin->show();
1604 VideoOutputWin
->show();
1605 //VideoOutputWin->RefreshContents(videoWidget);
1609 void MainWin::ResizeMainWindow(void)
1611 if (!vjs
.softTypeDebugger
)
1613 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
,
1614 zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1616 // Show the test pattern if user requested plzDontKillMyComputer mode
1617 if (!powerButtonOn
&& plzDontKillMyComputer
)
1619 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1621 if (vjs
.hardwareTypeNTSC
)
1622 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1624 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1634 void MainWin::ReadSettings(void)
1638 QSettings
settings("Underground Software", "Virtual Jaguar");
1640 zoomLevel
= settings
.value("zoom", 2).toInt();
1641 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1642 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1644 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1645 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1646 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1647 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1648 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1649 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1650 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1651 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1652 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1653 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1654 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1655 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1656 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1657 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1658 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1659 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1660 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1662 // Read settings from the Debugger mode
1663 settings
.beginGroup("debugger");
1664 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1665 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1666 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1667 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1668 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1669 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1670 settings
.endGroup();
1672 // Read settings from the Alpine mode
1673 settings
.beginGroup("alpine");
1674 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1675 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1676 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1677 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1678 settings
.endGroup();
1680 // Read settings from the Keybindings
1681 settings
.beginGroup("keybindings");
1682 for (i
= 0; i
< KB_END
; i
++)
1684 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1686 settings
.endGroup();
1688 // Write important settings to the log file
1689 WriteLog("MainWin: Paths\n");
1690 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1691 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1692 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1693 WriteLog("DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1694 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1695 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1698 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1699 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1700 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1701 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1702 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1703 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1704 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1705 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1706 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1707 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1708 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1709 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1710 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1711 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1712 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1713 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1714 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1715 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1716 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1717 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1718 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1719 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1721 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1722 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1723 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1724 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1725 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1726 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1727 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1728 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1729 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1730 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1731 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1732 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1733 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1734 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1735 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1736 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1737 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1738 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1739 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1740 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1741 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1744 ReadProfiles(&settings
);
1749 // Default values will be used in case of no settings can be found
1751 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1753 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1755 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1756 void MainWin::ReadUISettings(void)
1763 // Point on the emulator settings
1764 QSettings
settings("Underground Software", "Virtual Jaguar");
1765 settings
.beginGroup("ui");
1767 // Emulator main window UI information
1768 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1769 size
= settings
.value("size", QSize(400, 400)).toSize();
1771 move(mainWinPosition
);
1772 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1773 filePickWin
->move(pos
);
1775 // Alpine debug UI information (also needed by the Debugger)
1776 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1778 // CPU registers UI information
1779 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1780 cpuBrowseWin
->move(pos
);
1781 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1783 // Memory browser UI information
1784 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1785 memBrowseWin
->move(pos
);
1786 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1788 // Stack browser UI information
1789 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1790 stackBrowseWin
->move(pos
);
1791 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1792 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1793 stackBrowseWin
->resize(size
);
1795 // Emulator status UI information
1796 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1797 emuStatusWin
->move(pos
);
1798 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1800 // OP (Object Processor) UI information
1801 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1802 opBrowseWin
->move(pos
);
1803 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1804 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1805 opBrowseWin
->resize(size
);
1807 // RISC disassembly UI information
1808 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1809 riscDasmBrowseWin
->move(pos
);
1810 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
1812 // M68k disassembly UI information
1813 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1814 m68kDasmBrowseWin
->move(pos
);
1815 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
1817 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
1819 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
1823 // Debugger UI information
1824 if (vjs
.softTypeDebugger
)
1827 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
1828 m68kDasmWin
->move(pos
);
1829 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
1830 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
1831 GPUDasmWin
->move(pos
);
1832 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
1833 DSPDasmWin
->move(pos
);
1835 // All watch browser UI information
1836 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
1837 allWatchBrowseWin
->move(pos
);
1838 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
1839 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
1840 allWatchBrowseWin
->resize(size
);
1842 // Heap memory allocation browser UI information
1843 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
1844 heapallocatorBrowseWin
->move(pos
);
1845 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
1846 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
1847 heapallocatorBrowseWin
->resize(size
);
1849 // Exception Vector Table UI Information
1850 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
1851 exceptionvectortableBrowseWin
->move(pos
);
1852 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
1853 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
1854 exceptionvectortableBrowseWin
->resize(size
);
1856 // Memories browser UI information
1857 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
1859 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
1860 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
1861 mem1BrowseWin
[i
]->move(pos
);
1862 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
1863 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
1864 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
1865 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
1866 mem1BrowseWin
[i
]->resize(size
);
1870 settings
.endGroup();
1874 // Save the settings
1875 void MainWin::WriteSettings(void)
1879 // Point on the emulator settings
1880 QSettings
settings("Underground Software", "Virtual Jaguar");
1881 //settings.setValue("pos", pos());
1882 //settings.setValue("size", size());
1883 //settings.setValue("cartLoadPos", filePickWin->pos());
1885 settings
.setValue("zoom", zoomLevel
);
1886 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
1887 settings
.setValue("lastEditedProfile", lastEditedProfile
);
1889 settings
.setValue("useJoystick", vjs
.useJoystick
);
1890 settings
.setValue("joyport", vjs
.joyport
);
1891 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
1892 settings
.setValue("frameSkip", vjs
.frameSkip
);
1893 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
1894 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
1895 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
1896 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
1897 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
1898 settings
.setValue("fullscreen", vjs
.fullscreen
);
1899 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
1900 settings
.setValue("glFilterType", vjs
.glFilter
);
1901 settings
.setValue("renderType", vjs
.renderType
);
1902 settings
.setValue("biosType", vjs
.biosType
);
1903 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
1904 settings
.setValue("JagBootROM", vjs
.jagBootPath
);
1905 settings
.setValue("CDBootROM", vjs
.CDBootPath
);
1906 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
1907 settings
.setValue("ROMs", vjs
.ROMPath
);
1909 // Write settings from the Alpine mode
1910 settings
.beginGroup("alpine");
1911 settings
.setValue("refresh", vjs
.refresh
);
1912 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
1913 settings
.setValue("DefaultABS", vjs
.absROMPath
);
1914 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
1915 settings
.endGroup();
1917 // Write settings from the Debugger mode
1918 settings
.beginGroup("debugger");
1919 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
1920 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
1921 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
1922 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
1923 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
1924 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
1925 settings
.endGroup();
1927 // Write settings from the Keybindings
1928 settings
.beginGroup("keybindings");
1929 for (i
= 0; i
< KB_END
; i
++)
1931 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
1933 settings
.endGroup();
1936 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
1937 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
1938 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
1939 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
1940 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
1941 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
1942 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
1943 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
1944 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
1945 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
1946 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
1947 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
1948 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
1949 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
1950 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
1951 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
1952 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
1953 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
1954 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
1955 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
1956 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
1958 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
1959 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
1960 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
1961 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
1962 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
1963 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
1964 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
1965 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
1966 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
1967 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
1968 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
1969 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
1970 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
1971 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
1972 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
1973 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
1974 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
1975 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
1976 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
1977 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
1978 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
1981 WriteProfiles(&settings
);
1985 // Save the UI settings
1986 void MainWin::WriteUISettings(void)
1991 // Point on the emulator settings
1992 QSettings
settings("Underground Software", "Virtual Jaguar");
1993 settings
.beginGroup("ui");
1995 // Emulator UI information
1996 settings
.setValue("pos", pos());
1997 settings
.setValue("size", size());
1998 settings
.setValue("cartLoadPos", filePickWin
->pos());
1999 settings
.setValue("zoom", zoomLevel
);
2001 // Alpine debug UI information (also needed by the Debugger)
2002 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2004 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2005 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2006 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2007 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2008 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2009 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2010 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2011 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2012 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2013 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2014 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2015 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2016 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2017 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2018 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2019 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2022 // Debugger UI information
2023 if (vjs
.softTypeDebugger
)
2026 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2027 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2028 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2029 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2031 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2032 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2033 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2034 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2035 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2036 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2037 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2038 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2039 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2040 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2042 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2043 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2044 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2045 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2046 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2047 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2051 settings
.endGroup();
2055 // Refresh alpine debug windows
2056 void MainWin::RefreshAlpineWindows(void)
2058 cpuBrowseWin
->RefreshContents();
2059 memBrowseWin
->RefreshContents();
2060 stackBrowseWin
->RefreshContents();
2061 emuStatusWin
->RefreshContents();
2062 opBrowseWin
->RefreshContents();
2063 riscDasmBrowseWin
->RefreshContents();
2064 m68kDasmBrowseWin
->RefreshContents();
2068 // Refresh soft debugger & alpine debug windows
2069 void MainWin::RefreshDebuggerWindows(void)
2073 if (vjs
.softTypeDebugger
)
2075 m68kDasmWin
->RefreshContents();
2076 GPUDasmWin
->RefreshContents();
2077 DSPDasmWin
->RefreshContents();
2078 allWatchBrowseWin
->RefreshContents();
2079 heapallocatorBrowseWin
->RefreshContents();
2080 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2082 mem1BrowseWin
[i
]->RefreshContents(i
);
2085 RefreshAlpineWindows();