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
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->setCentralWidget()
211 //DasmWin = new DasmWindow();
212 //DasmWin = new DasmWindow(this);
213 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
214 LocalBrowseWin
= new LocalBrowserWindow(this);
215 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
216 BreakpointsWin
= new BreakpointsWindow(this);
217 NewFunctionBreakpointWin
= new NewFnctBreakpointWindow(this);
218 SaveDumpAsWin
= new SaveDumpAsWindow(this);
219 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
220 CallStackBrowseWin
= new CallStackBrowserWindow(this);
221 CartFilesListWin
= new CartFilesListWindow(this);
223 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
225 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
227 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
229 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
231 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
234 // Setup dock to display source code filenames tree
235 QDockWidget
*dockFiles
= new QDockWidget(tr("Files"), this);
236 dockFiles
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
238 addDockWidget(Qt::LeftDockWidgetArea
, dockFiles
);
239 mainWindowCentrale
->addAction(dockFiles
->toggleViewAction());
240 dockFiles
->setWidget(FilesrcListWin
= new FilesrcListWindow(this));
242 // Setup dock to display disassembly
243 QDockWidget
*dockDisasm
= new QDockWidget(tr("Disassembly"), this);
244 dockDisasm
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
245 addDockWidget(Qt::RightDockWidgetArea
, dockDisasm
);
246 mainWindowCentrale
->addAction(dockDisasm
->toggleViewAction());
247 dockDisasm
->setWidget(dasmtabWidget
= new QTabWidget(this));
249 dasmtabWidget
= new QTabWidget(this);
252 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
253 dasmtabWidget
->addTab(SourcesWin
= new SourcesWindow(this), tr("Sources"));
254 dasmtabWidget
->setCurrentIndex(dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000")));
255 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
256 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
257 connect(dasmtabWidget
, SIGNAL(currentChanged(const int)), this, SLOT(SelectdasmtabWidget(const int)));
259 setCentralWidget(dasmtabWidget
);
263 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
264 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
266 setUnifiedTitleAndToolBarOnMac(true);
269 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
270 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
271 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
272 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
273 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
276 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
277 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
278 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
279 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
280 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
281 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
282 powerAct
->setCheckable(true);
283 powerAct
->setChecked(false);
284 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
288 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
289 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
290 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
291 pauseAct
->setStatusTip(tr("Toggles the running state"));
292 pauseAct
->setCheckable(true);
293 pauseAct
->setDisabled(true);
294 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
295 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
296 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
299 screenshotAct
= new QAction(QIcon(":/res/screenshot.png"), tr("&Screenshot"), this);
300 screenshotAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSCREENSHOT
].KBSettingValue
)));
301 screenshotAct
->setShortcutContext(Qt::ApplicationShortcut
);
302 screenshotAct
->setCheckable(false);
303 screenshotAct
->setDisabled(false);
304 connect(screenshotAct
, SIGNAL(triggered()), this, SLOT(MakeScreenshot()));
307 zoomActs
= new QActionGroup(this);
308 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
309 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
310 x1Act
->setCheckable(true);
311 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
312 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
313 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
314 x2Act
->setCheckable(true);
315 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
316 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
317 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
318 x3Act
->setCheckable(true);
319 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
322 tvTypeActs
= new QActionGroup(this);
323 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
324 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
325 ntscAct
->setCheckable(true);
326 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
327 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
328 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
329 palAct
->setCheckable(true);
330 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
333 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
334 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
335 blurAct
= new QAction(blur
, tr("Blur"), this);
336 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
337 blurAct
->setCheckable(true);
338 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
341 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
342 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
343 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
346 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
347 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
348 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
350 // File pickup action
351 if (!vjs
.softTypeDebugger
)
353 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
354 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
358 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
359 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
361 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
362 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
363 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
365 // Configuration action
366 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
367 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
368 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
369 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
370 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
372 // Emulation status action
373 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
374 emustatusAct
->setStatusTip(tr("Emulator status"));
375 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
376 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
377 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
380 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
381 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
382 useCDAct
->setCheckable(true);
383 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
385 // Frame advance action
386 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
387 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
388 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
389 frameAdvanceAct
->setDisabled(true);
390 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
393 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
394 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
395 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
396 fullScreenAct
->setCheckable(true);
397 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
399 // Actions dedicated to debugger mode
400 if (vjs
.softTypeDebugger
)
403 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
404 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
405 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
406 restartAct
->setCheckable(false);
407 restartAct
->setDisabled(true);
408 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
411 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
412 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
413 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
414 traceStepOverAct
->setCheckable(false);
415 traceStepOverAct
->setDisabled(true);
416 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
418 // Trace into tracing
419 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
420 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
421 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
422 traceStepIntoAct
->setCheckable(false);
423 traceStepIntoAct
->setDisabled(true);
424 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
426 // Function breakpoint
427 newFunctionBreakpointAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
428 newFunctionBreakpointAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFUNCTIONBREAKPOINT
].KBSettingValue
)));
429 connect(newFunctionBreakpointAct
, SIGNAL(triggered()), this, SLOT(ShowNewFunctionBreakpointWin()));
430 BreakpointsAct
= new QAction(QIcon(":/res/debug-breakpoints.png"), tr("&Breakpoints"), this);
431 BreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBBREAKPOINTS
].KBSettingValue
)));
432 connect(BreakpointsAct
, SIGNAL(triggered()), this, SLOT(ShowBreakpointsWin()));
433 deleteAllBreakpointsAct
= new QAction(QIcon(":/res/debug-deleteallbreakpoints.png"), tr("&Delete All Breakpoints"), this);
434 deleteAllBreakpointsAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBDELETEALLBREAKPOINTS
].KBSettingValue
)));
435 connect(deleteAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DeleteAllBreakpoints()));
436 disableAllBreakpointsAct
= new QAction(QIcon(":/res/debug-disableallbreakpoints.png"), tr("&Disable All Breakpoints"), this);
437 connect(disableAllBreakpointsAct
, SIGNAL(triggered()), this, SLOT(DisableAllBreakpoints()));
440 saveDumpAsAct
= new QAction(tr("&Save Dump As..."), this);
441 saveDumpAsAct
->setCheckable(false);
442 saveDumpAsAct
->setDisabled(false);
443 connect(saveDumpAsAct
, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));
445 //VideoOutputAct = new QAction(tr("Output Video"), this);
446 //VideoOutputAct->setStatusTip(tr("Shows the output video window"));
447 //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
449 //DasmAct = new QAction(tr("Disassembly"), this);
450 //DasmAct->setStatusTip(tr("Shows the disassembly window"));
451 //connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
453 // Exception vector table window
454 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
455 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
456 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
458 // All watch variables window
459 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
460 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
461 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
463 // Local variables window
464 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Locals"), this);
465 LocalBrowseAct
->setStatusTip(tr("Shows Locals browser window"));
466 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
468 // Heap (memory) allocation window
469 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
470 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
471 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
474 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
475 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
476 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
479 CartFilesListAct
= new QAction(QIcon(""), tr("Directory and files"), this);
480 CartFilesListAct
->setStatusTip(tr("List of the files in the cartridge's directory structure"));
481 connect(CartFilesListAct
, SIGNAL(triggered()), this, SLOT(ShowCartFilesListWin()));
484 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
485 QSignalMapper
*signalMapper
= new QSignalMapper(this);
487 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
489 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
491 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
494 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
495 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
496 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
497 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
498 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
499 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
503 // Memory browser window action
504 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
505 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
506 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
508 // Stack browser window action
509 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
510 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
511 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
513 // CPUs (M68000, GPU & DSP browser window action
514 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
515 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
516 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
518 // OP browser window action
519 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
520 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
521 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
523 // M68000 disassembly browser window
524 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
525 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
526 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
528 // HW registers browser window
529 hwRegsBrowseAct
= new QAction(QIcon(":/res/tool-hw-regs.png"), tr("HW Registers Browser"), this);
530 hwRegsBrowseAct
->setStatusTip(tr("Shows the HW registers browser window"));
531 connect(hwRegsBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHWRegsBrowserWin()));
533 // Risc (DSP / GPU) disassembly browser window
534 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
535 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
536 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
538 // Misc. connections...
539 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
540 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
544 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
545 fileMenu
->addAction(powerAct
);
546 if (!vjs
.softTypeDebugger
)
548 fileMenu
->addAction(pauseAct
);
549 // fileMenu->addAction(frameAdvanceAct);
551 fileMenu
->addAction(filePickAct
);
552 fileMenu
->addAction(useCDAct
);
553 fileMenu
->addAction(configAct
);
554 fileMenu
->addAction(emustatusAct
);
555 fileMenu
->addSeparator();
556 fileMenu
->addAction(quitAppAct
);
558 // Alpine and debugger menus
559 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
562 debugMenu
= menuBar()->addMenu(tr("&Debug"));
564 // Create debugger menu
565 if (vjs
.softTypeDebugger
)
568 viewMenu
= menuBar()->addMenu(tr("&View"));
571 viewCartMenu
= viewMenu
->addMenu(tr("&Cartridge"));
572 viewCartMenu
->addAction(CartFilesListAct
);
574 viewCartMenu
->addSeparator();
575 viewCartMenu
->addAction(CartStreamsAct
);
579 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
580 debugWindowsMenu
->addAction(BreakpointsAct
);
581 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
582 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
583 debugWindowsMenu
->addSeparator();
585 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
586 debugWindowOutputMenu
->addAction(VideoOutputAct
);
587 debugWindowsMenu
->addSeparator();
589 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
590 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
591 debugWindowsMenu
->addAction(LocalBrowseAct
);
592 debugWindowsMenu
->addSeparator();
593 debugWindowsMenu
->addAction(CallStackBrowseAct
);
594 debugWindowsMenu
->addSeparator();
595 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
596 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
597 debugWindowsMemoryMenu
->addSeparator();
598 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
600 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
602 debugWindowsMenu
->addSeparator();
603 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
604 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
605 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
606 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
607 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
608 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
609 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
610 debugWindowsBrowsesMenu
->addAction(hwRegsBrowseAct
);
611 debugMenu
->addSeparator();
612 debugMenu
->addAction(pauseAct
);
613 debugMenu
->addAction(frameAdvanceAct
);
614 debugMenu
->addAction(restartAct
);
615 debugMenu
->addSeparator();
616 debugMenu
->addAction(traceStepIntoAct
);
617 debugMenu
->addAction(traceStepOverAct
);
618 debugMenu
->addSeparator();
619 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
620 debugNewBreakpointMenu
->addAction(newFunctionBreakpointAct
);
621 debugMenu
->addAction(deleteAllBreakpointsAct
);
622 debugMenu
->addAction(disableAllBreakpointsAct
);
623 debugMenu
->addSeparator();
624 debugMenu
->addAction(saveDumpAsAct
);
626 debugMenu
->addSeparator();
627 debugMenu
->addAction(DasmAct
);
632 // Create alpine menu
633 debugMenu
->addAction(memBrowseAct
);
634 debugMenu
->addAction(stackBrowseAct
);
635 debugMenu
->addAction(cpuBrowseAct
);
636 debugMenu
->addAction(opBrowseAct
);
637 debugMenu
->addAction(m68kDasmBrowseAct
);
638 debugMenu
->addAction(riscDasmBrowseAct
);
639 debugMenu
->addAction(hwRegsBrowseAct
);
644 helpMenu
= menuBar()->addMenu(tr("&Help"));
645 helpMenu
->addAction(helpAct
);
646 helpMenu
->addAction(aboutAct
);
650 toolbar
= addToolBar(tr("System"));
651 toolbar
->addAction(powerAct
);
652 if (!vjs
.softTypeDebugger
)
654 toolbar
->addAction(pauseAct
);
655 toolbar
->addAction(frameAdvanceAct
);
657 toolbar
->addAction(filePickAct
);
658 toolbar
->addAction(useCDAct
);
659 toolbar
->addSeparator();
660 if (!vjs
.softTypeDebugger
)
662 toolbar
->addAction(screenshotAct
);
663 toolbar
->addSeparator();
664 toolbar
->addAction(x1Act
);
665 toolbar
->addAction(x2Act
);
666 toolbar
->addAction(x3Act
);
667 toolbar
->addSeparator();
668 toolbar
->addAction(ntscAct
);
669 toolbar
->addAction(palAct
);
670 toolbar
->addSeparator();
671 toolbar
->addAction(blurAct
);
672 toolbar
->addAction(fullScreenAct
);
676 debuggerbar
= addToolBar(tr("&Debugger"));
677 debuggerbar
->addAction(pauseAct
);
678 debuggerbar
->addAction(frameAdvanceAct
);
679 debuggerbar
->addAction(restartAct
);
680 debuggerbar
->addSeparator();
681 debuggerbar
->addAction(traceStepIntoAct
);
682 debuggerbar
->addAction(traceStepOverAct
);
683 debuggerbar
->addSeparator();
684 debuggerbar
->addAction(BreakpointsAct
);
687 if (vjs
.hardwareTypeAlpine
)
689 debugbar
= addToolBar(tr("&Debug"));
690 debugbar
->addAction(memBrowseAct
);
691 debugbar
->addAction(stackBrowseAct
);
692 debugbar
->addAction(cpuBrowseAct
);
693 debugbar
->addAction(opBrowseAct
);
694 debugbar
->addAction(m68kDasmBrowseAct
);
695 debugbar
->addAction(riscDasmBrowseAct
);
696 debugbar
->addAction(hwRegsBrowseAct
);
699 // Add actions to the main window, as hiding widgets with them
701 addAction(fullScreenAct
);
702 addAction(quitAppAct
);
703 addAction(configAct
);
704 addAction(emustatusAct
);
706 addAction(filePickAct
);
707 addAction(frameAdvanceAct
);
710 statusBar()->showMessage(tr("Ready"));
712 // Do this in case original size isn't correct (mostly for the first-run case)
715 WriteLog("Window creation done\n");
717 // Create our test pattern NTSC bitmap
718 WriteLog("Test pattern 1 bitmap\n");
720 QImage
tempImg(":/res/test-pattern.jpg");
721 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
723 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
725 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
727 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
729 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
730 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
734 // Create our test pattern PAL bitmap
735 WriteLog("Test pattern 2 bitmap\n");
737 QImage
tempImg2(":/res/test-pattern-pal.jpg");
738 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
740 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
742 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
744 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
746 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
747 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
751 // Set up timer based loop for animation...
752 timer
= new QTimer(this);
753 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
755 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
756 // This is because it's discarding the 0.6666... on the end of the fraction.
757 // Alas, 6 doesn't divide cleanly into 10. :-P
758 //Should we defer this until SyncUI? Probably.
759 //No, it doesn't work, because it uses setInterval() instead of start()...
760 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
762 // We set this initially, to make VJ behave somewhat as it would if no
763 // cart were inserted and the BIOS was set as active...
764 jaguarCartInserted
= true;
765 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
766 WriteLog("VJ: Initializing jaguar subsystem...\n");
769 #ifndef NEWMODELSBIOSHANDLER
770 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
771 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
773 SelectBIOS(vjs
.biosType
);
776 // Prevent the file scanner from running if filename passed
777 // in on the command line...
781 // Load up the default ROM if in Alpine mode:
782 if (vjs
.hardwareTypeAlpine
)
784 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
786 // If regular load failed, try just a straight file load
787 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
789 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
792 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
794 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
796 // Attempt to load/run the ABS file...
797 LoadSoftware(vjs
.absROMPath
);
798 #ifndef NEWMODELSBIOSHANDLER
799 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
801 SelectBIOS(vjs
.biosType
);
803 // Prevent the scanner from running...
807 // Load up the default ROM if in Debugger mode:
808 if (vjs
.softTypeDebugger
)
810 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
812 // If regular load failed, try just a straight file load
813 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
815 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
818 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
820 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
822 // Attempt to load/run the ABS file...
823 LoadSoftware(vjs
.absROMPath
);
824 #ifndef NEWMODELSBIOSHANDLER
825 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
826 // Prevent the scanner from running...
828 SelectBIOS(vjs
.biosType
);
833 // Run the scanner if nothing passed in and *not* Alpine mode...
834 // NB: Really need to look into caching the info scanned in here...
835 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
836 scannedSoftwareFolder
= true;
840 void MainWin::LoadFile(QString file
)
846 void MainWin::SyncUI(void)
848 // Set toolbar buttons/menus based on settings read in (sync the UI)...
849 // (Really, this is to sync command line options passed in)
850 blurAct
->setChecked(vjs
.glFilter
);
851 x1Act
->setChecked(zoomLevel
== 1);
852 x2Act
->setChecked(zoomLevel
== 2);
853 x3Act
->setChecked(zoomLevel
== 3);
854 // running = powerAct->isChecked();
855 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
856 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
857 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
859 fullScreenAct
->setChecked(vjs
.fullscreen
);
860 fullScreen
= vjs
.fullscreen
;
861 SetFullScreen(fullScreen
);
863 // Reset the timer to be what was set in the command line (if any):
864 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
865 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
870 void MainWin::SelectdasmtabWidget(const int Index
)
875 SourcesWin
->RefreshContents();
880 void MainWin::closeEvent(QCloseEvent
* event
)
883 // This should only be done by the config dialog
886 event
->accept(); // ignore() if can't close for some reason
890 void MainWin::keyPressEvent(QKeyEvent
* e
)
892 #ifndef VJ_REMOVE_DEV_CODE
894 //extern bool startM68KTracing; // moved to jaguar.h
896 extern int blit_start_log
;
898 extern bool startConciseBlitLogging
;
901 // We ignore the Alt key for now, since it causes problems with the GUI
902 if (e
->key() == Qt::Key_Alt
)
907 // Bar this shite from release versions kthxbai
908 #ifndef VJ_REMOVE_DEV_CODE
909 else if (e
->key() == Qt::Key_F11
)
911 startM68KTracing
= true;
915 else if (e
->key() == Qt::Key_F12
)
917 blit_start_log
= true;
921 else if (e
->key() == Qt::Key_F10
)
923 startConciseBlitLogging
= true;
928 else if (e
->key() == Qt::Key_F8
)
930 // ggn: For extra NYAN pleasure...
931 // ggn: There you go James :P
932 // Shamus: Thanks for the patch! :-D
933 WriteLog(" o + + +\n");
934 WriteLog("+ o o + o\n");
935 WriteLog("-_-_-_-_-_-_-_,------, o \n");
936 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
937 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
938 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
939 WriteLog("+ o o + o\n");
946 This is done now by a QAction...
947 if (e->key() == Qt::Key_F9)
957 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
959 // We ignore the Alt key for now, since it causes problems with the GUI
960 if (e
->key() == Qt::Key_Alt
)
966 HandleKeys(e
, false);
970 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
972 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
973 // We kill bad key combos here, before they can get to the emulator...
974 // This also kills the illegal instruction problem that cropped up in
977 // First, settle key states...
978 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
979 keyHeld
[P1LEFT
] = state
;
980 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
981 keyHeld
[P1RIGHT
] = state
;
982 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
983 keyHeld
[P1UP
] = state
;
984 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
985 keyHeld
[P1DOWN
] = state
;
986 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
987 keyHeld
[P2LEFT
] = state
;
988 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
989 keyHeld
[P2RIGHT
] = state
;
990 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
991 keyHeld
[P2UP
] = state
;
992 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
993 keyHeld
[P2DOWN
] = state
;
995 // Next, check for conflicts and kill 'em if there are any...
996 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
997 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
999 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
1000 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
1002 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
1003 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
1005 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
1006 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
1008 // No bad combos exist now, let's stuff the emulator key buffers...!
1009 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1011 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
1012 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
1014 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
1015 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
1021 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
1023 void MainWin::HandleGamepads(void)
1027 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
1029 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1030 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
1032 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
1033 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
1038 void MainWin::Open(void)
1043 void MainWin::Configure(void)
1045 // Call the configuration dialog and update settings
1046 ConfigDialog
dlg(this);
1048 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
1049 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
1050 dlg
.controllerTab1
->SetupLastUsedProfile();
1051 // maybe instead of this, we tell the controller tab to work on a copy that gets
1052 // written if the user hits 'OK'.
1053 SaveProfiles(); // Just in case user cancels
1055 if (dlg
.exec() == false)
1061 QString before
= vjs
.ROMPath
;
1062 QString alpineBefore
= vjs
.alpineROMPath
;
1063 QString absBefore
= vjs
.absROMPath
;
1064 // bool audioBefore = vjs.audioEnabled;
1065 bool audioBefore
= vjs
.DSPEnabled
;
1066 dlg
.UpdateVJSettings();
1067 QString after
= vjs
.ROMPath
;
1068 QString alpineAfter
= vjs
.alpineROMPath
;
1069 QString absAfter
= vjs
.absROMPath
;
1070 // bool audioAfter = vjs.audioEnabled;
1071 bool audioAfter
= vjs
.DSPEnabled
;
1073 bool allowOld
= allowUnknownSoftware
;
1075 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
1076 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
1077 AutoConnectProfiles();
1079 // We rescan the "software" folder if the user either changed the path or
1080 // checked/unchecked the "Allow unknown files" option in the config dialog.
1081 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
1082 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1084 // If the "Alpine" ROM is changed, then let's load it...
1085 if (alpineBefore
!= alpineAfter
)
1087 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
1089 // Oh crap, we couldn't get the file! Alert the media!
1091 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
1092 msg
.setIcon(QMessageBox::Warning
);
1097 // If the "ABS" ROM is changed, then let's load it...
1098 if (absBefore
!= absAfter
)
1100 if (!JaguarLoadFile(vjs
.absROMPath
))
1102 // Oh crap, we couldn't get the file! Alert the media!
1104 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
1105 msg
.setIcon(QMessageBox::Warning
);
1110 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1111 // since it's running in the host audio IRQ...
1112 if (audioBefore
!= audioAfter
)
1118 // Just in case we crash before a clean exit...
1126 // Here's the main emulator loop
1128 void MainWin::Timer(void)
1131 static uint32_t ntscTickCount
;
1132 if (vjs
.hardwareTypeNTSC
)
1136 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1143 if (showUntunedTankCircuit
)
1145 // Some machines can't handle this, so we give them the option to disable it. :-)
1146 if (!plzDontKillMyComputer
)
1148 // if (!vjs.softTypeDebugger)
1150 // Random hash & trash
1151 // We try to simulate an untuned tank circuit here... :-)
1152 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1154 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1156 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1164 // Otherwise, run the Jaguar simulation
1167 //if (!vjs.softTypeDebugger)
1168 videoWidget
->HandleMouseHiding();
1170 static uint32_t refresh
= 0;
1171 // Do autorefresh on debug windows
1172 // Have to be careful, too much causes the emulator to slow way down!
1173 if (refresh
== vjs
.refresh
)
1175 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1177 AlpineRefreshWindows();
1178 //memBrowseWin->RefreshContents();
1179 //cpuBrowseWin->RefreshContents();
1181 CommonRefreshWindows();
1190 //if (!vjs.softTypeDebugger)
1191 videoWidget
->updateGL();
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();
1336 cpuBrowseWin
->HoldBPM();
1337 cpuBrowseWin
->HandleBPMContinue();
1343 frameAdvanceAct
->setDisabled(true);
1344 pauseAct
->setChecked(false);
1345 pauseAct
->setDisabled(false);
1346 if (vjs
.softTypeDebugger
)
1348 traceStepIntoAct
->setDisabled(true);
1349 traceStepOverAct
->setDisabled(true);
1350 restartAct
->setDisabled(true);
1351 BreakpointsWin
->RefreshContents();
1354 cpuBrowseWin
->UnholdBPM();
1357 emuStatusWin
->ResetM68KCycles();
1358 // Pause/unpause any running/non-running threads...
1359 DACPauseAudioThread(!running
);
1363 void MainWin::SetZoom100(void)
1370 void MainWin::SetZoom200(void)
1377 void MainWin::SetZoom300(void)
1384 void MainWin::SetNTSC(void)
1386 powerAct
->setIcon(powerRed
);
1387 timer
->setInterval(16);
1388 vjs
.hardwareTypeNTSC
= true;
1394 void MainWin::SetPAL(void)
1396 powerAct
->setIcon(powerGreen
);
1397 timer
->setInterval(20);
1398 vjs
.hardwareTypeNTSC
= false;
1404 void MainWin::ToggleBlur(void)
1406 vjs
.glFilter
= !vjs
.glFilter
;
1411 void MainWin::ShowAboutWin(void)
1417 void MainWin::ShowHelpWin(void)
1423 void MainWin::InsertCart(void)
1425 // Check to see if we did autorun, 'cause we didn't load anything in that
1427 if (!scannedSoftwareFolder
)
1429 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1430 scannedSoftwareFolder
= true;
1433 // If the emulator is running, we pause it here and unpause it later
1434 // if we dismiss the file selector without choosing anything
1435 if (running
&& powerButtonOn
)
1438 pauseForFileSelector
= true;
1441 filePickWin
->show();
1445 void MainWin::Unpause(void)
1447 // Here we unpause the emulator if it was paused when we went into the file selector
1448 if (pauseForFileSelector
)
1450 pauseForFileSelector
= false;
1452 // Some nutter might have unpaused while in the file selector, so check for that
1459 // Jaguar initialisation and load software file
1460 void MainWin::LoadSoftware(QString file
)
1462 running
= false; // Prevent bad things(TM) from happening...
1463 pauseForFileSelector
= false; // Reset the file selector pause flag
1465 // Setup BIOS in his own dedicated Jaguar memory
1466 #ifndef NEWMODELSBIOSHANDLER
1467 uint8_t * biosPointer
= jaguarBootROM
;
1469 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1471 biosPointer
= jaguarDevBootROM2
;
1474 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1476 SelectBIOS(vjs
.biosType
);
1479 // Turn 'on' the power to initialize the Jaguar
1480 powerAct
->setDisabled(false);
1481 powerAct
->setChecked(true);
1482 powerButtonOn
= false;
1485 // We have to load our software *after* the Jaguar RESET
1486 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1487 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set stack in the M68000's Reset SP
1489 // This is icky because we've already done it
1490 // it gets worse :-P
1491 if (!vjs
.useJaguarBIOS
)
1493 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1498 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1499 if (vjs
.softTypeDebugger
)
1501 m68k_set_reg(M68K_REG_A6
, 0);
1502 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1504 //pauseAct->setDisabled(false);
1505 //pauseAct->setChecked(true);
1511 // Prevent the launch in case of software without a start address and without BIOS presence
1512 if (!vjs
.useJaguarBIOS
&& !jaguarRunAddress
)
1518 // Display the Atari Jaguar software which is running
1519 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1521 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1522 setWindowTitle(newTitle
);
1527 void MainWin::ToggleCDUsage(void)
1529 CDActive
= !CDActive
;
1531 // Set up the Jaguar CD for execution, otherwise, clear memory
1533 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1535 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1539 // Open, or display, the breakpoints list window
1540 void MainWin::ShowBreakpointsWin(void)
1542 BreakpointsWin
->show();
1543 BreakpointsWin
->RefreshContents();
1547 // Delete all breakpoints
1548 void MainWin::DeleteAllBreakpoints(void)
1550 cpuBrowseWin
->ResetBPM();
1552 ShowBreakpointsWin();
1556 // Disable all breakpoints
1557 void MainWin::DisableAllBreakpoints(void)
1559 cpuBrowseWin
->DisableBPM();
1561 ShowBreakpointsWin();
1565 // Open, or display, the new breakpoint function window
1566 void MainWin::ShowNewFunctionBreakpointWin(void)
1568 NewFunctionBreakpointWin
->SetFnctBreakpointWin(BreakpointsWin
);
1569 NewFunctionBreakpointWin
->show();
1570 ShowBreakpointsWin();
1574 // Display list of files found in cartridge
1575 void MainWin::ShowCartFilesListWin(void)
1577 CartFilesListWin
->show();
1578 CartFilesListWin
->RefreshContents();
1582 // Display the save dump pickup file
1583 void MainWin::ShowSaveDumpAsWin(void)
1585 SaveDumpAsWin
->show();
1590 void MainWin::DebuggerTraceStepInto(void)
1592 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1594 while (!SourcesWin
->CheckChangeLine())
1596 emuStatusWin
->UpdateM68KCycles(JaguarStepInto());
1601 emuStatusWin
->UpdateM68KCycles(JaguarStepInto());
1604 videoWidget
->updateGL();
1607 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1609 #warning "!!! Need to verify the Step Into function !!!"
1614 // Restart the Jaguar executable
1615 void MainWin::DebuggerRestart(void)
1620 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1621 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1623 dasmtabWidget
->setCurrentIndex(1); // set focus on the disasm M68K tab
1624 m68k_set_reg(M68K_REG_A6
, 0);
1625 m68k_brk_hitcounts_reset();
1626 emuStatusWin
->ResetM68KCycles();
1628 DebuggerResetWindows();
1629 CommonResetWindows();
1633 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1635 #warning "!!! Need to verify the Restart function !!!"
1641 void MainWin::DebuggerTraceStepOver(void)
1643 if (SourcesWin
->isVisible() && SourcesWin
->GetTraceStatus())
1645 while (!SourcesWin
->CheckChangeLine())
1647 emuStatusWin
->UpdateM68KCycles(JaguarStepOver(0));
1652 emuStatusWin
->UpdateM68KCycles(JaguarStepOver(0));
1655 videoWidget
->updateGL();
1658 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1660 #warning "!!! Need to verify the Step Over function !!!"
1665 // Advance / Execute for one frame
1666 void MainWin::FrameAdvance(void)
1668 //printf("Frame Advance...\n");
1670 // Execute 1 frame, then exit (only useful in Pause mode)
1672 //if (!vjs.softTypeDebugger)
1673 videoWidget
->updateGL();
1675 // Need to execute 1 frames' worth of DSP thread as well :-/
1677 //m68kDasmWin->Use68KPCAddress();
1680 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1682 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1687 void MainWin::SetFullScreen(bool state
/*= true*/)
1689 if (!vjs
.softTypeDebugger
)
1693 mainWinPosition
= pos();
1695 statusBar()->hide();
1701 // This is needed because the fullscreen may happen on a different
1702 // screen than screen 0:
1703 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1704 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1705 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1706 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1707 double aspectRatio
= targetWidth
/ targetHeight
;
1708 // NOTE: Really should check here to see which dimension constrains the
1709 // other. Right now, we assume that height is the constraint.
1710 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1711 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1712 videoWidget
->fullscreen
= true;
1713 videoWidget
->outputWidth
= newWidth
;
1714 videoWidget
->setFixedSize(r
.width(), r
.height());
1719 // Seems Qt is fussy about this: showNormal() has to go first, or it
1720 // will keep the window stuck in a psuedo-fullscreen mode with no way
1721 // to get out of it (except closing the app).
1724 // Reset the video widget to windowed mode
1725 videoWidget
->offset
= 0;
1726 videoWidget
->fullscreen
= false;
1728 statusBar()->show();
1735 move(mainWinPosition
);
1741 void MainWin::ToggleFullScreen(void)
1743 fullScreen
= !fullScreen
;
1744 SetFullScreen(fullScreen
);
1749 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1751 exceptionvectortableBrowseWin
->show();
1752 exceptionvectortableBrowseWin
->RefreshContents();
1757 void MainWin::ShowLocalBrowserWin(void)
1759 LocalBrowseWin
->show();
1760 LocalBrowseWin
->RefreshContents();
1765 void MainWin::ShowCallStackBrowserWin(void)
1767 CallStackBrowseWin
->show();
1768 CallStackBrowseWin
->RefreshContents();
1772 void MainWin::ShowAllWatchBrowserWin(void)
1774 allWatchBrowseWin
->show();
1775 allWatchBrowseWin
->RefreshContents();
1779 void MainWin::ShowHeapAllocatorBrowserWin(void)
1781 heapallocatorBrowseWin
->show();
1782 heapallocatorBrowseWin
->RefreshContents();
1786 void MainWin::ShowMemoryBrowserWin(void)
1788 memBrowseWin
->show();
1789 memBrowseWin
->RefreshContents();
1793 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1795 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1797 mem1BrowseWin
[NumWin
]->show();
1798 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1803 void MainWin::ShowEmuStatusWin(void)
1805 emuStatusWin
->show();
1806 emuStatusWin
->RefreshContents();
1810 void MainWin::ShowStackBrowserWin(void)
1812 stackBrowseWin
->show();
1813 stackBrowseWin
->RefreshContents();
1817 void MainWin::ShowCPUBrowserWin(void)
1819 cpuBrowseWin
->show();
1820 cpuBrowseWin
->RefreshContents();
1824 // Show the OP browser window
1825 void MainWin::ShowOPBrowserWin(void)
1827 opBrowseWin
->show();
1828 opBrowseWin
->RefreshContents();
1832 // Show the HW registers browser window
1833 void MainWin::ShowHWRegsBrowserWin(void)
1835 hwRegsBrowseWin
->show();
1836 hwRegsBrowseWin
->RefreshContents();
1840 // Show the M68K browser window
1841 void MainWin::ShowM68KDasmBrowserWin(void)
1843 m68kDasmBrowseWin
->show();
1844 m68kDasmBrowseWin
->RefreshContents();
1848 void MainWin::ShowRISCDasmBrowserWin(void)
1850 riscDasmBrowseWin
->show();
1851 riscDasmBrowseWin
->RefreshContents();
1857 void MainWin::ShowDasmWin(void)
1860 // DasmWin->RefreshContents();
1867 void MainWin::ShowVideoOutputWin(void)
1869 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1870 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1871 //VideoOutputWindowCentrale->show();
1872 //memBrowseWin->show();
1873 //VideoOutputWin->show();
1874 //VideoOutputWin->RefreshContents(videoWidget);
1879 // Resize video window based on zoom factor
1880 // It doesn't apply in debugger mode as we use this window to display disassembly
1881 void MainWin::ResizeMainWindow(void)
1883 if (!vjs
.softTypeDebugger
)
1885 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
, zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1887 // Show the test pattern if user requested plzDontKillMyComputer mode
1888 if (!powerButtonOn
&& plzDontKillMyComputer
)
1890 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1892 if (vjs
.hardwareTypeNTSC
)
1894 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1898 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1909 void MainWin::ReadSettings(void)
1913 QSettings
settings("Underground Software", "Virtual Jaguar");
1915 //zoomLevel = settings.value("zoom", 2).toInt();
1916 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1917 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1919 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1920 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1921 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1922 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1923 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1924 vjs
.useRetailBIOS
= settings
.value("useRetailBIOS", false).toBool();
1925 vjs
.useDevBIOS
= settings
.value("useDevBIOS", false).toBool();
1926 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1927 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1928 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1929 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1930 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1931 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1932 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1933 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1934 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1935 vjs
.jaguarModel
= settings
.value("jaguarModel", JAG_M_SERIES
).toInt();
1936 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1937 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1938 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1939 strcpy(vjs
.screenshotPath
, settings
.value("Screenshots", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/screenshots/")).toString().toUtf8().data());
1941 // Read settings from the Debugger mode
1942 settings
.beginGroup("debugger");
1943 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1944 strcpy(vjs
.sourcefilesearchPaths
, settings
.value("SourceFileSearchPaths", "").toString().toUtf8().data());
1945 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1946 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1947 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1948 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1949 vjs
.ELFSectionsCheck
= settings
.value("ELFSectionsCheck", false).toBool();
1950 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1951 settings
.endGroup();
1953 // Read settings from the Alpine mode
1954 settings
.beginGroup("alpine");
1955 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1956 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1957 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1958 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1959 vjs
.allowM68KExceptionCatch
= settings
.value("M68KExceptionCatch", false).toBool();
1960 settings
.endGroup();
1962 // Read settings from the Keybindings
1963 settings
.beginGroup("keybindings");
1964 for (i
= 0; i
< KB_END
; i
++)
1966 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1968 settings
.endGroup();
1970 // Write important settings to the log file
1971 WriteLog("MainWin: Paths\n");
1972 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1973 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1974 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1975 WriteLog(" DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1976 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1977 WriteLog(" ScreenshotsPath = \"%s\"\n", vjs
.screenshotPath
);
1978 WriteLog("SourceFileSearchPaths = \"%s\"\n", vjs
.sourcefilesearchPaths
);
1979 WriteLog("MainWin: Misc.\n");
1980 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1983 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1984 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1985 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1986 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1987 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1988 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1989 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1990 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1991 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1992 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1993 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1994 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1995 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1996 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1997 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1998 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1999 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
2000 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
2001 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
2002 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
2003 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
2004 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
2006 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
2007 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
2008 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
2009 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
2010 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
2011 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
2012 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
2013 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
2014 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
2015 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
2016 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
2017 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
2018 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
2019 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
2020 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
2021 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
2022 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
2023 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
2024 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
2025 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
2026 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
2029 WriteLog("Read setting = Done\n");
2031 ReadProfiles(&settings
);
2032 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2037 // Default values will be used in case of no settings can be found
2039 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
2041 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
2043 // i.e., someone could drag it to another screen, close it, then disconnect that screen
2044 void MainWin::ReadUISettings(void)
2051 // Point on the emulator settings
2052 QSettings
settings("Underground Software", "Virtual Jaguar");
2053 settings
.beginGroup("ui");
2055 // Emulator main window UI information
2056 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
2057 size
= settings
.value("size", QSize(400, 400)).toSize();
2059 move(mainWinPosition
);
2060 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
2061 filePickWin
->move(pos
);
2063 // Video output information
2064 zoomLevel
= settings
.value("zoom", 2).toInt();
2066 // Emulator status UI information
2067 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
2068 emuStatusWin
->move(pos
);
2069 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
2071 // Alpine debug UI information (also needed by the Debugger)
2072 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2074 // CPU registers UI information
2075 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
2076 cpuBrowseWin
->move(pos
);
2077 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
2079 // Memory browser UI information
2080 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
2081 memBrowseWin
->move(pos
);
2082 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
2084 // Stack browser UI information
2085 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
2086 stackBrowseWin
->move(pos
);
2087 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
2088 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
2089 stackBrowseWin
->resize(size
);
2091 // OP (Object Processor) UI information
2092 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
2093 opBrowseWin
->move(pos
);
2094 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
2095 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
2096 opBrowseWin
->resize(size
);
2098 // HW registers UI information
2099 pos
= settings
.value("hwRegsBrowseWinPos", QPoint(200, 200)).toPoint();
2100 hwRegsBrowseWin
->move(pos
);
2101 settings
.value("hwRegsBrowseWinIsVisible", false).toBool() ? ShowHWRegsBrowserWin() : void();
2102 size
= settings
.value("hwRegsBrowseWinSize", QSize(400, 400)).toSize();
2103 hwRegsBrowseWin
->resize(size
);
2105 // RISC disassembly UI information
2106 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2107 riscDasmBrowseWin
->move(pos
);
2108 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
2110 // M68k disassembly UI information
2111 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
2112 m68kDasmBrowseWin
->move(pos
);
2113 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
2115 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
2117 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
2121 // Debugger UI information
2122 if (vjs
.softTypeDebugger
)
2125 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
2126 m68kDasmWin
->move(pos
);
2127 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
2128 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
2129 GPUDasmWin
->move(pos
);
2130 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
2131 DSPDasmWin
->move(pos
);
2133 // All watch browser UI information
2134 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
2135 allWatchBrowseWin
->move(pos
);
2136 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
2137 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
2138 allWatchBrowseWin
->resize(size
);
2140 // Local browser UI information
2141 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
2142 LocalBrowseWin
->move(pos
);
2143 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
2144 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
2145 LocalBrowseWin
->resize(size
);
2147 // Heap memory allocation browser UI information
2148 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
2149 heapallocatorBrowseWin
->move(pos
);
2150 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
2151 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
2152 heapallocatorBrowseWin
->resize(size
);
2154 // Exception Vector Table UI Information
2155 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
2156 exceptionvectortableBrowseWin
->move(pos
);
2157 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
2158 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
2159 exceptionvectortableBrowseWin
->resize(size
);
2161 // Call Stack browser UI information
2162 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
2163 CallStackBrowseWin
->move(pos
);
2164 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
2165 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
2166 CallStackBrowseWin
->resize(size
);
2168 // cartridge directory and files UI information
2169 pos
= settings
.value("CartFilesListWinPos", QPoint(200, 200)).toPoint();
2170 CartFilesListWin
->move(pos
);
2171 settings
.value("CartFilesListWinIsVisible", false).toBool() ? ShowCartFilesListWin() : void();
2172 size
= settings
.value("CartFilesListWinSize", QSize(400, 400)).toSize();
2173 CartFilesListWin
->resize(size
);
2175 // Save dump UI information
2176 pos
= settings
.value("SaveDumpAsWinPos", QPoint(200, 200)).toPoint();
2177 SaveDumpAsWin
->move(pos
);
2178 settings
.value("SaveDumpAsWinIsVisible", false).toBool() ? ShowSaveDumpAsWin() : void();
2179 size
= settings
.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();
2180 SaveDumpAsWin
->resize(size
);
2182 // Breakpoints UI information
2183 pos
= settings
.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();
2184 BreakpointsWin
->move(pos
);
2185 settings
.value("BreakpointsWinIsVisible", false).toBool() ? ShowBreakpointsWin() : void();
2186 size
= settings
.value("BreakpointsWinSize", QSize(400, 400)).toSize();
2187 BreakpointsWin
->resize(size
);
2188 // New function breakpoint UI information
2189 pos
= settings
.value("NewFunctionBreakpointWinPos", QPoint(200, 200)).toPoint();
2190 NewFunctionBreakpointWin
->move(pos
);
2191 settings
.value("NewFunctionBreakpointWinIsVisible", false).toBool() ? ShowNewFunctionBreakpointWin() : void();
2192 size
= settings
.value("NewFunctionBreakpointWinSize", QSize(400, 400)).toSize();
2193 NewFunctionBreakpointWin
->resize(size
);
2195 // Memories browser UI information
2196 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2198 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2199 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
2200 mem1BrowseWin
[i
]->move(pos
);
2201 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2202 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
2203 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2204 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
2205 mem1BrowseWin
[i
]->resize(size
);
2209 settings
.endGroup();
2211 WriteLog("Read UI setting = Done\n");
2215 // Save the settings
2216 void MainWin::WriteSettings(void)
2220 // Point on the emulator settings
2221 QSettings
settings("Underground Software", "Virtual Jaguar");
2222 //settings.setValue("pos", pos());
2223 //settings.setValue("size", size());
2224 //settings.setValue("cartLoadPos", filePickWin->pos());
2226 //settings.setValue("zoom", zoomLevel);
2227 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
2228 settings
.setValue("lastEditedProfile", lastEditedProfile
);
2230 settings
.setValue("useJoystick", vjs
.useJoystick
);
2231 settings
.setValue("joyport", vjs
.joyport
);
2232 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
2233 settings
.setValue("frameSkip", vjs
.frameSkip
);
2234 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
2235 settings
.setValue("useRetailBIOS", vjs
.useRetailBIOS
);
2236 settings
.setValue("useDevBIOS", vjs
.useDevBIOS
);
2237 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
2238 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
2239 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
2240 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
2241 settings
.setValue("fullscreen", vjs
.fullscreen
);
2242 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
2243 settings
.setValue("glFilterType", vjs
.glFilter
);
2244 settings
.setValue("renderType", vjs
.renderType
);
2245 settings
.setValue("jaguarModel", vjs
.jaguarModel
);
2246 settings
.setValue("biosType", vjs
.biosType
);
2247 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
2248 //settings.setValue("JagBootROM", vjs.jagBootPath);
2249 //settings.setValue("CDBootROM", vjs.CDBootPath);
2250 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
2251 settings
.setValue("ROMs", vjs
.ROMPath
);
2252 settings
.setValue("Screenshots", vjs
.screenshotPath
);
2254 // Write settings from the Alpine mode
2255 settings
.beginGroup("alpine");
2256 settings
.setValue("refresh", vjs
.refresh
);
2257 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
2258 settings
.setValue("DefaultABS", vjs
.absROMPath
);
2259 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
2260 settings
.setValue("M68KExceptionCatch", vjs
.allowM68KExceptionCatch
);
2261 settings
.endGroup();
2263 // Write settings from the Debugger mode
2264 settings
.beginGroup("debugger");
2265 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
2266 settings
.setValue("NbrDisasmLines", (qulonglong
) vjs
.nbrdisasmlines
);
2267 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
2268 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
2269 settings
.setValue("ELFSectionsCheck", vjs
.ELFSectionsCheck
);
2270 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
2271 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
2272 settings
.setValue("SourceFileSearchPaths", vjs
.sourcefilesearchPaths
);
2273 settings
.endGroup();
2275 // Write settings from the Keybindings
2276 settings
.beginGroup("keybindings");
2277 for (i
= 0; i
< KB_END
; i
++)
2279 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2281 settings
.endGroup();
2284 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2285 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2286 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2287 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2288 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2289 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2290 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2291 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2292 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2293 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2294 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2295 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2296 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2297 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2298 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2299 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2300 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2301 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2302 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2303 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2304 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2306 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2307 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2308 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2309 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2310 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2311 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2312 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2313 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2314 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2315 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2316 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2317 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2318 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2319 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2320 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2321 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2322 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2323 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2324 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2325 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2326 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2329 WriteProfiles(&settings
);
2330 DBGManager_SourceFileSearchPathsSet(vjs
.sourcefilesearchPaths
);
2334 // Save the UI settings
2335 void MainWin::WriteUISettings(void)
2340 // Point on the emulator settings
2341 QSettings
settings("Underground Software", "Virtual Jaguar");
2342 settings
.beginGroup("ui");
2344 // Emulator UI information
2345 settings
.setValue("pos", pos());
2346 settings
.setValue("size", size());
2347 settings
.setValue("cartLoadPos", filePickWin
->pos());
2349 // Video output information
2350 settings
.setValue("zoom", zoomLevel
);
2352 // Common UI information
2353 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2354 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2356 // Alpine debug UI information (also needed by the Debugger)
2357 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2359 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2360 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2361 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2362 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2363 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2364 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2365 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2366 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2367 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2368 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2369 settings
.setValue("hwRegsBrowseWinPos", hwRegsBrowseWin
->pos());
2370 settings
.setValue("hwRegsBrowseWinIsVisible", hwRegsBrowseWin
->isVisible());
2371 settings
.setValue("hwRegsBrowseWinSize", hwRegsBrowseWin
->size());
2372 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2373 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2374 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2375 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2378 // Debugger UI information
2379 if (vjs
.softTypeDebugger
)
2382 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2383 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2384 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2385 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2387 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2388 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2389 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2390 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2391 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2392 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2393 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2394 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2395 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2396 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2397 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2398 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2399 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2400 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2401 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2402 settings
.setValue("BreakpointsWinPos", BreakpointsWin
->pos());
2403 settings
.setValue("BreakpointsWinIsVisible", BreakpointsWin
->isVisible());
2404 settings
.setValue("BreakpointsWinSize", BreakpointsWin
->size());
2405 settings
.setValue("NewFunctionBreakpointWinPos", NewFunctionBreakpointWin
->pos());
2406 settings
.setValue("NewFunctionBreakpointWinIsVisible", NewFunctionBreakpointWin
->isVisible());
2407 settings
.setValue("NewFunctionBreakpointWinSize", NewFunctionBreakpointWin
->size());
2408 settings
.setValue("CartFilesListWinPos", CartFilesListWin
->pos());
2409 settings
.setValue("CartFilesListWinIsVisible", CartFilesListWin
->isVisible());
2410 settings
.setValue("CartFilesListWinSize", CartFilesListWin
->size());
2411 settings
.setValue("SaveDumpAsWinPos", SaveDumpAsWin
->pos());
2412 settings
.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin
->isVisible());
2413 settings
.setValue("SaveDumpAsWinSize", SaveDumpAsWin
->size());
2415 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2417 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2418 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2419 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2420 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2421 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2422 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2426 settings
.endGroup();
2430 // Refresh alpine debug windows
2431 void MainWin::AlpineRefreshWindows(void)
2433 cpuBrowseWin
->RefreshContents();
2434 memBrowseWin
->RefreshContents();
2435 stackBrowseWin
->RefreshContents();
2436 opBrowseWin
->RefreshContents();
2437 riscDasmBrowseWin
->RefreshContents();
2438 m68kDasmBrowseWin
->RefreshContents();
2439 hwRegsBrowseWin
->RefreshContents();
2444 void MainWin::CommonResetWindows(void)
2450 void MainWin::CommonReset(void)
2455 // Reset soft debugger
2456 void MainWin::DebuggerReset(void)
2458 if (vjs
.softTypeDebugger
)
2460 DeleteAllBreakpoints();
2465 // Reset soft debugger windows
2466 void MainWin::DebuggerResetWindows(void)
2468 if (vjs
.softTypeDebugger
)
2470 FilesrcListWin
->Reset();
2471 allWatchBrowseWin
->Reset();
2472 heapallocatorBrowseWin
->Reset();
2473 BreakpointsWin
->Reset();
2474 CartFilesListWin
->Reset();
2475 SourcesWin
->Reset();
2476 //ResetAlpineWindows();
2481 // Refresh common windows
2482 void MainWin::CommonRefreshWindows(void)
2484 emuStatusWin
->RefreshContents();
2488 // Refresh view windows
2489 void MainWin::ViewRefreshWindows(void)
2491 CartFilesListWin
->RefreshContents();
2496 void MainWin::RefreshWindows(void)
2498 DebuggerRefreshWindows();
2499 CommonRefreshWindows();
2503 // Refresh soft debugger & alpine debug windows
2504 void MainWin::DebuggerRefreshWindows(void)
2506 if (vjs
.softTypeDebugger
)
2508 FilesrcListWin
->RefreshContents();
2509 SourcesWin
->RefreshContents();
2510 m68kDasmWin
->RefreshContents();
2511 GPUDasmWin
->RefreshContents();
2512 DSPDasmWin
->RefreshContents();
2513 allWatchBrowseWin
->RefreshContents();
2514 LocalBrowseWin
->RefreshContents();
2515 CallStackBrowseWin
->RefreshContents();
2516 heapallocatorBrowseWin
->RefreshContents();
2517 BreakpointsWin
->RefreshContents();
2518 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2520 mem1BrowseWin
[i
]->RefreshContents(i
);
2523 AlpineRefreshWindows();
2524 ViewRefreshWindows();
2529 // Create and save screenshot
2530 void MainWin::MakeScreenshot(void)
2534 time_t now
= time(0);
2538 tstruct
= *localtime(&now
);
2539 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
);
2541 // Create screenshot
2542 screenshot
= videoWidget
->grabFrameBuffer();
2543 screenshot
.save((char *)Text
, "JPG", 100);