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