2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James Hammons <jlhamm@acm.org>
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
8 // RG = Richard Goedeken
12 // --- ---------- ------------------------------------------------------------
13 // JLH 12/23/2009 Created this file
14 // JLH 12/20/2010 Added settings, menus & toolbars
15 // JLH 07/05/2011 Added CD BIOS functionality to GUI
16 // JPM June/2016 Visual Studio support & Soft debugger integration
17 // JPM 01/11/2017 Added stack browser
18 // JPM Feb./2017 Added GPU/DSP disassembly
19 // JPM 07/12/2017 Added all Watch window
20 // JPM Aug./2017 Added heap allocator and memories window, a restart feature, and a [Not Supported] breakpoints window
21 // JPM Sept./2017 Save position, size & visibility windows status in the settings; added Exception Vector Table window, the 'Rx' word to the emulator window name, and the keybindings in the settings
22 // JPM 11/04/2017 Added the local window
23 // JPM 08/31/2018 Added the call stack window
24 // JPM Sept./2018 Added the new Models and BIOS handler, a screenshot feature and source code files browsing
25 // JPM Oct./2018 Added search paths in the settings, breakpoints feature, cartridge view menu
26 // JPM 11/18/2018 Fix crash with non-debugger mode
27 // JPM April/2019 Added ELF sections check, added a save memory dump
28 // JPM Aug./2019 Update texts descriptions, set cartridge view menu for debugger mode only, added a HW registers browser and source level tracing
29 // JPM Marc./2020 Added the step over for source level tracing
30 // RG Jan./2021 Linux build fixes
31 // JPM Apr./2021 Handle number of M68K cycles used in tracing mode, added video output display in a window
36 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
37 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
38 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
39 // with 'R', etc) [DONE]
40 // - Controller configuration [DONE]
44 // - The source file listing do not need to be refresh more than one time
45 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
46 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
47 // - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't)
49 // SFDX CODE: S1E9T8H5M23YS
51 // Uncomment this for debugging...
53 //#define DEBUGFOO // Various tool debugging... but not used
54 //#define DEBUGTP // Toolpalette debugging... but not used
61 #include "configdialog.h"
62 #include "controllertab.h"
63 #include "keybindingstab.h"
64 #include "filepicker.h"
66 #include "generaltab.h"
72 #include "emustatus.h"
73 #include "debug/cpubrowser.h"
74 #include "debug/m68kdasmbrowser.h"
75 #include "debug/memorybrowser.h"
76 #include "debug/stackbrowser.h"
77 #include "debug/opbrowser.h"
78 #include "debug/riscdasmbrowser.h"
79 #include "debug/hwregsbrowser.h"
85 #ifndef NEWMODELSBIOSHANDLER
88 #include "jagstub2bios.h"
90 #include "modelsBIOS.h"
92 #include "jagcdbios.h"
94 #include "m68000/m68kinterface.h"
96 #include "debugger/DBGManager.h"
97 #include "debugger/VideoWin.h"
98 //#include "debugger/DasmWin.h"
99 #include "debugger/SourcesWin.h"
100 #include "debugger/m68kDasmWin.h"
101 #include "debugger/GPUDasmWin.h"
102 #include "debugger/DSPDasmWin.h"
103 #include "debugger/memory1browser.h"
104 #include "debugger/BreakpointsWin.h"
105 #include "debugger/NewFnctBreakpointWin.h"
106 #include "debugger/FilesrcListWin.h"
107 #include "debugger/exceptionvectortablebrowser.h"
108 #include "debugger/allwatchbrowser.h"
109 #include "debugger/localbrowser.h"
110 #include "debugger/heapallocatorbrowser.h"
111 #include "debugger/callstackbrowser.h"
112 #include "debugger/CartFilesListWin.h"
113 #include "debugger/SaveDumpAsWin.h"
116 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
117 //#ifdef __GCCWIN32__
118 // Apparently on win32, usleep() is not pulled in by the usual suspects.
122 #include "_MSC_VER/unistd.h"
126 // The way BSNES controls things is by setting a timer with a zero
127 // timeout, sleeping if not emulating anything. Seems there has to be a
130 // It has a novel approach to plugging-in/using different video/audio/input
131 // methods, can we do something similar or should we just use the built-in
134 // We're going to try to use the built-in OpenGL support and see how it goes.
135 // We'll make the VJ core modular so that it doesn't matter what GUI is in
136 // use, we can drop it in anywhere and use it as-is.
138 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
139 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
140 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
146 for(int i
=0; i
<8; i
++)
150 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
153 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
156 //if (vjs.softTypeDebugger)
158 // mainWindowCentrale = new QMdiArea;
159 // setCentralWidget(mainWindowCentrale);
162 WriteLog("Window creation start\n");
165 videoWidget
= new GLWidget(this);
166 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
168 // set central output window
169 if (!vjs
.softTypeDebugger
)
171 setCentralWidget(videoWidget
);
175 mainWindowCentrale
= new QMdiArea(this);
176 setCentralWidget(mainWindowCentrale
);
179 setWindowIcon(QIcon(":/res/vj-icon.png"));
181 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
183 if (vjs
.hardwareTypeAlpine
)
184 title
+= QString(tr(" - Alpine Mode"));
186 if (vjs
.softTypeDebugger
)
187 title
+= QString(tr(" - Debugger Mode"));
189 setWindowTitle(title
);
191 // Windows common features
192 aboutWin
= new AboutWindow(this);
193 helpWin
= new HelpWindow(this);
194 filePickWin
= new FilePickerWindow(this);
195 emuStatusWin
= new EmuStatusWindow(this);
197 // Windows alpine mode features
198 memBrowseWin
= new MemoryBrowserWindow(this);
199 stackBrowseWin
= new StackBrowserWindow(this);
200 cpuBrowseWin
= new CPUBrowserWindow(this);
201 opBrowseWin
= new OPBrowserWindow(this);
202 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
203 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
204 hwRegsBrowseWin
= new HWRegsBrowserWindow(this);
206 // Windows debugger mode features
207 if (vjs
.softTypeDebugger
)
209 VideoOutputWin
= new VideoOutputWindow(this);
210 //VideoOutputWin->show();
211 //VideoOutputWin->setCentralWidget()
212 //DasmWin = new DasmWindow();
213 //DasmWin = new DasmWindow(this);
214 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
215 LocalBrowseWin
= new LocalBrowserWindow(this);
216 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
217 BreakpointsWin
= new BreakpointsWindow(this);
218 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
219 SaveDumpAsWin
= new SaveDumpAsWindow(this);
220 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
221 CallStackBrowseWin
= new CallStackBrowserWindow(this);
222 CartFilesListWin
= new CartFilesListWindow(this);
224 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
226 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
228 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
230 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
232 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
235 // Setup dock to display source code filenames tree
236 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
237 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
239 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
240 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
241 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
243 // Setup dock to display disassembly
244 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
245 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
246 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
247 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
248 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
250 dasmtabWidget
= new QTabWidget(this);
253 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
254 dasmtabWidget
->addTab(SourcesWin
= new SourcesWindow(this), tr("Sources"));
255 dasmtabWidget
->setCurrentIndex(dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000")));
256 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
257 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
258 connect(dasmtabWidget
, SIGNAL(currentChanged(const int)), this, SLOT(SelectdasmtabWidget(const int)));
260 setCentralWidget(dasmtabWidget
);
264 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
265 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
267 setUnifiedTitleAndToolBarOnMac(true);
270 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
271 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
272 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
273 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
274 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
277 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
278 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
279 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
280 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
281 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
282 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
283 powerAct
->setCheckable(true);
284 powerAct
->setChecked(false);
285 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
289 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
290 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
291 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
292 pauseAct
->setStatusTip(tr("Toggles the running state"));
293 pauseAct
->setCheckable(true);
294 pauseAct
->setDisabled(true);
295 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
296 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
297 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
300 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
301 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
302 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
303 screenshotAct
->setCheckable(false);
304 screenshotAct
->setDisabled(false);
305 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
308 zoomActs
= new QActionGroup(this);
309 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
310 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
311 x1Act
->setCheckable(true);
312 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
313 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
314 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
315 x2Act
->setCheckable(true);
316 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
317 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
318 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
319 x3Act
->setCheckable(true);
320 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
323 tvTypeActs
= new QActionGroup(this);
324 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
325 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
326 ntscAct
->setCheckable(true);
327 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
328 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
329 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
330 palAct
->setCheckable(true);
331 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
334 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
335 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
336 blurAct
= new QAction(blur
, tr("Blur"), this);
337 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
338 blurAct
->setCheckable(true);
339 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
342 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
343 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
344 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
347 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
348 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
349 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
351 // File pickup action
352 if (!vjs
.softTypeDebugger
)
354 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
355 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
359 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
360 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
362 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
363 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
364 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
366 // Configuration action
367 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
368 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
369 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
370 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
371 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
373 // Emulation status action
374 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
375 emustatusAct
->setStatusTip(tr("Emulator status"));
376 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
377 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
378 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
381 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
382 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
383 useCDAct
->setCheckable(true);
384 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
386 // Frame advance action
387 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
388 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
389 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
390 frameAdvanceAct
->setDisabled(true);
391 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
394 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
395 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
396 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
397 fullScreenAct
->setCheckable(true);
398 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
400 // Actions dedicated to debugger mode
401 if (vjs
.softTypeDebugger
)
404 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
405 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
406 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
407 restartAct
->setCheckable(false);
408 restartAct
->setDisabled(true);
409 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
412 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
413 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
414 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
415 traceStepOverAct
->setCheckable(false);
416 traceStepOverAct
->setDisabled(true);
417 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
419 // Trace into tracing
420 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
421 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
422 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
423 traceStepIntoAct
->setCheckable(false);
424 traceStepIntoAct
->setDisabled(true);
425 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
427 // Function breakpoint
428 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
429 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
430 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
431 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
432 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
433 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
434 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
435 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
436 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
437 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
438 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
441 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
442 saveDumpAsAct
->setCheckable(false);
443 saveDumpAsAct
->setDisabled(false);
444 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
446 VideoOutputAct
= new QAction(tr("Output Video"), this);
447 VideoOutputAct
->setStatusTip(tr("Shows the output video window"));
448 connect(VideoOutputAct
, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
450 //DasmAct = new QAction(tr("Disassembly"), this);
451 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
452 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
454 // Exception vector table window
455 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
456 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
457 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
459 // All watch variables window
460 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
461 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
462 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
464 // Local variables window
465 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
466 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
467 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
469 // Heap (memory) allocation window
470 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
471 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
472 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
475 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
476 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
477 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
480 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
481 CartFilesListAct
->setStatusTip(tr("List of the files in the cartridge's directory structure"));
482 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
485 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
486 QSignalMapper
*signalMapper
= new QSignalMapper(this);
488 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
490 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
492 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
495 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
496 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
497 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
498 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
499 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
500 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
504 // Memory browser window action
505 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
506 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
507 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
509 // Stack browser window action
510 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
511 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
512 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
514 // CPUs (M68000, GPU & DSP browser window action
515 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
516 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
517 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
519 // OP browser window action
520 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
521 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
522 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
524 // M68000 disassembly browser window
525 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
526 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
527 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
529 // HW registers browser window
530 hwRegsBrowseAct
= new QAction(QIcon(":/res/tool-hw-regs.png"), tr("HW Registers Browser"), this);
531 hwRegsBrowseAct
->setStatusTip(tr("Shows the HW registers browser window"));
532 connect(hwRegsBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHWRegsBrowserWin()));
534 // Risc (DSP / GPU) disassembly browser window
535 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
536 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
537 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
539 // Misc. connections...
540 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
541 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
545 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
546 fileMenu
->addAction(powerAct
);
547 if (!vjs
.softTypeDebugger
)
549 fileMenu
->addAction(pauseAct
);
550 // fileMenu->addAction(frameAdvanceAct);
552 fileMenu
->addAction(filePickAct
);
553 fileMenu
->addAction(useCDAct
);
554 fileMenu
->addAction(configAct
);
555 fileMenu
->addAction(emustatusAct
);
556 fileMenu
->addSeparator();
557 fileMenu
->addAction(quitAppAct
);
559 // Alpine and debugger menus
560 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
563 debugMenu
= menuBar()->addMenu(tr("&Debug"));
565 // Create debugger menu
566 if (vjs
.softTypeDebugger
)
569 viewMenu
= menuBar()->addMenu(tr("&View"));
572 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
573 viewCartMenu
->addAction(CartFilesListAct
);
575 viewCartMenu
->addSeparator();
576 viewCartMenu
->addAction(CartStreamsAct
);
580 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
581 debugWindowsMenu
->addAction(BreakpointsAct
);
582 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
583 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
584 debugWindowsMenu
->addSeparator();
585 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
586 debugWindowOutputMenu
->addAction(VideoOutputAct
);
587 debugWindowsMenu
->addSeparator();
588 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
589 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
590 debugWindowsMenu
->addAction(LocalBrowseAct
);
591 debugWindowsMenu
->addSeparator();
592 debugWindowsMenu
->addAction(CallStackBrowseAct
);
593 debugWindowsMenu
->addSeparator();
594 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
595 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
596 debugWindowsMemoryMenu
->addSeparator();
597 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
599 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
601 debugWindowsMenu
->addSeparator();
602 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
603 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
604 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
605 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
606 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
607 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
608 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
609 debugWindowsBrowsesMenu
->addAction(hwRegsBrowseAct
);
610 debugMenu
->addSeparator();
611 debugMenu
->addAction(pauseAct
);
612 debugMenu
->addAction(frameAdvanceAct
);
613 debugMenu
->addAction(restartAct
);
614 debugMenu
->addSeparator();
615 debugMenu
->addAction(traceStepIntoAct
);
616 debugMenu
->addAction(traceStepOverAct
);
617 debugMenu
->addSeparator();
618 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
619 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
620 debugMenu
->addAction(deleteAllBreakpointsAct
);
621 debugMenu
->addAction(disableAllBreakpointsAct
);
622 debugMenu
->addSeparator();
623 debugMenu
->addAction(saveDumpAsAct
);
625 debugMenu
->addSeparator();
626 debugMenu
->addAction(DasmAct
);
631 // Create alpine menu
632 debugMenu
->addAction(memBrowseAct
);
633 debugMenu
->addAction(stackBrowseAct
);
634 debugMenu
->addAction(cpuBrowseAct
);
635 debugMenu
->addAction(opBrowseAct
);
636 debugMenu
->addAction(m68kDasmBrowseAct
);
637 debugMenu
->addAction(riscDasmBrowseAct
);
638 debugMenu
->addAction(hwRegsBrowseAct
);
643 helpMenu
= menuBar()->addMenu(tr("&Help"));
644 helpMenu
->addAction(helpAct
);
645 helpMenu
->addAction(aboutAct
);
649 toolbar
= addToolBar(tr("System"));
650 toolbar
->addAction(powerAct
);
651 if (!vjs
.softTypeDebugger
)
653 toolbar
->addAction(pauseAct
);
654 toolbar
->addAction(frameAdvanceAct
);
656 toolbar
->addAction(filePickAct
);
657 toolbar
->addAction(useCDAct
);
658 toolbar
->addSeparator();
659 if (!vjs
.softTypeDebugger
)
661 toolbar
->addAction(screenshotAct
);
662 toolbar
->addSeparator();
663 toolbar
->addAction(x1Act
);
664 toolbar
->addAction(x2Act
);
665 toolbar
->addAction(x3Act
);
666 toolbar
->addSeparator();
667 toolbar
->addAction(ntscAct
);
668 toolbar
->addAction(palAct
);
669 toolbar
->addSeparator();
670 toolbar
->addAction(blurAct
);
671 toolbar
->addAction(fullScreenAct
);
675 debuggerbar
= addToolBar(tr("&Debugger"));
676 debuggerbar
->addAction(pauseAct
);
677 debuggerbar
->addAction(frameAdvanceAct
);
678 debuggerbar
->addAction(restartAct
);
679 debuggerbar
->addSeparator();
680 debuggerbar
->addAction(traceStepIntoAct
);
681 debuggerbar
->addAction(traceStepOverAct
);
682 debuggerbar
->addSeparator();
683 debuggerbar
->addAction(BreakpointsAct
);
686 if (vjs
.hardwareTypeAlpine
)
688 debugbar
= addToolBar(tr("&Debug"));
689 debugbar
->addAction(memBrowseAct
);
690 debugbar
->addAction(stackBrowseAct
);
691 debugbar
->addAction(cpuBrowseAct
);
692 debugbar
->addAction(opBrowseAct
);
693 debugbar
->addAction(m68kDasmBrowseAct
);
694 debugbar
->addAction(riscDasmBrowseAct
);
695 debugbar
->addAction(hwRegsBrowseAct
);
698 // Add actions to the main window, as hiding widgets with them
700 addAction(fullScreenAct
);
701 addAction(quitAppAct
);
702 addAction(configAct
);
703 addAction(emustatusAct
);
705 addAction(filePickAct
);
706 addAction(frameAdvanceAct
);
709 statusBar()->showMessage(tr("Ready"));
711 // Do this in case original size isn't correct (mostly for the first-run case)
714 WriteLog("Window creation done\n");
716 // Create our test pattern NTSC bitmap
717 WriteLog("Test pattern 1 bitmap\n");
719 QImage
tempImg(":/res/test-pattern.jpg");
720 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
722 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
724 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
726 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
728 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
729 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
733 // Create our test pattern PAL bitmap
734 WriteLog("Test pattern 2 bitmap\n");
736 QImage
tempImg2(":/res/test-pattern-pal.jpg");
737 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
739 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
741 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
743 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
745 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
746 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
750 // Set up timer based loop for animation...
751 timer
= new QTimer(this);
752 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
754 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
755 // This is because it's discarding the 0.6666... on the end of the fraction.
756 // Alas, 6 doesn't divide cleanly into 10. :-P
757 //Should we defer this until SyncUI? Probably.
758 //No, it doesn't work, because it uses setInterval() instead of start()...
759 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
761 // We set this initially, to make VJ behave somewhat as it would if no
762 // cart were inserted and the BIOS was set as active...
763 jaguarCartInserted
= true;
764 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
765 WriteLog("VJ: Initializing jaguar subsystem...\n");
768 #ifndef NEWMODELSBIOSHANDLER
769 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
770 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
772 SelectBIOS(vjs
.biosType
);
775 // Prevent the file scanner from running if filename passed
776 // in on the command line...
780 // Load up the default ROM if in Alpine mode:
781 if (vjs
.hardwareTypeAlpine
)
783 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
785 // If regular load failed, try just a straight file load
786 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
788 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
791 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
793 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
795 // Attempt to load/run the ABS file...
796 LoadSoftware(vjs
.absROMPath
);
797 #ifndef NEWMODELSBIOSHANDLER
798 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
800 SelectBIOS(vjs
.biosType
);
802 // Prevent the scanner from running...
806 // Load up the default ROM if in Debugger mode:
807 if (vjs
.softTypeDebugger
)
809 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
811 // If regular load failed, try just a straight file load
812 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
814 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
817 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
819 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
821 // Attempt to load/run the ABS file...
822 LoadSoftware(vjs
.absROMPath
);
823 #ifndef NEWMODELSBIOSHANDLER
824 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
825 // Prevent the scanner from running...
827 SelectBIOS(vjs
.biosType
);
832 // Run the scanner if nothing passed in and *not* Alpine mode...
833 // NB: Really need to look into caching the info scanned in here...
834 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
835 scannedSoftwareFolder
= true;
839 void MainWin::LoadFile(QString file
)
845 void MainWin::SyncUI(void)
847 // Set toolbar buttons/menus based on settings read in (sync the UI)...
848 // (Really, this is to sync command line options passed in)
849 blurAct
->setChecked(vjs
.glFilter
);
850 x1Act
->setChecked(zoomLevel
== 1);
851 x2Act
->setChecked(zoomLevel
== 2);
852 x3Act
->setChecked(zoomLevel
== 3);
853 // running = powerAct->isChecked();
854 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
855 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
856 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
858 fullScreenAct
->setChecked(vjs
.fullscreen
);
859 fullScreen
= vjs
.fullscreen
;
860 SetFullScreen(fullScreen
);
862 // Reset the timer to be what was set in the command line (if any):
863 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
864 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
869 void MainWin::SelectdasmtabWidget(const int Index
)
874 SourcesWin
->RefreshContents();
879 void MainWin::closeEvent(QCloseEvent
* event
)
882 // This should only be done by the config dialog
885 event
->accept(); // ignore() if can't close for some reason
889 void MainWin::keyPressEvent(QKeyEvent
* e
)
891 #ifndef VJ_REMOVE_DEV_CODE
893 //extern bool startM68KTracing; // moved to jaguar.h
895 extern int blit_start_log
;
897 extern bool startConciseBlitLogging
;
900 // We ignore the Alt key for now, since it causes problems with the GUI
901 if (e
->key() == Qt::Key_Alt
)
906 // Bar this shite from release versions kthxbai
907 #ifndef VJ_REMOVE_DEV_CODE
908 else if (e
->key() == Qt::Key_F11
)
910 startM68KTracing
= true;
914 else if (e
->key() == Qt::Key_F12
)
916 blit_start_log
= true;
920 else if (e
->key() == Qt::Key_F10
)
922 startConciseBlitLogging
= true;
927 else if (e
->key() == Qt::Key_F8
)
929 // ggn: For extra NYAN pleasure...
930 // ggn: There you go James :P
931 // Shamus: Thanks for the patch! :-D
932 WriteLog(" o + + +\n");
933 WriteLog("+ o o + o\n");
934 WriteLog("-_-_-_-_-_-_-_,------, o \n");
935 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
936 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
937 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
938 WriteLog("+ o o + o\n");
945 This is done now by a QAction...
946 if (e->key() == Qt::Key_F9)
956 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
958 // We ignore the Alt key for now, since it causes problems with the GUI
959 if (e
->key() == Qt::Key_Alt
)
965 HandleKeys(e
, false);
969 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
971 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
972 // We kill bad key combos here, before they can get to the emulator...
973 // This also kills the illegal instruction problem that cropped up in
976 // First, settle key states...
977 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
978 keyHeld
[P1LEFT
] = state
;
979 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
980 keyHeld
[P1RIGHT
] = state
;
981 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
982 keyHeld
[P1UP
] = state
;
983 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
984 keyHeld
[P1DOWN
] = state
;
985 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
986 keyHeld
[P2LEFT
] = state
;
987 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
988 keyHeld
[P2RIGHT
] = state
;
989 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
990 keyHeld
[P2UP
] = state
;
991 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
992 keyHeld
[P2DOWN
] = state
;
994 // Next, check for conflicts and kill 'em if there are any...
995 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
996 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
998 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
999 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
1001 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
1002 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
1004 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
1005 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
1007 // No bad combos exist now, let's stuff the emulator key buffers...!
1008 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1010 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
1011 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
1013 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
1014 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
1020 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
1022 void MainWin::HandleGamepads(void)
1026 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1028 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1029 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
1031 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1032 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1037 void MainWin::Open(void)
1042 void MainWin::Configure(void)
1044 // Call the configuration dialog and update settings
1045 ConfigDialog
dlg(this);
1047 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1048 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1049 dlg
.controllerTab1
->SetupLastUsedProfile();
1050 // maybe instead of this, we tell the controller tab to work on a copy that gets
1051 // written if the user hits 'OK'.
1052 SaveProfiles(); // Just in case user cancels
1054 if (dlg
.exec() == false)
1060 QString before
= vjs
.ROMPath
;
1061 QString alpineBefore
= vjs
.alpineROMPath
;
1062 QString absBefore
= vjs
.absROMPath
;
1063 // bool audioBefore = vjs.audioEnabled;
1064 bool audioBefore
= vjs
.DSPEnabled
;
1065 dlg
.UpdateVJSettings();
1066 QString after
= vjs
.ROMPath
;
1067 QString alpineAfter
= vjs
.alpineROMPath
;
1068 QString absAfter
= vjs
.absROMPath
;
1069 // bool audioAfter = vjs.audioEnabled;
1070 bool audioAfter
= vjs
.DSPEnabled
;
1072 bool allowOld
= allowUnknownSoftware
;
1074 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1075 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1076 AutoConnectProfiles();
1078 // We rescan the "software" folder if the user either changed the path or
1079 // checked/unchecked the "Allow unknown files" option in the config dialog.
1080 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1081 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1083 // If the "Alpine" ROM is changed, then let's load it...
1084 if (alpineBefore
!= alpineAfter
)
1086 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1088 // Oh crap, we couldn't get the file! Alert the media!
1090 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1091 msg
.setIcon(QMessageBox::Warning
);
1096 // If the "ABS" ROM is changed, then let's load it...
1097 if (absBefore
!= absAfter
)
1099 if (!JaguarLoadFile(vjs
.absROMPath
))
1101 // Oh crap, we couldn't get the file! Alert the media!
1103 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1104 msg
.setIcon(QMessageBox::Warning
);
1109 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1110 // since it's running in the host audio IRQ...
1111 if (audioBefore
!= audioAfter
)
1117 // Just in case we crash before a clean exit...
1125 // Here's the main emulator loop
1127 void MainWin::Timer(void)
1130 static uint32_t ntscTickCount
;
1131 if (vjs
.hardwareTypeNTSC
)
1135 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1142 if (showUntunedTankCircuit
)
1144 // Some machines can't handle this, so we give them the option to disable it. :-)
1145 if (!plzDontKillMyComputer
)
1147 // if (!vjs.softTypeDebugger)
1149 // Random hash & trash
1150 // We try to simulate an untuned tank circuit here... :-)
1151 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1153 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1155 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1163 // Otherwise, run the Jaguar simulation
1166 //if (!vjs.softTypeDebugger)
1167 videoWidget
->HandleMouseHiding();
1169 static uint32_t refresh
= 0;
1170 // Do autorefresh on debug windows
1171 // Have to be careful, too much causes the emulator to slow way down!
1172 if (refresh
== vjs
.refresh
)
1174 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1176 AlpineRefreshWindows();
1177 //memBrowseWin->RefreshContents();
1178 //cpuBrowseWin->RefreshContents();
1180 CommonRefreshWindows();
1189 //if (!vjs.softTypeDebugger)
1190 videoWidget
->updateGL();
1191 //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL;
1194 // Approach: We use a ring buffer to store times (in ms) over a given
1195 // amount of frames, then sum them to figure out the FPS.
1196 uint32_t timestamp
= SDL_GetTicks();
1197 // This assumes the ring buffer size is a power of 2
1198 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1199 // Doing it this way is better. Ring buffer size can be arbitrary then.
1200 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1201 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1202 uint32_t elapsedTime
= 0;
1204 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1205 elapsedTime
+= ringBuffer
[i
];
1207 // elapsedTime must be non-zero
1208 if (elapsedTime
== 0)
1211 // This is in frames per 10 seconds, so we can have 1 decimal
1212 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1213 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1214 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1215 // If this is updated too frequently to be useful, we can throttle it down
1216 // so that it only updates every 10th frame or so
1217 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1218 oldTimestamp
= timestamp
;
1220 if (M68KDebugHaltStatus())
1225 // Toggle the power state, it can be either on or off
1226 void MainWin::TogglePowerState(void)
1228 powerButtonOn
= !powerButtonOn
;
1231 // With the power off, we simulate white noise on the screen. :-)
1234 // Restore the mouse pointer, if hidden:
1235 //if (!vjs.softTypeDebugger)
1237 videoWidget
->CheckAndRestoreMouseCursor();
1240 useCDAct
->setDisabled(false);
1241 palAct
->setDisabled(false);
1242 ntscAct
->setDisabled(false);
1243 pauseAct
->setChecked(false);
1244 pauseAct
->setDisabled(true);
1245 showUntunedTankCircuit
= true;
1247 DACPauseAudioThread();
1248 // 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. :-)
1251 if (plzDontKillMyComputer
)
1253 // We have to do it line by line, because the texture pitch is not the same as the picture buffer's pitch.
1254 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1256 if (vjs
.hardwareTypeNTSC
)
1258 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1262 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1269 useCDAct
->setDisabled(true);
1270 palAct
->setDisabled(true);
1271 ntscAct
->setDisabled(true);
1272 pauseAct
->setChecked(false);
1273 pauseAct
->setDisabled(false);
1274 showUntunedTankCircuit
= false;
1276 // Otherwise, we prepare for running regular software...
1279 // Should check for cartridgeLoaded here as well...!
1280 // We can clear it when toggling CDActive on, so that when we power cycle it
1281 // does the expected thing. Otherwise, if we use the file picker to insert a
1282 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1283 // works if the CD unit is active?
1284 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1287 WriteLog("GUI: Resetting Jaguar...\n");
1291 DebuggerResetWindows();
1292 CommonResetWindows();
1293 DACPauseAudioThread(false);
1298 // Toggle the emulator state, it can be either on or off
1299 void MainWin::ToggleRunState(void)
1301 startM68KTracing
= running
;
1307 // Set action buttons for the pause mode
1308 frameAdvanceAct
->setDisabled(false);
1309 pauseAct
->setChecked(true);
1310 pauseAct
->setDisabled(false);
1311 if (vjs
.softTypeDebugger
)
1313 traceStepIntoAct
->setDisabled(false);
1314 traceStepOverAct
->setDisabled(false);
1315 restartAct
->setDisabled(false);
1316 m68kDasmWin
->Use68KPCAddress();
1317 GPUDasmWin
->UseGPUPCAddress();
1318 DSPDasmWin
->UseDSPPCAddress();
1321 //if (!vjs.softTypeDebugger)
1323 // Restore the mouse pointer, if hidden:
1324 videoWidget
->CheckAndRestoreMouseCursor();
1326 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1328 uint32_t pixel
= videoWidget
->buffer
[i
];
1329 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1330 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1331 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1334 videoWidget
->updateGL();
1335 //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL;
1337 cpuBrowseWin
->HoldBPM();
1338 cpuBrowseWin
->HandleBPMContinue();
1344 frameAdvanceAct
->setDisabled(true);
1345 pauseAct
->setChecked(false);
1346 pauseAct
->setDisabled(false);
1347 if (vjs
.softTypeDebugger
)
1349 traceStepIntoAct
->setDisabled(true);
1350 traceStepOverAct
->setDisabled(true);
1351 restartAct
->setDisabled(true);
1352 BreakpointsWin
->RefreshContents();
1355 cpuBrowseWin
->UnholdBPM();
1358 emuStatusWin
->ResetM68KCycles();
1359 // Pause/unpause any running/non-running threads...
1360 DACPauseAudioThread(!running
);
1364 void MainWin::SetZoom100(void)
1371 void MainWin::SetZoom200(void)
1378 void MainWin::SetZoom300(void)
1385 void MainWin::SetNTSC(void)
1387 powerAct
->setIcon(powerRed
);
1388 timer
->setInterval(16);
1389 vjs
.hardwareTypeNTSC
= true;
1395 void MainWin::SetPAL(void)
1397 powerAct
->setIcon(powerGreen
);
1398 timer
->setInterval(20);
1399 vjs
.hardwareTypeNTSC
= false;
1405 void MainWin::ToggleBlur(void)
1407 vjs
.glFilter
= !vjs
.glFilter
;
1412 void MainWin::ShowAboutWin(void)
1418 void MainWin::ShowHelpWin(void)
1424 void MainWin::InsertCart(void)
1426 // Check to see if we did autorun, 'cause we didn't load anything in that
1428 if (!scannedSoftwareFolder
)
1430 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1431 scannedSoftwareFolder
= true;
1434 // If the emulator is running, we pause it here and unpause it later
1435 // if we dismiss the file selector without choosing anything
1436 if (running
&& powerButtonOn
)
1439 pauseForFileSelector
= true;
1442 filePickWin
->show();
1446 void MainWin::Unpause(void)
1448 // Here we unpause the emulator if it was paused when we went into the file selector
1449 if (pauseForFileSelector
)
1451 pauseForFileSelector
= false;
1453 // Some nutter might have unpaused while in the file selector, so check for that
1460 // Jaguar initialisation and load software file
1461 void MainWin::LoadSoftware(QString file
)
1463 running
= false; // Prevent bad things(TM) from happening...
1464 pauseForFileSelector
= false; // Reset the file selector pause flag
1466 // Setup BIOS in his own dedicated Jaguar memory
1467 #ifndef NEWMODELSBIOSHANDLER
1468 uint8_t * biosPointer
= jaguarBootROM
;
1470 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1472 biosPointer
= jaguarDevBootROM2
;
1475 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1477 SelectBIOS(vjs
.biosType
);
1480 // Turn 'on' the power to initialize the Jaguar
1481 powerAct
->setDisabled(false);
1482 powerAct
->setChecked(true);
1483 powerButtonOn
= false;
1486 // We have to load our software *after* the Jaguar RESET
1487 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1488 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1490 // This is icky because we've already done it
1491 // it gets worse :-P
1492 if (!vjs
.useJaguarBIOS
)
1494 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1499 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1500 if (vjs
.softTypeDebugger
)
1502 m68k_set_reg(M68K_REG_A6
, 0);
1503 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1505 //pauseAct->setDisabled(false);
1506 //pauseAct->setChecked(true);
1512 // Prevent the launch in case of software without a start address and without BIOS presence
1513 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1519 // Display the Atari Jaguar software which is running
1520 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1522 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1523 setWindowTitle(newTitle
);
1528 void MainWin::ToggleCDUsage(void)
1530 CDActive
= !CDActive
;
1532 // Set up the Jaguar CD for execution, otherwise, clear memory
1534 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1536 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1540 // Open, or display, the breakpoints list window
1541 void MainWin::ShowBreakpointsWin(void)
1543 BreakpointsWin
->show();
1544 BreakpointsWin
->RefreshContents();
1548 // Delete all breakpoints
1549 void MainWin::DeleteAllBreakpoints(void)
1551 cpuBrowseWin
->ResetBPM();
1553 ShowBreakpointsWin();
1557 // Disable all breakpoints
1558 void MainWin::DisableAllBreakpoints(void)
1560 cpuBrowseWin
->DisableBPM();
1562 ShowBreakpointsWin();
1566 // Open, or display, the new breakpoint function window
1567 void MainWin::ShowNewFunctionBreakpointWin(void)
1569 NewFunctionBreakpointWin
->SetFnctBreakpointWin(BreakpointsWin
);
1570 NewFunctionBreakpointWin
->show();
1571 ShowBreakpointsWin();
1575 // Display list of files found in cartridge
1576 void MainWin::ShowCartFilesListWin(void)
1578 CartFilesListWin
->show();
1579 CartFilesListWin
->RefreshContents();
1583 // Display the save dump pickup file
1584 void MainWin::ShowSaveDumpAsWin(void)
1586 SaveDumpAsWin
->show();
1591 void MainWin::DebuggerTraceStepInto(void)
1593 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1595 while (!SourcesWin
->CheckChangeLine())
1597 emuStatusWin
->UpdateM68KCycles(JaguarStepInto());
1602 emuStatusWin
->UpdateM68KCycles(JaguarStepInto());
1605 videoWidget
->updateGL();
1608 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1610 #warning "!!! Need to verify the Step Into function !!!"
1615 // Restart the Jaguar executable
1616 void MainWin::DebuggerRestart(void)
1621 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1622 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1624 dasmtabWidget
->setCurrentIndex(1); // set focus on the disasm M68K tab
1625 m68k_set_reg(M68K_REG_A6
, 0);
1626 m68k_brk_hitcounts_reset();
1627 emuStatusWin
->ResetM68KCycles();
1629 DebuggerResetWindows();
1630 CommonResetWindows();
1634 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1636 #warning "!!! Need to verify the Restart function !!!"
1642 void MainWin::DebuggerTraceStepOver(void)
1644 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1646 while (!SourcesWin
->CheckChangeLine())
1648 emuStatusWin
->UpdateM68KCycles(JaguarStepOver(0));
1653 emuStatusWin
->UpdateM68KCycles(JaguarStepOver(0));
1656 videoWidget
->updateGL();
1659 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1661 #warning "!!! Need to verify the Step Over function !!!"
1666 // Advance / Execute for one frame
1667 void MainWin::FrameAdvance(void)
1669 //printf("Frame Advance...\n");
1671 // Execute 1 frame, then exit (only useful in Pause mode)
1673 //if (!vjs.softTypeDebugger)
1674 videoWidget
->updateGL();
1675 //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL;
1677 // Need to execute 1 frames' worth of DSP thread as well :-/
1679 //m68kDasmWin->Use68KPCAddress();
1682 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1684 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1689 void MainWin::SetFullScreen(bool state
/*= true*/)
1691 if (!vjs
.softTypeDebugger
)
1695 mainWinPosition
= pos();
1697 statusBar()->hide();
1703 // This is needed because the fullscreen may happen on a different
1704 // screen than screen 0:
1705 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1706 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1707 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1708 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1709 double aspectRatio
= targetWidth
/ targetHeight
;
1710 // NOTE: Really should check here to see which dimension constrains the
1711 // other. Right now, we assume that height is the constraint.
1712 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1713 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1714 videoWidget
->fullscreen
= true;
1715 videoWidget
->outputWidth
= newWidth
;
1716 videoWidget
->setFixedSize(r
.width(), r
.height());
1721 // Seems Qt is fussy about this: showNormal() has to go first, or it
1722 // will keep the window stuck in a psuedo-fullscreen mode with no way
1723 // to get out of it (except closing the app).
1726 // Reset the video widget to windowed mode
1727 videoWidget
->offset
= 0;
1728 videoWidget
->fullscreen
= false;
1730 statusBar()->show();
1737 move(mainWinPosition
);
1743 void MainWin::ToggleFullScreen(void)
1745 fullScreen
= !fullScreen
;
1746 SetFullScreen(fullScreen
);
1751 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1753 exceptionvectortableBrowseWin
->show();
1754 exceptionvectortableBrowseWin
->RefreshContents();
1759 void MainWin::ShowLocalBrowserWin(void)
1761 LocalBrowseWin
->show();
1762 LocalBrowseWin
->RefreshContents();
1767 void MainWin::ShowCallStackBrowserWin(void)
1769 CallStackBrowseWin
->show();
1770 CallStackBrowseWin
->RefreshContents();
1774 void MainWin::ShowAllWatchBrowserWin(void)
1776 allWatchBrowseWin
->show();
1777 allWatchBrowseWin
->RefreshContents();
1781 void MainWin::ShowHeapAllocatorBrowserWin(void)
1783 heapallocatorBrowseWin
->show();
1784 heapallocatorBrowseWin
->RefreshContents();
1788 void MainWin::ShowMemoryBrowserWin(void)
1790 memBrowseWin
->show();
1791 memBrowseWin
->RefreshContents();
1795 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1797 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1799 mem1BrowseWin
[NumWin
]->show();
1800 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1805 void MainWin::ShowEmuStatusWin(void)
1807 emuStatusWin
->show();
1808 emuStatusWin
->RefreshContents();
1812 void MainWin::ShowStackBrowserWin(void)
1814 stackBrowseWin
->show();
1815 stackBrowseWin
->RefreshContents();
1819 void MainWin::ShowCPUBrowserWin(void)
1821 cpuBrowseWin
->show();
1822 cpuBrowseWin
->RefreshContents();
1826 // Show the OP browser window
1827 void MainWin::ShowOPBrowserWin(void)
1829 opBrowseWin
->show();
1830 opBrowseWin
->RefreshContents();
1834 // Show the HW registers browser window
1835 void MainWin::ShowHWRegsBrowserWin(void)
1837 hwRegsBrowseWin
->show();
1838 hwRegsBrowseWin
->RefreshContents();
1842 // Show the M68K browser window
1843 void MainWin::ShowM68KDasmBrowserWin(void)
1845 m68kDasmBrowseWin
->show();
1846 m68kDasmBrowseWin
->RefreshContents();
1850 void MainWin::ShowRISCDasmBrowserWin(void)
1852 riscDasmBrowseWin
->show();
1853 riscDasmBrowseWin
->RefreshContents();
1859 void MainWin::ShowDasmWin(void)
1862 // DasmWin->RefreshContents();
1868 void MainWin::ShowVideoOutputWin(void)
1870 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1871 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1872 //VideoOutputWindowCentrale->show();
1873 //memBrowseWin->show();
1874 VideoOutputWin
->show();
1875 VideoOutputWin
->SetupVideo(videoWidget
);
1876 //VideoOutputWin->adjustSize();
1877 //VideoOutputWin->RefreshContents(videoWidget);
1881 // Resize video window based on zoom factor
1882 // It doesn't apply in debugger mode as we use this window to display disassembly
1883 void MainWin::ResizeMainWindow(void)
1885 if (!vjs
.softTypeDebugger
)
1887 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1889 // Show the test pattern if user requested plzDontKillMyComputer mode
1890 if (!powerButtonOn
&& plzDontKillMyComputer
)
1892 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1894 if (vjs
.hardwareTypeNTSC
)
1896 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1900 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1911 void MainWin::ReadSettings(void)
1915 QSettings
settings("Underground Software", "Virtual Jaguar");
1917 //zoomLevel = settings.value("zoom", 2).toInt();
1918 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1919 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1921 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1922 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1923 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1924 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1925 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1926 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1927 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1928 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1929 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1930 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1931 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1932 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1933 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1934 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1935 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1936 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1937 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1938 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1939 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1940 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1941 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1943 // Read settings from the Debugger mode
1944 settings
.beginGroup("debugger");
1945 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1946 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1947 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1948 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1949 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1950 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1951 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1952 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1953 settings
.endGroup();
1955 // Read settings from the Alpine mode
1956 settings
.beginGroup("alpine");
1957 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1958 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1959 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1960 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1961 vjs
.allowM68KExceptionCatch
= settings
.value("M68KExceptionCatch", false).toBool();
1962 settings
.endGroup();
1964 // Read settings from the Keybindings
1965 settings
.beginGroup("keybindings");
1966 for (i
= 0; i
< KB_END
; i
++)
1968 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1970 settings
.endGroup();
1972 // Write important settings to the log file
1973 WriteLog("MainWin: Paths\n");
1974 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1975 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1976 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1977 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1978 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1979 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1980 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1981 WriteLog("MainWin: Misc.\n");
1982 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1985 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1986 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1987 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1988 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1989 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1990 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1991 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1992 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1993 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1994 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1995 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1996 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1997 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1998 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1999 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
2000 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
2001 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
2002 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
2003 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
2004 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
2005 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
2006 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
2008 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
2009 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
2010 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
2011 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
2012 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
2013 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
2014 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
2015 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
2016 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
2017 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
2018 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
2019 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
2020 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
2021 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
2022 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
2023 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
2024 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
2025 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
2026 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
2027 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
2028 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
2031 WriteLog("Read setting = Done\n");
2033 ReadProfiles(&settings
);
2034 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2039 // Default values will be used in case of no settings can be found
2041 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
2043 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
2045 // i.e., someone could drag it to another screen, close it, then disconnect that screen
2046 void MainWin::ReadUISettings(void)
2053 // Point on the emulator settings
2054 QSettings
settings("Underground Software", "Virtual Jaguar");
2055 settings
.beginGroup("ui");
2057 // Emulator main window UI information
2058 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
2059 size
= settings
.value("size", QSize(400, 400)).toSize();
2061 move(mainWinPosition
);
2062 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
2063 filePickWin
->move(pos
);
2065 // Video output information
2066 zoomLevel
= settings
.value("zoom", 2).toInt();
2068 // Emulator status UI information
2069 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2070 emuStatusWin
->move(pos
);
2071 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2073 // Alpine debug UI information (also needed by the Debugger)
2074 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2076 // CPU registers UI information
2077 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
2078 cpuBrowseWin
->move(pos
);
2079 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
2081 // Memory browser UI information
2082 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
2083 memBrowseWin
->move(pos
);
2084 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
2086 // Stack browser UI information
2087 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
2088 stackBrowseWin
->move(pos
);
2089 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2090 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2091 stackBrowseWin
->resize(size
);
2093 // OP (Object Processor) UI information
2094 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2095 opBrowseWin
->move(pos
);
2096 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2097 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2098 opBrowseWin
->resize(size
);
2100 // HW registers UI information
2101 pos
= settings
.value("hwRegsBrowseWinPos", QPoint(200, 200)).toPoint();
2102 hwRegsBrowseWin
->move(pos
);
2103 settings
.value("hwRegsBrowseWinIsVisible", false).toBool() ? ShowHWRegsBrowserWin() : void();
2104 size
= settings
.value("hwRegsBrowseWinSize", QSize(400, 400)).toSize();
2105 hwRegsBrowseWin
->resize(size
);
2107 // RISC disassembly UI information
2108 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2109 riscDasmBrowseWin
->move(pos
);
2110 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2112 // M68k disassembly UI information
2113 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2114 m68kDasmBrowseWin
->move(pos
);
2115 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2117 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2119 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2123 // Debugger UI information
2124 if (vjs
.softTypeDebugger
)
2127 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2128 m68kDasmWin
->move(pos
);
2129 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2130 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2131 GPUDasmWin
->move(pos
);
2132 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2133 DSPDasmWin
->move(pos
);
2135 // All watch browser UI information
2136 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2137 allWatchBrowseWin
->move(pos
);
2138 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2139 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2140 allWatchBrowseWin
->resize(size
);
2142 // Local browser UI information
2143 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2144 LocalBrowseWin
->move(pos
);
2145 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2146 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2147 LocalBrowseWin
->resize(size
);
2149 // Heap memory allocation browser UI information
2150 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2151 heapallocatorBrowseWin
->move(pos
);
2152 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2153 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2154 heapallocatorBrowseWin
->resize(size
);
2156 // Exception Vector Table UI Information
2157 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2158 exceptionvectortableBrowseWin
->move(pos
);
2159 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2160 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2161 exceptionvectortableBrowseWin
->resize(size
);
2163 // Call Stack browser UI information
2164 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2165 CallStackBrowseWin
->move(pos
);
2166 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2167 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2168 CallStackBrowseWin
->resize(size
);
2170 // cartridge directory and files UI information
2171 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2172 CartFilesListWin
->move(pos
);
2173 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2174 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2175 CartFilesListWin
->resize(size
);
2177 // Save dump UI information
2178 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2179 SaveDumpAsWin
->move(pos
);
2180 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2181 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2182 SaveDumpAsWin
->resize(size
);
2184 // save output video UI information
2185 pos
= settings
.value("VideoOutputWinPos", QPoint(200, 200)).toPoint();
2186 VideoOutputWin
->move(pos
);
2187 settings
.value("VideoOutputWinIsVisible", false).toBool() ? ShowVideoOutputWin() : void();
2188 size
= settings
.value("VideoOutputWinSize", QSize(400, 400)).toSize();
2189 VideoOutputWin
->resize(size
);
2191 // Breakpoints UI information
2192 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2193 BreakpointsWin
->move(pos
);
2194 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2195 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2196 BreakpointsWin
->resize(size
);
2197 // New function breakpoint UI information
2198 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2199 NewFunctionBreakpointWin
->move(pos
);
2200 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2201 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2202 NewFunctionBreakpointWin
->resize(size
);
2204 // Memories browser UI information
2205 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2207 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2208 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2209 mem1BrowseWin
[i
]->move(pos
);
2210 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2211 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2212 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2213 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2214 mem1BrowseWin
[i
]->resize(size
);
2218 settings
.endGroup();
2220 WriteLog("Read UI setting = Done\n");
2224 // Save the settings
2225 void MainWin::WriteSettings(void)
2229 // Point on the emulator settings
2230 QSettings
settings("Underground Software", "Virtual Jaguar");
2231 //settings.setValue("pos", pos());
2232 //settings.setValue("size", size());
2233 //settings.setValue("cartLoadPos", filePickWin->pos());
2235 //settings.setValue("zoom", zoomLevel);
2236 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2237 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2239 settings
.setValue("useJoystick", vjs
.useJoystick
);
2240 settings
.setValue("joyport", vjs
.joyport
);
2241 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2242 settings
.setValue("frameSkip", vjs
.frameSkip
);
2243 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2244 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2245 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2246 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2247 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2248 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2249 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2250 settings
.setValue("fullscreen", vjs
.fullscreen
);
2251 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2252 settings
.setValue("glFilterType", vjs
.glFilter
);
2253 settings
.setValue("renderType", vjs
.renderType
);
2254 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2255 settings
.setValue("biosType", vjs
.biosType
);
2256 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2257 //settings.setValue("JagBootROM", vjs.jagBootPath);
2258 //settings.setValue("CDBootROM", vjs.CDBootPath);
2259 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2260 settings
.setValue("ROMs", vjs
.ROMPath
);
2261 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2263 // Write settings from the Alpine mode
2264 settings
.beginGroup("alpine");
2265 settings
.setValue("refresh", vjs
.refresh
);
2266 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2267 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2268 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2269 settings
.setValue("M68KExceptionCatch", vjs
.allowM68KExceptionCatch
);
2270 settings
.endGroup();
2272 // Write settings from the Debugger mode
2273 settings
.beginGroup("debugger");
2274 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2275 settings
.setValue("NbrDisasmLines", (qulonglong
) vjs
.nbrdisasmlines
);
2276 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2277 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2278 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2279 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2280 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2281 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2282 settings
.endGroup();
2284 // Write settings from the Keybindings
2285 settings
.beginGroup("keybindings");
2286 for (i
= 0; i
< KB_END
; i
++)
2288 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2290 settings
.endGroup();
2293 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2294 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2295 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2296 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2297 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2298 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2299 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2300 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2301 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2302 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2303 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2304 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2305 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2306 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2307 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2308 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2309 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2310 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2311 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2312 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2313 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2315 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2316 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2317 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2318 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2319 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2320 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2321 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2322 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2323 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2324 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2325 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2326 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2327 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2328 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2329 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2330 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2331 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2332 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2333 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2334 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2335 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2338 WriteProfiles(&settings
);
2339 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2343 // Save the UI settings
2344 void MainWin::WriteUISettings(void)
2349 // Point on the emulator settings
2350 QSettings
settings("Underground Software", "Virtual Jaguar");
2351 settings
.beginGroup("ui");
2353 // Emulator UI information
2354 settings
.setValue("pos", pos());
2355 settings
.setValue("size", size());
2356 settings
.setValue("cartLoadPos", filePickWin
->pos());
2358 // Video output information
2359 settings
.setValue("zoom", zoomLevel
);
2361 // Common UI information
2362 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2363 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2365 // Alpine debug UI information (also needed by the Debugger)
2366 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2368 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2369 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2370 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2371 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2372 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2373 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2374 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2375 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2376 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2377 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2378 settings
.setValue("hwRegsBrowseWinPos", hwRegsBrowseWin
->pos());
2379 settings
.setValue("hwRegsBrowseWinIsVisible", hwRegsBrowseWin
->isVisible());
2380 settings
.setValue("hwRegsBrowseWinSize", hwRegsBrowseWin
->size());
2381 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2382 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2383 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2384 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2387 // Debugger UI information
2388 if (vjs
.softTypeDebugger
)
2391 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2392 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2393 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2394 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2396 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2397 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2398 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2399 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2400 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2401 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2402 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2403 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2404 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2405 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2406 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2407 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2408 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2409 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2410 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2411 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2412 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2413 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2414 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2415 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2416 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2417 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2418 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2419 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2420 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2421 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2422 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2423 settings
.setValue("VideoOutputWinPos", VideoOutputWin
->pos());
2424 settings
.setValue("VideoOutputWinIsVisible", VideoOutputWin
->isVisible());
2425 settings
.setValue("VideoOutputWinSize", VideoOutputWin
->size());
2427 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2429 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2430 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2431 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2432 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2433 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2434 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2438 settings
.endGroup();
2442 // Refresh alpine debug windows
2443 void MainWin::AlpineRefreshWindows(void)
2445 cpuBrowseWin
->RefreshContents();
2446 memBrowseWin
->RefreshContents();
2447 stackBrowseWin
->RefreshContents();
2448 opBrowseWin
->RefreshContents();
2449 riscDasmBrowseWin
->RefreshContents();
2450 m68kDasmBrowseWin
->RefreshContents();
2451 hwRegsBrowseWin
->RefreshContents();
2456 void MainWin::CommonResetWindows(void)
2462 void MainWin::CommonReset(void)
2467 // Reset soft debugger
2468 void MainWin::DebuggerReset(void)
2470 if (vjs
.softTypeDebugger
)
2472 DeleteAllBreakpoints();
2477 // Reset soft debugger windows
2478 void MainWin::DebuggerResetWindows(void)
2480 if (vjs
.softTypeDebugger
)
2482 FilesrcListWin
->Reset();
2483 allWatchBrowseWin
->Reset();
2484 heapallocatorBrowseWin
->Reset();
2485 BreakpointsWin
->Reset();
2486 CartFilesListWin
->Reset();
2487 SourcesWin
->Reset();
2488 //ResetAlpineWindows();
2493 // Refresh common windows
2494 void MainWin::CommonRefreshWindows(void)
2496 emuStatusWin
->RefreshContents();
2500 // Refresh view windows
2501 void MainWin::ViewRefreshWindows(void)
2503 CartFilesListWin
->RefreshContents();
2508 void MainWin::RefreshWindows(void)
2510 DebuggerRefreshWindows();
2511 CommonRefreshWindows();
2515 // Refresh soft debugger & alpine debug windows
2516 void MainWin::DebuggerRefreshWindows(void)
2518 if (vjs
.softTypeDebugger
)
2520 //VideoOutputWin->RefreshContents(videoWidget);
2521 FilesrcListWin
->RefreshContents();
2522 SourcesWin
->RefreshContents();
2523 m68kDasmWin
->RefreshContents();
2524 GPUDasmWin
->RefreshContents();
2525 DSPDasmWin
->RefreshContents();
2526 allWatchBrowseWin
->RefreshContents();
2527 LocalBrowseWin
->RefreshContents();
2528 CallStackBrowseWin
->RefreshContents();
2529 heapallocatorBrowseWin
->RefreshContents();
2530 BreakpointsWin
->RefreshContents();
2531 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2533 mem1BrowseWin
[i
]->RefreshContents(i
);
2536 AlpineRefreshWindows();
2537 ViewRefreshWindows();
2542 // Create and save screenshot
2543 void MainWin::MakeScreenshot(void)
2547 time_t now
= time(0);
2551 tstruct
= *localtime(&now
);
2552 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
);
2554 // Create screenshot
2555 screenshot
= videoWidget
->grabFrameBuffer();
2556 screenshot
.save((char *)Text
, "JPG", 100);