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 and source level tracing
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 // - The source file listing do not need to be refresh more than one time
40 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
41 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
42 // - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't)
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/SourcesWin.h"
95 #include "debugger/m68KDasmWin.h"
96 #include "debugger/GPUDasmWin.h"
97 #include "debugger/DSPDasmWin.h"
98 #include "debugger/memory1browser.h"
99 #include "debugger/BreakpointsWin.h"
100 #include "debugger/NewFnctBreakpointWin.h"
101 #include "debugger/FilesrcListWin.h"
102 #include "debugger/exceptionvectortablebrowser.h"
103 #include "debugger/allwatchbrowser.h"
104 #include "debugger/localbrowser.h"
105 #include "debugger/heapallocatorbrowser.h"
106 #include "debugger/callstackbrowser.h"
107 #include "debugger/CartFilesListWin.h"
108 #include "debugger/SaveDumpAsWin.h"
111 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
112 //#ifdef __GCCWIN32__
113 // Apparently on win32, usleep() is not pulled in by the usual suspects.
117 #include "_MSC_VER/unistd.h"
121 // The way BSNES controls things is by setting a timer with a zero
122 // timeout, sleeping if not emulating anything. Seems there has to be a
125 // It has a novel approach to plugging-in/using different video/audio/input
126 // methods, can we do something similar or should we just use the built-in
129 // We're going to try to use the built-in OpenGL support and see how it goes.
130 // We'll make the VJ core modular so that it doesn't matter what GUI is in
131 // use, we can drop it in anywhere and use it as-is.
133 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
134 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
135 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
141 for(int i
=0; i
<8; i
++)
145 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
148 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
151 //if (vjs.softTypeDebugger)
153 // mainWindowCentrale = new QMdiArea;
154 // setCentralWidget(mainWindowCentrale);
157 WriteLog("Window creation start\n");
160 videoWidget
= new GLWidget(this);
161 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
163 // set central output window
164 if (!vjs
.softTypeDebugger
)
166 setCentralWidget(videoWidget
);
170 mainWindowCentrale
= new QMdiArea(this);
171 setCentralWidget(mainWindowCentrale
);
174 setWindowIcon(QIcon(":/res/vj-icon.png"));
176 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
178 if (vjs
.hardwareTypeAlpine
)
179 title
+= QString(tr(" - Alpine Mode"));
181 if (vjs
.softTypeDebugger
)
182 title
+= QString(tr(" - Debugger Mode"));
184 setWindowTitle(title
);
186 // Windows common features
187 aboutWin
= new AboutWindow(this);
188 helpWin
= new HelpWindow(this);
189 filePickWin
= new FilePickerWindow(this);
190 emuStatusWin
= new EmuStatusWindow(this);
192 // Windows alpine mode features
193 memBrowseWin
= new MemoryBrowserWindow(this);
194 stackBrowseWin
= new StackBrowserWindow(this);
195 cpuBrowseWin
= new CPUBrowserWindow(this);
196 opBrowseWin
= new OPBrowserWindow(this);
197 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
198 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
199 hwRegsBrowseWin
= new HWRegsBrowserWindow(this);
201 // Windows debugger mode features
202 if (vjs
.softTypeDebugger
)
204 //VideoOutputWin = new VideoOutputWindow(this);
205 //VideoOutputWin->setCentralWidget()
206 //DasmWin = new DasmWindow();
207 //DasmWin = new DasmWindow(this);
208 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
209 LocalBrowseWin
= new LocalBrowserWindow(this);
210 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
211 BreakpointsWin
= new BreakpointsWindow(this);
212 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
213 SaveDumpAsWin
= new SaveDumpAsWindow(this);
214 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
215 CallStackBrowseWin
= new CallStackBrowserWindow(this);
216 CartFilesListWin
= new CartFilesListWindow(this);
218 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
220 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
222 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
224 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
226 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
229 // Setup dock to display source code filenames tree
230 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
231 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
233 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
234 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
235 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
237 // Setup dock to display disassembly
238 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
239 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
240 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
241 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
242 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
244 dasmtabWidget
= new QTabWidget(this);
247 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
248 dasmtabWidget
->addTab(SourcesWin
= new SourcesWindow(this), tr("Sources"));
249 dasmtabWidget
->setCurrentIndex(dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000")));
250 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
251 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
252 connect(dasmtabWidget
, SIGNAL(currentChanged(const int)), this, SLOT(SelectdasmtabWidget(const int)));
254 setCentralWidget(dasmtabWidget
);
258 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
259 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
261 setUnifiedTitleAndToolBarOnMac(true);
264 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
265 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
266 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
267 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
268 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
271 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
272 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
273 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
274 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
275 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
276 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
277 powerAct
->setCheckable(true);
278 powerAct
->setChecked(false);
279 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
283 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
284 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
285 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
286 pauseAct
->setStatusTip(tr("Toggles the running state"));
287 pauseAct
->setCheckable(true);
288 pauseAct
->setDisabled(true);
289 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
290 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
291 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
294 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
295 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
296 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
297 screenshotAct
->setCheckable(false);
298 screenshotAct
->setDisabled(false);
299 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
302 zoomActs
= new QActionGroup(this);
303 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
304 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
305 x1Act
->setCheckable(true);
306 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
307 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
308 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
309 x2Act
->setCheckable(true);
310 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
311 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
312 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
313 x3Act
->setCheckable(true);
314 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
317 tvTypeActs
= new QActionGroup(this);
318 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
319 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
320 ntscAct
->setCheckable(true);
321 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
322 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
323 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
324 palAct
->setCheckable(true);
325 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
328 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
329 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
330 blurAct
= new QAction(blur
, tr("Blur"), this);
331 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
332 blurAct
->setCheckable(true);
333 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
336 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
337 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
338 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
341 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
342 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
343 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
345 // File pickup action
346 if (!vjs
.softTypeDebugger
)
348 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
349 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
353 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
354 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
356 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
357 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
358 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
360 // Configuration action
361 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
362 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
363 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
364 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
365 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
367 // Emulation status action
368 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
369 emustatusAct
->setStatusTip(tr("Emulator status"));
370 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
371 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
372 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
375 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
376 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
377 useCDAct
->setCheckable(true);
378 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
380 // Frame advance action
381 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
382 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
383 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
384 frameAdvanceAct
->setDisabled(true);
385 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
388 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
389 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
390 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
391 fullScreenAct
->setCheckable(true);
392 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
394 // Actions dedicated to debugger mode
395 if (vjs
.softTypeDebugger
)
398 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
399 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
400 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
401 restartAct
->setCheckable(false);
402 restartAct
->setDisabled(true);
403 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
406 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
407 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
408 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
409 traceStepOverAct
->setCheckable(false);
410 traceStepOverAct
->setDisabled(true);
411 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
413 // Trace into tracing
414 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
415 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
416 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
417 traceStepIntoAct
->setCheckable(false);
418 traceStepIntoAct
->setDisabled(true);
419 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
421 // Function breakpoint
422 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
423 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
424 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
425 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
426 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
427 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
428 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
429 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
430 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
431 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
432 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
435 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
436 saveDumpAsAct
->setCheckable(false);
437 saveDumpAsAct
->setDisabled(false);
438 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
440 //VideoOutputAct = new QAction(tr("Output Video"), this);
441 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
442 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
444 //DasmAct = new QAction(tr("Disassembly"), this);
445 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
446 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
448 // Exception vector table window
449 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
450 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
451 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
453 // All watch variables window
454 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
455 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
456 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
458 // Local variables window
459 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
460 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
461 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
463 // Heap (memory) allocation window
464 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
465 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
466 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
469 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
470 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
471 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
474 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
475 CartFilesListAct
->setStatusTip(tr("List of the files in the cartridge's directory structure"));
476 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
479 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
480 QSignalMapper
*signalMapper
= new QSignalMapper(this);
482 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
484 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
486 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
489 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
490 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
491 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
492 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
493 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
494 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
498 // Memory browser window action
499 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
500 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
501 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
503 // Stack browser window action
504 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
505 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
506 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
508 // CPUs (M68000, GPU & DSP browser window action
509 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
510 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
511 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
513 // OP browser window action
514 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
515 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
516 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
518 // M68000 disassembly browser window
519 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
520 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
521 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
523 // HW registers browser window
524 hwRegsBrowseAct
= new QAction(QIcon(":/res/tool-hw-regs.png"), tr("HW Registers Browser"), this);
525 hwRegsBrowseAct
->setStatusTip(tr("Shows the HW registers browser window"));
526 connect(hwRegsBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHWRegsBrowserWin()));
528 // Risc (DSP / GPU) disassembly browser window
529 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
530 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
531 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
533 // Misc. connections...
534 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
535 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
539 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
540 fileMenu
->addAction(powerAct
);
541 if (!vjs
.softTypeDebugger
)
543 fileMenu
->addAction(pauseAct
);
544 // fileMenu->addAction(frameAdvanceAct);
546 fileMenu
->addAction(filePickAct
);
547 fileMenu
->addAction(useCDAct
);
548 fileMenu
->addAction(configAct
);
549 fileMenu
->addAction(emustatusAct
);
550 fileMenu
->addSeparator();
551 fileMenu
->addAction(quitAppAct
);
553 // Alpine and debugger menus
554 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
557 debugMenu
= menuBar()->addMenu(tr("&Debug"));
559 // Create debugger menu
560 if (vjs
.softTypeDebugger
)
563 viewMenu
= menuBar()->addMenu(tr("&View"));
566 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
567 viewCartMenu
->addAction(CartFilesListAct
);
569 viewCartMenu
->addSeparator();
570 viewCartMenu
->addAction(CartStreamsAct
);
574 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
575 debugWindowsMenu
->addAction(BreakpointsAct
);
576 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
577 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
578 debugWindowsMenu
->addSeparator();
580 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
581 debugWindowOutputMenu
->addAction(VideoOutputAct
);
582 debugWindowsMenu
->addSeparator();
584 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
585 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
586 debugWindowsMenu
->addAction(LocalBrowseAct
);
587 debugWindowsMenu
->addSeparator();
588 debugWindowsMenu
->addAction(CallStackBrowseAct
);
589 debugWindowsMenu
->addSeparator();
590 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
591 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
592 debugWindowsMemoryMenu
->addSeparator();
593 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
595 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
597 debugWindowsMenu
->addSeparator();
598 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
599 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
600 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
601 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
602 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
603 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
604 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
605 debugWindowsBrowsesMenu
->addAction(hwRegsBrowseAct
);
606 debugMenu
->addSeparator();
607 debugMenu
->addAction(pauseAct
);
608 debugMenu
->addAction(frameAdvanceAct
);
609 debugMenu
->addAction(restartAct
);
610 debugMenu
->addSeparator();
611 debugMenu
->addAction(traceStepIntoAct
);
612 debugMenu
->addAction(traceStepOverAct
);
613 debugMenu
->addSeparator();
614 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
615 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
616 debugMenu
->addAction(deleteAllBreakpointsAct
);
617 debugMenu
->addAction(disableAllBreakpointsAct
);
618 debugMenu
->addSeparator();
619 debugMenu
->addAction(saveDumpAsAct
);
621 debugMenu
->addSeparator();
622 debugMenu
->addAction(DasmAct
);
627 // Create alpine menu
628 debugMenu
->addAction(memBrowseAct
);
629 debugMenu
->addAction(stackBrowseAct
);
630 debugMenu
->addAction(cpuBrowseAct
);
631 debugMenu
->addAction(opBrowseAct
);
632 debugMenu
->addAction(m68kDasmBrowseAct
);
633 debugMenu
->addAction(riscDasmBrowseAct
);
634 debugMenu
->addAction(hwRegsBrowseAct
);
639 helpMenu
= menuBar()->addMenu(tr("&Help"));
640 helpMenu
->addAction(helpAct
);
641 helpMenu
->addAction(aboutAct
);
645 toolbar
= addToolBar(tr("System"));
646 toolbar
->addAction(powerAct
);
647 if (!vjs
.softTypeDebugger
)
649 toolbar
->addAction(pauseAct
);
650 toolbar
->addAction(frameAdvanceAct
);
652 toolbar
->addAction(filePickAct
);
653 toolbar
->addAction(useCDAct
);
654 toolbar
->addSeparator();
655 if (!vjs
.softTypeDebugger
)
657 toolbar
->addAction(screenshotAct
);
658 toolbar
->addSeparator();
659 toolbar
->addAction(x1Act
);
660 toolbar
->addAction(x2Act
);
661 toolbar
->addAction(x3Act
);
662 toolbar
->addSeparator();
663 toolbar
->addAction(ntscAct
);
664 toolbar
->addAction(palAct
);
665 toolbar
->addSeparator();
666 toolbar
->addAction(blurAct
);
667 toolbar
->addAction(fullScreenAct
);
671 debuggerbar
= addToolBar(tr("&Debugger"));
672 debuggerbar
->addAction(pauseAct
);
673 debuggerbar
->addAction(frameAdvanceAct
);
674 debuggerbar
->addAction(restartAct
);
675 debuggerbar
->addSeparator();
676 debuggerbar
->addAction(traceStepIntoAct
);
677 debuggerbar
->addAction(traceStepOverAct
);
678 debuggerbar
->addSeparator();
679 debuggerbar
->addAction(BreakpointsAct
);
682 if (vjs
.hardwareTypeAlpine
)
684 debugbar
= addToolBar(tr("&Debug"));
685 debugbar
->addAction(memBrowseAct
);
686 debugbar
->addAction(stackBrowseAct
);
687 debugbar
->addAction(cpuBrowseAct
);
688 debugbar
->addAction(opBrowseAct
);
689 debugbar
->addAction(m68kDasmBrowseAct
);
690 debugbar
->addAction(riscDasmBrowseAct
);
691 debugbar
->addAction(hwRegsBrowseAct
);
694 // Add actions to the main window, as hiding widgets with them
696 addAction(fullScreenAct
);
697 addAction(quitAppAct
);
698 addAction(configAct
);
699 addAction(emustatusAct
);
701 addAction(filePickAct
);
702 addAction(frameAdvanceAct
);
705 statusBar()->showMessage(tr("Ready"));
707 // Do this in case original size isn't correct (mostly for the first-run case)
710 WriteLog("Window creation done\n");
712 // Create our test pattern NTSC bitmap
713 WriteLog("Test pattern 1 bitmap\n");
715 QImage
tempImg(":/res/test-pattern.jpg");
716 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
718 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
720 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
722 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
724 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
725 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
729 // Create our test pattern PAL bitmap
730 WriteLog("Test pattern 2 bitmap\n");
732 QImage
tempImg2(":/res/test-pattern-pal.jpg");
733 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
735 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
737 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
739 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
741 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
742 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
746 // Set up timer based loop for animation...
747 timer
= new QTimer(this);
748 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
750 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
751 // This is because it's discarding the 0.6666... on the end of the fraction.
752 // Alas, 6 doesn't divide cleanly into 10. :-P
753 //Should we defer this until SyncUI? Probably.
754 //No, it doesn't work, because it uses setInterval() instead of start()...
755 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
757 // We set this initially, to make VJ behave somewhat as it would if no
758 // cart were inserted and the BIOS was set as active...
759 jaguarCartInserted
= true;
760 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
761 WriteLog("VJ: Initializing jaguar subsystem...\n");
764 #ifndef NEWMODELSBIOSHANDLER
765 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
766 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
768 SelectBIOS(vjs
.biosType
);
771 // Prevent the file scanner from running if filename passed
772 // in on the command line...
776 // Load up the default ROM if in Alpine mode:
777 if (vjs
.hardwareTypeAlpine
)
779 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
781 // If regular load failed, try just a straight file load
782 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
784 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
787 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
789 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
791 // Attempt to load/run the ABS file...
792 LoadSoftware(vjs
.absROMPath
);
793 #ifndef NEWMODELSBIOSHANDLER
794 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
796 SelectBIOS(vjs
.biosType
);
798 // Prevent the scanner from running...
802 // Load up the default ROM if in Debugger mode:
803 if (vjs
.softTypeDebugger
)
805 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
807 // If regular load failed, try just a straight file load
808 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
810 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
813 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
815 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
817 // Attempt to load/run the ABS file...
818 LoadSoftware(vjs
.absROMPath
);
819 #ifndef NEWMODELSBIOSHANDLER
820 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
821 // Prevent the scanner from running...
823 SelectBIOS(vjs
.biosType
);
828 // Run the scanner if nothing passed in and *not* Alpine mode...
829 // NB: Really need to look into caching the info scanned in here...
830 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
831 scannedSoftwareFolder
= true;
835 void MainWin::LoadFile(QString file
)
841 void MainWin::SyncUI(void)
843 // Set toolbar buttons/menus based on settings read in (sync the UI)...
844 // (Really, this is to sync command line options passed in)
845 blurAct
->setChecked(vjs
.glFilter
);
846 x1Act
->setChecked(zoomLevel
== 1);
847 x2Act
->setChecked(zoomLevel
== 2);
848 x3Act
->setChecked(zoomLevel
== 3);
849 // running = powerAct->isChecked();
850 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
851 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
852 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
854 fullScreenAct
->setChecked(vjs
.fullscreen
);
855 fullScreen
= vjs
.fullscreen
;
856 SetFullScreen(fullScreen
);
858 // Reset the timer to be what was set in the command line (if any):
859 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
860 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
865 void MainWin::SelectdasmtabWidget(const int Index
)
870 SourcesWin
->RefreshContents();
875 void MainWin::closeEvent(QCloseEvent
* event
)
878 // This should only be done by the config dialog
881 event
->accept(); // ignore() if can't close for some reason
885 void MainWin::keyPressEvent(QKeyEvent
* e
)
887 #ifndef VJ_REMOVE_DEV_CODE
889 //extern bool startM68KTracing; // moved to jaguar.h
891 extern int blit_start_log
;
893 extern bool startConciseBlitLogging
;
896 // We ignore the Alt key for now, since it causes problems with the GUI
897 if (e
->key() == Qt::Key_Alt
)
902 // Bar this shite from release versions kthxbai
903 #ifndef VJ_REMOVE_DEV_CODE
904 else if (e
->key() == Qt::Key_F11
)
906 startM68KTracing
= true;
910 else if (e
->key() == Qt::Key_F12
)
912 blit_start_log
= true;
916 else if (e
->key() == Qt::Key_F10
)
918 startConciseBlitLogging
= true;
923 else if (e
->key() == Qt::Key_F8
)
925 // ggn: For extra NYAN pleasure...
926 // ggn: There you go James :P
927 // Shamus: Thanks for the patch! :-D
928 WriteLog(" o + + +\n");
929 WriteLog("+ o o + o\n");
930 WriteLog("-_-_-_-_-_-_-_,------, o \n");
931 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
932 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
933 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
934 WriteLog("+ o o + o\n");
941 This is done now by a QAction...
942 if (e->key() == Qt::Key_F9)
952 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
954 // We ignore the Alt key for now, since it causes problems with the GUI
955 if (e
->key() == Qt::Key_Alt
)
961 HandleKeys(e
, false);
965 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
967 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
968 // We kill bad key combos here, before they can get to the emulator...
969 // This also kills the illegal instruction problem that cropped up in
972 // First, settle key states...
973 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
974 keyHeld
[P1LEFT
] = state
;
975 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
976 keyHeld
[P1RIGHT
] = state
;
977 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
978 keyHeld
[P1UP
] = state
;
979 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
980 keyHeld
[P1DOWN
] = state
;
981 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
982 keyHeld
[P2LEFT
] = state
;
983 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
984 keyHeld
[P2RIGHT
] = state
;
985 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
986 keyHeld
[P2UP
] = state
;
987 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
988 keyHeld
[P2DOWN
] = state
;
990 // Next, check for conflicts and kill 'em if there are any...
991 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
992 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
994 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
995 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
997 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
998 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
1000 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
1001 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
1003 // No bad combos exist now, let's stuff the emulator key buffers...!
1004 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1006 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
1007 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
1009 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
1010 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
1016 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
1018 void MainWin::HandleGamepads(void)
1022 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1024 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1025 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
1027 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1028 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1033 void MainWin::Open(void)
1038 void MainWin::Configure(void)
1040 // Call the configuration dialog and update settings
1041 ConfigDialog
dlg(this);
1043 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1044 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1045 dlg
.controllerTab1
->SetupLastUsedProfile();
1046 // maybe instead of this, we tell the controller tab to work on a copy that gets
1047 // written if the user hits 'OK'.
1048 SaveProfiles(); // Just in case user cancels
1050 if (dlg
.exec() == false)
1056 QString before
= vjs
.ROMPath
;
1057 QString alpineBefore
= vjs
.alpineROMPath
;
1058 QString absBefore
= vjs
.absROMPath
;
1059 // bool audioBefore = vjs.audioEnabled;
1060 bool audioBefore
= vjs
.DSPEnabled
;
1061 dlg
.UpdateVJSettings();
1062 QString after
= vjs
.ROMPath
;
1063 QString alpineAfter
= vjs
.alpineROMPath
;
1064 QString absAfter
= vjs
.absROMPath
;
1065 // bool audioAfter = vjs.audioEnabled;
1066 bool audioAfter
= vjs
.DSPEnabled
;
1068 bool allowOld
= allowUnknownSoftware
;
1070 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1071 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1072 AutoConnectProfiles();
1074 // We rescan the "software" folder if the user either changed the path or
1075 // checked/unchecked the "Allow unknown files" option in the config dialog.
1076 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1077 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1079 // If the "Alpine" ROM is changed, then let's load it...
1080 if (alpineBefore
!= alpineAfter
)
1082 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1084 // Oh crap, we couldn't get the file! Alert the media!
1086 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1087 msg
.setIcon(QMessageBox::Warning
);
1092 // If the "ABS" ROM is changed, then let's load it...
1093 if (absBefore
!= absAfter
)
1095 if (!JaguarLoadFile(vjs
.absROMPath
))
1097 // Oh crap, we couldn't get the file! Alert the media!
1099 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1100 msg
.setIcon(QMessageBox::Warning
);
1105 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1106 // since it's running in the host audio IRQ...
1107 if (audioBefore
!= audioAfter
)
1113 // Just in case we crash before a clean exit...
1121 // Here's the main emulator loop
1123 void MainWin::Timer(void)
1126 static uint32_t ntscTickCount
;
1127 if (vjs
.hardwareTypeNTSC
)
1131 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1138 if (showUntunedTankCircuit
)
1140 // Some machines can't handle this, so we give them the option to disable it. :-)
1141 if (!plzDontKillMyComputer
)
1143 // if (!vjs.softTypeDebugger)
1145 // Random hash & trash
1146 // We try to simulate an untuned tank circuit here... :-)
1147 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1149 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1151 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1159 // Otherwise, run the Jaguar simulation
1162 //if (!vjs.softTypeDebugger)
1163 videoWidget
->HandleMouseHiding();
1165 static uint32_t refresh
= 0;
1166 // Do autorefresh on debug windows
1167 // Have to be careful, too much causes the emulator to slow way down!
1168 if (refresh
== vjs
.refresh
)
1170 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1172 AlpineRefreshWindows();
1173 //memBrowseWin->RefreshContents();
1174 //cpuBrowseWin->RefreshContents();
1176 CommonRefreshWindows();
1185 //if (!vjs.softTypeDebugger)
1186 videoWidget
->updateGL();
1189 // Approach: We use a ring buffer to store times (in ms) over a given
1190 // amount of frames, then sum them to figure out the FPS.
1191 uint32_t timestamp
= SDL_GetTicks();
1192 // This assumes the ring buffer size is a power of 2
1193 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1194 // Doing it this way is better. Ring buffer size can be arbitrary then.
1195 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1196 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1197 uint32_t elapsedTime
= 0;
1199 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1200 elapsedTime
+= ringBuffer
[i
];
1202 // elapsedTime must be non-zero
1203 if (elapsedTime
== 0)
1206 // This is in frames per 10 seconds, so we can have 1 decimal
1207 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1208 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1209 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1210 // If this is updated too frequently to be useful, we can throttle it down
1211 // so that it only updates every 10th frame or so
1212 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1213 oldTimestamp
= timestamp
;
1215 if (M68KDebugHaltStatus())
1220 // Toggle the power state, it can be either on or off
1221 void MainWin::TogglePowerState(void)
1223 powerButtonOn
= !powerButtonOn
;
1226 // With the power off, we simulate white noise on the screen. :-)
1229 // Restore the mouse pointer, if hidden:
1230 //if (!vjs.softTypeDebugger)
1232 videoWidget
->CheckAndRestoreMouseCursor();
1235 useCDAct
->setDisabled(false);
1236 palAct
->setDisabled(false);
1237 ntscAct
->setDisabled(false);
1238 pauseAct
->setChecked(false);
1239 pauseAct
->setDisabled(true);
1240 showUntunedTankCircuit
= true;
1242 DACPauseAudioThread();
1243 // 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. :-)
1246 if (plzDontKillMyComputer
)
1248 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1249 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1251 if (vjs
.hardwareTypeNTSC
)
1253 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1257 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1264 useCDAct
->setDisabled(true);
1265 palAct
->setDisabled(true);
1266 ntscAct
->setDisabled(true);
1267 pauseAct
->setChecked(false);
1268 pauseAct
->setDisabled(false);
1269 showUntunedTankCircuit
= false;
1271 // Otherwise, we prepare for running regular software...
1274 // Should check for cartridgeLoaded here as well...!
1275 // We can clear it when toggling CDActive on, so that when we power cycle it
1276 // does the expected thing. Otherwise, if we use the file picker to insert a
1277 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1278 // works if the CD unit is active?
1279 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1282 WriteLog("GUI: Resetting Jaguar...\n");
1286 DebuggerResetWindows();
1287 CommonResetWindows();
1288 DACPauseAudioThread(false);
1293 // Toggle the emulator state, it can be either on or off
1294 void MainWin::ToggleRunState(void)
1296 startM68KTracing
= running
;
1302 // Set action buttons for the pause mode
1303 frameAdvanceAct
->setDisabled(false);
1304 pauseAct
->setChecked(true);
1305 pauseAct
->setDisabled(false);
1306 if (vjs
.softTypeDebugger
)
1308 traceStepIntoAct
->setDisabled(false);
1309 traceStepOverAct
->setDisabled(false);
1310 restartAct
->setDisabled(false);
1311 m68kDasmWin
->Use68KPCAddress();
1312 GPUDasmWin
->UseGPUPCAddress();
1313 DSPDasmWin
->UseDSPPCAddress();
1316 //if (!vjs.softTypeDebugger)
1318 // Restore the mouse pointer, if hidden:
1319 videoWidget
->CheckAndRestoreMouseCursor();
1321 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1323 uint32_t pixel
= videoWidget
->buffer
[i
];
1324 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1325 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1326 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1329 videoWidget
->updateGL();
1331 cpuBrowseWin
->HoldBPM();
1332 cpuBrowseWin
->HandleBPMContinue();
1338 frameAdvanceAct
->setDisabled(true);
1339 pauseAct
->setChecked(false);
1340 pauseAct
->setDisabled(false);
1341 if (vjs
.softTypeDebugger
)
1343 traceStepIntoAct
->setDisabled(true);
1344 traceStepOverAct
->setDisabled(true);
1345 restartAct
->setDisabled(true);
1346 BreakpointsWin
->RefreshContents();
1349 cpuBrowseWin
->UnholdBPM();
1352 // Pause/unpause any running/non-running threads...
1353 DACPauseAudioThread(!running
);
1357 void MainWin::SetZoom100(void)
1364 void MainWin::SetZoom200(void)
1371 void MainWin::SetZoom300(void)
1378 void MainWin::SetNTSC(void)
1380 powerAct
->setIcon(powerRed
);
1381 timer
->setInterval(16);
1382 vjs
.hardwareTypeNTSC
= true;
1388 void MainWin::SetPAL(void)
1390 powerAct
->setIcon(powerGreen
);
1391 timer
->setInterval(20);
1392 vjs
.hardwareTypeNTSC
= false;
1398 void MainWin::ToggleBlur(void)
1400 vjs
.glFilter
= !vjs
.glFilter
;
1405 void MainWin::ShowAboutWin(void)
1411 void MainWin::ShowHelpWin(void)
1417 void MainWin::InsertCart(void)
1419 // Check to see if we did autorun, 'cause we didn't load anything in that
1421 if (!scannedSoftwareFolder
)
1423 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1424 scannedSoftwareFolder
= true;
1427 // If the emulator is running, we pause it here and unpause it later
1428 // if we dismiss the file selector without choosing anything
1429 if (running
&& powerButtonOn
)
1432 pauseForFileSelector
= true;
1435 filePickWin
->show();
1439 void MainWin::Unpause(void)
1441 // Here we unpause the emulator if it was paused when we went into the file selector
1442 if (pauseForFileSelector
)
1444 pauseForFileSelector
= false;
1446 // Some nutter might have unpaused while in the file selector, so check for that
1453 // Jaguar initialisation and load software file
1454 void MainWin::LoadSoftware(QString file
)
1456 running
= false; // Prevent bad things(TM) from happening...
1457 pauseForFileSelector
= false; // Reset the file selector pause flag
1459 // Setup BIOS in his own dedicated Jaguar memory
1460 #ifndef NEWMODELSBIOSHANDLER
1461 uint8_t * biosPointer
= jaguarBootROM
;
1463 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1465 biosPointer
= jaguarDevBootROM2
;
1468 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1470 SelectBIOS(vjs
.biosType
);
1473 // Turn 'on' the power to initialize the Jaguar
1474 powerAct
->setDisabled(false);
1475 powerAct
->setChecked(true);
1476 powerButtonOn
= false;
1479 // We have to load our software *after* the Jaguar RESET
1480 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1481 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1483 // This is icky because we've already done it
1484 // it gets worse :-P
1485 if (!vjs
.useJaguarBIOS
)
1487 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1492 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1493 if (vjs
.softTypeDebugger
)
1495 m68k_set_reg(M68K_REG_A6
, 0);
1496 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1498 //pauseAct->setDisabled(false);
1499 //pauseAct->setChecked(true);
1505 // Prevent the launch in case of software without a start address and without BIOS presence
1506 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1512 // Display the Atari Jaguar software which is running
1513 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1515 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1516 setWindowTitle(newTitle
);
1521 void MainWin::ToggleCDUsage(void)
1523 CDActive
= !CDActive
;
1525 // Set up the Jaguar CD for execution, otherwise, clear memory
1527 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1529 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1533 // Open, or display, the breakpoints list window
1534 void MainWin::ShowBreakpointsWin(void)
1536 BreakpointsWin
->show();
1537 BreakpointsWin
->RefreshContents();
1541 // Delete all breakpoints
1542 void MainWin::DeleteAllBreakpoints(void)
1544 cpuBrowseWin
->ResetBPM();
1546 ShowBreakpointsWin();
1550 // Disable all breakpoints
1551 void MainWin::DisableAllBreakpoints(void)
1553 cpuBrowseWin
->DisableBPM();
1555 ShowBreakpointsWin();
1559 // Open, or display, the new breakpoint function window
1560 void MainWin::ShowNewFunctionBreakpointWin(void)
1562 NewFunctionBreakpointWin
->show();
1563 ShowBreakpointsWin();
1567 // Display list of files found in cartridge
1568 void MainWin::ShowCartFilesListWin(void)
1570 CartFilesListWin
->show();
1571 CartFilesListWin
->RefreshContents();
1575 // Display the save dump pickup file
1576 void MainWin::ShowSaveDumpAsWin(void)
1578 SaveDumpAsWin
->show();
1583 void MainWin::DebuggerTraceStepInto(void)
1585 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1587 while (!SourcesWin
->CheckChangeLine())
1597 videoWidget
->updateGL();
1600 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1602 #warning "!!! Need to verify the Step Into function !!!"
1607 // Restart the Jaguar executable
1608 void MainWin::DebuggerRestart(void)
1613 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1614 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1616 dasmtabWidget
->setCurrentIndex(1); // set focus on the disasm M68K tab
1617 m68k_set_reg(M68K_REG_A6
, 0);
1618 m68k_brk_hitcounts_reset();
1620 DebuggerResetWindows();
1621 CommonResetWindows();
1625 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1627 #warning "!!! Need to verify the Restart function !!!"
1633 void MainWin::DebuggerTraceStepOver(void)
1635 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1644 videoWidget
->updateGL();
1647 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1649 #warning "!!! Need to verify the Step Over function !!!"
1654 // Advance / Execute for one frame
1655 void MainWin::FrameAdvance(void)
1657 //printf("Frame Advance...\n");
1659 // Execute 1 frame, then exit (only useful in Pause mode)
1661 //if (!vjs.softTypeDebugger)
1662 videoWidget
->updateGL();
1664 // Need to execute 1 frames' worth of DSP thread as well :-/
1666 //m68kDasmWin->Use68KPCAddress();
1669 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1671 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1676 void MainWin::SetFullScreen(bool state
/*= true*/)
1678 if (!vjs
.softTypeDebugger
)
1682 mainWinPosition
= pos();
1684 statusBar()->hide();
1690 // This is needed because the fullscreen may happen on a different
1691 // screen than screen 0:
1692 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1693 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1694 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1695 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1696 double aspectRatio
= targetWidth
/ targetHeight
;
1697 // NOTE: Really should check here to see which dimension constrains the
1698 // other. Right now, we assume that height is the constraint.
1699 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1700 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1701 videoWidget
->fullscreen
= true;
1702 videoWidget
->outputWidth
= newWidth
;
1703 videoWidget
->setFixedSize(r
.width(), r
.height());
1708 // Seems Qt is fussy about this: showNormal() has to go first, or it
1709 // will keep the window stuck in a psuedo-fullscreen mode with no way
1710 // to get out of it (except closing the app).
1713 // Reset the video widget to windowed mode
1714 videoWidget
->offset
= 0;
1715 videoWidget
->fullscreen
= false;
1717 statusBar()->show();
1724 move(mainWinPosition
);
1730 void MainWin::ToggleFullScreen(void)
1732 fullScreen
= !fullScreen
;
1733 SetFullScreen(fullScreen
);
1738 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1740 exceptionvectortableBrowseWin
->show();
1741 exceptionvectortableBrowseWin
->RefreshContents();
1746 void MainWin::ShowLocalBrowserWin(void)
1748 LocalBrowseWin
->show();
1749 LocalBrowseWin
->RefreshContents();
1754 void MainWin::ShowCallStackBrowserWin(void)
1756 CallStackBrowseWin
->show();
1757 CallStackBrowseWin
->RefreshContents();
1761 void MainWin::ShowAllWatchBrowserWin(void)
1763 allWatchBrowseWin
->show();
1764 allWatchBrowseWin
->RefreshContents();
1768 void MainWin::ShowHeapAllocatorBrowserWin(void)
1770 heapallocatorBrowseWin
->show();
1771 heapallocatorBrowseWin
->RefreshContents();
1775 void MainWin::ShowMemoryBrowserWin(void)
1777 memBrowseWin
->show();
1778 memBrowseWin
->RefreshContents();
1782 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1784 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1786 mem1BrowseWin
[NumWin
]->show();
1787 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1792 void MainWin::ShowEmuStatusWin(void)
1794 emuStatusWin
->show();
1795 emuStatusWin
->RefreshContents();
1799 void MainWin::ShowStackBrowserWin(void)
1801 stackBrowseWin
->show();
1802 stackBrowseWin
->RefreshContents();
1806 void MainWin::ShowCPUBrowserWin(void)
1808 cpuBrowseWin
->show();
1809 cpuBrowseWin
->RefreshContents();
1813 // Show the OP browser window
1814 void MainWin::ShowOPBrowserWin(void)
1816 opBrowseWin
->show();
1817 opBrowseWin
->RefreshContents();
1821 // Show the HW registers browser window
1822 void MainWin::ShowHWRegsBrowserWin(void)
1824 hwRegsBrowseWin
->show();
1825 hwRegsBrowseWin
->RefreshContents();
1829 // Show the M68K browser window
1830 void MainWin::ShowM68KDasmBrowserWin(void)
1832 m68kDasmBrowseWin
->show();
1833 m68kDasmBrowseWin
->RefreshContents();
1837 void MainWin::ShowRISCDasmBrowserWin(void)
1839 riscDasmBrowseWin
->show();
1840 riscDasmBrowseWin
->RefreshContents();
1846 void MainWin::ShowDasmWin(void)
1849 // DasmWin->RefreshContents();
1856 void MainWin::ShowVideoOutputWin(void)
1858 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1859 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1860 //VideoOutputWindowCentrale->show();
1861 //memBrowseWin->show();
1862 //VideoOutputWin->show();
1863 //VideoOutputWin->RefreshContents(videoWidget);
1868 // Resize video window based on zoom factor
1869 // It doesn't apply in debugger mode as we use this window to display disassembly
1870 void MainWin::ResizeMainWindow(void)
1872 if (!vjs
.softTypeDebugger
)
1874 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1876 // Show the test pattern if user requested plzDontKillMyComputer mode
1877 if (!powerButtonOn
&& plzDontKillMyComputer
)
1879 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1881 if (vjs
.hardwareTypeNTSC
)
1883 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1887 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1898 void MainWin::ReadSettings(void)
1902 QSettings
settings("Underground Software", "Virtual Jaguar");
1904 //zoomLevel = settings.value("zoom", 2).toInt();
1905 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1906 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1908 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1909 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1910 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1911 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1912 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1913 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1914 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1915 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1916 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1917 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1918 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1919 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1920 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1921 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1922 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1923 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1924 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1925 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1926 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1927 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1928 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1930 // Read settings from the Debugger mode
1931 settings
.beginGroup("debugger");
1932 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1933 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1934 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1935 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1936 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1937 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1938 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1939 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1940 settings
.endGroup();
1942 // Read settings from the Alpine mode
1943 settings
.beginGroup("alpine");
1944 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1945 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1946 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1947 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1948 settings
.endGroup();
1950 // Read settings from the Keybindings
1951 settings
.beginGroup("keybindings");
1952 for (i
= 0; i
< KB_END
; i
++)
1954 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1956 settings
.endGroup();
1958 // Write important settings to the log file
1959 WriteLog("MainWin: Paths\n");
1960 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1961 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1962 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1963 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1964 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1965 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1966 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1967 WriteLog("MainWin: Misc.\n");
1968 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1971 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1972 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1973 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1974 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1975 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1976 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1977 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1978 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1979 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1980 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1981 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1982 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1983 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1984 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1985 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1986 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1987 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1988 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1989 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1990 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1991 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1992 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1994 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1995 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1996 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1997 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1998 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1999 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
2000 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
2001 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
2002 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
2003 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
2004 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
2005 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
2006 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
2007 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
2008 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
2009 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
2010 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
2011 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
2012 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
2013 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
2014 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
2017 WriteLog("Read setting = Done\n");
2019 ReadProfiles(&settings
);
2020 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2025 // Default values will be used in case of no settings can be found
2027 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
2029 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
2031 // i.e., someone could drag it to another screen, close it, then disconnect that screen
2032 void MainWin::ReadUISettings(void)
2039 // Point on the emulator settings
2040 QSettings
settings("Underground Software", "Virtual Jaguar");
2041 settings
.beginGroup("ui");
2043 // Emulator main window UI information
2044 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
2045 size
= settings
.value("size", QSize(400, 400)).toSize();
2047 move(mainWinPosition
);
2048 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
2049 filePickWin
->move(pos
);
2051 // Video output information
2052 zoomLevel
= settings
.value("zoom", 2).toInt();
2054 // Emulator status UI information
2055 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2056 emuStatusWin
->move(pos
);
2057 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2059 // Alpine debug UI information (also needed by the Debugger)
2060 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2062 // CPU registers UI information
2063 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
2064 cpuBrowseWin
->move(pos
);
2065 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
2067 // Memory browser UI information
2068 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
2069 memBrowseWin
->move(pos
);
2070 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
2072 // Stack browser UI information
2073 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
2074 stackBrowseWin
->move(pos
);
2075 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2076 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2077 stackBrowseWin
->resize(size
);
2079 // OP (Object Processor) UI information
2080 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2081 opBrowseWin
->move(pos
);
2082 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2083 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2084 opBrowseWin
->resize(size
);
2086 // HW registers UI information
2087 pos
= settings
.value("hwRegsBrowseWinPos", QPoint(200, 200)).toPoint();
2088 hwRegsBrowseWin
->move(pos
);
2089 settings
.value("hwRegsBrowseWinIsVisible", false).toBool() ? ShowHWRegsBrowserWin() : void();
2090 size
= settings
.value("hwRegsBrowseWinSize", QSize(400, 400)).toSize();
2091 hwRegsBrowseWin
->resize(size
);
2093 // RISC disassembly UI information
2094 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2095 riscDasmBrowseWin
->move(pos
);
2096 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2098 // M68k disassembly UI information
2099 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2100 m68kDasmBrowseWin
->move(pos
);
2101 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2103 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2105 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2109 // Debugger UI information
2110 if (vjs
.softTypeDebugger
)
2113 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2114 m68kDasmWin
->move(pos
);
2115 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2116 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2117 GPUDasmWin
->move(pos
);
2118 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2119 DSPDasmWin
->move(pos
);
2121 // All watch browser UI information
2122 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2123 allWatchBrowseWin
->move(pos
);
2124 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2125 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2126 allWatchBrowseWin
->resize(size
);
2128 // Local browser UI information
2129 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2130 LocalBrowseWin
->move(pos
);
2131 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2132 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2133 LocalBrowseWin
->resize(size
);
2135 // Heap memory allocation browser UI information
2136 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2137 heapallocatorBrowseWin
->move(pos
);
2138 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2139 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2140 heapallocatorBrowseWin
->resize(size
);
2142 // Exception Vector Table UI Information
2143 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2144 exceptionvectortableBrowseWin
->move(pos
);
2145 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2146 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2147 exceptionvectortableBrowseWin
->resize(size
);
2149 // Call Stack browser UI information
2150 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2151 CallStackBrowseWin
->move(pos
);
2152 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2153 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2154 CallStackBrowseWin
->resize(size
);
2156 // cartridge directory and files UI information
2157 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2158 CartFilesListWin
->move(pos
);
2159 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2160 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2161 CartFilesListWin
->resize(size
);
2163 // Save dump UI information
2164 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2165 SaveDumpAsWin
->move(pos
);
2166 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2167 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2168 SaveDumpAsWin
->resize(size
);
2170 // Breakpoints UI information
2171 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2172 BreakpointsWin
->move(pos
);
2173 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2174 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2175 BreakpointsWin
->resize(size
);
2176 // New function breakpoint UI information
2177 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2178 NewFunctionBreakpointWin
->move(pos
);
2179 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2180 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2181 NewFunctionBreakpointWin
->resize(size
);
2183 // Memories browser UI information
2184 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2186 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2187 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2188 mem1BrowseWin
[i
]->move(pos
);
2189 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2190 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2191 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2192 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2193 mem1BrowseWin
[i
]->resize(size
);
2197 settings
.endGroup();
2199 WriteLog("Read UI setting = Done\n");
2203 // Save the settings
2204 void MainWin::WriteSettings(void)
2208 // Point on the emulator settings
2209 QSettings
settings("Underground Software", "Virtual Jaguar");
2210 //settings.setValue("pos", pos());
2211 //settings.setValue("size", size());
2212 //settings.setValue("cartLoadPos", filePickWin->pos());
2214 //settings.setValue("zoom", zoomLevel);
2215 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2216 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2218 settings
.setValue("useJoystick", vjs
.useJoystick
);
2219 settings
.setValue("joyport", vjs
.joyport
);
2220 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2221 settings
.setValue("frameSkip", vjs
.frameSkip
);
2222 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2223 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2224 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2225 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2226 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2227 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2228 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2229 settings
.setValue("fullscreen", vjs
.fullscreen
);
2230 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2231 settings
.setValue("glFilterType", vjs
.glFilter
);
2232 settings
.setValue("renderType", vjs
.renderType
);
2233 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2234 settings
.setValue("biosType", vjs
.biosType
);
2235 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2236 //settings.setValue("JagBootROM", vjs.jagBootPath);
2237 //settings.setValue("CDBootROM", vjs.CDBootPath);
2238 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2239 settings
.setValue("ROMs", vjs
.ROMPath
);
2240 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2242 // Write settings from the Alpine mode
2243 settings
.beginGroup("alpine");
2244 settings
.setValue("refresh", vjs
.refresh
);
2245 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2246 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2247 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2248 settings
.endGroup();
2250 // Write settings from the Debugger mode
2251 settings
.beginGroup("debugger");
2252 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2253 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2254 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2255 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2256 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2257 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2258 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2259 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2260 settings
.endGroup();
2262 // Write settings from the Keybindings
2263 settings
.beginGroup("keybindings");
2264 for (i
= 0; i
< KB_END
; i
++)
2266 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2268 settings
.endGroup();
2271 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2272 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2273 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2274 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2275 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2276 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2277 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2278 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2279 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2280 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2281 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2282 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2283 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2284 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2285 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2286 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2287 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2288 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2289 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2290 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2291 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2293 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2294 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2295 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2296 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2297 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2298 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2299 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2300 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2301 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2302 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2303 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2304 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2305 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2306 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2307 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2308 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2309 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2310 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2311 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2312 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2313 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2316 WriteProfiles(&settings
);
2317 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2321 // Save the UI settings
2322 void MainWin::WriteUISettings(void)
2327 // Point on the emulator settings
2328 QSettings
settings("Underground Software", "Virtual Jaguar");
2329 settings
.beginGroup("ui");
2331 // Emulator UI information
2332 settings
.setValue("pos", pos());
2333 settings
.setValue("size", size());
2334 settings
.setValue("cartLoadPos", filePickWin
->pos());
2336 // Video output information
2337 settings
.setValue("zoom", zoomLevel
);
2339 // Common UI information
2340 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2341 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2343 // Alpine debug UI information (also needed by the Debugger)
2344 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2346 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2347 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2348 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2349 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2350 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2351 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2352 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2353 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2354 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2355 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2356 settings
.setValue("hwRegsBrowseWinPos", hwRegsBrowseWin
->pos());
2357 settings
.setValue("hwRegsBrowseWinIsVisible", hwRegsBrowseWin
->isVisible());
2358 settings
.setValue("hwRegsBrowseWinSize", hwRegsBrowseWin
->size());
2359 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2360 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2361 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2362 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2365 // Debugger UI information
2366 if (vjs
.softTypeDebugger
)
2369 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2370 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2371 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2372 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2374 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2375 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2376 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2377 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2378 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2379 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2380 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2381 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2382 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2383 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2384 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2385 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2386 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2387 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2388 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2389 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2390 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2391 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2392 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2393 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2394 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2395 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2396 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2397 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2398 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2399 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2400 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2402 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2404 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2405 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2406 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2407 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2408 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2409 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2413 settings
.endGroup();
2417 // Refresh alpine debug windows
2418 void MainWin::AlpineRefreshWindows(void)
2420 cpuBrowseWin
->RefreshContents();
2421 memBrowseWin
->RefreshContents();
2422 stackBrowseWin
->RefreshContents();
2423 opBrowseWin
->RefreshContents();
2424 riscDasmBrowseWin
->RefreshContents();
2425 m68kDasmBrowseWin
->RefreshContents();
2426 hwRegsBrowseWin
->RefreshContents();
2431 void MainWin::CommonResetWindows(void)
2437 void MainWin::CommonReset(void)
2442 // Reset soft debugger
2443 void MainWin::DebuggerReset(void)
2445 if (vjs
.softTypeDebugger
)
2447 DeleteAllBreakpoints();
2452 // Reset soft debugger windows
2453 void MainWin::DebuggerResetWindows(void)
2455 if (vjs
.softTypeDebugger
)
2457 FilesrcListWin
->Reset();
2458 allWatchBrowseWin
->Reset();
2459 heapallocatorBrowseWin
->Reset();
2460 BreakpointsWin
->Reset();
2461 CartFilesListWin
->Reset();
2462 SourcesWin
->Reset();
2463 //ResetAlpineWindows();
2468 // Refresh common windows
2469 void MainWin::CommonRefreshWindows(void)
2471 emuStatusWin
->RefreshContents();
2475 // Refresh view windows
2476 void MainWin::ViewRefreshWindows(void)
2478 CartFilesListWin
->RefreshContents();
2483 void MainWin::RefreshWindows(void)
2485 DebuggerRefreshWindows();
2486 CommonRefreshWindows();
2490 // Refresh soft debugger & alpine debug windows
2491 void MainWin::DebuggerRefreshWindows(void)
2493 if (vjs
.softTypeDebugger
)
2495 FilesrcListWin
->RefreshContents();
2496 SourcesWin
->RefreshContents();
2497 m68kDasmWin
->RefreshContents();
2498 GPUDasmWin
->RefreshContents();
2499 DSPDasmWin
->RefreshContents();
2500 allWatchBrowseWin
->RefreshContents();
2501 LocalBrowseWin
->RefreshContents();
2502 CallStackBrowseWin
->RefreshContents();
2503 heapallocatorBrowseWin
->RefreshContents();
2504 BreakpointsWin
->RefreshContents();
2505 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2507 mem1BrowseWin
[i
]->RefreshContents(i
);
2510 AlpineRefreshWindows();
2511 ViewRefreshWindows();
2516 // Create and save screenshot
2517 void MainWin::MakeScreenshot(void)
2521 time_t now
= time(0);
2525 tstruct
= *localtime(&now
);
2526 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
);
2528 // Create screenshot
2529 screenshot
= videoWidget
->grabFrameBuffer();
2530 screenshot
.save((char *)Text
, "JPG", 100);