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
28 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
29 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
30 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
31 // with 'R', etc) [DONE]
32 // - Controller configuration [DONE]
36 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
37 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
38 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
41 // SFDX CODE: S1E9T8H5M23YS
43 // Uncomment this for debugging...
45 //#define DEBUGFOO // Various tool debugging... but not used
46 //#define DEBUGTP // Toolpalette debugging... but not used
53 #include "configdialog.h"
54 #include "controllertab.h"
55 #include "keybindingstab.h"
56 #include "filepicker.h"
58 #include "generaltab.h"
64 #include "emustatus.h"
65 #include "debug/cpubrowser.h"
66 #include "debug/m68kdasmbrowser.h"
67 #include "debug/memorybrowser.h"
68 #include "debug/stackbrowser.h"
69 #include "debug/opbrowser.h"
70 #include "debug/riscdasmbrowser.h"
76 #ifndef NEWMODELSBIOSHANDLER
79 #include "jagstub2bios.h"
81 #include "modelsBIOS.h"
83 #include "jagcdbios.h"
85 #include "m68000/m68kinterface.h"
87 #include "debugger/DBGManager.h"
88 //#include "debugger/VideoWin.h"
89 //#include "debugger/DasmWin.h"
90 #include "debugger/m68KDasmWin.h"
91 #include "debugger/GPUDasmWin.h"
92 #include "debugger/DSPDasmWin.h"
93 #include "debugger/memory1browser.h"
94 #include "debugger/BreakpointsWin.h"
95 #include "debugger/NewFnctBreakpointWin.h"
96 #include "debugger/FilesrcListWin.h"
97 #include "debugger/exceptionvectortablebrowser.h"
98 #include "debugger/allwatchbrowser.h"
99 #include "debugger/localbrowser.h"
100 #include "debugger/heapallocatorbrowser.h"
101 #include "debugger/callstackbrowser.h"
102 #include "debugger/CartFilesListWin.h"
105 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
106 //#ifdef __GCCWIN32__
107 // Apparently on win32, usleep() is not pulled in by the usual suspects.
111 #include "_MSC_VER/unistd.h"
115 // The way BSNES controls things is by setting a timer with a zero
116 // timeout, sleeping if not emulating anything. Seems there has to be a
119 // It has a novel approach to plugging-in/using different video/audio/input
120 // methods, can we do something similar or should we just use the built-in
123 // We're going to try to use the built-in OpenGL support and see how it goes.
124 // We'll make the VJ core modular so that it doesn't matter what GUI is in
125 // use, we can drop it in anywhere and use it as-is.
127 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
128 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
129 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
135 for(int i
=0; i
<8; i
++)
139 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
142 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
145 //if (vjs.softTypeDebugger)
147 // mainWindowCentrale = new QMdiArea;
148 // setCentralWidget(mainWindowCentrale);
151 WriteLog("Window creation start\n");
154 videoWidget
= new GLWidget(this);
155 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
157 // set central output window
158 if (!vjs
.softTypeDebugger
)
160 setCentralWidget(videoWidget
);
164 mainWindowCentrale
= new QMdiArea(this);
165 setCentralWidget(mainWindowCentrale
);
168 setWindowIcon(QIcon(":/res/vj-icon.png"));
170 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
172 if (vjs
.hardwareTypeAlpine
)
173 title
+= QString(tr(" - Alpine Mode"));
175 if (vjs
.softTypeDebugger
)
176 title
+= QString(tr(" - Debugger Mode"));
178 setWindowTitle(title
);
180 aboutWin
= new AboutWindow(this);
181 helpWin
= new HelpWindow(this);
182 filePickWin
= new FilePickerWindow(this);
183 memBrowseWin
= new MemoryBrowserWindow(this);
184 stackBrowseWin
= new StackBrowserWindow(this);
185 emuStatusWin
= new EmuStatusWindow(this);
186 cpuBrowseWin
= new CPUBrowserWindow(this);
187 opBrowseWin
= new OPBrowserWindow(this);
188 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
189 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
190 if (vjs
.softTypeDebugger
)
192 //VideoOutputWin = new VideoOutputWindow(this);
193 //VideoOutputWin->setCentralWidget()
194 //DasmWin = new DasmWindow();
195 //DasmWin = new DasmWindow(this);
196 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
197 LocalBrowseWin
= new LocalBrowserWindow(this);
198 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
199 BreakpointsWin
= new BreakpointsWindow(this);
200 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
201 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
202 CallStackBrowseWin
= new CallStackBrowserWindow(this);
203 CartFilesListWin
= new CartFilesListWindow(this);
205 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
207 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
209 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
211 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
213 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
216 // Setup dock to display source code filenames tree
217 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
218 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
220 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
221 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
222 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
224 // Setup dock to display disassembly
225 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
226 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
227 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
228 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
229 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
231 dasmtabWidget
= new QTabWidget(this);
234 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
235 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
236 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
237 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
239 setCentralWidget(dasmtabWidget
);
243 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
244 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
246 setUnifiedTitleAndToolBarOnMac(true);
249 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
250 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
251 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
252 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
253 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
256 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
257 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
258 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
259 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
260 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
261 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
262 powerAct
->setCheckable(true);
263 powerAct
->setChecked(false);
264 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
268 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
269 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
270 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
271 pauseAct
->setStatusTip(tr("Toggles the running state"));
272 pauseAct
->setCheckable(true);
273 pauseAct
->setDisabled(true);
274 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
275 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
276 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
279 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
280 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
281 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
282 screenshotAct
->setCheckable(false);
283 screenshotAct
->setDisabled(false);
284 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
287 zoomActs
= new QActionGroup(this);
288 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
289 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
290 x1Act
->setCheckable(true);
291 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
292 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
293 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
294 x2Act
->setCheckable(true);
295 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
296 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
297 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
298 x3Act
->setCheckable(true);
299 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
302 tvTypeActs
= new QActionGroup(this);
303 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
304 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
305 ntscAct
->setCheckable(true);
306 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
307 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
308 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
309 palAct
->setCheckable(true);
310 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
313 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
314 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
315 blurAct
= new QAction(blur
, tr("Blur"), this);
316 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
317 blurAct
->setCheckable(true);
318 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
321 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
322 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
323 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
326 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
327 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
328 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
330 // File pickup action
331 if (!vjs
.softTypeDebugger
)
333 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
334 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
338 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
339 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
341 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
342 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
343 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
345 // Configuration action
346 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
347 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
348 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
349 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
350 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
352 // Emulation status action
353 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
354 emustatusAct
->setStatusTip(tr("Emulator status"));
355 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
356 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
357 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
360 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
361 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
362 useCDAct
->setCheckable(true);
363 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
365 // Frame advance action
366 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
367 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
368 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
369 frameAdvanceAct
->setDisabled(true);
370 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
373 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
374 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
375 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
376 fullScreenAct
->setCheckable(true);
377 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
379 // Actions dedicated to debugger mode
380 if (vjs
.softTypeDebugger
)
383 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
384 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
385 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
386 restartAct
->setCheckable(false);
387 restartAct
->setDisabled(true);
388 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
391 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
392 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
393 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
394 traceStepOverAct
->setCheckable(false);
395 traceStepOverAct
->setDisabled(true);
396 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
398 // Trace into tracing
399 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
400 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
401 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
402 traceStepIntoAct
->setCheckable(false);
403 traceStepIntoAct
->setDisabled(true);
404 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
406 // Function breakpoint
407 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
408 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
409 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
410 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
411 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
412 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
413 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
414 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
415 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
416 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
417 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
419 //VideoOutputAct = new QAction(tr("Output Video"), this);
420 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
421 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
423 //DasmAct = new QAction(tr("Disassembly"), this);
424 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
425 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
427 // Exception vector table window
428 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
429 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
430 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
432 // All watch variables window
433 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
434 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
435 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
437 // Local variables window
438 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
439 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
440 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
442 // Heap (memory) allocation window
443 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
444 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
445 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
448 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
449 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
450 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
453 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
454 CartFilesListAct
->setStatusTip(tr("List of the files in the cartdridge's directory"));
455 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
458 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
459 QSignalMapper
*signalMapper
= new QSignalMapper(this);
461 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
463 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
465 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
468 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
469 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
470 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
471 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
472 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
473 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
477 // Memory browser window action
478 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
479 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
480 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
482 // Stack browser window action
483 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
484 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
485 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
487 // CPUs (M68000, GPU & DSP browser window action
488 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
489 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
490 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
492 // OP browser window action
493 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
494 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
495 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
497 // M68000 disassembly browser window
498 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
499 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
500 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
502 // Risc (DSP / GPU) disassembly browser window
503 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
504 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
505 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
507 // Misc. connections...
508 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
509 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
513 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
514 fileMenu
->addAction(powerAct
);
515 if (!vjs
.softTypeDebugger
)
517 fileMenu
->addAction(pauseAct
);
518 // fileMenu->addAction(frameAdvanceAct);
520 fileMenu
->addAction(filePickAct
);
521 fileMenu
->addAction(useCDAct
);
522 fileMenu
->addAction(configAct
);
523 fileMenu
->addAction(emustatusAct
);
524 fileMenu
->addSeparator();
525 fileMenu
->addAction(quitAppAct
);
527 // Alpine and debugger menus
528 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
530 // Create debug & view menu
531 debugMenu
= menuBar()->addMenu(tr("&Debug"));
532 viewMenu
= menuBar()->addMenu(tr("&View"));
534 // Create debugger menu
535 if (vjs
.softTypeDebugger
)
538 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
539 viewCartMenu
->addAction(CartFilesListAct
);
541 viewCartMenu
->addSeparator();
542 viewCartMenu
->addAction(CartStreamsAct
);
546 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
547 debugWindowsMenu
->addAction(BreakpointsAct
);
548 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
549 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
550 debugWindowsMenu
->addSeparator();
552 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
553 debugWindowOutputMenu
->addAction(VideoOutputAct
);
554 debugWindowsMenu
->addSeparator();
556 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
557 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
558 debugWindowsMenu
->addAction(LocalBrowseAct
);
559 debugWindowsMenu
->addSeparator();
560 debugWindowsMenu
->addAction(CallStackBrowseAct
);
561 debugWindowsMenu
->addSeparator();
562 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
563 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
564 debugWindowsMemoryMenu
->addSeparator();
565 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
567 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
569 debugWindowsMenu
->addSeparator();
570 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
571 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
572 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
573 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
574 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
575 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
576 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
577 debugMenu
->addSeparator();
578 debugMenu
->addAction(pauseAct
);
579 debugMenu
->addAction(frameAdvanceAct
);
580 debugMenu
->addAction(restartAct
);
581 debugMenu
->addSeparator();
582 debugMenu
->addAction(traceStepIntoAct
);
583 debugMenu
->addAction(traceStepOverAct
);
584 debugMenu
->addSeparator();
585 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
586 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
587 debugMenu
->addAction(deleteAllBreakpointsAct
);
588 debugMenu
->addAction(disableAllBreakpointsAct
);
590 debugMenu
->addSeparator();
591 debugMenu
->addAction(DasmAct
);
596 // Create alpine menu
597 debugMenu
->addAction(memBrowseAct
);
598 debugMenu
->addAction(stackBrowseAct
);
599 debugMenu
->addAction(cpuBrowseAct
);
600 debugMenu
->addAction(opBrowseAct
);
601 debugMenu
->addAction(m68kDasmBrowseAct
);
602 debugMenu
->addAction(riscDasmBrowseAct
);
607 helpMenu
= menuBar()->addMenu(tr("&Help"));
608 helpMenu
->addAction(helpAct
);
609 helpMenu
->addAction(aboutAct
);
613 toolbar
= addToolBar(tr("System"));
614 toolbar
->addAction(powerAct
);
615 if (!vjs
.softTypeDebugger
)
617 toolbar
->addAction(pauseAct
);
618 toolbar
->addAction(frameAdvanceAct
);
620 toolbar
->addAction(filePickAct
);
621 toolbar
->addAction(useCDAct
);
622 toolbar
->addSeparator();
623 if (!vjs
.softTypeDebugger
)
625 toolbar
->addAction(screenshotAct
);
626 toolbar
->addSeparator();
627 toolbar
->addAction(x1Act
);
628 toolbar
->addAction(x2Act
);
629 toolbar
->addAction(x3Act
);
630 toolbar
->addSeparator();
631 toolbar
->addAction(ntscAct
);
632 toolbar
->addAction(palAct
);
633 toolbar
->addSeparator();
634 toolbar
->addAction(blurAct
);
635 toolbar
->addAction(fullScreenAct
);
639 debuggerbar
= addToolBar(tr("&Debugger"));
640 debuggerbar
->addAction(pauseAct
);
641 debuggerbar
->addAction(frameAdvanceAct
);
642 debuggerbar
->addAction(restartAct
);
643 debuggerbar
->addSeparator();
644 debuggerbar
->addAction(traceStepIntoAct
);
645 debuggerbar
->addAction(traceStepOverAct
);
646 debuggerbar
->addSeparator();
647 debuggerbar
->addAction(BreakpointsAct
);
650 if (vjs
.hardwareTypeAlpine
)
652 debugbar
= addToolBar(tr("&Debug"));
653 debugbar
->addAction(memBrowseAct
);
654 debugbar
->addAction(stackBrowseAct
);
655 debugbar
->addAction(cpuBrowseAct
);
656 debugbar
->addAction(opBrowseAct
);
657 debugbar
->addAction(m68kDasmBrowseAct
);
658 debugbar
->addAction(riscDasmBrowseAct
);
661 // Add actions to the main window, as hiding widgets with them
663 addAction(fullScreenAct
);
664 addAction(quitAppAct
);
665 addAction(configAct
);
666 addAction(emustatusAct
);
668 addAction(filePickAct
);
669 addAction(frameAdvanceAct
);
672 statusBar()->showMessage(tr("Ready"));
674 // Do this in case original size isn't correct (mostly for the first-run case)
677 WriteLog("Window creation done\n");
679 // Create our test pattern NTSC bitmap
680 WriteLog("Test pattern 1 bitmap\n");
682 QImage
tempImg(":/res/test-pattern.jpg");
683 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
685 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
687 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
689 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
691 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
692 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
696 // Create our test pattern PAL bitmap
697 WriteLog("Test pattern 2 bitmap\n");
699 QImage
tempImg2(":/res/test-pattern-pal.jpg");
700 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
702 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
704 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
706 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
708 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
709 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
713 // Set up timer based loop for animation...
714 timer
= new QTimer(this);
715 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
717 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
718 // This is because it's discarding the 0.6666... on the end of the fraction.
719 // Alas, 6 doesn't divide cleanly into 10. :-P
720 //Should we defer this until SyncUI? Probably.
721 //No, it doesn't work, because it uses setInterval() instead of start()...
722 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
724 // We set this initially, to make VJ behave somewhat as it would if no
725 // cart were inserted and the BIOS was set as active...
726 jaguarCartInserted
= true;
727 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
728 WriteLog("VJ: Initializing jaguar subsystem...\n");
731 #ifndef NEWMODELSBIOSHANDLER
732 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
733 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
735 SelectBIOS(vjs
.biosType
);
738 // Prevent the file scanner from running if filename passed
739 // in on the command line...
743 // Load up the default ROM if in Alpine mode:
744 if (vjs
.hardwareTypeAlpine
)
746 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
748 // If regular load failed, try just a straight file load
749 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
751 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
754 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
756 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
758 // Attempt to load/run the ABS file...
759 LoadSoftware(vjs
.absROMPath
);
760 #ifndef NEWMODELSBIOSHANDLER
761 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
763 SelectBIOS(vjs
.biosType
);
765 // Prevent the scanner from running...
769 // Load up the default ROM if in Debugger mode:
770 if (vjs
.softTypeDebugger
)
772 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
774 // If regular load failed, try just a straight file load
775 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
777 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
780 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
782 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
784 // Attempt to load/run the ABS file...
785 LoadSoftware(vjs
.absROMPath
);
786 #ifndef NEWMODELSBIOSHANDLER
787 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
788 // Prevent the scanner from running...
790 SelectBIOS(vjs
.biosType
);
795 // Run the scanner if nothing passed in and *not* Alpine mode...
796 // NB: Really need to look into caching the info scanned in here...
797 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
798 scannedSoftwareFolder
= true;
802 void MainWin::LoadFile(QString file
)
808 void MainWin::SyncUI(void)
810 // Set toolbar buttons/menus based on settings read in (sync the UI)...
811 // (Really, this is to sync command line options passed in)
812 blurAct
->setChecked(vjs
.glFilter
);
813 x1Act
->setChecked(zoomLevel
== 1);
814 x2Act
->setChecked(zoomLevel
== 2);
815 x3Act
->setChecked(zoomLevel
== 3);
816 // running = powerAct->isChecked();
817 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
818 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
819 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
821 fullScreenAct
->setChecked(vjs
.fullscreen
);
822 fullScreen
= vjs
.fullscreen
;
823 SetFullScreen(fullScreen
);
825 // Reset the timer to be what was set in the command line (if any):
826 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
827 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
831 void MainWin::closeEvent(QCloseEvent
* event
)
834 // This should only be done by the config dialog
837 event
->accept(); // ignore() if can't close for some reason
841 void MainWin::keyPressEvent(QKeyEvent
* e
)
843 #ifndef VJ_REMOVE_DEV_CODE
845 //extern bool startM68KTracing; // moved to jaguar.h
847 extern int blit_start_log
;
849 extern bool startConciseBlitLogging
;
852 // We ignore the Alt key for now, since it causes problems with the GUI
853 if (e
->key() == Qt::Key_Alt
)
858 // Bar this shite from release versions kthxbai
859 #ifndef VJ_REMOVE_DEV_CODE
860 else if (e
->key() == Qt::Key_F11
)
862 startM68KTracing
= true;
866 else if (e
->key() == Qt::Key_F12
)
868 blit_start_log
= true;
872 else if (e
->key() == Qt::Key_F10
)
874 startConciseBlitLogging
= true;
879 else if (e
->key() == Qt::Key_F8
)
881 // ggn: For extra NYAN pleasure...
882 // ggn: There you go James :P
883 // Shamus: Thanks for the patch! :-D
884 WriteLog(" o + + +\n");
885 WriteLog("+ o o + o\n");
886 WriteLog("-_-_-_-_-_-_-_,------, o \n");
887 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
888 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
889 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
890 WriteLog("+ o o + o\n");
897 This is done now by a QAction...
898 if (e->key() == Qt::Key_F9)
908 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
910 // We ignore the Alt key for now, since it causes problems with the GUI
911 if (e
->key() == Qt::Key_Alt
)
917 HandleKeys(e
, false);
921 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
923 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
924 // We kill bad key combos here, before they can get to the emulator...
925 // This also kills the illegal instruction problem that cropped up in
928 // First, settle key states...
929 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
930 keyHeld
[P1LEFT
] = state
;
931 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
932 keyHeld
[P1RIGHT
] = state
;
933 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
934 keyHeld
[P1UP
] = state
;
935 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
936 keyHeld
[P1DOWN
] = state
;
937 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
938 keyHeld
[P2LEFT
] = state
;
939 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
940 keyHeld
[P2RIGHT
] = state
;
941 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
942 keyHeld
[P2UP
] = state
;
943 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
944 keyHeld
[P2DOWN
] = state
;
946 // Next, check for conflicts and kill 'em if there are any...
947 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
948 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
950 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
951 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
953 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
954 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
956 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
957 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
959 // No bad combos exist now, let's stuff the emulator key buffers...!
960 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
962 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
963 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
965 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
966 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
972 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
974 void MainWin::HandleGamepads(void)
978 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
980 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
981 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
983 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
984 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
989 void MainWin::Open(void)
994 void MainWin::Configure(void)
996 // Call the configuration dialog and update settings
997 ConfigDialog
dlg(this);
999 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1000 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1001 dlg
.controllerTab1
->SetupLastUsedProfile();
1002 // maybe instead of this, we tell the controller tab to work on a copy that gets
1003 // written if the user hits 'OK'.
1004 SaveProfiles(); // Just in case user cancels
1006 if (dlg
.exec() == false)
1012 QString before
= vjs
.ROMPath
;
1013 QString alpineBefore
= vjs
.alpineROMPath
;
1014 QString absBefore
= vjs
.absROMPath
;
1015 // bool audioBefore = vjs.audioEnabled;
1016 bool audioBefore
= vjs
.DSPEnabled
;
1017 dlg
.UpdateVJSettings();
1018 QString after
= vjs
.ROMPath
;
1019 QString alpineAfter
= vjs
.alpineROMPath
;
1020 QString absAfter
= vjs
.absROMPath
;
1021 // bool audioAfter = vjs.audioEnabled;
1022 bool audioAfter
= vjs
.DSPEnabled
;
1024 bool allowOld
= allowUnknownSoftware
;
1026 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1027 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1028 AutoConnectProfiles();
1030 // We rescan the "software" folder if the user either changed the path or
1031 // checked/unchecked the "Allow unknown files" option in the config dialog.
1032 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1033 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1035 // If the "Alpine" ROM is changed, then let's load it...
1036 if (alpineBefore
!= alpineAfter
)
1038 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1040 // Oh crap, we couldn't get the file! Alert the media!
1042 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1043 msg
.setIcon(QMessageBox::Warning
);
1048 // If the "ABS" ROM is changed, then let's load it...
1049 if (absBefore
!= absAfter
)
1051 if (!JaguarLoadFile(vjs
.absROMPath
))
1053 // Oh crap, we couldn't get the file! Alert the media!
1055 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1056 msg
.setIcon(QMessageBox::Warning
);
1061 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1062 // since it's running in the host audio IRQ...
1063 if (audioBefore
!= audioAfter
)
1069 // Just in case we crash before a clean exit...
1072 DebuggerRefreshWindows();
1077 // Here's the main emulator loop
1079 void MainWin::Timer(void)
1082 static uint32_t ntscTickCount
;
1083 if (vjs
.hardwareTypeNTSC
)
1087 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1094 if (showUntunedTankCircuit
)
1096 // Some machines can't handle this, so we give them the option to disable it. :-)
1097 if (!plzDontKillMyComputer
)
1099 // if (!vjs.softTypeDebugger)
1101 // Random hash & trash
1102 // We try to simulate an untuned tank circuit here... :-)
1103 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1105 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1107 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1115 // Otherwise, run the Jaguar simulation
1118 //if (!vjs.softTypeDebugger)
1119 videoWidget
->HandleMouseHiding();
1121 static uint32_t refresh
= 0;
1122 // Do autorefresh on debug windows
1123 // Have to be careful, too much causes the emulator to slow way down!
1124 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1126 if (refresh
== vjs
.refresh
)
1128 AlpineRefreshWindows();
1129 //memBrowseWin->RefreshContents();
1130 //cpuBrowseWin->RefreshContents();
1138 //if (!vjs.softTypeDebugger)
1139 videoWidget
->updateGL();
1142 // Approach: We use a ring buffer to store times (in ms) over a given
1143 // amount of frames, then sum them to figure out the FPS.
1144 uint32_t timestamp
= SDL_GetTicks();
1145 // This assumes the ring buffer size is a power of 2
1146 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1147 // Doing it this way is better. Ring buffer size can be arbitrary then.
1148 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1149 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1150 uint32_t elapsedTime
= 0;
1152 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1153 elapsedTime
+= ringBuffer
[i
];
1155 // elapsedTime must be non-zero
1156 if (elapsedTime
== 0)
1159 // This is in frames per 10 seconds, so we can have 1 decimal
1160 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1161 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1162 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1163 // If this is updated too frequently to be useful, we can throttle it down
1164 // so that it only updates every 10th frame or so
1165 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1166 oldTimestamp
= timestamp
;
1168 if (M68KDebugHaltStatus())
1173 // Toggle the power state, it can be either on or off
1174 void MainWin::TogglePowerState(void)
1176 powerButtonOn
= !powerButtonOn
;
1179 // With the power off, we simulate white noise on the screen. :-)
1182 // Restore the mouse pointer, if hidden:
1183 //if (!vjs.softTypeDebugger)
1185 videoWidget
->CheckAndRestoreMouseCursor();
1188 useCDAct
->setDisabled(false);
1189 palAct
->setDisabled(false);
1190 ntscAct
->setDisabled(false);
1191 pauseAct
->setChecked(false);
1192 pauseAct
->setDisabled(true);
1193 showUntunedTankCircuit
= true;
1195 DACPauseAudioThread();
1196 // 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. :-)
1199 if (plzDontKillMyComputer
)
1201 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1202 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1204 if (vjs
.hardwareTypeNTSC
)
1206 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1210 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1217 useCDAct
->setDisabled(true);
1218 palAct
->setDisabled(true);
1219 ntscAct
->setDisabled(true);
1220 pauseAct
->setChecked(false);
1221 pauseAct
->setDisabled(false);
1222 showUntunedTankCircuit
= false;
1224 // Otherwise, we prepare for running regular software...
1227 // Should check for cartridgeLoaded here as well...!
1228 // We can clear it when toggling CDActive on, so that when we power cycle it
1229 // does the expected thing. Otherwise, if we use the file picker to insert a
1230 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1231 // works if the CD unit is active?
1232 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1235 WriteLog("GUI: Resetting Jaguar...\n");
1237 DeleteAllBreakpoints();
1238 DebuggerResetWindows();
1239 DACPauseAudioThread(false);
1244 // Toggle the emulator state, it can be either on or off
1245 void MainWin::ToggleRunState(void)
1247 startM68KTracing
= running
;
1253 // Set action buttons for the pause mode
1254 frameAdvanceAct
->setDisabled(false);
1255 pauseAct
->setChecked(true);
1256 pauseAct
->setDisabled(false);
1257 if (vjs
.softTypeDebugger
)
1259 traceStepIntoAct
->setDisabled(false);
1260 traceStepOverAct
->setDisabled(false);
1261 restartAct
->setDisabled(false);
1262 m68kDasmWin
->Use68KPCAddress();
1263 GPUDasmWin
->UseGPUPCAddress();
1264 DSPDasmWin
->UseDSPPCAddress();
1267 //if (!vjs.softTypeDebugger)
1269 // Restore the mouse pointer, if hidden:
1270 videoWidget
->CheckAndRestoreMouseCursor();
1272 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1274 uint32_t pixel
= videoWidget
->buffer
[i
];
1275 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1276 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1277 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1280 videoWidget
->updateGL();
1282 cpuBrowseWin
->HoldBPM();
1283 cpuBrowseWin
->HandleBPMContinue();
1284 DebuggerRefreshWindows();
1289 frameAdvanceAct
->setDisabled(true);
1290 pauseAct
->setChecked(false);
1291 pauseAct
->setDisabled(false);
1292 if (vjs
.softTypeDebugger
)
1294 traceStepIntoAct
->setDisabled(true);
1295 traceStepOverAct
->setDisabled(true);
1296 restartAct
->setDisabled(true);
1299 cpuBrowseWin
->UnholdBPM();
1300 BreakpointsWin
->RefreshContents();
1303 // Pause/unpause any running/non-running threads...
1304 DACPauseAudioThread(!running
);
1308 void MainWin::SetZoom100(void)
1315 void MainWin::SetZoom200(void)
1322 void MainWin::SetZoom300(void)
1329 void MainWin::SetNTSC(void)
1331 powerAct
->setIcon(powerRed
);
1332 timer
->setInterval(16);
1333 vjs
.hardwareTypeNTSC
= true;
1339 void MainWin::SetPAL(void)
1341 powerAct
->setIcon(powerGreen
);
1342 timer
->setInterval(20);
1343 vjs
.hardwareTypeNTSC
= false;
1349 void MainWin::ToggleBlur(void)
1351 vjs
.glFilter
= !vjs
.glFilter
;
1356 void MainWin::ShowAboutWin(void)
1362 void MainWin::ShowHelpWin(void)
1368 void MainWin::InsertCart(void)
1370 // Check to see if we did autorun, 'cause we didn't load anything in that
1372 if (!scannedSoftwareFolder
)
1374 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1375 scannedSoftwareFolder
= true;
1378 // If the emulator is running, we pause it here and unpause it later
1379 // if we dismiss the file selector without choosing anything
1380 if (running
&& powerButtonOn
)
1383 pauseForFileSelector
= true;
1386 filePickWin
->show();
1390 void MainWin::Unpause(void)
1392 // Here we unpause the emulator if it was paused when we went into the file selector
1393 if (pauseForFileSelector
)
1395 pauseForFileSelector
= false;
1397 // Some nutter might have unpaused while in the file selector, so check for that
1404 // Jaguar initialisation and load software file
1405 void MainWin::LoadSoftware(QString file
)
1407 running
= false; // Prevent bad things(TM) from happening...
1408 pauseForFileSelector
= false; // Reset the file selector pause flag
1410 // Setup BIOS in his own dedicated Jaguar memory
1411 #ifndef NEWMODELSBIOSHANDLER
1412 uint8_t * biosPointer
= jaguarBootROM
;
1414 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1416 biosPointer
= jaguarDevBootROM2
;
1419 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1421 SelectBIOS(vjs
.biosType
);
1424 // Turn 'on' the power to initialize the Jaguar
1425 powerAct
->setDisabled(false);
1426 powerAct
->setChecked(true);
1427 powerButtonOn
= false;
1430 // We have to load our software *after* the Jaguar RESET
1431 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1432 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1434 // This is icky because we've already done it
1435 // it gets worse :-P
1436 if (!vjs
.useJaguarBIOS
)
1438 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1443 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1444 if (vjs
.softTypeDebugger
)
1446 m68k_set_reg(M68K_REG_A6
, 0);
1447 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1448 //pauseAct->setDisabled(false);
1449 //pauseAct->setChecked(true);
1455 // Prevent the launch in case of software without a start address and without BIOS presence
1456 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1462 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1464 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1465 setWindowTitle(newTitle
);
1470 void MainWin::ToggleCDUsage(void)
1472 CDActive
= !CDActive
;
1474 // Set up the Jaguar CD for execution, otherwise, clear memory
1476 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1478 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1483 void MainWin::ShowBreakpointsWin(void)
1485 BreakpointsWin
->show();
1486 BreakpointsWin
->RefreshContents();
1491 void MainWin::DeleteAllBreakpoints(void)
1493 cpuBrowseWin
->ResetBPM();
1495 ShowBreakpointsWin();
1500 void MainWin::DisableAllBreakpoints(void)
1502 cpuBrowseWin
->DisableBPM();
1504 ShowBreakpointsWin();
1509 void MainWin::ShowNewFunctionBreakpointWin(void)
1511 NewFunctionBreakpointWin
->show();
1512 ShowBreakpointsWin();
1517 void MainWin::ShowCartFilesListWin(void)
1519 CartFilesListWin
->show();
1520 CartFilesListWin
->RefreshContents();
1525 void MainWin::DebuggerTraceStepInto(void)
1528 videoWidget
->updateGL();
1529 DebuggerRefreshWindows();
1531 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1533 #warning "!!! Need to verify the Step Into function !!!"
1538 // Restart the Jaguar executable
1539 void MainWin::DebuggerRestart(void)
1544 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1545 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1547 m68k_set_reg(M68K_REG_A6
, 0);
1548 m68k_brk_hitcounts_reset();
1550 DebuggerResetWindows();
1551 DebuggerRefreshWindows();
1553 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1555 #warning "!!! Need to verify the Restart function !!!"
1561 void MainWin::DebuggerTraceStepOver(void)
1564 videoWidget
->updateGL();
1565 DebuggerRefreshWindows();
1567 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1569 #warning "!!! Need to verify the Step Over function !!!"
1574 // Advance / Execute for one frame
1575 void MainWin::FrameAdvance(void)
1577 //printf("Frame Advance...\n");
1579 // Execute 1 frame, then exit (only useful in Pause mode)
1581 //if (!vjs.softTypeDebugger)
1582 videoWidget
->updateGL();
1584 // Need to execute 1 frames' worth of DSP thread as well :-/
1586 //m68kDasmWin->Use68KPCAddress();
1589 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1591 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1596 void MainWin::SetFullScreen(bool state
/*= true*/)
1598 if (!vjs
.softTypeDebugger
)
1602 mainWinPosition
= pos();
1604 statusBar()->hide();
1610 // This is needed because the fullscreen may happen on a different
1611 // screen than screen 0:
1612 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1613 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1614 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1615 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1616 double aspectRatio
= targetWidth
/ targetHeight
;
1617 // NOTE: Really should check here to see which dimension constrains the
1618 // other. Right now, we assume that height is the constraint.
1619 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1620 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1621 videoWidget
->fullscreen
= true;
1622 videoWidget
->outputWidth
= newWidth
;
1623 videoWidget
->setFixedSize(r
.width(), r
.height());
1628 // Seems Qt is fussy about this: showNormal() has to go first, or it
1629 // will keep the window stuck in a psuedo-fullscreen mode with no way
1630 // to get out of it (except closing the app).
1633 // Reset the video widget to windowed mode
1634 videoWidget
->offset
= 0;
1635 videoWidget
->fullscreen
= false;
1637 statusBar()->show();
1644 move(mainWinPosition
);
1650 void MainWin::ToggleFullScreen(void)
1652 fullScreen
= !fullScreen
;
1653 SetFullScreen(fullScreen
);
1658 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1660 exceptionvectortableBrowseWin
->show();
1661 exceptionvectortableBrowseWin
->RefreshContents();
1666 void MainWin::ShowLocalBrowserWin(void)
1668 LocalBrowseWin
->show();
1669 LocalBrowseWin
->RefreshContents();
1674 void MainWin::ShowCallStackBrowserWin(void)
1676 CallStackBrowseWin
->show();
1677 CallStackBrowseWin
->RefreshContents();
1681 void MainWin::ShowAllWatchBrowserWin(void)
1683 allWatchBrowseWin
->show();
1684 allWatchBrowseWin
->RefreshContents();
1688 void MainWin::ShowHeapAllocatorBrowserWin(void)
1690 heapallocatorBrowseWin
->show();
1691 heapallocatorBrowseWin
->RefreshContents();
1695 void MainWin::ShowMemoryBrowserWin(void)
1697 memBrowseWin
->show();
1698 memBrowseWin
->RefreshContents();
1702 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1704 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1706 mem1BrowseWin
[NumWin
]->show();
1707 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1712 void MainWin::ShowEmuStatusWin(void)
1714 emuStatusWin
->show();
1715 emuStatusWin
->RefreshContents();
1719 void MainWin::ShowStackBrowserWin(void)
1721 stackBrowseWin
->show();
1722 stackBrowseWin
->RefreshContents();
1726 void MainWin::ShowCPUBrowserWin(void)
1728 cpuBrowseWin
->show();
1729 cpuBrowseWin
->RefreshContents();
1733 void MainWin::ShowOPBrowserWin(void)
1735 opBrowseWin
->show();
1736 opBrowseWin
->RefreshContents();
1740 void MainWin::ShowM68KDasmBrowserWin(void)
1742 m68kDasmBrowseWin
->show();
1743 m68kDasmBrowseWin
->RefreshContents();
1747 void MainWin::ShowRISCDasmBrowserWin(void)
1749 riscDasmBrowseWin
->show();
1750 riscDasmBrowseWin
->RefreshContents();
1756 void MainWin::ShowDasmWin(void)
1759 // DasmWin->RefreshContents();
1766 void MainWin::ShowVideoOutputWin(void)
1768 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1769 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1770 //VideoOutputWindowCentrale->show();
1771 //memBrowseWin->show();
1772 //VideoOutputWin->show();
1773 //VideoOutputWin->RefreshContents(videoWidget);
1778 // Resize video window based on zoom factor
1779 // It doesn't apply in debugger mode as we use this window to display disassembly
1780 void MainWin::ResizeMainWindow(void)
1782 if (!vjs
.softTypeDebugger
)
1784 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1786 // Show the test pattern if user requested plzDontKillMyComputer mode
1787 if (!powerButtonOn
&& plzDontKillMyComputer
)
1789 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1791 if (vjs
.hardwareTypeNTSC
)
1793 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1797 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1808 void MainWin::ReadSettings(void)
1812 QSettings
settings("Underground Software", "Virtual Jaguar");
1814 //zoomLevel = settings.value("zoom", 2).toInt();
1815 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1816 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1818 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1819 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1820 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1821 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1822 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1823 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1824 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1825 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1826 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1827 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1828 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1829 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1830 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1831 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1832 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1833 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1834 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1835 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1836 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1837 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1838 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1840 // Read settings from the Debugger mode
1841 settings
.beginGroup("debugger");
1842 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1843 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1844 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1845 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1846 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1847 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1848 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1849 settings
.endGroup();
1851 // Read settings from the Alpine mode
1852 settings
.beginGroup("alpine");
1853 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1854 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1855 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1856 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1857 settings
.endGroup();
1859 // Read settings from the Keybindings
1860 settings
.beginGroup("keybindings");
1861 for (i
= 0; i
< KB_END
; i
++)
1863 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1865 settings
.endGroup();
1867 // Write important settings to the log file
1868 WriteLog("MainWin: Paths\n");
1869 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1870 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1871 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1872 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1873 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1874 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1875 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1876 WriteLog("MainWin: Misc.\n");
1877 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1880 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1881 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1882 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1883 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1884 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1885 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1886 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1887 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1888 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1889 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1890 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1891 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1892 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1893 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1894 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1895 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1896 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1897 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1898 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1899 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1900 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1901 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1903 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1904 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1905 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1906 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1907 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1908 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1909 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1910 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1911 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1912 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1913 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1914 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1915 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1916 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1917 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1918 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1919 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1920 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1921 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1922 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1923 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1926 WriteLog("Read setting = Done\n");
1928 ReadProfiles(&settings
);
1929 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
1934 // Default values will be used in case of no settings can be found
1936 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1938 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1940 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1941 void MainWin::ReadUISettings(void)
1948 // Point on the emulator settings
1949 QSettings
settings("Underground Software", "Virtual Jaguar");
1950 settings
.beginGroup("ui");
1952 // Emulator main window UI information
1953 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1954 size
= settings
.value("size", QSize(400, 400)).toSize();
1956 move(mainWinPosition
);
1957 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1958 filePickWin
->move(pos
);
1960 // Video output information
1961 zoomLevel
= settings
.value("zoom", 2).toInt();
1963 // Alpine debug UI information (also needed by the Debugger)
1964 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1966 // CPU registers UI information
1967 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1968 cpuBrowseWin
->move(pos
);
1969 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1971 // Memory browser UI information
1972 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1973 memBrowseWin
->move(pos
);
1974 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1976 // Stack browser UI information
1977 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1978 stackBrowseWin
->move(pos
);
1979 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1980 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1981 stackBrowseWin
->resize(size
);
1983 // Emulator status UI information
1984 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1985 emuStatusWin
->move(pos
);
1986 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1988 // OP (Object Processor) UI information
1989 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1990 opBrowseWin
->move(pos
);
1991 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1992 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1993 opBrowseWin
->resize(size
);
1995 // RISC disassembly UI information
1996 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1997 riscDasmBrowseWin
->move(pos
);
1998 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2000 // M68k disassembly UI information
2001 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2002 m68kDasmBrowseWin
->move(pos
);
2003 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2005 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2007 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2011 // Debugger UI information
2012 if (vjs
.softTypeDebugger
)
2015 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2016 m68kDasmWin
->move(pos
);
2017 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2018 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2019 GPUDasmWin
->move(pos
);
2020 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2021 DSPDasmWin
->move(pos
);
2023 // All watch browser UI information
2024 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2025 allWatchBrowseWin
->move(pos
);
2026 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2027 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2028 allWatchBrowseWin
->resize(size
);
2030 // Local browser UI information
2031 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2032 LocalBrowseWin
->move(pos
);
2033 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2034 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2035 LocalBrowseWin
->resize(size
);
2037 // Heap memory allocation browser UI information
2038 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2039 heapallocatorBrowseWin
->move(pos
);
2040 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2041 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2042 heapallocatorBrowseWin
->resize(size
);
2044 // Exception Vector Table UI Information
2045 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2046 exceptionvectortableBrowseWin
->move(pos
);
2047 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2048 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2049 exceptionvectortableBrowseWin
->resize(size
);
2051 // Call Stack browser UI information
2052 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2053 CallStackBrowseWin
->move(pos
);
2054 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2055 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2056 CallStackBrowseWin
->resize(size
);
2058 // Cartdridge directory and files
2059 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2060 CartFilesListWin
->move(pos
);
2061 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2062 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2063 CartFilesListWin
->resize(size
);
2065 // Breakpoints UI information
2066 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2067 BreakpointsWin
->move(pos
);
2068 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2069 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2070 BreakpointsWin
->resize(size
);
2071 // New function breakpoint UI information
2072 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2073 NewFunctionBreakpointWin
->move(pos
);
2074 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2075 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2076 NewFunctionBreakpointWin
->resize(size
);
2078 // Memories browser UI information
2079 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2081 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2082 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2083 mem1BrowseWin
[i
]->move(pos
);
2084 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2085 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2086 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2087 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2088 mem1BrowseWin
[i
]->resize(size
);
2092 settings
.endGroup();
2094 WriteLog("Read UI setting = Done\n");
2098 // Save the settings
2099 void MainWin::WriteSettings(void)
2103 // Point on the emulator settings
2104 QSettings
settings("Underground Software", "Virtual Jaguar");
2105 //settings.setValue("pos", pos());
2106 //settings.setValue("size", size());
2107 //settings.setValue("cartLoadPos", filePickWin->pos());
2109 //settings.setValue("zoom", zoomLevel);
2110 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2111 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2113 settings
.setValue("useJoystick", vjs
.useJoystick
);
2114 settings
.setValue("joyport", vjs
.joyport
);
2115 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2116 settings
.setValue("frameSkip", vjs
.frameSkip
);
2117 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2118 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2119 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2120 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2121 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2122 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2123 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2124 settings
.setValue("fullscreen", vjs
.fullscreen
);
2125 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2126 settings
.setValue("glFilterType", vjs
.glFilter
);
2127 settings
.setValue("renderType", vjs
.renderType
);
2128 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2129 settings
.setValue("biosType", vjs
.biosType
);
2130 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2131 //settings.setValue("JagBootROM", vjs.jagBootPath);
2132 //settings.setValue("CDBootROM", vjs.CDBootPath);
2133 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2134 settings
.setValue("ROMs", vjs
.ROMPath
);
2135 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2137 // Write settings from the Alpine mode
2138 settings
.beginGroup("alpine");
2139 settings
.setValue("refresh", vjs
.refresh
);
2140 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2141 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2142 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2143 settings
.endGroup();
2145 // Write settings from the Debugger mode
2146 settings
.beginGroup("debugger");
2147 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2148 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
2149 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2150 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2151 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2152 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2153 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2154 settings
.endGroup();
2156 // Write settings from the Keybindings
2157 settings
.beginGroup("keybindings");
2158 for (i
= 0; i
< KB_END
; i
++)
2160 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2162 settings
.endGroup();
2165 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2166 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2167 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2168 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2169 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2170 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2171 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2172 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2173 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2174 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2175 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2176 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2177 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2178 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2179 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2180 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2181 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2182 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2183 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2184 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2185 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2187 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2188 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2189 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2190 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2191 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2192 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2193 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2194 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2195 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2196 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2197 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2198 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2199 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2200 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2201 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2202 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2203 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2204 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2205 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2206 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2207 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2210 WriteProfiles(&settings
);
2211 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2215 // Save the UI settings
2216 void MainWin::WriteUISettings(void)
2221 // Point on the emulator settings
2222 QSettings
settings("Underground Software", "Virtual Jaguar");
2223 settings
.beginGroup("ui");
2225 // Emulator UI information
2226 settings
.setValue("pos", pos());
2227 settings
.setValue("size", size());
2228 settings
.setValue("cartLoadPos", filePickWin
->pos());
2230 // Video output information
2231 settings
.setValue("zoom", zoomLevel
);
2233 // Alpine debug UI information (also needed by the Debugger)
2234 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2236 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2237 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2238 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2239 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2240 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2241 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2242 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2243 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2244 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2245 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2246 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2247 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2248 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2249 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2250 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2251 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2254 // Debugger UI information
2255 if (vjs
.softTypeDebugger
)
2258 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2259 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2260 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2261 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2263 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2264 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2265 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2266 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2267 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2268 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2269 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2270 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2271 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2272 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2273 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2274 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2275 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2276 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2277 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2278 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2279 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2280 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2281 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2282 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2283 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2284 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2285 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2286 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2288 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2290 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2291 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2292 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2293 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2294 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2295 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2299 settings
.endGroup();
2303 // Refresh alpine debug windows
2304 void MainWin::AlpineRefreshWindows(void)
2306 cpuBrowseWin
->RefreshContents();
2307 memBrowseWin
->RefreshContents();
2308 stackBrowseWin
->RefreshContents();
2309 emuStatusWin
->RefreshContents();
2310 opBrowseWin
->RefreshContents();
2311 riscDasmBrowseWin
->RefreshContents();
2312 m68kDasmBrowseWin
->RefreshContents();
2316 // Reset soft view windows
2317 void MainWin::ViewResetWindows(void)
2319 CartFilesListWin
->Reset();
2323 // Reset soft debugger windows
2324 void MainWin::DebuggerResetWindows(void)
2326 if (vjs
.softTypeDebugger
)
2328 FilesrcListWin
->Reset();
2329 allWatchBrowseWin
->Reset();
2330 heapallocatorBrowseWin
->Reset();
2331 BreakpointsWin
->Reset();
2332 //ResetAlpineWindows();
2338 // Refresh view windows
2339 void MainWin::ViewRefreshWindows(void)
2341 CartFilesListWin
->RefreshContents();
2345 // Refresh soft debugger & alpine debug windows
2346 void MainWin::DebuggerRefreshWindows(void)
2350 if (vjs
.softTypeDebugger
)
2352 FilesrcListWin
->RefreshContents();
2353 m68kDasmWin
->RefreshContents();
2354 GPUDasmWin
->RefreshContents();
2355 DSPDasmWin
->RefreshContents();
2356 allWatchBrowseWin
->RefreshContents();
2357 LocalBrowseWin
->RefreshContents();
2358 CallStackBrowseWin
->RefreshContents();
2359 heapallocatorBrowseWin
->RefreshContents();
2360 BreakpointsWin
->RefreshContents();
2361 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2363 mem1BrowseWin
[i
]->RefreshContents(i
);
2366 AlpineRefreshWindows();
2367 ViewRefreshWindows();
2372 // Create and save screenshot
2373 void MainWin::MakeScreenshot(void)
2377 time_t now
= time(0);
2381 tstruct
= *localtime(&now
);
2382 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
);
2384 // Create screenshot
2385 screenshot
= videoWidget
->grabFrameBuffer();
2386 screenshot
.save((char *)Text
, "JPG", 100);