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
29 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
30 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
31 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
32 // with 'R', etc) [DONE]
33 // - Controller configuration [DONE]
37 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
38 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
39 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
42 // SFDX CODE: S1E9T8H5M23YS
44 // Uncomment this for debugging...
46 //#define DEBUGFOO // Various tool debugging... but not used
47 //#define DEBUGTP // Toolpalette debugging... but not used
54 #include "configdialog.h"
55 #include "controllertab.h"
56 #include "keybindingstab.h"
57 #include "filepicker.h"
59 #include "generaltab.h"
65 #include "emustatus.h"
66 #include "debug/cpubrowser.h"
67 #include "debug/m68kdasmbrowser.h"
68 #include "debug/memorybrowser.h"
69 #include "debug/stackbrowser.h"
70 #include "debug/opbrowser.h"
71 #include "debug/riscdasmbrowser.h"
77 #ifndef NEWMODELSBIOSHANDLER
80 #include "jagstub2bios.h"
82 #include "modelsBIOS.h"
84 #include "jagcdbios.h"
86 #include "m68000/m68kinterface.h"
88 #include "debugger/DBGManager.h"
89 //#include "debugger/VideoWin.h"
90 //#include "debugger/DasmWin.h"
91 #include "debugger/m68KDasmWin.h"
92 #include "debugger/GPUDasmWin.h"
93 #include "debugger/DSPDasmWin.h"
94 #include "debugger/memory1browser.h"
95 #include "debugger/BreakpointsWin.h"
96 #include "debugger/NewFnctBreakpointWin.h"
97 #include "debugger/FilesrcListWin.h"
98 #include "debugger/exceptionvectortablebrowser.h"
99 #include "debugger/allwatchbrowser.h"
100 #include "debugger/localbrowser.h"
101 #include "debugger/heapallocatorbrowser.h"
102 #include "debugger/callstackbrowser.h"
103 #include "debugger/CartFilesListWin.h"
106 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
107 //#ifdef __GCCWIN32__
108 // Apparently on win32, usleep() is not pulled in by the usual suspects.
112 #include "_MSC_VER/unistd.h"
116 // The way BSNES controls things is by setting a timer with a zero
117 // timeout, sleeping if not emulating anything. Seems there has to be a
120 // It has a novel approach to plugging-in/using different video/audio/input
121 // methods, can we do something similar or should we just use the built-in
124 // We're going to try to use the built-in OpenGL support and see how it goes.
125 // We'll make the VJ core modular so that it doesn't matter what GUI is in
126 // use, we can drop it in anywhere and use it as-is.
128 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
129 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
130 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
136 for(int i
=0; i
<8; i
++)
140 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
143 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
146 //if (vjs.softTypeDebugger)
148 // mainWindowCentrale = new QMdiArea;
149 // setCentralWidget(mainWindowCentrale);
152 WriteLog("Window creation start\n");
155 videoWidget
= new GLWidget(this);
156 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
158 // set central output window
159 if (!vjs
.softTypeDebugger
)
161 setCentralWidget(videoWidget
);
165 mainWindowCentrale
= new QMdiArea(this);
166 setCentralWidget(mainWindowCentrale
);
169 setWindowIcon(QIcon(":/res/vj-icon.png"));
171 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
173 if (vjs
.hardwareTypeAlpine
)
174 title
+= QString(tr(" - Alpine Mode"));
176 if (vjs
.softTypeDebugger
)
177 title
+= QString(tr(" - Debugger Mode"));
179 setWindowTitle(title
);
181 aboutWin
= new AboutWindow(this);
182 helpWin
= new HelpWindow(this);
183 filePickWin
= new FilePickerWindow(this);
184 memBrowseWin
= new MemoryBrowserWindow(this);
185 stackBrowseWin
= new StackBrowserWindow(this);
186 emuStatusWin
= new EmuStatusWindow(this);
187 cpuBrowseWin
= new CPUBrowserWindow(this);
188 opBrowseWin
= new OPBrowserWindow(this);
189 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
190 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
191 if (vjs
.softTypeDebugger
)
193 //VideoOutputWin = new VideoOutputWindow(this);
194 //VideoOutputWin->setCentralWidget()
195 //DasmWin = new DasmWindow();
196 //DasmWin = new DasmWindow(this);
197 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
198 LocalBrowseWin
= new LocalBrowserWindow(this);
199 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
200 BreakpointsWin
= new BreakpointsWindow(this);
201 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
202 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
203 CallStackBrowseWin
= new CallStackBrowserWindow(this);
204 CartFilesListWin
= new CartFilesListWindow(this);
206 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
208 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
210 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
212 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
214 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
217 // Setup dock to display source code filenames tree
218 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
219 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
221 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
222 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
223 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
225 // Setup dock to display disassembly
226 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
227 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
228 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
229 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
230 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
232 dasmtabWidget
= new QTabWidget(this);
235 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
236 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
237 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
238 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
240 setCentralWidget(dasmtabWidget
);
244 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
245 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
247 setUnifiedTitleAndToolBarOnMac(true);
250 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
251 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
252 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
253 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
254 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
257 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
258 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
259 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
260 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
261 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
262 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
263 powerAct
->setCheckable(true);
264 powerAct
->setChecked(false);
265 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
269 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
270 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
271 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
272 pauseAct
->setStatusTip(tr("Toggles the running state"));
273 pauseAct
->setCheckable(true);
274 pauseAct
->setDisabled(true);
275 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
276 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
277 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
280 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
281 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
282 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
283 screenshotAct
->setCheckable(false);
284 screenshotAct
->setDisabled(false);
285 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
288 zoomActs
= new QActionGroup(this);
289 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
290 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
291 x1Act
->setCheckable(true);
292 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
293 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
294 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
295 x2Act
->setCheckable(true);
296 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
297 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
298 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
299 x3Act
->setCheckable(true);
300 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
303 tvTypeActs
= new QActionGroup(this);
304 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
305 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
306 ntscAct
->setCheckable(true);
307 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
308 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
309 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
310 palAct
->setCheckable(true);
311 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
314 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
315 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
316 blurAct
= new QAction(blur
, tr("Blur"), this);
317 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
318 blurAct
->setCheckable(true);
319 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
322 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
323 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
324 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
327 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
328 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
329 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
331 // File pickup action
332 if (!vjs
.softTypeDebugger
)
334 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
335 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
339 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
340 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
342 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
343 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
344 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
346 // Configuration action
347 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
348 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
349 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
350 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
351 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
353 // Emulation status action
354 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
355 emustatusAct
->setStatusTip(tr("Emulator status"));
356 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
357 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
358 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
361 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
362 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
363 useCDAct
->setCheckable(true);
364 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
366 // Frame advance action
367 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
368 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
369 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
370 frameAdvanceAct
->setDisabled(true);
371 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
374 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
375 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
376 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
377 fullScreenAct
->setCheckable(true);
378 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
380 // Actions dedicated to debugger mode
381 if (vjs
.softTypeDebugger
)
384 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
385 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
386 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
387 restartAct
->setCheckable(false);
388 restartAct
->setDisabled(true);
389 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
392 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
393 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
394 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
395 traceStepOverAct
->setCheckable(false);
396 traceStepOverAct
->setDisabled(true);
397 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
399 // Trace into tracing
400 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
401 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
402 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
403 traceStepIntoAct
->setCheckable(false);
404 traceStepIntoAct
->setDisabled(true);
405 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
407 // Function breakpoint
408 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
409 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
410 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
411 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
412 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
413 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
414 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
415 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
416 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
417 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
418 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
420 //VideoOutputAct = new QAction(tr("Output Video"), this);
421 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
422 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
424 //DasmAct = new QAction(tr("Disassembly"), this);
425 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
426 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
428 // Exception vector table window
429 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
430 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
431 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
433 // All watch variables window
434 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
435 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
436 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
438 // Local variables window
439 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
440 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
441 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
443 // Heap (memory) allocation window
444 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
445 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
446 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
449 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
450 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
451 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
454 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
455 CartFilesListAct
->setStatusTip(tr("List of the files in the cartdridge's directory"));
456 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
459 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
460 QSignalMapper
*signalMapper
= new QSignalMapper(this);
462 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
464 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
466 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
469 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
470 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
471 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
472 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
473 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
474 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
478 // Memory browser window action
479 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
480 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
481 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
483 // Stack browser window action
484 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
485 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
486 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
488 // CPUs (M68000, GPU & DSP browser window action
489 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
490 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
491 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
493 // OP browser window action
494 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
495 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
496 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
498 // M68000 disassembly browser window
499 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
500 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
501 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
503 // Risc (DSP / GPU) disassembly browser window
504 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
505 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
506 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
508 // Misc. connections...
509 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
510 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
514 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
515 fileMenu
->addAction(powerAct
);
516 if (!vjs
.softTypeDebugger
)
518 fileMenu
->addAction(pauseAct
);
519 // fileMenu->addAction(frameAdvanceAct);
521 fileMenu
->addAction(filePickAct
);
522 fileMenu
->addAction(useCDAct
);
523 fileMenu
->addAction(configAct
);
524 fileMenu
->addAction(emustatusAct
);
525 fileMenu
->addSeparator();
526 fileMenu
->addAction(quitAppAct
);
528 // Alpine and debugger menus
529 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
531 // Create debug & view menu
532 debugMenu
= menuBar()->addMenu(tr("&Debug"));
533 viewMenu
= menuBar()->addMenu(tr("&View"));
535 // Create debugger menu
536 if (vjs
.softTypeDebugger
)
539 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
540 viewCartMenu
->addAction(CartFilesListAct
);
542 viewCartMenu
->addSeparator();
543 viewCartMenu
->addAction(CartStreamsAct
);
547 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
548 debugWindowsMenu
->addAction(BreakpointsAct
);
549 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
550 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
551 debugWindowsMenu
->addSeparator();
553 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
554 debugWindowOutputMenu
->addAction(VideoOutputAct
);
555 debugWindowsMenu
->addSeparator();
557 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
558 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
559 debugWindowsMenu
->addAction(LocalBrowseAct
);
560 debugWindowsMenu
->addSeparator();
561 debugWindowsMenu
->addAction(CallStackBrowseAct
);
562 debugWindowsMenu
->addSeparator();
563 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
564 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
565 debugWindowsMemoryMenu
->addSeparator();
566 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
568 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
570 debugWindowsMenu
->addSeparator();
571 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
572 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
573 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
574 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
575 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
576 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
577 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
578 debugMenu
->addSeparator();
579 debugMenu
->addAction(pauseAct
);
580 debugMenu
->addAction(frameAdvanceAct
);
581 debugMenu
->addAction(restartAct
);
582 debugMenu
->addSeparator();
583 debugMenu
->addAction(traceStepIntoAct
);
584 debugMenu
->addAction(traceStepOverAct
);
585 debugMenu
->addSeparator();
586 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
587 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
588 debugMenu
->addAction(deleteAllBreakpointsAct
);
589 debugMenu
->addAction(disableAllBreakpointsAct
);
591 debugMenu
->addSeparator();
592 debugMenu
->addAction(DasmAct
);
597 // Create alpine menu
598 debugMenu
->addAction(memBrowseAct
);
599 debugMenu
->addAction(stackBrowseAct
);
600 debugMenu
->addAction(cpuBrowseAct
);
601 debugMenu
->addAction(opBrowseAct
);
602 debugMenu
->addAction(m68kDasmBrowseAct
);
603 debugMenu
->addAction(riscDasmBrowseAct
);
608 helpMenu
= menuBar()->addMenu(tr("&Help"));
609 helpMenu
->addAction(helpAct
);
610 helpMenu
->addAction(aboutAct
);
614 toolbar
= addToolBar(tr("System"));
615 toolbar
->addAction(powerAct
);
616 if (!vjs
.softTypeDebugger
)
618 toolbar
->addAction(pauseAct
);
619 toolbar
->addAction(frameAdvanceAct
);
621 toolbar
->addAction(filePickAct
);
622 toolbar
->addAction(useCDAct
);
623 toolbar
->addSeparator();
624 if (!vjs
.softTypeDebugger
)
626 toolbar
->addAction(screenshotAct
);
627 toolbar
->addSeparator();
628 toolbar
->addAction(x1Act
);
629 toolbar
->addAction(x2Act
);
630 toolbar
->addAction(x3Act
);
631 toolbar
->addSeparator();
632 toolbar
->addAction(ntscAct
);
633 toolbar
->addAction(palAct
);
634 toolbar
->addSeparator();
635 toolbar
->addAction(blurAct
);
636 toolbar
->addAction(fullScreenAct
);
640 debuggerbar
= addToolBar(tr("&Debugger"));
641 debuggerbar
->addAction(pauseAct
);
642 debuggerbar
->addAction(frameAdvanceAct
);
643 debuggerbar
->addAction(restartAct
);
644 debuggerbar
->addSeparator();
645 debuggerbar
->addAction(traceStepIntoAct
);
646 debuggerbar
->addAction(traceStepOverAct
);
647 debuggerbar
->addSeparator();
648 debuggerbar
->addAction(BreakpointsAct
);
651 if (vjs
.hardwareTypeAlpine
)
653 debugbar
= addToolBar(tr("&Debug"));
654 debugbar
->addAction(memBrowseAct
);
655 debugbar
->addAction(stackBrowseAct
);
656 debugbar
->addAction(cpuBrowseAct
);
657 debugbar
->addAction(opBrowseAct
);
658 debugbar
->addAction(m68kDasmBrowseAct
);
659 debugbar
->addAction(riscDasmBrowseAct
);
662 // Add actions to the main window, as hiding widgets with them
664 addAction(fullScreenAct
);
665 addAction(quitAppAct
);
666 addAction(configAct
);
667 addAction(emustatusAct
);
669 addAction(filePickAct
);
670 addAction(frameAdvanceAct
);
673 statusBar()->showMessage(tr("Ready"));
675 // Do this in case original size isn't correct (mostly for the first-run case)
678 WriteLog("Window creation done\n");
680 // Create our test pattern NTSC bitmap
681 WriteLog("Test pattern 1 bitmap\n");
683 QImage
tempImg(":/res/test-pattern.jpg");
684 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
686 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
688 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
690 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
692 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
693 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
697 // Create our test pattern PAL bitmap
698 WriteLog("Test pattern 2 bitmap\n");
700 QImage
tempImg2(":/res/test-pattern-pal.jpg");
701 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
703 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
705 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
707 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
709 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
710 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
714 // Set up timer based loop for animation...
715 timer
= new QTimer(this);
716 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
718 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
719 // This is because it's discarding the 0.6666... on the end of the fraction.
720 // Alas, 6 doesn't divide cleanly into 10. :-P
721 //Should we defer this until SyncUI? Probably.
722 //No, it doesn't work, because it uses setInterval() instead of start()...
723 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
725 // We set this initially, to make VJ behave somewhat as it would if no
726 // cart were inserted and the BIOS was set as active...
727 jaguarCartInserted
= true;
728 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
729 WriteLog("VJ: Initializing jaguar subsystem...\n");
732 #ifndef NEWMODELSBIOSHANDLER
733 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
734 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
736 SelectBIOS(vjs
.biosType
);
739 // Prevent the file scanner from running if filename passed
740 // in on the command line...
744 // Load up the default ROM if in Alpine mode:
745 if (vjs
.hardwareTypeAlpine
)
747 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
749 // If regular load failed, try just a straight file load
750 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
752 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
755 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
757 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
759 // Attempt to load/run the ABS file...
760 LoadSoftware(vjs
.absROMPath
);
761 #ifndef NEWMODELSBIOSHANDLER
762 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
764 SelectBIOS(vjs
.biosType
);
766 // Prevent the scanner from running...
770 // Load up the default ROM if in Debugger mode:
771 if (vjs
.softTypeDebugger
)
773 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
775 // If regular load failed, try just a straight file load
776 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
778 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
781 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
783 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
785 // Attempt to load/run the ABS file...
786 LoadSoftware(vjs
.absROMPath
);
787 #ifndef NEWMODELSBIOSHANDLER
788 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
789 // Prevent the scanner from running...
791 SelectBIOS(vjs
.biosType
);
796 // Run the scanner if nothing passed in and *not* Alpine mode...
797 // NB: Really need to look into caching the info scanned in here...
798 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
799 scannedSoftwareFolder
= true;
803 void MainWin::LoadFile(QString file
)
809 void MainWin::SyncUI(void)
811 // Set toolbar buttons/menus based on settings read in (sync the UI)...
812 // (Really, this is to sync command line options passed in)
813 blurAct
->setChecked(vjs
.glFilter
);
814 x1Act
->setChecked(zoomLevel
== 1);
815 x2Act
->setChecked(zoomLevel
== 2);
816 x3Act
->setChecked(zoomLevel
== 3);
817 // running = powerAct->isChecked();
818 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
819 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
820 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
822 fullScreenAct
->setChecked(vjs
.fullscreen
);
823 fullScreen
= vjs
.fullscreen
;
824 SetFullScreen(fullScreen
);
826 // Reset the timer to be what was set in the command line (if any):
827 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
828 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
832 void MainWin::closeEvent(QCloseEvent
* event
)
835 // This should only be done by the config dialog
838 event
->accept(); // ignore() if can't close for some reason
842 void MainWin::keyPressEvent(QKeyEvent
* e
)
844 #ifndef VJ_REMOVE_DEV_CODE
846 //extern bool startM68KTracing; // moved to jaguar.h
848 extern int blit_start_log
;
850 extern bool startConciseBlitLogging
;
853 // We ignore the Alt key for now, since it causes problems with the GUI
854 if (e
->key() == Qt::Key_Alt
)
859 // Bar this shite from release versions kthxbai
860 #ifndef VJ_REMOVE_DEV_CODE
861 else if (e
->key() == Qt::Key_F11
)
863 startM68KTracing
= true;
867 else if (e
->key() == Qt::Key_F12
)
869 blit_start_log
= true;
873 else if (e
->key() == Qt::Key_F10
)
875 startConciseBlitLogging
= true;
880 else if (e
->key() == Qt::Key_F8
)
882 // ggn: For extra NYAN pleasure...
883 // ggn: There you go James :P
884 // Shamus: Thanks for the patch! :-D
885 WriteLog(" o + + +\n");
886 WriteLog("+ o o + o\n");
887 WriteLog("-_-_-_-_-_-_-_,------, o \n");
888 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
889 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
890 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
891 WriteLog("+ o o + o\n");
898 This is done now by a QAction...
899 if (e->key() == Qt::Key_F9)
909 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
911 // We ignore the Alt key for now, since it causes problems with the GUI
912 if (e
->key() == Qt::Key_Alt
)
918 HandleKeys(e
, false);
922 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
924 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
925 // We kill bad key combos here, before they can get to the emulator...
926 // This also kills the illegal instruction problem that cropped up in
929 // First, settle key states...
930 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
931 keyHeld
[P1LEFT
] = state
;
932 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
933 keyHeld
[P1RIGHT
] = state
;
934 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
935 keyHeld
[P1UP
] = state
;
936 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
937 keyHeld
[P1DOWN
] = state
;
938 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
939 keyHeld
[P2LEFT
] = state
;
940 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
941 keyHeld
[P2RIGHT
] = state
;
942 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
943 keyHeld
[P2UP
] = state
;
944 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
945 keyHeld
[P2DOWN
] = state
;
947 // Next, check for conflicts and kill 'em if there are any...
948 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
949 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
951 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
952 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
954 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
955 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
957 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
958 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
960 // No bad combos exist now, let's stuff the emulator key buffers...!
961 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
963 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
964 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
966 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
967 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
973 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
975 void MainWin::HandleGamepads(void)
979 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
981 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
982 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
984 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
985 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
990 void MainWin::Open(void)
995 void MainWin::Configure(void)
997 // Call the configuration dialog and update settings
998 ConfigDialog
dlg(this);
1000 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1001 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1002 dlg
.controllerTab1
->SetupLastUsedProfile();
1003 // maybe instead of this, we tell the controller tab to work on a copy that gets
1004 // written if the user hits 'OK'.
1005 SaveProfiles(); // Just in case user cancels
1007 if (dlg
.exec() == false)
1013 QString before
= vjs
.ROMPath
;
1014 QString alpineBefore
= vjs
.alpineROMPath
;
1015 QString absBefore
= vjs
.absROMPath
;
1016 // bool audioBefore = vjs.audioEnabled;
1017 bool audioBefore
= vjs
.DSPEnabled
;
1018 dlg
.UpdateVJSettings();
1019 QString after
= vjs
.ROMPath
;
1020 QString alpineAfter
= vjs
.alpineROMPath
;
1021 QString absAfter
= vjs
.absROMPath
;
1022 // bool audioAfter = vjs.audioEnabled;
1023 bool audioAfter
= vjs
.DSPEnabled
;
1025 bool allowOld
= allowUnknownSoftware
;
1027 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1028 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1029 AutoConnectProfiles();
1031 // We rescan the "software" folder if the user either changed the path or
1032 // checked/unchecked the "Allow unknown files" option in the config dialog.
1033 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1034 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1036 // If the "Alpine" ROM is changed, then let's load it...
1037 if (alpineBefore
!= alpineAfter
)
1039 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1041 // Oh crap, we couldn't get the file! Alert the media!
1043 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1044 msg
.setIcon(QMessageBox::Warning
);
1049 // If the "ABS" ROM is changed, then let's load it...
1050 if (absBefore
!= absAfter
)
1052 if (!JaguarLoadFile(vjs
.absROMPath
))
1054 // Oh crap, we couldn't get the file! Alert the media!
1056 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1057 msg
.setIcon(QMessageBox::Warning
);
1062 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1063 // since it's running in the host audio IRQ...
1064 if (audioBefore
!= audioAfter
)
1070 // Just in case we crash before a clean exit...
1073 DebuggerRefreshWindows();
1078 // Here's the main emulator loop
1080 void MainWin::Timer(void)
1083 static uint32_t ntscTickCount
;
1084 if (vjs
.hardwareTypeNTSC
)
1088 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1095 if (showUntunedTankCircuit
)
1097 // Some machines can't handle this, so we give them the option to disable it. :-)
1098 if (!plzDontKillMyComputer
)
1100 // if (!vjs.softTypeDebugger)
1102 // Random hash & trash
1103 // We try to simulate an untuned tank circuit here... :-)
1104 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1106 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1108 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1116 // Otherwise, run the Jaguar simulation
1119 //if (!vjs.softTypeDebugger)
1120 videoWidget
->HandleMouseHiding();
1122 static uint32_t refresh
= 0;
1123 // Do autorefresh on debug windows
1124 // Have to be careful, too much causes the emulator to slow way down!
1125 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1127 if (refresh
== vjs
.refresh
)
1129 AlpineRefreshWindows();
1130 //memBrowseWin->RefreshContents();
1131 //cpuBrowseWin->RefreshContents();
1139 //if (!vjs.softTypeDebugger)
1140 videoWidget
->updateGL();
1143 // Approach: We use a ring buffer to store times (in ms) over a given
1144 // amount of frames, then sum them to figure out the FPS.
1145 uint32_t timestamp
= SDL_GetTicks();
1146 // This assumes the ring buffer size is a power of 2
1147 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1148 // Doing it this way is better. Ring buffer size can be arbitrary then.
1149 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1150 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1151 uint32_t elapsedTime
= 0;
1153 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1154 elapsedTime
+= ringBuffer
[i
];
1156 // elapsedTime must be non-zero
1157 if (elapsedTime
== 0)
1160 // This is in frames per 10 seconds, so we can have 1 decimal
1161 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1162 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1163 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1164 // If this is updated too frequently to be useful, we can throttle it down
1165 // so that it only updates every 10th frame or so
1166 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1167 oldTimestamp
= timestamp
;
1169 if (M68KDebugHaltStatus())
1174 // Toggle the power state, it can be either on or off
1175 void MainWin::TogglePowerState(void)
1177 powerButtonOn
= !powerButtonOn
;
1180 // With the power off, we simulate white noise on the screen. :-)
1183 // Restore the mouse pointer, if hidden:
1184 //if (!vjs.softTypeDebugger)
1186 videoWidget
->CheckAndRestoreMouseCursor();
1189 useCDAct
->setDisabled(false);
1190 palAct
->setDisabled(false);
1191 ntscAct
->setDisabled(false);
1192 pauseAct
->setChecked(false);
1193 pauseAct
->setDisabled(true);
1194 showUntunedTankCircuit
= true;
1196 DACPauseAudioThread();
1197 // 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. :-)
1200 if (plzDontKillMyComputer
)
1202 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1203 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1205 if (vjs
.hardwareTypeNTSC
)
1207 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1211 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1218 useCDAct
->setDisabled(true);
1219 palAct
->setDisabled(true);
1220 ntscAct
->setDisabled(true);
1221 pauseAct
->setChecked(false);
1222 pauseAct
->setDisabled(false);
1223 showUntunedTankCircuit
= false;
1225 // Otherwise, we prepare for running regular software...
1228 // Should check for cartridgeLoaded here as well...!
1229 // We can clear it when toggling CDActive on, so that when we power cycle it
1230 // does the expected thing. Otherwise, if we use the file picker to insert a
1231 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1232 // works if the CD unit is active?
1233 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1236 WriteLog("GUI: Resetting Jaguar...\n");
1239 DebuggerResetWindows();
1240 DACPauseAudioThread(false);
1245 // Toggle the emulator state, it can be either on or off
1246 void MainWin::ToggleRunState(void)
1248 startM68KTracing
= running
;
1254 // Set action buttons for the pause mode
1255 frameAdvanceAct
->setDisabled(false);
1256 pauseAct
->setChecked(true);
1257 pauseAct
->setDisabled(false);
1258 if (vjs
.softTypeDebugger
)
1260 traceStepIntoAct
->setDisabled(false);
1261 traceStepOverAct
->setDisabled(false);
1262 restartAct
->setDisabled(false);
1263 m68kDasmWin
->Use68KPCAddress();
1264 GPUDasmWin
->UseGPUPCAddress();
1265 DSPDasmWin
->UseDSPPCAddress();
1268 //if (!vjs.softTypeDebugger)
1270 // Restore the mouse pointer, if hidden:
1271 videoWidget
->CheckAndRestoreMouseCursor();
1273 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1275 uint32_t pixel
= videoWidget
->buffer
[i
];
1276 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1277 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1278 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1281 videoWidget
->updateGL();
1283 cpuBrowseWin
->HoldBPM();
1284 cpuBrowseWin
->HandleBPMContinue();
1285 DebuggerRefreshWindows();
1290 frameAdvanceAct
->setDisabled(true);
1291 pauseAct
->setChecked(false);
1292 pauseAct
->setDisabled(false);
1293 if (vjs
.softTypeDebugger
)
1295 traceStepIntoAct
->setDisabled(true);
1296 traceStepOverAct
->setDisabled(true);
1297 restartAct
->setDisabled(true);
1298 BreakpointsWin
->RefreshContents();
1301 cpuBrowseWin
->UnholdBPM();
1304 // Pause/unpause any running/non-running threads...
1305 DACPauseAudioThread(!running
);
1309 void MainWin::SetZoom100(void)
1316 void MainWin::SetZoom200(void)
1323 void MainWin::SetZoom300(void)
1330 void MainWin::SetNTSC(void)
1332 powerAct
->setIcon(powerRed
);
1333 timer
->setInterval(16);
1334 vjs
.hardwareTypeNTSC
= true;
1340 void MainWin::SetPAL(void)
1342 powerAct
->setIcon(powerGreen
);
1343 timer
->setInterval(20);
1344 vjs
.hardwareTypeNTSC
= false;
1350 void MainWin::ToggleBlur(void)
1352 vjs
.glFilter
= !vjs
.glFilter
;
1357 void MainWin::ShowAboutWin(void)
1363 void MainWin::ShowHelpWin(void)
1369 void MainWin::InsertCart(void)
1371 // Check to see if we did autorun, 'cause we didn't load anything in that
1373 if (!scannedSoftwareFolder
)
1375 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1376 scannedSoftwareFolder
= true;
1379 // If the emulator is running, we pause it here and unpause it later
1380 // if we dismiss the file selector without choosing anything
1381 if (running
&& powerButtonOn
)
1384 pauseForFileSelector
= true;
1387 filePickWin
->show();
1391 void MainWin::Unpause(void)
1393 // Here we unpause the emulator if it was paused when we went into the file selector
1394 if (pauseForFileSelector
)
1396 pauseForFileSelector
= false;
1398 // Some nutter might have unpaused while in the file selector, so check for that
1405 // Jaguar initialisation and load software file
1406 void MainWin::LoadSoftware(QString file
)
1408 running
= false; // Prevent bad things(TM) from happening...
1409 pauseForFileSelector
= false; // Reset the file selector pause flag
1411 // Setup BIOS in his own dedicated Jaguar memory
1412 #ifndef NEWMODELSBIOSHANDLER
1413 uint8_t * biosPointer
= jaguarBootROM
;
1415 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1417 biosPointer
= jaguarDevBootROM2
;
1420 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1422 SelectBIOS(vjs
.biosType
);
1425 // Turn 'on' the power to initialize the Jaguar
1426 powerAct
->setDisabled(false);
1427 powerAct
->setChecked(true);
1428 powerButtonOn
= false;
1431 // We have to load our software *after* the Jaguar RESET
1432 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1433 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1435 // This is icky because we've already done it
1436 // it gets worse :-P
1437 if (!vjs
.useJaguarBIOS
)
1439 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1444 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1445 if (vjs
.softTypeDebugger
)
1447 m68k_set_reg(M68K_REG_A6
, 0);
1448 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1449 //pauseAct->setDisabled(false);
1450 //pauseAct->setChecked(true);
1456 // Prevent the launch in case of software without a start address and without BIOS presence
1457 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1463 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1465 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1466 setWindowTitle(newTitle
);
1471 void MainWin::ToggleCDUsage(void)
1473 CDActive
= !CDActive
;
1475 // Set up the Jaguar CD for execution, otherwise, clear memory
1477 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1479 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1483 // Open, or display, the breakpoints list window
1484 void MainWin::ShowBreakpointsWin(void)
1486 BreakpointsWin
->show();
1487 BreakpointsWin
->RefreshContents();
1491 // Delete all breakpoints
1492 void MainWin::DeleteAllBreakpoints(void)
1494 cpuBrowseWin
->ResetBPM();
1496 ShowBreakpointsWin();
1500 // Disable all breakpoints
1501 void MainWin::DisableAllBreakpoints(void)
1503 cpuBrowseWin
->DisableBPM();
1505 ShowBreakpointsWin();
1509 // Open, or display, the new breakpoint function window
1510 void MainWin::ShowNewFunctionBreakpointWin(void)
1512 NewFunctionBreakpointWin
->show();
1513 ShowBreakpointsWin();
1518 void MainWin::ShowCartFilesListWin(void)
1520 CartFilesListWin
->show();
1521 CartFilesListWin
->RefreshContents();
1526 void MainWin::DebuggerTraceStepInto(void)
1529 videoWidget
->updateGL();
1530 DebuggerRefreshWindows();
1532 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1534 #warning "!!! Need to verify the Step Into function !!!"
1539 // Restart the Jaguar executable
1540 void MainWin::DebuggerRestart(void)
1545 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1546 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1548 m68k_set_reg(M68K_REG_A6
, 0);
1549 m68k_brk_hitcounts_reset();
1551 DebuggerResetWindows();
1552 DebuggerRefreshWindows();
1554 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1556 #warning "!!! Need to verify the Restart function !!!"
1562 void MainWin::DebuggerTraceStepOver(void)
1565 videoWidget
->updateGL();
1566 DebuggerRefreshWindows();
1568 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1570 #warning "!!! Need to verify the Step Over function !!!"
1575 // Advance / Execute for one frame
1576 void MainWin::FrameAdvance(void)
1578 //printf("Frame Advance...\n");
1580 // Execute 1 frame, then exit (only useful in Pause mode)
1582 //if (!vjs.softTypeDebugger)
1583 videoWidget
->updateGL();
1585 // Need to execute 1 frames' worth of DSP thread as well :-/
1587 //m68kDasmWin->Use68KPCAddress();
1590 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1592 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1597 void MainWin::SetFullScreen(bool state
/*= true*/)
1599 if (!vjs
.softTypeDebugger
)
1603 mainWinPosition
= pos();
1605 statusBar()->hide();
1611 // This is needed because the fullscreen may happen on a different
1612 // screen than screen 0:
1613 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1614 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1615 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1616 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1617 double aspectRatio
= targetWidth
/ targetHeight
;
1618 // NOTE: Really should check here to see which dimension constrains the
1619 // other. Right now, we assume that height is the constraint.
1620 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1621 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1622 videoWidget
->fullscreen
= true;
1623 videoWidget
->outputWidth
= newWidth
;
1624 videoWidget
->setFixedSize(r
.width(), r
.height());
1629 // Seems Qt is fussy about this: showNormal() has to go first, or it
1630 // will keep the window stuck in a psuedo-fullscreen mode with no way
1631 // to get out of it (except closing the app).
1634 // Reset the video widget to windowed mode
1635 videoWidget
->offset
= 0;
1636 videoWidget
->fullscreen
= false;
1638 statusBar()->show();
1645 move(mainWinPosition
);
1651 void MainWin::ToggleFullScreen(void)
1653 fullScreen
= !fullScreen
;
1654 SetFullScreen(fullScreen
);
1659 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1661 exceptionvectortableBrowseWin
->show();
1662 exceptionvectortableBrowseWin
->RefreshContents();
1667 void MainWin::ShowLocalBrowserWin(void)
1669 LocalBrowseWin
->show();
1670 LocalBrowseWin
->RefreshContents();
1675 void MainWin::ShowCallStackBrowserWin(void)
1677 CallStackBrowseWin
->show();
1678 CallStackBrowseWin
->RefreshContents();
1682 void MainWin::ShowAllWatchBrowserWin(void)
1684 allWatchBrowseWin
->show();
1685 allWatchBrowseWin
->RefreshContents();
1689 void MainWin::ShowHeapAllocatorBrowserWin(void)
1691 heapallocatorBrowseWin
->show();
1692 heapallocatorBrowseWin
->RefreshContents();
1696 void MainWin::ShowMemoryBrowserWin(void)
1698 memBrowseWin
->show();
1699 memBrowseWin
->RefreshContents();
1703 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1705 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1707 mem1BrowseWin
[NumWin
]->show();
1708 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1713 void MainWin::ShowEmuStatusWin(void)
1715 emuStatusWin
->show();
1716 emuStatusWin
->RefreshContents();
1720 void MainWin::ShowStackBrowserWin(void)
1722 stackBrowseWin
->show();
1723 stackBrowseWin
->RefreshContents();
1727 void MainWin::ShowCPUBrowserWin(void)
1729 cpuBrowseWin
->show();
1730 cpuBrowseWin
->RefreshContents();
1734 void MainWin::ShowOPBrowserWin(void)
1736 opBrowseWin
->show();
1737 opBrowseWin
->RefreshContents();
1741 void MainWin::ShowM68KDasmBrowserWin(void)
1743 m68kDasmBrowseWin
->show();
1744 m68kDasmBrowseWin
->RefreshContents();
1748 void MainWin::ShowRISCDasmBrowserWin(void)
1750 riscDasmBrowseWin
->show();
1751 riscDasmBrowseWin
->RefreshContents();
1757 void MainWin::ShowDasmWin(void)
1760 // DasmWin->RefreshContents();
1767 void MainWin::ShowVideoOutputWin(void)
1769 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1770 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1771 //VideoOutputWindowCentrale->show();
1772 //memBrowseWin->show();
1773 //VideoOutputWin->show();
1774 //VideoOutputWin->RefreshContents(videoWidget);
1779 // Resize video window based on zoom factor
1780 // It doesn't apply in debugger mode as we use this window to display disassembly
1781 void MainWin::ResizeMainWindow(void)
1783 if (!vjs
.softTypeDebugger
)
1785 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1787 // Show the test pattern if user requested plzDontKillMyComputer mode
1788 if (!powerButtonOn
&& plzDontKillMyComputer
)
1790 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1792 if (vjs
.hardwareTypeNTSC
)
1794 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1798 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1809 void MainWin::ReadSettings(void)
1813 QSettings
settings("Underground Software", "Virtual Jaguar");
1815 //zoomLevel = settings.value("zoom", 2).toInt();
1816 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1817 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1819 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1820 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1821 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1822 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1823 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1824 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1825 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1826 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1827 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1828 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1829 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1830 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1831 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1832 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1833 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1834 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1835 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1836 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1837 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1838 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1839 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1841 // Read settings from the Debugger mode
1842 settings
.beginGroup("debugger");
1843 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1844 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1845 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1846 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1847 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1848 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1849 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1850 settings
.endGroup();
1852 // Read settings from the Alpine mode
1853 settings
.beginGroup("alpine");
1854 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1855 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1856 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1857 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1858 settings
.endGroup();
1860 // Read settings from the Keybindings
1861 settings
.beginGroup("keybindings");
1862 for (i
= 0; i
< KB_END
; i
++)
1864 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1866 settings
.endGroup();
1868 // Write important settings to the log file
1869 WriteLog("MainWin: Paths\n");
1870 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1871 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1872 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1873 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1874 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1875 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1876 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1877 WriteLog("MainWin: Misc.\n");
1878 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1881 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1882 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1883 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1884 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1885 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1886 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1887 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1888 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1889 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1890 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1891 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1892 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1893 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1894 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1895 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1896 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1897 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1898 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1899 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1900 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1901 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1902 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1904 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1905 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1906 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1907 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1908 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1909 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1910 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1911 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1912 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1913 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1914 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1915 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1916 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1917 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1918 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1919 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1920 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1921 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1922 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1923 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1924 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1927 WriteLog("Read setting = Done\n");
1929 ReadProfiles(&settings
);
1930 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
1935 // Default values will be used in case of no settings can be found
1937 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1939 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1941 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1942 void MainWin::ReadUISettings(void)
1949 // Point on the emulator settings
1950 QSettings
settings("Underground Software", "Virtual Jaguar");
1951 settings
.beginGroup("ui");
1953 // Emulator main window UI information
1954 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1955 size
= settings
.value("size", QSize(400, 400)).toSize();
1957 move(mainWinPosition
);
1958 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1959 filePickWin
->move(pos
);
1961 // Video output information
1962 zoomLevel
= settings
.value("zoom", 2).toInt();
1964 // Alpine debug UI information (also needed by the Debugger)
1965 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1967 // CPU registers UI information
1968 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1969 cpuBrowseWin
->move(pos
);
1970 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1972 // Memory browser UI information
1973 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1974 memBrowseWin
->move(pos
);
1975 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1977 // Stack browser UI information
1978 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1979 stackBrowseWin
->move(pos
);
1980 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1981 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1982 stackBrowseWin
->resize(size
);
1984 // Emulator status UI information
1985 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1986 emuStatusWin
->move(pos
);
1987 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1989 // OP (Object Processor) UI information
1990 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1991 opBrowseWin
->move(pos
);
1992 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1993 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1994 opBrowseWin
->resize(size
);
1996 // RISC disassembly UI information
1997 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1998 riscDasmBrowseWin
->move(pos
);
1999 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2001 // M68k disassembly UI information
2002 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2003 m68kDasmBrowseWin
->move(pos
);
2004 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2006 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2008 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2012 // Debugger UI information
2013 if (vjs
.softTypeDebugger
)
2016 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2017 m68kDasmWin
->move(pos
);
2018 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2019 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2020 GPUDasmWin
->move(pos
);
2021 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2022 DSPDasmWin
->move(pos
);
2024 // All watch browser UI information
2025 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2026 allWatchBrowseWin
->move(pos
);
2027 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2028 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2029 allWatchBrowseWin
->resize(size
);
2031 // Local browser UI information
2032 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2033 LocalBrowseWin
->move(pos
);
2034 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2035 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2036 LocalBrowseWin
->resize(size
);
2038 // Heap memory allocation browser UI information
2039 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2040 heapallocatorBrowseWin
->move(pos
);
2041 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2042 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2043 heapallocatorBrowseWin
->resize(size
);
2045 // Exception Vector Table UI Information
2046 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2047 exceptionvectortableBrowseWin
->move(pos
);
2048 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2049 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2050 exceptionvectortableBrowseWin
->resize(size
);
2052 // Call Stack browser UI information
2053 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2054 CallStackBrowseWin
->move(pos
);
2055 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2056 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2057 CallStackBrowseWin
->resize(size
);
2059 // Cartdridge directory and files
2060 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2061 CartFilesListWin
->move(pos
);
2062 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2063 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2064 CartFilesListWin
->resize(size
);
2066 // Breakpoints UI information
2067 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2068 BreakpointsWin
->move(pos
);
2069 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2070 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2071 BreakpointsWin
->resize(size
);
2072 // New function breakpoint UI information
2073 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2074 NewFunctionBreakpointWin
->move(pos
);
2075 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2076 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2077 NewFunctionBreakpointWin
->resize(size
);
2079 // Memories browser UI information
2080 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2082 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2083 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2084 mem1BrowseWin
[i
]->move(pos
);
2085 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2086 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2087 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2088 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2089 mem1BrowseWin
[i
]->resize(size
);
2093 settings
.endGroup();
2095 WriteLog("Read UI setting = Done\n");
2099 // Save the settings
2100 void MainWin::WriteSettings(void)
2104 // Point on the emulator settings
2105 QSettings
settings("Underground Software", "Virtual Jaguar");
2106 //settings.setValue("pos", pos());
2107 //settings.setValue("size", size());
2108 //settings.setValue("cartLoadPos", filePickWin->pos());
2110 //settings.setValue("zoom", zoomLevel);
2111 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2112 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2114 settings
.setValue("useJoystick", vjs
.useJoystick
);
2115 settings
.setValue("joyport", vjs
.joyport
);
2116 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2117 settings
.setValue("frameSkip", vjs
.frameSkip
);
2118 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2119 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2120 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2121 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2122 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2123 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2124 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2125 settings
.setValue("fullscreen", vjs
.fullscreen
);
2126 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2127 settings
.setValue("glFilterType", vjs
.glFilter
);
2128 settings
.setValue("renderType", vjs
.renderType
);
2129 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2130 settings
.setValue("biosType", vjs
.biosType
);
2131 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2132 //settings.setValue("JagBootROM", vjs.jagBootPath);
2133 //settings.setValue("CDBootROM", vjs.CDBootPath);
2134 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2135 settings
.setValue("ROMs", vjs
.ROMPath
);
2136 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2138 // Write settings from the Alpine mode
2139 settings
.beginGroup("alpine");
2140 settings
.setValue("refresh", vjs
.refresh
);
2141 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2142 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2143 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2144 settings
.endGroup();
2146 // Write settings from the Debugger mode
2147 settings
.beginGroup("debugger");
2148 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2149 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2150 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2151 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2152 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2153 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2154 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2155 settings
.endGroup();
2157 // Write settings from the Keybindings
2158 settings
.beginGroup("keybindings");
2159 for (i
= 0; i
< KB_END
; i
++)
2161 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2163 settings
.endGroup();
2166 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2167 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2168 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2169 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2170 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2171 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2172 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2173 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2174 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2175 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2176 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2177 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2178 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2179 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2180 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2181 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2182 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2183 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2184 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2185 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2186 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2188 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2189 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2190 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2191 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2192 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2193 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2194 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2195 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2196 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2197 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2198 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2199 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2200 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2201 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2202 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2203 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2204 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2205 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2206 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2207 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2208 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2211 WriteProfiles(&settings
);
2212 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2216 // Save the UI settings
2217 void MainWin::WriteUISettings(void)
2222 // Point on the emulator settings
2223 QSettings
settings("Underground Software", "Virtual Jaguar");
2224 settings
.beginGroup("ui");
2226 // Emulator UI information
2227 settings
.setValue("pos", pos());
2228 settings
.setValue("size", size());
2229 settings
.setValue("cartLoadPos", filePickWin
->pos());
2231 // Video output information
2232 settings
.setValue("zoom", zoomLevel
);
2234 // Alpine debug UI information (also needed by the Debugger)
2235 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2237 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2238 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2239 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2240 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2241 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2242 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2243 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2244 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2245 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2246 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2247 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2248 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2249 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2250 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2251 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2252 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2255 // Debugger UI information
2256 if (vjs
.softTypeDebugger
)
2259 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2260 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2261 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2262 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2264 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2265 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2266 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2267 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2268 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2269 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2270 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2271 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2272 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2273 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2274 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2275 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2276 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2277 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2278 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2279 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2280 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2281 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2282 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2283 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2284 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2285 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2286 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2287 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2289 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2291 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2292 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2293 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2294 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2295 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2296 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2300 settings
.endGroup();
2304 // Refresh alpine debug windows
2305 void MainWin::AlpineRefreshWindows(void)
2307 cpuBrowseWin
->RefreshContents();
2308 memBrowseWin
->RefreshContents();
2309 stackBrowseWin
->RefreshContents();
2310 emuStatusWin
->RefreshContents();
2311 opBrowseWin
->RefreshContents();
2312 riscDasmBrowseWin
->RefreshContents();
2313 m68kDasmBrowseWin
->RefreshContents();
2317 // Reset soft debugger
2318 void MainWin::DebuggerReset(void)
2320 if (vjs
.softTypeDebugger
)
2322 DeleteAllBreakpoints();
2327 // Reset soft debugger windows
2328 void MainWin::DebuggerResetWindows(void)
2330 if (vjs
.softTypeDebugger
)
2332 FilesrcListWin
->Reset();
2333 allWatchBrowseWin
->Reset();
2334 heapallocatorBrowseWin
->Reset();
2335 BreakpointsWin
->Reset();
2336 CartFilesListWin
->Reset();
2337 //ResetAlpineWindows();
2342 // Refresh view windows
2343 void MainWin::ViewRefreshWindows(void)
2345 CartFilesListWin
->RefreshContents();
2349 // Refresh soft debugger & alpine debug windows
2350 void MainWin::DebuggerRefreshWindows(void)
2352 if (vjs
.softTypeDebugger
)
2354 FilesrcListWin
->RefreshContents();
2355 m68kDasmWin
->RefreshContents();
2356 GPUDasmWin
->RefreshContents();
2357 DSPDasmWin
->RefreshContents();
2358 allWatchBrowseWin
->RefreshContents();
2359 LocalBrowseWin
->RefreshContents();
2360 CallStackBrowseWin
->RefreshContents();
2361 heapallocatorBrowseWin
->RefreshContents();
2362 BreakpointsWin
->RefreshContents();
2363 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2365 mem1BrowseWin
[i
]->RefreshContents(i
);
2368 AlpineRefreshWindows();
2369 ViewRefreshWindows();
2374 // Create and save screenshot
2375 void MainWin::MakeScreenshot(void)
2379 time_t now
= time(0);
2383 tstruct
= *localtime(&now
);
2384 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
);
2386 // Create screenshot
2387 screenshot
= videoWidget
->grabFrameBuffer();
2388 screenshot
.save((char *)Text
, "JPG", 100);