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>
8 // RG = Richard Goedeken
12 // --- ---------- ------------------------------------------------------------
13 // JLH 12/23/2009 Created this file
14 // JLH 12/20/2010 Added settings, menus & toolbars
15 // JLH 07/05/2011 Added CD BIOS functionality to GUI
16 // JPM June/2016 Visual Studio support & Soft debugger integration
17 // JPM 01/11/2017 Added stack browser
18 // JPM Feb./2017 Added GPU/DSP disassembly
19 // JPM 07/12/2017 Added all Watch window
20 // JPM Aug./2017 Added heap allocator and memories window, a restart feature, and a [Not Supported] breakpoints window
21 // 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
22 // JPM 11/04/2017 Added the local window
23 // JPM 08/31/2018 Added the call stack window
24 // JPM Sept./2018 Added the new Models and BIOS handler, a screenshot feature and source code files browsing
25 // JPM Oct./2018 Added search paths in the settings, breakpoints feature, cartridge view menu
26 // JPM 11/18/2018 Fix crash with non-debugger mode
27 // JPM April/2019 Added ELF sections check, added a save memory dump
28 // JPM Aug./2019 Update texts descriptions, set cartridge view menu for debugger mode only, added a HW registers browser and source level tracing
29 // JPM Marc./2020 Added the step over for source level tracing
30 // RG Jan./2021 Linux build fixes
35 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
36 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
37 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
38 // with 'R', etc) [DONE]
39 // - Controller configuration [DONE]
43 // - The source file listing do not need to be refresh more than one time
44 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
45 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
46 // - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't)
48 // SFDX CODE: S1E9T8H5M23YS
50 // Uncomment this for debugging...
52 //#define DEBUGFOO // Various tool debugging... but not used
53 //#define DEBUGTP // Toolpalette debugging... but not used
60 #include "configdialog.h"
61 #include "controllertab.h"
62 #include "keybindingstab.h"
63 #include "filepicker.h"
65 #include "generaltab.h"
71 #include "emustatus.h"
72 #include "debug/cpubrowser.h"
73 #include "debug/m68kdasmbrowser.h"
74 #include "debug/memorybrowser.h"
75 #include "debug/stackbrowser.h"
76 #include "debug/opbrowser.h"
77 #include "debug/riscdasmbrowser.h"
78 #include "debug/hwregsbrowser.h"
84 #ifndef NEWMODELSBIOSHANDLER
87 #include "jagstub2bios.h"
89 #include "modelsBIOS.h"
91 #include "jagcdbios.h"
93 #include "m68000/m68kinterface.h"
95 #include "debugger/DBGManager.h"
96 //#include "debugger/VideoWin.h"
97 //#include "debugger/DasmWin.h"
98 #include "debugger/SourcesWin.h"
99 #include "debugger/m68kDasmWin.h"
100 #include "debugger/GPUDasmWin.h"
101 #include "debugger/DSPDasmWin.h"
102 #include "debugger/memory1browser.h"
103 #include "debugger/BreakpointsWin.h"
104 #include "debugger/NewFnctBreakpointWin.h"
105 #include "debugger/FilesrcListWin.h"
106 #include "debugger/exceptionvectortablebrowser.h"
107 #include "debugger/allwatchbrowser.h"
108 #include "debugger/localbrowser.h"
109 #include "debugger/heapallocatorbrowser.h"
110 #include "debugger/callstackbrowser.h"
111 #include "debugger/CartFilesListWin.h"
112 #include "debugger/SaveDumpAsWin.h"
115 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
116 //#ifdef __GCCWIN32__
117 // Apparently on win32, usleep() is not pulled in by the usual suspects.
121 #include "_MSC_VER/unistd.h"
125 // The way BSNES controls things is by setting a timer with a zero
126 // timeout, sleeping if not emulating anything. Seems there has to be a
129 // It has a novel approach to plugging-in/using different video/audio/input
130 // methods, can we do something similar or should we just use the built-in
133 // We're going to try to use the built-in OpenGL support and see how it goes.
134 // We'll make the VJ core modular so that it doesn't matter what GUI is in
135 // use, we can drop it in anywhere and use it as-is.
137 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
138 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
139 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
145 for(int i
=0; i
<8; i
++)
149 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
152 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
155 //if (vjs.softTypeDebugger)
157 // mainWindowCentrale = new QMdiArea;
158 // setCentralWidget(mainWindowCentrale);
161 WriteLog("Window creation start\n");
164 videoWidget
= new GLWidget(this);
165 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
167 // set central output window
168 if (!vjs
.softTypeDebugger
)
170 setCentralWidget(videoWidget
);
174 mainWindowCentrale
= new QMdiArea(this);
175 setCentralWidget(mainWindowCentrale
);
178 setWindowIcon(QIcon(":/res/vj-icon.png"));
180 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
182 if (vjs
.hardwareTypeAlpine
)
183 title
+= QString(tr(" - Alpine Mode"));
185 if (vjs
.softTypeDebugger
)
186 title
+= QString(tr(" - Debugger Mode"));
188 setWindowTitle(title
);
190 // Windows common features
191 aboutWin
= new AboutWindow(this);
192 helpWin
= new HelpWindow(this);
193 filePickWin
= new FilePickerWindow(this);
194 emuStatusWin
= new EmuStatusWindow(this);
196 // Windows alpine mode features
197 memBrowseWin
= new MemoryBrowserWindow(this);
198 stackBrowseWin
= new StackBrowserWindow(this);
199 cpuBrowseWin
= new CPUBrowserWindow(this);
200 opBrowseWin
= new OPBrowserWindow(this);
201 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
202 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
203 hwRegsBrowseWin
= new HWRegsBrowserWindow(this);
205 // Windows debugger mode features
206 if (vjs
.softTypeDebugger
)
208 //VideoOutputWin = new VideoOutputWindow(this);
209 //VideoOutputWin->setCentralWidget()
210 //DasmWin = new DasmWindow();
211 //DasmWin = new DasmWindow(this);
212 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
213 LocalBrowseWin
= new LocalBrowserWindow(this);
214 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
215 BreakpointsWin
= new BreakpointsWindow(this);
216 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
217 SaveDumpAsWin
= new SaveDumpAsWindow(this);
218 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
219 CallStackBrowseWin
= new CallStackBrowserWindow(this);
220 CartFilesListWin
= new CartFilesListWindow(this);
222 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
224 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
226 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
228 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
230 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
233 // Setup dock to display source code filenames tree
234 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
235 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
237 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
238 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
239 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
241 // Setup dock to display disassembly
242 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
243 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
244 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
245 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
246 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
248 dasmtabWidget
= new QTabWidget(this);
251 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
252 dasmtabWidget
->addTab(SourcesWin
= new SourcesWindow(this), tr("Sources"));
253 dasmtabWidget
->setCurrentIndex(dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000")));
254 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
255 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
256 connect(dasmtabWidget
, SIGNAL(currentChanged(const int)), this, SLOT(SelectdasmtabWidget(const int)));
258 setCentralWidget(dasmtabWidget
);
262 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
263 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
265 setUnifiedTitleAndToolBarOnMac(true);
268 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
269 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
270 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
271 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
272 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
275 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
276 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
277 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
278 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
279 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
280 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
281 powerAct
->setCheckable(true);
282 powerAct
->setChecked(false);
283 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
287 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
288 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
289 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
290 pauseAct
->setStatusTip(tr("Toggles the running state"));
291 pauseAct
->setCheckable(true);
292 pauseAct
->setDisabled(true);
293 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
294 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
295 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
298 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
299 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
300 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
301 screenshotAct
->setCheckable(false);
302 screenshotAct
->setDisabled(false);
303 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
306 zoomActs
= new QActionGroup(this);
307 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
308 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
309 x1Act
->setCheckable(true);
310 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
311 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
312 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
313 x2Act
->setCheckable(true);
314 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
315 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
316 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
317 x3Act
->setCheckable(true);
318 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
321 tvTypeActs
= new QActionGroup(this);
322 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
323 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
324 ntscAct
->setCheckable(true);
325 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
326 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
327 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
328 palAct
->setCheckable(true);
329 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
332 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
333 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
334 blurAct
= new QAction(blur
, tr("Blur"), this);
335 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
336 blurAct
->setCheckable(true);
337 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
340 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
341 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
342 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
345 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
346 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
347 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
349 // File pickup action
350 if (!vjs
.softTypeDebugger
)
352 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
353 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
357 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
358 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
360 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
361 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
362 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
364 // Configuration action
365 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
366 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
367 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
368 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
369 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
371 // Emulation status action
372 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
373 emustatusAct
->setStatusTip(tr("Emulator status"));
374 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
375 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
376 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
379 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
380 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
381 useCDAct
->setCheckable(true);
382 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
384 // Frame advance action
385 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
386 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
387 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
388 frameAdvanceAct
->setDisabled(true);
389 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
392 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
393 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
394 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
395 fullScreenAct
->setCheckable(true);
396 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
398 // Actions dedicated to debugger mode
399 if (vjs
.softTypeDebugger
)
402 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
403 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
404 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
405 restartAct
->setCheckable(false);
406 restartAct
->setDisabled(true);
407 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
410 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
411 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
412 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
413 traceStepOverAct
->setCheckable(false);
414 traceStepOverAct
->setDisabled(true);
415 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
417 // Trace into tracing
418 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
419 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
420 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
421 traceStepIntoAct
->setCheckable(false);
422 traceStepIntoAct
->setDisabled(true);
423 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
425 // Function breakpoint
426 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
427 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
428 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
429 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
430 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
431 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
432 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
433 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
434 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
435 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
436 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
439 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
440 saveDumpAsAct
->setCheckable(false);
441 saveDumpAsAct
->setDisabled(false);
442 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
444 //VideoOutputAct = new QAction(tr("Output Video"), this);
445 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
446 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
448 //DasmAct = new QAction(tr("Disassembly"), this);
449 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
450 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
452 // Exception vector table window
453 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
454 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
455 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
457 // All watch variables window
458 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
459 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
460 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
462 // Local variables window
463 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
464 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
465 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
467 // Heap (memory) allocation window
468 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
469 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
470 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
473 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
474 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
475 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
478 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
479 CartFilesListAct
->setStatusTip(tr("List of the files in the cartridge's directory structure"));
480 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
483 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
484 QSignalMapper
*signalMapper
= new QSignalMapper(this);
486 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
488 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
490 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
493 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
494 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
495 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
496 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
497 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
498 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
502 // Memory browser window action
503 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
504 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
505 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
507 // Stack browser window action
508 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
509 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
510 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
512 // CPUs (M68000, GPU & DSP browser window action
513 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
514 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
515 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
517 // OP browser window action
518 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
519 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
520 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
522 // M68000 disassembly browser window
523 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
524 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
525 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
527 // HW registers browser window
528 hwRegsBrowseAct
= new QAction(QIcon(":/res/tool-hw-regs.png"), tr("HW Registers Browser"), this);
529 hwRegsBrowseAct
->setStatusTip(tr("Shows the HW registers browser window"));
530 connect(hwRegsBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHWRegsBrowserWin()));
532 // Risc (DSP / GPU) disassembly browser window
533 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
534 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
535 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
537 // Misc. connections...
538 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
539 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
543 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
544 fileMenu
->addAction(powerAct
);
545 if (!vjs
.softTypeDebugger
)
547 fileMenu
->addAction(pauseAct
);
548 // fileMenu->addAction(frameAdvanceAct);
550 fileMenu
->addAction(filePickAct
);
551 fileMenu
->addAction(useCDAct
);
552 fileMenu
->addAction(configAct
);
553 fileMenu
->addAction(emustatusAct
);
554 fileMenu
->addSeparator();
555 fileMenu
->addAction(quitAppAct
);
557 // Alpine and debugger menus
558 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
561 debugMenu
= menuBar()->addMenu(tr("&Debug"));
563 // Create debugger menu
564 if (vjs
.softTypeDebugger
)
567 viewMenu
= menuBar()->addMenu(tr("&View"));
570 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
571 viewCartMenu
->addAction(CartFilesListAct
);
573 viewCartMenu
->addSeparator();
574 viewCartMenu
->addAction(CartStreamsAct
);
578 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
579 debugWindowsMenu
->addAction(BreakpointsAct
);
580 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
581 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
582 debugWindowsMenu
->addSeparator();
584 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
585 debugWindowOutputMenu
->addAction(VideoOutputAct
);
586 debugWindowsMenu
->addSeparator();
588 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
589 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
590 debugWindowsMenu
->addAction(LocalBrowseAct
);
591 debugWindowsMenu
->addSeparator();
592 debugWindowsMenu
->addAction(CallStackBrowseAct
);
593 debugWindowsMenu
->addSeparator();
594 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
595 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
596 debugWindowsMemoryMenu
->addSeparator();
597 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
599 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
601 debugWindowsMenu
->addSeparator();
602 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
603 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
604 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
605 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
606 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
607 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
608 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
609 debugWindowsBrowsesMenu
->addAction(hwRegsBrowseAct
);
610 debugMenu
->addSeparator();
611 debugMenu
->addAction(pauseAct
);
612 debugMenu
->addAction(frameAdvanceAct
);
613 debugMenu
->addAction(restartAct
);
614 debugMenu
->addSeparator();
615 debugMenu
->addAction(traceStepIntoAct
);
616 debugMenu
->addAction(traceStepOverAct
);
617 debugMenu
->addSeparator();
618 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
619 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
620 debugMenu
->addAction(deleteAllBreakpointsAct
);
621 debugMenu
->addAction(disableAllBreakpointsAct
);
622 debugMenu
->addSeparator();
623 debugMenu
->addAction(saveDumpAsAct
);
625 debugMenu
->addSeparator();
626 debugMenu
->addAction(DasmAct
);
631 // Create alpine menu
632 debugMenu
->addAction(memBrowseAct
);
633 debugMenu
->addAction(stackBrowseAct
);
634 debugMenu
->addAction(cpuBrowseAct
);
635 debugMenu
->addAction(opBrowseAct
);
636 debugMenu
->addAction(m68kDasmBrowseAct
);
637 debugMenu
->addAction(riscDasmBrowseAct
);
638 debugMenu
->addAction(hwRegsBrowseAct
);
643 helpMenu
= menuBar()->addMenu(tr("&Help"));
644 helpMenu
->addAction(helpAct
);
645 helpMenu
->addAction(aboutAct
);
649 toolbar
= addToolBar(tr("System"));
650 toolbar
->addAction(powerAct
);
651 if (!vjs
.softTypeDebugger
)
653 toolbar
->addAction(pauseAct
);
654 toolbar
->addAction(frameAdvanceAct
);
656 toolbar
->addAction(filePickAct
);
657 toolbar
->addAction(useCDAct
);
658 toolbar
->addSeparator();
659 if (!vjs
.softTypeDebugger
)
661 toolbar
->addAction(screenshotAct
);
662 toolbar
->addSeparator();
663 toolbar
->addAction(x1Act
);
664 toolbar
->addAction(x2Act
);
665 toolbar
->addAction(x3Act
);
666 toolbar
->addSeparator();
667 toolbar
->addAction(ntscAct
);
668 toolbar
->addAction(palAct
);
669 toolbar
->addSeparator();
670 toolbar
->addAction(blurAct
);
671 toolbar
->addAction(fullScreenAct
);
675 debuggerbar
= addToolBar(tr("&Debugger"));
676 debuggerbar
->addAction(pauseAct
);
677 debuggerbar
->addAction(frameAdvanceAct
);
678 debuggerbar
->addAction(restartAct
);
679 debuggerbar
->addSeparator();
680 debuggerbar
->addAction(traceStepIntoAct
);
681 debuggerbar
->addAction(traceStepOverAct
);
682 debuggerbar
->addSeparator();
683 debuggerbar
->addAction(BreakpointsAct
);
686 if (vjs
.hardwareTypeAlpine
)
688 debugbar
= addToolBar(tr("&Debug"));
689 debugbar
->addAction(memBrowseAct
);
690 debugbar
->addAction(stackBrowseAct
);
691 debugbar
->addAction(cpuBrowseAct
);
692 debugbar
->addAction(opBrowseAct
);
693 debugbar
->addAction(m68kDasmBrowseAct
);
694 debugbar
->addAction(riscDasmBrowseAct
);
695 debugbar
->addAction(hwRegsBrowseAct
);
698 // Add actions to the main window, as hiding widgets with them
700 addAction(fullScreenAct
);
701 addAction(quitAppAct
);
702 addAction(configAct
);
703 addAction(emustatusAct
);
705 addAction(filePickAct
);
706 addAction(frameAdvanceAct
);
709 statusBar()->showMessage(tr("Ready"));
711 // Do this in case original size isn't correct (mostly for the first-run case)
714 WriteLog("Window creation done\n");
716 // Create our test pattern NTSC bitmap
717 WriteLog("Test pattern 1 bitmap\n");
719 QImage
tempImg(":/res/test-pattern.jpg");
720 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
722 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
724 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
726 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
728 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
729 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
733 // Create our test pattern PAL bitmap
734 WriteLog("Test pattern 2 bitmap\n");
736 QImage
tempImg2(":/res/test-pattern-pal.jpg");
737 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
739 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
741 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
743 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
745 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
746 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
750 // Set up timer based loop for animation...
751 timer
= new QTimer(this);
752 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
754 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
755 // This is because it's discarding the 0.6666... on the end of the fraction.
756 // Alas, 6 doesn't divide cleanly into 10. :-P
757 //Should we defer this until SyncUI? Probably.
758 //No, it doesn't work, because it uses setInterval() instead of start()...
759 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
761 // We set this initially, to make VJ behave somewhat as it would if no
762 // cart were inserted and the BIOS was set as active...
763 jaguarCartInserted
= true;
764 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
765 WriteLog("VJ: Initializing jaguar subsystem...\n");
768 #ifndef NEWMODELSBIOSHANDLER
769 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
770 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
772 SelectBIOS(vjs
.biosType
);
775 // Prevent the file scanner from running if filename passed
776 // in on the command line...
780 // Load up the default ROM if in Alpine mode:
781 if (vjs
.hardwareTypeAlpine
)
783 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
785 // If regular load failed, try just a straight file load
786 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
788 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
791 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
793 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
795 // Attempt to load/run the ABS file...
796 LoadSoftware(vjs
.absROMPath
);
797 #ifndef NEWMODELSBIOSHANDLER
798 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
800 SelectBIOS(vjs
.biosType
);
802 // Prevent the scanner from running...
806 // Load up the default ROM if in Debugger mode:
807 if (vjs
.softTypeDebugger
)
809 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
811 // If regular load failed, try just a straight file load
812 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
814 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
817 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
819 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
821 // Attempt to load/run the ABS file...
822 LoadSoftware(vjs
.absROMPath
);
823 #ifndef NEWMODELSBIOSHANDLER
824 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
825 // Prevent the scanner from running...
827 SelectBIOS(vjs
.biosType
);
832 // Run the scanner if nothing passed in and *not* Alpine mode...
833 // NB: Really need to look into caching the info scanned in here...
834 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
835 scannedSoftwareFolder
= true;
839 void MainWin::LoadFile(QString file
)
845 void MainWin::SyncUI(void)
847 // Set toolbar buttons/menus based on settings read in (sync the UI)...
848 // (Really, this is to sync command line options passed in)
849 blurAct
->setChecked(vjs
.glFilter
);
850 x1Act
->setChecked(zoomLevel
== 1);
851 x2Act
->setChecked(zoomLevel
== 2);
852 x3Act
->setChecked(zoomLevel
== 3);
853 // running = powerAct->isChecked();
854 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
855 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
856 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
858 fullScreenAct
->setChecked(vjs
.fullscreen
);
859 fullScreen
= vjs
.fullscreen
;
860 SetFullScreen(fullScreen
);
862 // Reset the timer to be what was set in the command line (if any):
863 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
864 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
869 void MainWin::SelectdasmtabWidget(const int Index
)
874 SourcesWin
->RefreshContents();
879 void MainWin::closeEvent(QCloseEvent
* event
)
882 // This should only be done by the config dialog
885 event
->accept(); // ignore() if can't close for some reason
889 void MainWin::keyPressEvent(QKeyEvent
* e
)
891 #ifndef VJ_REMOVE_DEV_CODE
893 //extern bool startM68KTracing; // moved to jaguar.h
895 extern int blit_start_log
;
897 extern bool startConciseBlitLogging
;
900 // We ignore the Alt key for now, since it causes problems with the GUI
901 if (e
->key() == Qt::Key_Alt
)
906 // Bar this shite from release versions kthxbai
907 #ifndef VJ_REMOVE_DEV_CODE
908 else if (e
->key() == Qt::Key_F11
)
910 startM68KTracing
= true;
914 else if (e
->key() == Qt::Key_F12
)
916 blit_start_log
= true;
920 else if (e
->key() == Qt::Key_F10
)
922 startConciseBlitLogging
= true;
927 else if (e
->key() == Qt::Key_F8
)
929 // ggn: For extra NYAN pleasure...
930 // ggn: There you go James :P
931 // Shamus: Thanks for the patch! :-D
932 WriteLog(" o + + +\n");
933 WriteLog("+ o o + o\n");
934 WriteLog("-_-_-_-_-_-_-_,------, o \n");
935 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
936 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
937 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
938 WriteLog("+ o o + o\n");
945 This is done now by a QAction...
946 if (e->key() == Qt::Key_F9)
956 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
958 // We ignore the Alt key for now, since it causes problems with the GUI
959 if (e
->key() == Qt::Key_Alt
)
965 HandleKeys(e
, false);
969 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
971 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
972 // We kill bad key combos here, before they can get to the emulator...
973 // This also kills the illegal instruction problem that cropped up in
976 // First, settle key states...
977 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
978 keyHeld
[P1LEFT
] = state
;
979 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
980 keyHeld
[P1RIGHT
] = state
;
981 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
982 keyHeld
[P1UP
] = state
;
983 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
984 keyHeld
[P1DOWN
] = state
;
985 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
986 keyHeld
[P2LEFT
] = state
;
987 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
988 keyHeld
[P2RIGHT
] = state
;
989 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
990 keyHeld
[P2UP
] = state
;
991 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
992 keyHeld
[P2DOWN
] = state
;
994 // Next, check for conflicts and kill 'em if there are any...
995 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
996 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
998 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
999 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
1001 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
1002 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
1004 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
1005 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
1007 // No bad combos exist now, let's stuff the emulator key buffers...!
1008 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1010 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
1011 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
1013 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
1014 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
1020 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
1022 void MainWin::HandleGamepads(void)
1026 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1028 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1029 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
1031 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1032 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1037 void MainWin::Open(void)
1042 void MainWin::Configure(void)
1044 // Call the configuration dialog and update settings
1045 ConfigDialog
dlg(this);
1047 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1048 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1049 dlg
.controllerTab1
->SetupLastUsedProfile();
1050 // maybe instead of this, we tell the controller tab to work on a copy that gets
1051 // written if the user hits 'OK'.
1052 SaveProfiles(); // Just in case user cancels
1054 if (dlg
.exec() == false)
1060 QString before
= vjs
.ROMPath
;
1061 QString alpineBefore
= vjs
.alpineROMPath
;
1062 QString absBefore
= vjs
.absROMPath
;
1063 // bool audioBefore = vjs.audioEnabled;
1064 bool audioBefore
= vjs
.DSPEnabled
;
1065 dlg
.UpdateVJSettings();
1066 QString after
= vjs
.ROMPath
;
1067 QString alpineAfter
= vjs
.alpineROMPath
;
1068 QString absAfter
= vjs
.absROMPath
;
1069 // bool audioAfter = vjs.audioEnabled;
1070 bool audioAfter
= vjs
.DSPEnabled
;
1072 bool allowOld
= allowUnknownSoftware
;
1074 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1075 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1076 AutoConnectProfiles();
1078 // We rescan the "software" folder if the user either changed the path or
1079 // checked/unchecked the "Allow unknown files" option in the config dialog.
1080 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1081 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1083 // If the "Alpine" ROM is changed, then let's load it...
1084 if (alpineBefore
!= alpineAfter
)
1086 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1088 // Oh crap, we couldn't get the file! Alert the media!
1090 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1091 msg
.setIcon(QMessageBox::Warning
);
1096 // If the "ABS" ROM is changed, then let's load it...
1097 if (absBefore
!= absAfter
)
1099 if (!JaguarLoadFile(vjs
.absROMPath
))
1101 // Oh crap, we couldn't get the file! Alert the media!
1103 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1104 msg
.setIcon(QMessageBox::Warning
);
1109 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1110 // since it's running in the host audio IRQ...
1111 if (audioBefore
!= audioAfter
)
1117 // Just in case we crash before a clean exit...
1125 // Here's the main emulator loop
1127 void MainWin::Timer(void)
1130 static uint32_t ntscTickCount
;
1131 if (vjs
.hardwareTypeNTSC
)
1135 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1142 if (showUntunedTankCircuit
)
1144 // Some machines can't handle this, so we give them the option to disable it. :-)
1145 if (!plzDontKillMyComputer
)
1147 // if (!vjs.softTypeDebugger)
1149 // Random hash & trash
1150 // We try to simulate an untuned tank circuit here... :-)
1151 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1153 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1155 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1163 // Otherwise, run the Jaguar simulation
1166 //if (!vjs.softTypeDebugger)
1167 videoWidget
->HandleMouseHiding();
1169 static uint32_t refresh
= 0;
1170 // Do autorefresh on debug windows
1171 // Have to be careful, too much causes the emulator to slow way down!
1172 if (refresh
== vjs
.refresh
)
1174 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1176 AlpineRefreshWindows();
1177 //memBrowseWin->RefreshContents();
1178 //cpuBrowseWin->RefreshContents();
1180 CommonRefreshWindows();
1189 //if (!vjs.softTypeDebugger)
1190 videoWidget
->updateGL();
1193 // Approach: We use a ring buffer to store times (in ms) over a given
1194 // amount of frames, then sum them to figure out the FPS.
1195 uint32_t timestamp
= SDL_GetTicks();
1196 // This assumes the ring buffer size is a power of 2
1197 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1198 // Doing it this way is better. Ring buffer size can be arbitrary then.
1199 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1200 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1201 uint32_t elapsedTime
= 0;
1203 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1204 elapsedTime
+= ringBuffer
[i
];
1206 // elapsedTime must be non-zero
1207 if (elapsedTime
== 0)
1210 // This is in frames per 10 seconds, so we can have 1 decimal
1211 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1212 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1213 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1214 // If this is updated too frequently to be useful, we can throttle it down
1215 // so that it only updates every 10th frame or so
1216 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1217 oldTimestamp
= timestamp
;
1219 if (M68KDebugHaltStatus())
1224 // Toggle the power state, it can be either on or off
1225 void MainWin::TogglePowerState(void)
1227 powerButtonOn
= !powerButtonOn
;
1230 // With the power off, we simulate white noise on the screen. :-)
1233 // Restore the mouse pointer, if hidden:
1234 //if (!vjs.softTypeDebugger)
1236 videoWidget
->CheckAndRestoreMouseCursor();
1239 useCDAct
->setDisabled(false);
1240 palAct
->setDisabled(false);
1241 ntscAct
->setDisabled(false);
1242 pauseAct
->setChecked(false);
1243 pauseAct
->setDisabled(true);
1244 showUntunedTankCircuit
= true;
1246 DACPauseAudioThread();
1247 // 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. :-)
1250 if (plzDontKillMyComputer
)
1252 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1253 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1255 if (vjs
.hardwareTypeNTSC
)
1257 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1261 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1268 useCDAct
->setDisabled(true);
1269 palAct
->setDisabled(true);
1270 ntscAct
->setDisabled(true);
1271 pauseAct
->setChecked(false);
1272 pauseAct
->setDisabled(false);
1273 showUntunedTankCircuit
= false;
1275 // Otherwise, we prepare for running regular software...
1278 // Should check for cartridgeLoaded here as well...!
1279 // We can clear it when toggling CDActive on, so that when we power cycle it
1280 // does the expected thing. Otherwise, if we use the file picker to insert a
1281 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1282 // works if the CD unit is active?
1283 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1286 WriteLog("GUI: Resetting Jaguar...\n");
1290 DebuggerResetWindows();
1291 CommonResetWindows();
1292 DACPauseAudioThread(false);
1297 // Toggle the emulator state, it can be either on or off
1298 void MainWin::ToggleRunState(void)
1300 startM68KTracing
= running
;
1306 // Set action buttons for the pause mode
1307 frameAdvanceAct
->setDisabled(false);
1308 pauseAct
->setChecked(true);
1309 pauseAct
->setDisabled(false);
1310 if (vjs
.softTypeDebugger
)
1312 traceStepIntoAct
->setDisabled(false);
1313 traceStepOverAct
->setDisabled(false);
1314 restartAct
->setDisabled(false);
1315 m68kDasmWin
->Use68KPCAddress();
1316 GPUDasmWin
->UseGPUPCAddress();
1317 DSPDasmWin
->UseDSPPCAddress();
1320 //if (!vjs.softTypeDebugger)
1322 // Restore the mouse pointer, if hidden:
1323 videoWidget
->CheckAndRestoreMouseCursor();
1325 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1327 uint32_t pixel
= videoWidget
->buffer
[i
];
1328 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1329 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1330 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1333 videoWidget
->updateGL();
1335 cpuBrowseWin
->HoldBPM();
1336 cpuBrowseWin
->HandleBPMContinue();
1342 frameAdvanceAct
->setDisabled(true);
1343 pauseAct
->setChecked(false);
1344 pauseAct
->setDisabled(false);
1345 if (vjs
.softTypeDebugger
)
1347 traceStepIntoAct
->setDisabled(true);
1348 traceStepOverAct
->setDisabled(true);
1349 restartAct
->setDisabled(true);
1350 BreakpointsWin
->RefreshContents();
1353 cpuBrowseWin
->UnholdBPM();
1356 // Pause/unpause any running/non-running threads...
1357 DACPauseAudioThread(!running
);
1361 void MainWin::SetZoom100(void)
1368 void MainWin::SetZoom200(void)
1375 void MainWin::SetZoom300(void)
1382 void MainWin::SetNTSC(void)
1384 powerAct
->setIcon(powerRed
);
1385 timer
->setInterval(16);
1386 vjs
.hardwareTypeNTSC
= true;
1392 void MainWin::SetPAL(void)
1394 powerAct
->setIcon(powerGreen
);
1395 timer
->setInterval(20);
1396 vjs
.hardwareTypeNTSC
= false;
1402 void MainWin::ToggleBlur(void)
1404 vjs
.glFilter
= !vjs
.glFilter
;
1409 void MainWin::ShowAboutWin(void)
1415 void MainWin::ShowHelpWin(void)
1421 void MainWin::InsertCart(void)
1423 // Check to see if we did autorun, 'cause we didn't load anything in that
1425 if (!scannedSoftwareFolder
)
1427 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1428 scannedSoftwareFolder
= true;
1431 // If the emulator is running, we pause it here and unpause it later
1432 // if we dismiss the file selector without choosing anything
1433 if (running
&& powerButtonOn
)
1436 pauseForFileSelector
= true;
1439 filePickWin
->show();
1443 void MainWin::Unpause(void)
1445 // Here we unpause the emulator if it was paused when we went into the file selector
1446 if (pauseForFileSelector
)
1448 pauseForFileSelector
= false;
1450 // Some nutter might have unpaused while in the file selector, so check for that
1457 // Jaguar initialisation and load software file
1458 void MainWin::LoadSoftware(QString file
)
1460 running
= false; // Prevent bad things(TM) from happening...
1461 pauseForFileSelector
= false; // Reset the file selector pause flag
1463 // Setup BIOS in his own dedicated Jaguar memory
1464 #ifndef NEWMODELSBIOSHANDLER
1465 uint8_t * biosPointer
= jaguarBootROM
;
1467 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1469 biosPointer
= jaguarDevBootROM2
;
1472 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1474 SelectBIOS(vjs
.biosType
);
1477 // Turn 'on' the power to initialize the Jaguar
1478 powerAct
->setDisabled(false);
1479 powerAct
->setChecked(true);
1480 powerButtonOn
= false;
1483 // We have to load our software *after* the Jaguar RESET
1484 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1485 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1487 // This is icky because we've already done it
1488 // it gets worse :-P
1489 if (!vjs
.useJaguarBIOS
)
1491 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1496 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1497 if (vjs
.softTypeDebugger
)
1499 m68k_set_reg(M68K_REG_A6
, 0);
1500 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1502 //pauseAct->setDisabled(false);
1503 //pauseAct->setChecked(true);
1509 // Prevent the launch in case of software without a start address and without BIOS presence
1510 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1516 // Display the Atari Jaguar software which is running
1517 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1519 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1520 setWindowTitle(newTitle
);
1525 void MainWin::ToggleCDUsage(void)
1527 CDActive
= !CDActive
;
1529 // Set up the Jaguar CD for execution, otherwise, clear memory
1531 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1533 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1537 // Open, or display, the breakpoints list window
1538 void MainWin::ShowBreakpointsWin(void)
1540 BreakpointsWin
->show();
1541 BreakpointsWin
->RefreshContents();
1545 // Delete all breakpoints
1546 void MainWin::DeleteAllBreakpoints(void)
1548 cpuBrowseWin
->ResetBPM();
1550 ShowBreakpointsWin();
1554 // Disable all breakpoints
1555 void MainWin::DisableAllBreakpoints(void)
1557 cpuBrowseWin
->DisableBPM();
1559 ShowBreakpointsWin();
1563 // Open, or display, the new breakpoint function window
1564 void MainWin::ShowNewFunctionBreakpointWin(void)
1566 NewFunctionBreakpointWin
->SetFnctBreakpointWin(BreakpointsWin
);
1567 NewFunctionBreakpointWin
->show();
1568 ShowBreakpointsWin();
1572 // Display list of files found in cartridge
1573 void MainWin::ShowCartFilesListWin(void)
1575 CartFilesListWin
->show();
1576 CartFilesListWin
->RefreshContents();
1580 // Display the save dump pickup file
1581 void MainWin::ShowSaveDumpAsWin(void)
1583 SaveDumpAsWin
->show();
1588 void MainWin::DebuggerTraceStepInto(void)
1590 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1592 while (!SourcesWin
->CheckChangeLine())
1602 videoWidget
->updateGL();
1605 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1607 #warning "!!! Need to verify the Step Into function !!!"
1612 // Restart the Jaguar executable
1613 void MainWin::DebuggerRestart(void)
1618 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1619 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1621 dasmtabWidget
->setCurrentIndex(1); // set focus on the disasm M68K tab
1622 m68k_set_reg(M68K_REG_A6
, 0);
1623 m68k_brk_hitcounts_reset();
1625 DebuggerResetWindows();
1626 CommonResetWindows();
1630 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1632 #warning "!!! Need to verify the Restart function !!!"
1638 void MainWin::DebuggerTraceStepOver(void)
1640 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1642 while (!SourcesWin
->CheckChangeLine())
1652 videoWidget
->updateGL();
1655 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1657 #warning "!!! Need to verify the Step Over function !!!"
1662 // Advance / Execute for one frame
1663 void MainWin::FrameAdvance(void)
1665 //printf("Frame Advance...\n");
1667 // Execute 1 frame, then exit (only useful in Pause mode)
1669 //if (!vjs.softTypeDebugger)
1670 videoWidget
->updateGL();
1672 // Need to execute 1 frames' worth of DSP thread as well :-/
1674 //m68kDasmWin->Use68KPCAddress();
1677 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1679 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1684 void MainWin::SetFullScreen(bool state
/*= true*/)
1686 if (!vjs
.softTypeDebugger
)
1690 mainWinPosition
= pos();
1692 statusBar()->hide();
1698 // This is needed because the fullscreen may happen on a different
1699 // screen than screen 0:
1700 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1701 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1702 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1703 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1704 double aspectRatio
= targetWidth
/ targetHeight
;
1705 // NOTE: Really should check here to see which dimension constrains the
1706 // other. Right now, we assume that height is the constraint.
1707 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1708 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1709 videoWidget
->fullscreen
= true;
1710 videoWidget
->outputWidth
= newWidth
;
1711 videoWidget
->setFixedSize(r
.width(), r
.height());
1716 // Seems Qt is fussy about this: showNormal() has to go first, or it
1717 // will keep the window stuck in a psuedo-fullscreen mode with no way
1718 // to get out of it (except closing the app).
1721 // Reset the video widget to windowed mode
1722 videoWidget
->offset
= 0;
1723 videoWidget
->fullscreen
= false;
1725 statusBar()->show();
1732 move(mainWinPosition
);
1738 void MainWin::ToggleFullScreen(void)
1740 fullScreen
= !fullScreen
;
1741 SetFullScreen(fullScreen
);
1746 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1748 exceptionvectortableBrowseWin
->show();
1749 exceptionvectortableBrowseWin
->RefreshContents();
1754 void MainWin::ShowLocalBrowserWin(void)
1756 LocalBrowseWin
->show();
1757 LocalBrowseWin
->RefreshContents();
1762 void MainWin::ShowCallStackBrowserWin(void)
1764 CallStackBrowseWin
->show();
1765 CallStackBrowseWin
->RefreshContents();
1769 void MainWin::ShowAllWatchBrowserWin(void)
1771 allWatchBrowseWin
->show();
1772 allWatchBrowseWin
->RefreshContents();
1776 void MainWin::ShowHeapAllocatorBrowserWin(void)
1778 heapallocatorBrowseWin
->show();
1779 heapallocatorBrowseWin
->RefreshContents();
1783 void MainWin::ShowMemoryBrowserWin(void)
1785 memBrowseWin
->show();
1786 memBrowseWin
->RefreshContents();
1790 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1792 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1794 mem1BrowseWin
[NumWin
]->show();
1795 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1800 void MainWin::ShowEmuStatusWin(void)
1802 emuStatusWin
->show();
1803 emuStatusWin
->RefreshContents();
1807 void MainWin::ShowStackBrowserWin(void)
1809 stackBrowseWin
->show();
1810 stackBrowseWin
->RefreshContents();
1814 void MainWin::ShowCPUBrowserWin(void)
1816 cpuBrowseWin
->show();
1817 cpuBrowseWin
->RefreshContents();
1821 // Show the OP browser window
1822 void MainWin::ShowOPBrowserWin(void)
1824 opBrowseWin
->show();
1825 opBrowseWin
->RefreshContents();
1829 // Show the HW registers browser window
1830 void MainWin::ShowHWRegsBrowserWin(void)
1832 hwRegsBrowseWin
->show();
1833 hwRegsBrowseWin
->RefreshContents();
1837 // Show the M68K browser window
1838 void MainWin::ShowM68KDasmBrowserWin(void)
1840 m68kDasmBrowseWin
->show();
1841 m68kDasmBrowseWin
->RefreshContents();
1845 void MainWin::ShowRISCDasmBrowserWin(void)
1847 riscDasmBrowseWin
->show();
1848 riscDasmBrowseWin
->RefreshContents();
1854 void MainWin::ShowDasmWin(void)
1857 // DasmWin->RefreshContents();
1864 void MainWin::ShowVideoOutputWin(void)
1866 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1867 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1868 //VideoOutputWindowCentrale->show();
1869 //memBrowseWin->show();
1870 //VideoOutputWin->show();
1871 //VideoOutputWin->RefreshContents(videoWidget);
1876 // Resize video window based on zoom factor
1877 // It doesn't apply in debugger mode as we use this window to display disassembly
1878 void MainWin::ResizeMainWindow(void)
1880 if (!vjs
.softTypeDebugger
)
1882 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1884 // Show the test pattern if user requested plzDontKillMyComputer mode
1885 if (!powerButtonOn
&& plzDontKillMyComputer
)
1887 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1889 if (vjs
.hardwareTypeNTSC
)
1891 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1895 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1906 void MainWin::ReadSettings(void)
1910 QSettings
settings("Underground Software", "Virtual Jaguar");
1912 //zoomLevel = settings.value("zoom", 2).toInt();
1913 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1914 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1916 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1917 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1918 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1919 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1920 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1921 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1922 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1923 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1924 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1925 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1926 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1927 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1928 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1929 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1930 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1931 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1932 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1933 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1934 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1935 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1936 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1938 // Read settings from the Debugger mode
1939 settings
.beginGroup("debugger");
1940 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1941 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1942 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1943 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1944 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1945 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1946 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1947 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1948 settings
.endGroup();
1950 // Read settings from the Alpine mode
1951 settings
.beginGroup("alpine");
1952 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1953 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1954 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1955 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1956 vjs
.allowM68KExceptionCatch
= settings
.value("M68KExceptionCatch", false).toBool();
1957 settings
.endGroup();
1959 // Read settings from the Keybindings
1960 settings
.beginGroup("keybindings");
1961 for (i
= 0; i
< KB_END
; i
++)
1963 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1965 settings
.endGroup();
1967 // Write important settings to the log file
1968 WriteLog("MainWin: Paths\n");
1969 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1970 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1971 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1972 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1973 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1974 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1975 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1976 WriteLog("MainWin: Misc.\n");
1977 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1980 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1981 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1982 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1983 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1984 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1985 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1986 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1987 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1988 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1989 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1990 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1991 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1992 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1993 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1994 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1995 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1996 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1997 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1998 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1999 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
2000 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
2001 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
2003 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
2004 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
2005 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
2006 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
2007 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
2008 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
2009 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
2010 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
2011 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
2012 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
2013 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
2014 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
2015 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
2016 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
2017 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
2018 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
2019 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
2020 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
2021 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
2022 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
2023 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
2026 WriteLog("Read setting = Done\n");
2028 ReadProfiles(&settings
);
2029 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2034 // Default values will be used in case of no settings can be found
2036 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
2038 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
2040 // i.e., someone could drag it to another screen, close it, then disconnect that screen
2041 void MainWin::ReadUISettings(void)
2048 // Point on the emulator settings
2049 QSettings
settings("Underground Software", "Virtual Jaguar");
2050 settings
.beginGroup("ui");
2052 // Emulator main window UI information
2053 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
2054 size
= settings
.value("size", QSize(400, 400)).toSize();
2056 move(mainWinPosition
);
2057 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
2058 filePickWin
->move(pos
);
2060 // Video output information
2061 zoomLevel
= settings
.value("zoom", 2).toInt();
2063 // Emulator status UI information
2064 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2065 emuStatusWin
->move(pos
);
2066 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2068 // Alpine debug UI information (also needed by the Debugger)
2069 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2071 // CPU registers UI information
2072 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
2073 cpuBrowseWin
->move(pos
);
2074 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
2076 // Memory browser UI information
2077 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
2078 memBrowseWin
->move(pos
);
2079 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
2081 // Stack browser UI information
2082 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
2083 stackBrowseWin
->move(pos
);
2084 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2085 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2086 stackBrowseWin
->resize(size
);
2088 // OP (Object Processor) UI information
2089 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2090 opBrowseWin
->move(pos
);
2091 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2092 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2093 opBrowseWin
->resize(size
);
2095 // HW registers UI information
2096 pos
= settings
.value("hwRegsBrowseWinPos", QPoint(200, 200)).toPoint();
2097 hwRegsBrowseWin
->move(pos
);
2098 settings
.value("hwRegsBrowseWinIsVisible", false).toBool() ? ShowHWRegsBrowserWin() : void();
2099 size
= settings
.value("hwRegsBrowseWinSize", QSize(400, 400)).toSize();
2100 hwRegsBrowseWin
->resize(size
);
2102 // RISC disassembly UI information
2103 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2104 riscDasmBrowseWin
->move(pos
);
2105 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2107 // M68k disassembly UI information
2108 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2109 m68kDasmBrowseWin
->move(pos
);
2110 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2112 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2114 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2118 // Debugger UI information
2119 if (vjs
.softTypeDebugger
)
2122 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2123 m68kDasmWin
->move(pos
);
2124 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2125 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2126 GPUDasmWin
->move(pos
);
2127 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2128 DSPDasmWin
->move(pos
);
2130 // All watch browser UI information
2131 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2132 allWatchBrowseWin
->move(pos
);
2133 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2134 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2135 allWatchBrowseWin
->resize(size
);
2137 // Local browser UI information
2138 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2139 LocalBrowseWin
->move(pos
);
2140 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2141 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2142 LocalBrowseWin
->resize(size
);
2144 // Heap memory allocation browser UI information
2145 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2146 heapallocatorBrowseWin
->move(pos
);
2147 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2148 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2149 heapallocatorBrowseWin
->resize(size
);
2151 // Exception Vector Table UI Information
2152 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2153 exceptionvectortableBrowseWin
->move(pos
);
2154 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2155 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2156 exceptionvectortableBrowseWin
->resize(size
);
2158 // Call Stack browser UI information
2159 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2160 CallStackBrowseWin
->move(pos
);
2161 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2162 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2163 CallStackBrowseWin
->resize(size
);
2165 // cartridge directory and files UI information
2166 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2167 CartFilesListWin
->move(pos
);
2168 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2169 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2170 CartFilesListWin
->resize(size
);
2172 // Save dump UI information
2173 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2174 SaveDumpAsWin
->move(pos
);
2175 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2176 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2177 SaveDumpAsWin
->resize(size
);
2179 // Breakpoints UI information
2180 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2181 BreakpointsWin
->move(pos
);
2182 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2183 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2184 BreakpointsWin
->resize(size
);
2185 // New function breakpoint UI information
2186 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2187 NewFunctionBreakpointWin
->move(pos
);
2188 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2189 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2190 NewFunctionBreakpointWin
->resize(size
);
2192 // Memories browser UI information
2193 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2195 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2196 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2197 mem1BrowseWin
[i
]->move(pos
);
2198 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2199 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2200 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2201 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2202 mem1BrowseWin
[i
]->resize(size
);
2206 settings
.endGroup();
2208 WriteLog("Read UI setting = Done\n");
2212 // Save the settings
2213 void MainWin::WriteSettings(void)
2217 // Point on the emulator settings
2218 QSettings
settings("Underground Software", "Virtual Jaguar");
2219 //settings.setValue("pos", pos());
2220 //settings.setValue("size", size());
2221 //settings.setValue("cartLoadPos", filePickWin->pos());
2223 //settings.setValue("zoom", zoomLevel);
2224 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2225 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2227 settings
.setValue("useJoystick", vjs
.useJoystick
);
2228 settings
.setValue("joyport", vjs
.joyport
);
2229 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2230 settings
.setValue("frameSkip", vjs
.frameSkip
);
2231 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2232 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2233 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2234 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2235 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2236 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2237 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2238 settings
.setValue("fullscreen", vjs
.fullscreen
);
2239 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2240 settings
.setValue("glFilterType", vjs
.glFilter
);
2241 settings
.setValue("renderType", vjs
.renderType
);
2242 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2243 settings
.setValue("biosType", vjs
.biosType
);
2244 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2245 //settings.setValue("JagBootROM", vjs.jagBootPath);
2246 //settings.setValue("CDBootROM", vjs.CDBootPath);
2247 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2248 settings
.setValue("ROMs", vjs
.ROMPath
);
2249 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2251 // Write settings from the Alpine mode
2252 settings
.beginGroup("alpine");
2253 settings
.setValue("refresh", vjs
.refresh
);
2254 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2255 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2256 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2257 settings
.setValue("M68KExceptionCatch", vjs
.allowM68KExceptionCatch
);
2258 settings
.endGroup();
2260 // Write settings from the Debugger mode
2261 settings
.beginGroup("debugger");
2262 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2263 settings
.setValue("NbrDisasmLines", (qulonglong
) vjs
.nbrdisasmlines
);
2264 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2265 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2266 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2267 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2268 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2269 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2270 settings
.endGroup();
2272 // Write settings from the Keybindings
2273 settings
.beginGroup("keybindings");
2274 for (i
= 0; i
< KB_END
; i
++)
2276 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2278 settings
.endGroup();
2281 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2282 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2283 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2284 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2285 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2286 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2287 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2288 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2289 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2290 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2291 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2292 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2293 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2294 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2295 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2296 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2297 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2298 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2299 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2300 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2301 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2303 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2304 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2305 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2306 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2307 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2308 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2309 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2310 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2311 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2312 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2313 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2314 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2315 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2316 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2317 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2318 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2319 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2320 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2321 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2322 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2323 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2326 WriteProfiles(&settings
);
2327 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2331 // Save the UI settings
2332 void MainWin::WriteUISettings(void)
2337 // Point on the emulator settings
2338 QSettings
settings("Underground Software", "Virtual Jaguar");
2339 settings
.beginGroup("ui");
2341 // Emulator UI information
2342 settings
.setValue("pos", pos());
2343 settings
.setValue("size", size());
2344 settings
.setValue("cartLoadPos", filePickWin
->pos());
2346 // Video output information
2347 settings
.setValue("zoom", zoomLevel
);
2349 // Common UI information
2350 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2351 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2353 // Alpine debug UI information (also needed by the Debugger)
2354 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2356 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2357 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2358 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2359 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2360 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2361 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2362 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2363 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2364 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2365 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2366 settings
.setValue("hwRegsBrowseWinPos", hwRegsBrowseWin
->pos());
2367 settings
.setValue("hwRegsBrowseWinIsVisible", hwRegsBrowseWin
->isVisible());
2368 settings
.setValue("hwRegsBrowseWinSize", hwRegsBrowseWin
->size());
2369 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2370 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2371 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2372 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2375 // Debugger UI information
2376 if (vjs
.softTypeDebugger
)
2379 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2380 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2381 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2382 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2384 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2385 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2386 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2387 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2388 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2389 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2390 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2391 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2392 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2393 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2394 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2395 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2396 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2397 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2398 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2399 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2400 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2401 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2402 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2403 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2404 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2405 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2406 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2407 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2408 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2409 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2410 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2412 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2414 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2415 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2416 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2417 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2418 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2419 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2423 settings
.endGroup();
2427 // Refresh alpine debug windows
2428 void MainWin::AlpineRefreshWindows(void)
2430 cpuBrowseWin
->RefreshContents();
2431 memBrowseWin
->RefreshContents();
2432 stackBrowseWin
->RefreshContents();
2433 opBrowseWin
->RefreshContents();
2434 riscDasmBrowseWin
->RefreshContents();
2435 m68kDasmBrowseWin
->RefreshContents();
2436 hwRegsBrowseWin
->RefreshContents();
2441 void MainWin::CommonResetWindows(void)
2447 void MainWin::CommonReset(void)
2452 // Reset soft debugger
2453 void MainWin::DebuggerReset(void)
2455 if (vjs
.softTypeDebugger
)
2457 DeleteAllBreakpoints();
2462 // Reset soft debugger windows
2463 void MainWin::DebuggerResetWindows(void)
2465 if (vjs
.softTypeDebugger
)
2467 FilesrcListWin
->Reset();
2468 allWatchBrowseWin
->Reset();
2469 heapallocatorBrowseWin
->Reset();
2470 BreakpointsWin
->Reset();
2471 CartFilesListWin
->Reset();
2472 SourcesWin
->Reset();
2473 //ResetAlpineWindows();
2478 // Refresh common windows
2479 void MainWin::CommonRefreshWindows(void)
2481 emuStatusWin
->RefreshContents();
2485 // Refresh view windows
2486 void MainWin::ViewRefreshWindows(void)
2488 CartFilesListWin
->RefreshContents();
2493 void MainWin::RefreshWindows(void)
2495 DebuggerRefreshWindows();
2496 CommonRefreshWindows();
2500 // Refresh soft debugger & alpine debug windows
2501 void MainWin::DebuggerRefreshWindows(void)
2503 if (vjs
.softTypeDebugger
)
2505 FilesrcListWin
->RefreshContents();
2506 SourcesWin
->RefreshContents();
2507 m68kDasmWin
->RefreshContents();
2508 GPUDasmWin
->RefreshContents();
2509 DSPDasmWin
->RefreshContents();
2510 allWatchBrowseWin
->RefreshContents();
2511 LocalBrowseWin
->RefreshContents();
2512 CallStackBrowseWin
->RefreshContents();
2513 heapallocatorBrowseWin
->RefreshContents();
2514 BreakpointsWin
->RefreshContents();
2515 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2517 mem1BrowseWin
[i
]->RefreshContents(i
);
2520 AlpineRefreshWindows();
2521 ViewRefreshWindows();
2526 // Create and save screenshot
2527 void MainWin::MakeScreenshot(void)
2531 time_t now
= time(0);
2535 tstruct
= *localtime(&now
);
2536 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
);
2538 // Create screenshot
2539 screenshot
= videoWidget
->grabFrameBuffer();
2540 screenshot
.save((char *)Text
, "JPG", 100);