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