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, added a HW registers browser
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"
74 #include "debug/hwregsbrowser.h"
80 #ifndef NEWMODELSBIOSHANDLER
83 #include "jagstub2bios.h"
85 #include "modelsBIOS.h"
87 #include "jagcdbios.h"
89 #include "m68000/m68kinterface.h"
91 #include "debugger/DBGManager.h"
92 //#include "debugger/VideoWin.h"
93 //#include "debugger/DasmWin.h"
94 #include "debugger/m68KDasmWin.h"
95 #include "debugger/GPUDasmWin.h"
96 #include "debugger/DSPDasmWin.h"
97 #include "debugger/memory1browser.h"
98 #include "debugger/BreakpointsWin.h"
99 #include "debugger/NewFnctBreakpointWin.h"
100 #include "debugger/FilesrcListWin.h"
101 #include "debugger/exceptionvectortablebrowser.h"
102 #include "debugger/allwatchbrowser.h"
103 #include "debugger/localbrowser.h"
104 #include "debugger/heapallocatorbrowser.h"
105 #include "debugger/callstackbrowser.h"
106 #include "debugger/CartFilesListWin.h"
107 #include "debugger/SaveDumpAsWin.h"
110 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
111 //#ifdef __GCCWIN32__
112 // Apparently on win32, usleep() is not pulled in by the usual suspects.
116 #include "_MSC_VER/unistd.h"
120 // The way BSNES controls things is by setting a timer with a zero
121 // timeout, sleeping if not emulating anything. Seems there has to be a
124 // It has a novel approach to plugging-in/using different video/audio/input
125 // methods, can we do something similar or should we just use the built-in
128 // We're going to try to use the built-in OpenGL support and see how it goes.
129 // We'll make the VJ core modular so that it doesn't matter what GUI is in
130 // use, we can drop it in anywhere and use it as-is.
132 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
133 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
134 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
140 for(int i
=0; i
<8; i
++)
144 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
147 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
150 //if (vjs.softTypeDebugger)
152 // mainWindowCentrale = new QMdiArea;
153 // setCentralWidget(mainWindowCentrale);
156 WriteLog("Window creation start\n");
159 videoWidget
= new GLWidget(this);
160 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
162 // set central output window
163 if (!vjs
.softTypeDebugger
)
165 setCentralWidget(videoWidget
);
169 mainWindowCentrale
= new QMdiArea(this);
170 setCentralWidget(mainWindowCentrale
);
173 setWindowIcon(QIcon(":/res/vj-icon.png"));
175 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
177 if (vjs
.hardwareTypeAlpine
)
178 title
+= QString(tr(" - Alpine Mode"));
180 if (vjs
.softTypeDebugger
)
181 title
+= QString(tr(" - Debugger Mode"));
183 setWindowTitle(title
);
185 // Windows common features
186 aboutWin
= new AboutWindow(this);
187 helpWin
= new HelpWindow(this);
188 filePickWin
= new FilePickerWindow(this);
189 emuStatusWin
= new EmuStatusWindow(this);
191 // Windows alpine mode features
192 memBrowseWin
= new MemoryBrowserWindow(this);
193 stackBrowseWin
= new StackBrowserWindow(this);
194 cpuBrowseWin
= new CPUBrowserWindow(this);
195 opBrowseWin
= new OPBrowserWindow(this);
196 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
197 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
198 hwRegsBrowseWin
= new HWRegsBrowserWindow(this);
200 // Windows debugger mode features
201 if (vjs
.softTypeDebugger
)
203 //VideoOutputWin = new VideoOutputWindow(this);
204 //VideoOutputWin->setCentralWidget()
205 //DasmWin = new DasmWindow();
206 //DasmWin = new DasmWindow(this);
207 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
208 LocalBrowseWin
= new LocalBrowserWindow(this);
209 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
210 BreakpointsWin
= new BreakpointsWindow(this);
211 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
212 SaveDumpAsWin
= new SaveDumpAsWindow(this);
213 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
214 CallStackBrowseWin
= new CallStackBrowserWindow(this);
215 CartFilesListWin
= new CartFilesListWindow(this);
217 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
219 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
221 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
223 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
225 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
228 // Setup dock to display source code filenames tree
229 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
230 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
232 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
233 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
234 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
236 // Setup dock to display disassembly
237 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
238 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
239 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
240 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
241 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
243 dasmtabWidget
= new QTabWidget(this);
246 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
247 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
248 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
249 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
251 setCentralWidget(dasmtabWidget
);
255 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
256 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
258 setUnifiedTitleAndToolBarOnMac(true);
261 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
262 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
263 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
264 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
265 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
268 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
269 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
270 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
271 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
272 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
273 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
274 powerAct
->setCheckable(true);
275 powerAct
->setChecked(false);
276 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
280 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
281 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
282 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
283 pauseAct
->setStatusTip(tr("Toggles the running state"));
284 pauseAct
->setCheckable(true);
285 pauseAct
->setDisabled(true);
286 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
287 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
288 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
291 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
292 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
293 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
294 screenshotAct
->setCheckable(false);
295 screenshotAct
->setDisabled(false);
296 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
299 zoomActs
= new QActionGroup(this);
300 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
301 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
302 x1Act
->setCheckable(true);
303 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
304 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
305 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
306 x2Act
->setCheckable(true);
307 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
308 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
309 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
310 x3Act
->setCheckable(true);
311 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
314 tvTypeActs
= new QActionGroup(this);
315 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
316 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
317 ntscAct
->setCheckable(true);
318 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
319 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
320 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
321 palAct
->setCheckable(true);
322 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
325 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
326 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
327 blurAct
= new QAction(blur
, tr("Blur"), this);
328 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
329 blurAct
->setCheckable(true);
330 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
333 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
334 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
335 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
338 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
339 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
340 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
342 // File pickup action
343 if (!vjs
.softTypeDebugger
)
345 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
346 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
350 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
351 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
353 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
354 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
355 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
357 // Configuration action
358 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
359 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
360 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
361 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
362 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
364 // Emulation status action
365 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
366 emustatusAct
->setStatusTip(tr("Emulator status"));
367 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
368 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
369 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
372 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
373 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
374 useCDAct
->setCheckable(true);
375 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
377 // Frame advance action
378 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
379 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
380 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
381 frameAdvanceAct
->setDisabled(true);
382 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
385 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
386 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
387 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
388 fullScreenAct
->setCheckable(true);
389 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
391 // Actions dedicated to debugger mode
392 if (vjs
.softTypeDebugger
)
395 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
396 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
397 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
398 restartAct
->setCheckable(false);
399 restartAct
->setDisabled(true);
400 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
403 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
404 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
405 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
406 traceStepOverAct
->setCheckable(false);
407 traceStepOverAct
->setDisabled(true);
408 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
410 // Trace into tracing
411 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
412 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
413 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
414 traceStepIntoAct
->setCheckable(false);
415 traceStepIntoAct
->setDisabled(true);
416 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
418 // Function breakpoint
419 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
420 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
421 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
422 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
423 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
424 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
425 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
426 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
427 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
428 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
429 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
432 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
433 saveDumpAsAct
->setCheckable(false);
434 saveDumpAsAct
->setDisabled(false);
435 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
437 //VideoOutputAct = new QAction(tr("Output Video"), this);
438 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
439 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
441 //DasmAct = new QAction(tr("Disassembly"), this);
442 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
443 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
445 // Exception vector table window
446 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
447 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
448 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
450 // All watch variables window
451 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
452 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
453 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
455 // Local variables window
456 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
457 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
458 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
460 // Heap (memory) allocation window
461 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
462 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
463 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
466 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
467 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
468 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
471 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
472 CartFilesListAct
->setStatusTip(tr("List of the files in the cartridge's directory structure"));
473 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
476 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
477 QSignalMapper
*signalMapper
= new QSignalMapper(this);
479 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
481 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
483 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
486 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
487 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
488 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
489 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
490 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
491 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
495 // Memory browser window action
496 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
497 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
498 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
500 // Stack browser window action
501 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
502 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
503 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
505 // CPUs (M68000, GPU & DSP browser window action
506 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
507 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
508 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
510 // OP browser window action
511 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
512 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
513 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
515 // M68000 disassembly browser window
516 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
517 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
518 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
520 // HW registers browser window
521 hwRegsBrowseAct
= new QAction(QIcon(":/res/tool-hw-regs.png"), tr("HW Registers Browser"), this);
522 hwRegsBrowseAct
->setStatusTip(tr("Shows the HW registers browser window"));
523 connect(hwRegsBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHWRegsBrowserWin()));
525 // Risc (DSP / GPU) disassembly browser window
526 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
527 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
528 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
530 // Misc. connections...
531 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
532 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
536 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
537 fileMenu
->addAction(powerAct
);
538 if (!vjs
.softTypeDebugger
)
540 fileMenu
->addAction(pauseAct
);
541 // fileMenu->addAction(frameAdvanceAct);
543 fileMenu
->addAction(filePickAct
);
544 fileMenu
->addAction(useCDAct
);
545 fileMenu
->addAction(configAct
);
546 fileMenu
->addAction(emustatusAct
);
547 fileMenu
->addSeparator();
548 fileMenu
->addAction(quitAppAct
);
550 // Alpine and debugger menus
551 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
554 debugMenu
= menuBar()->addMenu(tr("&Debug"));
556 // Create debugger menu
557 if (vjs
.softTypeDebugger
)
560 viewMenu
= menuBar()->addMenu(tr("&View"));
563 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
564 viewCartMenu
->addAction(CartFilesListAct
);
566 viewCartMenu
->addSeparator();
567 viewCartMenu
->addAction(CartStreamsAct
);
571 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
572 debugWindowsMenu
->addAction(BreakpointsAct
);
573 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
574 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
575 debugWindowsMenu
->addSeparator();
577 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
578 debugWindowOutputMenu
->addAction(VideoOutputAct
);
579 debugWindowsMenu
->addSeparator();
581 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
582 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
583 debugWindowsMenu
->addAction(LocalBrowseAct
);
584 debugWindowsMenu
->addSeparator();
585 debugWindowsMenu
->addAction(CallStackBrowseAct
);
586 debugWindowsMenu
->addSeparator();
587 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
588 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
589 debugWindowsMemoryMenu
->addSeparator();
590 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
592 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
594 debugWindowsMenu
->addSeparator();
595 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
596 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
597 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
598 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
599 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
600 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
601 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
602 debugWindowsBrowsesMenu
->addAction(hwRegsBrowseAct
);
603 debugMenu
->addSeparator();
604 debugMenu
->addAction(pauseAct
);
605 debugMenu
->addAction(frameAdvanceAct
);
606 debugMenu
->addAction(restartAct
);
607 debugMenu
->addSeparator();
608 debugMenu
->addAction(traceStepIntoAct
);
609 debugMenu
->addAction(traceStepOverAct
);
610 debugMenu
->addSeparator();
611 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
612 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
613 debugMenu
->addAction(deleteAllBreakpointsAct
);
614 debugMenu
->addAction(disableAllBreakpointsAct
);
615 debugMenu
->addSeparator();
616 debugMenu
->addAction(saveDumpAsAct
);
618 debugMenu
->addSeparator();
619 debugMenu
->addAction(DasmAct
);
624 // Create alpine menu
625 debugMenu
->addAction(memBrowseAct
);
626 debugMenu
->addAction(stackBrowseAct
);
627 debugMenu
->addAction(cpuBrowseAct
);
628 debugMenu
->addAction(opBrowseAct
);
629 debugMenu
->addAction(m68kDasmBrowseAct
);
630 debugMenu
->addAction(riscDasmBrowseAct
);
631 debugMenu
->addAction(hwRegsBrowseAct
);
636 helpMenu
= menuBar()->addMenu(tr("&Help"));
637 helpMenu
->addAction(helpAct
);
638 helpMenu
->addAction(aboutAct
);
642 toolbar
= addToolBar(tr("System"));
643 toolbar
->addAction(powerAct
);
644 if (!vjs
.softTypeDebugger
)
646 toolbar
->addAction(pauseAct
);
647 toolbar
->addAction(frameAdvanceAct
);
649 toolbar
->addAction(filePickAct
);
650 toolbar
->addAction(useCDAct
);
651 toolbar
->addSeparator();
652 if (!vjs
.softTypeDebugger
)
654 toolbar
->addAction(screenshotAct
);
655 toolbar
->addSeparator();
656 toolbar
->addAction(x1Act
);
657 toolbar
->addAction(x2Act
);
658 toolbar
->addAction(x3Act
);
659 toolbar
->addSeparator();
660 toolbar
->addAction(ntscAct
);
661 toolbar
->addAction(palAct
);
662 toolbar
->addSeparator();
663 toolbar
->addAction(blurAct
);
664 toolbar
->addAction(fullScreenAct
);
668 debuggerbar
= addToolBar(tr("&Debugger"));
669 debuggerbar
->addAction(pauseAct
);
670 debuggerbar
->addAction(frameAdvanceAct
);
671 debuggerbar
->addAction(restartAct
);
672 debuggerbar
->addSeparator();
673 debuggerbar
->addAction(traceStepIntoAct
);
674 debuggerbar
->addAction(traceStepOverAct
);
675 debuggerbar
->addSeparator();
676 debuggerbar
->addAction(BreakpointsAct
);
679 if (vjs
.hardwareTypeAlpine
)
681 debugbar
= addToolBar(tr("&Debug"));
682 debugbar
->addAction(memBrowseAct
);
683 debugbar
->addAction(stackBrowseAct
);
684 debugbar
->addAction(cpuBrowseAct
);
685 debugbar
->addAction(opBrowseAct
);
686 debugbar
->addAction(m68kDasmBrowseAct
);
687 debugbar
->addAction(riscDasmBrowseAct
);
688 debugbar
->addAction(hwRegsBrowseAct
);
691 // Add actions to the main window, as hiding widgets with them
693 addAction(fullScreenAct
);
694 addAction(quitAppAct
);
695 addAction(configAct
);
696 addAction(emustatusAct
);
698 addAction(filePickAct
);
699 addAction(frameAdvanceAct
);
702 statusBar()->showMessage(tr("Ready"));
704 // Do this in case original size isn't correct (mostly for the first-run case)
707 WriteLog("Window creation done\n");
709 // Create our test pattern NTSC bitmap
710 WriteLog("Test pattern 1 bitmap\n");
712 QImage
tempImg(":/res/test-pattern.jpg");
713 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
715 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
717 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
719 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
721 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
722 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
726 // Create our test pattern PAL bitmap
727 WriteLog("Test pattern 2 bitmap\n");
729 QImage
tempImg2(":/res/test-pattern-pal.jpg");
730 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
732 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
734 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
736 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
738 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
739 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
743 // Set up timer based loop for animation...
744 timer
= new QTimer(this);
745 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
747 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
748 // This is because it's discarding the 0.6666... on the end of the fraction.
749 // Alas, 6 doesn't divide cleanly into 10. :-P
750 //Should we defer this until SyncUI? Probably.
751 //No, it doesn't work, because it uses setInterval() instead of start()...
752 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
754 // We set this initially, to make VJ behave somewhat as it would if no
755 // cart were inserted and the BIOS was set as active...
756 jaguarCartInserted
= true;
757 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
758 WriteLog("VJ: Initializing jaguar subsystem...\n");
761 #ifndef NEWMODELSBIOSHANDLER
762 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
763 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
765 SelectBIOS(vjs
.biosType
);
768 // Prevent the file scanner from running if filename passed
769 // in on the command line...
773 // Load up the default ROM if in Alpine mode:
774 if (vjs
.hardwareTypeAlpine
)
776 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
778 // If regular load failed, try just a straight file load
779 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
781 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
784 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
786 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
788 // Attempt to load/run the ABS file...
789 LoadSoftware(vjs
.absROMPath
);
790 #ifndef NEWMODELSBIOSHANDLER
791 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
793 SelectBIOS(vjs
.biosType
);
795 // Prevent the scanner from running...
799 // Load up the default ROM if in Debugger mode:
800 if (vjs
.softTypeDebugger
)
802 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
804 // If regular load failed, try just a straight file load
805 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
807 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
810 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
812 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
814 // Attempt to load/run the ABS file...
815 LoadSoftware(vjs
.absROMPath
);
816 #ifndef NEWMODELSBIOSHANDLER
817 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
818 // Prevent the scanner from running...
820 SelectBIOS(vjs
.biosType
);
825 // Run the scanner if nothing passed in and *not* Alpine mode...
826 // NB: Really need to look into caching the info scanned in here...
827 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
828 scannedSoftwareFolder
= true;
832 void MainWin::LoadFile(QString file
)
838 void MainWin::SyncUI(void)
840 // Set toolbar buttons/menus based on settings read in (sync the UI)...
841 // (Really, this is to sync command line options passed in)
842 blurAct
->setChecked(vjs
.glFilter
);
843 x1Act
->setChecked(zoomLevel
== 1);
844 x2Act
->setChecked(zoomLevel
== 2);
845 x3Act
->setChecked(zoomLevel
== 3);
846 // running = powerAct->isChecked();
847 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
848 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
849 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
851 fullScreenAct
->setChecked(vjs
.fullscreen
);
852 fullScreen
= vjs
.fullscreen
;
853 SetFullScreen(fullScreen
);
855 // Reset the timer to be what was set in the command line (if any):
856 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
857 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
861 void MainWin::closeEvent(QCloseEvent
* event
)
864 // This should only be done by the config dialog
867 event
->accept(); // ignore() if can't close for some reason
871 void MainWin::keyPressEvent(QKeyEvent
* e
)
873 #ifndef VJ_REMOVE_DEV_CODE
875 //extern bool startM68KTracing; // moved to jaguar.h
877 extern int blit_start_log
;
879 extern bool startConciseBlitLogging
;
882 // We ignore the Alt key for now, since it causes problems with the GUI
883 if (e
->key() == Qt::Key_Alt
)
888 // Bar this shite from release versions kthxbai
889 #ifndef VJ_REMOVE_DEV_CODE
890 else if (e
->key() == Qt::Key_F11
)
892 startM68KTracing
= true;
896 else if (e
->key() == Qt::Key_F12
)
898 blit_start_log
= true;
902 else if (e
->key() == Qt::Key_F10
)
904 startConciseBlitLogging
= true;
909 else if (e
->key() == Qt::Key_F8
)
911 // ggn: For extra NYAN pleasure...
912 // ggn: There you go James :P
913 // Shamus: Thanks for the patch! :-D
914 WriteLog(" o + + +\n");
915 WriteLog("+ o o + o\n");
916 WriteLog("-_-_-_-_-_-_-_,------, o \n");
917 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
918 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
919 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
920 WriteLog("+ o o + o\n");
927 This is done now by a QAction...
928 if (e->key() == Qt::Key_F9)
938 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
940 // We ignore the Alt key for now, since it causes problems with the GUI
941 if (e
->key() == Qt::Key_Alt
)
947 HandleKeys(e
, false);
951 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
953 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
954 // We kill bad key combos here, before they can get to the emulator...
955 // This also kills the illegal instruction problem that cropped up in
958 // First, settle key states...
959 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
960 keyHeld
[P1LEFT
] = state
;
961 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
962 keyHeld
[P1RIGHT
] = state
;
963 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
964 keyHeld
[P1UP
] = state
;
965 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
966 keyHeld
[P1DOWN
] = state
;
967 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
968 keyHeld
[P2LEFT
] = state
;
969 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
970 keyHeld
[P2RIGHT
] = state
;
971 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
972 keyHeld
[P2UP
] = state
;
973 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
974 keyHeld
[P2DOWN
] = state
;
976 // Next, check for conflicts and kill 'em if there are any...
977 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
978 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
980 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
981 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
983 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
984 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
986 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
987 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
989 // No bad combos exist now, let's stuff the emulator key buffers...!
990 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
992 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
993 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
995 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
996 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
1002 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
1004 void MainWin::HandleGamepads(void)
1008 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1010 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1011 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
1013 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1014 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1019 void MainWin::Open(void)
1024 void MainWin::Configure(void)
1026 // Call the configuration dialog and update settings
1027 ConfigDialog
dlg(this);
1029 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1030 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1031 dlg
.controllerTab1
->SetupLastUsedProfile();
1032 // maybe instead of this, we tell the controller tab to work on a copy that gets
1033 // written if the user hits 'OK'.
1034 SaveProfiles(); // Just in case user cancels
1036 if (dlg
.exec() == false)
1042 QString before
= vjs
.ROMPath
;
1043 QString alpineBefore
= vjs
.alpineROMPath
;
1044 QString absBefore
= vjs
.absROMPath
;
1045 // bool audioBefore = vjs.audioEnabled;
1046 bool audioBefore
= vjs
.DSPEnabled
;
1047 dlg
.UpdateVJSettings();
1048 QString after
= vjs
.ROMPath
;
1049 QString alpineAfter
= vjs
.alpineROMPath
;
1050 QString absAfter
= vjs
.absROMPath
;
1051 // bool audioAfter = vjs.audioEnabled;
1052 bool audioAfter
= vjs
.DSPEnabled
;
1054 bool allowOld
= allowUnknownSoftware
;
1056 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1057 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1058 AutoConnectProfiles();
1060 // We rescan the "software" folder if the user either changed the path or
1061 // checked/unchecked the "Allow unknown files" option in the config dialog.
1062 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1063 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1065 // If the "Alpine" ROM is changed, then let's load it...
1066 if (alpineBefore
!= alpineAfter
)
1068 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1070 // Oh crap, we couldn't get the file! Alert the media!
1072 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1073 msg
.setIcon(QMessageBox::Warning
);
1078 // If the "ABS" ROM is changed, then let's load it...
1079 if (absBefore
!= absAfter
)
1081 if (!JaguarLoadFile(vjs
.absROMPath
))
1083 // Oh crap, we couldn't get the file! Alert the media!
1085 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1086 msg
.setIcon(QMessageBox::Warning
);
1091 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1092 // since it's running in the host audio IRQ...
1093 if (audioBefore
!= audioAfter
)
1099 // Just in case we crash before a clean exit...
1107 // Here's the main emulator loop
1109 void MainWin::Timer(void)
1112 static uint32_t ntscTickCount
;
1113 if (vjs
.hardwareTypeNTSC
)
1117 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1124 if (showUntunedTankCircuit
)
1126 // Some machines can't handle this, so we give them the option to disable it. :-)
1127 if (!plzDontKillMyComputer
)
1129 // if (!vjs.softTypeDebugger)
1131 // Random hash & trash
1132 // We try to simulate an untuned tank circuit here... :-)
1133 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1135 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1137 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1145 // Otherwise, run the Jaguar simulation
1148 //if (!vjs.softTypeDebugger)
1149 videoWidget
->HandleMouseHiding();
1151 static uint32_t refresh
= 0;
1152 // Do autorefresh on debug windows
1153 // Have to be careful, too much causes the emulator to slow way down!
1154 if (refresh
== vjs
.refresh
)
1156 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1158 AlpineRefreshWindows();
1159 //memBrowseWin->RefreshContents();
1160 //cpuBrowseWin->RefreshContents();
1162 CommonRefreshWindows();
1171 //if (!vjs.softTypeDebugger)
1172 videoWidget
->updateGL();
1175 // Approach: We use a ring buffer to store times (in ms) over a given
1176 // amount of frames, then sum them to figure out the FPS.
1177 uint32_t timestamp
= SDL_GetTicks();
1178 // This assumes the ring buffer size is a power of 2
1179 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1180 // Doing it this way is better. Ring buffer size can be arbitrary then.
1181 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1182 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1183 uint32_t elapsedTime
= 0;
1185 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1186 elapsedTime
+= ringBuffer
[i
];
1188 // elapsedTime must be non-zero
1189 if (elapsedTime
== 0)
1192 // This is in frames per 10 seconds, so we can have 1 decimal
1193 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1194 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1195 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1196 // If this is updated too frequently to be useful, we can throttle it down
1197 // so that it only updates every 10th frame or so
1198 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1199 oldTimestamp
= timestamp
;
1201 if (M68KDebugHaltStatus())
1206 // Toggle the power state, it can be either on or off
1207 void MainWin::TogglePowerState(void)
1209 powerButtonOn
= !powerButtonOn
;
1212 // With the power off, we simulate white noise on the screen. :-)
1215 // Restore the mouse pointer, if hidden:
1216 //if (!vjs.softTypeDebugger)
1218 videoWidget
->CheckAndRestoreMouseCursor();
1221 useCDAct
->setDisabled(false);
1222 palAct
->setDisabled(false);
1223 ntscAct
->setDisabled(false);
1224 pauseAct
->setChecked(false);
1225 pauseAct
->setDisabled(true);
1226 showUntunedTankCircuit
= true;
1228 DACPauseAudioThread();
1229 // 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. :-)
1232 if (plzDontKillMyComputer
)
1234 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1235 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1237 if (vjs
.hardwareTypeNTSC
)
1239 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1243 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1250 useCDAct
->setDisabled(true);
1251 palAct
->setDisabled(true);
1252 ntscAct
->setDisabled(true);
1253 pauseAct
->setChecked(false);
1254 pauseAct
->setDisabled(false);
1255 showUntunedTankCircuit
= false;
1257 // Otherwise, we prepare for running regular software...
1260 // Should check for cartridgeLoaded here as well...!
1261 // We can clear it when toggling CDActive on, so that when we power cycle it
1262 // does the expected thing. Otherwise, if we use the file picker to insert a
1263 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1264 // works if the CD unit is active?
1265 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1268 WriteLog("GUI: Resetting Jaguar...\n");
1272 DebuggerResetWindows();
1273 CommonResetWindows();
1274 DACPauseAudioThread(false);
1279 // Toggle the emulator state, it can be either on or off
1280 void MainWin::ToggleRunState(void)
1282 startM68KTracing
= running
;
1288 // Set action buttons for the pause mode
1289 frameAdvanceAct
->setDisabled(false);
1290 pauseAct
->setChecked(true);
1291 pauseAct
->setDisabled(false);
1292 if (vjs
.softTypeDebugger
)
1294 traceStepIntoAct
->setDisabled(false);
1295 traceStepOverAct
->setDisabled(false);
1296 restartAct
->setDisabled(false);
1297 m68kDasmWin
->Use68KPCAddress();
1298 GPUDasmWin
->UseGPUPCAddress();
1299 DSPDasmWin
->UseDSPPCAddress();
1302 //if (!vjs.softTypeDebugger)
1304 // Restore the mouse pointer, if hidden:
1305 videoWidget
->CheckAndRestoreMouseCursor();
1307 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1309 uint32_t pixel
= videoWidget
->buffer
[i
];
1310 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1311 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1312 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1315 videoWidget
->updateGL();
1317 cpuBrowseWin
->HoldBPM();
1318 cpuBrowseWin
->HandleBPMContinue();
1324 frameAdvanceAct
->setDisabled(true);
1325 pauseAct
->setChecked(false);
1326 pauseAct
->setDisabled(false);
1327 if (vjs
.softTypeDebugger
)
1329 traceStepIntoAct
->setDisabled(true);
1330 traceStepOverAct
->setDisabled(true);
1331 restartAct
->setDisabled(true);
1332 BreakpointsWin
->RefreshContents();
1335 cpuBrowseWin
->UnholdBPM();
1338 // Pause/unpause any running/non-running threads...
1339 DACPauseAudioThread(!running
);
1343 void MainWin::SetZoom100(void)
1350 void MainWin::SetZoom200(void)
1357 void MainWin::SetZoom300(void)
1364 void MainWin::SetNTSC(void)
1366 powerAct
->setIcon(powerRed
);
1367 timer
->setInterval(16);
1368 vjs
.hardwareTypeNTSC
= true;
1374 void MainWin::SetPAL(void)
1376 powerAct
->setIcon(powerGreen
);
1377 timer
->setInterval(20);
1378 vjs
.hardwareTypeNTSC
= false;
1384 void MainWin::ToggleBlur(void)
1386 vjs
.glFilter
= !vjs
.glFilter
;
1391 void MainWin::ShowAboutWin(void)
1397 void MainWin::ShowHelpWin(void)
1403 void MainWin::InsertCart(void)
1405 // Check to see if we did autorun, 'cause we didn't load anything in that
1407 if (!scannedSoftwareFolder
)
1409 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1410 scannedSoftwareFolder
= true;
1413 // If the emulator is running, we pause it here and unpause it later
1414 // if we dismiss the file selector without choosing anything
1415 if (running
&& powerButtonOn
)
1418 pauseForFileSelector
= true;
1421 filePickWin
->show();
1425 void MainWin::Unpause(void)
1427 // Here we unpause the emulator if it was paused when we went into the file selector
1428 if (pauseForFileSelector
)
1430 pauseForFileSelector
= false;
1432 // Some nutter might have unpaused while in the file selector, so check for that
1439 // Jaguar initialisation and load software file
1440 void MainWin::LoadSoftware(QString file
)
1442 running
= false; // Prevent bad things(TM) from happening...
1443 pauseForFileSelector
= false; // Reset the file selector pause flag
1445 // Setup BIOS in his own dedicated Jaguar memory
1446 #ifndef NEWMODELSBIOSHANDLER
1447 uint8_t * biosPointer
= jaguarBootROM
;
1449 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1451 biosPointer
= jaguarDevBootROM2
;
1454 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1456 SelectBIOS(vjs
.biosType
);
1459 // Turn 'on' the power to initialize the Jaguar
1460 powerAct
->setDisabled(false);
1461 powerAct
->setChecked(true);
1462 powerButtonOn
= false;
1465 // We have to load our software *after* the Jaguar RESET
1466 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1467 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1469 // This is icky because we've already done it
1470 // it gets worse :-P
1471 if (!vjs
.useJaguarBIOS
)
1473 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1478 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1479 if (vjs
.softTypeDebugger
)
1481 m68k_set_reg(M68K_REG_A6
, 0);
1482 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1483 //pauseAct->setDisabled(false);
1484 //pauseAct->setChecked(true);
1490 // Prevent the launch in case of software without a start address and without BIOS presence
1491 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1497 // Display the Atari Jaguar software which is running
1498 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1500 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1501 setWindowTitle(newTitle
);
1506 void MainWin::ToggleCDUsage(void)
1508 CDActive
= !CDActive
;
1510 // Set up the Jaguar CD for execution, otherwise, clear memory
1512 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1514 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1518 // Open, or display, the breakpoints list window
1519 void MainWin::ShowBreakpointsWin(void)
1521 BreakpointsWin
->show();
1522 BreakpointsWin
->RefreshContents();
1526 // Delete all breakpoints
1527 void MainWin::DeleteAllBreakpoints(void)
1529 cpuBrowseWin
->ResetBPM();
1531 ShowBreakpointsWin();
1535 // Disable all breakpoints
1536 void MainWin::DisableAllBreakpoints(void)
1538 cpuBrowseWin
->DisableBPM();
1540 ShowBreakpointsWin();
1544 // Open, or display, the new breakpoint function window
1545 void MainWin::ShowNewFunctionBreakpointWin(void)
1547 NewFunctionBreakpointWin
->show();
1548 ShowBreakpointsWin();
1552 // Display list of files found in cartridge
1553 void MainWin::ShowCartFilesListWin(void)
1555 CartFilesListWin
->show();
1556 CartFilesListWin
->RefreshContents();
1560 // Display the save dump pickup file
1561 void MainWin::ShowSaveDumpAsWin(void)
1563 SaveDumpAsWin
->show();
1568 void MainWin::DebuggerTraceStepInto(void)
1571 videoWidget
->updateGL();
1574 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1576 #warning "!!! Need to verify the Step Into function !!!"
1581 // Restart the Jaguar executable
1582 void MainWin::DebuggerRestart(void)
1587 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1588 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1590 m68k_set_reg(M68K_REG_A6
, 0);
1591 m68k_brk_hitcounts_reset();
1593 DebuggerResetWindows();
1594 CommonResetWindows();
1597 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1599 #warning "!!! Need to verify the Restart function !!!"
1605 void MainWin::DebuggerTraceStepOver(void)
1608 videoWidget
->updateGL();
1611 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1613 #warning "!!! Need to verify the Step Over function !!!"
1618 // Advance / Execute for one frame
1619 void MainWin::FrameAdvance(void)
1621 //printf("Frame Advance...\n");
1623 // Execute 1 frame, then exit (only useful in Pause mode)
1625 //if (!vjs.softTypeDebugger)
1626 videoWidget
->updateGL();
1628 // Need to execute 1 frames' worth of DSP thread as well :-/
1630 //m68kDasmWin->Use68KPCAddress();
1633 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1635 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1640 void MainWin::SetFullScreen(bool state
/*= true*/)
1642 if (!vjs
.softTypeDebugger
)
1646 mainWinPosition
= pos();
1648 statusBar()->hide();
1654 // This is needed because the fullscreen may happen on a different
1655 // screen than screen 0:
1656 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1657 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1658 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1659 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1660 double aspectRatio
= targetWidth
/ targetHeight
;
1661 // NOTE: Really should check here to see which dimension constrains the
1662 // other. Right now, we assume that height is the constraint.
1663 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1664 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1665 videoWidget
->fullscreen
= true;
1666 videoWidget
->outputWidth
= newWidth
;
1667 videoWidget
->setFixedSize(r
.width(), r
.height());
1672 // Seems Qt is fussy about this: showNormal() has to go first, or it
1673 // will keep the window stuck in a psuedo-fullscreen mode with no way
1674 // to get out of it (except closing the app).
1677 // Reset the video widget to windowed mode
1678 videoWidget
->offset
= 0;
1679 videoWidget
->fullscreen
= false;
1681 statusBar()->show();
1688 move(mainWinPosition
);
1694 void MainWin::ToggleFullScreen(void)
1696 fullScreen
= !fullScreen
;
1697 SetFullScreen(fullScreen
);
1702 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1704 exceptionvectortableBrowseWin
->show();
1705 exceptionvectortableBrowseWin
->RefreshContents();
1710 void MainWin::ShowLocalBrowserWin(void)
1712 LocalBrowseWin
->show();
1713 LocalBrowseWin
->RefreshContents();
1718 void MainWin::ShowCallStackBrowserWin(void)
1720 CallStackBrowseWin
->show();
1721 CallStackBrowseWin
->RefreshContents();
1725 void MainWin::ShowAllWatchBrowserWin(void)
1727 allWatchBrowseWin
->show();
1728 allWatchBrowseWin
->RefreshContents();
1732 void MainWin::ShowHeapAllocatorBrowserWin(void)
1734 heapallocatorBrowseWin
->show();
1735 heapallocatorBrowseWin
->RefreshContents();
1739 void MainWin::ShowMemoryBrowserWin(void)
1741 memBrowseWin
->show();
1742 memBrowseWin
->RefreshContents();
1746 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1748 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1750 mem1BrowseWin
[NumWin
]->show();
1751 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1756 void MainWin::ShowEmuStatusWin(void)
1758 emuStatusWin
->show();
1759 emuStatusWin
->RefreshContents();
1763 void MainWin::ShowStackBrowserWin(void)
1765 stackBrowseWin
->show();
1766 stackBrowseWin
->RefreshContents();
1770 void MainWin::ShowCPUBrowserWin(void)
1772 cpuBrowseWin
->show();
1773 cpuBrowseWin
->RefreshContents();
1777 // Show the OP browser window
1778 void MainWin::ShowOPBrowserWin(void)
1780 opBrowseWin
->show();
1781 opBrowseWin
->RefreshContents();
1785 // Show the HW registers browser window
1786 void MainWin::ShowHWRegsBrowserWin(void)
1788 hwRegsBrowseWin
->show();
1789 hwRegsBrowseWin
->RefreshContents();
1793 // Show the M68K browser window
1794 void MainWin::ShowM68KDasmBrowserWin(void)
1796 m68kDasmBrowseWin
->show();
1797 m68kDasmBrowseWin
->RefreshContents();
1801 void MainWin::ShowRISCDasmBrowserWin(void)
1803 riscDasmBrowseWin
->show();
1804 riscDasmBrowseWin
->RefreshContents();
1810 void MainWin::ShowDasmWin(void)
1813 // DasmWin->RefreshContents();
1820 void MainWin::ShowVideoOutputWin(void)
1822 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1823 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1824 //VideoOutputWindowCentrale->show();
1825 //memBrowseWin->show();
1826 //VideoOutputWin->show();
1827 //VideoOutputWin->RefreshContents(videoWidget);
1832 // Resize video window based on zoom factor
1833 // It doesn't apply in debugger mode as we use this window to display disassembly
1834 void MainWin::ResizeMainWindow(void)
1836 if (!vjs
.softTypeDebugger
)
1838 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1840 // Show the test pattern if user requested plzDontKillMyComputer mode
1841 if (!powerButtonOn
&& plzDontKillMyComputer
)
1843 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1845 if (vjs
.hardwareTypeNTSC
)
1847 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1851 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1862 void MainWin::ReadSettings(void)
1866 QSettings
settings("Underground Software", "Virtual Jaguar");
1868 //zoomLevel = settings.value("zoom", 2).toInt();
1869 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1870 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1872 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1873 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1874 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1875 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1876 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1877 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1878 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1879 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1880 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1881 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1882 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1883 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1884 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1885 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1886 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1887 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1888 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1889 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1890 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1891 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1892 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1894 // Read settings from the Debugger mode
1895 settings
.beginGroup("debugger");
1896 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1897 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1898 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1899 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1900 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1901 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1902 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1903 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1904 settings
.endGroup();
1906 // Read settings from the Alpine mode
1907 settings
.beginGroup("alpine");
1908 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1909 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1910 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1911 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1912 settings
.endGroup();
1914 // Read settings from the Keybindings
1915 settings
.beginGroup("keybindings");
1916 for (i
= 0; i
< KB_END
; i
++)
1918 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1920 settings
.endGroup();
1922 // Write important settings to the log file
1923 WriteLog("MainWin: Paths\n");
1924 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1925 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1926 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1927 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1928 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1929 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1930 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1931 WriteLog("MainWin: Misc.\n");
1932 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1935 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1936 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1937 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1938 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1939 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1940 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1941 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1942 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1943 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1944 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1945 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1946 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1947 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1948 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1949 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1950 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1951 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1952 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1953 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1954 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1955 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1956 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1958 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1959 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1960 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1961 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1962 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1963 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1964 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1965 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1966 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1967 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1968 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1969 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1970 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1971 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1972 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1973 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1974 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1975 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1976 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1977 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1978 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1981 WriteLog("Read setting = Done\n");
1983 ReadProfiles(&settings
);
1984 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
1989 // Default values will be used in case of no settings can be found
1991 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1993 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1995 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1996 void MainWin::ReadUISettings(void)
2003 // Point on the emulator settings
2004 QSettings
settings("Underground Software", "Virtual Jaguar");
2005 settings
.beginGroup("ui");
2007 // Emulator main window UI information
2008 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
2009 size
= settings
.value("size", QSize(400, 400)).toSize();
2011 move(mainWinPosition
);
2012 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
2013 filePickWin
->move(pos
);
2015 // Video output information
2016 zoomLevel
= settings
.value("zoom", 2).toInt();
2018 // Emulator status UI information
2019 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2020 emuStatusWin
->move(pos
);
2021 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2023 // Alpine debug UI information (also needed by the Debugger)
2024 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2026 // CPU registers UI information
2027 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
2028 cpuBrowseWin
->move(pos
);
2029 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
2031 // Memory browser UI information
2032 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
2033 memBrowseWin
->move(pos
);
2034 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
2036 // Stack browser UI information
2037 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
2038 stackBrowseWin
->move(pos
);
2039 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2040 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2041 stackBrowseWin
->resize(size
);
2043 // OP (Object Processor) UI information
2044 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2045 opBrowseWin
->move(pos
);
2046 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2047 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2048 opBrowseWin
->resize(size
);
2050 // HW registers UI information
2051 pos
= settings
.value("hwRegsBrowseWinPos", QPoint(200, 200)).toPoint();
2052 hwRegsBrowseWin
->move(pos
);
2053 settings
.value("hwRegsBrowseWinIsVisible", false).toBool() ? ShowHWRegsBrowserWin() : void();
2054 size
= settings
.value("hwRegsBrowseWinSize", QSize(400, 400)).toSize();
2055 hwRegsBrowseWin
->resize(size
);
2057 // RISC disassembly UI information
2058 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2059 riscDasmBrowseWin
->move(pos
);
2060 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2062 // M68k disassembly UI information
2063 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2064 m68kDasmBrowseWin
->move(pos
);
2065 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2067 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2069 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2073 // Debugger UI information
2074 if (vjs
.softTypeDebugger
)
2077 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2078 m68kDasmWin
->move(pos
);
2079 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2080 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2081 GPUDasmWin
->move(pos
);
2082 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2083 DSPDasmWin
->move(pos
);
2085 // All watch browser UI information
2086 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2087 allWatchBrowseWin
->move(pos
);
2088 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2089 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2090 allWatchBrowseWin
->resize(size
);
2092 // Local browser UI information
2093 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2094 LocalBrowseWin
->move(pos
);
2095 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2096 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2097 LocalBrowseWin
->resize(size
);
2099 // Heap memory allocation browser UI information
2100 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2101 heapallocatorBrowseWin
->move(pos
);
2102 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2103 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2104 heapallocatorBrowseWin
->resize(size
);
2106 // Exception Vector Table UI Information
2107 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2108 exceptionvectortableBrowseWin
->move(pos
);
2109 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2110 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2111 exceptionvectortableBrowseWin
->resize(size
);
2113 // Call Stack browser UI information
2114 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2115 CallStackBrowseWin
->move(pos
);
2116 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2117 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2118 CallStackBrowseWin
->resize(size
);
2120 // cartridge directory and files UI information
2121 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2122 CartFilesListWin
->move(pos
);
2123 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2124 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2125 CartFilesListWin
->resize(size
);
2127 // Save dump UI information
2128 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2129 SaveDumpAsWin
->move(pos
);
2130 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2131 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2132 SaveDumpAsWin
->resize(size
);
2134 // Breakpoints UI information
2135 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2136 BreakpointsWin
->move(pos
);
2137 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2138 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2139 BreakpointsWin
->resize(size
);
2140 // New function breakpoint UI information
2141 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2142 NewFunctionBreakpointWin
->move(pos
);
2143 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2144 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2145 NewFunctionBreakpointWin
->resize(size
);
2147 // Memories browser UI information
2148 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2150 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2151 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2152 mem1BrowseWin
[i
]->move(pos
);
2153 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2154 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2155 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2156 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2157 mem1BrowseWin
[i
]->resize(size
);
2161 settings
.endGroup();
2163 WriteLog("Read UI setting = Done\n");
2167 // Save the settings
2168 void MainWin::WriteSettings(void)
2172 // Point on the emulator settings
2173 QSettings
settings("Underground Software", "Virtual Jaguar");
2174 //settings.setValue("pos", pos());
2175 //settings.setValue("size", size());
2176 //settings.setValue("cartLoadPos", filePickWin->pos());
2178 //settings.setValue("zoom", zoomLevel);
2179 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2180 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2182 settings
.setValue("useJoystick", vjs
.useJoystick
);
2183 settings
.setValue("joyport", vjs
.joyport
);
2184 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2185 settings
.setValue("frameSkip", vjs
.frameSkip
);
2186 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2187 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2188 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2189 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2190 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2191 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2192 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2193 settings
.setValue("fullscreen", vjs
.fullscreen
);
2194 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2195 settings
.setValue("glFilterType", vjs
.glFilter
);
2196 settings
.setValue("renderType", vjs
.renderType
);
2197 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2198 settings
.setValue("biosType", vjs
.biosType
);
2199 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2200 //settings.setValue("JagBootROM", vjs.jagBootPath);
2201 //settings.setValue("CDBootROM", vjs.CDBootPath);
2202 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2203 settings
.setValue("ROMs", vjs
.ROMPath
);
2204 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2206 // Write settings from the Alpine mode
2207 settings
.beginGroup("alpine");
2208 settings
.setValue("refresh", vjs
.refresh
);
2209 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2210 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2211 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2212 settings
.endGroup();
2214 // Write settings from the Debugger mode
2215 settings
.beginGroup("debugger");
2216 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2217 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2218 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2219 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2220 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2221 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2222 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2223 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2224 settings
.endGroup();
2226 // Write settings from the Keybindings
2227 settings
.beginGroup("keybindings");
2228 for (i
= 0; i
< KB_END
; i
++)
2230 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2232 settings
.endGroup();
2235 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2236 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2237 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2238 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2239 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2240 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2241 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2242 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2243 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2244 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2245 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2246 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2247 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2248 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2249 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2250 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2251 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2252 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2253 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2254 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2255 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2257 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2258 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2259 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2260 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2261 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2262 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2263 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2264 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2265 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2266 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2267 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2268 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2269 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2270 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2271 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2272 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2273 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2274 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2275 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2276 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2277 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2280 WriteProfiles(&settings
);
2281 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2285 // Save the UI settings
2286 void MainWin::WriteUISettings(void)
2291 // Point on the emulator settings
2292 QSettings
settings("Underground Software", "Virtual Jaguar");
2293 settings
.beginGroup("ui");
2295 // Emulator UI information
2296 settings
.setValue("pos", pos());
2297 settings
.setValue("size", size());
2298 settings
.setValue("cartLoadPos", filePickWin
->pos());
2300 // Video output information
2301 settings
.setValue("zoom", zoomLevel
);
2303 // Common UI information
2304 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2305 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2307 // Alpine debug UI information (also needed by the Debugger)
2308 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2310 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2311 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2312 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2313 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2314 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2315 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2316 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2317 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2318 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2319 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2320 settings
.setValue("hwRegsBrowseWinPos", hwRegsBrowseWin
->pos());
2321 settings
.setValue("hwRegsBrowseWinIsVisible", hwRegsBrowseWin
->isVisible());
2322 settings
.setValue("hwRegsBrowseWinSize", hwRegsBrowseWin
->size());
2323 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2324 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2325 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2326 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2329 // Debugger UI information
2330 if (vjs
.softTypeDebugger
)
2333 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2334 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2335 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2336 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2338 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2339 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2340 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2341 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2342 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2343 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2344 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2345 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2346 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2347 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2348 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2349 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2350 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2351 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2352 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2353 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2354 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2355 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2356 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2357 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2358 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2359 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2360 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2361 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2362 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2363 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2364 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2366 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2368 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2369 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2370 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2371 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2372 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2373 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2377 settings
.endGroup();
2381 // Refresh alpine debug windows
2382 void MainWin::AlpineRefreshWindows(void)
2384 cpuBrowseWin
->RefreshContents();
2385 memBrowseWin
->RefreshContents();
2386 stackBrowseWin
->RefreshContents();
2387 opBrowseWin
->RefreshContents();
2388 riscDasmBrowseWin
->RefreshContents();
2389 m68kDasmBrowseWin
->RefreshContents();
2390 hwRegsBrowseWin
->RefreshContents();
2395 void MainWin::CommonResetWindows(void)
2401 void MainWin::CommonReset(void)
2406 // Reset soft debugger
2407 void MainWin::DebuggerReset(void)
2409 if (vjs
.softTypeDebugger
)
2411 DeleteAllBreakpoints();
2416 // Reset soft debugger windows
2417 void MainWin::DebuggerResetWindows(void)
2419 if (vjs
.softTypeDebugger
)
2421 FilesrcListWin
->Reset();
2422 allWatchBrowseWin
->Reset();
2423 heapallocatorBrowseWin
->Reset();
2424 BreakpointsWin
->Reset();
2425 CartFilesListWin
->Reset();
2426 //ResetAlpineWindows();
2431 // Refresh common windows
2432 void MainWin::CommonRefreshWindows(void)
2434 emuStatusWin
->RefreshContents();
2438 // Refresh view windows
2439 void MainWin::ViewRefreshWindows(void)
2441 CartFilesListWin
->RefreshContents();
2446 void MainWin::RefreshWindows(void)
2448 DebuggerRefreshWindows();
2449 CommonRefreshWindows();
2453 // Refresh soft debugger & alpine debug windows
2454 void MainWin::DebuggerRefreshWindows(void)
2456 if (vjs
.softTypeDebugger
)
2458 FilesrcListWin
->RefreshContents();
2459 m68kDasmWin
->RefreshContents();
2460 GPUDasmWin
->RefreshContents();
2461 DSPDasmWin
->RefreshContents();
2462 allWatchBrowseWin
->RefreshContents();
2463 LocalBrowseWin
->RefreshContents();
2464 CallStackBrowseWin
->RefreshContents();
2465 heapallocatorBrowseWin
->RefreshContents();
2466 BreakpointsWin
->RefreshContents();
2467 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2469 mem1BrowseWin
[i
]->RefreshContents(i
);
2472 AlpineRefreshWindows();
2473 ViewRefreshWindows();
2478 // Create and save screenshot
2479 void MainWin::MakeScreenshot(void)
2483 time_t now
= time(0);
2487 tstruct
= *localtime(&now
);
2488 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
);
2490 // Create screenshot
2491 screenshot
= videoWidget
->grabFrameBuffer();
2492 screenshot
.save((char *)Text
, "JPG", 100);