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