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