2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James Hammons <jlhamm@acm.org>
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 12/23/2009 Created this file
12 // JLH 12/20/2010 Added settings, menus & toolbars
13 // JLH 07/05/2011 Added CD BIOS functionality to GUI
14 // JPM 06/06/2016 Visual Studio support
15 // JPM 06/19/2016 Soft debugger integration
16 // JPM 01/11/2017 Added stack browser
17 // JPM 01/02/2017 Added GPU disassembly
18 // JPM 02/02/2017 Added DSP disassembly
19 // JPM 07/12/2017 Added all Watch browser window
20 // JPM 08/01/2017 Added heap allocator browser window
21 // JPM 08/07/2017 Added memories window browser
22 // JPM 08/10/2017 Added a restart feature
23 // JPM 08/31/2017 Added breakpoints winndow
24 // JPM 09/01/2017 Save position & visibility windows status in the settings
25 // JPM 09/02/2017 Save size windows in the settings
26 // JPM 09/05/2017 Added Exception Vector Table window
27 // JPM 09/06/2017 Added the 'Rx' word to the emulator window name
28 // JPM 09/12/2017 Added the keybindings in the settings
29 // JPM 11/04/2017 Added the local browser window
34 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
35 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
36 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
37 // with 'R', etc) [DONE]
38 // - Controller configuration [DONE]
42 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
43 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
44 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
47 // SFDX CODE: S1E9T8H5M23YS
49 // Uncomment this for debugging...
51 //#define DEBUGFOO // Various tool debugging... but not used
52 //#define DEBUGTP // Toolpalette debugging... but not used
59 #include "configdialog.h"
60 #include "controllertab.h"
61 #include "keybindingstab.h"
62 #include "filepicker.h"
64 #include "generaltab.h"
70 #include "emustatus.h"
71 #include "debug/cpubrowser.h"
72 #include "debug/m68kdasmbrowser.h"
73 #include "debug/memorybrowser.h"
74 #include "debug/stackbrowser.h"
75 #include "debug/opbrowser.h"
76 #include "debug/riscdasmbrowser.h"
78 #include "debugger/allwatchbrowser.h"
79 #include "debugger/localbrowser.h"
80 #include "debugger/heapallocatorbrowser.h"
88 #include "jagcdbios.h"
89 #include "jagstub2bios.h"
91 #include "m68000/m68kinterface.h"
93 #include "debugger/VideoWin.h"
94 #include "debugger/DasmWin.h"
95 #include "debugger/m68KDasmWin.h"
96 #include "debugger/GPUDasmWin.h"
97 #include "debugger/DSPDasmWin.h"
98 #include "debugger/memory1browser.h"
99 #include "debugger/brkWin.h"
100 #include "debugger/exceptionvectortablebrowser.h"
102 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
103 //#ifdef __GCCWIN32__
104 // Apparently on win32, usleep() is not pulled in by the usual suspects.
108 #include "_MSC_VER/unistd.h"
112 // The way BSNES controls things is by setting a timer with a zero
113 // timeout, sleeping if not emulating anything. Seems there has to be a
116 // It has a novel approach to plugging-in/using different video/audio/input
117 // methods, can we do something similar or should we just use the built-in
120 // We're going to try to use the built-in OpenGL support and see how it goes.
121 // We'll make the VJ core modular so that it doesn't matter what GUI is in
122 // use, we can drop it in anywhere and use it as-is.
124 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
125 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
126 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
132 for(int i
=0; i
<8; i
++)
136 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
139 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
142 //if (vjs.softTypeDebugger)
144 // mainWindowCentrale = new QMdiArea;
145 // setCentralWidget(mainWindowCentrale);
149 videoWidget
= new GLWidget(this);
150 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
152 // set central output window
153 if (!vjs
.softTypeDebugger
)
155 setCentralWidget(videoWidget
);
159 mainWindowCentrale
= new QMdiArea(this);
160 setCentralWidget(mainWindowCentrale
);
163 setWindowIcon(QIcon(":/res/vj-icon.png"));
165 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
167 if (vjs
.hardwareTypeAlpine
)
168 title
+= QString(tr(" - Alpine Mode"));
170 if (vjs
.softTypeDebugger
)
171 title
+= QString(tr(" - Debugger Mode"));
173 setWindowTitle(title
);
175 aboutWin
= new AboutWindow(this);
176 helpWin
= new HelpWindow(this);
177 filePickWin
= new FilePickerWindow(this);
178 memBrowseWin
= new MemoryBrowserWindow(this);
179 stackBrowseWin
= new StackBrowserWindow(this);
180 emuStatusWin
= new EmuStatusWindow(this);
181 cpuBrowseWin
= new CPUBrowserWindow(this);
182 opBrowseWin
= new OPBrowserWindow(this);
183 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
184 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
185 if (vjs
.softTypeDebugger
)
187 VideoOutputWin
= new VideoOutputWindow(this);
188 //VideoOutputWin->setCentralWidget()
189 //DasmWin = new DasmWindow();
190 DasmWin
= new DasmWindow(this);
191 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
192 LocalBrowseWin
= new LocalBrowserWindow(this);
193 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
194 brkWin
= new BrkWindow(this);
195 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
197 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
199 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
201 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
203 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
205 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
208 dasmtabWidget
= new QTabWidget(this);
209 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
210 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
211 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
212 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
213 ////dasmtabWidget->addTab(m68kDasmBrowseWin, tr("M68000"));
214 setCentralWidget(dasmtabWidget
);
217 QDockWidget
*shapesDockWidget
= new QDockWidget(tr("Shapes"));
218 shapesDockWidget
->setObjectName("shapesDockWidget");
219 shapesDockWidget
->setWidget(m68kDasmWin
);
220 //shapesDockWidget->setWidget(treeWidget);
221 shapesDockWidget
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
222 addDockWidget(Qt::LeftDockWidgetArea
, shapesDockWidget
);
226 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
227 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
229 setUnifiedTitleAndToolBarOnMac(true);
233 quitAppAct
= new QAction(tr("E&xit"), this);
234 // quitAppAct->setShortcuts(QKeySequence::Quit);
235 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
236 //quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
237 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
238 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
239 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
240 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
242 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
243 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
244 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
245 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
247 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
248 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
249 powerAct
->setCheckable(true);
250 powerAct
->setChecked(false);
251 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
254 pauseIcon
.addFile(":/res/pause-off", QSize(), QIcon::Normal
, QIcon::Off
);
255 pauseIcon
.addFile(":/res/pause-on", QSize(), QIcon::Normal
, QIcon::On
);
256 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
257 pauseAct
->setStatusTip(tr("Toggles the running state"));
258 pauseAct
->setCheckable(true);
259 pauseAct
->setDisabled(true);
260 //pauseAct->setShortcut(QKeySequence(tr("Esc")));
261 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
262 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
263 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
265 zoomActs
= new QActionGroup(this);
267 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
268 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
269 x1Act
->setCheckable(true);
270 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
272 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
273 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
274 x2Act
->setCheckable(true);
275 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
277 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
278 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
279 x3Act
->setCheckable(true);
280 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
282 tvTypeActs
= new QActionGroup(this);
284 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
285 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
286 ntscAct
->setCheckable(true);
287 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
289 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
290 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
291 palAct
->setCheckable(true);
292 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
294 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
295 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
297 blurAct
= new QAction(blur
, tr("Blur"), this);
298 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
299 blurAct
->setCheckable(true);
300 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
302 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
303 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
304 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
306 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
307 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
308 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
310 if (!vjs
.softTypeDebugger
)
312 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
313 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
317 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
318 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
320 //filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
321 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
322 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
323 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
325 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
326 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
327 //configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
328 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
329 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
330 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
332 emustatusAct
= new QAction(QIcon(""), tr("&Status"), this);
333 emustatusAct
->setStatusTip(tr("Emulator status"));
334 //emustatusAct->setShortcut(QKeySequence(tr("Ctrl+s")));
335 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
336 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
337 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
339 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
340 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
341 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
342 useCDAct
->setCheckable(true);
343 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
345 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
346 //frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
347 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
348 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
349 frameAdvanceAct
->setDisabled(true);
350 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
352 if (vjs
.softTypeDebugger
)
354 restartAct
= new QAction(QIcon(":/res/Restart.png"), tr("&Restart"), this);
355 //restartAct->setShortcut(QKeySequence(tr("Ctrl+Shift+F5")));
356 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
357 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
358 restartAct
->setCheckable(false);
359 restartAct
->setDisabled(true);
360 connect(restartAct
, SIGNAL(triggered()), this, SLOT(Restart()));
362 traceStepOverAct
= new QAction(QIcon(":/res/StepOver.png"), tr("&Step Over"), this);
363 //traceStepOverAct->setShortcut(QKeySequence(tr("F10")));
364 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
365 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
366 traceStepOverAct
->setCheckable(false);
367 traceStepOverAct
->setDisabled(true);
368 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(TraceStepOver()));
370 traceStepIntoAct
= new QAction(QIcon(":/res/StepInto.png"), tr("&Step Into"), this);
371 //traceStepIntoAct->setShortcut(QKeySequence(tr("F11")));
372 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
373 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
374 traceStepIntoAct
->setCheckable(false);
375 traceStepIntoAct
->setDisabled(true);
376 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(TraceStepInto()));
378 newBreakpointFunctionAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
379 newBreakpointFunctionAct
->setShortcut(QKeySequence(tr("Ctrl+B")));
380 connect(newBreakpointFunctionAct
, SIGNAL(triggered()), this, SLOT(NewBreakpointFunction()));
383 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
384 //fullScreenAct->setShortcut(QKeySequence(tr("F9")));
385 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
386 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
387 fullScreenAct
->setCheckable(true);
388 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
391 if (vjs
.softTypeDebugger
)
393 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
394 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
395 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
397 allWatchBrowseAct
= new QAction(QIcon(":/res/Watch.png"), tr("All Watch"), this);
398 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
399 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
401 LocalBrowseAct
= new QAction(QIcon(":/res/Local.png"), tr("Local"), this);
402 LocalBrowseAct
->setStatusTip(tr("Shows Local browser window"));
403 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
405 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
406 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
407 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
409 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
410 QSignalMapper
*signalMapper
= new QSignalMapper(this);
412 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
414 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
416 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
419 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
420 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/tool-memory.png"), tr(MB
), this);
421 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
423 //connect(mem1BrowseAct[0], SIGNAL(triggered()), this, SLOT(ShowMemory1BrowserWin(size_t(0))));
424 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
425 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
426 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
430 // Debugger Browser Actions
431 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
432 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
433 // memBrowseAct->setCheckable(true);
434 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
436 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
437 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
438 // memBrowseAct->setCheckable(true);
439 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
441 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
442 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
443 // memBrowseAct->setCheckable(true);
444 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
446 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
447 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
448 // memBrowseAct->setCheckable(true);
449 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
451 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
452 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
453 // memBrowseAct->setCheckable(true);
454 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
456 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
457 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
458 // memBrowseAct->setCheckable(true);
459 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
461 if (vjs
.softTypeDebugger
)
463 VideoOutputAct
= new QAction(tr("Output Video"), this);
464 VideoOutputAct
->setStatusTip(tr("Shows the output video window"));
465 connect(VideoOutputAct
, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
467 DasmAct
= new QAction(tr("Disassembly"), this);
468 DasmAct
->setStatusTip(tr("Shows the disassembly window"));
469 connect(DasmAct
, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
472 // Misc. connections...
473 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
474 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
478 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
479 fileMenu
->addAction(powerAct
);
480 if (!vjs
.softTypeDebugger
)
482 fileMenu
->addAction(pauseAct
);
483 // fileMenu->addAction(frameAdvanceAct);
485 fileMenu
->addAction(filePickAct
);
486 fileMenu
->addAction(useCDAct
);
487 fileMenu
->addAction(configAct
);
488 fileMenu
->addAction(emustatusAct
);
489 fileMenu
->addSeparator();
490 fileMenu
->addAction(quitAppAct
);
492 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
494 debugMenu
= menuBar()->addMenu(tr("&Debug"));
495 if (vjs
.softTypeDebugger
)
497 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
498 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
499 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
500 debugWindowsMenu
->addSeparator();
502 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
503 debugWindowOutputMenu
->addAction(VideoOutputAct
);
504 debugWindowsMenu
->addSeparator();
506 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
507 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
508 debugWindowsMenu
->addAction(LocalBrowseAct
);
509 debugWindowsMenu
->addSeparator();
510 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
511 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
512 debugWindowsMemoryMenu
->addSeparator();
513 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
515 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
517 debugWindowsMenu
->addSeparator();
518 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
519 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
520 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
521 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
522 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
523 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
524 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
525 debugMenu
->addSeparator();
526 debugMenu
->addAction(pauseAct
);
527 debugMenu
->addAction(frameAdvanceAct
);
528 debugMenu
->addAction(restartAct
);
529 debugMenu
->addSeparator();
530 debugMenu
->addAction(traceStepIntoAct
);
531 debugMenu
->addAction(traceStepOverAct
);
533 debugMenu
->addSeparator();
534 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
535 debugNewBreakpointMenu
->addAction(newBreakpointFunctionAct
);
537 //debugMenu->addSeparator();
538 //debugMenu->addAction(DasmAct);
542 debugMenu
->addAction(memBrowseAct
);
543 debugMenu
->addAction(stackBrowseAct
);
544 debugMenu
->addAction(cpuBrowseAct
);
545 debugMenu
->addAction(opBrowseAct
);
546 debugMenu
->addAction(m68kDasmBrowseAct
);
547 debugMenu
->addAction(riscDasmBrowseAct
);
551 helpMenu
= menuBar()->addMenu(tr("&Help"));
552 helpMenu
->addAction(helpAct
);
553 helpMenu
->addAction(aboutAct
);
557 toolbar
= addToolBar(tr("Stuff"));
558 toolbar
->addAction(powerAct
);
559 if (!vjs
.softTypeDebugger
)
561 toolbar
->addAction(pauseAct
);
562 toolbar
->addAction(frameAdvanceAct
);
564 toolbar
->addAction(filePickAct
);
565 toolbar
->addAction(useCDAct
);
566 toolbar
->addSeparator();
567 if (!vjs
.softTypeDebugger
)
569 toolbar
->addAction(x1Act
);
570 toolbar
->addAction(x2Act
);
571 toolbar
->addAction(x3Act
);
572 toolbar
->addSeparator();
573 toolbar
->addAction(ntscAct
);
574 toolbar
->addAction(palAct
);
575 toolbar
->addSeparator();
576 toolbar
->addAction(blurAct
);
577 toolbar
->addAction(fullScreenAct
);
581 debuggerbar
= addToolBar(tr("&Debugger"));
582 debuggerbar
->addAction(pauseAct
);
583 debuggerbar
->addAction(frameAdvanceAct
);
584 debuggerbar
->addAction(restartAct
);
585 debuggerbar
->addSeparator();
586 debuggerbar
->addAction(traceStepIntoAct
);
587 debuggerbar
->addAction(traceStepOverAct
);
590 if (vjs
.hardwareTypeAlpine
)
592 debugbar
= addToolBar(tr("&Debug"));
593 debugbar
->addAction(memBrowseAct
);
594 debugbar
->addAction(stackBrowseAct
);
595 debugbar
->addAction(cpuBrowseAct
);
596 debugbar
->addAction(opBrowseAct
);
597 debugbar
->addAction(m68kDasmBrowseAct
);
598 debugbar
->addAction(riscDasmBrowseAct
);
601 // Add actions to the main window, as hiding widgets with them
603 addAction(fullScreenAct
);
604 addAction(quitAppAct
);
605 addAction(configAct
);
606 addAction(emustatusAct
);
608 addAction(filePickAct
);
609 addAction(frameAdvanceAct
);
612 statusBar()->showMessage(tr("Ready"));
614 // Do this in case original size isn't correct (mostly for the first-run case)
617 // Create our test pattern bitmaps
618 QImage
tempImg(":/res/test-pattern.jpg");
619 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
621 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
623 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
625 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
627 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
628 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
632 QImage
tempImg2(":/res/test-pattern-pal");
633 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
635 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
637 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
639 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
641 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
642 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
646 // Set up timer based loop for animation...
647 timer
= new QTimer(this);
648 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
650 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
651 // This is because it's discarding the 0.6666... on the end of the fraction.
652 // Alas, 6 doesn't divide cleanly into 10. :-P
653 //Should we defer this until SyncUI? Probably.
654 //No, it doesn't work, because it uses setInterval() instead of start()...
655 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
657 // We set this initially, to make VJ behave somewhat as it would if no
658 // cart were inserted and the BIOS was set as active...
659 jaguarCartInserted
= true;
660 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
661 WriteLog("VJ: Initializing jaguar subsystem...\n");
663 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
664 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
666 // Prevent the file scanner from running if filename passed
667 // in on the command line...
671 // Load up the default ROM if in Alpine mode:
672 if (vjs
.hardwareTypeAlpine
)
674 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
676 // If regular load failed, try just a straight file load
677 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
679 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
682 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
684 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
686 // Attempt to load/run the ABS file...
687 LoadSoftware(vjs
.absROMPath
);
688 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
689 // Prevent the scanner from running...
693 // Load up the default ROM if in Debugger mode:
694 if (vjs
.softTypeDebugger
)
696 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
698 // If regular load failed, try just a straight file load
699 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
701 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
704 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
706 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
708 // Attempt to load/run the ABS file...
709 LoadSoftware(vjs
.absROMPath
);
710 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
711 // Prevent the scanner from running...
715 // Run the scanner if nothing passed in and *not* Alpine mode...
716 // NB: Really need to look into caching the info scanned in here...
717 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
718 scannedSoftwareFolder
= true;
722 void MainWin::LoadFile(QString file
)
728 void MainWin::SyncUI(void)
730 // Set toolbar buttons/menus based on settings read in (sync the UI)...
731 // (Really, this is to sync command line options passed in)
732 blurAct
->setChecked(vjs
.glFilter
);
733 x1Act
->setChecked(zoomLevel
== 1);
734 x2Act
->setChecked(zoomLevel
== 2);
735 x3Act
->setChecked(zoomLevel
== 3);
736 // running = powerAct->isChecked();
737 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
738 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
739 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
741 fullScreenAct
->setChecked(vjs
.fullscreen
);
742 fullScreen
= vjs
.fullscreen
;
743 SetFullScreen(fullScreen
);
745 // Reset the timer to be what was set in the command line (if any):
746 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
747 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
751 void MainWin::closeEvent(QCloseEvent
* event
)
754 // This should only be done by the config dialog
757 event
->accept(); // ignore() if can't close for some reason
761 void MainWin::keyPressEvent(QKeyEvent
* e
)
763 #ifndef VJ_REMOVE_DEV_CODE
765 //extern bool startM68KTracing; // moved to jaguar.h
767 extern int blit_start_log
;
769 extern bool startConciseBlitLogging
;
772 // We ignore the Alt key for now, since it causes problems with the GUI
773 if (e
->key() == Qt::Key_Alt
)
778 // Bar this shite from release versions kthxbai
779 #ifndef VJ_REMOVE_DEV_CODE
780 else if (e
->key() == Qt::Key_F11
)
782 startM68KTracing
= true;
786 else if (e
->key() == Qt::Key_F12
)
788 blit_start_log
= true;
792 else if (e
->key() == Qt::Key_F10
)
794 startConciseBlitLogging
= true;
799 else if (e
->key() == Qt::Key_F8
)
801 // ggn: For extra NYAN pleasure...
802 // ggn: There you go James :P
803 // Shamus: Thanks for the patch! :-D
804 WriteLog(" o + + +\n");
805 WriteLog("+ o o + o\n");
806 WriteLog("-_-_-_-_-_-_-_,------, o \n");
807 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
808 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
809 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
810 WriteLog("+ o o + o\n");
817 This is done now by a QAction...
818 if (e->key() == Qt::Key_F9)
828 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
830 // We ignore the Alt key for now, since it causes problems with the GUI
831 if (e
->key() == Qt::Key_Alt
)
837 HandleKeys(e
, false);
841 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
843 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
844 // We kill bad key combos here, before they can get to the emulator...
845 // This also kills the illegal instruction problem that cropped up in
848 // First, settle key states...
849 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
850 keyHeld
[P1LEFT
] = state
;
851 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
852 keyHeld
[P1RIGHT
] = state
;
853 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
854 keyHeld
[P1UP
] = state
;
855 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
856 keyHeld
[P1DOWN
] = state
;
857 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
858 keyHeld
[P2LEFT
] = state
;
859 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
860 keyHeld
[P2RIGHT
] = state
;
861 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
862 keyHeld
[P2UP
] = state
;
863 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
864 keyHeld
[P2DOWN
] = state
;
866 // Next, check for conflicts and kill 'em if there are any...
867 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
868 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
870 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
871 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
873 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
874 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
876 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
877 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
879 // No bad combos exist now, let's stuff the emulator key buffers...!
880 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
882 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
883 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
885 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
886 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
892 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
894 void MainWin::HandleGamepads(void)
898 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
900 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
901 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
903 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
904 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
909 void MainWin::Open(void)
914 void MainWin::Configure(void)
916 // Call the configuration dialog and update settings
917 ConfigDialog
dlg(this);
919 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
920 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
921 dlg
.controllerTab1
->SetupLastUsedProfile();
922 // maybe instead of this, we tell the controller tab to work on a copy that gets
923 // written if the user hits 'OK'.
924 SaveProfiles(); // Just in case user cancels
926 if (dlg
.exec() == false)
932 QString before
= vjs
.ROMPath
;
933 QString alpineBefore
= vjs
.alpineROMPath
;
934 QString absBefore
= vjs
.absROMPath
;
935 // bool audioBefore = vjs.audioEnabled;
936 bool audioBefore
= vjs
.DSPEnabled
;
937 dlg
.UpdateVJSettings();
938 QString after
= vjs
.ROMPath
;
939 QString alpineAfter
= vjs
.alpineROMPath
;
940 QString absAfter
= vjs
.absROMPath
;
941 // bool audioAfter = vjs.audioEnabled;
942 bool audioAfter
= vjs
.DSPEnabled
;
944 bool allowOld
= allowUnknownSoftware
;
946 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
947 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
948 AutoConnectProfiles();
950 // We rescan the "software" folder if the user either changed the path or
951 // checked/unchecked the "Allow unknown files" option in the config dialog.
952 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
953 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
955 // If the "Alpine" ROM is changed, then let's load it...
956 if (alpineBefore
!= alpineAfter
)
958 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
960 // Oh crap, we couldn't get the file! Alert the media!
962 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
963 msg
.setIcon(QMessageBox::Warning
);
968 // If the "ABS" ROM is changed, then let's load it...
969 if (absBefore
!= absAfter
)
971 if (!JaguarLoadFile(vjs
.absROMPath
))
973 // Oh crap, we couldn't get the file! Alert the media!
975 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
976 msg
.setIcon(QMessageBox::Warning
);
981 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
982 // since it's running in the host audio IRQ...
983 if (audioBefore
!= audioAfter
)
989 // Just in case we crash before a clean exit...
992 RefreshDebuggerWindows();
997 // Here's the main emulator loop
999 void MainWin::Timer(void)
1002 static uint32_t ntscTickCount
;
1003 if (vjs
.hardwareTypeNTSC
)
1007 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1014 if (showUntunedTankCircuit
)
1016 // Some machines can't handle this, so we give them the option to disable it. :-)
1017 if (!plzDontKillMyComputer
)
1019 // if (!vjs.softTypeDebugger)
1021 // Random hash & trash
1022 // We try to simulate an untuned tank circuit here... :-)
1023 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1025 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1027 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1035 // Otherwise, run the Jaguar simulation
1038 if (!vjs
.softTypeDebugger
)
1039 videoWidget
->HandleMouseHiding();
1041 static uint32_t refresh
= 0;
1042 // Do autorefresh on debug windows
1043 // Have to be careful, too much causes the emulator to slow way down!
1044 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1046 if (refresh
== vjs
.refresh
)
1048 RefreshAlpineWindows();
1049 //memBrowseWin->RefreshContents();
1050 //cpuBrowseWin->RefreshContents();
1058 //if (!vjs.softTypeDebugger)
1059 videoWidget
->updateGL();
1062 // Approach: We use a ring buffer to store times (in ms) over a given
1063 // amount of frames, then sum them to figure out the FPS.
1064 uint32_t timestamp
= SDL_GetTicks();
1065 // This assumes the ring buffer size is a power of 2
1066 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1067 // Doing it this way is better. Ring buffer size can be arbitrary then.
1068 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1069 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1070 uint32_t elapsedTime
= 0;
1072 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1073 elapsedTime
+= ringBuffer
[i
];
1075 // elapsedTime must be non-zero
1076 if (elapsedTime
== 0)
1079 // This is in frames per 10 seconds, so we can have 1 decimal
1080 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1081 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1082 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1083 // If this is updated too frequently to be useful, we can throttle it down
1084 // so that it only updates every 10th frame or so
1085 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1086 oldTimestamp
= timestamp
;
1088 if (M68KDebugHaltStatus())
1093 void MainWin::TogglePowerState(void)
1095 powerButtonOn
= !powerButtonOn
;
1098 // With the power off, we simulate white noise on the screen. :-)
1101 // Restore the mouse pointer, if hidden:
1102 if (!vjs
.softTypeDebugger
)
1103 videoWidget
->CheckAndRestoreMouseCursor();
1104 useCDAct
->setDisabled(false);
1105 palAct
->setDisabled(false);
1106 ntscAct
->setDisabled(false);
1107 pauseAct
->setChecked(false);
1108 pauseAct
->setDisabled(true);
1109 showUntunedTankCircuit
= true;
1110 DACPauseAudioThread();
1111 // This is just in case the ROM we were playing was in a narrow or wide
1112 // field mode, so the untuned tank sim doesn't look wrong. :-)
1115 if (plzDontKillMyComputer
)
1117 //if (!vjs.softTypeDebugger)
1119 // We have to do it line by line, because the texture pitch is not
1120 // the same as the picture buffer's pitch.
1121 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1123 if (vjs
.hardwareTypeNTSC
)
1124 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1126 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1133 useCDAct
->setDisabled(true);
1134 palAct
->setDisabled(true);
1135 ntscAct
->setDisabled(true);
1136 pauseAct
->setChecked(false);
1137 pauseAct
->setDisabled(false);
1138 showUntunedTankCircuit
= false;
1140 // Otherwise, we prepare for running regular software...
1143 // Should check for cartridgeLoaded here as well...!
1144 // We can clear it when toggling CDActive on, so that when we power cycle it
1145 // does the expected thing. Otherwise, if we use the file picker to insert a
1146 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1147 // works if the CD unit is active?
1148 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
1149 " Rx - Now playing: Jaguar CD"));
1152 WriteLog("GUI: Resetting Jaguar...\n");
1154 DACPauseAudioThread(false);
1159 void MainWin::ToggleRunState(void)
1161 startM68KTracing
= running
;
1166 frameAdvanceAct
->setDisabled(false);
1167 pauseAct
->setChecked(true);
1168 pauseAct
->setDisabled(false);
1169 if (vjs
.softTypeDebugger
)
1171 traceStepIntoAct
->setDisabled(false);
1172 traceStepOverAct
->setDisabled(false);
1173 restartAct
->setDisabled(false);
1174 m68kDasmWin
->Use68KPCAddress();
1175 GPUDasmWin
->UseGPUPCAddress();
1176 DSPDasmWin
->UseDSPPCAddress();
1179 //if (!vjs.softTypeDebugger)
1181 // Restore the mouse pointer, if hidden:
1182 videoWidget
->CheckAndRestoreMouseCursor();
1183 // frameAdvanceAct->setDisabled(false);
1185 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1187 uint32_t pixel
= videoWidget
->buffer
[i
];
1188 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1189 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1190 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1193 videoWidget
->updateGL();
1195 cpuBrowseWin
->HoldBPM();
1196 cpuBrowseWin
->HandleBPMContinue();
1197 RefreshDebuggerWindows();
1202 frameAdvanceAct
->setDisabled(true);
1203 pauseAct
->setChecked(false);
1204 pauseAct
->setDisabled(false);
1205 if (vjs
.softTypeDebugger
)
1207 traceStepIntoAct
->setDisabled(true);
1208 traceStepOverAct
->setDisabled(true);
1209 restartAct
->setDisabled(true);
1212 cpuBrowseWin
->UnholdBPM();
1215 // Pause/unpause any running/non-running threads...
1216 DACPauseAudioThread(!running
);
1220 void MainWin::SetZoom100(void)
1227 void MainWin::SetZoom200(void)
1234 void MainWin::SetZoom300(void)
1241 void MainWin::SetNTSC(void)
1243 powerAct
->setIcon(powerRed
);
1244 timer
->setInterval(16);
1245 vjs
.hardwareTypeNTSC
= true;
1251 void MainWin::SetPAL(void)
1253 powerAct
->setIcon(powerGreen
);
1254 timer
->setInterval(20);
1255 vjs
.hardwareTypeNTSC
= false;
1261 void MainWin::ToggleBlur(void)
1263 vjs
.glFilter
= !vjs
.glFilter
;
1268 void MainWin::ShowAboutWin(void)
1274 void MainWin::ShowHelpWin(void)
1280 void MainWin::InsertCart(void)
1282 // Check to see if we did autorun, 'cause we didn't load anything in that
1284 if (!scannedSoftwareFolder
)
1286 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1287 scannedSoftwareFolder
= true;
1290 // If the emulator is running, we pause it here and unpause it later
1291 // if we dismiss the file selector without choosing anything
1292 if (running
&& powerButtonOn
)
1295 pauseForFileSelector
= true;
1298 filePickWin
->show();
1302 void MainWin::Unpause(void)
1304 // Here we unpause the emulator if it was paused when we went into the file selector
1305 if (pauseForFileSelector
)
1307 pauseForFileSelector
= false;
1309 // Some nutter might have unpaused while in the file selector, so check for that
1316 void MainWin::LoadSoftware(QString file
)
1318 running
= false; // Prevent bad things(TM) from happening...
1319 pauseForFileSelector
= false; // Reset the file selector pause flag
1321 uint8_t * biosPointer
= jaguarBootROM
;
1323 if (vjs
.hardwareTypeAlpine
)
1324 biosPointer
= jaguarDevBootROM2
;
1326 if (vjs
.softTypeDebugger
)
1327 biosPointer
= jaguarDevBootROM2
;
1329 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1331 powerAct
->setDisabled(false);
1332 powerAct
->setChecked(true);
1333 powerButtonOn
= false;
1336 // We have to load our software *after* the Jaguar RESET
1337 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1338 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set top of stack...
1340 // This is icky because we've already done it
1341 // it gets worse :-P
1342 if (!vjs
.useJaguarBIOS
)
1343 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1347 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1348 if (vjs
.softTypeDebugger
)
1350 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1351 //pauseAct->setDisabled(false);
1352 //pauseAct->setChecked(true);
1358 if (vjs
.hardwareTypeAlpine
&& !jaguarRunAddress
)
1364 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1366 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1")
1367 .arg(filePickWin
->GetSelectedPrettyName());
1368 setWindowTitle(newTitle
);
1373 void MainWin::ToggleCDUsage(void)
1375 CDActive
= !CDActive
;
1377 // Set up the Jaguar CD for execution, otherwise, clear memory
1379 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1381 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1386 void MainWin::NewBreakpointFunction(void)
1389 brkWin
->RefreshContents();
1394 void MainWin::TraceStepInto(void)
1397 videoWidget
->updateGL();
1398 RefreshDebuggerWindows();
1400 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1402 #warning "!!! Need to verify the Step Into function !!!"
1408 void MainWin::Restart(void)
1410 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1411 //m68kDasmWin->SetAddress(jaguarRunAddress);
1412 RefreshDebuggerWindows();
1414 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1416 #warning "!!! Need to verify the Restart function !!!"
1422 void MainWin::TraceStepOver(void)
1425 videoWidget
->updateGL();
1426 RefreshDebuggerWindows();
1428 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1430 #warning "!!! Need to verify the Step Over function !!!"
1435 // Advance / Execute for one frame
1436 void MainWin::FrameAdvance(void)
1438 //printf("Frame Advance...\n");
1440 // Execute 1 frame, then exit (only useful in Pause mode)
1442 //if (!vjs.softTypeDebugger)
1443 videoWidget
->updateGL();
1445 // Need to execute 1 frames' worth of DSP thread as well :-/
1447 //m68kDasmWin->Use68KPCAddress();
1450 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1452 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1457 void MainWin::SetFullScreen(bool state
/*= true*/)
1459 if (!vjs
.softTypeDebugger
)
1463 mainWinPosition
= pos();
1465 statusBar()->hide();
1471 // This is needed because the fullscreen may happen on a different
1472 // screen than screen 0:
1473 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1474 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1475 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1476 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1477 double aspectRatio
= targetWidth
/ targetHeight
;
1478 // NOTE: Really should check here to see which dimension constrains the
1479 // other. Right now, we assume that height is the constraint.
1480 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1481 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1482 videoWidget
->fullscreen
= true;
1483 videoWidget
->outputWidth
= newWidth
;
1484 videoWidget
->setFixedSize(r
.width(), r
.height());
1489 // Seems Qt is fussy about this: showNormal() has to go first, or it
1490 // will keep the window stuck in a psuedo-fullscreen mode with no way
1491 // to get out of it (except closing the app).
1494 // Reset the video widget to windowed mode
1495 videoWidget
->offset
= 0;
1496 videoWidget
->fullscreen
= false;
1498 statusBar()->show();
1505 move(mainWinPosition
);
1511 void MainWin::ToggleFullScreen(void)
1513 fullScreen
= !fullScreen
;
1514 SetFullScreen(fullScreen
);
1518 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1520 exceptionvectortableBrowseWin
->show();
1521 exceptionvectortableBrowseWin
->RefreshContents();
1525 void MainWin::ShowLocalBrowserWin(void)
1527 LocalBrowseWin
->show();
1528 LocalBrowseWin
->RefreshContents();
1532 void MainWin::ShowAllWatchBrowserWin(void)
1534 allWatchBrowseWin
->show();
1535 allWatchBrowseWin
->RefreshContents();
1539 void MainWin::ShowHeapAllocatorBrowserWin(void)
1541 heapallocatorBrowseWin
->show();
1542 heapallocatorBrowseWin
->RefreshContents();
1546 void MainWin::ShowMemoryBrowserWin(void)
1548 memBrowseWin
->show();
1549 memBrowseWin
->RefreshContents();
1553 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1555 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1557 mem1BrowseWin
[NumWin
]->show();
1558 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1563 void MainWin::ShowEmuStatusWin(void)
1565 emuStatusWin
->show();
1566 emuStatusWin
->RefreshContents();
1570 void MainWin::ShowStackBrowserWin(void)
1572 stackBrowseWin
->show();
1573 stackBrowseWin
->RefreshContents();
1577 void MainWin::ShowCPUBrowserWin(void)
1579 cpuBrowseWin
->show();
1580 cpuBrowseWin
->RefreshContents();
1584 void MainWin::ShowOPBrowserWin(void)
1586 opBrowseWin
->show();
1587 opBrowseWin
->RefreshContents();
1591 void MainWin::ShowM68KDasmBrowserWin(void)
1593 m68kDasmBrowseWin
->show();
1594 m68kDasmBrowseWin
->RefreshContents();
1598 void MainWin::ShowRISCDasmBrowserWin(void)
1600 riscDasmBrowseWin
->show();
1601 riscDasmBrowseWin
->RefreshContents();
1605 void MainWin::ShowDasmWin(void)
1608 // DasmWin->RefreshContents();
1612 void MainWin::ShowVideoOutputWin(void)
1614 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1615 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1616 //VideoOutputWindowCentrale->show();
1617 //memBrowseWin->show();
1618 VideoOutputWin
->show();
1619 //VideoOutputWin->RefreshContents(videoWidget);
1623 void MainWin::ResizeMainWindow(void)
1625 if (!vjs
.softTypeDebugger
)
1627 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
,
1628 zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1630 // Show the test pattern if user requested plzDontKillMyComputer mode
1631 if (!powerButtonOn
&& plzDontKillMyComputer
)
1633 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1635 if (vjs
.hardwareTypeNTSC
)
1636 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1638 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1648 void MainWin::ReadSettings(void)
1652 QSettings
settings("Underground Software", "Virtual Jaguar");
1654 zoomLevel
= settings
.value("zoom", 2).toInt();
1655 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1656 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1658 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1659 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1660 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1661 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1662 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1663 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1664 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1665 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1666 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1667 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1668 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1669 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1670 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1671 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1672 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1673 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1674 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1676 // Read settings from the Debugger mode
1677 settings
.beginGroup("debugger");
1678 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1679 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1680 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1681 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1682 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1683 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1684 settings
.endGroup();
1686 // Read settings from the Alpine mode
1687 settings
.beginGroup("alpine");
1688 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1689 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1690 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1691 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1692 settings
.endGroup();
1694 // Read settings from the Keybindings
1695 settings
.beginGroup("keybindings");
1696 for (i
= 0; i
< KB_END
; i
++)
1698 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1700 settings
.endGroup();
1702 // Write important settings to the log file
1703 WriteLog("MainWin: Paths\n");
1704 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1705 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1706 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1707 WriteLog("DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1708 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1709 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1712 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1713 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1714 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1715 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1716 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1717 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1718 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1719 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1720 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1721 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1722 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1723 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1724 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1725 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1726 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1727 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1728 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1729 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1730 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1731 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1732 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1733 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1735 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1736 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1737 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1738 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1739 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1740 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1741 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1742 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1743 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1744 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1745 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1746 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1747 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1748 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1749 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1750 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1751 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1752 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1753 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1754 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1755 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1758 ReadProfiles(&settings
);
1763 // Default values will be used in case of no settings can be found
1765 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1767 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1769 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1770 void MainWin::ReadUISettings(void)
1777 // Point on the emulator settings
1778 QSettings
settings("Underground Software", "Virtual Jaguar");
1779 settings
.beginGroup("ui");
1781 // Emulator main window UI information
1782 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1783 size
= settings
.value("size", QSize(400, 400)).toSize();
1785 move(mainWinPosition
);
1786 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1787 filePickWin
->move(pos
);
1789 // Alpine debug UI information (also needed by the Debugger)
1790 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1792 // CPU registers UI information
1793 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1794 cpuBrowseWin
->move(pos
);
1795 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1797 // Memory browser UI information
1798 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1799 memBrowseWin
->move(pos
);
1800 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1802 // Stack browser UI information
1803 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1804 stackBrowseWin
->move(pos
);
1805 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1806 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1807 stackBrowseWin
->resize(size
);
1809 // Emulator status UI information
1810 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1811 emuStatusWin
->move(pos
);
1812 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1814 // OP (Object Processor) UI information
1815 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1816 opBrowseWin
->move(pos
);
1817 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1818 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1819 opBrowseWin
->resize(size
);
1821 // RISC disassembly UI information
1822 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1823 riscDasmBrowseWin
->move(pos
);
1824 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
1826 // M68k disassembly UI information
1827 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1828 m68kDasmBrowseWin
->move(pos
);
1829 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
1831 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
1833 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
1837 // Debugger UI information
1838 if (vjs
.softTypeDebugger
)
1841 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
1842 m68kDasmWin
->move(pos
);
1843 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
1844 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
1845 GPUDasmWin
->move(pos
);
1846 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
1847 DSPDasmWin
->move(pos
);
1849 // All watch browser UI information
1850 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
1851 allWatchBrowseWin
->move(pos
);
1852 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
1853 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
1854 allWatchBrowseWin
->resize(size
);
1856 // Local browser UI information
1857 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
1858 LocalBrowseWin
->move(pos
);
1859 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
1860 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
1861 LocalBrowseWin
->resize(size
);
1863 // Heap memory allocation browser UI information
1864 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
1865 heapallocatorBrowseWin
->move(pos
);
1866 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
1867 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
1868 heapallocatorBrowseWin
->resize(size
);
1870 // Exception Vector Table UI Information
1871 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
1872 exceptionvectortableBrowseWin
->move(pos
);
1873 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
1874 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
1875 exceptionvectortableBrowseWin
->resize(size
);
1877 // Memories browser UI information
1878 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
1880 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
1881 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
1882 mem1BrowseWin
[i
]->move(pos
);
1883 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
1884 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
1885 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
1886 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
1887 mem1BrowseWin
[i
]->resize(size
);
1891 settings
.endGroup();
1895 // Save the settings
1896 void MainWin::WriteSettings(void)
1900 // Point on the emulator settings
1901 QSettings
settings("Underground Software", "Virtual Jaguar");
1902 //settings.setValue("pos", pos());
1903 //settings.setValue("size", size());
1904 //settings.setValue("cartLoadPos", filePickWin->pos());
1906 settings
.setValue("zoom", zoomLevel
);
1907 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
1908 settings
.setValue("lastEditedProfile", lastEditedProfile
);
1910 settings
.setValue("useJoystick", vjs
.useJoystick
);
1911 settings
.setValue("joyport", vjs
.joyport
);
1912 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
1913 settings
.setValue("frameSkip", vjs
.frameSkip
);
1914 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
1915 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
1916 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
1917 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
1918 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
1919 settings
.setValue("fullscreen", vjs
.fullscreen
);
1920 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
1921 settings
.setValue("glFilterType", vjs
.glFilter
);
1922 settings
.setValue("renderType", vjs
.renderType
);
1923 settings
.setValue("biosType", vjs
.biosType
);
1924 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
1925 settings
.setValue("JagBootROM", vjs
.jagBootPath
);
1926 settings
.setValue("CDBootROM", vjs
.CDBootPath
);
1927 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
1928 settings
.setValue("ROMs", vjs
.ROMPath
);
1930 // Write settings from the Alpine mode
1931 settings
.beginGroup("alpine");
1932 settings
.setValue("refresh", vjs
.refresh
);
1933 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
1934 settings
.setValue("DefaultABS", vjs
.absROMPath
);
1935 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
1936 settings
.endGroup();
1938 // Write settings from the Debugger mode
1939 settings
.beginGroup("debugger");
1940 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
1941 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
1942 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
1943 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
1944 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
1945 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
1946 settings
.endGroup();
1948 // Write settings from the Keybindings
1949 settings
.beginGroup("keybindings");
1950 for (i
= 0; i
< KB_END
; i
++)
1952 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
1954 settings
.endGroup();
1957 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
1958 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
1959 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
1960 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
1961 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
1962 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
1963 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
1964 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
1965 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
1966 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
1967 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
1968 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
1969 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
1970 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
1971 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
1972 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
1973 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
1974 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
1975 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
1976 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
1977 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
1979 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
1980 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
1981 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
1982 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
1983 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
1984 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
1985 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
1986 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
1987 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
1988 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
1989 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
1990 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
1991 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
1992 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
1993 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
1994 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
1995 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
1996 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
1997 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
1998 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
1999 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2002 WriteProfiles(&settings
);
2006 // Save the UI settings
2007 void MainWin::WriteUISettings(void)
2012 // Point on the emulator settings
2013 QSettings
settings("Underground Software", "Virtual Jaguar");
2014 settings
.beginGroup("ui");
2016 // Emulator UI information
2017 settings
.setValue("pos", pos());
2018 settings
.setValue("size", size());
2019 settings
.setValue("cartLoadPos", filePickWin
->pos());
2020 settings
.setValue("zoom", zoomLevel
);
2022 // Alpine debug UI information (also needed by the Debugger)
2023 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2025 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2026 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2027 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2028 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2029 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2030 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2031 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2032 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2033 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2034 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2035 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2036 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2037 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2038 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2039 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2040 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2043 // Debugger UI information
2044 if (vjs
.softTypeDebugger
)
2047 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2048 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2049 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2050 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2052 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2053 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2054 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2055 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2056 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2057 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2058 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2059 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2060 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2061 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2062 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2063 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2064 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2066 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2067 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2068 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2069 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2070 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2071 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2075 settings
.endGroup();
2079 // Refresh alpine debug windows
2080 void MainWin::RefreshAlpineWindows(void)
2082 cpuBrowseWin
->RefreshContents();
2083 memBrowseWin
->RefreshContents();
2084 stackBrowseWin
->RefreshContents();
2085 emuStatusWin
->RefreshContents();
2086 opBrowseWin
->RefreshContents();
2087 riscDasmBrowseWin
->RefreshContents();
2088 m68kDasmBrowseWin
->RefreshContents();
2092 // Refresh soft debugger & alpine debug windows
2093 void MainWin::RefreshDebuggerWindows(void)
2097 if (vjs
.softTypeDebugger
)
2099 m68kDasmWin
->RefreshContents();
2100 GPUDasmWin
->RefreshContents();
2101 DSPDasmWin
->RefreshContents();
2102 allWatchBrowseWin
->RefreshContents();
2103 LocalBrowseWin
->RefreshContents();
2104 heapallocatorBrowseWin
->RefreshContents();
2105 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2107 mem1BrowseWin
[i
]->RefreshContents(i
);
2110 RefreshAlpineWindows();