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