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 June/2016 Visual Studio support & Soft debugger integration
15 // JPM 01/11/2017 Added stack browser
16 // JPM Feb./2017 Added GPU/DSP disassembly
17 // JPM 07/12/2017 Added all Watch window
18 // JPM Aug./2017 Added heap allocator and memories window, a restart feature, and a [Not Supported] breakpoints window
19 // JPM Sept./2017 Save position, size & visibility windows status in the settings; added Exception Vector Table window, the 'Rx' word to the emulator window name, and the keybindings in the settings
20 // JPM 11/04/2017 Added the local window
21 // JPM 08/31/2018 Added the call stack window
22 // JPM Sept./2018 Added the new Models and BIOS handler, a screenshot feature and source code files browsing
23 // JPM Oct./2018 Added search paths in the settings, breakpoints feature, cartridge view menu
24 // JPM 11/18/2018 Fix crash with non-debugger mode
25 // JPM April/2019 Added ELF sections check, added a save memory dump
26 // JPM Aug./2019 Update texts descriptions, set cartridge view menu for debugger mode only
31 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
32 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
33 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
34 // with 'R', etc) [DONE]
35 // - Controller configuration [DONE]
39 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
40 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
41 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
44 // SFDX CODE: S1E9T8H5M23YS
46 // Uncomment this for debugging...
48 //#define DEBUGFOO // Various tool debugging... but not used
49 //#define DEBUGTP // Toolpalette debugging... but not used
56 #include "configdialog.h"
57 #include "controllertab.h"
58 #include "keybindingstab.h"
59 #include "filepicker.h"
61 #include "generaltab.h"
67 #include "emustatus.h"
68 #include "debug/cpubrowser.h"
69 #include "debug/m68kdasmbrowser.h"
70 #include "debug/memorybrowser.h"
71 #include "debug/stackbrowser.h"
72 #include "debug/opbrowser.h"
73 #include "debug/riscdasmbrowser.h"
79 #ifndef NEWMODELSBIOSHANDLER
82 #include "jagstub2bios.h"
84 #include "modelsBIOS.h"
86 #include "jagcdbios.h"
88 #include "m68000/m68kinterface.h"
90 #include "debugger/DBGManager.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/BreakpointsWin.h"
98 #include "debugger/NewFnctBreakpointWin.h"
99 #include "debugger/FilesrcListWin.h"
100 #include "debugger/exceptionvectortablebrowser.h"
101 #include "debugger/allwatchbrowser.h"
102 #include "debugger/localbrowser.h"
103 #include "debugger/heapallocatorbrowser.h"
104 #include "debugger/callstackbrowser.h"
105 #include "debugger/CartFilesListWin.h"
106 #include "debugger/SaveDumpAsWin.h"
109 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
110 //#ifdef __GCCWIN32__
111 // Apparently on win32, usleep() is not pulled in by the usual suspects.
115 #include "_MSC_VER/unistd.h"
119 // The way BSNES controls things is by setting a timer with a zero
120 // timeout, sleeping if not emulating anything. Seems there has to be a
123 // It has a novel approach to plugging-in/using different video/audio/input
124 // methods, can we do something similar or should we just use the built-in
127 // We're going to try to use the built-in OpenGL support and see how it goes.
128 // We'll make the VJ core modular so that it doesn't matter what GUI is in
129 // use, we can drop it in anywhere and use it as-is.
131 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
132 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
133 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
139 for(int i
=0; i
<8; i
++)
143 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
146 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
149 //if (vjs.softTypeDebugger)
151 // mainWindowCentrale = new QMdiArea;
152 // setCentralWidget(mainWindowCentrale);
155 WriteLog("Window creation start\n");
158 videoWidget
= new GLWidget(this);
159 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
161 // set central output window
162 if (!vjs
.softTypeDebugger
)
164 setCentralWidget(videoWidget
);
168 mainWindowCentrale
= new QMdiArea(this);
169 setCentralWidget(mainWindowCentrale
);
172 setWindowIcon(QIcon(":/res/vj-icon.png"));
174 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
176 if (vjs
.hardwareTypeAlpine
)
177 title
+= QString(tr(" - Alpine Mode"));
179 if (vjs
.softTypeDebugger
)
180 title
+= QString(tr(" - Debugger Mode"));
182 setWindowTitle(title
);
184 // Windows common features
185 aboutWin
= new AboutWindow(this);
186 helpWin
= new HelpWindow(this);
187 filePickWin
= new FilePickerWindow(this);
188 emuStatusWin
= new EmuStatusWindow(this);
190 // Windows alpine mode features
191 memBrowseWin
= new MemoryBrowserWindow(this);
192 stackBrowseWin
= new StackBrowserWindow(this);
193 cpuBrowseWin
= new CPUBrowserWindow(this);
194 opBrowseWin
= new OPBrowserWindow(this);
195 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
196 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
198 // Windows debugger mode features
199 if (vjs
.softTypeDebugger
)
201 //VideoOutputWin = new VideoOutputWindow(this);
202 //VideoOutputWin->setCentralWidget()
203 //DasmWin = new DasmWindow();
204 //DasmWin = new DasmWindow(this);
205 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
206 LocalBrowseWin
= new LocalBrowserWindow(this);
207 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
208 BreakpointsWin
= new BreakpointsWindow(this);
209 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
210 SaveDumpAsWin
= new SaveDumpAsWindow(this);
211 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
212 CallStackBrowseWin
= new CallStackBrowserWindow(this);
213 CartFilesListWin
= new CartFilesListWindow(this);
215 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
217 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
219 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
221 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
223 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
226 // Setup dock to display source code filenames tree
227 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
228 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
230 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
231 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
232 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
234 // Setup dock to display disassembly
235 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
236 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
237 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
238 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
239 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
241 dasmtabWidget
= new QTabWidget(this);
244 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
245 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
246 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
247 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
249 setCentralWidget(dasmtabWidget
);
253 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
254 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
256 setUnifiedTitleAndToolBarOnMac(true);
259 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
260 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
261 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
262 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
263 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
266 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
267 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
268 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
269 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
270 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
271 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
272 powerAct
->setCheckable(true);
273 powerAct
->setChecked(false);
274 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
278 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
279 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
280 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
281 pauseAct
->setStatusTip(tr("Toggles the running state"));
282 pauseAct
->setCheckable(true);
283 pauseAct
->setDisabled(true);
284 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
285 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
286 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
289 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
290 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
291 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
292 screenshotAct
->setCheckable(false);
293 screenshotAct
->setDisabled(false);
294 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
297 zoomActs
= new QActionGroup(this);
298 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
299 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
300 x1Act
->setCheckable(true);
301 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
302 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
303 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
304 x2Act
->setCheckable(true);
305 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
306 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
307 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
308 x3Act
->setCheckable(true);
309 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
312 tvTypeActs
= new QActionGroup(this);
313 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
314 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
315 ntscAct
->setCheckable(true);
316 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
317 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
318 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
319 palAct
->setCheckable(true);
320 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
323 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
324 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
325 blurAct
= new QAction(blur
, tr("Blur"), this);
326 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
327 blurAct
->setCheckable(true);
328 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
331 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
332 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
333 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
336 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
337 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
338 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
340 // File pickup action
341 if (!vjs
.softTypeDebugger
)
343 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
344 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
348 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
349 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
351 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
352 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
353 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
355 // Configuration action
356 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
357 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
358 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
359 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
360 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
362 // Emulation status action
363 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
364 emustatusAct
->setStatusTip(tr("Emulator status"));
365 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
366 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
367 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
370 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
371 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
372 useCDAct
->setCheckable(true);
373 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
375 // Frame advance action
376 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
377 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
378 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
379 frameAdvanceAct
->setDisabled(true);
380 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
383 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
384 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
385 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
386 fullScreenAct
->setCheckable(true);
387 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
389 // Actions dedicated to debugger mode
390 if (vjs
.softTypeDebugger
)
393 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
394 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
395 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
396 restartAct
->setCheckable(false);
397 restartAct
->setDisabled(true);
398 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
401 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
402 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
403 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
404 traceStepOverAct
->setCheckable(false);
405 traceStepOverAct
->setDisabled(true);
406 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
408 // Trace into tracing
409 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
410 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
411 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
412 traceStepIntoAct
->setCheckable(false);
413 traceStepIntoAct
->setDisabled(true);
414 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
416 // Function breakpoint
417 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
418 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
419 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
420 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
421 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
422 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
423 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
424 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
425 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
426 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
427 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
430 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
431 saveDumpAsAct
->setCheckable(false);
432 saveDumpAsAct
->setDisabled(false);
433 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
435 //VideoOutputAct = new QAction(tr("Output Video"), this);
436 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
437 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
439 //DasmAct = new QAction(tr("Disassembly"), this);
440 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
441 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
443 // Exception vector table window
444 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
445 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
446 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
448 // All watch variables window
449 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
450 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
451 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
453 // Local variables window
454 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
455 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
456 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
458 // Heap (memory) allocation window
459 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
460 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
461 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
464 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
465 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
466 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
469 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
470 CartFilesListAct
->setStatusTip(tr("List of the files in the cartridge's directory structure"));
471 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
474 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
475 QSignalMapper
*signalMapper
= new QSignalMapper(this);
477 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
479 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
481 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
484 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
485 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
486 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
487 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
488 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
489 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
493 // Memory browser window action
494 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
495 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
496 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
498 // Stack browser window action
499 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
500 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
501 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
503 // CPUs (M68000, GPU & DSP browser window action
504 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
505 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
506 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
508 // OP browser window action
509 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
510 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
511 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
513 // M68000 disassembly browser window
514 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
515 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
516 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
518 // Risc (DSP / GPU) disassembly browser window
519 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
520 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
521 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
523 // Misc. connections...
524 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
525 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
529 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
530 fileMenu
->addAction(powerAct
);
531 if (!vjs
.softTypeDebugger
)
533 fileMenu
->addAction(pauseAct
);
534 // fileMenu->addAction(frameAdvanceAct);
536 fileMenu
->addAction(filePickAct
);
537 fileMenu
->addAction(useCDAct
);
538 fileMenu
->addAction(configAct
);
539 fileMenu
->addAction(emustatusAct
);
540 fileMenu
->addSeparator();
541 fileMenu
->addAction(quitAppAct
);
543 // Alpine and debugger menus
544 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
547 debugMenu
= menuBar()->addMenu(tr("&Debug"));
549 // Create debugger menu
550 if (vjs
.softTypeDebugger
)
553 viewMenu
= menuBar()->addMenu(tr("&View"));
556 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
557 viewCartMenu
->addAction(CartFilesListAct
);
559 viewCartMenu
->addSeparator();
560 viewCartMenu
->addAction(CartStreamsAct
);
564 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
565 debugWindowsMenu
->addAction(BreakpointsAct
);
566 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
567 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
568 debugWindowsMenu
->addSeparator();
570 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
571 debugWindowOutputMenu
->addAction(VideoOutputAct
);
572 debugWindowsMenu
->addSeparator();
574 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
575 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
576 debugWindowsMenu
->addAction(LocalBrowseAct
);
577 debugWindowsMenu
->addSeparator();
578 debugWindowsMenu
->addAction(CallStackBrowseAct
);
579 debugWindowsMenu
->addSeparator();
580 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
581 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
582 debugWindowsMemoryMenu
->addSeparator();
583 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
585 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
587 debugWindowsMenu
->addSeparator();
588 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
589 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
590 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
591 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
592 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
593 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
594 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
595 debugMenu
->addSeparator();
596 debugMenu
->addAction(pauseAct
);
597 debugMenu
->addAction(frameAdvanceAct
);
598 debugMenu
->addAction(restartAct
);
599 debugMenu
->addSeparator();
600 debugMenu
->addAction(traceStepIntoAct
);
601 debugMenu
->addAction(traceStepOverAct
);
602 debugMenu
->addSeparator();
603 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
604 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
605 debugMenu
->addAction(deleteAllBreakpointsAct
);
606 debugMenu
->addAction(disableAllBreakpointsAct
);
607 debugMenu
->addSeparator();
608 debugMenu
->addAction(saveDumpAsAct
);
610 debugMenu
->addSeparator();
611 debugMenu
->addAction(DasmAct
);
616 // Create alpine menu
617 debugMenu
->addAction(memBrowseAct
);
618 debugMenu
->addAction(stackBrowseAct
);
619 debugMenu
->addAction(cpuBrowseAct
);
620 debugMenu
->addAction(opBrowseAct
);
621 debugMenu
->addAction(m68kDasmBrowseAct
);
622 debugMenu
->addAction(riscDasmBrowseAct
);
627 helpMenu
= menuBar()->addMenu(tr("&Help"));
628 helpMenu
->addAction(helpAct
);
629 helpMenu
->addAction(aboutAct
);
633 toolbar
= addToolBar(tr("System"));
634 toolbar
->addAction(powerAct
);
635 if (!vjs
.softTypeDebugger
)
637 toolbar
->addAction(pauseAct
);
638 toolbar
->addAction(frameAdvanceAct
);
640 toolbar
->addAction(filePickAct
);
641 toolbar
->addAction(useCDAct
);
642 toolbar
->addSeparator();
643 if (!vjs
.softTypeDebugger
)
645 toolbar
->addAction(screenshotAct
);
646 toolbar
->addSeparator();
647 toolbar
->addAction(x1Act
);
648 toolbar
->addAction(x2Act
);
649 toolbar
->addAction(x3Act
);
650 toolbar
->addSeparator();
651 toolbar
->addAction(ntscAct
);
652 toolbar
->addAction(palAct
);
653 toolbar
->addSeparator();
654 toolbar
->addAction(blurAct
);
655 toolbar
->addAction(fullScreenAct
);
659 debuggerbar
= addToolBar(tr("&Debugger"));
660 debuggerbar
->addAction(pauseAct
);
661 debuggerbar
->addAction(frameAdvanceAct
);
662 debuggerbar
->addAction(restartAct
);
663 debuggerbar
->addSeparator();
664 debuggerbar
->addAction(traceStepIntoAct
);
665 debuggerbar
->addAction(traceStepOverAct
);
666 debuggerbar
->addSeparator();
667 debuggerbar
->addAction(BreakpointsAct
);
670 if (vjs
.hardwareTypeAlpine
)
672 debugbar
= addToolBar(tr("&Debug"));
673 debugbar
->addAction(memBrowseAct
);
674 debugbar
->addAction(stackBrowseAct
);
675 debugbar
->addAction(cpuBrowseAct
);
676 debugbar
->addAction(opBrowseAct
);
677 debugbar
->addAction(m68kDasmBrowseAct
);
678 debugbar
->addAction(riscDasmBrowseAct
);
681 // Add actions to the main window, as hiding widgets with them
683 addAction(fullScreenAct
);
684 addAction(quitAppAct
);
685 addAction(configAct
);
686 addAction(emustatusAct
);
688 addAction(filePickAct
);
689 addAction(frameAdvanceAct
);
692 statusBar()->showMessage(tr("Ready"));
694 // Do this in case original size isn't correct (mostly for the first-run case)
697 WriteLog("Window creation done\n");
699 // Create our test pattern NTSC bitmap
700 WriteLog("Test pattern 1 bitmap\n");
702 QImage
tempImg(":/res/test-pattern.jpg");
703 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
705 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
707 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
709 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
711 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
712 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
716 // Create our test pattern PAL bitmap
717 WriteLog("Test pattern 2 bitmap\n");
719 QImage
tempImg2(":/res/test-pattern-pal.jpg");
720 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
722 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
724 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
726 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
728 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
729 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
733 // Set up timer based loop for animation...
734 timer
= new QTimer(this);
735 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
737 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
738 // This is because it's discarding the 0.6666... on the end of the fraction.
739 // Alas, 6 doesn't divide cleanly into 10. :-P
740 //Should we defer this until SyncUI? Probably.
741 //No, it doesn't work, because it uses setInterval() instead of start()...
742 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
744 // We set this initially, to make VJ behave somewhat as it would if no
745 // cart were inserted and the BIOS was set as active...
746 jaguarCartInserted
= true;
747 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
748 WriteLog("VJ: Initializing jaguar subsystem...\n");
751 #ifndef NEWMODELSBIOSHANDLER
752 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
753 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
755 SelectBIOS(vjs
.biosType
);
758 // Prevent the file scanner from running if filename passed
759 // in on the command line...
763 // Load up the default ROM if in Alpine mode:
764 if (vjs
.hardwareTypeAlpine
)
766 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
768 // If regular load failed, try just a straight file load
769 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
771 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
774 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
776 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
778 // Attempt to load/run the ABS file...
779 LoadSoftware(vjs
.absROMPath
);
780 #ifndef NEWMODELSBIOSHANDLER
781 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
783 SelectBIOS(vjs
.biosType
);
785 // Prevent the scanner from running...
789 // Load up the default ROM if in Debugger mode:
790 if (vjs
.softTypeDebugger
)
792 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
794 // If regular load failed, try just a straight file load
795 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
797 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
800 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
802 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
804 // Attempt to load/run the ABS file...
805 LoadSoftware(vjs
.absROMPath
);
806 #ifndef NEWMODELSBIOSHANDLER
807 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
808 // Prevent the scanner from running...
810 SelectBIOS(vjs
.biosType
);
815 // Run the scanner if nothing passed in and *not* Alpine mode...
816 // NB: Really need to look into caching the info scanned in here...
817 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
818 scannedSoftwareFolder
= true;
822 void MainWin::LoadFile(QString file
)
828 void MainWin::SyncUI(void)
830 // Set toolbar buttons/menus based on settings read in (sync the UI)...
831 // (Really, this is to sync command line options passed in)
832 blurAct
->setChecked(vjs
.glFilter
);
833 x1Act
->setChecked(zoomLevel
== 1);
834 x2Act
->setChecked(zoomLevel
== 2);
835 x3Act
->setChecked(zoomLevel
== 3);
836 // running = powerAct->isChecked();
837 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
838 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
839 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
841 fullScreenAct
->setChecked(vjs
.fullscreen
);
842 fullScreen
= vjs
.fullscreen
;
843 SetFullScreen(fullScreen
);
845 // Reset the timer to be what was set in the command line (if any):
846 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
847 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
851 void MainWin::closeEvent(QCloseEvent
* event
)
854 // This should only be done by the config dialog
857 event
->accept(); // ignore() if can't close for some reason
861 void MainWin::keyPressEvent(QKeyEvent
* e
)
863 #ifndef VJ_REMOVE_DEV_CODE
865 //extern bool startM68KTracing; // moved to jaguar.h
867 extern int blit_start_log
;
869 extern bool startConciseBlitLogging
;
872 // We ignore the Alt key for now, since it causes problems with the GUI
873 if (e
->key() == Qt::Key_Alt
)
878 // Bar this shite from release versions kthxbai
879 #ifndef VJ_REMOVE_DEV_CODE
880 else if (e
->key() == Qt::Key_F11
)
882 startM68KTracing
= true;
886 else if (e
->key() == Qt::Key_F12
)
888 blit_start_log
= true;
892 else if (e
->key() == Qt::Key_F10
)
894 startConciseBlitLogging
= true;
899 else if (e
->key() == Qt::Key_F8
)
901 // ggn: For extra NYAN pleasure...
902 // ggn: There you go James :P
903 // Shamus: Thanks for the patch! :-D
904 WriteLog(" o + + +\n");
905 WriteLog("+ o o + o\n");
906 WriteLog("-_-_-_-_-_-_-_,------, o \n");
907 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
908 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
909 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
910 WriteLog("+ o o + o\n");
917 This is done now by a QAction...
918 if (e->key() == Qt::Key_F9)
928 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
930 // We ignore the Alt key for now, since it causes problems with the GUI
931 if (e
->key() == Qt::Key_Alt
)
937 HandleKeys(e
, false);
941 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
943 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
944 // We kill bad key combos here, before they can get to the emulator...
945 // This also kills the illegal instruction problem that cropped up in
948 // First, settle key states...
949 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
950 keyHeld
[P1LEFT
] = state
;
951 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
952 keyHeld
[P1RIGHT
] = state
;
953 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
954 keyHeld
[P1UP
] = state
;
955 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
956 keyHeld
[P1DOWN
] = state
;
957 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
958 keyHeld
[P2LEFT
] = state
;
959 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
960 keyHeld
[P2RIGHT
] = state
;
961 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
962 keyHeld
[P2UP
] = state
;
963 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
964 keyHeld
[P2DOWN
] = state
;
966 // Next, check for conflicts and kill 'em if there are any...
967 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
968 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
970 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
971 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
973 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
974 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
976 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
977 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
979 // No bad combos exist now, let's stuff the emulator key buffers...!
980 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
982 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
983 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
985 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
986 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
992 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
994 void MainWin::HandleGamepads(void)
998 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1000 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1001 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
1003 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1004 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1009 void MainWin::Open(void)
1014 void MainWin::Configure(void)
1016 // Call the configuration dialog and update settings
1017 ConfigDialog
dlg(this);
1019 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1020 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1021 dlg
.controllerTab1
->SetupLastUsedProfile();
1022 // maybe instead of this, we tell the controller tab to work on a copy that gets
1023 // written if the user hits 'OK'.
1024 SaveProfiles(); // Just in case user cancels
1026 if (dlg
.exec() == false)
1032 QString before
= vjs
.ROMPath
;
1033 QString alpineBefore
= vjs
.alpineROMPath
;
1034 QString absBefore
= vjs
.absROMPath
;
1035 // bool audioBefore = vjs.audioEnabled;
1036 bool audioBefore
= vjs
.DSPEnabled
;
1037 dlg
.UpdateVJSettings();
1038 QString after
= vjs
.ROMPath
;
1039 QString alpineAfter
= vjs
.alpineROMPath
;
1040 QString absAfter
= vjs
.absROMPath
;
1041 // bool audioAfter = vjs.audioEnabled;
1042 bool audioAfter
= vjs
.DSPEnabled
;
1044 bool allowOld
= allowUnknownSoftware
;
1046 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1047 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1048 AutoConnectProfiles();
1050 // We rescan the "software" folder if the user either changed the path or
1051 // checked/unchecked the "Allow unknown files" option in the config dialog.
1052 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1053 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1055 // If the "Alpine" ROM is changed, then let's load it...
1056 if (alpineBefore
!= alpineAfter
)
1058 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1060 // Oh crap, we couldn't get the file! Alert the media!
1062 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1063 msg
.setIcon(QMessageBox::Warning
);
1068 // If the "ABS" ROM is changed, then let's load it...
1069 if (absBefore
!= absAfter
)
1071 if (!JaguarLoadFile(vjs
.absROMPath
))
1073 // Oh crap, we couldn't get the file! Alert the media!
1075 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1076 msg
.setIcon(QMessageBox::Warning
);
1081 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1082 // since it's running in the host audio IRQ...
1083 if (audioBefore
!= audioAfter
)
1089 // Just in case we crash before a clean exit...
1097 // Here's the main emulator loop
1099 void MainWin::Timer(void)
1102 static uint32_t ntscTickCount
;
1103 if (vjs
.hardwareTypeNTSC
)
1107 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1114 if (showUntunedTankCircuit
)
1116 // Some machines can't handle this, so we give them the option to disable it. :-)
1117 if (!plzDontKillMyComputer
)
1119 // if (!vjs.softTypeDebugger)
1121 // Random hash & trash
1122 // We try to simulate an untuned tank circuit here... :-)
1123 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1125 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1127 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1135 // Otherwise, run the Jaguar simulation
1138 //if (!vjs.softTypeDebugger)
1139 videoWidget
->HandleMouseHiding();
1141 static uint32_t refresh
= 0;
1142 // Do autorefresh on debug windows
1143 // Have to be careful, too much causes the emulator to slow way down!
1144 if (refresh
== vjs
.refresh
)
1146 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1148 AlpineRefreshWindows();
1149 //memBrowseWin->RefreshContents();
1150 //cpuBrowseWin->RefreshContents();
1152 CommonRefreshWindows();
1161 //if (!vjs.softTypeDebugger)
1162 videoWidget
->updateGL();
1165 // Approach: We use a ring buffer to store times (in ms) over a given
1166 // amount of frames, then sum them to figure out the FPS.
1167 uint32_t timestamp
= SDL_GetTicks();
1168 // This assumes the ring buffer size is a power of 2
1169 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1170 // Doing it this way is better. Ring buffer size can be arbitrary then.
1171 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1172 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1173 uint32_t elapsedTime
= 0;
1175 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1176 elapsedTime
+= ringBuffer
[i
];
1178 // elapsedTime must be non-zero
1179 if (elapsedTime
== 0)
1182 // This is in frames per 10 seconds, so we can have 1 decimal
1183 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1184 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1185 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1186 // If this is updated too frequently to be useful, we can throttle it down
1187 // so that it only updates every 10th frame or so
1188 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1189 oldTimestamp
= timestamp
;
1191 if (M68KDebugHaltStatus())
1196 // Toggle the power state, it can be either on or off
1197 void MainWin::TogglePowerState(void)
1199 powerButtonOn
= !powerButtonOn
;
1202 // With the power off, we simulate white noise on the screen. :-)
1205 // Restore the mouse pointer, if hidden:
1206 //if (!vjs.softTypeDebugger)
1208 videoWidget
->CheckAndRestoreMouseCursor();
1211 useCDAct
->setDisabled(false);
1212 palAct
->setDisabled(false);
1213 ntscAct
->setDisabled(false);
1214 pauseAct
->setChecked(false);
1215 pauseAct
->setDisabled(true);
1216 showUntunedTankCircuit
= true;
1218 DACPauseAudioThread();
1219 // This is just in case the ROM we were playing was in a narrow or wide field mode, so the untuned tank sim doesn't look wrong. :-)
1222 if (plzDontKillMyComputer
)
1224 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1225 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1227 if (vjs
.hardwareTypeNTSC
)
1229 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1233 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1240 useCDAct
->setDisabled(true);
1241 palAct
->setDisabled(true);
1242 ntscAct
->setDisabled(true);
1243 pauseAct
->setChecked(false);
1244 pauseAct
->setDisabled(false);
1245 showUntunedTankCircuit
= false;
1247 // Otherwise, we prepare for running regular software...
1250 // Should check for cartridgeLoaded here as well...!
1251 // We can clear it when toggling CDActive on, so that when we power cycle it
1252 // does the expected thing. Otherwise, if we use the file picker to insert a
1253 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1254 // works if the CD unit is active?
1255 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1258 WriteLog("GUI: Resetting Jaguar...\n");
1262 DebuggerResetWindows();
1263 CommonResetWindows();
1264 DACPauseAudioThread(false);
1269 // Toggle the emulator state, it can be either on or off
1270 void MainWin::ToggleRunState(void)
1272 startM68KTracing
= running
;
1278 // Set action buttons for the pause mode
1279 frameAdvanceAct
->setDisabled(false);
1280 pauseAct
->setChecked(true);
1281 pauseAct
->setDisabled(false);
1282 if (vjs
.softTypeDebugger
)
1284 traceStepIntoAct
->setDisabled(false);
1285 traceStepOverAct
->setDisabled(false);
1286 restartAct
->setDisabled(false);
1287 m68kDasmWin
->Use68KPCAddress();
1288 GPUDasmWin
->UseGPUPCAddress();
1289 DSPDasmWin
->UseDSPPCAddress();
1292 //if (!vjs.softTypeDebugger)
1294 // Restore the mouse pointer, if hidden:
1295 videoWidget
->CheckAndRestoreMouseCursor();
1297 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1299 uint32_t pixel
= videoWidget
->buffer
[i
];
1300 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1301 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1302 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1305 videoWidget
->updateGL();
1307 cpuBrowseWin
->HoldBPM();
1308 cpuBrowseWin
->HandleBPMContinue();
1314 frameAdvanceAct
->setDisabled(true);
1315 pauseAct
->setChecked(false);
1316 pauseAct
->setDisabled(false);
1317 if (vjs
.softTypeDebugger
)
1319 traceStepIntoAct
->setDisabled(true);
1320 traceStepOverAct
->setDisabled(true);
1321 restartAct
->setDisabled(true);
1322 BreakpointsWin
->RefreshContents();
1325 cpuBrowseWin
->UnholdBPM();
1328 // Pause/unpause any running/non-running threads...
1329 DACPauseAudioThread(!running
);
1333 void MainWin::SetZoom100(void)
1340 void MainWin::SetZoom200(void)
1347 void MainWin::SetZoom300(void)
1354 void MainWin::SetNTSC(void)
1356 powerAct
->setIcon(powerRed
);
1357 timer
->setInterval(16);
1358 vjs
.hardwareTypeNTSC
= true;
1364 void MainWin::SetPAL(void)
1366 powerAct
->setIcon(powerGreen
);
1367 timer
->setInterval(20);
1368 vjs
.hardwareTypeNTSC
= false;
1374 void MainWin::ToggleBlur(void)
1376 vjs
.glFilter
= !vjs
.glFilter
;
1381 void MainWin::ShowAboutWin(void)
1387 void MainWin::ShowHelpWin(void)
1393 void MainWin::InsertCart(void)
1395 // Check to see if we did autorun, 'cause we didn't load anything in that
1397 if (!scannedSoftwareFolder
)
1399 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1400 scannedSoftwareFolder
= true;
1403 // If the emulator is running, we pause it here and unpause it later
1404 // if we dismiss the file selector without choosing anything
1405 if (running
&& powerButtonOn
)
1408 pauseForFileSelector
= true;
1411 filePickWin
->show();
1415 void MainWin::Unpause(void)
1417 // Here we unpause the emulator if it was paused when we went into the file selector
1418 if (pauseForFileSelector
)
1420 pauseForFileSelector
= false;
1422 // Some nutter might have unpaused while in the file selector, so check for that
1429 // Jaguar initialisation and load software file
1430 void MainWin::LoadSoftware(QString file
)
1432 running
= false; // Prevent bad things(TM) from happening...
1433 pauseForFileSelector
= false; // Reset the file selector pause flag
1435 // Setup BIOS in his own dedicated Jaguar memory
1436 #ifndef NEWMODELSBIOSHANDLER
1437 uint8_t * biosPointer
= jaguarBootROM
;
1439 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1441 biosPointer
= jaguarDevBootROM2
;
1444 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1446 SelectBIOS(vjs
.biosType
);
1449 // Turn 'on' the power to initialize the Jaguar
1450 powerAct
->setDisabled(false);
1451 powerAct
->setChecked(true);
1452 powerButtonOn
= false;
1455 // We have to load our software *after* the Jaguar RESET
1456 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1457 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1459 // This is icky because we've already done it
1460 // it gets worse :-P
1461 if (!vjs
.useJaguarBIOS
)
1463 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1468 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1469 if (vjs
.softTypeDebugger
)
1471 m68k_set_reg(M68K_REG_A6
, 0);
1472 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1473 //pauseAct->setDisabled(false);
1474 //pauseAct->setChecked(true);
1480 // Prevent the launch in case of software without a start address and without BIOS presence
1481 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1487 // Display the Atari Jaguar software which is running
1488 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1490 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1491 setWindowTitle(newTitle
);
1496 void MainWin::ToggleCDUsage(void)
1498 CDActive
= !CDActive
;
1500 // Set up the Jaguar CD for execution, otherwise, clear memory
1502 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1504 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1508 // Open, or display, the breakpoints list window
1509 void MainWin::ShowBreakpointsWin(void)
1511 BreakpointsWin
->show();
1512 BreakpointsWin
->RefreshContents();
1516 // Delete all breakpoints
1517 void MainWin::DeleteAllBreakpoints(void)
1519 cpuBrowseWin
->ResetBPM();
1521 ShowBreakpointsWin();
1525 // Disable all breakpoints
1526 void MainWin::DisableAllBreakpoints(void)
1528 cpuBrowseWin
->DisableBPM();
1530 ShowBreakpointsWin();
1534 // Open, or display, the new breakpoint function window
1535 void MainWin::ShowNewFunctionBreakpointWin(void)
1537 NewFunctionBreakpointWin
->show();
1538 ShowBreakpointsWin();
1542 // Display list of files found in cartridge
1543 void MainWin::ShowCartFilesListWin(void)
1545 CartFilesListWin
->show();
1546 CartFilesListWin
->RefreshContents();
1550 // Display the save dump pickup file
1551 void MainWin::ShowSaveDumpAsWin(void)
1553 SaveDumpAsWin
->show();
1558 void MainWin::DebuggerTraceStepInto(void)
1561 videoWidget
->updateGL();
1564 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1566 #warning "!!! Need to verify the Step Into function !!!"
1571 // Restart the Jaguar executable
1572 void MainWin::DebuggerRestart(void)
1577 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1578 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1580 m68k_set_reg(M68K_REG_A6
, 0);
1581 m68k_brk_hitcounts_reset();
1583 DebuggerResetWindows();
1584 CommonResetWindows();
1587 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1589 #warning "!!! Need to verify the Restart function !!!"
1595 void MainWin::DebuggerTraceStepOver(void)
1598 videoWidget
->updateGL();
1601 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1603 #warning "!!! Need to verify the Step Over function !!!"
1608 // Advance / Execute for one frame
1609 void MainWin::FrameAdvance(void)
1611 //printf("Frame Advance...\n");
1613 // Execute 1 frame, then exit (only useful in Pause mode)
1615 //if (!vjs.softTypeDebugger)
1616 videoWidget
->updateGL();
1618 // Need to execute 1 frames' worth of DSP thread as well :-/
1620 //m68kDasmWin->Use68KPCAddress();
1623 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1625 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1630 void MainWin::SetFullScreen(bool state
/*= true*/)
1632 if (!vjs
.softTypeDebugger
)
1636 mainWinPosition
= pos();
1638 statusBar()->hide();
1644 // This is needed because the fullscreen may happen on a different
1645 // screen than screen 0:
1646 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1647 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1648 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1649 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1650 double aspectRatio
= targetWidth
/ targetHeight
;
1651 // NOTE: Really should check here to see which dimension constrains the
1652 // other. Right now, we assume that height is the constraint.
1653 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1654 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1655 videoWidget
->fullscreen
= true;
1656 videoWidget
->outputWidth
= newWidth
;
1657 videoWidget
->setFixedSize(r
.width(), r
.height());
1662 // Seems Qt is fussy about this: showNormal() has to go first, or it
1663 // will keep the window stuck in a psuedo-fullscreen mode with no way
1664 // to get out of it (except closing the app).
1667 // Reset the video widget to windowed mode
1668 videoWidget
->offset
= 0;
1669 videoWidget
->fullscreen
= false;
1671 statusBar()->show();
1678 move(mainWinPosition
);
1684 void MainWin::ToggleFullScreen(void)
1686 fullScreen
= !fullScreen
;
1687 SetFullScreen(fullScreen
);
1692 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1694 exceptionvectortableBrowseWin
->show();
1695 exceptionvectortableBrowseWin
->RefreshContents();
1700 void MainWin::ShowLocalBrowserWin(void)
1702 LocalBrowseWin
->show();
1703 LocalBrowseWin
->RefreshContents();
1708 void MainWin::ShowCallStackBrowserWin(void)
1710 CallStackBrowseWin
->show();
1711 CallStackBrowseWin
->RefreshContents();
1715 void MainWin::ShowAllWatchBrowserWin(void)
1717 allWatchBrowseWin
->show();
1718 allWatchBrowseWin
->RefreshContents();
1722 void MainWin::ShowHeapAllocatorBrowserWin(void)
1724 heapallocatorBrowseWin
->show();
1725 heapallocatorBrowseWin
->RefreshContents();
1729 void MainWin::ShowMemoryBrowserWin(void)
1731 memBrowseWin
->show();
1732 memBrowseWin
->RefreshContents();
1736 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1738 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1740 mem1BrowseWin
[NumWin
]->show();
1741 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1746 void MainWin::ShowEmuStatusWin(void)
1748 emuStatusWin
->show();
1749 emuStatusWin
->RefreshContents();
1753 void MainWin::ShowStackBrowserWin(void)
1755 stackBrowseWin
->show();
1756 stackBrowseWin
->RefreshContents();
1760 void MainWin::ShowCPUBrowserWin(void)
1762 cpuBrowseWin
->show();
1763 cpuBrowseWin
->RefreshContents();
1767 void MainWin::ShowOPBrowserWin(void)
1769 opBrowseWin
->show();
1770 opBrowseWin
->RefreshContents();
1774 void MainWin::ShowM68KDasmBrowserWin(void)
1776 m68kDasmBrowseWin
->show();
1777 m68kDasmBrowseWin
->RefreshContents();
1781 void MainWin::ShowRISCDasmBrowserWin(void)
1783 riscDasmBrowseWin
->show();
1784 riscDasmBrowseWin
->RefreshContents();
1790 void MainWin::ShowDasmWin(void)
1793 // DasmWin->RefreshContents();
1800 void MainWin::ShowVideoOutputWin(void)
1802 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1803 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1804 //VideoOutputWindowCentrale->show();
1805 //memBrowseWin->show();
1806 //VideoOutputWin->show();
1807 //VideoOutputWin->RefreshContents(videoWidget);
1812 // Resize video window based on zoom factor
1813 // It doesn't apply in debugger mode as we use this window to display disassembly
1814 void MainWin::ResizeMainWindow(void)
1816 if (!vjs
.softTypeDebugger
)
1818 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1820 // Show the test pattern if user requested plzDontKillMyComputer mode
1821 if (!powerButtonOn
&& plzDontKillMyComputer
)
1823 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1825 if (vjs
.hardwareTypeNTSC
)
1827 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1831 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1842 void MainWin::ReadSettings(void)
1846 QSettings
settings("Underground Software", "Virtual Jaguar");
1848 //zoomLevel = settings.value("zoom", 2).toInt();
1849 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1850 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1852 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1853 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1854 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1855 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1856 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1857 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1858 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1859 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1860 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1861 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1862 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1863 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1864 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1865 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1866 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1867 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1868 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1869 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1870 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1871 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1872 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1874 // Read settings from the Debugger mode
1875 settings
.beginGroup("debugger");
1876 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1877 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1878 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1879 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1880 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1881 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1882 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1883 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1884 settings
.endGroup();
1886 // Read settings from the Alpine mode
1887 settings
.beginGroup("alpine");
1888 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1889 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1890 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1891 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1892 settings
.endGroup();
1894 // Read settings from the Keybindings
1895 settings
.beginGroup("keybindings");
1896 for (i
= 0; i
< KB_END
; i
++)
1898 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1900 settings
.endGroup();
1902 // Write important settings to the log file
1903 WriteLog("MainWin: Paths\n");
1904 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1905 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1906 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1907 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1908 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1909 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1910 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1911 WriteLog("MainWin: Misc.\n");
1912 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1915 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1916 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1917 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1918 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1919 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1920 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1921 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1922 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1923 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1924 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1925 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1926 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1927 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1928 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1929 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1930 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1931 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1932 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1933 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1934 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1935 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1936 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1938 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1939 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1940 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1941 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1942 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1943 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1944 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1945 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1946 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1947 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1948 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1949 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1950 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1951 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1952 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1953 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1954 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1955 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1956 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1957 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1958 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1961 WriteLog("Read setting = Done\n");
1963 ReadProfiles(&settings
);
1964 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
1969 // Default values will be used in case of no settings can be found
1971 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1973 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1975 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1976 void MainWin::ReadUISettings(void)
1983 // Point on the emulator settings
1984 QSettings
settings("Underground Software", "Virtual Jaguar");
1985 settings
.beginGroup("ui");
1987 // Emulator main window UI information
1988 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1989 size
= settings
.value("size", QSize(400, 400)).toSize();
1991 move(mainWinPosition
);
1992 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1993 filePickWin
->move(pos
);
1995 // Video output information
1996 zoomLevel
= settings
.value("zoom", 2).toInt();
1998 // Emulator status UI information
1999 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2000 emuStatusWin
->move(pos
);
2001 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2003 // Alpine debug UI information (also needed by the Debugger)
2004 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2006 // CPU registers UI information
2007 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
2008 cpuBrowseWin
->move(pos
);
2009 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
2011 // Memory browser UI information
2012 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
2013 memBrowseWin
->move(pos
);
2014 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
2016 // Stack browser UI information
2017 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
2018 stackBrowseWin
->move(pos
);
2019 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2020 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2021 stackBrowseWin
->resize(size
);
2023 // OP (Object Processor) UI information
2024 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2025 opBrowseWin
->move(pos
);
2026 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2027 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2028 opBrowseWin
->resize(size
);
2030 // RISC disassembly UI information
2031 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2032 riscDasmBrowseWin
->move(pos
);
2033 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2035 // M68k disassembly UI information
2036 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2037 m68kDasmBrowseWin
->move(pos
);
2038 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2040 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2042 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2046 // Debugger UI information
2047 if (vjs
.softTypeDebugger
)
2050 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2051 m68kDasmWin
->move(pos
);
2052 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2053 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2054 GPUDasmWin
->move(pos
);
2055 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2056 DSPDasmWin
->move(pos
);
2058 // All watch browser UI information
2059 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2060 allWatchBrowseWin
->move(pos
);
2061 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2062 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2063 allWatchBrowseWin
->resize(size
);
2065 // Local browser UI information
2066 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2067 LocalBrowseWin
->move(pos
);
2068 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2069 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2070 LocalBrowseWin
->resize(size
);
2072 // Heap memory allocation browser UI information
2073 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2074 heapallocatorBrowseWin
->move(pos
);
2075 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2076 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2077 heapallocatorBrowseWin
->resize(size
);
2079 // Exception Vector Table UI Information
2080 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2081 exceptionvectortableBrowseWin
->move(pos
);
2082 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2083 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2084 exceptionvectortableBrowseWin
->resize(size
);
2086 // Call Stack browser UI information
2087 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2088 CallStackBrowseWin
->move(pos
);
2089 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2090 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2091 CallStackBrowseWin
->resize(size
);
2093 // cartridge directory and files UI information
2094 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2095 CartFilesListWin
->move(pos
);
2096 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2097 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2098 CartFilesListWin
->resize(size
);
2100 // Save dump UI information
2101 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2102 SaveDumpAsWin
->move(pos
);
2103 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2104 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2105 SaveDumpAsWin
->resize(size
);
2107 // Breakpoints UI information
2108 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2109 BreakpointsWin
->move(pos
);
2110 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2111 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2112 BreakpointsWin
->resize(size
);
2113 // New function breakpoint UI information
2114 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2115 NewFunctionBreakpointWin
->move(pos
);
2116 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2117 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2118 NewFunctionBreakpointWin
->resize(size
);
2120 // Memories browser UI information
2121 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2123 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2124 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2125 mem1BrowseWin
[i
]->move(pos
);
2126 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2127 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2128 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2129 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2130 mem1BrowseWin
[i
]->resize(size
);
2134 settings
.endGroup();
2136 WriteLog("Read UI setting = Done\n");
2140 // Save the settings
2141 void MainWin::WriteSettings(void)
2145 // Point on the emulator settings
2146 QSettings
settings("Underground Software", "Virtual Jaguar");
2147 //settings.setValue("pos", pos());
2148 //settings.setValue("size", size());
2149 //settings.setValue("cartLoadPos", filePickWin->pos());
2151 //settings.setValue("zoom", zoomLevel);
2152 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2153 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2155 settings
.setValue("useJoystick", vjs
.useJoystick
);
2156 settings
.setValue("joyport", vjs
.joyport
);
2157 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2158 settings
.setValue("frameSkip", vjs
.frameSkip
);
2159 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2160 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2161 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2162 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2163 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2164 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2165 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2166 settings
.setValue("fullscreen", vjs
.fullscreen
);
2167 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2168 settings
.setValue("glFilterType", vjs
.glFilter
);
2169 settings
.setValue("renderType", vjs
.renderType
);
2170 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2171 settings
.setValue("biosType", vjs
.biosType
);
2172 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2173 //settings.setValue("JagBootROM", vjs.jagBootPath);
2174 //settings.setValue("CDBootROM", vjs.CDBootPath);
2175 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2176 settings
.setValue("ROMs", vjs
.ROMPath
);
2177 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2179 // Write settings from the Alpine mode
2180 settings
.beginGroup("alpine");
2181 settings
.setValue("refresh", vjs
.refresh
);
2182 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2183 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2184 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2185 settings
.endGroup();
2187 // Write settings from the Debugger mode
2188 settings
.beginGroup("debugger");
2189 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2190 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2191 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2192 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2193 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2194 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2195 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2196 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2197 settings
.endGroup();
2199 // Write settings from the Keybindings
2200 settings
.beginGroup("keybindings");
2201 for (i
= 0; i
< KB_END
; i
++)
2203 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2205 settings
.endGroup();
2208 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2209 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2210 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2211 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2212 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2213 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2214 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2215 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2216 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2217 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2218 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2219 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2220 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2221 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2222 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2223 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2224 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2225 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2226 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2227 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2228 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2230 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2231 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2232 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2233 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2234 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2235 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2236 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2237 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2238 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2239 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2240 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2241 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2242 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2243 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2244 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2245 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2246 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2247 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2248 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2249 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2250 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2253 WriteProfiles(&settings
);
2254 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2258 // Save the UI settings
2259 void MainWin::WriteUISettings(void)
2264 // Point on the emulator settings
2265 QSettings
settings("Underground Software", "Virtual Jaguar");
2266 settings
.beginGroup("ui");
2268 // Emulator UI information
2269 settings
.setValue("pos", pos());
2270 settings
.setValue("size", size());
2271 settings
.setValue("cartLoadPos", filePickWin
->pos());
2273 // Video output information
2274 settings
.setValue("zoom", zoomLevel
);
2276 // Common UI information
2277 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2278 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2280 // Alpine debug UI information (also needed by the Debugger)
2281 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2283 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2284 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2285 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2286 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2287 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2288 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2289 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2290 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2291 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2292 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2293 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2294 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2295 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2296 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2299 // Debugger UI information
2300 if (vjs
.softTypeDebugger
)
2303 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2304 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2305 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2306 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2308 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2309 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2310 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2311 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2312 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2313 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2314 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2315 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2316 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2317 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2318 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2319 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2320 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2321 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2322 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2323 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2324 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2325 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2326 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2327 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2328 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2329 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2330 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2331 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2332 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2333 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2334 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2336 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2338 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2339 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2340 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2341 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2342 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2343 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2347 settings
.endGroup();
2351 // Refresh alpine debug windows
2352 void MainWin::AlpineRefreshWindows(void)
2354 cpuBrowseWin
->RefreshContents();
2355 memBrowseWin
->RefreshContents();
2356 stackBrowseWin
->RefreshContents();
2357 opBrowseWin
->RefreshContents();
2358 riscDasmBrowseWin
->RefreshContents();
2359 m68kDasmBrowseWin
->RefreshContents();
2364 void MainWin::CommonResetWindows(void)
2370 void MainWin::CommonReset(void)
2375 // Reset soft debugger
2376 void MainWin::DebuggerReset(void)
2378 if (vjs
.softTypeDebugger
)
2380 DeleteAllBreakpoints();
2385 // Reset soft debugger windows
2386 void MainWin::DebuggerResetWindows(void)
2388 if (vjs
.softTypeDebugger
)
2390 FilesrcListWin
->Reset();
2391 allWatchBrowseWin
->Reset();
2392 heapallocatorBrowseWin
->Reset();
2393 BreakpointsWin
->Reset();
2394 CartFilesListWin
->Reset();
2395 //ResetAlpineWindows();
2400 // Refresh common windows
2401 void MainWin::CommonRefreshWindows(void)
2403 emuStatusWin
->RefreshContents();
2407 // Refresh view windows
2408 void MainWin::ViewRefreshWindows(void)
2410 CartFilesListWin
->RefreshContents();
2415 void MainWin::RefreshWindows(void)
2417 DebuggerRefreshWindows();
2418 CommonRefreshWindows();
2422 // Refresh soft debugger & alpine debug windows
2423 void MainWin::DebuggerRefreshWindows(void)
2425 if (vjs
.softTypeDebugger
)
2427 FilesrcListWin
->RefreshContents();
2428 m68kDasmWin
->RefreshContents();
2429 GPUDasmWin
->RefreshContents();
2430 DSPDasmWin
->RefreshContents();
2431 allWatchBrowseWin
->RefreshContents();
2432 LocalBrowseWin
->RefreshContents();
2433 CallStackBrowseWin
->RefreshContents();
2434 heapallocatorBrowseWin
->RefreshContents();
2435 BreakpointsWin
->RefreshContents();
2436 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2438 mem1BrowseWin
[i
]->RefreshContents(i
);
2441 AlpineRefreshWindows();
2442 ViewRefreshWindows();
2447 // Create and save screenshot
2448 void MainWin::MakeScreenshot(void)
2452 time_t now
= time(0);
2456 tstruct
= *localtime(&now
);
2457 sprintf(Text
, "%svj_%i%i%i_%i%i%i.jpg", vjs
.screenshotPath
, tstruct
.tm_year
, tstruct
.tm_mon
, tstruct
.tm_mday
, tstruct
.tm_hour
, tstruct
.tm_min
, tstruct
.tm_sec
);
2459 // Create screenshot
2460 screenshot
= videoWidget
->grabFrameBuffer();
2461 screenshot
.save((char *)Text
, "JPG", 100);