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, cartdridge 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
30 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
31 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
32 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
33 // with 'R', etc) [DONE]
34 // - Controller configuration [DONE]
38 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
39 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
40 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
43 // SFDX CODE: S1E9T8H5M23YS
45 // Uncomment this for debugging...
47 //#define DEBUGFOO // Various tool debugging... but not used
48 //#define DEBUGTP // Toolpalette debugging... but not used
55 #include "configdialog.h"
56 #include "controllertab.h"
57 #include "keybindingstab.h"
58 #include "filepicker.h"
60 #include "generaltab.h"
66 #include "emustatus.h"
67 #include "debug/cpubrowser.h"
68 #include "debug/m68kdasmbrowser.h"
69 #include "debug/memorybrowser.h"
70 #include "debug/stackbrowser.h"
71 #include "debug/opbrowser.h"
72 #include "debug/riscdasmbrowser.h"
78 #ifndef NEWMODELSBIOSHANDLER
81 #include "jagstub2bios.h"
83 #include "modelsBIOS.h"
85 #include "jagcdbios.h"
87 #include "m68000/m68kinterface.h"
89 #include "debugger/DBGManager.h"
90 //#include "debugger/VideoWin.h"
91 //#include "debugger/DasmWin.h"
92 #include "debugger/m68KDasmWin.h"
93 #include "debugger/GPUDasmWin.h"
94 #include "debugger/DSPDasmWin.h"
95 #include "debugger/memory1browser.h"
96 #include "debugger/BreakpointsWin.h"
97 #include "debugger/NewFnctBreakpointWin.h"
98 #include "debugger/FilesrcListWin.h"
99 #include "debugger/exceptionvectortablebrowser.h"
100 #include "debugger/allwatchbrowser.h"
101 #include "debugger/localbrowser.h"
102 #include "debugger/heapallocatorbrowser.h"
103 #include "debugger/callstackbrowser.h"
104 #include "debugger/CartFilesListWin.h"
105 #include "debugger/SaveDumpAsWin.h"
108 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
109 //#ifdef __GCCWIN32__
110 // Apparently on win32, usleep() is not pulled in by the usual suspects.
114 #include "_MSC_VER/unistd.h"
118 // The way BSNES controls things is by setting a timer with a zero
119 // timeout, sleeping if not emulating anything. Seems there has to be a
122 // It has a novel approach to plugging-in/using different video/audio/input
123 // methods, can we do something similar or should we just use the built-in
126 // We're going to try to use the built-in OpenGL support and see how it goes.
127 // We'll make the VJ core modular so that it doesn't matter what GUI is in
128 // use, we can drop it in anywhere and use it as-is.
130 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
131 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
132 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
138 for(int i
=0; i
<8; i
++)
142 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
145 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
148 //if (vjs.softTypeDebugger)
150 // mainWindowCentrale = new QMdiArea;
151 // setCentralWidget(mainWindowCentrale);
154 WriteLog("Window creation start\n");
157 videoWidget
= new GLWidget(this);
158 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
160 // set central output window
161 if (!vjs
.softTypeDebugger
)
163 setCentralWidget(videoWidget
);
167 mainWindowCentrale
= new QMdiArea(this);
168 setCentralWidget(mainWindowCentrale
);
171 setWindowIcon(QIcon(":/res/vj-icon.png"));
173 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
175 if (vjs
.hardwareTypeAlpine
)
176 title
+= QString(tr(" - Alpine Mode"));
178 if (vjs
.softTypeDebugger
)
179 title
+= QString(tr(" - Debugger Mode"));
181 setWindowTitle(title
);
183 aboutWin
= new AboutWindow(this);
184 helpWin
= new HelpWindow(this);
185 filePickWin
= new FilePickerWindow(this);
186 memBrowseWin
= new MemoryBrowserWindow(this);
187 stackBrowseWin
= new StackBrowserWindow(this);
188 emuStatusWin
= new EmuStatusWindow(this);
189 cpuBrowseWin
= new CPUBrowserWindow(this);
190 opBrowseWin
= new OPBrowserWindow(this);
191 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
192 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
193 if (vjs
.softTypeDebugger
)
195 //VideoOutputWin = new VideoOutputWindow(this);
196 //VideoOutputWin->setCentralWidget()
197 //DasmWin = new DasmWindow();
198 //DasmWin = new DasmWindow(this);
199 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
200 LocalBrowseWin
= new LocalBrowserWindow(this);
201 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
202 BreakpointsWin
= new BreakpointsWindow(this);
203 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
204 SaveDumpAsWin
= new SaveDumpAsWindow(this);
205 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
206 CallStackBrowseWin
= new CallStackBrowserWindow(this);
207 CartFilesListWin
= new CartFilesListWindow(this);
209 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
211 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
213 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
215 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
217 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
220 // Setup dock to display source code filenames tree
221 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
222 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
224 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
225 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
226 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
228 // Setup dock to display disassembly
229 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
230 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
231 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
232 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
233 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
235 dasmtabWidget
= new QTabWidget(this);
238 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
239 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
240 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
241 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
243 setCentralWidget(dasmtabWidget
);
247 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
248 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
250 setUnifiedTitleAndToolBarOnMac(true);
253 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
254 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
255 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
256 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
257 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
260 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
261 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
262 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
263 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
264 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
265 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
266 powerAct
->setCheckable(true);
267 powerAct
->setChecked(false);
268 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
272 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
273 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
274 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
275 pauseAct
->setStatusTip(tr("Toggles the running state"));
276 pauseAct
->setCheckable(true);
277 pauseAct
->setDisabled(true);
278 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
279 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
280 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
283 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
284 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
285 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
286 screenshotAct
->setCheckable(false);
287 screenshotAct
->setDisabled(false);
288 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
291 zoomActs
= new QActionGroup(this);
292 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
293 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
294 x1Act
->setCheckable(true);
295 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
296 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
297 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
298 x2Act
->setCheckable(true);
299 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
300 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
301 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
302 x3Act
->setCheckable(true);
303 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
306 tvTypeActs
= new QActionGroup(this);
307 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
308 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
309 ntscAct
->setCheckable(true);
310 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
311 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
312 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
313 palAct
->setCheckable(true);
314 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
317 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
318 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
319 blurAct
= new QAction(blur
, tr("Blur"), this);
320 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
321 blurAct
->setCheckable(true);
322 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
325 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
326 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
327 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
330 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
331 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
332 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
334 // File pickup action
335 if (!vjs
.softTypeDebugger
)
337 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
338 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
342 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
343 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
345 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
346 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
347 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
349 // Configuration action
350 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
351 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
352 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
353 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
354 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
356 // Emulation status action
357 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
358 emustatusAct
->setStatusTip(tr("Emulator status"));
359 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
360 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
361 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
364 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
365 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
366 useCDAct
->setCheckable(true);
367 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
369 // Frame advance action
370 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
371 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
372 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
373 frameAdvanceAct
->setDisabled(true);
374 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
377 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
378 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
379 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
380 fullScreenAct
->setCheckable(true);
381 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
383 // Actions dedicated to debugger mode
384 if (vjs
.softTypeDebugger
)
387 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
388 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
389 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
390 restartAct
->setCheckable(false);
391 restartAct
->setDisabled(true);
392 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
395 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
396 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
397 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
398 traceStepOverAct
->setCheckable(false);
399 traceStepOverAct
->setDisabled(true);
400 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
402 // Trace into tracing
403 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
404 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
405 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
406 traceStepIntoAct
->setCheckable(false);
407 traceStepIntoAct
->setDisabled(true);
408 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
410 // Function breakpoint
411 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
412 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
413 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
414 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
415 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
416 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
417 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
418 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
419 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
420 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
421 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
424 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
425 saveDumpAsAct
->setCheckable(false);
426 saveDumpAsAct
->setDisabled(false);
427 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
429 //VideoOutputAct = new QAction(tr("Output Video"), this);
430 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
431 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
433 //DasmAct = new QAction(tr("Disassembly"), this);
434 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
435 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
437 // Exception vector table window
438 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
439 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
440 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
442 // All watch variables window
443 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
444 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
445 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
447 // Local variables window
448 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
449 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
450 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
452 // Heap (memory) allocation window
453 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
454 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
455 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
458 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
459 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
460 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
463 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
464 CartFilesListAct
->setStatusTip(tr("List of the files in the cartdridge's directory"));
465 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
468 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
469 QSignalMapper
*signalMapper
= new QSignalMapper(this);
471 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
473 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
475 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
478 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
479 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
480 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
481 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
482 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
483 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
487 // Memory browser window action
488 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
489 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
490 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
492 // Stack browser window action
493 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
494 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
495 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
497 // CPUs (M68000, GPU & DSP browser window action
498 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
499 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
500 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
502 // OP browser window action
503 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
504 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
505 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
507 // M68000 disassembly browser window
508 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
509 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
510 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
512 // Risc (DSP / GPU) disassembly browser window
513 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
514 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
515 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
517 // Misc. connections...
518 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
519 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
523 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
524 fileMenu
->addAction(powerAct
);
525 if (!vjs
.softTypeDebugger
)
527 fileMenu
->addAction(pauseAct
);
528 // fileMenu->addAction(frameAdvanceAct);
530 fileMenu
->addAction(filePickAct
);
531 fileMenu
->addAction(useCDAct
);
532 fileMenu
->addAction(configAct
);
533 fileMenu
->addAction(emustatusAct
);
534 fileMenu
->addSeparator();
535 fileMenu
->addAction(quitAppAct
);
537 // Alpine and debugger menus
538 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
540 // Create debug & view menu
541 debugMenu
= menuBar()->addMenu(tr("&Debug"));
542 viewMenu
= menuBar()->addMenu(tr("&View"));
544 // Create debugger menu
545 if (vjs
.softTypeDebugger
)
548 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
549 viewCartMenu
->addAction(CartFilesListAct
);
551 viewCartMenu
->addSeparator();
552 viewCartMenu
->addAction(CartStreamsAct
);
556 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
557 debugWindowsMenu
->addAction(BreakpointsAct
);
558 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
559 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
560 debugWindowsMenu
->addSeparator();
562 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
563 debugWindowOutputMenu
->addAction(VideoOutputAct
);
564 debugWindowsMenu
->addSeparator();
566 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
567 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
568 debugWindowsMenu
->addAction(LocalBrowseAct
);
569 debugWindowsMenu
->addSeparator();
570 debugWindowsMenu
->addAction(CallStackBrowseAct
);
571 debugWindowsMenu
->addSeparator();
572 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
573 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
574 debugWindowsMemoryMenu
->addSeparator();
575 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
577 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
579 debugWindowsMenu
->addSeparator();
580 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
581 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
582 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
583 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
584 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
585 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
586 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
587 debugMenu
->addSeparator();
588 debugMenu
->addAction(pauseAct
);
589 debugMenu
->addAction(frameAdvanceAct
);
590 debugMenu
->addAction(restartAct
);
591 debugMenu
->addSeparator();
592 debugMenu
->addAction(traceStepIntoAct
);
593 debugMenu
->addAction(traceStepOverAct
);
594 debugMenu
->addSeparator();
595 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
596 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
597 debugMenu
->addAction(deleteAllBreakpointsAct
);
598 debugMenu
->addAction(disableAllBreakpointsAct
);
599 debugMenu
->addSeparator();
600 debugMenu
->addAction(saveDumpAsAct
);
602 debugMenu
->addSeparator();
603 debugMenu
->addAction(DasmAct
);
608 // Create alpine menu
609 debugMenu
->addAction(memBrowseAct
);
610 debugMenu
->addAction(stackBrowseAct
);
611 debugMenu
->addAction(cpuBrowseAct
);
612 debugMenu
->addAction(opBrowseAct
);
613 debugMenu
->addAction(m68kDasmBrowseAct
);
614 debugMenu
->addAction(riscDasmBrowseAct
);
619 helpMenu
= menuBar()->addMenu(tr("&Help"));
620 helpMenu
->addAction(helpAct
);
621 helpMenu
->addAction(aboutAct
);
625 toolbar
= addToolBar(tr("System"));
626 toolbar
->addAction(powerAct
);
627 if (!vjs
.softTypeDebugger
)
629 toolbar
->addAction(pauseAct
);
630 toolbar
->addAction(frameAdvanceAct
);
632 toolbar
->addAction(filePickAct
);
633 toolbar
->addAction(useCDAct
);
634 toolbar
->addSeparator();
635 if (!vjs
.softTypeDebugger
)
637 toolbar
->addAction(screenshotAct
);
638 toolbar
->addSeparator();
639 toolbar
->addAction(x1Act
);
640 toolbar
->addAction(x2Act
);
641 toolbar
->addAction(x3Act
);
642 toolbar
->addSeparator();
643 toolbar
->addAction(ntscAct
);
644 toolbar
->addAction(palAct
);
645 toolbar
->addSeparator();
646 toolbar
->addAction(blurAct
);
647 toolbar
->addAction(fullScreenAct
);
651 debuggerbar
= addToolBar(tr("&Debugger"));
652 debuggerbar
->addAction(pauseAct
);
653 debuggerbar
->addAction(frameAdvanceAct
);
654 debuggerbar
->addAction(restartAct
);
655 debuggerbar
->addSeparator();
656 debuggerbar
->addAction(traceStepIntoAct
);
657 debuggerbar
->addAction(traceStepOverAct
);
658 debuggerbar
->addSeparator();
659 debuggerbar
->addAction(BreakpointsAct
);
662 if (vjs
.hardwareTypeAlpine
)
664 debugbar
= addToolBar(tr("&Debug"));
665 debugbar
->addAction(memBrowseAct
);
666 debugbar
->addAction(stackBrowseAct
);
667 debugbar
->addAction(cpuBrowseAct
);
668 debugbar
->addAction(opBrowseAct
);
669 debugbar
->addAction(m68kDasmBrowseAct
);
670 debugbar
->addAction(riscDasmBrowseAct
);
673 // Add actions to the main window, as hiding widgets with them
675 addAction(fullScreenAct
);
676 addAction(quitAppAct
);
677 addAction(configAct
);
678 addAction(emustatusAct
);
680 addAction(filePickAct
);
681 addAction(frameAdvanceAct
);
684 statusBar()->showMessage(tr("Ready"));
686 // Do this in case original size isn't correct (mostly for the first-run case)
689 WriteLog("Window creation done\n");
691 // Create our test pattern NTSC bitmap
692 WriteLog("Test pattern 1 bitmap\n");
694 QImage
tempImg(":/res/test-pattern.jpg");
695 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
697 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
699 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
701 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
703 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
704 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
708 // Create our test pattern PAL bitmap
709 WriteLog("Test pattern 2 bitmap\n");
711 QImage
tempImg2(":/res/test-pattern-pal.jpg");
712 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
714 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
716 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
718 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
720 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
721 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
725 // Set up timer based loop for animation...
726 timer
= new QTimer(this);
727 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
729 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
730 // This is because it's discarding the 0.6666... on the end of the fraction.
731 // Alas, 6 doesn't divide cleanly into 10. :-P
732 //Should we defer this until SyncUI? Probably.
733 //No, it doesn't work, because it uses setInterval() instead of start()...
734 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
736 // We set this initially, to make VJ behave somewhat as it would if no
737 // cart were inserted and the BIOS was set as active...
738 jaguarCartInserted
= true;
739 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
740 WriteLog("VJ: Initializing jaguar subsystem...\n");
743 #ifndef NEWMODELSBIOSHANDLER
744 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
745 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
747 SelectBIOS(vjs
.biosType
);
750 // Prevent the file scanner from running if filename passed
751 // in on the command line...
755 // Load up the default ROM if in Alpine mode:
756 if (vjs
.hardwareTypeAlpine
)
758 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
760 // If regular load failed, try just a straight file load
761 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
763 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
766 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
768 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
770 // Attempt to load/run the ABS file...
771 LoadSoftware(vjs
.absROMPath
);
772 #ifndef NEWMODELSBIOSHANDLER
773 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
775 SelectBIOS(vjs
.biosType
);
777 // Prevent the scanner from running...
781 // Load up the default ROM if in Debugger mode:
782 if (vjs
.softTypeDebugger
)
784 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
786 // If regular load failed, try just a straight file load
787 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
789 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
792 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
794 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
796 // Attempt to load/run the ABS file...
797 LoadSoftware(vjs
.absROMPath
);
798 #ifndef NEWMODELSBIOSHANDLER
799 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
800 // Prevent the scanner from running...
802 SelectBIOS(vjs
.biosType
);
807 // Run the scanner if nothing passed in and *not* Alpine mode...
808 // NB: Really need to look into caching the info scanned in here...
809 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
810 scannedSoftwareFolder
= true;
814 void MainWin::LoadFile(QString file
)
820 void MainWin::SyncUI(void)
822 // Set toolbar buttons/menus based on settings read in (sync the UI)...
823 // (Really, this is to sync command line options passed in)
824 blurAct
->setChecked(vjs
.glFilter
);
825 x1Act
->setChecked(zoomLevel
== 1);
826 x2Act
->setChecked(zoomLevel
== 2);
827 x3Act
->setChecked(zoomLevel
== 3);
828 // running = powerAct->isChecked();
829 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
830 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
831 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
833 fullScreenAct
->setChecked(vjs
.fullscreen
);
834 fullScreen
= vjs
.fullscreen
;
835 SetFullScreen(fullScreen
);
837 // Reset the timer to be what was set in the command line (if any):
838 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
839 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
843 void MainWin::closeEvent(QCloseEvent
* event
)
846 // This should only be done by the config dialog
849 event
->accept(); // ignore() if can't close for some reason
853 void MainWin::keyPressEvent(QKeyEvent
* e
)
855 #ifndef VJ_REMOVE_DEV_CODE
857 //extern bool startM68KTracing; // moved to jaguar.h
859 extern int blit_start_log
;
861 extern bool startConciseBlitLogging
;
864 // We ignore the Alt key for now, since it causes problems with the GUI
865 if (e
->key() == Qt::Key_Alt
)
870 // Bar this shite from release versions kthxbai
871 #ifndef VJ_REMOVE_DEV_CODE
872 else if (e
->key() == Qt::Key_F11
)
874 startM68KTracing
= true;
878 else if (e
->key() == Qt::Key_F12
)
880 blit_start_log
= true;
884 else if (e
->key() == Qt::Key_F10
)
886 startConciseBlitLogging
= true;
891 else if (e
->key() == Qt::Key_F8
)
893 // ggn: For extra NYAN pleasure...
894 // ggn: There you go James :P
895 // Shamus: Thanks for the patch! :-D
896 WriteLog(" o + + +\n");
897 WriteLog("+ o o + o\n");
898 WriteLog("-_-_-_-_-_-_-_,------, o \n");
899 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
900 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
901 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
902 WriteLog("+ o o + o\n");
909 This is done now by a QAction...
910 if (e->key() == Qt::Key_F9)
920 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
922 // We ignore the Alt key for now, since it causes problems with the GUI
923 if (e
->key() == Qt::Key_Alt
)
929 HandleKeys(e
, false);
933 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
935 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
936 // We kill bad key combos here, before they can get to the emulator...
937 // This also kills the illegal instruction problem that cropped up in
940 // First, settle key states...
941 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
942 keyHeld
[P1LEFT
] = state
;
943 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
944 keyHeld
[P1RIGHT
] = state
;
945 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
946 keyHeld
[P1UP
] = state
;
947 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
948 keyHeld
[P1DOWN
] = state
;
949 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
950 keyHeld
[P2LEFT
] = state
;
951 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
952 keyHeld
[P2RIGHT
] = state
;
953 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
954 keyHeld
[P2UP
] = state
;
955 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
956 keyHeld
[P2DOWN
] = state
;
958 // Next, check for conflicts and kill 'em if there are any...
959 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
960 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
962 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
963 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
965 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
966 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
968 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
969 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
971 // No bad combos exist now, let's stuff the emulator key buffers...!
972 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
974 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
975 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
977 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
978 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
984 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
986 void MainWin::HandleGamepads(void)
990 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
992 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
993 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
995 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
996 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1001 void MainWin::Open(void)
1006 void MainWin::Configure(void)
1008 // Call the configuration dialog and update settings
1009 ConfigDialog
dlg(this);
1011 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1012 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1013 dlg
.controllerTab1
->SetupLastUsedProfile();
1014 // maybe instead of this, we tell the controller tab to work on a copy that gets
1015 // written if the user hits 'OK'.
1016 SaveProfiles(); // Just in case user cancels
1018 if (dlg
.exec() == false)
1024 QString before
= vjs
.ROMPath
;
1025 QString alpineBefore
= vjs
.alpineROMPath
;
1026 QString absBefore
= vjs
.absROMPath
;
1027 // bool audioBefore = vjs.audioEnabled;
1028 bool audioBefore
= vjs
.DSPEnabled
;
1029 dlg
.UpdateVJSettings();
1030 QString after
= vjs
.ROMPath
;
1031 QString alpineAfter
= vjs
.alpineROMPath
;
1032 QString absAfter
= vjs
.absROMPath
;
1033 // bool audioAfter = vjs.audioEnabled;
1034 bool audioAfter
= vjs
.DSPEnabled
;
1036 bool allowOld
= allowUnknownSoftware
;
1038 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1039 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1040 AutoConnectProfiles();
1042 // We rescan the "software" folder if the user either changed the path or
1043 // checked/unchecked the "Allow unknown files" option in the config dialog.
1044 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1045 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1047 // If the "Alpine" ROM is changed, then let's load it...
1048 if (alpineBefore
!= alpineAfter
)
1050 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1052 // Oh crap, we couldn't get the file! Alert the media!
1054 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1055 msg
.setIcon(QMessageBox::Warning
);
1060 // If the "ABS" ROM is changed, then let's load it...
1061 if (absBefore
!= absAfter
)
1063 if (!JaguarLoadFile(vjs
.absROMPath
))
1065 // Oh crap, we couldn't get the file! Alert the media!
1067 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1068 msg
.setIcon(QMessageBox::Warning
);
1073 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1074 // since it's running in the host audio IRQ...
1075 if (audioBefore
!= audioAfter
)
1081 // Just in case we crash before a clean exit...
1084 DebuggerRefreshWindows();
1089 // Here's the main emulator loop
1091 void MainWin::Timer(void)
1094 static uint32_t ntscTickCount
;
1095 if (vjs
.hardwareTypeNTSC
)
1099 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1106 if (showUntunedTankCircuit
)
1108 // Some machines can't handle this, so we give them the option to disable it. :-)
1109 if (!plzDontKillMyComputer
)
1111 // if (!vjs.softTypeDebugger)
1113 // Random hash & trash
1114 // We try to simulate an untuned tank circuit here... :-)
1115 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1117 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1119 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1127 // Otherwise, run the Jaguar simulation
1130 //if (!vjs.softTypeDebugger)
1131 videoWidget
->HandleMouseHiding();
1133 static uint32_t refresh
= 0;
1134 // Do autorefresh on debug windows
1135 // Have to be careful, too much causes the emulator to slow way down!
1136 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1138 if (refresh
== vjs
.refresh
)
1140 AlpineRefreshWindows();
1141 //memBrowseWin->RefreshContents();
1142 //cpuBrowseWin->RefreshContents();
1150 //if (!vjs.softTypeDebugger)
1151 videoWidget
->updateGL();
1154 // Approach: We use a ring buffer to store times (in ms) over a given
1155 // amount of frames, then sum them to figure out the FPS.
1156 uint32_t timestamp
= SDL_GetTicks();
1157 // This assumes the ring buffer size is a power of 2
1158 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1159 // Doing it this way is better. Ring buffer size can be arbitrary then.
1160 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1161 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1162 uint32_t elapsedTime
= 0;
1164 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1165 elapsedTime
+= ringBuffer
[i
];
1167 // elapsedTime must be non-zero
1168 if (elapsedTime
== 0)
1171 // This is in frames per 10 seconds, so we can have 1 decimal
1172 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1173 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1174 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1175 // If this is updated too frequently to be useful, we can throttle it down
1176 // so that it only updates every 10th frame or so
1177 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1178 oldTimestamp
= timestamp
;
1180 if (M68KDebugHaltStatus())
1185 // Toggle the power state, it can be either on or off
1186 void MainWin::TogglePowerState(void)
1188 powerButtonOn
= !powerButtonOn
;
1191 // With the power off, we simulate white noise on the screen. :-)
1194 // Restore the mouse pointer, if hidden:
1195 //if (!vjs.softTypeDebugger)
1197 videoWidget
->CheckAndRestoreMouseCursor();
1200 useCDAct
->setDisabled(false);
1201 palAct
->setDisabled(false);
1202 ntscAct
->setDisabled(false);
1203 pauseAct
->setChecked(false);
1204 pauseAct
->setDisabled(true);
1205 showUntunedTankCircuit
= true;
1207 DACPauseAudioThread();
1208 // 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. :-)
1211 if (plzDontKillMyComputer
)
1213 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1214 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1216 if (vjs
.hardwareTypeNTSC
)
1218 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1222 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1229 useCDAct
->setDisabled(true);
1230 palAct
->setDisabled(true);
1231 ntscAct
->setDisabled(true);
1232 pauseAct
->setChecked(false);
1233 pauseAct
->setDisabled(false);
1234 showUntunedTankCircuit
= false;
1236 // Otherwise, we prepare for running regular software...
1239 // Should check for cartridgeLoaded here as well...!
1240 // We can clear it when toggling CDActive on, so that when we power cycle it
1241 // does the expected thing. Otherwise, if we use the file picker to insert a
1242 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1243 // works if the CD unit is active?
1244 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1247 WriteLog("GUI: Resetting Jaguar...\n");
1250 DebuggerResetWindows();
1251 DACPauseAudioThread(false);
1256 // Toggle the emulator state, it can be either on or off
1257 void MainWin::ToggleRunState(void)
1259 startM68KTracing
= running
;
1265 // Set action buttons for the pause mode
1266 frameAdvanceAct
->setDisabled(false);
1267 pauseAct
->setChecked(true);
1268 pauseAct
->setDisabled(false);
1269 if (vjs
.softTypeDebugger
)
1271 traceStepIntoAct
->setDisabled(false);
1272 traceStepOverAct
->setDisabled(false);
1273 restartAct
->setDisabled(false);
1274 m68kDasmWin
->Use68KPCAddress();
1275 GPUDasmWin
->UseGPUPCAddress();
1276 DSPDasmWin
->UseDSPPCAddress();
1279 //if (!vjs.softTypeDebugger)
1281 // Restore the mouse pointer, if hidden:
1282 videoWidget
->CheckAndRestoreMouseCursor();
1284 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1286 uint32_t pixel
= videoWidget
->buffer
[i
];
1287 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1288 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1289 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1292 videoWidget
->updateGL();
1294 cpuBrowseWin
->HoldBPM();
1295 cpuBrowseWin
->HandleBPMContinue();
1296 DebuggerRefreshWindows();
1301 frameAdvanceAct
->setDisabled(true);
1302 pauseAct
->setChecked(false);
1303 pauseAct
->setDisabled(false);
1304 if (vjs
.softTypeDebugger
)
1306 traceStepIntoAct
->setDisabled(true);
1307 traceStepOverAct
->setDisabled(true);
1308 restartAct
->setDisabled(true);
1309 BreakpointsWin
->RefreshContents();
1312 cpuBrowseWin
->UnholdBPM();
1315 // Pause/unpause any running/non-running threads...
1316 DACPauseAudioThread(!running
);
1320 void MainWin::SetZoom100(void)
1327 void MainWin::SetZoom200(void)
1334 void MainWin::SetZoom300(void)
1341 void MainWin::SetNTSC(void)
1343 powerAct
->setIcon(powerRed
);
1344 timer
->setInterval(16);
1345 vjs
.hardwareTypeNTSC
= true;
1351 void MainWin::SetPAL(void)
1353 powerAct
->setIcon(powerGreen
);
1354 timer
->setInterval(20);
1355 vjs
.hardwareTypeNTSC
= false;
1361 void MainWin::ToggleBlur(void)
1363 vjs
.glFilter
= !vjs
.glFilter
;
1368 void MainWin::ShowAboutWin(void)
1374 void MainWin::ShowHelpWin(void)
1380 void MainWin::InsertCart(void)
1382 // Check to see if we did autorun, 'cause we didn't load anything in that
1384 if (!scannedSoftwareFolder
)
1386 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1387 scannedSoftwareFolder
= true;
1390 // If the emulator is running, we pause it here and unpause it later
1391 // if we dismiss the file selector without choosing anything
1392 if (running
&& powerButtonOn
)
1395 pauseForFileSelector
= true;
1398 filePickWin
->show();
1402 void MainWin::Unpause(void)
1404 // Here we unpause the emulator if it was paused when we went into the file selector
1405 if (pauseForFileSelector
)
1407 pauseForFileSelector
= false;
1409 // Some nutter might have unpaused while in the file selector, so check for that
1416 // Jaguar initialisation and load software file
1417 void MainWin::LoadSoftware(QString file
)
1419 running
= false; // Prevent bad things(TM) from happening...
1420 pauseForFileSelector
= false; // Reset the file selector pause flag
1422 // Setup BIOS in his own dedicated Jaguar memory
1423 #ifndef NEWMODELSBIOSHANDLER
1424 uint8_t * biosPointer
= jaguarBootROM
;
1426 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1428 biosPointer
= jaguarDevBootROM2
;
1431 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1433 SelectBIOS(vjs
.biosType
);
1436 // Turn 'on' the power to initialize the Jaguar
1437 powerAct
->setDisabled(false);
1438 powerAct
->setChecked(true);
1439 powerButtonOn
= false;
1442 // We have to load our software *after* the Jaguar RESET
1443 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1444 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1446 // This is icky because we've already done it
1447 // it gets worse :-P
1448 if (!vjs
.useJaguarBIOS
)
1450 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1455 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1456 if (vjs
.softTypeDebugger
)
1458 m68k_set_reg(M68K_REG_A6
, 0);
1459 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1460 //pauseAct->setDisabled(false);
1461 //pauseAct->setChecked(true);
1467 // Prevent the launch in case of software without a start address and without BIOS presence
1468 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1474 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1476 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1477 setWindowTitle(newTitle
);
1482 void MainWin::ToggleCDUsage(void)
1484 CDActive
= !CDActive
;
1486 // Set up the Jaguar CD for execution, otherwise, clear memory
1488 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1490 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1494 // Open, or display, the breakpoints list window
1495 void MainWin::ShowBreakpointsWin(void)
1497 BreakpointsWin
->show();
1498 BreakpointsWin
->RefreshContents();
1502 // Delete all breakpoints
1503 void MainWin::DeleteAllBreakpoints(void)
1505 cpuBrowseWin
->ResetBPM();
1507 ShowBreakpointsWin();
1511 // Disable all breakpoints
1512 void MainWin::DisableAllBreakpoints(void)
1514 cpuBrowseWin
->DisableBPM();
1516 ShowBreakpointsWin();
1520 // Open, or display, the new breakpoint function window
1521 void MainWin::ShowNewFunctionBreakpointWin(void)
1523 NewFunctionBreakpointWin
->show();
1524 ShowBreakpointsWin();
1528 // Display list of files found in cartdridge
1529 void MainWin::ShowCartFilesListWin(void)
1531 CartFilesListWin
->show();
1532 CartFilesListWin
->RefreshContents();
1537 void MainWin::ShowSaveDumpAsWin(void)
1539 SaveDumpAsWin
->show();
1544 void MainWin::DebuggerTraceStepInto(void)
1547 videoWidget
->updateGL();
1548 DebuggerRefreshWindows();
1550 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1552 #warning "!!! Need to verify the Step Into function !!!"
1557 // Restart the Jaguar executable
1558 void MainWin::DebuggerRestart(void)
1563 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1564 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1566 m68k_set_reg(M68K_REG_A6
, 0);
1567 m68k_brk_hitcounts_reset();
1569 DebuggerResetWindows();
1570 DebuggerRefreshWindows();
1572 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1574 #warning "!!! Need to verify the Restart function !!!"
1580 void MainWin::DebuggerTraceStepOver(void)
1583 videoWidget
->updateGL();
1584 DebuggerRefreshWindows();
1586 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1588 #warning "!!! Need to verify the Step Over function !!!"
1593 // Advance / Execute for one frame
1594 void MainWin::FrameAdvance(void)
1596 //printf("Frame Advance...\n");
1598 // Execute 1 frame, then exit (only useful in Pause mode)
1600 //if (!vjs.softTypeDebugger)
1601 videoWidget
->updateGL();
1603 // Need to execute 1 frames' worth of DSP thread as well :-/
1605 //m68kDasmWin->Use68KPCAddress();
1608 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1610 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1615 void MainWin::SetFullScreen(bool state
/*= true*/)
1617 if (!vjs
.softTypeDebugger
)
1621 mainWinPosition
= pos();
1623 statusBar()->hide();
1629 // This is needed because the fullscreen may happen on a different
1630 // screen than screen 0:
1631 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1632 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1633 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1634 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1635 double aspectRatio
= targetWidth
/ targetHeight
;
1636 // NOTE: Really should check here to see which dimension constrains the
1637 // other. Right now, we assume that height is the constraint.
1638 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1639 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1640 videoWidget
->fullscreen
= true;
1641 videoWidget
->outputWidth
= newWidth
;
1642 videoWidget
->setFixedSize(r
.width(), r
.height());
1647 // Seems Qt is fussy about this: showNormal() has to go first, or it
1648 // will keep the window stuck in a psuedo-fullscreen mode with no way
1649 // to get out of it (except closing the app).
1652 // Reset the video widget to windowed mode
1653 videoWidget
->offset
= 0;
1654 videoWidget
->fullscreen
= false;
1656 statusBar()->show();
1663 move(mainWinPosition
);
1669 void MainWin::ToggleFullScreen(void)
1671 fullScreen
= !fullScreen
;
1672 SetFullScreen(fullScreen
);
1677 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1679 exceptionvectortableBrowseWin
->show();
1680 exceptionvectortableBrowseWin
->RefreshContents();
1685 void MainWin::ShowLocalBrowserWin(void)
1687 LocalBrowseWin
->show();
1688 LocalBrowseWin
->RefreshContents();
1693 void MainWin::ShowCallStackBrowserWin(void)
1695 CallStackBrowseWin
->show();
1696 CallStackBrowseWin
->RefreshContents();
1700 void MainWin::ShowAllWatchBrowserWin(void)
1702 allWatchBrowseWin
->show();
1703 allWatchBrowseWin
->RefreshContents();
1707 void MainWin::ShowHeapAllocatorBrowserWin(void)
1709 heapallocatorBrowseWin
->show();
1710 heapallocatorBrowseWin
->RefreshContents();
1714 void MainWin::ShowMemoryBrowserWin(void)
1716 memBrowseWin
->show();
1717 memBrowseWin
->RefreshContents();
1721 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1723 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1725 mem1BrowseWin
[NumWin
]->show();
1726 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1731 void MainWin::ShowEmuStatusWin(void)
1733 emuStatusWin
->show();
1734 emuStatusWin
->RefreshContents();
1738 void MainWin::ShowStackBrowserWin(void)
1740 stackBrowseWin
->show();
1741 stackBrowseWin
->RefreshContents();
1745 void MainWin::ShowCPUBrowserWin(void)
1747 cpuBrowseWin
->show();
1748 cpuBrowseWin
->RefreshContents();
1752 void MainWin::ShowOPBrowserWin(void)
1754 opBrowseWin
->show();
1755 opBrowseWin
->RefreshContents();
1759 void MainWin::ShowM68KDasmBrowserWin(void)
1761 m68kDasmBrowseWin
->show();
1762 m68kDasmBrowseWin
->RefreshContents();
1766 void MainWin::ShowRISCDasmBrowserWin(void)
1768 riscDasmBrowseWin
->show();
1769 riscDasmBrowseWin
->RefreshContents();
1775 void MainWin::ShowDasmWin(void)
1778 // DasmWin->RefreshContents();
1785 void MainWin::ShowVideoOutputWin(void)
1787 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1788 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1789 //VideoOutputWindowCentrale->show();
1790 //memBrowseWin->show();
1791 //VideoOutputWin->show();
1792 //VideoOutputWin->RefreshContents(videoWidget);
1797 // Resize video window based on zoom factor
1798 // It doesn't apply in debugger mode as we use this window to display disassembly
1799 void MainWin::ResizeMainWindow(void)
1801 if (!vjs
.softTypeDebugger
)
1803 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1805 // Show the test pattern if user requested plzDontKillMyComputer mode
1806 if (!powerButtonOn
&& plzDontKillMyComputer
)
1808 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1810 if (vjs
.hardwareTypeNTSC
)
1812 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1816 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1827 void MainWin::ReadSettings(void)
1831 QSettings
settings("Underground Software", "Virtual Jaguar");
1833 //zoomLevel = settings.value("zoom", 2).toInt();
1834 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1835 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1837 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1838 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1839 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1840 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1841 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1842 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1843 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1844 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1845 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1846 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1847 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1848 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1849 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1850 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1851 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1852 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1853 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1854 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1855 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1856 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1857 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1859 // Read settings from the Debugger mode
1860 settings
.beginGroup("debugger");
1861 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1862 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1863 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1864 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1865 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1866 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1867 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1868 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1869 settings
.endGroup();
1871 // Read settings from the Alpine mode
1872 settings
.beginGroup("alpine");
1873 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1874 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1875 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1876 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1877 settings
.endGroup();
1879 // Read settings from the Keybindings
1880 settings
.beginGroup("keybindings");
1881 for (i
= 0; i
< KB_END
; i
++)
1883 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1885 settings
.endGroup();
1887 // Write important settings to the log file
1888 WriteLog("MainWin: Paths\n");
1889 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1890 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1891 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1892 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1893 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1894 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1895 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1896 WriteLog("MainWin: Misc.\n");
1897 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1900 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1901 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1902 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1903 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1904 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1905 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1906 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1907 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1908 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1909 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1910 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1911 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1912 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1913 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1914 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1915 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1916 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1917 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1918 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1919 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1920 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1921 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1923 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1924 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1925 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1926 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1927 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1928 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1929 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1930 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1931 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1932 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1933 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1934 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1935 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1936 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1937 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1938 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1939 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1940 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1941 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1942 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1943 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1946 WriteLog("Read setting = Done\n");
1948 ReadProfiles(&settings
);
1949 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
1954 // Default values will be used in case of no settings can be found
1956 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1958 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1960 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1961 void MainWin::ReadUISettings(void)
1968 // Point on the emulator settings
1969 QSettings
settings("Underground Software", "Virtual Jaguar");
1970 settings
.beginGroup("ui");
1972 // Emulator main window UI information
1973 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1974 size
= settings
.value("size", QSize(400, 400)).toSize();
1976 move(mainWinPosition
);
1977 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1978 filePickWin
->move(pos
);
1980 // Video output information
1981 zoomLevel
= settings
.value("zoom", 2).toInt();
1983 // Alpine debug UI information (also needed by the Debugger)
1984 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1986 // CPU registers UI information
1987 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1988 cpuBrowseWin
->move(pos
);
1989 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1991 // Memory browser UI information
1992 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1993 memBrowseWin
->move(pos
);
1994 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1996 // Stack browser UI information
1997 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1998 stackBrowseWin
->move(pos
);
1999 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2000 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2001 stackBrowseWin
->resize(size
);
2003 // Emulator status UI information
2004 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2005 emuStatusWin
->move(pos
);
2006 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2008 // OP (Object Processor) UI information
2009 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2010 opBrowseWin
->move(pos
);
2011 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2012 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2013 opBrowseWin
->resize(size
);
2015 // RISC disassembly UI information
2016 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2017 riscDasmBrowseWin
->move(pos
);
2018 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2020 // M68k disassembly UI information
2021 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2022 m68kDasmBrowseWin
->move(pos
);
2023 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2025 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2027 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2031 // Debugger UI information
2032 if (vjs
.softTypeDebugger
)
2035 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2036 m68kDasmWin
->move(pos
);
2037 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2038 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2039 GPUDasmWin
->move(pos
);
2040 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2041 DSPDasmWin
->move(pos
);
2043 // All watch browser UI information
2044 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2045 allWatchBrowseWin
->move(pos
);
2046 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2047 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2048 allWatchBrowseWin
->resize(size
);
2050 // Local browser UI information
2051 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2052 LocalBrowseWin
->move(pos
);
2053 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2054 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2055 LocalBrowseWin
->resize(size
);
2057 // Heap memory allocation browser UI information
2058 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2059 heapallocatorBrowseWin
->move(pos
);
2060 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2061 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2062 heapallocatorBrowseWin
->resize(size
);
2064 // Exception Vector Table UI Information
2065 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2066 exceptionvectortableBrowseWin
->move(pos
);
2067 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2068 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2069 exceptionvectortableBrowseWin
->resize(size
);
2071 // Call Stack browser UI information
2072 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2073 CallStackBrowseWin
->move(pos
);
2074 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2075 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2076 CallStackBrowseWin
->resize(size
);
2078 // Cartdridge directory and files UI information
2079 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2080 CartFilesListWin
->move(pos
);
2081 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2082 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2083 CartFilesListWin
->resize(size
);
2085 // Save dump UI information
2086 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2087 SaveDumpAsWin
->move(pos
);
2088 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2089 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2090 SaveDumpAsWin
->resize(size
);
2092 // Breakpoints UI information
2093 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2094 BreakpointsWin
->move(pos
);
2095 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2096 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2097 BreakpointsWin
->resize(size
);
2098 // New function breakpoint UI information
2099 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2100 NewFunctionBreakpointWin
->move(pos
);
2101 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2102 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2103 NewFunctionBreakpointWin
->resize(size
);
2105 // Memories browser UI information
2106 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2108 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2109 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2110 mem1BrowseWin
[i
]->move(pos
);
2111 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2112 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2113 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2114 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2115 mem1BrowseWin
[i
]->resize(size
);
2119 settings
.endGroup();
2121 WriteLog("Read UI setting = Done\n");
2125 // Save the settings
2126 void MainWin::WriteSettings(void)
2130 // Point on the emulator settings
2131 QSettings
settings("Underground Software", "Virtual Jaguar");
2132 //settings.setValue("pos", pos());
2133 //settings.setValue("size", size());
2134 //settings.setValue("cartLoadPos", filePickWin->pos());
2136 //settings.setValue("zoom", zoomLevel);
2137 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2138 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2140 settings
.setValue("useJoystick", vjs
.useJoystick
);
2141 settings
.setValue("joyport", vjs
.joyport
);
2142 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2143 settings
.setValue("frameSkip", vjs
.frameSkip
);
2144 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2145 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2146 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2147 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2148 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2149 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2150 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2151 settings
.setValue("fullscreen", vjs
.fullscreen
);
2152 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2153 settings
.setValue("glFilterType", vjs
.glFilter
);
2154 settings
.setValue("renderType", vjs
.renderType
);
2155 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2156 settings
.setValue("biosType", vjs
.biosType
);
2157 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2158 //settings.setValue("JagBootROM", vjs.jagBootPath);
2159 //settings.setValue("CDBootROM", vjs.CDBootPath);
2160 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2161 settings
.setValue("ROMs", vjs
.ROMPath
);
2162 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2164 // Write settings from the Alpine mode
2165 settings
.beginGroup("alpine");
2166 settings
.setValue("refresh", vjs
.refresh
);
2167 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2168 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2169 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2170 settings
.endGroup();
2172 // Write settings from the Debugger mode
2173 settings
.beginGroup("debugger");
2174 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2175 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2176 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2177 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2178 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2179 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2180 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2181 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2182 settings
.endGroup();
2184 // Write settings from the Keybindings
2185 settings
.beginGroup("keybindings");
2186 for (i
= 0; i
< KB_END
; i
++)
2188 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2190 settings
.endGroup();
2193 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2194 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2195 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2196 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2197 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2198 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2199 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2200 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2201 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2202 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2203 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2204 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2205 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2206 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2207 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2208 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2209 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2210 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2211 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2212 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2213 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2215 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2216 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2217 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2218 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2219 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2220 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2221 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2222 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2223 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2224 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2225 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2226 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2227 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2228 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2229 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2230 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2231 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2232 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2233 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2234 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2235 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2238 WriteProfiles(&settings
);
2239 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2243 // Save the UI settings
2244 void MainWin::WriteUISettings(void)
2249 // Point on the emulator settings
2250 QSettings
settings("Underground Software", "Virtual Jaguar");
2251 settings
.beginGroup("ui");
2253 // Emulator UI information
2254 settings
.setValue("pos", pos());
2255 settings
.setValue("size", size());
2256 settings
.setValue("cartLoadPos", filePickWin
->pos());
2258 // Video output information
2259 settings
.setValue("zoom", zoomLevel
);
2261 // Alpine debug UI information (also needed by the Debugger)
2262 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2264 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2265 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2266 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2267 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2268 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2269 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2270 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2271 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2272 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2273 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2274 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2275 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2276 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2277 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2278 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2279 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2282 // Debugger UI information
2283 if (vjs
.softTypeDebugger
)
2286 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2287 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2288 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2289 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2291 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2292 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2293 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2294 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2295 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2296 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2297 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2298 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2299 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2300 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2301 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2302 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2303 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2304 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2305 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2306 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2307 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2308 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2309 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2310 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2311 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2312 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2313 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2314 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2315 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2316 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2317 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2319 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2321 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2322 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2323 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2324 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2325 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2326 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2330 settings
.endGroup();
2334 // Refresh alpine debug windows
2335 void MainWin::AlpineRefreshWindows(void)
2337 cpuBrowseWin
->RefreshContents();
2338 memBrowseWin
->RefreshContents();
2339 stackBrowseWin
->RefreshContents();
2340 emuStatusWin
->RefreshContents();
2341 opBrowseWin
->RefreshContents();
2342 riscDasmBrowseWin
->RefreshContents();
2343 m68kDasmBrowseWin
->RefreshContents();
2347 // Reset soft debugger
2348 void MainWin::DebuggerReset(void)
2350 if (vjs
.softTypeDebugger
)
2352 DeleteAllBreakpoints();
2357 // Reset soft debugger windows
2358 void MainWin::DebuggerResetWindows(void)
2360 if (vjs
.softTypeDebugger
)
2362 FilesrcListWin
->Reset();
2363 allWatchBrowseWin
->Reset();
2364 heapallocatorBrowseWin
->Reset();
2365 BreakpointsWin
->Reset();
2366 CartFilesListWin
->Reset();
2367 //ResetAlpineWindows();
2372 // Refresh view windows
2373 void MainWin::ViewRefreshWindows(void)
2375 CartFilesListWin
->RefreshContents();
2379 // Refresh soft debugger & alpine debug windows
2380 void MainWin::DebuggerRefreshWindows(void)
2382 if (vjs
.softTypeDebugger
)
2384 FilesrcListWin
->RefreshContents();
2385 m68kDasmWin
->RefreshContents();
2386 GPUDasmWin
->RefreshContents();
2387 DSPDasmWin
->RefreshContents();
2388 allWatchBrowseWin
->RefreshContents();
2389 LocalBrowseWin
->RefreshContents();
2390 CallStackBrowseWin
->RefreshContents();
2391 heapallocatorBrowseWin
->RefreshContents();
2392 BreakpointsWin
->RefreshContents();
2393 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2395 mem1BrowseWin
[i
]->RefreshContents(i
);
2398 AlpineRefreshWindows();
2399 ViewRefreshWindows();
2404 // Create and save screenshot
2405 void MainWin::MakeScreenshot(void)
2409 time_t now
= time(0);
2413 tstruct
= *localtime(&now
);
2414 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
);
2416 // Create screenshot
2417 screenshot
= videoWidget
->grabFrameBuffer();
2418 screenshot
.save((char *)Text
, "JPG", 100);