2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James Hammons <jlhamm@acm.org>
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 12/23/2009 Created this file
12 // JLH 12/20/2010 Added settings, menus & toolbars
13 // JLH 07/05/2011 Added CD BIOS functionality to GUI
14 // JPM June/2016 Visual Studio support & Soft debugger integration
15 // JPM 01/11/2017 Added stack browser
16 // JPM Feb./2017 Added GPU/DSP disassembly
17 // JPM 07/12/2017 Added all Watch window
18 // JPM Aug./2017 Added heap allocator and memories window, a restart feature, and a [Not Supported] breakpoints window
19 // JPM Sept./2017 Save position, size & visibility windows status in the settings; added Exception Vector Table window, the 'Rx' word to the emulator window name, and the keybindings in the settings
20 // JPM 11/04/2017 Added the local window
21 // JPM 08/31/2018 Added the call stack window
22 // JPM Sept./2018 Added the new Models and BIOS handler, a screenshot feature and source code files browsing
23 // JPM Oct./2018 Added search paths in the settings, breakpoints feature, cartdridge view menu
24 // JPM 11/18/2018 Fix crash with non-debugger mode
25 // JPM 04/06/2019 Added ELF sections check
30 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
31 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
32 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
33 // with 'R', etc) [DONE]
34 // - Controller configuration [DONE]
38 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
39 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
40 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
43 // SFDX CODE: S1E9T8H5M23YS
45 // Uncomment this for debugging...
47 //#define DEBUGFOO // Various tool debugging... but not used
48 //#define DEBUGTP // Toolpalette debugging... but not used
55 #include "configdialog.h"
56 #include "controllertab.h"
57 #include "keybindingstab.h"
58 #include "filepicker.h"
60 #include "generaltab.h"
66 #include "emustatus.h"
67 #include "debug/cpubrowser.h"
68 #include "debug/m68kdasmbrowser.h"
69 #include "debug/memorybrowser.h"
70 #include "debug/stackbrowser.h"
71 #include "debug/opbrowser.h"
72 #include "debug/riscdasmbrowser.h"
78 #ifndef NEWMODELSBIOSHANDLER
81 #include "jagstub2bios.h"
83 #include "modelsBIOS.h"
85 #include "jagcdbios.h"
87 #include "m68000/m68kinterface.h"
89 #include "debugger/DBGManager.h"
90 //#include "debugger/VideoWin.h"
91 //#include "debugger/DasmWin.h"
92 #include "debugger/m68KDasmWin.h"
93 #include "debugger/GPUDasmWin.h"
94 #include "debugger/DSPDasmWin.h"
95 #include "debugger/memory1browser.h"
96 #include "debugger/BreakpointsWin.h"
97 #include "debugger/NewFnctBreakpointWin.h"
98 #include "debugger/FilesrcListWin.h"
99 #include "debugger/exceptionvectortablebrowser.h"
100 #include "debugger/allwatchbrowser.h"
101 #include "debugger/localbrowser.h"
102 #include "debugger/heapallocatorbrowser.h"
103 #include "debugger/callstackbrowser.h"
104 #include "debugger/CartFilesListWin.h"
107 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
108 //#ifdef __GCCWIN32__
109 // Apparently on win32, usleep() is not pulled in by the usual suspects.
113 #include "_MSC_VER/unistd.h"
117 // The way BSNES controls things is by setting a timer with a zero
118 // timeout, sleeping if not emulating anything. Seems there has to be a
121 // It has a novel approach to plugging-in/using different video/audio/input
122 // methods, can we do something similar or should we just use the built-in
125 // We're going to try to use the built-in OpenGL support and see how it goes.
126 // We'll make the VJ core modular so that it doesn't matter what GUI is in
127 // use, we can drop it in anywhere and use it as-is.
129 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
130 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
131 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
137 for(int i
=0; i
<8; i
++)
141 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
144 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
147 //if (vjs.softTypeDebugger)
149 // mainWindowCentrale = new QMdiArea;
150 // setCentralWidget(mainWindowCentrale);
153 WriteLog("Window creation start\n");
156 videoWidget
= new GLWidget(this);
157 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
159 // set central output window
160 if (!vjs
.softTypeDebugger
)
162 setCentralWidget(videoWidget
);
166 mainWindowCentrale
= new QMdiArea(this);
167 setCentralWidget(mainWindowCentrale
);
170 setWindowIcon(QIcon(":/res/vj-icon.png"));
172 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
174 if (vjs
.hardwareTypeAlpine
)
175 title
+= QString(tr(" - Alpine Mode"));
177 if (vjs
.softTypeDebugger
)
178 title
+= QString(tr(" - Debugger Mode"));
180 setWindowTitle(title
);
182 aboutWin
= new AboutWindow(this);
183 helpWin
= new HelpWindow(this);
184 filePickWin
= new FilePickerWindow(this);
185 memBrowseWin
= new MemoryBrowserWindow(this);
186 stackBrowseWin
= new StackBrowserWindow(this);
187 emuStatusWin
= new EmuStatusWindow(this);
188 cpuBrowseWin
= new CPUBrowserWindow(this);
189 opBrowseWin
= new OPBrowserWindow(this);
190 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
191 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
192 if (vjs
.softTypeDebugger
)
194 //VideoOutputWin = new VideoOutputWindow(this);
195 //VideoOutputWin->setCentralWidget()
196 //DasmWin = new DasmWindow();
197 //DasmWin = new DasmWindow(this);
198 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
199 LocalBrowseWin
= new LocalBrowserWindow(this);
200 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
201 BreakpointsWin
= new BreakpointsWindow(this);
202 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
203 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
204 CallStackBrowseWin
= new CallStackBrowserWindow(this);
205 CartFilesListWin
= new CartFilesListWindow(this);
207 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
209 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
211 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
213 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
215 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
218 // Setup dock to display source code filenames tree
219 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
220 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
222 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
223 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
224 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
226 // Setup dock to display disassembly
227 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
228 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
229 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
230 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
231 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
233 dasmtabWidget
= new QTabWidget(this);
236 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
237 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
238 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
239 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
241 setCentralWidget(dasmtabWidget
);
245 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
246 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
248 setUnifiedTitleAndToolBarOnMac(true);
251 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
252 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
253 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
254 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
255 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
258 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
259 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
260 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
261 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
262 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
263 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
264 powerAct
->setCheckable(true);
265 powerAct
->setChecked(false);
266 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
270 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
271 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
272 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
273 pauseAct
->setStatusTip(tr("Toggles the running state"));
274 pauseAct
->setCheckable(true);
275 pauseAct
->setDisabled(true);
276 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
277 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
278 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
281 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
282 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
283 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
284 screenshotAct
->setCheckable(false);
285 screenshotAct
->setDisabled(false);
286 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
289 zoomActs
= new QActionGroup(this);
290 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
291 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
292 x1Act
->setCheckable(true);
293 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
294 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
295 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
296 x2Act
->setCheckable(true);
297 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
298 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
299 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
300 x3Act
->setCheckable(true);
301 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
304 tvTypeActs
= new QActionGroup(this);
305 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
306 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
307 ntscAct
->setCheckable(true);
308 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
309 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
310 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
311 palAct
->setCheckable(true);
312 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
315 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
316 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
317 blurAct
= new QAction(blur
, tr("Blur"), this);
318 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
319 blurAct
->setCheckable(true);
320 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
323 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
324 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
325 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
328 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
329 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
330 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
332 // File pickup action
333 if (!vjs
.softTypeDebugger
)
335 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
336 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
340 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
341 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
343 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
344 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
345 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
347 // Configuration action
348 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
349 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
350 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
351 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
352 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
354 // Emulation status action
355 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
356 emustatusAct
->setStatusTip(tr("Emulator status"));
357 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
358 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
359 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
362 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
363 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
364 useCDAct
->setCheckable(true);
365 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
367 // Frame advance action
368 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
369 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
370 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
371 frameAdvanceAct
->setDisabled(true);
372 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
375 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
376 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
377 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
378 fullScreenAct
->setCheckable(true);
379 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
381 // Actions dedicated to debugger mode
382 if (vjs
.softTypeDebugger
)
385 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
386 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
387 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
388 restartAct
->setCheckable(false);
389 restartAct
->setDisabled(true);
390 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
393 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
394 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
395 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
396 traceStepOverAct
->setCheckable(false);
397 traceStepOverAct
->setDisabled(true);
398 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
400 // Trace into tracing
401 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
402 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
403 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
404 traceStepIntoAct
->setCheckable(false);
405 traceStepIntoAct
->setDisabled(true);
406 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
408 // Function breakpoint
409 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
410 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
411 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
412 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
413 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
414 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
415 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
416 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
417 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
418 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
419 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
421 //VideoOutputAct = new QAction(tr("Output Video"), this);
422 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
423 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
425 //DasmAct = new QAction(tr("Disassembly"), this);
426 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
427 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
429 // Exception vector table window
430 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
431 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
432 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
434 // All watch variables window
435 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
436 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
437 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
439 // Local variables window
440 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
441 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
442 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
444 // Heap (memory) allocation window
445 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
446 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
447 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
450 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
451 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
452 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
455 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
456 CartFilesListAct
->setStatusTip(tr("List of the files in the cartdridge's directory"));
457 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
460 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
461 QSignalMapper
*signalMapper
= new QSignalMapper(this);
463 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
465 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
467 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
470 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
471 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
472 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
473 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
474 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
475 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
479 // Memory browser window action
480 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
481 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
482 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
484 // Stack browser window action
485 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
486 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
487 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
489 // CPUs (M68000, GPU & DSP browser window action
490 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
491 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
492 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
494 // OP browser window action
495 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
496 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
497 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
499 // M68000 disassembly browser window
500 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
501 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
502 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
504 // Risc (DSP / GPU) disassembly browser window
505 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
506 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
507 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
509 // Misc. connections...
510 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
511 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
515 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
516 fileMenu
->addAction(powerAct
);
517 if (!vjs
.softTypeDebugger
)
519 fileMenu
->addAction(pauseAct
);
520 // fileMenu->addAction(frameAdvanceAct);
522 fileMenu
->addAction(filePickAct
);
523 fileMenu
->addAction(useCDAct
);
524 fileMenu
->addAction(configAct
);
525 fileMenu
->addAction(emustatusAct
);
526 fileMenu
->addSeparator();
527 fileMenu
->addAction(quitAppAct
);
529 // Alpine and debugger menus
530 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
532 // Create debug & view menu
533 debugMenu
= menuBar()->addMenu(tr("&Debug"));
534 viewMenu
= menuBar()->addMenu(tr("&View"));
536 // Create debugger menu
537 if (vjs
.softTypeDebugger
)
540 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
541 viewCartMenu
->addAction(CartFilesListAct
);
543 viewCartMenu
->addSeparator();
544 viewCartMenu
->addAction(CartStreamsAct
);
548 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
549 debugWindowsMenu
->addAction(BreakpointsAct
);
550 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
551 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
552 debugWindowsMenu
->addSeparator();
554 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
555 debugWindowOutputMenu
->addAction(VideoOutputAct
);
556 debugWindowsMenu
->addSeparator();
558 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
559 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
560 debugWindowsMenu
->addAction(LocalBrowseAct
);
561 debugWindowsMenu
->addSeparator();
562 debugWindowsMenu
->addAction(CallStackBrowseAct
);
563 debugWindowsMenu
->addSeparator();
564 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
565 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
566 debugWindowsMemoryMenu
->addSeparator();
567 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
569 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
571 debugWindowsMenu
->addSeparator();
572 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
573 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
574 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
575 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
576 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
577 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
578 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
579 debugMenu
->addSeparator();
580 debugMenu
->addAction(pauseAct
);
581 debugMenu
->addAction(frameAdvanceAct
);
582 debugMenu
->addAction(restartAct
);
583 debugMenu
->addSeparator();
584 debugMenu
->addAction(traceStepIntoAct
);
585 debugMenu
->addAction(traceStepOverAct
);
586 debugMenu
->addSeparator();
587 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
588 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
589 debugMenu
->addAction(deleteAllBreakpointsAct
);
590 debugMenu
->addAction(disableAllBreakpointsAct
);
592 debugMenu
->addSeparator();
593 debugMenu
->addAction(DasmAct
);
598 // Create alpine menu
599 debugMenu
->addAction(memBrowseAct
);
600 debugMenu
->addAction(stackBrowseAct
);
601 debugMenu
->addAction(cpuBrowseAct
);
602 debugMenu
->addAction(opBrowseAct
);
603 debugMenu
->addAction(m68kDasmBrowseAct
);
604 debugMenu
->addAction(riscDasmBrowseAct
);
609 helpMenu
= menuBar()->addMenu(tr("&Help"));
610 helpMenu
->addAction(helpAct
);
611 helpMenu
->addAction(aboutAct
);
615 toolbar
= addToolBar(tr("System"));
616 toolbar
->addAction(powerAct
);
617 if (!vjs
.softTypeDebugger
)
619 toolbar
->addAction(pauseAct
);
620 toolbar
->addAction(frameAdvanceAct
);
622 toolbar
->addAction(filePickAct
);
623 toolbar
->addAction(useCDAct
);
624 toolbar
->addSeparator();
625 if (!vjs
.softTypeDebugger
)
627 toolbar
->addAction(screenshotAct
);
628 toolbar
->addSeparator();
629 toolbar
->addAction(x1Act
);
630 toolbar
->addAction(x2Act
);
631 toolbar
->addAction(x3Act
);
632 toolbar
->addSeparator();
633 toolbar
->addAction(ntscAct
);
634 toolbar
->addAction(palAct
);
635 toolbar
->addSeparator();
636 toolbar
->addAction(blurAct
);
637 toolbar
->addAction(fullScreenAct
);
641 debuggerbar
= addToolBar(tr("&Debugger"));
642 debuggerbar
->addAction(pauseAct
);
643 debuggerbar
->addAction(frameAdvanceAct
);
644 debuggerbar
->addAction(restartAct
);
645 debuggerbar
->addSeparator();
646 debuggerbar
->addAction(traceStepIntoAct
);
647 debuggerbar
->addAction(traceStepOverAct
);
648 debuggerbar
->addSeparator();
649 debuggerbar
->addAction(BreakpointsAct
);
652 if (vjs
.hardwareTypeAlpine
)
654 debugbar
= addToolBar(tr("&Debug"));
655 debugbar
->addAction(memBrowseAct
);
656 debugbar
->addAction(stackBrowseAct
);
657 debugbar
->addAction(cpuBrowseAct
);
658 debugbar
->addAction(opBrowseAct
);
659 debugbar
->addAction(m68kDasmBrowseAct
);
660 debugbar
->addAction(riscDasmBrowseAct
);
663 // Add actions to the main window, as hiding widgets with them
665 addAction(fullScreenAct
);
666 addAction(quitAppAct
);
667 addAction(configAct
);
668 addAction(emustatusAct
);
670 addAction(filePickAct
);
671 addAction(frameAdvanceAct
);
674 statusBar()->showMessage(tr("Ready"));
676 // Do this in case original size isn't correct (mostly for the first-run case)
679 WriteLog("Window creation done\n");
681 // Create our test pattern NTSC bitmap
682 WriteLog("Test pattern 1 bitmap\n");
684 QImage
tempImg(":/res/test-pattern.jpg");
685 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
687 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
689 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
691 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
693 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
694 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
698 // Create our test pattern PAL bitmap
699 WriteLog("Test pattern 2 bitmap\n");
701 QImage
tempImg2(":/res/test-pattern-pal.jpg");
702 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
704 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
706 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
708 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
710 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
711 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
715 // Set up timer based loop for animation...
716 timer
= new QTimer(this);
717 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
719 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
720 // This is because it's discarding the 0.6666... on the end of the fraction.
721 // Alas, 6 doesn't divide cleanly into 10. :-P
722 //Should we defer this until SyncUI? Probably.
723 //No, it doesn't work, because it uses setInterval() instead of start()...
724 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
726 // We set this initially, to make VJ behave somewhat as it would if no
727 // cart were inserted and the BIOS was set as active...
728 jaguarCartInserted
= true;
729 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
730 WriteLog("VJ: Initializing jaguar subsystem...\n");
733 #ifndef NEWMODELSBIOSHANDLER
734 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
735 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
737 SelectBIOS(vjs
.biosType
);
740 // Prevent the file scanner from running if filename passed
741 // in on the command line...
745 // Load up the default ROM if in Alpine mode:
746 if (vjs
.hardwareTypeAlpine
)
748 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
750 // If regular load failed, try just a straight file load
751 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
753 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
756 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
758 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
760 // Attempt to load/run the ABS file...
761 LoadSoftware(vjs
.absROMPath
);
762 #ifndef NEWMODELSBIOSHANDLER
763 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
765 SelectBIOS(vjs
.biosType
);
767 // Prevent the scanner from running...
771 // Load up the default ROM if in Debugger mode:
772 if (vjs
.softTypeDebugger
)
774 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
776 // If regular load failed, try just a straight file load
777 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
779 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
782 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
784 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
786 // Attempt to load/run the ABS file...
787 LoadSoftware(vjs
.absROMPath
);
788 #ifndef NEWMODELSBIOSHANDLER
789 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
790 // Prevent the scanner from running...
792 SelectBIOS(vjs
.biosType
);
797 // Run the scanner if nothing passed in and *not* Alpine mode...
798 // NB: Really need to look into caching the info scanned in here...
799 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
800 scannedSoftwareFolder
= true;
804 void MainWin::LoadFile(QString file
)
810 void MainWin::SyncUI(void)
812 // Set toolbar buttons/menus based on settings read in (sync the UI)...
813 // (Really, this is to sync command line options passed in)
814 blurAct
->setChecked(vjs
.glFilter
);
815 x1Act
->setChecked(zoomLevel
== 1);
816 x2Act
->setChecked(zoomLevel
== 2);
817 x3Act
->setChecked(zoomLevel
== 3);
818 // running = powerAct->isChecked();
819 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
820 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
821 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
823 fullScreenAct
->setChecked(vjs
.fullscreen
);
824 fullScreen
= vjs
.fullscreen
;
825 SetFullScreen(fullScreen
);
827 // Reset the timer to be what was set in the command line (if any):
828 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
829 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
833 void MainWin::closeEvent(QCloseEvent
* event
)
836 // This should only be done by the config dialog
839 event
->accept(); // ignore() if can't close for some reason
843 void MainWin::keyPressEvent(QKeyEvent
* e
)
845 #ifndef VJ_REMOVE_DEV_CODE
847 //extern bool startM68KTracing; // moved to jaguar.h
849 extern int blit_start_log
;
851 extern bool startConciseBlitLogging
;
854 // We ignore the Alt key for now, since it causes problems with the GUI
855 if (e
->key() == Qt::Key_Alt
)
860 // Bar this shite from release versions kthxbai
861 #ifndef VJ_REMOVE_DEV_CODE
862 else if (e
->key() == Qt::Key_F11
)
864 startM68KTracing
= true;
868 else if (e
->key() == Qt::Key_F12
)
870 blit_start_log
= true;
874 else if (e
->key() == Qt::Key_F10
)
876 startConciseBlitLogging
= true;
881 else if (e
->key() == Qt::Key_F8
)
883 // ggn: For extra NYAN pleasure...
884 // ggn: There you go James :P
885 // Shamus: Thanks for the patch! :-D
886 WriteLog(" o + + +\n");
887 WriteLog("+ o o + o\n");
888 WriteLog("-_-_-_-_-_-_-_,------, o \n");
889 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
890 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
891 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
892 WriteLog("+ o o + o\n");
899 This is done now by a QAction...
900 if (e->key() == Qt::Key_F9)
910 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
912 // We ignore the Alt key for now, since it causes problems with the GUI
913 if (e
->key() == Qt::Key_Alt
)
919 HandleKeys(e
, false);
923 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
925 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
926 // We kill bad key combos here, before they can get to the emulator...
927 // This also kills the illegal instruction problem that cropped up in
930 // First, settle key states...
931 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
932 keyHeld
[P1LEFT
] = state
;
933 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
934 keyHeld
[P1RIGHT
] = state
;
935 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
936 keyHeld
[P1UP
] = state
;
937 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
938 keyHeld
[P1DOWN
] = state
;
939 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
940 keyHeld
[P2LEFT
] = state
;
941 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
942 keyHeld
[P2RIGHT
] = state
;
943 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
944 keyHeld
[P2UP
] = state
;
945 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
946 keyHeld
[P2DOWN
] = state
;
948 // Next, check for conflicts and kill 'em if there are any...
949 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
950 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
952 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
953 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
955 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
956 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
958 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
959 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
961 // No bad combos exist now, let's stuff the emulator key buffers...!
962 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
964 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
965 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
967 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
968 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
974 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
976 void MainWin::HandleGamepads(void)
980 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
982 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
983 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
985 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
986 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
991 void MainWin::Open(void)
996 void MainWin::Configure(void)
998 // Call the configuration dialog and update settings
999 ConfigDialog
dlg(this);
1001 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1002 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1003 dlg
.controllerTab1
->SetupLastUsedProfile();
1004 // maybe instead of this, we tell the controller tab to work on a copy that gets
1005 // written if the user hits 'OK'.
1006 SaveProfiles(); // Just in case user cancels
1008 if (dlg
.exec() == false)
1014 QString before
= vjs
.ROMPath
;
1015 QString alpineBefore
= vjs
.alpineROMPath
;
1016 QString absBefore
= vjs
.absROMPath
;
1017 // bool audioBefore = vjs.audioEnabled;
1018 bool audioBefore
= vjs
.DSPEnabled
;
1019 dlg
.UpdateVJSettings();
1020 QString after
= vjs
.ROMPath
;
1021 QString alpineAfter
= vjs
.alpineROMPath
;
1022 QString absAfter
= vjs
.absROMPath
;
1023 // bool audioAfter = vjs.audioEnabled;
1024 bool audioAfter
= vjs
.DSPEnabled
;
1026 bool allowOld
= allowUnknownSoftware
;
1028 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1029 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1030 AutoConnectProfiles();
1032 // We rescan the "software" folder if the user either changed the path or
1033 // checked/unchecked the "Allow unknown files" option in the config dialog.
1034 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1035 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1037 // If the "Alpine" ROM is changed, then let's load it...
1038 if (alpineBefore
!= alpineAfter
)
1040 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1042 // Oh crap, we couldn't get the file! Alert the media!
1044 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1045 msg
.setIcon(QMessageBox::Warning
);
1050 // If the "ABS" ROM is changed, then let's load it...
1051 if (absBefore
!= absAfter
)
1053 if (!JaguarLoadFile(vjs
.absROMPath
))
1055 // Oh crap, we couldn't get the file! Alert the media!
1057 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1058 msg
.setIcon(QMessageBox::Warning
);
1063 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1064 // since it's running in the host audio IRQ...
1065 if (audioBefore
!= audioAfter
)
1071 // Just in case we crash before a clean exit...
1074 DebuggerRefreshWindows();
1079 // Here's the main emulator loop
1081 void MainWin::Timer(void)
1084 static uint32_t ntscTickCount
;
1085 if (vjs
.hardwareTypeNTSC
)
1089 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1096 if (showUntunedTankCircuit
)
1098 // Some machines can't handle this, so we give them the option to disable it. :-)
1099 if (!plzDontKillMyComputer
)
1101 // if (!vjs.softTypeDebugger)
1103 // Random hash & trash
1104 // We try to simulate an untuned tank circuit here... :-)
1105 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1107 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1109 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1117 // Otherwise, run the Jaguar simulation
1120 //if (!vjs.softTypeDebugger)
1121 videoWidget
->HandleMouseHiding();
1123 static uint32_t refresh
= 0;
1124 // Do autorefresh on debug windows
1125 // Have to be careful, too much causes the emulator to slow way down!
1126 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1128 if (refresh
== vjs
.refresh
)
1130 AlpineRefreshWindows();
1131 //memBrowseWin->RefreshContents();
1132 //cpuBrowseWin->RefreshContents();
1140 //if (!vjs.softTypeDebugger)
1141 videoWidget
->updateGL();
1144 // Approach: We use a ring buffer to store times (in ms) over a given
1145 // amount of frames, then sum them to figure out the FPS.
1146 uint32_t timestamp
= SDL_GetTicks();
1147 // This assumes the ring buffer size is a power of 2
1148 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1149 // Doing it this way is better. Ring buffer size can be arbitrary then.
1150 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1151 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1152 uint32_t elapsedTime
= 0;
1154 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1155 elapsedTime
+= ringBuffer
[i
];
1157 // elapsedTime must be non-zero
1158 if (elapsedTime
== 0)
1161 // This is in frames per 10 seconds, so we can have 1 decimal
1162 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1163 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1164 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1165 // If this is updated too frequently to be useful, we can throttle it down
1166 // so that it only updates every 10th frame or so
1167 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1168 oldTimestamp
= timestamp
;
1170 if (M68KDebugHaltStatus())
1175 // Toggle the power state, it can be either on or off
1176 void MainWin::TogglePowerState(void)
1178 powerButtonOn
= !powerButtonOn
;
1181 // With the power off, we simulate white noise on the screen. :-)
1184 // Restore the mouse pointer, if hidden:
1185 //if (!vjs.softTypeDebugger)
1187 videoWidget
->CheckAndRestoreMouseCursor();
1190 useCDAct
->setDisabled(false);
1191 palAct
->setDisabled(false);
1192 ntscAct
->setDisabled(false);
1193 pauseAct
->setChecked(false);
1194 pauseAct
->setDisabled(true);
1195 showUntunedTankCircuit
= true;
1197 DACPauseAudioThread();
1198 // 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. :-)
1201 if (plzDontKillMyComputer
)
1203 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1204 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1206 if (vjs
.hardwareTypeNTSC
)
1208 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1212 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1219 useCDAct
->setDisabled(true);
1220 palAct
->setDisabled(true);
1221 ntscAct
->setDisabled(true);
1222 pauseAct
->setChecked(false);
1223 pauseAct
->setDisabled(false);
1224 showUntunedTankCircuit
= false;
1226 // Otherwise, we prepare for running regular software...
1229 // Should check for cartridgeLoaded here as well...!
1230 // We can clear it when toggling CDActive on, so that when we power cycle it
1231 // does the expected thing. Otherwise, if we use the file picker to insert a
1232 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1233 // works if the CD unit is active?
1234 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1237 WriteLog("GUI: Resetting Jaguar...\n");
1240 DebuggerResetWindows();
1241 DACPauseAudioThread(false);
1246 // Toggle the emulator state, it can be either on or off
1247 void MainWin::ToggleRunState(void)
1249 startM68KTracing
= running
;
1255 // Set action buttons for the pause mode
1256 frameAdvanceAct
->setDisabled(false);
1257 pauseAct
->setChecked(true);
1258 pauseAct
->setDisabled(false);
1259 if (vjs
.softTypeDebugger
)
1261 traceStepIntoAct
->setDisabled(false);
1262 traceStepOverAct
->setDisabled(false);
1263 restartAct
->setDisabled(false);
1264 m68kDasmWin
->Use68KPCAddress();
1265 GPUDasmWin
->UseGPUPCAddress();
1266 DSPDasmWin
->UseDSPPCAddress();
1269 //if (!vjs.softTypeDebugger)
1271 // Restore the mouse pointer, if hidden:
1272 videoWidget
->CheckAndRestoreMouseCursor();
1274 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1276 uint32_t pixel
= videoWidget
->buffer
[i
];
1277 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1278 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1279 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1282 videoWidget
->updateGL();
1284 cpuBrowseWin
->HoldBPM();
1285 cpuBrowseWin
->HandleBPMContinue();
1286 DebuggerRefreshWindows();
1291 frameAdvanceAct
->setDisabled(true);
1292 pauseAct
->setChecked(false);
1293 pauseAct
->setDisabled(false);
1294 if (vjs
.softTypeDebugger
)
1296 traceStepIntoAct
->setDisabled(true);
1297 traceStepOverAct
->setDisabled(true);
1298 restartAct
->setDisabled(true);
1299 BreakpointsWin
->RefreshContents();
1302 cpuBrowseWin
->UnholdBPM();
1305 // Pause/unpause any running/non-running threads...
1306 DACPauseAudioThread(!running
);
1310 void MainWin::SetZoom100(void)
1317 void MainWin::SetZoom200(void)
1324 void MainWin::SetZoom300(void)
1331 void MainWin::SetNTSC(void)
1333 powerAct
->setIcon(powerRed
);
1334 timer
->setInterval(16);
1335 vjs
.hardwareTypeNTSC
= true;
1341 void MainWin::SetPAL(void)
1343 powerAct
->setIcon(powerGreen
);
1344 timer
->setInterval(20);
1345 vjs
.hardwareTypeNTSC
= false;
1351 void MainWin::ToggleBlur(void)
1353 vjs
.glFilter
= !vjs
.glFilter
;
1358 void MainWin::ShowAboutWin(void)
1364 void MainWin::ShowHelpWin(void)
1370 void MainWin::InsertCart(void)
1372 // Check to see if we did autorun, 'cause we didn't load anything in that
1374 if (!scannedSoftwareFolder
)
1376 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1377 scannedSoftwareFolder
= true;
1380 // If the emulator is running, we pause it here and unpause it later
1381 // if we dismiss the file selector without choosing anything
1382 if (running
&& powerButtonOn
)
1385 pauseForFileSelector
= true;
1388 filePickWin
->show();
1392 void MainWin::Unpause(void)
1394 // Here we unpause the emulator if it was paused when we went into the file selector
1395 if (pauseForFileSelector
)
1397 pauseForFileSelector
= false;
1399 // Some nutter might have unpaused while in the file selector, so check for that
1406 // Jaguar initialisation and load software file
1407 void MainWin::LoadSoftware(QString file
)
1409 running
= false; // Prevent bad things(TM) from happening...
1410 pauseForFileSelector
= false; // Reset the file selector pause flag
1412 // Setup BIOS in his own dedicated Jaguar memory
1413 #ifndef NEWMODELSBIOSHANDLER
1414 uint8_t * biosPointer
= jaguarBootROM
;
1416 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1418 biosPointer
= jaguarDevBootROM2
;
1421 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1423 SelectBIOS(vjs
.biosType
);
1426 // Turn 'on' the power to initialize the Jaguar
1427 powerAct
->setDisabled(false);
1428 powerAct
->setChecked(true);
1429 powerButtonOn
= false;
1432 // We have to load our software *after* the Jaguar RESET
1433 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1434 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1436 // This is icky because we've already done it
1437 // it gets worse :-P
1438 if (!vjs
.useJaguarBIOS
)
1440 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1445 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1446 if (vjs
.softTypeDebugger
)
1448 m68k_set_reg(M68K_REG_A6
, 0);
1449 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1450 //pauseAct->setDisabled(false);
1451 //pauseAct->setChecked(true);
1457 // Prevent the launch in case of software without a start address and without BIOS presence
1458 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1464 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1466 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1467 setWindowTitle(newTitle
);
1472 void MainWin::ToggleCDUsage(void)
1474 CDActive
= !CDActive
;
1476 // Set up the Jaguar CD for execution, otherwise, clear memory
1478 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1480 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1484 // Open, or display, the breakpoints list window
1485 void MainWin::ShowBreakpointsWin(void)
1487 BreakpointsWin
->show();
1488 BreakpointsWin
->RefreshContents();
1492 // Delete all breakpoints
1493 void MainWin::DeleteAllBreakpoints(void)
1495 cpuBrowseWin
->ResetBPM();
1497 ShowBreakpointsWin();
1501 // Disable all breakpoints
1502 void MainWin::DisableAllBreakpoints(void)
1504 cpuBrowseWin
->DisableBPM();
1506 ShowBreakpointsWin();
1510 // Open, or display, the new breakpoint function window
1511 void MainWin::ShowNewFunctionBreakpointWin(void)
1513 NewFunctionBreakpointWin
->show();
1514 ShowBreakpointsWin();
1519 void MainWin::ShowCartFilesListWin(void)
1521 CartFilesListWin
->show();
1522 CartFilesListWin
->RefreshContents();
1527 void MainWin::DebuggerTraceStepInto(void)
1530 videoWidget
->updateGL();
1531 DebuggerRefreshWindows();
1533 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1535 #warning "!!! Need to verify the Step Into function !!!"
1540 // Restart the Jaguar executable
1541 void MainWin::DebuggerRestart(void)
1546 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1547 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1549 m68k_set_reg(M68K_REG_A6
, 0);
1550 m68k_brk_hitcounts_reset();
1552 DebuggerResetWindows();
1553 DebuggerRefreshWindows();
1555 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1557 #warning "!!! Need to verify the Restart function !!!"
1563 void MainWin::DebuggerTraceStepOver(void)
1566 videoWidget
->updateGL();
1567 DebuggerRefreshWindows();
1569 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1571 #warning "!!! Need to verify the Step Over function !!!"
1576 // Advance / Execute for one frame
1577 void MainWin::FrameAdvance(void)
1579 //printf("Frame Advance...\n");
1581 // Execute 1 frame, then exit (only useful in Pause mode)
1583 //if (!vjs.softTypeDebugger)
1584 videoWidget
->updateGL();
1586 // Need to execute 1 frames' worth of DSP thread as well :-/
1588 //m68kDasmWin->Use68KPCAddress();
1591 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1593 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1598 void MainWin::SetFullScreen(bool state
/*= true*/)
1600 if (!vjs
.softTypeDebugger
)
1604 mainWinPosition
= pos();
1606 statusBar()->hide();
1612 // This is needed because the fullscreen may happen on a different
1613 // screen than screen 0:
1614 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1615 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1616 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1617 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1618 double aspectRatio
= targetWidth
/ targetHeight
;
1619 // NOTE: Really should check here to see which dimension constrains the
1620 // other. Right now, we assume that height is the constraint.
1621 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1622 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1623 videoWidget
->fullscreen
= true;
1624 videoWidget
->outputWidth
= newWidth
;
1625 videoWidget
->setFixedSize(r
.width(), r
.height());
1630 // Seems Qt is fussy about this: showNormal() has to go first, or it
1631 // will keep the window stuck in a psuedo-fullscreen mode with no way
1632 // to get out of it (except closing the app).
1635 // Reset the video widget to windowed mode
1636 videoWidget
->offset
= 0;
1637 videoWidget
->fullscreen
= false;
1639 statusBar()->show();
1646 move(mainWinPosition
);
1652 void MainWin::ToggleFullScreen(void)
1654 fullScreen
= !fullScreen
;
1655 SetFullScreen(fullScreen
);
1660 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1662 exceptionvectortableBrowseWin
->show();
1663 exceptionvectortableBrowseWin
->RefreshContents();
1668 void MainWin::ShowLocalBrowserWin(void)
1670 LocalBrowseWin
->show();
1671 LocalBrowseWin
->RefreshContents();
1676 void MainWin::ShowCallStackBrowserWin(void)
1678 CallStackBrowseWin
->show();
1679 CallStackBrowseWin
->RefreshContents();
1683 void MainWin::ShowAllWatchBrowserWin(void)
1685 allWatchBrowseWin
->show();
1686 allWatchBrowseWin
->RefreshContents();
1690 void MainWin::ShowHeapAllocatorBrowserWin(void)
1692 heapallocatorBrowseWin
->show();
1693 heapallocatorBrowseWin
->RefreshContents();
1697 void MainWin::ShowMemoryBrowserWin(void)
1699 memBrowseWin
->show();
1700 memBrowseWin
->RefreshContents();
1704 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1706 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1708 mem1BrowseWin
[NumWin
]->show();
1709 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1714 void MainWin::ShowEmuStatusWin(void)
1716 emuStatusWin
->show();
1717 emuStatusWin
->RefreshContents();
1721 void MainWin::ShowStackBrowserWin(void)
1723 stackBrowseWin
->show();
1724 stackBrowseWin
->RefreshContents();
1728 void MainWin::ShowCPUBrowserWin(void)
1730 cpuBrowseWin
->show();
1731 cpuBrowseWin
->RefreshContents();
1735 void MainWin::ShowOPBrowserWin(void)
1737 opBrowseWin
->show();
1738 opBrowseWin
->RefreshContents();
1742 void MainWin::ShowM68KDasmBrowserWin(void)
1744 m68kDasmBrowseWin
->show();
1745 m68kDasmBrowseWin
->RefreshContents();
1749 void MainWin::ShowRISCDasmBrowserWin(void)
1751 riscDasmBrowseWin
->show();
1752 riscDasmBrowseWin
->RefreshContents();
1758 void MainWin::ShowDasmWin(void)
1761 // DasmWin->RefreshContents();
1768 void MainWin::ShowVideoOutputWin(void)
1770 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1771 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1772 //VideoOutputWindowCentrale->show();
1773 //memBrowseWin->show();
1774 //VideoOutputWin->show();
1775 //VideoOutputWin->RefreshContents(videoWidget);
1780 // Resize video window based on zoom factor
1781 // It doesn't apply in debugger mode as we use this window to display disassembly
1782 void MainWin::ResizeMainWindow(void)
1784 if (!vjs
.softTypeDebugger
)
1786 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1788 // Show the test pattern if user requested plzDontKillMyComputer mode
1789 if (!powerButtonOn
&& plzDontKillMyComputer
)
1791 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1793 if (vjs
.hardwareTypeNTSC
)
1795 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1799 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1810 void MainWin::ReadSettings(void)
1814 QSettings
settings("Underground Software", "Virtual Jaguar");
1816 //zoomLevel = settings.value("zoom", 2).toInt();
1817 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1818 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1820 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1821 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1822 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1823 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1824 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1825 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1826 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1827 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1828 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1829 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1830 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1831 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1832 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1833 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1834 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1835 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1836 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1837 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1838 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1839 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1840 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1842 // Read settings from the Debugger mode
1843 settings
.beginGroup("debugger");
1844 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1845 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1846 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1847 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1848 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1849 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1850 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1851 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1852 settings
.endGroup();
1854 // Read settings from the Alpine mode
1855 settings
.beginGroup("alpine");
1856 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1857 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1858 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1859 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1860 settings
.endGroup();
1862 // Read settings from the Keybindings
1863 settings
.beginGroup("keybindings");
1864 for (i
= 0; i
< KB_END
; i
++)
1866 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1868 settings
.endGroup();
1870 // Write important settings to the log file
1871 WriteLog("MainWin: Paths\n");
1872 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1873 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1874 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1875 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1876 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1877 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1878 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1879 WriteLog("MainWin: Misc.\n");
1880 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1883 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1884 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1885 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1886 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1887 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1888 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1889 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1890 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1891 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1892 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1893 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1894 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1895 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1896 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1897 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1898 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1899 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1900 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1901 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1902 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1903 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1904 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1906 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1907 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1908 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1909 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1910 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1911 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1912 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1913 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1914 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1915 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1916 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1917 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1918 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1919 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1920 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1921 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1922 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1923 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1924 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1925 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1926 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1929 WriteLog("Read setting = Done\n");
1931 ReadProfiles(&settings
);
1932 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
1937 // Default values will be used in case of no settings can be found
1939 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1941 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1943 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1944 void MainWin::ReadUISettings(void)
1951 // Point on the emulator settings
1952 QSettings
settings("Underground Software", "Virtual Jaguar");
1953 settings
.beginGroup("ui");
1955 // Emulator main window UI information
1956 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1957 size
= settings
.value("size", QSize(400, 400)).toSize();
1959 move(mainWinPosition
);
1960 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1961 filePickWin
->move(pos
);
1963 // Video output information
1964 zoomLevel
= settings
.value("zoom", 2).toInt();
1966 // Alpine debug UI information (also needed by the Debugger)
1967 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1969 // CPU registers UI information
1970 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1971 cpuBrowseWin
->move(pos
);
1972 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1974 // Memory browser UI information
1975 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1976 memBrowseWin
->move(pos
);
1977 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1979 // Stack browser UI information
1980 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1981 stackBrowseWin
->move(pos
);
1982 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1983 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1984 stackBrowseWin
->resize(size
);
1986 // Emulator status UI information
1987 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1988 emuStatusWin
->move(pos
);
1989 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1991 // OP (Object Processor) UI information
1992 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1993 opBrowseWin
->move(pos
);
1994 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1995 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1996 opBrowseWin
->resize(size
);
1998 // RISC disassembly UI information
1999 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2000 riscDasmBrowseWin
->move(pos
);
2001 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2003 // M68k disassembly UI information
2004 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2005 m68kDasmBrowseWin
->move(pos
);
2006 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2008 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2010 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2014 // Debugger UI information
2015 if (vjs
.softTypeDebugger
)
2018 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2019 m68kDasmWin
->move(pos
);
2020 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2021 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2022 GPUDasmWin
->move(pos
);
2023 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2024 DSPDasmWin
->move(pos
);
2026 // All watch browser UI information
2027 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2028 allWatchBrowseWin
->move(pos
);
2029 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2030 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2031 allWatchBrowseWin
->resize(size
);
2033 // Local browser UI information
2034 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2035 LocalBrowseWin
->move(pos
);
2036 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2037 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2038 LocalBrowseWin
->resize(size
);
2040 // Heap memory allocation browser UI information
2041 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2042 heapallocatorBrowseWin
->move(pos
);
2043 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2044 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2045 heapallocatorBrowseWin
->resize(size
);
2047 // Exception Vector Table UI Information
2048 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2049 exceptionvectortableBrowseWin
->move(pos
);
2050 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2051 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2052 exceptionvectortableBrowseWin
->resize(size
);
2054 // Call Stack browser UI information
2055 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2056 CallStackBrowseWin
->move(pos
);
2057 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2058 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2059 CallStackBrowseWin
->resize(size
);
2061 // Cartdridge directory and files
2062 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2063 CartFilesListWin
->move(pos
);
2064 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2065 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2066 CartFilesListWin
->resize(size
);
2068 // Breakpoints UI information
2069 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2070 BreakpointsWin
->move(pos
);
2071 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2072 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2073 BreakpointsWin
->resize(size
);
2074 // New function breakpoint UI information
2075 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2076 NewFunctionBreakpointWin
->move(pos
);
2077 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2078 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2079 NewFunctionBreakpointWin
->resize(size
);
2081 // Memories browser UI information
2082 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2084 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2085 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2086 mem1BrowseWin
[i
]->move(pos
);
2087 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2088 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2089 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2090 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2091 mem1BrowseWin
[i
]->resize(size
);
2095 settings
.endGroup();
2097 WriteLog("Read UI setting = Done\n");
2101 // Save the settings
2102 void MainWin::WriteSettings(void)
2106 // Point on the emulator settings
2107 QSettings
settings("Underground Software", "Virtual Jaguar");
2108 //settings.setValue("pos", pos());
2109 //settings.setValue("size", size());
2110 //settings.setValue("cartLoadPos", filePickWin->pos());
2112 //settings.setValue("zoom", zoomLevel);
2113 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2114 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2116 settings
.setValue("useJoystick", vjs
.useJoystick
);
2117 settings
.setValue("joyport", vjs
.joyport
);
2118 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2119 settings
.setValue("frameSkip", vjs
.frameSkip
);
2120 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2121 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2122 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2123 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2124 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2125 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2126 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2127 settings
.setValue("fullscreen", vjs
.fullscreen
);
2128 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2129 settings
.setValue("glFilterType", vjs
.glFilter
);
2130 settings
.setValue("renderType", vjs
.renderType
);
2131 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2132 settings
.setValue("biosType", vjs
.biosType
);
2133 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2134 //settings.setValue("JagBootROM", vjs.jagBootPath);
2135 //settings.setValue("CDBootROM", vjs.CDBootPath);
2136 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2137 settings
.setValue("ROMs", vjs
.ROMPath
);
2138 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2140 // Write settings from the Alpine mode
2141 settings
.beginGroup("alpine");
2142 settings
.setValue("refresh", vjs
.refresh
);
2143 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2144 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2145 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2146 settings
.endGroup();
2148 // Write settings from the Debugger mode
2149 settings
.beginGroup("debugger");
2150 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2151 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2152 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2153 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2154 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2155 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2156 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2157 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2158 settings
.endGroup();
2160 // Write settings from the Keybindings
2161 settings
.beginGroup("keybindings");
2162 for (i
= 0; i
< KB_END
; i
++)
2164 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2166 settings
.endGroup();
2169 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2170 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2171 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2172 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2173 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2174 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2175 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2176 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2177 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2178 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2179 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2180 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2181 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2182 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2183 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2184 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2185 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2186 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2187 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2188 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2189 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2191 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2192 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2193 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2194 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2195 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2196 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2197 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2198 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2199 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2200 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2201 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2202 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2203 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2204 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2205 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2206 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2207 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2208 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2209 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2210 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2211 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2214 WriteProfiles(&settings
);
2215 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2219 // Save the UI settings
2220 void MainWin::WriteUISettings(void)
2225 // Point on the emulator settings
2226 QSettings
settings("Underground Software", "Virtual Jaguar");
2227 settings
.beginGroup("ui");
2229 // Emulator UI information
2230 settings
.setValue("pos", pos());
2231 settings
.setValue("size", size());
2232 settings
.setValue("cartLoadPos", filePickWin
->pos());
2234 // Video output information
2235 settings
.setValue("zoom", zoomLevel
);
2237 // Alpine debug UI information (also needed by the Debugger)
2238 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2240 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2241 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2242 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2243 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2244 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2245 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2246 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2247 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2248 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2249 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2250 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2251 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2252 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2253 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2254 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2255 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2258 // Debugger UI information
2259 if (vjs
.softTypeDebugger
)
2262 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2263 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2264 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2265 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2267 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2268 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2269 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2270 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2271 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2272 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2273 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2274 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2275 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2276 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2277 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2278 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2279 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2280 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2281 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2282 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2283 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2284 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2285 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2286 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2287 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2288 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2289 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2290 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2292 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2294 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2295 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2296 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2297 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2298 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2299 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2303 settings
.endGroup();
2307 // Refresh alpine debug windows
2308 void MainWin::AlpineRefreshWindows(void)
2310 cpuBrowseWin
->RefreshContents();
2311 memBrowseWin
->RefreshContents();
2312 stackBrowseWin
->RefreshContents();
2313 emuStatusWin
->RefreshContents();
2314 opBrowseWin
->RefreshContents();
2315 riscDasmBrowseWin
->RefreshContents();
2316 m68kDasmBrowseWin
->RefreshContents();
2320 // Reset soft debugger
2321 void MainWin::DebuggerReset(void)
2323 if (vjs
.softTypeDebugger
)
2325 DeleteAllBreakpoints();
2330 // Reset soft debugger windows
2331 void MainWin::DebuggerResetWindows(void)
2333 if (vjs
.softTypeDebugger
)
2335 FilesrcListWin
->Reset();
2336 allWatchBrowseWin
->Reset();
2337 heapallocatorBrowseWin
->Reset();
2338 BreakpointsWin
->Reset();
2339 CartFilesListWin
->Reset();
2340 //ResetAlpineWindows();
2345 // Refresh view windows
2346 void MainWin::ViewRefreshWindows(void)
2348 CartFilesListWin
->RefreshContents();
2352 // Refresh soft debugger & alpine debug windows
2353 void MainWin::DebuggerRefreshWindows(void)
2355 if (vjs
.softTypeDebugger
)
2357 FilesrcListWin
->RefreshContents();
2358 m68kDasmWin
->RefreshContents();
2359 GPUDasmWin
->RefreshContents();
2360 DSPDasmWin
->RefreshContents();
2361 allWatchBrowseWin
->RefreshContents();
2362 LocalBrowseWin
->RefreshContents();
2363 CallStackBrowseWin
->RefreshContents();
2364 heapallocatorBrowseWin
->RefreshContents();
2365 BreakpointsWin
->RefreshContents();
2366 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2368 mem1BrowseWin
[i
]->RefreshContents(i
);
2371 AlpineRefreshWindows();
2372 ViewRefreshWindows();
2377 // Create and save screenshot
2378 void MainWin::MakeScreenshot(void)
2382 time_t now
= time(0);
2386 tstruct
= *localtime(&now
);
2387 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
);
2389 // Create screenshot
2390 screenshot
= videoWidget
->grabFrameBuffer();
2391 screenshot
.save((char *)Text
, "JPG", 100);