UI modifications and crash fix
[clinton/Virtual-Jaguar-Rx.git] / src / gui / mainwin.cpp
1 //
2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
3 // by James Hammons
4 // (C) 2009 Underground Software
5 //
6 // JLH = James Hammons <jlhamm@acm.org>
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
8 //
9 // Who When What
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 window
20 // JPM 08/01/2017 Added heap allocator window
21 // JPM 08/07/2017 Added memories window
22 // JPM 08/10/2017 Added a restart feature
23 // JPM 08/31/2017 Added breakpoints window [Not Supported]
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 window
30 // JPM 08/31/2018 Added the call stack window
31 //
32
33 // FIXED:
34 //
35 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
36 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
37 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
38 // with 'R', etc) [DONE]
39 // - Controller configuration [DONE]
40 //
41 // STILL TO BE DONE:
42 //
43 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
44 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
45 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
46 // software doesn't)
47 //
48 // SFDX CODE: S1E9T8H5M23YS
49
50 // Uncomment this for debugging...
51 //#define DEBUG
52 //#define DEBUGFOO // Various tool debugging... but not used
53 //#define DEBUGTP // Toolpalette debugging... but not used
54
55 #include "mainwin.h"
56
57 #include "SDL.h"
58 #include "app.h"
59 #include "about.h"
60 #include "configdialog.h"
61 #include "controllertab.h"
62 #include "keybindingstab.h"
63 #include "filepicker.h"
64 #include "gamepad.h"
65 #include "generaltab.h"
66 #include "glwidget.h"
67 #include "help.h"
68 #include "profile.h"
69 #include "settings.h"
70 #include "version.h"
71 #include "emustatus.h"
72 #include "debug/cpubrowser.h"
73 #include "debug/m68kdasmbrowser.h"
74 #include "debug/memorybrowser.h"
75 #include "debug/stackbrowser.h"
76 #include "debug/opbrowser.h"
77 #include "debug/riscdasmbrowser.h"
78
79 #include "dac.h"
80 #include "jaguar.h"
81 #include "log.h"
82 #include "file.h"
83 #include "jagbios.h"
84 #include "jagbios2.h"
85 #include "jagcdbios.h"
86 #include "jagstub2bios.h"
87 #include "joystick.h"
88 #include "m68000/m68kinterface.h"
89
90 //#include "debugger/VideoWin.h"
91 #include "debugger/DasmWin.h"
92 #include "debugger/m68KDasmWin.h"
93 #include "debugger/GPUDasmWin.h"
94 #include "debugger/DSPDasmWin.h"
95 #include "debugger/memory1browser.h"
96 #include "debugger/brkWin.h"
97 #include "debugger/exceptionvectortablebrowser.h"
98 #include "debugger/allwatchbrowser.h"
99 #include "debugger/localbrowser.h"
100 #include "debugger/heapallocatorbrowser.h"
101 #include "debugger/callstackbrowser.h"
102
103
104 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
105 //#ifdef __GCCWIN32__
106 // Apparently on win32, usleep() is not pulled in by the usual suspects.
107 #ifndef _MSC_VER
108 #include <unistd.h>
109 #else
110 #include "_MSC_VER/unistd.h"
111 #endif // !_MSC_VER
112 //#endif
113
114 // The way BSNES controls things is by setting a timer with a zero
115 // timeout, sleeping if not emulating anything. Seems there has to be a
116 // better way.
117
118 // It has a novel approach to plugging-in/using different video/audio/input
119 // methods, can we do something similar or should we just use the built-in
120 // QOpenGL?
121
122 // We're going to try to use the built-in OpenGL support and see how it goes.
123 // We'll make the VJ core modular so that it doesn't matter what GUI is in
124 // use, we can drop it in anywhere and use it as-is.
125
126 MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
127 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
128 pauseForFileSelector(false), loadAndGo(autoRun), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
129 {
130 ReadSettings();
131
132 debugbar = NULL;
133
134 for(int i=0; i<8; i++)
135 keyHeld[i] = false;
136
137 // FPS management
138 for(int i=0; i<RING_BUFFER_SIZE; i++)
139 ringBuffer[i] = 0;
140
141 ringBufferPointer = RING_BUFFER_SIZE - 1;
142
143 // main window
144 //if (vjs.softTypeDebugger)
145 //{
146 // mainWindowCentrale = new QMdiArea;
147 // setCentralWidget(mainWindowCentrale);
148 //}
149
150 WriteLog("Window creation start\n");
151
152 // video output
153 videoWidget = new GLWidget(this);
154 videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
155
156 // set central output window
157 if (!vjs.softTypeDebugger)
158 {
159 setCentralWidget(videoWidget);
160 }
161 else
162 {
163 mainWindowCentrale = new QMdiArea(this);
164 setCentralWidget(mainWindowCentrale);
165 }
166
167 setWindowIcon(QIcon(":/res/vj-icon.png"));
168
169 QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION " Rx"));
170
171 if (vjs.hardwareTypeAlpine)
172 title += QString(tr(" - Alpine Mode"));
173
174 if (vjs.softTypeDebugger)
175 title += QString(tr(" - Debugger Mode"));
176
177 setWindowTitle(title);
178
179 aboutWin = new AboutWindow(this);
180 helpWin = new HelpWindow(this);
181 filePickWin = new FilePickerWindow(this);
182 memBrowseWin = new MemoryBrowserWindow(this);
183 stackBrowseWin = new StackBrowserWindow(this);
184 emuStatusWin = new EmuStatusWindow(this);
185 cpuBrowseWin = new CPUBrowserWindow(this);
186 opBrowseWin = new OPBrowserWindow(this);
187 m68kDasmBrowseWin = new M68KDasmBrowserWindow(this);
188 riscDasmBrowseWin = new RISCDasmBrowserWindow(this);
189 if (vjs.softTypeDebugger)
190 {
191 //VideoOutputWin = new VideoOutputWindow(this);
192 //VideoOutputWin->setCentralWidget()
193 //DasmWin = new DasmWindow();
194 DasmWin = new DasmWindow(this);
195 allWatchBrowseWin = new AllWatchBrowserWindow(this);
196 LocalBrowseWin = new LocalBrowserWindow(this);
197 heapallocatorBrowseWin = new HeapAllocatorBrowserWindow(this);
198 brkWin = new BrkWindow(this);
199 exceptionvectortableBrowseWin = new ExceptionVectorTableBrowserWindow(this);
200 CallStackBrowseWin = new CallStackBrowserWindow(this);
201
202 mem1BrowseWin = (Memory1BrowserWindow **)calloc(vjs.nbrmemory1browserwindow, sizeof(Memory1BrowserWindow));
203 #ifdef _MSC_VER
204 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
205 #else
206 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
207 #endif // _MSC_VER
208 for (size_t i = 0; i < vjs.nbrmemory1browserwindow; i++)
209 {
210 mem1BrowseWin[i] = new Memory1BrowserWindow(this);
211 }
212
213 dasmtabWidget = new QTabWidget(this);
214 dasmtabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
215 dasmtabWidget->addTab(m68kDasmWin = new m68KDasmWindow(this), tr("M68000"));
216 dasmtabWidget->addTab(GPUDasmWin = new GPUDasmWindow(this), tr("GPU"));
217 dasmtabWidget->addTab(DSPDasmWin = new DSPDasmWindow(this), tr("DSP"));
218 ////dasmtabWidget->addTab(m68kDasmBrowseWin, tr("M68000"));
219 setCentralWidget(dasmtabWidget);
220
221 #if 0
222 QDockWidget *shapesDockWidget = new QDockWidget(tr("Shapes"));
223 shapesDockWidget->setObjectName("shapesDockWidget");
224 shapesDockWidget->setWidget(m68kDasmWin);
225 //shapesDockWidget->setWidget(treeWidget);
226 shapesDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
227 addDockWidget(Qt::LeftDockWidgetArea, shapesDockWidget);
228 #endif
229 }
230
231 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
232 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
233
234 setUnifiedTitleAndToolBarOnMac(true);
235
236 // Create actions
237
238 quitAppAct = new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
239 // quitAppAct->setShortcuts(QKeySequence::Quit);
240 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
241 //quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
242 quitAppAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBQUIT].KBSettingValue)));
243 quitAppAct->setShortcutContext(Qt::ApplicationShortcut);
244 quitAppAct->setStatusTip(tr("Quit Virtual Jaguar"));
245 connect(quitAppAct, SIGNAL(triggered()), this, SLOT(close()));
246
247 powerGreen.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
248 powerGreen.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal, QIcon::On);
249 powerRed.addFile(":/res/power-off.png", QSize(), QIcon::Normal, QIcon::Off);
250 powerRed.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal, QIcon::On);
251
252 powerAct = new QAction(powerGreen, tr("&Power"), this);
253 powerAct->setStatusTip(tr("Powers Jaguar on/off"));
254 powerAct->setCheckable(true);
255 powerAct->setChecked(false);
256 connect(powerAct, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
257
258 QIcon pauseIcon;
259 pauseIcon.addFile(":/res/pause-off.png", QSize(), QIcon::Normal, QIcon::Off);
260 pauseIcon.addFile(":/res/pause-on.png", QSize(), QIcon::Normal, QIcon::On);
261 pauseAct = new QAction(pauseIcon, tr("Pause"), this);
262 pauseAct->setStatusTip(tr("Toggles the running state"));
263 pauseAct->setCheckable(true);
264 pauseAct->setDisabled(true);
265 //pauseAct->setShortcut(QKeySequence(tr("Esc")));
266 pauseAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBPAUSE].KBSettingValue)));
267 pauseAct->setShortcutContext(Qt::ApplicationShortcut);
268 connect(pauseAct, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
269
270 zoomActs = new QActionGroup(this);
271
272 x1Act = new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs);
273 x1Act->setStatusTip(tr("Set window zoom to 100%"));
274 x1Act->setCheckable(true);
275 connect(x1Act, SIGNAL(triggered()), this, SLOT(SetZoom100()));
276
277 x2Act = new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs);
278 x2Act->setStatusTip(tr("Set window zoom to 200%"));
279 x2Act->setCheckable(true);
280 connect(x2Act, SIGNAL(triggered()), this, SLOT(SetZoom200()));
281
282 x3Act = new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs);
283 x3Act->setStatusTip(tr("Set window zoom to 300%"));
284 x3Act->setCheckable(true);
285 connect(x3Act, SIGNAL(triggered()), this, SLOT(SetZoom300()));
286
287 tvTypeActs = new QActionGroup(this);
288
289 ntscAct = new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs);
290 ntscAct->setStatusTip(tr("Sets Jaguar to NTSC mode"));
291 ntscAct->setCheckable(true);
292 connect(ntscAct, SIGNAL(triggered()), this, SLOT(SetNTSC()));
293
294 palAct = new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs);
295 palAct->setStatusTip(tr("Sets Jaguar to PAL mode"));
296 palAct->setCheckable(true);
297 connect(palAct, SIGNAL(triggered()), this, SLOT(SetPAL()));
298
299 blur.addFile(":/res/blur-off.png", QSize(), QIcon::Normal, QIcon::Off);
300 blur.addFile(":/res/blur-on.png", QSize(), QIcon::Normal, QIcon::On);
301
302 blurAct = new QAction(blur, tr("Blur"), this);
303 blurAct->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
304 blurAct->setCheckable(true);
305 connect(blurAct, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
306
307 aboutAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
308 aboutAct->setStatusTip(tr("Blatant self-promotion"));
309 connect(aboutAct, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
310
311 helpAct = new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
312 helpAct->setStatusTip(tr("Help is available, if you should need it"));
313 connect(helpAct, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
314
315 if (!vjs.softTypeDebugger)
316 {
317 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
318 filePickAct->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
319 }
320 else
321 {
322 filePickAct = new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
323 filePickAct->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
324 }
325 //filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
326 filePickAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBPICKFILE].KBSettingValue)));
327 filePickAct->setShortcutContext(Qt::ApplicationShortcut);
328 connect(filePickAct, SIGNAL(triggered()), this, SLOT(InsertCart()));
329
330 configAct = new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
331 configAct->setStatusTip(tr("Configure options for Virtual Jaguar"));
332 //configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
333 configAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBCONFIGURE].KBSettingValue)));
334 configAct->setShortcutContext(Qt::ApplicationShortcut);
335 connect(configAct, SIGNAL(triggered()), this, SLOT(Configure()));
336
337 emustatusAct = new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
338 emustatusAct->setStatusTip(tr("Emulator status"));
339 //emustatusAct->setShortcut(QKeySequence(tr("Ctrl+s")));
340 emustatusAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBEMUSTATUS].KBSettingValue)));
341 emustatusAct->setShortcutContext(Qt::ApplicationShortcut);
342 connect(emustatusAct, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
343
344 useCDAct = new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
345 useCDAct->setStatusTip(tr("Use Jaguar Virtual CD unit"));
346 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
347 useCDAct->setCheckable(true);
348 connect(useCDAct, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
349
350 frameAdvanceAct = new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
351 //frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
352 frameAdvanceAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBFRAMEADVANCE].KBSettingValue)));
353 frameAdvanceAct->setShortcutContext(Qt::ApplicationShortcut);
354 frameAdvanceAct->setDisabled(true);
355 connect(frameAdvanceAct, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
356
357 if (vjs.softTypeDebugger)
358 {
359 restartAct = new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
360 //restartAct->setShortcut(QKeySequence(tr("Ctrl+Shift+F5")));
361 restartAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBRESTART].KBSettingValue)));
362 restartAct->setShortcutContext(Qt::ApplicationShortcut);
363 restartAct->setCheckable(false);
364 restartAct->setDisabled(true);
365 connect(restartAct, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
366
367 traceStepOverAct = new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
368 //traceStepOverAct->setShortcut(QKeySequence(tr("F10")));
369 traceStepOverAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBSTEPOVER].KBSettingValue)));
370 traceStepOverAct->setShortcutContext(Qt::ApplicationShortcut);
371 traceStepOverAct->setCheckable(false);
372 traceStepOverAct->setDisabled(true);
373 connect(traceStepOverAct, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
374
375 traceStepIntoAct = new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
376 //traceStepIntoAct->setShortcut(QKeySequence(tr("F11")));
377 traceStepIntoAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBSTEPINTO].KBSettingValue)));
378 traceStepIntoAct->setShortcutContext(Qt::ApplicationShortcut);
379 traceStepIntoAct->setCheckable(false);
380 traceStepIntoAct->setDisabled(true);
381 connect(traceStepIntoAct, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
382
383 newBreakpointFunctionAct = new QAction(QIcon(""), tr("&Function Breakpoint"), this);
384 newBreakpointFunctionAct->setShortcut(QKeySequence(tr("Ctrl+B")));
385 connect(newBreakpointFunctionAct, SIGNAL(triggered()), this, SLOT(NewBreakpointFunction()));
386 }
387
388 fullScreenAct = new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
389 //fullScreenAct->setShortcut(QKeySequence(tr("F9")));
390 fullScreenAct->setShortcut(QKeySequence(tr(vjs.KBContent[KBFULLSCREEN].KBSettingValue)));
391 fullScreenAct->setShortcutContext(Qt::ApplicationShortcut);
392 fullScreenAct->setCheckable(true);
393 connect(fullScreenAct, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
394
395 // Debugger Actions
396 if (vjs.softTypeDebugger)
397 {
398 exceptionVectorTableBrowseAct = new QAction(QIcon(""), tr("Exception Vector Table"), this);
399 exceptionVectorTableBrowseAct->setStatusTip(tr("Shows all Exception Vector Table browser window"));
400 connect(exceptionVectorTableBrowseAct, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
401
402 allWatchBrowseAct = new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
403 allWatchBrowseAct->setStatusTip(tr("Shows all Watch browser window"));
404 connect(allWatchBrowseAct, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
405
406 LocalBrowseAct = new QAction(QIcon(":/res/debug-local.png"), tr("Local"), this);
407 LocalBrowseAct->setStatusTip(tr("Shows Local browser window"));
408 connect(LocalBrowseAct, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
409
410 heapallocatorBrowseAct = new QAction(QIcon(""), tr("Heap allocator"), this);
411 heapallocatorBrowseAct->setStatusTip(tr("Shows the heap allocator browser window"));
412 connect(heapallocatorBrowseAct, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
413
414 CallStackBrowseAct = new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
415 CallStackBrowseAct->setStatusTip(tr("Shows Call Stack browser window"));
416 connect(CallStackBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
417
418 mem1BrowseAct = (QAction **)calloc(vjs.nbrmemory1browserwindow, sizeof(QAction));
419 QSignalMapper *signalMapper = new QSignalMapper(this);
420 #ifdef _MSC_VER
421 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
422 #else
423 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
424 #endif // _MSC_VER
425 for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
426 {
427 char MB[100];
428 sprintf(MB, "Memory %i", (unsigned int)(i+1));
429 mem1BrowseAct[i] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB), this);
430 mem1BrowseAct[i]->setStatusTip(tr("Shows a Jaguar memory browser window"));
431 //mem1BrowseAct[i]->
432 //connect(mem1BrowseAct[0], SIGNAL(triggered()), this, SLOT(ShowMemory1BrowserWin(size_t(0))));
433 connect(mem1BrowseAct[i], SIGNAL(triggered()), signalMapper, SLOT(map()));
434 signalMapper->setMapping(mem1BrowseAct[i], (int)i);
435 connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
436 }
437 }
438
439 // Debugger Browser Actions
440 memBrowseAct = new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
441 memBrowseAct->setStatusTip(tr("Shows the Jaguar memory browser window"));
442 // memBrowseAct->setCheckable(true);
443 connect(memBrowseAct, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
444
445 stackBrowseAct = new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
446 stackBrowseAct->setStatusTip(tr("Shows the Jaguar stack browser window"));
447 // memBrowseAct->setCheckable(true);
448 connect(stackBrowseAct, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
449
450 cpuBrowseAct = new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
451 cpuBrowseAct->setStatusTip(tr("Shows the Jaguar CPU browser window"));
452 // memBrowseAct->setCheckable(true);
453 connect(cpuBrowseAct, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
454
455 opBrowseAct = new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
456 opBrowseAct->setStatusTip(tr("Shows the Jaguar OP browser window"));
457 // memBrowseAct->setCheckable(true);
458 connect(opBrowseAct, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
459
460 m68kDasmBrowseAct = new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
461 m68kDasmBrowseAct->setStatusTip(tr("Shows the 68K disassembly browser window"));
462 // memBrowseAct->setCheckable(true);
463 connect(m68kDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
464
465 riscDasmBrowseAct = new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
466 riscDasmBrowseAct->setStatusTip(tr("Shows the RISC disassembly browser window"));
467 // memBrowseAct->setCheckable(true);
468 connect(riscDasmBrowseAct, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
469
470 if (vjs.softTypeDebugger)
471 {
472 VideoOutputAct = new QAction(tr("Output Video"), this);
473 VideoOutputAct->setStatusTip(tr("Shows the output video window"));
474 connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
475
476 DasmAct = new QAction(tr("Disassembly"), this);
477 DasmAct->setStatusTip(tr("Shows the disassembly window"));
478 connect(DasmAct, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
479 }
480
481 // Misc. connections...
482 connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString)));
483 connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
484
485 // Create menus
486
487 fileMenu = menuBar()->addMenu(tr("&Jaguar"));
488 fileMenu->addAction(powerAct);
489 if (!vjs.softTypeDebugger)
490 {
491 fileMenu->addAction(pauseAct);
492 // fileMenu->addAction(frameAdvanceAct);
493 }
494 fileMenu->addAction(filePickAct);
495 fileMenu->addAction(useCDAct);
496 fileMenu->addAction(configAct);
497 fileMenu->addAction(emustatusAct);
498 fileMenu->addSeparator();
499 fileMenu->addAction(quitAppAct);
500
501 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
502 {
503 debugMenu = menuBar()->addMenu(tr("&Debug"));
504 if (vjs.softTypeDebugger)
505 {
506 debugWindowsMenu = debugMenu->addMenu(tr("&Windows"));
507 debugWindowExceptionMenu = debugWindowsMenu->addMenu(tr("&Exception"));
508 debugWindowExceptionMenu->addAction(exceptionVectorTableBrowseAct);
509 debugWindowsMenu->addSeparator();
510 #if 0
511 debugWindowOutputMenu = debugWindowsMenu->addMenu(tr("&Output"));
512 debugWindowOutputMenu->addAction(VideoOutputAct);
513 debugWindowsMenu->addSeparator();
514 #endif
515 debugWindowsWatchMenu = debugWindowsMenu->addMenu(tr("&Watch"));
516 debugWindowsWatchMenu->addAction(allWatchBrowseAct);
517 debugWindowsMenu->addAction(LocalBrowseAct);
518 debugWindowsMenu->addSeparator();
519 debugWindowsMenu->addAction(CallStackBrowseAct);
520 debugWindowsMenu->addSeparator();
521 debugWindowsMemoryMenu = debugWindowsMenu->addMenu(tr("&Memory"));
522 debugWindowsMemoryMenu->addAction(heapallocatorBrowseAct);
523 debugWindowsMemoryMenu->addSeparator();
524 for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
525 {
526 debugWindowsMemoryMenu->addAction(mem1BrowseAct[i]);
527 }
528 debugWindowsMenu->addSeparator();
529 debugWindowsBrowsesMenu = debugWindowsMenu->addMenu(tr("&Browsers"));
530 debugWindowsBrowsesMenu->addAction(memBrowseAct);
531 debugWindowsBrowsesMenu->addAction(stackBrowseAct);
532 debugWindowsBrowsesMenu->addAction(cpuBrowseAct);
533 debugWindowsBrowsesMenu->addAction(opBrowseAct);
534 debugWindowsBrowsesMenu->addAction(m68kDasmBrowseAct);
535 debugWindowsBrowsesMenu->addAction(riscDasmBrowseAct);
536 debugMenu->addSeparator();
537 debugMenu->addAction(pauseAct);
538 debugMenu->addAction(frameAdvanceAct);
539 debugMenu->addAction(restartAct);
540 debugMenu->addSeparator();
541 debugMenu->addAction(traceStepIntoAct);
542 debugMenu->addAction(traceStepOverAct);
543 #if 0
544 debugMenu->addSeparator();
545 debugNewBreakpointMenu = debugMenu->addMenu(tr("&New Breakpoint"));
546 debugNewBreakpointMenu->addAction(newBreakpointFunctionAct);
547 #endif
548 //debugMenu->addSeparator();
549 //debugMenu->addAction(DasmAct);
550 }
551 else
552 {
553 debugMenu->addAction(memBrowseAct);
554 debugMenu->addAction(stackBrowseAct);
555 debugMenu->addAction(cpuBrowseAct);
556 debugMenu->addAction(opBrowseAct);
557 debugMenu->addAction(m68kDasmBrowseAct);
558 debugMenu->addAction(riscDasmBrowseAct);
559 }
560 }
561
562 helpMenu = menuBar()->addMenu(tr("&Help"));
563 helpMenu->addAction(helpAct);
564 helpMenu->addAction(aboutAct);
565
566 // Create toolbars
567
568 toolbar = addToolBar(tr("Stuff"));
569 toolbar->addAction(powerAct);
570 if (!vjs.softTypeDebugger)
571 {
572 toolbar->addAction(pauseAct);
573 toolbar->addAction(frameAdvanceAct);
574 }
575 toolbar->addAction(filePickAct);
576 toolbar->addAction(useCDAct);
577 toolbar->addSeparator();
578 if (!vjs.softTypeDebugger)
579 {
580 toolbar->addAction(x1Act);
581 toolbar->addAction(x2Act);
582 toolbar->addAction(x3Act);
583 toolbar->addSeparator();
584 toolbar->addAction(ntscAct);
585 toolbar->addAction(palAct);
586 toolbar->addSeparator();
587 toolbar->addAction(blurAct);
588 toolbar->addAction(fullScreenAct);
589 }
590 else
591 {
592 debuggerbar = addToolBar(tr("&Debugger"));
593 debuggerbar->addAction(pauseAct);
594 debuggerbar->addAction(frameAdvanceAct);
595 debuggerbar->addAction(restartAct);
596 debuggerbar->addSeparator();
597 debuggerbar->addAction(traceStepIntoAct);
598 debuggerbar->addAction(traceStepOverAct);
599 }
600
601 if (vjs.hardwareTypeAlpine)
602 {
603 debugbar = addToolBar(tr("&Debug"));
604 debugbar->addAction(memBrowseAct);
605 debugbar->addAction(stackBrowseAct);
606 debugbar->addAction(cpuBrowseAct);
607 debugbar->addAction(opBrowseAct);
608 debugbar->addAction(m68kDasmBrowseAct);
609 debugbar->addAction(riscDasmBrowseAct);
610 }
611
612 // Add actions to the main window, as hiding widgets with them
613 // disables them :-P
614 addAction(fullScreenAct);
615 addAction(quitAppAct);
616 addAction(configAct);
617 addAction(emustatusAct);
618 addAction(pauseAct);
619 addAction(filePickAct);
620 addAction(frameAdvanceAct);
621
622 // Create status bar
623 statusBar()->showMessage(tr("Ready"));
624 ReadUISettings();
625 // Do this in case original size isn't correct (mostly for the first-run case)
626 ResizeMainWindow();
627
628 WriteLog("Window creation done\n");
629
630 // Create our test pattern NTSC bitmap
631 WriteLog("Test pattern 1 bitmap\n");
632
633 QImage tempImg(":/res/test-pattern.jpg");
634 QImage tempImgScaled = tempImg.scaled(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT_PAL, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
635
636 for(uint32_t y=0; y<VIRTUAL_SCREEN_HEIGHT_PAL; y++)
637 {
638 const QRgb * scanline = (QRgb *)tempImgScaled.constScanLine(y);
639
640 for(uint32_t x=0; x<VIRTUAL_SCREEN_WIDTH; x++)
641 {
642 uint32_t pixel = (qRed(scanline[x]) << 24) | (qGreen(scanline[x]) << 16) | (qBlue(scanline[x]) << 8) | 0xFF;
643 testPattern[(y * VIRTUAL_SCREEN_WIDTH) + x] = pixel;
644 }
645 }
646
647 // Create our test pattern PAL bitmap
648 WriteLog("Test pattern 2 bitmap\n");
649
650 QImage tempImg2(":/res/test-pattern-pal.jpg");
651 QImage tempImgScaled2 = tempImg2.scaled(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT_PAL, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
652
653 for(uint32_t y=0; y<VIRTUAL_SCREEN_HEIGHT_PAL; y++)
654 {
655 const QRgb * scanline = (QRgb *)tempImgScaled2.constScanLine(y);
656
657 for(uint32_t x=0; x<VIRTUAL_SCREEN_WIDTH; x++)
658 {
659 uint32_t pixel = (qRed(scanline[x]) << 24) | (qGreen(scanline[x]) << 16) | (qBlue(scanline[x]) << 8) | 0xFF;
660 testPattern2[(y * VIRTUAL_SCREEN_WIDTH) + x] = pixel;
661 }
662 }
663
664 // Set up timer based loop for animation...
665 timer = new QTimer(this);
666 connect(timer, SIGNAL(timeout()), this, SLOT(Timer()));
667
668 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
669 // This is because it's discarding the 0.6666... on the end of the fraction.
670 // Alas, 6 doesn't divide cleanly into 10. :-P
671 //Should we defer this until SyncUI? Probably.
672 //No, it doesn't work, because it uses setInterval() instead of start()...
673 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
674
675 // We set this initially, to make VJ behave somewhat as it would if no
676 // cart were inserted and the BIOS was set as active...
677 jaguarCartInserted = true;
678 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__);
679 WriteLog("VJ: Initializing jaguar subsystem...\n");
680 JaguarInit();
681 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
682 memcpy(jagMemSpace + 0xE00000, (vjs.biosType == BT_K_SERIES ? jaguarBootROM : jaguarBootROM2), 0x20000); // Use the stock BIOS
683
684 // Prevent the file scanner from running if filename passed
685 // in on the command line...
686 if (autoRun)
687 return;
688
689 // Load up the default ROM if in Alpine mode:
690 if (vjs.hardwareTypeAlpine)
691 {
692 bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
693
694 // If regular load failed, try just a straight file load
695 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
696 if (!romLoaded)
697 romLoaded = AlpineLoadFile(vjs.alpineROMPath);
698
699 if (romLoaded)
700 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
701 else
702 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
703
704 // Attempt to load/run the ABS file...
705 LoadSoftware(vjs.absROMPath);
706 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
707 // Prevent the scanner from running...
708 return;
709 }
710
711 // Load up the default ROM if in Debugger mode:
712 if (vjs.softTypeDebugger)
713 {
714 bool romLoaded = JaguarLoadFile(vjs.debuggerROMPath);
715
716 // If regular load failed, try just a straight file load
717 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
718 if (!romLoaded)
719 romLoaded = DebuggerLoadFile(vjs.debuggerROMPath);
720
721 if (romLoaded)
722 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs.debuggerROMPath);
723 else
724 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs.debuggerROMPath);
725
726 // Attempt to load/run the ABS file...
727 LoadSoftware(vjs.absROMPath);
728 memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS
729 // Prevent the scanner from running...
730 return;
731 }
732
733 // Run the scanner if nothing passed in and *not* Alpine mode...
734 // NB: Really need to look into caching the info scanned in here...
735 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
736 scannedSoftwareFolder = true;
737 }
738
739
740 void MainWin::LoadFile(QString file)
741 {
742 LoadSoftware(file);
743 }
744
745
746 void MainWin::SyncUI(void)
747 {
748 // Set toolbar buttons/menus based on settings read in (sync the UI)...
749 // (Really, this is to sync command line options passed in)
750 blurAct->setChecked(vjs.glFilter);
751 x1Act->setChecked(zoomLevel == 1);
752 x2Act->setChecked(zoomLevel == 2);
753 x3Act->setChecked(zoomLevel == 3);
754 // running = powerAct->isChecked();
755 ntscAct->setChecked(vjs.hardwareTypeNTSC);
756 palAct->setChecked(!vjs.hardwareTypeNTSC);
757 powerAct->setIcon(vjs.hardwareTypeNTSC ? powerRed : powerGreen);
758
759 fullScreenAct->setChecked(vjs.fullscreen);
760 fullScreen = vjs.fullscreen;
761 SetFullScreen(fullScreen);
762
763 // Reset the timer to be what was set in the command line (if any):
764 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
765 timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
766 }
767
768
769 void MainWin::closeEvent(QCloseEvent * event)
770 {
771 JaguarDone();
772 // This should only be done by the config dialog
773 // WriteSettings();
774 WriteUISettings();
775 event->accept(); // ignore() if can't close for some reason
776 }
777
778
779 void MainWin::keyPressEvent(QKeyEvent * e)
780 {
781 #ifndef VJ_REMOVE_DEV_CODE
782 // From jaguar.cpp
783 //extern bool startM68KTracing; // moved to jaguar.h
784 // From joystick.cpp
785 extern int blit_start_log;
786 // From blitter.cpp
787 extern bool startConciseBlitLogging;
788 #endif
789
790 // We ignore the Alt key for now, since it causes problems with the GUI
791 if (e->key() == Qt::Key_Alt)
792 {
793 e->accept();
794 return;
795 }
796 // Bar this shite from release versions kthxbai
797 #ifndef VJ_REMOVE_DEV_CODE
798 else if (e->key() == Qt::Key_F11)
799 {
800 startM68KTracing = true;
801 e->accept();
802 return;
803 }
804 else if (e->key() == Qt::Key_F12)
805 {
806 blit_start_log = true;
807 e->accept();
808 return;
809 }
810 else if (e->key() == Qt::Key_F10)
811 {
812 startConciseBlitLogging = true;
813 e->accept();
814 return;
815 }
816 #endif
817 else if (e->key() == Qt::Key_F8)
818 {
819 // ggn: For extra NYAN pleasure...
820 // ggn: There you go James :P
821 // Shamus: Thanks for the patch! :-D
822 WriteLog(" o + + +\n");
823 WriteLog("+ o o + o\n");
824 WriteLog("-_-_-_-_-_-_-_,------, o \n");
825 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
826 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
827 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
828 WriteLog("+ o o + o\n");
829 WriteLog(" + +\n");
830 e->accept();
831 return;
832 }
833
834 /*
835 This is done now by a QAction...
836 if (e->key() == Qt::Key_F9)
837 {
838 ToggleFullScreen();
839 return;
840 }
841 */
842 HandleKeys(e, true);
843 }
844
845
846 void MainWin::keyReleaseEvent(QKeyEvent * e)
847 {
848 // We ignore the Alt key for now, since it causes problems with the GUI
849 if (e->key() == Qt::Key_Alt)
850 {
851 e->accept();
852 return;
853 }
854
855 HandleKeys(e, false);
856 }
857
858
859 void MainWin::HandleKeys(QKeyEvent * e, bool state)
860 {
861 enum { P1LEFT = 0, P1RIGHT, P1UP, P1DOWN, P2LEFT, P2RIGHT, P2UP, P2DOWN };
862 // We kill bad key combos here, before they can get to the emulator...
863 // This also kills the illegal instruction problem that cropped up in
864 // Rayman!
865
866 // First, settle key states...
867 if (e->key() == (int)vjs.p1KeyBindings[BUTTON_L])
868 keyHeld[P1LEFT] = state;
869 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_R])
870 keyHeld[P1RIGHT] = state;
871 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_U])
872 keyHeld[P1UP] = state;
873 else if (e->key() == (int)vjs.p1KeyBindings[BUTTON_D])
874 keyHeld[P1DOWN] = state;
875 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_L])
876 keyHeld[P2LEFT] = state;
877 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_R])
878 keyHeld[P2RIGHT] = state;
879 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_U])
880 keyHeld[P2UP] = state;
881 else if (e->key() == (int)vjs.p2KeyBindings[BUTTON_D])
882 keyHeld[P2DOWN] = state;
883
884 // Next, check for conflicts and kill 'em if there are any...
885 if (keyHeld[P1LEFT] && keyHeld[P1RIGHT])
886 keyHeld[P1LEFT] = keyHeld[P1RIGHT] = false;
887
888 if (keyHeld[P1UP] && keyHeld[P1DOWN])
889 keyHeld[P1UP] = keyHeld[P1DOWN] = false;
890
891 if (keyHeld[P2LEFT] && keyHeld[P2RIGHT])
892 keyHeld[P2LEFT] = keyHeld[P2RIGHT] = false;
893
894 if (keyHeld[P2UP] && keyHeld[P2DOWN])
895 keyHeld[P2UP] = keyHeld[P2DOWN] = false;
896
897 // No bad combos exist now, let's stuff the emulator key buffers...!
898 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
899 {
900 if (e->key() == (int)vjs.p1KeyBindings[i])
901 joypad0Buttons[i] = (state ? 0x01 : 0x00);
902
903 if (e->key() == (int)vjs.p2KeyBindings[i])
904 joypad1Buttons[i] = (state ? 0x01 : 0x00);
905 }
906 }
907
908
909 //
910 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
911 //
912 void MainWin::HandleGamepads(void)
913 {
914 Gamepad::Update();
915
916 for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
917 {
918 if (vjs.p1KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
919 joypad0Buttons[i] = (Gamepad::GetState(gamepadIDSlot1, vjs.p1KeyBindings[i]) ? 0x01 : 0x00);
920
921 if (vjs.p2KeyBindings[i] & (JOY_BUTTON | JOY_HAT | JOY_AXIS))
922 joypad1Buttons[i] = (Gamepad::GetState(gamepadIDSlot2, vjs.p2KeyBindings[i]) ? 0x01 : 0x00);
923 }
924 }
925
926
927 void MainWin::Open(void)
928 {
929 }
930
931
932 void MainWin::Configure(void)
933 {
934 // Call the configuration dialog and update settings
935 ConfigDialog dlg(this);
936 //ick.
937 dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
938 dlg.controllerTab1->profileNum = lastEditedProfile;
939 dlg.controllerTab1->SetupLastUsedProfile();
940 // maybe instead of this, we tell the controller tab to work on a copy that gets
941 // written if the user hits 'OK'.
942 SaveProfiles(); // Just in case user cancels
943
944 if (dlg.exec() == false)
945 {
946 RestoreProfiles();
947 return;
948 }
949
950 QString before = vjs.ROMPath;
951 QString alpineBefore = vjs.alpineROMPath;
952 QString absBefore = vjs.absROMPath;
953 // bool audioBefore = vjs.audioEnabled;
954 bool audioBefore = vjs.DSPEnabled;
955 dlg.UpdateVJSettings();
956 QString after = vjs.ROMPath;
957 QString alpineAfter = vjs.alpineROMPath;
958 QString absAfter = vjs.absROMPath;
959 // bool audioAfter = vjs.audioEnabled;
960 bool audioAfter = vjs.DSPEnabled;
961
962 bool allowOld = allowUnknownSoftware;
963 //ick.
964 allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
965 lastEditedProfile = dlg.controllerTab1->profileNum;
966 AutoConnectProfiles();
967
968 // We rescan the "software" folder if the user either changed the path or
969 // checked/unchecked the "Allow unknown files" option in the config dialog.
970 if ((before != after) || (allowOld != allowUnknownSoftware))
971 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
972
973 // If the "Alpine" ROM is changed, then let's load it...
974 if (alpineBefore != alpineAfter)
975 {
976 if (!JaguarLoadFile(vjs.alpineROMPath) && !AlpineLoadFile(vjs.alpineROMPath))
977 {
978 // Oh crap, we couldn't get the file! Alert the media!
979 QMessageBox msg;
980 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.alpineROMPath));
981 msg.setIcon(QMessageBox::Warning);
982 msg.exec();
983 }
984 }
985
986 // If the "ABS" ROM is changed, then let's load it...
987 if (absBefore != absAfter)
988 {
989 if (!JaguarLoadFile(vjs.absROMPath))
990 {
991 // Oh crap, we couldn't get the file! Alert the media!
992 QMessageBox msg;
993 msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
994 msg.setIcon(QMessageBox::Warning);
995 msg.exec();
996 }
997 }
998
999 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1000 // since it's running in the host audio IRQ...
1001 if (audioBefore != audioAfter)
1002 {
1003 DACDone();
1004 DACInit();
1005 }
1006
1007 // Just in case we crash before a clean exit...
1008 WriteSettings();
1009
1010 DebuggerRefreshWindows();
1011 }
1012
1013
1014 //
1015 // Here's the main emulator loop
1016 //
1017 void MainWin::Timer(void)
1018 {
1019 #if 0
1020 static uint32_t ntscTickCount;
1021 if (vjs.hardwareTypeNTSC)
1022 {
1023 ntscTickCount++;
1024 ntscTickCount %= 3;
1025 timer->start(16 + (ntscTickCount == 0 ? 1 : 0));
1026 }
1027 #endif
1028
1029 if (!running)
1030 return;
1031
1032 if (showUntunedTankCircuit)
1033 {
1034 // Some machines can't handle this, so we give them the option to disable it. :-)
1035 if (!plzDontKillMyComputer)
1036 {
1037 // if (!vjs.softTypeDebugger)
1038 {
1039 // Random hash & trash
1040 // We try to simulate an untuned tank circuit here... :-)
1041 for (uint32_t x = 0; x < videoWidget->rasterWidth; x++)
1042 {
1043 for (uint32_t y = 0; y < videoWidget->rasterHeight; y++)
1044 {
1045 videoWidget->buffer[(y * videoWidget->textureWidth) + x] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1046 }
1047 }
1048 }
1049 }
1050 }
1051 else
1052 {
1053 // Otherwise, run the Jaguar simulation
1054 HandleGamepads();
1055 JaguarExecuteNew();
1056 if (!vjs.softTypeDebugger)
1057 videoWidget->HandleMouseHiding();
1058
1059 static uint32_t refresh = 0;
1060 // Do autorefresh on debug windows
1061 // Have to be careful, too much causes the emulator to slow way down!
1062 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
1063 {
1064 if (refresh == vjs.refresh)
1065 {
1066 RefreshAlpineWindows();
1067 //memBrowseWin->RefreshContents();
1068 //cpuBrowseWin->RefreshContents();
1069 refresh = 0;
1070 }
1071 else
1072 refresh++;
1073 }
1074 }
1075
1076 //if (!vjs.softTypeDebugger)
1077 videoWidget->updateGL();
1078
1079 // FPS handling
1080 // Approach: We use a ring buffer to store times (in ms) over a given
1081 // amount of frames, then sum them to figure out the FPS.
1082 uint32_t timestamp = SDL_GetTicks();
1083 // This assumes the ring buffer size is a power of 2
1084 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1085 // Doing it this way is better. Ring buffer size can be arbitrary then.
1086 ringBufferPointer = (ringBufferPointer + 1) % RING_BUFFER_SIZE;
1087 ringBuffer[ringBufferPointer] = timestamp - oldTimestamp;
1088 uint32_t elapsedTime = 0;
1089
1090 for(uint32_t i=0; i<RING_BUFFER_SIZE; i++)
1091 elapsedTime += ringBuffer[i];
1092
1093 // elapsedTime must be non-zero
1094 if (elapsedTime == 0)
1095 elapsedTime = 1;
1096
1097 // This is in frames per 10 seconds, so we can have 1 decimal
1098 uint32_t framesPerSecond = (uint32_t)(((float)RING_BUFFER_SIZE / (float)elapsedTime) * 10000.0);
1099 uint32_t fpsIntegerPart = framesPerSecond / 10;
1100 uint32_t fpsDecimalPart = framesPerSecond % 10;
1101 // If this is updated too frequently to be useful, we can throttle it down
1102 // so that it only updates every 10th frame or so
1103 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart).arg(fpsDecimalPart));
1104 oldTimestamp = timestamp;
1105
1106 if (M68KDebugHaltStatus())
1107 ToggleRunState();
1108 }
1109
1110
1111 void MainWin::TogglePowerState(void)
1112 {
1113 powerButtonOn = !powerButtonOn;
1114 running = true;
1115
1116 // With the power off, we simulate white noise on the screen. :-)
1117 if (!powerButtonOn)
1118 {
1119 // Restore the mouse pointer, if hidden:
1120 if (!vjs.softTypeDebugger)
1121 videoWidget->CheckAndRestoreMouseCursor();
1122 useCDAct->setDisabled(false);
1123 palAct->setDisabled(false);
1124 ntscAct->setDisabled(false);
1125 pauseAct->setChecked(false);
1126 pauseAct->setDisabled(true);
1127 showUntunedTankCircuit = true;
1128 DACPauseAudioThread();
1129 // This is just in case the ROM we were playing was in a narrow or wide
1130 // field mode, so the untuned tank sim doesn't look wrong. :-)
1131 TOMReset();
1132
1133 if (plzDontKillMyComputer)
1134 {
1135 //if (!vjs.softTypeDebugger)
1136 {
1137 // We have to do it line by line, because the texture pitch is not
1138 // the same as the picture buffer's pitch.
1139 for (uint32_t y = 0; y < videoWidget->rasterHeight; y++)
1140 {
1141 if (vjs.hardwareTypeNTSC)
1142 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1143 else
1144 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern2 + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1145 }
1146 }
1147 }
1148 }
1149 else
1150 {
1151 useCDAct->setDisabled(true);
1152 palAct->setDisabled(true);
1153 ntscAct->setDisabled(true);
1154 pauseAct->setChecked(false);
1155 pauseAct->setDisabled(false);
1156 showUntunedTankCircuit = false;
1157
1158 // Otherwise, we prepare for running regular software...
1159 if (CDActive)
1160 {
1161 // Should check for cartridgeLoaded here as well...!
1162 // We can clear it when toggling CDActive on, so that when we power cycle it
1163 // does the expected thing. Otherwise, if we use the file picker to insert a
1164 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1165 // works if the CD unit is active?
1166 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION " Rx - Now playing: Jaguar CD"));
1167 }
1168
1169 WriteLog("GUI: Resetting Jaguar...\n");
1170 JaguarReset();
1171 DebuggerResetWindows();
1172 DACPauseAudioThread(false);
1173 }
1174 }
1175
1176
1177 void MainWin::ToggleRunState(void)
1178 {
1179 startM68KTracing = running;
1180 running = !running;
1181
1182 if (!running)
1183 {
1184 frameAdvanceAct->setDisabled(false);
1185 pauseAct->setChecked(true);
1186 pauseAct->setDisabled(false);
1187 if (vjs.softTypeDebugger)
1188 {
1189 traceStepIntoAct->setDisabled(false);
1190 traceStepOverAct->setDisabled(false);
1191 restartAct->setDisabled(false);
1192 m68kDasmWin->Use68KPCAddress();
1193 GPUDasmWin->UseGPUPCAddress();
1194 DSPDasmWin->UseDSPPCAddress();
1195 }
1196
1197 //if (!vjs.softTypeDebugger)
1198 {
1199 // Restore the mouse pointer, if hidden:
1200 videoWidget->CheckAndRestoreMouseCursor();
1201 // frameAdvanceAct->setDisabled(false);
1202
1203 for (uint32_t i = 0; i < (uint32_t)(videoWidget->textureWidth * 256); i++)
1204 {
1205 uint32_t pixel = videoWidget->buffer[i];
1206 uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF;
1207 pixel = ((r + g + b) / 3) & 0x00FF;
1208 videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8);
1209 }
1210
1211 videoWidget->updateGL();
1212
1213 cpuBrowseWin->HoldBPM();
1214 cpuBrowseWin->HandleBPMContinue();
1215 DebuggerRefreshWindows();
1216 }
1217 }
1218 else
1219 {
1220 frameAdvanceAct->setDisabled(true);
1221 pauseAct->setChecked(false);
1222 pauseAct->setDisabled(false);
1223 if (vjs.softTypeDebugger)
1224 {
1225 traceStepIntoAct->setDisabled(true);
1226 traceStepOverAct->setDisabled(true);
1227 restartAct->setDisabled(true);
1228 }
1229
1230 cpuBrowseWin->UnholdBPM();
1231 }
1232
1233 // Pause/unpause any running/non-running threads...
1234 DACPauseAudioThread(!running);
1235 }
1236
1237
1238 void MainWin::SetZoom100(void)
1239 {
1240 zoomLevel = 1;
1241 ResizeMainWindow();
1242 }
1243
1244
1245 void MainWin::SetZoom200(void)
1246 {
1247 zoomLevel = 2;
1248 ResizeMainWindow();
1249 }
1250
1251
1252 void MainWin::SetZoom300(void)
1253 {
1254 zoomLevel = 3;
1255 ResizeMainWindow();
1256 }
1257
1258
1259 void MainWin::SetNTSC(void)
1260 {
1261 powerAct->setIcon(powerRed);
1262 timer->setInterval(16);
1263 vjs.hardwareTypeNTSC = true;
1264 ResizeMainWindow();
1265 WriteSettings();
1266 }
1267
1268
1269 void MainWin::SetPAL(void)
1270 {
1271 powerAct->setIcon(powerGreen);
1272 timer->setInterval(20);
1273 vjs.hardwareTypeNTSC = false;
1274 ResizeMainWindow();
1275 WriteSettings();
1276 }
1277
1278
1279 void MainWin::ToggleBlur(void)
1280 {
1281 vjs.glFilter = !vjs.glFilter;
1282 WriteSettings();
1283 }
1284
1285
1286 void MainWin::ShowAboutWin(void)
1287 {
1288 aboutWin->show();
1289 }
1290
1291
1292 void MainWin::ShowHelpWin(void)
1293 {
1294 helpWin->show();
1295 }
1296
1297
1298 void MainWin::InsertCart(void)
1299 {
1300 // Check to see if we did autorun, 'cause we didn't load anything in that
1301 // case
1302 if (!scannedSoftwareFolder)
1303 {
1304 filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
1305 scannedSoftwareFolder = true;
1306 }
1307
1308 // If the emulator is running, we pause it here and unpause it later
1309 // if we dismiss the file selector without choosing anything
1310 if (running && powerButtonOn)
1311 {
1312 ToggleRunState();
1313 pauseForFileSelector = true;
1314 }
1315
1316 filePickWin->show();
1317 }
1318
1319
1320 void MainWin::Unpause(void)
1321 {
1322 // Here we unpause the emulator if it was paused when we went into the file selector
1323 if (pauseForFileSelector)
1324 {
1325 pauseForFileSelector = false;
1326
1327 // Some nutter might have unpaused while in the file selector, so check for that
1328 if (!running)
1329 ToggleRunState();
1330 }
1331 }
1332
1333
1334 // Jaguar initialisation and load software file
1335 void MainWin::LoadSoftware(QString file)
1336 {
1337 running = false; // Prevent bad things(TM) from happening...
1338 pauseForFileSelector = false; // Reset the file selector pause flag
1339
1340 uint8_t * biosPointer = jaguarBootROM;
1341
1342 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
1343 {
1344 biosPointer = jaguarDevBootROM2;
1345 }
1346
1347 memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
1348
1349 powerAct->setDisabled(false);
1350 powerAct->setChecked(true);
1351 powerButtonOn = false;
1352 TogglePowerState();
1353
1354 // We have to load our software *after* the Jaguar RESET
1355 cartridgeLoaded = JaguarLoadFile(file.toUtf8().data());
1356 SET32(jaguarMainRAM, 0, vjs.DRAM_size); // Set top of stack...
1357
1358 // This is icky because we've already done it
1359 // it gets worse :-P
1360 if (!vjs.useJaguarBIOS)
1361 {
1362 SET32(jaguarMainRAM, 4, jaguarRunAddress);
1363 }
1364
1365 m68k_pulse_reset();
1366
1367 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1368 if (vjs.softTypeDebugger)
1369 {
1370 m68k_set_reg(M68K_REG_A6, 0);
1371 m68kDasmWin->SetAddress(jaguarRunAddress);
1372 //pauseAct->setDisabled(false);
1373 //pauseAct->setChecked(true);
1374 ToggleRunState();
1375 //RefreshWindows();
1376 }
1377 else
1378 {
1379 if (vjs.hardwareTypeAlpine && !jaguarRunAddress)
1380 {
1381 ToggleRunState();
1382 }
1383 }
1384
1385 if ((!vjs.hardwareTypeAlpine || !vjs.softTypeDebugger) && !loadAndGo && jaguarRunAddress)
1386 {
1387 QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " Rx - Now playing: %1").arg(filePickWin->GetSelectedPrettyName());
1388 setWindowTitle(newTitle);
1389 }
1390 }
1391
1392
1393 void MainWin::ToggleCDUsage(void)
1394 {
1395 CDActive = !CDActive;
1396
1397 // Set up the Jaguar CD for execution, otherwise, clear memory
1398 if (CDActive)
1399 memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
1400 else
1401 memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
1402 }
1403
1404
1405 //
1406 void MainWin::NewBreakpointFunction(void)
1407 {
1408 brkWin->show();
1409 brkWin->RefreshContents();
1410 }
1411
1412
1413 // Step Into trace
1414 void MainWin::DebuggerTraceStepInto(void)
1415 {
1416 JaguarStepInto();
1417 videoWidget->updateGL();
1418 DebuggerRefreshWindows();
1419 #ifdef _MSC_VER
1420 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1421 #else
1422 #warning "!!! Need to verify the Step Into function !!!"
1423 #endif // _MSC_VER
1424 }
1425
1426
1427 // Restart
1428 void MainWin::DebuggerRestart(void)
1429 {
1430 #if 1
1431 m68k_pulse_reset();
1432 #else
1433 m68k_set_reg(M68K_REG_PC, jaguarRunAddress);
1434 m68k_set_reg(M68K_REG_SP, vjs.DRAM_size);
1435 #endif
1436 m68k_set_reg(M68K_REG_A6, 0);
1437
1438 DebuggerResetWindows();
1439 DebuggerRefreshWindows();
1440 #ifdef _MSC_VER
1441 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1442 #else
1443 #warning "!!! Need to verify the Restart function !!!"
1444 #endif // _MSC_VER
1445 }
1446
1447
1448 // Step Over trace
1449 void MainWin::DebuggerTraceStepOver(void)
1450 {
1451 JaguarStepOver(0);
1452 videoWidget->updateGL();
1453 DebuggerRefreshWindows();
1454 #ifdef _MSC_VER
1455 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1456 #else
1457 #warning "!!! Need to verify the Step Over function !!!"
1458 #endif // _MSC_VER
1459 }
1460
1461
1462 // Advance / Execute for one frame
1463 void MainWin::FrameAdvance(void)
1464 {
1465 //printf("Frame Advance...\n");
1466 ToggleRunState();
1467 // Execute 1 frame, then exit (only useful in Pause mode)
1468 JaguarExecuteNew();
1469 //if (!vjs.softTypeDebugger)
1470 videoWidget->updateGL();
1471 ToggleRunState();
1472 // Need to execute 1 frames' worth of DSP thread as well :-/
1473
1474 //m68kDasmWin->Use68KPCAddress();
1475 //RefreshWindows();
1476 #ifdef _MSC_VER
1477 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1478 #else
1479 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1480 #endif // _MSC_VER
1481 }
1482
1483
1484 void MainWin::SetFullScreen(bool state/*= true*/)
1485 {
1486 if (!vjs.softTypeDebugger)
1487 {
1488 if (state)
1489 {
1490 mainWinPosition = pos();
1491 menuBar()->hide();
1492 statusBar()->hide();
1493 toolbar->hide();
1494
1495 if (debugbar)
1496 debugbar->hide();
1497
1498 // This is needed because the fullscreen may happen on a different
1499 // screen than screen 0:
1500 int screenNum = QApplication::desktop()->screenNumber(videoWidget);
1501 QRect r = QApplication::desktop()->screenGeometry(screenNum);
1502 double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
1503 targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
1504 double aspectRatio = targetWidth / targetHeight;
1505 // NOTE: Really should check here to see which dimension constrains the
1506 // other. Right now, we assume that height is the constraint.
1507 int newWidth = (int)(aspectRatio * (double)r.height());
1508 videoWidget->offset = (r.width() - newWidth) / 2;
1509 videoWidget->fullscreen = true;
1510 videoWidget->outputWidth = newWidth;
1511 videoWidget->setFixedSize(r.width(), r.height());
1512 showFullScreen();
1513 }
1514 else
1515 {
1516 // Seems Qt is fussy about this: showNormal() has to go first, or it
1517 // will keep the window stuck in a psuedo-fullscreen mode with no way
1518 // to get out of it (except closing the app).
1519 showNormal();
1520
1521 // Reset the video widget to windowed mode
1522 videoWidget->offset = 0;
1523 videoWidget->fullscreen = false;
1524 menuBar()->show();
1525 statusBar()->show();
1526 toolbar->show();
1527
1528 if (debugbar)
1529 debugbar->show();
1530
1531 ResizeMainWindow();
1532 move(mainWinPosition);
1533 }
1534 }
1535 }
1536
1537
1538 void MainWin::ToggleFullScreen(void)
1539 {
1540 fullScreen = !fullScreen;
1541 SetFullScreen(fullScreen);
1542 }
1543
1544
1545 //
1546 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1547 {
1548 exceptionvectortableBrowseWin->show();
1549 exceptionvectortableBrowseWin->RefreshContents();
1550 }
1551
1552
1553 //
1554 void MainWin::ShowLocalBrowserWin(void)
1555 {
1556 LocalBrowseWin->show();
1557 LocalBrowseWin->RefreshContents();
1558 }
1559
1560
1561 //
1562 void MainWin::ShowCallStackBrowserWin(void)
1563 {
1564 CallStackBrowseWin->show();
1565 CallStackBrowseWin->RefreshContents();
1566 }
1567
1568
1569 void MainWin::ShowAllWatchBrowserWin(void)
1570 {
1571 allWatchBrowseWin->show();
1572 allWatchBrowseWin->RefreshContents();
1573 }
1574
1575
1576 void MainWin::ShowHeapAllocatorBrowserWin(void)
1577 {
1578 heapallocatorBrowseWin->show();
1579 heapallocatorBrowseWin->RefreshContents();
1580 }
1581
1582
1583 void MainWin::ShowMemoryBrowserWin(void)
1584 {
1585 memBrowseWin->show();
1586 memBrowseWin->RefreshContents();
1587 }
1588
1589
1590 void MainWin::ShowMemory1BrowserWin(int NumWin)
1591 {
1592 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1593 {
1594 mem1BrowseWin[NumWin]->show();
1595 mem1BrowseWin[NumWin]->RefreshContents(NumWin);
1596 }
1597 }
1598
1599
1600 void MainWin::ShowEmuStatusWin(void)
1601 {
1602 emuStatusWin->show();
1603 emuStatusWin->RefreshContents();
1604 }
1605
1606
1607 void MainWin::ShowStackBrowserWin(void)
1608 {
1609 stackBrowseWin->show();
1610 stackBrowseWin->RefreshContents();
1611 }
1612
1613
1614 void MainWin::ShowCPUBrowserWin(void)
1615 {
1616 cpuBrowseWin->show();
1617 cpuBrowseWin->RefreshContents();
1618 }
1619
1620
1621 void MainWin::ShowOPBrowserWin(void)
1622 {
1623 opBrowseWin->show();
1624 opBrowseWin->RefreshContents();
1625 }
1626
1627
1628 void MainWin::ShowM68KDasmBrowserWin(void)
1629 {
1630 m68kDasmBrowseWin->show();
1631 m68kDasmBrowseWin->RefreshContents();
1632 }
1633
1634
1635 void MainWin::ShowRISCDasmBrowserWin(void)
1636 {
1637 riscDasmBrowseWin->show();
1638 riscDasmBrowseWin->RefreshContents();
1639 }
1640
1641
1642 void MainWin::ShowDasmWin(void)
1643 {
1644 DasmWin->show();
1645 // DasmWin->RefreshContents();
1646 }
1647
1648
1649 void MainWin::ShowVideoOutputWin(void)
1650 {
1651 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1652 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1653 //VideoOutputWindowCentrale->show();
1654 //memBrowseWin->show();
1655 //VideoOutputWin->show();
1656 //VideoOutputWin->RefreshContents(videoWidget);
1657 }
1658
1659
1660 void MainWin::ResizeMainWindow(void)
1661 {
1662 if (!vjs.softTypeDebugger)
1663 {
1664 videoWidget->setFixedSize(zoomLevel * VIRTUAL_SCREEN_WIDTH,
1665 zoomLevel * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
1666
1667 // Show the test pattern if user requested plzDontKillMyComputer mode
1668 if (!powerButtonOn && plzDontKillMyComputer)
1669 {
1670 for (uint32_t y = 0; y < videoWidget->rasterHeight; y++)
1671 {
1672 if (vjs.hardwareTypeNTSC)
1673 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1674 else
1675 memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern2 + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
1676 }
1677 }
1678
1679 adjustSize();
1680 }
1681 }
1682
1683
1684 // Read settings
1685 void MainWin::ReadSettings(void)
1686 {
1687 size_t i;
1688
1689 QSettings settings("Underground Software", "Virtual Jaguar");
1690
1691 //zoomLevel = settings.value("zoom", 2).toInt();
1692 allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
1693 lastEditedProfile = settings.value("lastEditedProfile", 0).toInt();
1694
1695 vjs.useJoystick = settings.value("useJoystick", false).toBool();
1696 vjs.joyport = settings.value("joyport", 0).toInt();
1697 vjs.hardwareTypeNTSC = settings.value("hardwareTypeNTSC", true).toBool();
1698 vjs.frameSkip = settings.value("frameSkip", 0).toInt();
1699 vjs.useJaguarBIOS = settings.value("useJaguarBIOS", false).toBool();
1700 vjs.GPUEnabled = settings.value("GPUEnabled", true).toBool();
1701 vjs.DSPEnabled = settings.value("DSPEnabled", true).toBool();
1702 vjs.audioEnabled = settings.value("audioEnabled", true).toBool();
1703 vjs.usePipelinedDSP = settings.value("usePipelinedDSP", false).toBool();
1704 vjs.fullscreen = settings.value("fullscreen", false).toBool();
1705 vjs.useOpenGL = settings.value("useOpenGL", true).toBool();
1706 vjs.glFilter = settings.value("glFilterType", 1).toInt();
1707 vjs.renderType = settings.value("renderType", 0).toInt();
1708 vjs.biosType = settings.value("biosType", BT_M_SERIES).toInt();
1709 vjs.useFastBlitter = settings.value("useFastBlitter", false).toBool();
1710 strcpy(vjs.EEPROMPath, settings.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation).append("/eeproms/")).toString().toUtf8().data());
1711 strcpy(vjs.ROMPath, settings.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation).append("/software/")).toString().toUtf8().data());
1712
1713 // Read settings from the Debugger mode
1714 settings.beginGroup("debugger");
1715 strcpy(vjs.debuggerROMPath, settings.value("DefaultROM", "").toString().toUtf8().data());
1716 vjs.nbrdisasmlines = settings.value("NbrDisasmLines", 32).toUInt();
1717 vjs.disasmopcodes = settings.value("DisasmOpcodes", true).toBool();
1718 vjs.displayHWlabels = settings.value("DisplayHWLabels", true).toBool();
1719 vjs.displayFullSourceFilename = settings.value("displayFullSourceFilename", true).toBool();
1720 vjs.nbrmemory1browserwindow = settings.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow).toUInt();
1721 settings.endGroup();
1722
1723 // Read settings from the Alpine mode
1724 settings.beginGroup("alpine");
1725 strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toUtf8().data());
1726 strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toUtf8().data());
1727 vjs.refresh = settings.value("refresh", 60).toUInt();
1728 vjs.allowWritesToROM = settings.value("writeROM", false).toBool();
1729 settings.endGroup();
1730
1731 // Read settings from the Keybindings
1732 settings.beginGroup("keybindings");
1733 for (i = 0; i < KB_END; i++)
1734 {
1735 strcpy(vjs.KBContent[i].KBSettingValue, settings.value(KeyBindingsTable[i].KBNameSetting, KeyBindingsTable[i].KBDefaultValue).toString().toUtf8().data());
1736 }
1737 settings.endGroup();
1738
1739 // Write important settings to the log file
1740 WriteLog("MainWin: Paths\n");
1741 WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
1742 WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
1743 WriteLog(" AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
1744 WriteLog("DebuggerROMPath = \"%s\"\n", vjs.debuggerROMPath);
1745 WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
1746 WriteLog(" Pipelined DSP = %s\n", (vjs.usePipelinedDSP ? "ON" : "off"));
1747
1748 #if 0
1749 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1750 vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_S).toInt();
1751 vjs.p1KeyBindings[BUTTON_D] = settings.value("p1k_down", Qt::Key_X).toInt();
1752 vjs.p1KeyBindings[BUTTON_L] = settings.value("p1k_left", Qt::Key_A).toInt();
1753 vjs.p1KeyBindings[BUTTON_R] = settings.value("p1k_right", Qt::Key_D).toInt();
1754 vjs.p1KeyBindings[BUTTON_C] = settings.value("p1k_c", Qt::Key_J).toInt();
1755 vjs.p1KeyBindings[BUTTON_B] = settings.value("p1k_b", Qt::Key_K).toInt();
1756 vjs.p1KeyBindings[BUTTON_A] = settings.value("p1k_a", Qt::Key_L).toInt();
1757 vjs.p1KeyBindings[BUTTON_OPTION] = settings.value("p1k_option", Qt::Key_O).toInt();
1758 vjs.p1KeyBindings[BUTTON_PAUSE] = settings.value("p1k_pause", Qt::Key_P).toInt();
1759 vjs.p1KeyBindings[BUTTON_0] = settings.value("p1k_0", Qt::Key_0).toInt();
1760 vjs.p1KeyBindings[BUTTON_1] = settings.value("p1k_1", Qt::Key_1).toInt();
1761 vjs.p1KeyBindings[BUTTON_2] = settings.value("p1k_2", Qt::Key_2).toInt();
1762 vjs.p1KeyBindings[BUTTON_3] = settings.value("p1k_3", Qt::Key_3).toInt();
1763 vjs.p1KeyBindings[BUTTON_4] = settings.value("p1k_4", Qt::Key_4).toInt();
1764 vjs.p1KeyBindings[BUTTON_5] = settings.value("p1k_5", Qt::Key_5).toInt();
1765 vjs.p1KeyBindings[BUTTON_6] = settings.value("p1k_6", Qt::Key_6).toInt();
1766 vjs.p1KeyBindings[BUTTON_7] = settings.value("p1k_7", Qt::Key_7).toInt();
1767 vjs.p1KeyBindings[BUTTON_8] = settings.value("p1k_8", Qt::Key_8).toInt();
1768 vjs.p1KeyBindings[BUTTON_9] = settings.value("p1k_9", Qt::Key_9).toInt();
1769 vjs.p1KeyBindings[BUTTON_d] = settings.value("p1k_pound", Qt::Key_Minus).toInt();
1770 vjs.p1KeyBindings[BUTTON_s] = settings.value("p1k_star", Qt::Key_Equal).toInt();
1771
1772 vjs.p2KeyBindings[BUTTON_U] = settings.value("p2k_up", Qt::Key_Up).toInt();
1773 vjs.p2KeyBindings[BUTTON_D] = settings.value("p2k_down", Qt::Key_Down).toInt();
1774 vjs.p2KeyBindings[BUTTON_L] = settings.value("p2k_left", Qt::Key_Left).toInt();
1775 vjs.p2KeyBindings[BUTTON_R] = settings.value("p2k_right", Qt::Key_Right).toInt();
1776 vjs.p2KeyBindings[BUTTON_C] = settings.value("p2k_c", Qt::Key_Z).toInt();
1777 vjs.p2KeyBindings[BUTTON_B] = settings.value("p2k_b", Qt::Key_X).toInt();
1778 vjs.p2KeyBindings[BUTTON_A] = settings.value("p2k_a", Qt::Key_C).toInt();
1779 vjs.p2KeyBindings[BUTTON_OPTION] = settings.value("p2k_option", Qt::Key_Apostrophe).toInt();
1780 vjs.p2KeyBindings[BUTTON_PAUSE] = settings.value("p2k_pause", Qt::Key_Return).toInt();
1781 vjs.p2KeyBindings[BUTTON_0] = settings.value("p2k_0", Qt::Key_0).toInt();
1782 vjs.p2KeyBindings[BUTTON_1] = settings.value("p2k_1", Qt::Key_1).toInt();
1783 vjs.p2KeyBindings[BUTTON_2] = settings.value("p2k_2", Qt::Key_2).toInt();
1784 vjs.p2KeyBindings[BUTTON_3] = settings.value("p2k_3", Qt::Key_3).toInt();
1785 vjs.p2KeyBindings[BUTTON_4] = settings.value("p2k_4", Qt::Key_4).toInt();
1786 vjs.p2KeyBindings[BUTTON_5] = settings.value("p2k_5", Qt::Key_5).toInt();
1787 vjs.p2KeyBindings[BUTTON_6] = settings.value("p2k_6", Qt::Key_6).toInt();
1788 vjs.p2KeyBindings[BUTTON_7] = settings.value("p2k_7", Qt::Key_7).toInt();
1789 vjs.p2KeyBindings[BUTTON_8] = settings.value("p2k_8", Qt::Key_8).toInt();
1790 vjs.p2KeyBindings[BUTTON_9] = settings.value("p2k_9", Qt::Key_9).toInt();
1791 vjs.p2KeyBindings[BUTTON_d] = settings.value("p2k_pound", Qt::Key_Slash).toInt();
1792 vjs.p2KeyBindings[BUTTON_s] = settings.value("p2k_star", Qt::Key_Asterisk).toInt();
1793 #endif
1794
1795 WriteLog("Read setting = Done\n");
1796
1797 ReadProfiles(&settings);
1798 }
1799
1800
1801 // Read UI settings
1802 // Default values will be used in case of no settings can be found
1803 #ifdef _MSC_VER
1804 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1805 #else
1806 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1807 #endif // _MSC_VER
1808 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1809 void MainWin::ReadUISettings(void)
1810 {
1811 QPoint pos;
1812 char mem1Name[100];
1813 size_t i;
1814 QSize size;
1815
1816 // Point on the emulator settings
1817 QSettings settings("Underground Software", "Virtual Jaguar");
1818 settings.beginGroup("ui");
1819
1820 // Emulator main window UI information
1821 mainWinPosition = settings.value("pos", QPoint(200, 200)).toPoint();
1822 size = settings.value("size", QSize(400, 400)).toSize();
1823 resize(size);
1824 move(mainWinPosition);
1825 pos = settings.value("cartLoadPos", QPoint(200, 200)).toPoint();
1826 filePickWin->move(pos);
1827
1828 // Video output information
1829 zoomLevel = settings.value("zoom", 2).toInt();
1830
1831 // Alpine debug UI information (also needed by the Debugger)
1832 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
1833 {
1834 // CPU registers UI information
1835 pos = settings.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1836 cpuBrowseWin->move(pos);
1837 settings.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1838
1839 // Memory browser UI information
1840 pos = settings.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1841 memBrowseWin->move(pos);
1842 settings.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1843
1844 // Stack browser UI information
1845 pos = settings.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1846 stackBrowseWin->move(pos);
1847 settings.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1848 size = settings.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1849 stackBrowseWin->resize(size);
1850
1851 // Emulator status UI information
1852 pos = settings.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1853 emuStatusWin->move(pos);
1854 settings.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1855
1856 // OP (Object Processor) UI information
1857 pos = settings.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1858 opBrowseWin->move(pos);
1859 settings.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1860 size = settings.value("opBrowseWinSize", QSize(400, 400)).toSize();
1861 opBrowseWin->resize(size);
1862
1863 // RISC disassembly UI information
1864 pos = settings.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1865 riscDasmBrowseWin->move(pos);
1866 settings.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
1867
1868 // M68k disassembly UI information
1869 pos = settings.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1870 m68kDasmBrowseWin->move(pos);
1871 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
1872 #ifdef _MSC_VER
1873 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
1874 #else
1875 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
1876 #endif // _MSC_VER
1877 }
1878
1879 // Debugger UI information
1880 if (vjs.softTypeDebugger)
1881 {
1882 #if 0
1883 pos = settings.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
1884 m68kDasmWin->move(pos);
1885 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
1886 pos = settings.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
1887 GPUDasmWin->move(pos);
1888 pos = settings.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
1889 DSPDasmWin->move(pos);
1890 #endif
1891 // All watch browser UI information
1892 pos = settings.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
1893 allWatchBrowseWin->move(pos);
1894 settings.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
1895 size = settings.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
1896 allWatchBrowseWin->resize(size);
1897
1898 // Local browser UI information
1899 pos = settings.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
1900 LocalBrowseWin->move(pos);
1901 settings.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
1902 size = settings.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
1903 LocalBrowseWin->resize(size);
1904
1905 // Heap memory allocation browser UI information
1906 pos = settings.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
1907 heapallocatorBrowseWin->move(pos);
1908 settings.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
1909 size = settings.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
1910 heapallocatorBrowseWin->resize(size);
1911
1912 // Exception Vector Table UI Information
1913 pos = settings.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
1914 exceptionvectortableBrowseWin->move(pos);
1915 settings.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
1916 size = settings.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
1917 exceptionvectortableBrowseWin->resize(size);
1918
1919 // Call Stack browser UI information
1920 pos = settings.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
1921 CallStackBrowseWin->move(pos);
1922 settings.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
1923 size = settings.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
1924 CallStackBrowseWin->resize(size);
1925
1926 // Memories browser UI information
1927 for (i = 0; i < vjs.nbrmemory1browserwindow; i++)
1928 {
1929 sprintf(mem1Name, "mem1BrowseWinPos[%i]", (unsigned int)i);
1930 pos = settings.value(mem1Name, QPoint(200, 200)).toPoint();
1931 mem1BrowseWin[i]->move(pos);
1932 sprintf(mem1Name, "mem1BrowseWinIsVisible[%i]", (unsigned int)i);
1933 settings.value(mem1Name, false).toBool() ? ShowMemory1BrowserWin((int)i) : void();
1934 sprintf(mem1Name, "mem1BrowseWinSize[%i]", (unsigned int)i);
1935 size = settings.value(mem1Name, QSize(400, 400)).toSize();
1936 mem1BrowseWin[i]->resize(size);
1937 }
1938 }
1939
1940 settings.endGroup();
1941
1942 WriteLog("Read UI setting = Done\n");
1943 }
1944
1945
1946 // Save the settings
1947 void MainWin::WriteSettings(void)
1948 {
1949 size_t i;
1950
1951 // Point on the emulator settings
1952 QSettings settings("Underground Software", "Virtual Jaguar");
1953 //settings.setValue("pos", pos());
1954 //settings.setValue("size", size());
1955 //settings.setValue("cartLoadPos", filePickWin->pos());
1956
1957 //settings.setValue("zoom", zoomLevel);
1958 settings.setValue("showUnknownSoftware", allowUnknownSoftware);
1959 settings.setValue("lastEditedProfile", lastEditedProfile);
1960
1961 settings.setValue("useJoystick", vjs.useJoystick);
1962 settings.setValue("joyport", vjs.joyport);
1963 settings.setValue("hardwareTypeNTSC", vjs.hardwareTypeNTSC);
1964 settings.setValue("frameSkip", vjs.frameSkip);
1965 settings.setValue("useJaguarBIOS", vjs.useJaguarBIOS);
1966 settings.setValue("GPUEnabled", vjs.GPUEnabled);
1967 settings.setValue("DSPEnabled", vjs.DSPEnabled);
1968 settings.setValue("audioEnabled", vjs.audioEnabled);
1969 settings.setValue("usePipelinedDSP", vjs.usePipelinedDSP);
1970 settings.setValue("fullscreen", vjs.fullscreen);
1971 settings.setValue("useOpenGL", vjs.useOpenGL);
1972 settings.setValue("glFilterType", vjs.glFilter);
1973 settings.setValue("renderType", vjs.renderType);
1974 settings.setValue("biosType", vjs.biosType);
1975 settings.setValue("useFastBlitter", vjs.useFastBlitter);
1976 settings.setValue("JagBootROM", vjs.jagBootPath);
1977 settings.setValue("CDBootROM", vjs.CDBootPath);
1978 settings.setValue("EEPROMs", vjs.EEPROMPath);
1979 settings.setValue("ROMs", vjs.ROMPath);
1980
1981 // Write settings from the Alpine mode
1982 settings.beginGroup("alpine");
1983 settings.setValue("refresh", vjs.refresh);
1984 settings.setValue("DefaultROM", vjs.alpineROMPath);
1985 settings.setValue("DefaultABS", vjs.absROMPath);
1986 settings.setValue("writeROM", vjs.allowWritesToROM);
1987 settings.endGroup();
1988
1989 // Write settings from the Debugger mode
1990 settings.beginGroup("debugger");
1991 settings.setValue("DisplayHWLabels", vjs.displayHWlabels);
1992 settings.setValue("NbrDisasmLines", vjs.nbrdisasmlines);
1993 settings.setValue("DisasmOpcodes", vjs.disasmopcodes);
1994 settings.setValue("displayFullSourceFilename", vjs.displayFullSourceFilename);
1995 settings.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs.nbrmemory1browserwindow);
1996 settings.setValue("DefaultROM", vjs.debuggerROMPath);
1997 settings.endGroup();
1998
1999 // Write settings from the Keybindings
2000 settings.beginGroup("keybindings");
2001 for (i = 0; i < KB_END; i++)
2002 {
2003 settings.setValue(KeyBindingsTable[i].KBNameSetting, vjs.KBContent[i].KBSettingValue);
2004 }
2005 settings.endGroup();
2006
2007 #if 0
2008 settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
2009 settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
2010 settings.setValue("p1k_left", vjs.p1KeyBindings[BUTTON_L]);
2011 settings.setValue("p1k_right", vjs.p1KeyBindings[BUTTON_R]);
2012 settings.setValue("p1k_c", vjs.p1KeyBindings[BUTTON_C]);
2013 settings.setValue("p1k_b", vjs.p1KeyBindings[BUTTON_B]);
2014 settings.setValue("p1k_a", vjs.p1KeyBindings[BUTTON_A]);
2015 settings.setValue("p1k_option", vjs.p1KeyBindings[BUTTON_OPTION]);
2016 settings.setValue("p1k_pause", vjs.p1KeyBindings[BUTTON_PAUSE]);
2017 settings.setValue("p1k_0", vjs.p1KeyBindings[BUTTON_0]);
2018 settings.setValue("p1k_1", vjs.p1KeyBindings[BUTTON_1]);
2019 settings.setValue("p1k_2", vjs.p1KeyBindings[BUTTON_2]);
2020 settings.setValue("p1k_3", vjs.p1KeyBindings[BUTTON_3]);
2021 settings.setValue("p1k_4", vjs.p1KeyBindings[BUTTON_4]);
2022 settings.setValue("p1k_5", vjs.p1KeyBindings[BUTTON_5]);
2023 settings.setValue("p1k_6", vjs.p1KeyBindings[BUTTON_6]);
2024 settings.setValue("p1k_7", vjs.p1KeyBindings[BUTTON_7]);
2025 settings.setValue("p1k_8", vjs.p1KeyBindings[BUTTON_8]);
2026 settings.setValue("p1k_9", vjs.p1KeyBindings[BUTTON_9]);
2027 settings.setValue("p1k_pound", vjs.p1KeyBindings[BUTTON_d]);
2028 settings.setValue("p1k_star", vjs.p1KeyBindings[BUTTON_s]);
2029
2030 settings.setValue("p2k_up", vjs.p2KeyBindings[BUTTON_U]);
2031 settings.setValue("p2k_down", vjs.p2KeyBindings[BUTTON_D]);
2032 settings.setValue("p2k_left", vjs.p2KeyBindings[BUTTON_L]);
2033 settings.setValue("p2k_right", vjs.p2KeyBindings[BUTTON_R]);
2034 settings.setValue("p2k_c", vjs.p2KeyBindings[BUTTON_C]);
2035 settings.setValue("p2k_b", vjs.p2KeyBindings[BUTTON_B]);
2036 settings.setValue("p2k_a", vjs.p2KeyBindings[BUTTON_A]);
2037 settings.setValue("p2k_option", vjs.p2KeyBindings[BUTTON_OPTION]);
2038 settings.setValue("p2k_pause", vjs.p2KeyBindings[BUTTON_PAUSE]);
2039 settings.setValue("p2k_0", vjs.p2KeyBindings[BUTTON_0]);
2040 settings.setValue("p2k_1", vjs.p2KeyBindings[BUTTON_1]);
2041 settings.setValue("p2k_2", vjs.p2KeyBindings[BUTTON_2]);
2042 settings.setValue("p2k_3", vjs.p2KeyBindings[BUTTON_3]);
2043 settings.setValue("p2k_4", vjs.p2KeyBindings[BUTTON_4]);
2044 settings.setValue("p2k_5", vjs.p2KeyBindings[BUTTON_5]);
2045 settings.setValue("p2k_6", vjs.p2KeyBindings[BUTTON_6]);
2046 settings.setValue("p2k_7", vjs.p2KeyBindings[BUTTON_7]);
2047 settings.setValue("p2k_8", vjs.p2KeyBindings[BUTTON_8]);
2048 settings.setValue("p2k_9", vjs.p2KeyBindings[BUTTON_9]);
2049 settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]);
2050 settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]);
2051 #endif
2052
2053 WriteProfiles(&settings);
2054 }
2055
2056
2057 // Save the UI settings
2058 void MainWin::WriteUISettings(void)
2059 {
2060 char mem1Name[100];
2061 size_t i;
2062
2063 // Point on the emulator settings
2064 QSettings settings("Underground Software", "Virtual Jaguar");
2065 settings.beginGroup("ui");
2066
2067 // Emulator UI information
2068 settings.setValue("pos", pos());
2069 settings.setValue("size", size());
2070 settings.setValue("cartLoadPos", filePickWin->pos());
2071
2072 // Video output information
2073 settings.setValue("zoom", zoomLevel);
2074
2075 // Alpine debug UI information (also needed by the Debugger)
2076 if (vjs.hardwareTypeAlpine || vjs.softTypeDebugger)
2077 {
2078 settings.setValue("cpuBrowseWinPos", cpuBrowseWin->pos());
2079 settings.setValue("cpuBrowseWinIsVisible", cpuBrowseWin->isVisible());
2080 settings.setValue("memBrowseWinPos", memBrowseWin->pos());
2081 settings.setValue("memBrowseWinIsVisible", memBrowseWin->isVisible());
2082 settings.setValue("stackBrowseWinPos", stackBrowseWin->pos());
2083 settings.setValue("stackBrowseWinIsVisible", stackBrowseWin->isVisible());
2084 settings.setValue("stackBrowseWinSize", stackBrowseWin->size());
2085 settings.setValue("emuStatusWinPos", emuStatusWin->pos());
2086 settings.setValue("emuStatusWinIsVisible", emuStatusWin->isVisible());
2087 settings.setValue("opBrowseWinPos", opBrowseWin->pos());
2088 settings.setValue("opBrowseWinIsVisible", opBrowseWin->isVisible());
2089 settings.setValue("opBrowseWinSize", opBrowseWin->size());
2090 settings.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin->pos());
2091 settings.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin->isVisible());
2092 settings.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin->pos());
2093 settings.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin->isVisible());
2094 }
2095
2096 // Debugger UI information
2097 if (vjs.softTypeDebugger)
2098 {
2099 #if 0
2100 settings.setValue("m68kDasmWinPos", m68kDasmWin->pos());
2101 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2102 settings.setValue("GPUDasmWinPos", GPUDasmWin->pos());
2103 settings.setValue("DSPDasmWinPos", DSPDasmWin->pos());
2104 #endif
2105 settings.setValue("allWatchBrowseWinPos", allWatchBrowseWin->pos());
2106 settings.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin->isVisible());
2107 settings.setValue("allWatchBrowseWinSize", allWatchBrowseWin->size());
2108 settings.setValue("LocalBrowseWinPos", LocalBrowseWin->pos());
2109 settings.setValue("LocalBrowseWinIsVisible", LocalBrowseWin->isVisible());
2110 settings.setValue("LocalBrowseWinSize", LocalBrowseWin->size());
2111 settings.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin->pos());
2112 settings.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin->isVisible());
2113 settings.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin->size());
2114 settings.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin->pos());
2115 settings.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin->isVisible());
2116 settings.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin->size());
2117 settings.setValue("CallStackBrowseWinPos", CallStackBrowseWin->pos());
2118 settings.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin->isVisible());
2119 settings.setValue("CallStackBrowseWinSize", CallStackBrowseWin->size());
2120 for (i = 0; i < vjs.nbrmemory1browserwindow; i++)
2121 {
2122 sprintf(mem1Name, "mem1BrowseWinPos[%i]", (unsigned int)i);
2123 settings.setValue(mem1Name, mem1BrowseWin[i]->pos());
2124 sprintf(mem1Name, "mem1BrowseWinIsVisible[%i]", (unsigned int)i);
2125 settings.setValue(mem1Name, mem1BrowseWin[i]->isVisible());
2126 sprintf(mem1Name, "mem1BrowseWinSize[%i]", (unsigned int)i);
2127 settings.setValue(mem1Name, mem1BrowseWin[i]->size());
2128 }
2129 }
2130
2131 settings.endGroup();
2132 }
2133
2134
2135 // Refresh alpine debug windows
2136 void MainWin::RefreshAlpineWindows(void)
2137 {
2138 cpuBrowseWin->RefreshContents();
2139 memBrowseWin->RefreshContents();
2140 stackBrowseWin->RefreshContents();
2141 emuStatusWin->RefreshContents();
2142 opBrowseWin->RefreshContents();
2143 riscDasmBrowseWin->RefreshContents();
2144 m68kDasmBrowseWin->RefreshContents();
2145 }
2146
2147
2148 // Reset soft debugger windows
2149 void MainWin::DebuggerResetWindows(void)
2150 {
2151 if (vjs.softTypeDebugger)
2152 {
2153 allWatchBrowseWin->Reset();
2154 heapallocatorBrowseWin->Reset();
2155
2156 //ResetAlpineWindows();
2157 }
2158 }
2159
2160
2161 // Refresh soft debugger & alpine debug windows
2162 void MainWin::DebuggerRefreshWindows(void)
2163 {
2164 size_t i;
2165
2166 if (vjs.softTypeDebugger)
2167 {
2168 m68kDasmWin->RefreshContents();
2169 GPUDasmWin->RefreshContents();
2170 DSPDasmWin->RefreshContents();
2171 allWatchBrowseWin->RefreshContents();
2172 LocalBrowseWin->RefreshContents();
2173 CallStackBrowseWin->RefreshContents();
2174 heapallocatorBrowseWin->RefreshContents();
2175 for (i = 0; i < vjs.nbrmemory1browserwindow; i++)
2176 {
2177 mem1BrowseWin[i]->RefreshContents(i);
2178 }
2179
2180 RefreshAlpineWindows();
2181 }
2182 }