2 // mainwin.cpp - Qt-based GUI for Virtual Jaguar: Main Application Window
4 // (C) 2009 Underground Software
6 // JLH = James Hammons <jlhamm@acm.org>
7 // JPM = Jean-Paul Mari <djipi.mari@gmail.com>
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 window
20 // JPM 08/01/2017 Added heap allocator window
21 // JPM 08/07/2017 Added memories window
22 // JPM 08/10/2017 Added a restart feature
23 // JPM 08/31/2017 Added breakpoints window [Not Supported]
24 // JPM 09/01/2017 Save position & visibility windows status in the settings
25 // JPM 09/02/2017 Save size windows in the settings
26 // JPM 09/05/2017 Added Exception Vector Table window
27 // JPM 09/06/2017 Added the 'Rx' word to the emulator window name
28 // JPM 09/12/2017 Added the keybindings in the settings
29 // JPM 11/04/2017 Added the local window
30 // JPM 08/31/2018 Added the call stack window
35 // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
36 // - Autoscan/autoload all available BIOS from 'software' folder [DONE]
37 // - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting
38 // with 'R', etc) [DONE]
39 // - Controller configuration [DONE]
43 // - Fix bug in switching between PAL & NTSC in fullscreen mode.
44 // - Remove SDL dependencies (sound, mainly) from Jaguar core lib
45 // - Fix inconsistency with trailing slashes in paths (eeproms needs one,
48 // SFDX CODE: S1E9T8H5M23YS
50 // Uncomment this for debugging...
52 //#define DEBUGFOO // Various tool debugging... but not used
53 //#define DEBUGTP // Toolpalette debugging... but not used
60 #include "configdialog.h"
61 #include "controllertab.h"
62 #include "keybindingstab.h"
63 #include "filepicker.h"
65 #include "generaltab.h"
71 #include "emustatus.h"
72 #include "debug/cpubrowser.h"
73 #include "debug/m68kdasmbrowser.h"
74 #include "debug/memorybrowser.h"
75 #include "debug/stackbrowser.h"
76 #include "debug/opbrowser.h"
77 #include "debug/riscdasmbrowser.h"
85 #include "jagcdbios.h"
86 #include "jagstub2bios.h"
88 #include "m68000/m68kinterface.h"
90 //#include "debugger/VideoWin.h"
91 #include "debugger/DasmWin.h"
92 #include "debugger/m68KDasmWin.h"
93 #include "debugger/GPUDasmWin.h"
94 #include "debugger/DSPDasmWin.h"
95 #include "debugger/memory1browser.h"
96 #include "debugger/brkWin.h"
97 #include "debugger/exceptionvectortablebrowser.h"
98 #include "debugger/allwatchbrowser.h"
99 #include "debugger/localbrowser.h"
100 #include "debugger/heapallocatorbrowser.h"
101 #include "debugger/callstackbrowser.h"
104 // According to SebRmv, this header isn't seen on Arch Linux either... :-/
105 //#ifdef __GCCWIN32__
106 // Apparently on win32, usleep() is not pulled in by the usual suspects.
110 #include "_MSC_VER/unistd.h"
114 // The way BSNES controls things is by setting a timer with a zero
115 // timeout, sleeping if not emulating anything. Seems there has to be a
118 // It has a novel approach to plugging-in/using different video/audio/input
119 // methods, can we do something similar or should we just use the built-in
122 // We're going to try to use the built-in OpenGL support and see how it goes.
123 // We'll make the VJ core modular so that it doesn't matter what GUI is in
124 // use, we can drop it in anywhere and use it as-is.
126 MainWin::MainWin(bool autoRun
): running(true), powerButtonOn(false),
127 showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false),
128 pauseForFileSelector(false), loadAndGo(autoRun
), scannedSoftwareFolder(false), plzDontKillMyComputer(false)
134 for(int i
=0; i
<8; i
++)
138 for(int i
=0; i
<RING_BUFFER_SIZE
; i
++)
141 ringBufferPointer
= RING_BUFFER_SIZE
- 1;
144 //if (vjs.softTypeDebugger)
146 // mainWindowCentrale = new QMdiArea;
147 // setCentralWidget(mainWindowCentrale);
150 WriteLog("Window creation start\n");
153 videoWidget
= new GLWidget(this);
154 videoWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
156 // set central output window
157 if (!vjs
.softTypeDebugger
)
159 setCentralWidget(videoWidget
);
163 mainWindowCentrale
= new QMdiArea(this);
164 setCentralWidget(mainWindowCentrale
);
167 setWindowIcon(QIcon(":/res/vj-icon.png"));
169 QString title
= QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx"));
171 if (vjs
.hardwareTypeAlpine
)
172 title
+= QString(tr(" - Alpine Mode"));
174 if (vjs
.softTypeDebugger
)
175 title
+= QString(tr(" - Debugger Mode"));
177 setWindowTitle(title
);
179 aboutWin
= new AboutWindow(this);
180 helpWin
= new HelpWindow(this);
181 filePickWin
= new FilePickerWindow(this);
182 memBrowseWin
= new MemoryBrowserWindow(this);
183 stackBrowseWin
= new StackBrowserWindow(this);
184 emuStatusWin
= new EmuStatusWindow(this);
185 cpuBrowseWin
= new CPUBrowserWindow(this);
186 opBrowseWin
= new OPBrowserWindow(this);
187 m68kDasmBrowseWin
= new M68KDasmBrowserWindow(this);
188 riscDasmBrowseWin
= new RISCDasmBrowserWindow(this);
189 if (vjs
.softTypeDebugger
)
191 //VideoOutputWin = new VideoOutputWindow(this);
192 //VideoOutputWin->setCentralWidget()
193 //DasmWin = new DasmWindow();
194 DasmWin
= new DasmWindow(this);
195 allWatchBrowseWin
= new AllWatchBrowserWindow(this);
196 LocalBrowseWin
= new LocalBrowserWindow(this);
197 heapallocatorBrowseWin
= new HeapAllocatorBrowserWindow(this);
198 brkWin
= new BrkWindow(this);
199 exceptionvectortableBrowseWin
= new ExceptionVectorTableBrowserWindow(this);
200 CallStackBrowseWin
= new CallStackBrowserWindow(this);
202 mem1BrowseWin
= (Memory1BrowserWindow
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(Memory1BrowserWindow
));
204 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseWin !!!")
206 #warning "!!! Need to do the memory desalocation for mem1BrowseWin !!!"
208 for (size_t i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
210 mem1BrowseWin
[i
] = new Memory1BrowserWindow(this);
213 dasmtabWidget
= new QTabWidget(this);
214 dasmtabWidget
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
215 dasmtabWidget
->addTab(m68kDasmWin
= new m68KDasmWindow(this), tr("M68000"));
216 dasmtabWidget
->addTab(GPUDasmWin
= new GPUDasmWindow(this), tr("GPU"));
217 dasmtabWidget
->addTab(DSPDasmWin
= new DSPDasmWindow(this), tr("DSP"));
218 ////dasmtabWidget->addTab(m68kDasmBrowseWin, tr("M68000"));
219 setCentralWidget(dasmtabWidget
);
222 QDockWidget
*shapesDockWidget
= new QDockWidget(tr("Shapes"));
223 shapesDockWidget
->setObjectName("shapesDockWidget");
224 shapesDockWidget
->setWidget(m68kDasmWin
);
225 //shapesDockWidget->setWidget(treeWidget);
226 shapesDockWidget
->setAllowedAreas(Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea
);
227 addDockWidget(Qt::LeftDockWidgetArea
, shapesDockWidget
);
231 // videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
232 setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
234 setUnifiedTitleAndToolBarOnMac(true);
238 quitAppAct
= new QAction(QIcon(":/res/exit.png"), tr("E&xit"), this);
239 // quitAppAct->setShortcuts(QKeySequence::Quit);
240 // quitAppAct->setShortcut(QKeySequence(tr("Alt+x")));
241 //quitAppAct->setShortcut(QKeySequence(tr("Ctrl+q")));
242 quitAppAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBQUIT
].KBSettingValue
)));
243 quitAppAct
->setShortcutContext(Qt::ApplicationShortcut
);
244 quitAppAct
->setStatusTip(tr("Quit Virtual Jaguar"));
245 connect(quitAppAct
, SIGNAL(triggered()), this, SLOT(close()));
247 powerGreen
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
248 powerGreen
.addFile(":/res/power-on-green.png", QSize(), QIcon::Normal
, QIcon::On
);
249 powerRed
.addFile(":/res/power-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
250 powerRed
.addFile(":/res/power-on-red.png", QSize(), QIcon::Normal
, QIcon::On
);
252 powerAct
= new QAction(powerGreen
, tr("&Power"), this);
253 powerAct
->setStatusTip(tr("Powers Jaguar on/off"));
254 powerAct
->setCheckable(true);
255 powerAct
->setChecked(false);
256 connect(powerAct
, SIGNAL(triggered()), this, SLOT(TogglePowerState()));
259 pauseIcon
.addFile(":/res/pause-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
260 pauseIcon
.addFile(":/res/pause-on.png", QSize(), QIcon::Normal
, QIcon::On
);
261 pauseAct
= new QAction(pauseIcon
, tr("Pause"), this);
262 pauseAct
->setStatusTip(tr("Toggles the running state"));
263 pauseAct
->setCheckable(true);
264 pauseAct
->setDisabled(true);
265 //pauseAct->setShortcut(QKeySequence(tr("Esc")));
266 pauseAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPAUSE
].KBSettingValue
)));
267 pauseAct
->setShortcutContext(Qt::ApplicationShortcut
);
268 connect(pauseAct
, SIGNAL(triggered()), this, SLOT(ToggleRunState()));
270 zoomActs
= new QActionGroup(this);
272 x1Act
= new QAction(QIcon(":/res/zoom100.png"), tr("Zoom 100%"), zoomActs
);
273 x1Act
->setStatusTip(tr("Set window zoom to 100%"));
274 x1Act
->setCheckable(true);
275 connect(x1Act
, SIGNAL(triggered()), this, SLOT(SetZoom100()));
277 x2Act
= new QAction(QIcon(":/res/zoom200.png"), tr("Zoom 200%"), zoomActs
);
278 x2Act
->setStatusTip(tr("Set window zoom to 200%"));
279 x2Act
->setCheckable(true);
280 connect(x2Act
, SIGNAL(triggered()), this, SLOT(SetZoom200()));
282 x3Act
= new QAction(QIcon(":/res/zoom300.png"), tr("Zoom 300%"), zoomActs
);
283 x3Act
->setStatusTip(tr("Set window zoom to 300%"));
284 x3Act
->setCheckable(true);
285 connect(x3Act
, SIGNAL(triggered()), this, SLOT(SetZoom300()));
287 tvTypeActs
= new QActionGroup(this);
289 ntscAct
= new QAction(QIcon(":/res/ntsc.png"), tr("NTSC"), tvTypeActs
);
290 ntscAct
->setStatusTip(tr("Sets Jaguar to NTSC mode"));
291 ntscAct
->setCheckable(true);
292 connect(ntscAct
, SIGNAL(triggered()), this, SLOT(SetNTSC()));
294 palAct
= new QAction(QIcon(":/res/pal.png"), tr("PAL"), tvTypeActs
);
295 palAct
->setStatusTip(tr("Sets Jaguar to PAL mode"));
296 palAct
->setCheckable(true);
297 connect(palAct
, SIGNAL(triggered()), this, SLOT(SetPAL()));
299 blur
.addFile(":/res/blur-off.png", QSize(), QIcon::Normal
, QIcon::Off
);
300 blur
.addFile(":/res/blur-on.png", QSize(), QIcon::Normal
, QIcon::On
);
302 blurAct
= new QAction(blur
, tr("Blur"), this);
303 blurAct
->setStatusTip(tr("Sets OpenGL rendering to GL_NEAREST"));
304 blurAct
->setCheckable(true);
305 connect(blurAct
, SIGNAL(triggered()), this, SLOT(ToggleBlur()));
307 aboutAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&About..."), this);
308 aboutAct
->setStatusTip(tr("Blatant self-promotion"));
309 connect(aboutAct
, SIGNAL(triggered()), this, SLOT(ShowAboutWin()));
311 helpAct
= new QAction(QIcon(":/res/vj-icon.png"), tr("&Contents..."), this);
312 helpAct
->setStatusTip(tr("Help is available, if you should need it"));
313 connect(helpAct
, SIGNAL(triggered()), this, SLOT(ShowHelpWin()));
315 if (!vjs
.softTypeDebugger
)
317 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert Cartridge..."), this);
318 filePickAct
->setStatusTip(tr("Insert a cartridge into Virtual Jaguar"));
322 filePickAct
= new QAction(QIcon(":/res/software.png"), tr("&Insert executable file..."), this);
323 filePickAct
->setStatusTip(tr("Insert an executable into Virtual Jaguar"));
325 //filePickAct->setShortcut(QKeySequence(tr("Ctrl+i")));
326 filePickAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBPICKFILE
].KBSettingValue
)));
327 filePickAct
->setShortcutContext(Qt::ApplicationShortcut
);
328 connect(filePickAct
, SIGNAL(triggered()), this, SLOT(InsertCart()));
330 configAct
= new QAction(QIcon(":/res/wrench.png"), tr("&Configure"), this);
331 configAct
->setStatusTip(tr("Configure options for Virtual Jaguar"));
332 //configAct->setShortcut(QKeySequence(tr("Ctrl+c")));
333 configAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBCONFIGURE
].KBSettingValue
)));
334 configAct
->setShortcutContext(Qt::ApplicationShortcut
);
335 connect(configAct
, SIGNAL(triggered()), this, SLOT(Configure()));
337 emustatusAct
= new QAction(QIcon(":/res/status.png"), tr("&Status"), this);
338 emustatusAct
->setStatusTip(tr("Emulator status"));
339 //emustatusAct->setShortcut(QKeySequence(tr("Ctrl+s")));
340 emustatusAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBEMUSTATUS
].KBSettingValue
)));
341 emustatusAct
->setShortcutContext(Qt::ApplicationShortcut
);
342 connect(emustatusAct
, SIGNAL(triggered()), this, SLOT(ShowEmuStatusWin()));
344 useCDAct
= new QAction(QIcon(":/res/compact-disc.png"), tr("&Use CD Unit"), this);
345 useCDAct
->setStatusTip(tr("Use Jaguar Virtual CD unit"));
346 // useCDAct->setShortcut(QKeySequence(tr("Ctrl+c")));
347 useCDAct
->setCheckable(true);
348 connect(useCDAct
, SIGNAL(triggered()), this, SLOT(ToggleCDUsage()));
350 frameAdvanceAct
= new QAction(QIcon(":/res/frame-advance.png"), tr("&Frame Advance"), this);
351 //frameAdvanceAct->setShortcut(QKeySequence(tr("F7")));
352 frameAdvanceAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFRAMEADVANCE
].KBSettingValue
)));
353 frameAdvanceAct
->setShortcutContext(Qt::ApplicationShortcut
);
354 frameAdvanceAct
->setDisabled(true);
355 connect(frameAdvanceAct
, SIGNAL(triggered()), this, SLOT(FrameAdvance()));
357 if (vjs
.softTypeDebugger
)
359 restartAct
= new QAction(QIcon(":/res/debug-restart.png"), tr("&Restart"), this);
360 //restartAct->setShortcut(QKeySequence(tr("Ctrl+Shift+F5")));
361 restartAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBRESTART
].KBSettingValue
)));
362 restartAct
->setShortcutContext(Qt::ApplicationShortcut
);
363 restartAct
->setCheckable(false);
364 restartAct
->setDisabled(true);
365 connect(restartAct
, SIGNAL(triggered()), this, SLOT(DebuggerRestart()));
367 traceStepOverAct
= new QAction(QIcon(":/res/debug-stepover.png"), tr("&Step Over"), this);
368 //traceStepOverAct->setShortcut(QKeySequence(tr("F10")));
369 traceStepOverAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPOVER
].KBSettingValue
)));
370 traceStepOverAct
->setShortcutContext(Qt::ApplicationShortcut
);
371 traceStepOverAct
->setCheckable(false);
372 traceStepOverAct
->setDisabled(true);
373 connect(traceStepOverAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepOver()));
375 traceStepIntoAct
= new QAction(QIcon(":/res/debug-stepinto.png"), tr("&Step Into"), this);
376 //traceStepIntoAct->setShortcut(QKeySequence(tr("F11")));
377 traceStepIntoAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBSTEPINTO
].KBSettingValue
)));
378 traceStepIntoAct
->setShortcutContext(Qt::ApplicationShortcut
);
379 traceStepIntoAct
->setCheckable(false);
380 traceStepIntoAct
->setDisabled(true);
381 connect(traceStepIntoAct
, SIGNAL(triggered()), this, SLOT(DebuggerTraceStepInto()));
383 newBreakpointFunctionAct
= new QAction(QIcon(""), tr("&Function Breakpoint"), this);
384 newBreakpointFunctionAct
->setShortcut(QKeySequence(tr("Ctrl+B")));
385 connect(newBreakpointFunctionAct
, SIGNAL(triggered()), this, SLOT(NewBreakpointFunction()));
388 fullScreenAct
= new QAction(QIcon(":/res/fullscreen.png"), tr("F&ull Screen"), this);
389 //fullScreenAct->setShortcut(QKeySequence(tr("F9")));
390 fullScreenAct
->setShortcut(QKeySequence(tr(vjs
.KBContent
[KBFULLSCREEN
].KBSettingValue
)));
391 fullScreenAct
->setShortcutContext(Qt::ApplicationShortcut
);
392 fullScreenAct
->setCheckable(true);
393 connect(fullScreenAct
, SIGNAL(triggered()), this, SLOT(ToggleFullScreen()));
396 if (vjs
.softTypeDebugger
)
398 exceptionVectorTableBrowseAct
= new QAction(QIcon(""), tr("Exception Vector Table"), this);
399 exceptionVectorTableBrowseAct
->setStatusTip(tr("Shows all Exception Vector Table browser window"));
400 connect(exceptionVectorTableBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowExceptionVectorTableBrowserWin()));
402 allWatchBrowseAct
= new QAction(QIcon(":/res/debug-watch.png"), tr("All Watch"), this);
403 allWatchBrowseAct
->setStatusTip(tr("Shows all Watch browser window"));
404 connect(allWatchBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowAllWatchBrowserWin()));
406 LocalBrowseAct
= new QAction(QIcon(":/res/debug-local.png"), tr("Local"), this);
407 LocalBrowseAct
->setStatusTip(tr("Shows Local browser window"));
408 connect(LocalBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowLocalBrowserWin()));
410 heapallocatorBrowseAct
= new QAction(QIcon(""), tr("Heap allocator"), this);
411 heapallocatorBrowseAct
->setStatusTip(tr("Shows the heap allocator browser window"));
412 connect(heapallocatorBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowHeapAllocatorBrowserWin()));
414 CallStackBrowseAct
= new QAction(QIcon(":/res/debug-callstack.png"), tr("Call Stack"), this);
415 CallStackBrowseAct
->setStatusTip(tr("Shows Call Stack browser window"));
416 connect(CallStackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCallStackBrowserWin()));
418 mem1BrowseAct
= (QAction
**)calloc(vjs
.nbrmemory1browserwindow
, sizeof(QAction
));
419 QSignalMapper
*signalMapper
= new QSignalMapper(this);
421 #pragma message("Warning: !!! Need to do the memory desalocation for mem1BrowseAct !!!")
423 #warning "!!! Need to do the memory desalocation for mem1BrowseAct !!!"
425 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
428 sprintf(MB
, "Memory %i", (unsigned int)(i
+1));
429 mem1BrowseAct
[i
] = new QAction(QIcon(":/res/debug-memory.png"), tr(MB
), this);
430 mem1BrowseAct
[i
]->setStatusTip(tr("Shows a Jaguar memory browser window"));
432 //connect(mem1BrowseAct[0], SIGNAL(triggered()), this, SLOT(ShowMemory1BrowserWin(size_t(0))));
433 connect(mem1BrowseAct
[i
], SIGNAL(triggered()), signalMapper
, SLOT(map()));
434 signalMapper
->setMapping(mem1BrowseAct
[i
], (int)i
);
435 connect(signalMapper
, SIGNAL(mapped(int)), this, SLOT(ShowMemory1BrowserWin(int)));
439 // Debugger Browser Actions
440 memBrowseAct
= new QAction(QIcon(":/res/tool-memory.png"), tr("Memory Browser"), this);
441 memBrowseAct
->setStatusTip(tr("Shows the Jaguar memory browser window"));
442 // memBrowseAct->setCheckable(true);
443 connect(memBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowMemoryBrowserWin()));
445 stackBrowseAct
= new QAction(QIcon(":/res/tool-stack.png"), tr("Stack Browser"), this);
446 stackBrowseAct
->setStatusTip(tr("Shows the Jaguar stack browser window"));
447 // memBrowseAct->setCheckable(true);
448 connect(stackBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowStackBrowserWin()));
450 cpuBrowseAct
= new QAction(QIcon(":/res/tool-cpu.png"), tr("CPU Browser"), this);
451 cpuBrowseAct
->setStatusTip(tr("Shows the Jaguar CPU browser window"));
452 // memBrowseAct->setCheckable(true);
453 connect(cpuBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowCPUBrowserWin()));
455 opBrowseAct
= new QAction(QIcon(":/res/tool-op.png"), tr("OP Browser"), this);
456 opBrowseAct
->setStatusTip(tr("Shows the Jaguar OP browser window"));
457 // memBrowseAct->setCheckable(true);
458 connect(opBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowOPBrowserWin()));
460 m68kDasmBrowseAct
= new QAction(QIcon(":/res/tool-68k-dis.png"), tr("68K Listing Browser"), this);
461 m68kDasmBrowseAct
->setStatusTip(tr("Shows the 68K disassembly browser window"));
462 // memBrowseAct->setCheckable(true);
463 connect(m68kDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowM68KDasmBrowserWin()));
465 riscDasmBrowseAct
= new QAction(QIcon(":/res/tool-risc-dis.png"), tr("RISC Listing Browser"), this);
466 riscDasmBrowseAct
->setStatusTip(tr("Shows the RISC disassembly browser window"));
467 // memBrowseAct->setCheckable(true);
468 connect(riscDasmBrowseAct
, SIGNAL(triggered()), this, SLOT(ShowRISCDasmBrowserWin()));
470 if (vjs
.softTypeDebugger
)
472 VideoOutputAct
= new QAction(tr("Output Video"), this);
473 VideoOutputAct
->setStatusTip(tr("Shows the output video window"));
474 connect(VideoOutputAct
, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));
476 DasmAct
= new QAction(tr("Disassembly"), this);
477 DasmAct
->setStatusTip(tr("Shows the disassembly window"));
478 connect(DasmAct
, SIGNAL(triggered()), this, SLOT(ShowDasmWin()));
481 // Misc. connections...
482 connect(filePickWin
, SIGNAL(RequestLoad(QString
)), this, SLOT(LoadSoftware(QString
)));
483 connect(filePickWin
, SIGNAL(FilePickerHiding()), this, SLOT(Unpause()));
487 fileMenu
= menuBar()->addMenu(tr("&Jaguar"));
488 fileMenu
->addAction(powerAct
);
489 if (!vjs
.softTypeDebugger
)
491 fileMenu
->addAction(pauseAct
);
492 // fileMenu->addAction(frameAdvanceAct);
494 fileMenu
->addAction(filePickAct
);
495 fileMenu
->addAction(useCDAct
);
496 fileMenu
->addAction(configAct
);
497 fileMenu
->addAction(emustatusAct
);
498 fileMenu
->addSeparator();
499 fileMenu
->addAction(quitAppAct
);
501 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
503 debugMenu
= menuBar()->addMenu(tr("&Debug"));
504 if (vjs
.softTypeDebugger
)
506 debugWindowsMenu
= debugMenu
->addMenu(tr("&Windows"));
507 debugWindowExceptionMenu
= debugWindowsMenu
->addMenu(tr("&Exception"));
508 debugWindowExceptionMenu
->addAction(exceptionVectorTableBrowseAct
);
509 debugWindowsMenu
->addSeparator();
511 debugWindowOutputMenu
= debugWindowsMenu
->addMenu(tr("&Output"));
512 debugWindowOutputMenu
->addAction(VideoOutputAct
);
513 debugWindowsMenu
->addSeparator();
515 debugWindowsWatchMenu
= debugWindowsMenu
->addMenu(tr("&Watch"));
516 debugWindowsWatchMenu
->addAction(allWatchBrowseAct
);
517 debugWindowsMenu
->addAction(LocalBrowseAct
);
518 debugWindowsMenu
->addSeparator();
519 debugWindowsMenu
->addAction(CallStackBrowseAct
);
520 debugWindowsMenu
->addSeparator();
521 debugWindowsMemoryMenu
= debugWindowsMenu
->addMenu(tr("&Memory"));
522 debugWindowsMemoryMenu
->addAction(heapallocatorBrowseAct
);
523 debugWindowsMemoryMenu
->addSeparator();
524 for (int i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
526 debugWindowsMemoryMenu
->addAction(mem1BrowseAct
[i
]);
528 debugWindowsMenu
->addSeparator();
529 debugWindowsBrowsesMenu
= debugWindowsMenu
->addMenu(tr("&Browsers"));
530 debugWindowsBrowsesMenu
->addAction(memBrowseAct
);
531 debugWindowsBrowsesMenu
->addAction(stackBrowseAct
);
532 debugWindowsBrowsesMenu
->addAction(cpuBrowseAct
);
533 debugWindowsBrowsesMenu
->addAction(opBrowseAct
);
534 debugWindowsBrowsesMenu
->addAction(m68kDasmBrowseAct
);
535 debugWindowsBrowsesMenu
->addAction(riscDasmBrowseAct
);
536 debugMenu
->addSeparator();
537 debugMenu
->addAction(pauseAct
);
538 debugMenu
->addAction(frameAdvanceAct
);
539 debugMenu
->addAction(restartAct
);
540 debugMenu
->addSeparator();
541 debugMenu
->addAction(traceStepIntoAct
);
542 debugMenu
->addAction(traceStepOverAct
);
544 debugMenu
->addSeparator();
545 debugNewBreakpointMenu
= debugMenu
->addMenu(tr("&New Breakpoint"));
546 debugNewBreakpointMenu
->addAction(newBreakpointFunctionAct
);
548 //debugMenu->addSeparator();
549 //debugMenu->addAction(DasmAct);
553 debugMenu
->addAction(memBrowseAct
);
554 debugMenu
->addAction(stackBrowseAct
);
555 debugMenu
->addAction(cpuBrowseAct
);
556 debugMenu
->addAction(opBrowseAct
);
557 debugMenu
->addAction(m68kDasmBrowseAct
);
558 debugMenu
->addAction(riscDasmBrowseAct
);
562 helpMenu
= menuBar()->addMenu(tr("&Help"));
563 helpMenu
->addAction(helpAct
);
564 helpMenu
->addAction(aboutAct
);
568 toolbar
= addToolBar(tr("Stuff"));
569 toolbar
->addAction(powerAct
);
570 if (!vjs
.softTypeDebugger
)
572 toolbar
->addAction(pauseAct
);
573 toolbar
->addAction(frameAdvanceAct
);
575 toolbar
->addAction(filePickAct
);
576 toolbar
->addAction(useCDAct
);
577 toolbar
->addSeparator();
578 if (!vjs
.softTypeDebugger
)
580 toolbar
->addAction(x1Act
);
581 toolbar
->addAction(x2Act
);
582 toolbar
->addAction(x3Act
);
583 toolbar
->addSeparator();
584 toolbar
->addAction(ntscAct
);
585 toolbar
->addAction(palAct
);
586 toolbar
->addSeparator();
587 toolbar
->addAction(blurAct
);
588 toolbar
->addAction(fullScreenAct
);
592 debuggerbar
= addToolBar(tr("&Debugger"));
593 debuggerbar
->addAction(pauseAct
);
594 debuggerbar
->addAction(frameAdvanceAct
);
595 debuggerbar
->addAction(restartAct
);
596 debuggerbar
->addSeparator();
597 debuggerbar
->addAction(traceStepIntoAct
);
598 debuggerbar
->addAction(traceStepOverAct
);
601 if (vjs
.hardwareTypeAlpine
)
603 debugbar
= addToolBar(tr("&Debug"));
604 debugbar
->addAction(memBrowseAct
);
605 debugbar
->addAction(stackBrowseAct
);
606 debugbar
->addAction(cpuBrowseAct
);
607 debugbar
->addAction(opBrowseAct
);
608 debugbar
->addAction(m68kDasmBrowseAct
);
609 debugbar
->addAction(riscDasmBrowseAct
);
612 // Add actions to the main window, as hiding widgets with them
614 addAction(fullScreenAct
);
615 addAction(quitAppAct
);
616 addAction(configAct
);
617 addAction(emustatusAct
);
619 addAction(filePickAct
);
620 addAction(frameAdvanceAct
);
623 statusBar()->showMessage(tr("Ready"));
625 // Do this in case original size isn't correct (mostly for the first-run case)
628 WriteLog("Window creation done\n");
630 // Create our test pattern NTSC bitmap
631 WriteLog("Test pattern 1 bitmap\n");
633 QImage
tempImg(":/res/test-pattern.jpg");
634 QImage tempImgScaled
= tempImg
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
636 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
638 const QRgb
* scanline
= (QRgb
*)tempImgScaled
.constScanLine(y
);
640 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
642 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
643 testPattern
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
647 // Create our test pattern PAL bitmap
648 WriteLog("Test pattern 2 bitmap\n");
650 QImage
tempImg2(":/res/test-pattern-pal.jpg");
651 QImage tempImgScaled2
= tempImg2
.scaled(VIRTUAL_SCREEN_WIDTH
, VIRTUAL_SCREEN_HEIGHT_PAL
, Qt::IgnoreAspectRatio
, Qt::SmoothTransformation
);
653 for(uint32_t y
=0; y
<VIRTUAL_SCREEN_HEIGHT_PAL
; y
++)
655 const QRgb
* scanline
= (QRgb
*)tempImgScaled2
.constScanLine(y
);
657 for(uint32_t x
=0; x
<VIRTUAL_SCREEN_WIDTH
; x
++)
659 uint32_t pixel
= (qRed(scanline
[x
]) << 24) | (qGreen(scanline
[x
]) << 16) | (qBlue(scanline
[x
]) << 8) | 0xFF;
660 testPattern2
[(y
* VIRTUAL_SCREEN_WIDTH
) + x
] = pixel
;
664 // Set up timer based loop for animation...
665 timer
= new QTimer(this);
666 connect(timer
, SIGNAL(timeout()), this, SLOT(Timer()));
668 // This isn't very accurate for NTSC: This is early by 40 msec per frame.
669 // This is because it's discarding the 0.6666... on the end of the fraction.
670 // Alas, 6 doesn't divide cleanly into 10. :-P
671 //Should we defer this until SyncUI? Probably.
672 //No, it doesn't work, because it uses setInterval() instead of start()...
673 // timer->start(vjs.hardwareTypeNTSC ? 16 : 20);
675 // We set this initially, to make VJ behave somewhat as it would if no
676 // cart were inserted and the BIOS was set as active...
677 jaguarCartInserted
= true;
678 WriteLog("Virtual Jaguar %s Rx (Last full build was on %s %s)\n", VJ_RELEASE_VERSION
, __DATE__
, __TIME__
);
679 WriteLog("VJ: Initializing jaguar subsystem...\n");
681 // memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS
682 memcpy(jagMemSpace
+ 0xE00000, (vjs
.biosType
== BT_K_SERIES
? jaguarBootROM
: jaguarBootROM2
), 0x20000); // Use the stock BIOS
684 // Prevent the file scanner from running if filename passed
685 // in on the command line...
689 // Load up the default ROM if in Alpine mode:
690 if (vjs
.hardwareTypeAlpine
)
692 bool romLoaded
= JaguarLoadFile(vjs
.alpineROMPath
);
694 // If regular load failed, try just a straight file load
695 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
697 romLoaded
= AlpineLoadFile(vjs
.alpineROMPath
);
700 WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs
.alpineROMPath
);
702 WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs
.alpineROMPath
);
704 // Attempt to load/run the ABS file...
705 LoadSoftware(vjs
.absROMPath
);
706 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
707 // Prevent the scanner from running...
711 // Load up the default ROM if in Debugger mode:
712 if (vjs
.softTypeDebugger
)
714 bool romLoaded
= JaguarLoadFile(vjs
.debuggerROMPath
);
716 // If regular load failed, try just a straight file load
717 // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
719 romLoaded
= DebuggerLoadFile(vjs
.debuggerROMPath
);
722 WriteLog("Debugger Mode: Successfully loaded file \"%s\".\n", vjs
.debuggerROMPath
);
724 WriteLog("Debugger Mode: Unable to load file \"%s\"!\n", vjs
.debuggerROMPath
);
726 // Attempt to load/run the ABS file...
727 LoadSoftware(vjs
.absROMPath
);
728 memcpy(jagMemSpace
+ 0xE00000, jaguarDevBootROM2
, 0x20000); // Use the stub BIOS
729 // Prevent the scanner from running...
733 // Run the scanner if nothing passed in and *not* Alpine mode...
734 // NB: Really need to look into caching the info scanned in here...
735 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
736 scannedSoftwareFolder
= true;
740 void MainWin::LoadFile(QString file
)
746 void MainWin::SyncUI(void)
748 // Set toolbar buttons/menus based on settings read in (sync the UI)...
749 // (Really, this is to sync command line options passed in)
750 blurAct
->setChecked(vjs
.glFilter
);
751 x1Act
->setChecked(zoomLevel
== 1);
752 x2Act
->setChecked(zoomLevel
== 2);
753 x3Act
->setChecked(zoomLevel
== 3);
754 // running = powerAct->isChecked();
755 ntscAct
->setChecked(vjs
.hardwareTypeNTSC
);
756 palAct
->setChecked(!vjs
.hardwareTypeNTSC
);
757 powerAct
->setIcon(vjs
.hardwareTypeNTSC
? powerRed
: powerGreen
);
759 fullScreenAct
->setChecked(vjs
.fullscreen
);
760 fullScreen
= vjs
.fullscreen
;
761 SetFullScreen(fullScreen
);
763 // Reset the timer to be what was set in the command line (if any):
764 // timer->setInterval(vjs.hardwareTypeNTSC ? 16 : 20);
765 timer
->start(vjs
.hardwareTypeNTSC
? 16 : 20);
769 void MainWin::closeEvent(QCloseEvent
* event
)
772 // This should only be done by the config dialog
775 event
->accept(); // ignore() if can't close for some reason
779 void MainWin::keyPressEvent(QKeyEvent
* e
)
781 #ifndef VJ_REMOVE_DEV_CODE
783 //extern bool startM68KTracing; // moved to jaguar.h
785 extern int blit_start_log
;
787 extern bool startConciseBlitLogging
;
790 // We ignore the Alt key for now, since it causes problems with the GUI
791 if (e
->key() == Qt::Key_Alt
)
796 // Bar this shite from release versions kthxbai
797 #ifndef VJ_REMOVE_DEV_CODE
798 else if (e
->key() == Qt::Key_F11
)
800 startM68KTracing
= true;
804 else if (e
->key() == Qt::Key_F12
)
806 blit_start_log
= true;
810 else if (e
->key() == Qt::Key_F10
)
812 startConciseBlitLogging
= true;
817 else if (e
->key() == Qt::Key_F8
)
819 // ggn: For extra NYAN pleasure...
820 // ggn: There you go James :P
821 // Shamus: Thanks for the patch! :-D
822 WriteLog(" o + + +\n");
823 WriteLog("+ o o + o\n");
824 WriteLog("-_-_-_-_-_-_-_,------, o \n");
825 WriteLog("_-_-_-_-_-_-_-| /\\_/\\ \n");
826 WriteLog("-_-_-_-_-_-_-~|__( ^ .^) + + \n");
827 WriteLog("_-_-_-_-_-_-_-\"\" \"\" \n");
828 WriteLog("+ o o + o\n");
835 This is done now by a QAction...
836 if (e->key() == Qt::Key_F9)
846 void MainWin::keyReleaseEvent(QKeyEvent
* e
)
848 // We ignore the Alt key for now, since it causes problems with the GUI
849 if (e
->key() == Qt::Key_Alt
)
855 HandleKeys(e
, false);
859 void MainWin::HandleKeys(QKeyEvent
* e
, bool state
)
861 enum { P1LEFT
= 0, P1RIGHT
, P1UP
, P1DOWN
, P2LEFT
, P2RIGHT
, P2UP
, P2DOWN
};
862 // We kill bad key combos here, before they can get to the emulator...
863 // This also kills the illegal instruction problem that cropped up in
866 // First, settle key states...
867 if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_L
])
868 keyHeld
[P1LEFT
] = state
;
869 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_R
])
870 keyHeld
[P1RIGHT
] = state
;
871 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_U
])
872 keyHeld
[P1UP
] = state
;
873 else if (e
->key() == (int)vjs
.p1KeyBindings
[BUTTON_D
])
874 keyHeld
[P1DOWN
] = state
;
875 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_L
])
876 keyHeld
[P2LEFT
] = state
;
877 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_R
])
878 keyHeld
[P2RIGHT
] = state
;
879 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_U
])
880 keyHeld
[P2UP
] = state
;
881 else if (e
->key() == (int)vjs
.p2KeyBindings
[BUTTON_D
])
882 keyHeld
[P2DOWN
] = state
;
884 // Next, check for conflicts and kill 'em if there are any...
885 if (keyHeld
[P1LEFT
] && keyHeld
[P1RIGHT
])
886 keyHeld
[P1LEFT
] = keyHeld
[P1RIGHT
] = false;
888 if (keyHeld
[P1UP
] && keyHeld
[P1DOWN
])
889 keyHeld
[P1UP
] = keyHeld
[P1DOWN
] = false;
891 if (keyHeld
[P2LEFT
] && keyHeld
[P2RIGHT
])
892 keyHeld
[P2LEFT
] = keyHeld
[P2RIGHT
] = false;
894 if (keyHeld
[P2UP
] && keyHeld
[P2DOWN
])
895 keyHeld
[P2UP
] = keyHeld
[P2DOWN
] = false;
897 // No bad combos exist now, let's stuff the emulator key buffers...!
898 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
900 if (e
->key() == (int)vjs
.p1KeyBindings
[i
])
901 joypad0Buttons
[i
] = (state
? 0x01 : 0x00);
903 if (e
->key() == (int)vjs
.p2KeyBindings
[i
])
904 joypad1Buttons
[i
] = (state
? 0x01 : 0x00);
910 // N.B.: The profile system AutoConnect functionality sets the gamepad IDs here.
912 void MainWin::HandleGamepads(void)
916 for(int i
=BUTTON_FIRST
; i
<=BUTTON_LAST
; i
++)
918 if (vjs
.p1KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
919 joypad0Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot1
, vjs
.p1KeyBindings
[i
]) ? 0x01 : 0x00);
921 if (vjs
.p2KeyBindings
[i
] & (JOY_BUTTON
| JOY_HAT
| JOY_AXIS
))
922 joypad1Buttons
[i
] = (Gamepad::GetState(gamepadIDSlot2
, vjs
.p2KeyBindings
[i
]) ? 0x01 : 0x00);
927 void MainWin::Open(void)
932 void MainWin::Configure(void)
934 // Call the configuration dialog and update settings
935 ConfigDialog
dlg(this);
937 dlg
.generalTab
->useUnknownSoftware
->setChecked(allowUnknownSoftware
);
938 dlg
.controllerTab1
->profileNum
= lastEditedProfile
;
939 dlg
.controllerTab1
->SetupLastUsedProfile();
940 // maybe instead of this, we tell the controller tab to work on a copy that gets
941 // written if the user hits 'OK'.
942 SaveProfiles(); // Just in case user cancels
944 if (dlg
.exec() == false)
950 QString before
= vjs
.ROMPath
;
951 QString alpineBefore
= vjs
.alpineROMPath
;
952 QString absBefore
= vjs
.absROMPath
;
953 // bool audioBefore = vjs.audioEnabled;
954 bool audioBefore
= vjs
.DSPEnabled
;
955 dlg
.UpdateVJSettings();
956 QString after
= vjs
.ROMPath
;
957 QString alpineAfter
= vjs
.alpineROMPath
;
958 QString absAfter
= vjs
.absROMPath
;
959 // bool audioAfter = vjs.audioEnabled;
960 bool audioAfter
= vjs
.DSPEnabled
;
962 bool allowOld
= allowUnknownSoftware
;
964 allowUnknownSoftware
= dlg
.generalTab
->useUnknownSoftware
->isChecked();
965 lastEditedProfile
= dlg
.controllerTab1
->profileNum
;
966 AutoConnectProfiles();
968 // We rescan the "software" folder if the user either changed the path or
969 // checked/unchecked the "Allow unknown files" option in the config dialog.
970 if ((before
!= after
) || (allowOld
!= allowUnknownSoftware
))
971 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
973 // If the "Alpine" ROM is changed, then let's load it...
974 if (alpineBefore
!= alpineAfter
)
976 if (!JaguarLoadFile(vjs
.alpineROMPath
) && !AlpineLoadFile(vjs
.alpineROMPath
))
978 // Oh crap, we couldn't get the file! Alert the media!
980 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.alpineROMPath
));
981 msg
.setIcon(QMessageBox::Warning
);
986 // If the "ABS" ROM is changed, then let's load it...
987 if (absBefore
!= absAfter
)
989 if (!JaguarLoadFile(vjs
.absROMPath
))
991 // Oh crap, we couldn't get the file! Alert the media!
993 msg
.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs
.absROMPath
));
994 msg
.setIcon(QMessageBox::Warning
);
999 // If the "Enable DSP" checkbox changed, then we have to re-init the DAC,
1000 // since it's running in the host audio IRQ...
1001 if (audioBefore
!= audioAfter
)
1007 // Just in case we crash before a clean exit...
1010 DebuggerRefreshWindows();
1015 // Here's the main emulator loop
1017 void MainWin::Timer(void)
1020 static uint32_t ntscTickCount
;
1021 if (vjs
.hardwareTypeNTSC
)
1025 timer
->start(16 + (ntscTickCount
== 0 ? 1 : 0));
1032 if (showUntunedTankCircuit
)
1034 // Some machines can't handle this, so we give them the option to disable it. :-)
1035 if (!plzDontKillMyComputer
)
1037 // if (!vjs.softTypeDebugger)
1039 // Random hash & trash
1040 // We try to simulate an untuned tank circuit here... :-)
1041 for (uint32_t x
= 0; x
< videoWidget
->rasterWidth
; x
++)
1043 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1045 videoWidget
->buffer
[(y
* videoWidget
->textureWidth
) + x
] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;
1053 // Otherwise, run the Jaguar simulation
1056 if (!vjs
.softTypeDebugger
)
1057 videoWidget
->HandleMouseHiding();
1059 static uint32_t refresh
= 0;
1060 // Do autorefresh on debug windows
1061 // Have to be careful, too much causes the emulator to slow way down!
1062 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1064 if (refresh
== vjs
.refresh
)
1066 RefreshAlpineWindows();
1067 //memBrowseWin->RefreshContents();
1068 //cpuBrowseWin->RefreshContents();
1076 //if (!vjs.softTypeDebugger)
1077 videoWidget
->updateGL();
1080 // Approach: We use a ring buffer to store times (in ms) over a given
1081 // amount of frames, then sum them to figure out the FPS.
1082 uint32_t timestamp
= SDL_GetTicks();
1083 // This assumes the ring buffer size is a power of 2
1084 // ringBufferPointer = (ringBufferPointer + 1) & (RING_BUFFER_SIZE - 1);
1085 // Doing it this way is better. Ring buffer size can be arbitrary then.
1086 ringBufferPointer
= (ringBufferPointer
+ 1) % RING_BUFFER_SIZE
;
1087 ringBuffer
[ringBufferPointer
] = timestamp
- oldTimestamp
;
1088 uint32_t elapsedTime
= 0;
1090 for(uint32_t i
=0; i
<RING_BUFFER_SIZE
; i
++)
1091 elapsedTime
+= ringBuffer
[i
];
1093 // elapsedTime must be non-zero
1094 if (elapsedTime
== 0)
1097 // This is in frames per 10 seconds, so we can have 1 decimal
1098 uint32_t framesPerSecond
= (uint32_t)(((float)RING_BUFFER_SIZE
/ (float)elapsedTime
) * 10000.0);
1099 uint32_t fpsIntegerPart
= framesPerSecond
/ 10;
1100 uint32_t fpsDecimalPart
= framesPerSecond
% 10;
1101 // If this is updated too frequently to be useful, we can throttle it down
1102 // so that it only updates every 10th frame or so
1103 statusBar()->showMessage(QString("%1.%2 FPS").arg(fpsIntegerPart
).arg(fpsDecimalPart
));
1104 oldTimestamp
= timestamp
;
1106 if (M68KDebugHaltStatus())
1111 void MainWin::TogglePowerState(void)
1113 powerButtonOn
= !powerButtonOn
;
1116 // With the power off, we simulate white noise on the screen. :-)
1119 // Restore the mouse pointer, if hidden:
1120 if (!vjs
.softTypeDebugger
)
1121 videoWidget
->CheckAndRestoreMouseCursor();
1122 useCDAct
->setDisabled(false);
1123 palAct
->setDisabled(false);
1124 ntscAct
->setDisabled(false);
1125 pauseAct
->setChecked(false);
1126 pauseAct
->setDisabled(true);
1127 showUntunedTankCircuit
= true;
1128 DACPauseAudioThread();
1129 // This is just in case the ROM we were playing was in a narrow or wide
1130 // field mode, so the untuned tank sim doesn't look wrong. :-)
1133 if (plzDontKillMyComputer
)
1135 //if (!vjs.softTypeDebugger)
1137 // We have to do it line by line, because the texture pitch is not
1138 // the same as the picture buffer's pitch.
1139 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1141 if (vjs
.hardwareTypeNTSC
)
1142 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1144 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1151 useCDAct
->setDisabled(true);
1152 palAct
->setDisabled(true);
1153 ntscAct
->setDisabled(true);
1154 pauseAct
->setChecked(false);
1155 pauseAct
->setDisabled(false);
1156 showUntunedTankCircuit
= false;
1158 // Otherwise, we prepare for running regular software...
1161 // Should check for cartridgeLoaded here as well...!
1162 // We can clear it when toggling CDActive on, so that when we power cycle it
1163 // does the expected thing. Otherwise, if we use the file picker to insert a
1164 // cart, we expect to run the cart! Maybe have a RemoveCart function that only
1165 // works if the CD unit is active?
1166 setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: Jaguar CD"));
1169 WriteLog("GUI: Resetting Jaguar...\n");
1171 DebuggerResetWindows();
1172 DACPauseAudioThread(false);
1177 void MainWin::ToggleRunState(void)
1179 startM68KTracing
= running
;
1184 frameAdvanceAct
->setDisabled(false);
1185 pauseAct
->setChecked(true);
1186 pauseAct
->setDisabled(false);
1187 if (vjs
.softTypeDebugger
)
1189 traceStepIntoAct
->setDisabled(false);
1190 traceStepOverAct
->setDisabled(false);
1191 restartAct
->setDisabled(false);
1192 m68kDasmWin
->Use68KPCAddress();
1193 GPUDasmWin
->UseGPUPCAddress();
1194 DSPDasmWin
->UseDSPPCAddress();
1197 //if (!vjs.softTypeDebugger)
1199 // Restore the mouse pointer, if hidden:
1200 videoWidget
->CheckAndRestoreMouseCursor();
1201 // frameAdvanceAct->setDisabled(false);
1203 for (uint32_t i
= 0; i
< (uint32_t)(videoWidget
->textureWidth
* 256); i
++)
1205 uint32_t pixel
= videoWidget
->buffer
[i
];
1206 uint8_t r
= (pixel
>> 24) & 0xFF, g
= (pixel
>> 16) & 0xFF, b
= (pixel
>> 8) & 0xFF;
1207 pixel
= ((r
+ g
+ b
) / 3) & 0x00FF;
1208 videoWidget
->buffer
[i
] = 0x000000FF | (pixel
<< 16) | (pixel
<< 8);
1211 videoWidget
->updateGL();
1213 cpuBrowseWin
->HoldBPM();
1214 cpuBrowseWin
->HandleBPMContinue();
1215 DebuggerRefreshWindows();
1220 frameAdvanceAct
->setDisabled(true);
1221 pauseAct
->setChecked(false);
1222 pauseAct
->setDisabled(false);
1223 if (vjs
.softTypeDebugger
)
1225 traceStepIntoAct
->setDisabled(true);
1226 traceStepOverAct
->setDisabled(true);
1227 restartAct
->setDisabled(true);
1230 cpuBrowseWin
->UnholdBPM();
1233 // Pause/unpause any running/non-running threads...
1234 DACPauseAudioThread(!running
);
1238 void MainWin::SetZoom100(void)
1245 void MainWin::SetZoom200(void)
1252 void MainWin::SetZoom300(void)
1259 void MainWin::SetNTSC(void)
1261 powerAct
->setIcon(powerRed
);
1262 timer
->setInterval(16);
1263 vjs
.hardwareTypeNTSC
= true;
1269 void MainWin::SetPAL(void)
1271 powerAct
->setIcon(powerGreen
);
1272 timer
->setInterval(20);
1273 vjs
.hardwareTypeNTSC
= false;
1279 void MainWin::ToggleBlur(void)
1281 vjs
.glFilter
= !vjs
.glFilter
;
1286 void MainWin::ShowAboutWin(void)
1292 void MainWin::ShowHelpWin(void)
1298 void MainWin::InsertCart(void)
1300 // Check to see if we did autorun, 'cause we didn't load anything in that
1302 if (!scannedSoftwareFolder
)
1304 filePickWin
->ScanSoftwareFolder(allowUnknownSoftware
);
1305 scannedSoftwareFolder
= true;
1308 // If the emulator is running, we pause it here and unpause it later
1309 // if we dismiss the file selector without choosing anything
1310 if (running
&& powerButtonOn
)
1313 pauseForFileSelector
= true;
1316 filePickWin
->show();
1320 void MainWin::Unpause(void)
1322 // Here we unpause the emulator if it was paused when we went into the file selector
1323 if (pauseForFileSelector
)
1325 pauseForFileSelector
= false;
1327 // Some nutter might have unpaused while in the file selector, so check for that
1334 // Jaguar initialisation and load software file
1335 void MainWin::LoadSoftware(QString file
)
1337 running
= false; // Prevent bad things(TM) from happening...
1338 pauseForFileSelector
= false; // Reset the file selector pause flag
1340 uint8_t * biosPointer
= jaguarBootROM
;
1342 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1344 biosPointer
= jaguarDevBootROM2
;
1347 memcpy(jagMemSpace
+ 0xE00000, biosPointer
, 0x20000);
1349 powerAct
->setDisabled(false);
1350 powerAct
->setChecked(true);
1351 powerButtonOn
= false;
1354 // We have to load our software *after* the Jaguar RESET
1355 cartridgeLoaded
= JaguarLoadFile(file
.toUtf8().data());
1356 SET32(jaguarMainRAM
, 0, vjs
.DRAM_size
); // Set top of stack...
1358 // This is icky because we've already done it
1359 // it gets worse :-P
1360 if (!vjs
.useJaguarBIOS
)
1362 SET32(jaguarMainRAM
, 4, jaguarRunAddress
);
1367 // set the M68K in halt mode in case of a debug mode is used, so control is at user side
1368 if (vjs
.softTypeDebugger
)
1370 m68k_set_reg(M68K_REG_A6
, 0);
1371 m68kDasmWin
->SetAddress(jaguarRunAddress
);
1372 //pauseAct->setDisabled(false);
1373 //pauseAct->setChecked(true);
1379 if (vjs
.hardwareTypeAlpine
&& !jaguarRunAddress
)
1385 if ((!vjs
.hardwareTypeAlpine
|| !vjs
.softTypeDebugger
) && !loadAndGo
&& jaguarRunAddress
)
1387 QString newTitle
= QString("Virtual Jaguar " VJ_RELEASE_VERSION
" Rx - Now playing: %1").arg(filePickWin
->GetSelectedPrettyName());
1388 setWindowTitle(newTitle
);
1393 void MainWin::ToggleCDUsage(void)
1395 CDActive
= !CDActive
;
1397 // Set up the Jaguar CD for execution, otherwise, clear memory
1399 memcpy(jagMemSpace
+ 0x800000, jaguarCDBootROM
, 0x40000);
1401 memset(jagMemSpace
+ 0x800000, 0xFF, 0x40000);
1406 void MainWin::NewBreakpointFunction(void)
1409 brkWin
->RefreshContents();
1414 void MainWin::DebuggerTraceStepInto(void)
1417 videoWidget
->updateGL();
1418 DebuggerRefreshWindows();
1420 #pragma message("Warning: !!! Need to verify the Step Into function !!!")
1422 #warning "!!! Need to verify the Step Into function !!!"
1428 void MainWin::DebuggerRestart(void)
1433 m68k_set_reg(M68K_REG_PC
, jaguarRunAddress
);
1434 m68k_set_reg(M68K_REG_SP
, vjs
.DRAM_size
);
1436 m68k_set_reg(M68K_REG_A6
, 0);
1438 DebuggerResetWindows();
1439 DebuggerRefreshWindows();
1441 #pragma message("Warning: !!! Need to verify the Restart function !!!")
1443 #warning "!!! Need to verify the Restart function !!!"
1449 void MainWin::DebuggerTraceStepOver(void)
1452 videoWidget
->updateGL();
1453 DebuggerRefreshWindows();
1455 #pragma message("Warning: !!! Need to verify the Step Over function !!!")
1457 #warning "!!! Need to verify the Step Over function !!!"
1462 // Advance / Execute for one frame
1463 void MainWin::FrameAdvance(void)
1465 //printf("Frame Advance...\n");
1467 // Execute 1 frame, then exit (only useful in Pause mode)
1469 //if (!vjs.softTypeDebugger)
1470 videoWidget
->updateGL();
1472 // Need to execute 1 frames' worth of DSP thread as well :-/
1474 //m68kDasmWin->Use68KPCAddress();
1477 #pragma message("Warning: !!! Need to execute the DSP thread for 1 frame too !!!")
1479 #warning "!!! Need to execute the DSP thread for 1 frame too !!!"
1484 void MainWin::SetFullScreen(bool state
/*= true*/)
1486 if (!vjs
.softTypeDebugger
)
1490 mainWinPosition
= pos();
1492 statusBar()->hide();
1498 // This is needed because the fullscreen may happen on a different
1499 // screen than screen 0:
1500 int screenNum
= QApplication::desktop()->screenNumber(videoWidget
);
1501 QRect r
= QApplication::desktop()->screenGeometry(screenNum
);
1502 double targetWidth
= (double)VIRTUAL_SCREEN_WIDTH
,
1503 targetHeight
= (double)(vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
);
1504 double aspectRatio
= targetWidth
/ targetHeight
;
1505 // NOTE: Really should check here to see which dimension constrains the
1506 // other. Right now, we assume that height is the constraint.
1507 int newWidth
= (int)(aspectRatio
* (double)r
.height());
1508 videoWidget
->offset
= (r
.width() - newWidth
) / 2;
1509 videoWidget
->fullscreen
= true;
1510 videoWidget
->outputWidth
= newWidth
;
1511 videoWidget
->setFixedSize(r
.width(), r
.height());
1516 // Seems Qt is fussy about this: showNormal() has to go first, or it
1517 // will keep the window stuck in a psuedo-fullscreen mode with no way
1518 // to get out of it (except closing the app).
1521 // Reset the video widget to windowed mode
1522 videoWidget
->offset
= 0;
1523 videoWidget
->fullscreen
= false;
1525 statusBar()->show();
1532 move(mainWinPosition
);
1538 void MainWin::ToggleFullScreen(void)
1540 fullScreen
= !fullScreen
;
1541 SetFullScreen(fullScreen
);
1546 void MainWin::ShowExceptionVectorTableBrowserWin(void)
1548 exceptionvectortableBrowseWin
->show();
1549 exceptionvectortableBrowseWin
->RefreshContents();
1554 void MainWin::ShowLocalBrowserWin(void)
1556 LocalBrowseWin
->show();
1557 LocalBrowseWin
->RefreshContents();
1562 void MainWin::ShowCallStackBrowserWin(void)
1564 CallStackBrowseWin
->show();
1565 CallStackBrowseWin
->RefreshContents();
1569 void MainWin::ShowAllWatchBrowserWin(void)
1571 allWatchBrowseWin
->show();
1572 allWatchBrowseWin
->RefreshContents();
1576 void MainWin::ShowHeapAllocatorBrowserWin(void)
1578 heapallocatorBrowseWin
->show();
1579 heapallocatorBrowseWin
->RefreshContents();
1583 void MainWin::ShowMemoryBrowserWin(void)
1585 memBrowseWin
->show();
1586 memBrowseWin
->RefreshContents();
1590 void MainWin::ShowMemory1BrowserWin(int NumWin
)
1592 // for (int i = 0; i < vjs.nbrmemory1browserwindow; i++)
1594 mem1BrowseWin
[NumWin
]->show();
1595 mem1BrowseWin
[NumWin
]->RefreshContents(NumWin
);
1600 void MainWin::ShowEmuStatusWin(void)
1602 emuStatusWin
->show();
1603 emuStatusWin
->RefreshContents();
1607 void MainWin::ShowStackBrowserWin(void)
1609 stackBrowseWin
->show();
1610 stackBrowseWin
->RefreshContents();
1614 void MainWin::ShowCPUBrowserWin(void)
1616 cpuBrowseWin
->show();
1617 cpuBrowseWin
->RefreshContents();
1621 void MainWin::ShowOPBrowserWin(void)
1623 opBrowseWin
->show();
1624 opBrowseWin
->RefreshContents();
1628 void MainWin::ShowM68KDasmBrowserWin(void)
1630 m68kDasmBrowseWin
->show();
1631 m68kDasmBrowseWin
->RefreshContents();
1635 void MainWin::ShowRISCDasmBrowserWin(void)
1637 riscDasmBrowseWin
->show();
1638 riscDasmBrowseWin
->RefreshContents();
1642 void MainWin::ShowDasmWin(void)
1645 // DasmWin->RefreshContents();
1649 void MainWin::ShowVideoOutputWin(void)
1651 //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);
1652 //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));
1653 //VideoOutputWindowCentrale->show();
1654 //memBrowseWin->show();
1655 //VideoOutputWin->show();
1656 //VideoOutputWin->RefreshContents(videoWidget);
1660 void MainWin::ResizeMainWindow(void)
1662 if (!vjs
.softTypeDebugger
)
1664 videoWidget
->setFixedSize(zoomLevel
* VIRTUAL_SCREEN_WIDTH
,
1665 zoomLevel
* (vjs
.hardwareTypeNTSC
? VIRTUAL_SCREEN_HEIGHT_NTSC
: VIRTUAL_SCREEN_HEIGHT_PAL
));
1667 // Show the test pattern if user requested plzDontKillMyComputer mode
1668 if (!powerButtonOn
&& plzDontKillMyComputer
)
1670 for (uint32_t y
= 0; y
< videoWidget
->rasterHeight
; y
++)
1672 if (vjs
.hardwareTypeNTSC
)
1673 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1675 memcpy(videoWidget
->buffer
+ (y
* videoWidget
->textureWidth
), testPattern2
+ (y
* VIRTUAL_SCREEN_WIDTH
), VIRTUAL_SCREEN_WIDTH
* sizeof(uint32_t));
1685 void MainWin::ReadSettings(void)
1689 QSettings
settings("Underground Software", "Virtual Jaguar");
1691 //zoomLevel = settings.value("zoom", 2).toInt();
1692 allowUnknownSoftware
= settings
.value("showUnknownSoftware", false).toBool();
1693 lastEditedProfile
= settings
.value("lastEditedProfile", 0).toInt();
1695 vjs
.useJoystick
= settings
.value("useJoystick", false).toBool();
1696 vjs
.joyport
= settings
.value("joyport", 0).toInt();
1697 vjs
.hardwareTypeNTSC
= settings
.value("hardwareTypeNTSC", true).toBool();
1698 vjs
.frameSkip
= settings
.value("frameSkip", 0).toInt();
1699 vjs
.useJaguarBIOS
= settings
.value("useJaguarBIOS", false).toBool();
1700 vjs
.GPUEnabled
= settings
.value("GPUEnabled", true).toBool();
1701 vjs
.DSPEnabled
= settings
.value("DSPEnabled", true).toBool();
1702 vjs
.audioEnabled
= settings
.value("audioEnabled", true).toBool();
1703 vjs
.usePipelinedDSP
= settings
.value("usePipelinedDSP", false).toBool();
1704 vjs
.fullscreen
= settings
.value("fullscreen", false).toBool();
1705 vjs
.useOpenGL
= settings
.value("useOpenGL", true).toBool();
1706 vjs
.glFilter
= settings
.value("glFilterType", 1).toInt();
1707 vjs
.renderType
= settings
.value("renderType", 0).toInt();
1708 vjs
.biosType
= settings
.value("biosType", BT_M_SERIES
).toInt();
1709 vjs
.useFastBlitter
= settings
.value("useFastBlitter", false).toBool();
1710 strcpy(vjs
.EEPROMPath
, settings
.value("EEPROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/eeproms/")).toString().toUtf8().data());
1711 strcpy(vjs
.ROMPath
, settings
.value("ROMs", QStandardPaths::writableLocation(QStandardPaths::DataLocation
).append("/software/")).toString().toUtf8().data());
1713 // Read settings from the Debugger mode
1714 settings
.beginGroup("debugger");
1715 strcpy(vjs
.debuggerROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1716 vjs
.nbrdisasmlines
= settings
.value("NbrDisasmLines", 32).toUInt();
1717 vjs
.disasmopcodes
= settings
.value("DisasmOpcodes", true).toBool();
1718 vjs
.displayHWlabels
= settings
.value("DisplayHWLabels", true).toBool();
1719 vjs
.displayFullSourceFilename
= settings
.value("displayFullSourceFilename", true).toBool();
1720 vjs
.nbrmemory1browserwindow
= settings
.value("NbrMemory1BrowserWindow", MaxMemory1BrowserWindow
).toUInt();
1721 settings
.endGroup();
1723 // Read settings from the Alpine mode
1724 settings
.beginGroup("alpine");
1725 strcpy(vjs
.alpineROMPath
, settings
.value("DefaultROM", "").toString().toUtf8().data());
1726 strcpy(vjs
.absROMPath
, settings
.value("DefaultABS", "").toString().toUtf8().data());
1727 vjs
.refresh
= settings
.value("refresh", 60).toUInt();
1728 vjs
.allowWritesToROM
= settings
.value("writeROM", false).toBool();
1729 settings
.endGroup();
1731 // Read settings from the Keybindings
1732 settings
.beginGroup("keybindings");
1733 for (i
= 0; i
< KB_END
; i
++)
1735 strcpy(vjs
.KBContent
[i
].KBSettingValue
, settings
.value(KeyBindingsTable
[i
].KBNameSetting
, KeyBindingsTable
[i
].KBDefaultValue
).toString().toUtf8().data());
1737 settings
.endGroup();
1739 // Write important settings to the log file
1740 WriteLog("MainWin: Paths\n");
1741 WriteLog(" EEPROMPath = \"%s\"\n", vjs
.EEPROMPath
);
1742 WriteLog(" ROMPath = \"%s\"\n", vjs
.ROMPath
);
1743 WriteLog(" AlpineROMPath = \"%s\"\n", vjs
.alpineROMPath
);
1744 WriteLog("DebuggerROMPath = \"%s\"\n", vjs
.debuggerROMPath
);
1745 WriteLog(" absROMPath = \"%s\"\n", vjs
.absROMPath
);
1746 WriteLog(" Pipelined DSP = %s\n", (vjs
.usePipelinedDSP
? "ON" : "off"));
1749 // Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
1750 vjs
.p1KeyBindings
[BUTTON_U
] = settings
.value("p1k_up", Qt::Key_S
).toInt();
1751 vjs
.p1KeyBindings
[BUTTON_D
] = settings
.value("p1k_down", Qt::Key_X
).toInt();
1752 vjs
.p1KeyBindings
[BUTTON_L
] = settings
.value("p1k_left", Qt::Key_A
).toInt();
1753 vjs
.p1KeyBindings
[BUTTON_R
] = settings
.value("p1k_right", Qt::Key_D
).toInt();
1754 vjs
.p1KeyBindings
[BUTTON_C
] = settings
.value("p1k_c", Qt::Key_J
).toInt();
1755 vjs
.p1KeyBindings
[BUTTON_B
] = settings
.value("p1k_b", Qt::Key_K
).toInt();
1756 vjs
.p1KeyBindings
[BUTTON_A
] = settings
.value("p1k_a", Qt::Key_L
).toInt();
1757 vjs
.p1KeyBindings
[BUTTON_OPTION
] = settings
.value("p1k_option", Qt::Key_O
).toInt();
1758 vjs
.p1KeyBindings
[BUTTON_PAUSE
] = settings
.value("p1k_pause", Qt::Key_P
).toInt();
1759 vjs
.p1KeyBindings
[BUTTON_0
] = settings
.value("p1k_0", Qt::Key_0
).toInt();
1760 vjs
.p1KeyBindings
[BUTTON_1
] = settings
.value("p1k_1", Qt::Key_1
).toInt();
1761 vjs
.p1KeyBindings
[BUTTON_2
] = settings
.value("p1k_2", Qt::Key_2
).toInt();
1762 vjs
.p1KeyBindings
[BUTTON_3
] = settings
.value("p1k_3", Qt::Key_3
).toInt();
1763 vjs
.p1KeyBindings
[BUTTON_4
] = settings
.value("p1k_4", Qt::Key_4
).toInt();
1764 vjs
.p1KeyBindings
[BUTTON_5
] = settings
.value("p1k_5", Qt::Key_5
).toInt();
1765 vjs
.p1KeyBindings
[BUTTON_6
] = settings
.value("p1k_6", Qt::Key_6
).toInt();
1766 vjs
.p1KeyBindings
[BUTTON_7
] = settings
.value("p1k_7", Qt::Key_7
).toInt();
1767 vjs
.p1KeyBindings
[BUTTON_8
] = settings
.value("p1k_8", Qt::Key_8
).toInt();
1768 vjs
.p1KeyBindings
[BUTTON_9
] = settings
.value("p1k_9", Qt::Key_9
).toInt();
1769 vjs
.p1KeyBindings
[BUTTON_d
] = settings
.value("p1k_pound", Qt::Key_Minus
).toInt();
1770 vjs
.p1KeyBindings
[BUTTON_s
] = settings
.value("p1k_star", Qt::Key_Equal
).toInt();
1772 vjs
.p2KeyBindings
[BUTTON_U
] = settings
.value("p2k_up", Qt::Key_Up
).toInt();
1773 vjs
.p2KeyBindings
[BUTTON_D
] = settings
.value("p2k_down", Qt::Key_Down
).toInt();
1774 vjs
.p2KeyBindings
[BUTTON_L
] = settings
.value("p2k_left", Qt::Key_Left
).toInt();
1775 vjs
.p2KeyBindings
[BUTTON_R
] = settings
.value("p2k_right", Qt::Key_Right
).toInt();
1776 vjs
.p2KeyBindings
[BUTTON_C
] = settings
.value("p2k_c", Qt::Key_Z
).toInt();
1777 vjs
.p2KeyBindings
[BUTTON_B
] = settings
.value("p2k_b", Qt::Key_X
).toInt();
1778 vjs
.p2KeyBindings
[BUTTON_A
] = settings
.value("p2k_a", Qt::Key_C
).toInt();
1779 vjs
.p2KeyBindings
[BUTTON_OPTION
] = settings
.value("p2k_option", Qt::Key_Apostrophe
).toInt();
1780 vjs
.p2KeyBindings
[BUTTON_PAUSE
] = settings
.value("p2k_pause", Qt::Key_Return
).toInt();
1781 vjs
.p2KeyBindings
[BUTTON_0
] = settings
.value("p2k_0", Qt::Key_0
).toInt();
1782 vjs
.p2KeyBindings
[BUTTON_1
] = settings
.value("p2k_1", Qt::Key_1
).toInt();
1783 vjs
.p2KeyBindings
[BUTTON_2
] = settings
.value("p2k_2", Qt::Key_2
).toInt();
1784 vjs
.p2KeyBindings
[BUTTON_3
] = settings
.value("p2k_3", Qt::Key_3
).toInt();
1785 vjs
.p2KeyBindings
[BUTTON_4
] = settings
.value("p2k_4", Qt::Key_4
).toInt();
1786 vjs
.p2KeyBindings
[BUTTON_5
] = settings
.value("p2k_5", Qt::Key_5
).toInt();
1787 vjs
.p2KeyBindings
[BUTTON_6
] = settings
.value("p2k_6", Qt::Key_6
).toInt();
1788 vjs
.p2KeyBindings
[BUTTON_7
] = settings
.value("p2k_7", Qt::Key_7
).toInt();
1789 vjs
.p2KeyBindings
[BUTTON_8
] = settings
.value("p2k_8", Qt::Key_8
).toInt();
1790 vjs
.p2KeyBindings
[BUTTON_9
] = settings
.value("p2k_9", Qt::Key_9
).toInt();
1791 vjs
.p2KeyBindings
[BUTTON_d
] = settings
.value("p2k_pound", Qt::Key_Slash
).toInt();
1792 vjs
.p2KeyBindings
[BUTTON_s
] = settings
.value("p2k_star", Qt::Key_Asterisk
).toInt();
1795 WriteLog("Read setting = Done\n");
1797 ReadProfiles(&settings
);
1802 // Default values will be used in case of no settings can be found
1804 #pragma message("Warning: !!! Need to check the window geometry to see if the positions are legal !!!")
1806 #warning "!!! Need to check the window geometry to see if the positions are legal !!!"
1808 // i.e., someone could drag it to another screen, close it, then disconnect that screen
1809 void MainWin::ReadUISettings(void)
1816 // Point on the emulator settings
1817 QSettings
settings("Underground Software", "Virtual Jaguar");
1818 settings
.beginGroup("ui");
1820 // Emulator main window UI information
1821 mainWinPosition
= settings
.value("pos", QPoint(200, 200)).toPoint();
1822 size
= settings
.value("size", QSize(400, 400)).toSize();
1824 move(mainWinPosition
);
1825 pos
= settings
.value("cartLoadPos", QPoint(200, 200)).toPoint();
1826 filePickWin
->move(pos
);
1828 // Video output information
1829 zoomLevel
= settings
.value("zoom", 2).toInt();
1831 // Alpine debug UI information (also needed by the Debugger)
1832 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
1834 // CPU registers UI information
1835 pos
= settings
.value("cpuBrowseWinPos", QPoint(200, 200)).toPoint();
1836 cpuBrowseWin
->move(pos
);
1837 settings
.value("cpuBrowseWinIsVisible", false).toBool() ? ShowCPUBrowserWin() : void();
1839 // Memory browser UI information
1840 pos
= settings
.value("memBrowseWinPos", QPoint(200, 200)).toPoint();
1841 memBrowseWin
->move(pos
);
1842 settings
.value("memBrowseWinIsVisible", false).toBool() ? ShowMemoryBrowserWin() : void();
1844 // Stack browser UI information
1845 pos
= settings
.value("stackBrowseWinPos", QPoint(200, 200)).toPoint();
1846 stackBrowseWin
->move(pos
);
1847 settings
.value("stackBrowseWinIsVisible", false).toBool() ? ShowStackBrowserWin() : void();
1848 size
= settings
.value("stackBrowseWinSize", QSize(400, 400)).toSize();
1849 stackBrowseWin
->resize(size
);
1851 // Emulator status UI information
1852 pos
= settings
.value("emuStatusWinPos", QPoint(200, 200)).toPoint();
1853 emuStatusWin
->move(pos
);
1854 settings
.value("emuStatusWinIsVisible", false).toBool() ? ShowEmuStatusWin() : void();
1856 // OP (Object Processor) UI information
1857 pos
= settings
.value("opBrowseWinPos", QPoint(200, 200)).toPoint();
1858 opBrowseWin
->move(pos
);
1859 settings
.value("opBrowseWinIsVisible", false).toBool() ? ShowOPBrowserWin() : void();
1860 size
= settings
.value("opBrowseWinSize", QSize(400, 400)).toSize();
1861 opBrowseWin
->resize(size
);
1863 // RISC disassembly UI information
1864 pos
= settings
.value("riscDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1865 riscDasmBrowseWin
->move(pos
);
1866 settings
.value("riscDasmBrowseWinIsVisible", false).toBool() ? ShowRISCDasmBrowserWin() : void();
1868 // M68k disassembly UI information
1869 pos
= settings
.value("m68kDasmBrowseWinPos", QPoint(200, 200)).toPoint();
1870 m68kDasmBrowseWin
->move(pos
);
1871 //settings.value("m68kDasmBrowseWinIsVisible", false).toBool() ? ShowM68KDasmBrowserWin() : void();
1873 #pragma message("Warning: !!! Need to check the M68k disassembly window position crashing !!!")
1875 #warning "!!! Need to check the M68k disassembly window position crashing !!!"
1879 // Debugger UI information
1880 if (vjs
.softTypeDebugger
)
1883 pos
= settings
.value("m68kDasmWinPos", QPoint(200, 200)).toPoint();
1884 m68kDasmWin
->move(pos
);
1885 //settings.value("m68kDasmWinIsVisible", false).toBool() ? m68kDasmWin->show() : m68kDasmWin->hide();
1886 pos
= settings
.value("GPUDasmWinPos", QPoint(200, 200)).toPoint();
1887 GPUDasmWin
->move(pos
);
1888 pos
= settings
.value("DSPDasmWinPos", QPoint(200, 200)).toPoint();
1889 DSPDasmWin
->move(pos
);
1891 // All watch browser UI information
1892 pos
= settings
.value("allWatchBrowseWinPos", QPoint(200, 200)).toPoint();
1893 allWatchBrowseWin
->move(pos
);
1894 settings
.value("allWatchBrowseWinIsVisible", false).toBool() ? ShowAllWatchBrowserWin() : void();
1895 size
= settings
.value("allWatchBrowseWinSize", QSize(400, 400)).toSize();
1896 allWatchBrowseWin
->resize(size
);
1898 // Local browser UI information
1899 pos
= settings
.value("LocalBrowseWinPos", QPoint(200, 200)).toPoint();
1900 LocalBrowseWin
->move(pos
);
1901 settings
.value("LocalBrowseWinIsVisible", false).toBool() ? ShowLocalBrowserWin() : void();
1902 size
= settings
.value("LocalBrowseWinSize", QSize(400, 400)).toSize();
1903 LocalBrowseWin
->resize(size
);
1905 // Heap memory allocation browser UI information
1906 pos
= settings
.value("heapallocatorBrowseWinPos", QPoint(200, 200)).toPoint();
1907 heapallocatorBrowseWin
->move(pos
);
1908 settings
.value("heapallocatorBrowseWinIsVisible", false).toBool() ? ShowHeapAllocatorBrowserWin() : void();
1909 size
= settings
.value("heapallocatorBrowseWinSize", QSize(400, 400)).toSize();
1910 heapallocatorBrowseWin
->resize(size
);
1912 // Exception Vector Table UI Information
1913 pos
= settings
.value("exceptionVectorTableBrowseWinPos", QPoint(200, 200)).toPoint();
1914 exceptionvectortableBrowseWin
->move(pos
);
1915 settings
.value("exceptionVectorTableBrowseWinIsVisible", false).toBool() ? ShowExceptionVectorTableBrowserWin() : void();
1916 size
= settings
.value("exceptionVectorTableBrowseWinSize", QSize(400, 400)).toSize();
1917 exceptionvectortableBrowseWin
->resize(size
);
1919 // Call Stack browser UI information
1920 pos
= settings
.value("CallStackBrowseWinPos", QPoint(200, 200)).toPoint();
1921 CallStackBrowseWin
->move(pos
);
1922 settings
.value("CallStackBrowseWinIsVisible", false).toBool() ? ShowCallStackBrowserWin() : void();
1923 size
= settings
.value("CallStackBrowseWinSize", QSize(400, 400)).toSize();
1924 CallStackBrowseWin
->resize(size
);
1926 // Memories browser UI information
1927 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
1929 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
1930 pos
= settings
.value(mem1Name
, QPoint(200, 200)).toPoint();
1931 mem1BrowseWin
[i
]->move(pos
);
1932 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
1933 settings
.value(mem1Name
, false).toBool() ? ShowMemory1BrowserWin((int)i
) : void();
1934 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
1935 size
= settings
.value(mem1Name
, QSize(400, 400)).toSize();
1936 mem1BrowseWin
[i
]->resize(size
);
1940 settings
.endGroup();
1942 WriteLog("Read UI setting = Done\n");
1946 // Save the settings
1947 void MainWin::WriteSettings(void)
1951 // Point on the emulator settings
1952 QSettings
settings("Underground Software", "Virtual Jaguar");
1953 //settings.setValue("pos", pos());
1954 //settings.setValue("size", size());
1955 //settings.setValue("cartLoadPos", filePickWin->pos());
1957 //settings.setValue("zoom", zoomLevel);
1958 settings
.setValue("showUnknownSoftware", allowUnknownSoftware
);
1959 settings
.setValue("lastEditedProfile", lastEditedProfile
);
1961 settings
.setValue("useJoystick", vjs
.useJoystick
);
1962 settings
.setValue("joyport", vjs
.joyport
);
1963 settings
.setValue("hardwareTypeNTSC", vjs
.hardwareTypeNTSC
);
1964 settings
.setValue("frameSkip", vjs
.frameSkip
);
1965 settings
.setValue("useJaguarBIOS", vjs
.useJaguarBIOS
);
1966 settings
.setValue("GPUEnabled", vjs
.GPUEnabled
);
1967 settings
.setValue("DSPEnabled", vjs
.DSPEnabled
);
1968 settings
.setValue("audioEnabled", vjs
.audioEnabled
);
1969 settings
.setValue("usePipelinedDSP", vjs
.usePipelinedDSP
);
1970 settings
.setValue("fullscreen", vjs
.fullscreen
);
1971 settings
.setValue("useOpenGL", vjs
.useOpenGL
);
1972 settings
.setValue("glFilterType", vjs
.glFilter
);
1973 settings
.setValue("renderType", vjs
.renderType
);
1974 settings
.setValue("biosType", vjs
.biosType
);
1975 settings
.setValue("useFastBlitter", vjs
.useFastBlitter
);
1976 settings
.setValue("JagBootROM", vjs
.jagBootPath
);
1977 settings
.setValue("CDBootROM", vjs
.CDBootPath
);
1978 settings
.setValue("EEPROMs", vjs
.EEPROMPath
);
1979 settings
.setValue("ROMs", vjs
.ROMPath
);
1981 // Write settings from the Alpine mode
1982 settings
.beginGroup("alpine");
1983 settings
.setValue("refresh", vjs
.refresh
);
1984 settings
.setValue("DefaultROM", vjs
.alpineROMPath
);
1985 settings
.setValue("DefaultABS", vjs
.absROMPath
);
1986 settings
.setValue("writeROM", vjs
.allowWritesToROM
);
1987 settings
.endGroup();
1989 // Write settings from the Debugger mode
1990 settings
.beginGroup("debugger");
1991 settings
.setValue("DisplayHWLabels", vjs
.displayHWlabels
);
1992 settings
.setValue("NbrDisasmLines", vjs
.nbrdisasmlines
);
1993 settings
.setValue("DisasmOpcodes", vjs
.disasmopcodes
);
1994 settings
.setValue("displayFullSourceFilename", vjs
.displayFullSourceFilename
);
1995 settings
.setValue("NbrMemory1BrowserWindow", (unsigned int)vjs
.nbrmemory1browserwindow
);
1996 settings
.setValue("DefaultROM", vjs
.debuggerROMPath
);
1997 settings
.endGroup();
1999 // Write settings from the Keybindings
2000 settings
.beginGroup("keybindings");
2001 for (i
= 0; i
< KB_END
; i
++)
2003 settings
.setValue(KeyBindingsTable
[i
].KBNameSetting
, vjs
.KBContent
[i
].KBSettingValue
);
2005 settings
.endGroup();
2008 settings
.setValue("p1k_up", vjs
.p1KeyBindings
[BUTTON_U
]);
2009 settings
.setValue("p1k_down", vjs
.p1KeyBindings
[BUTTON_D
]);
2010 settings
.setValue("p1k_left", vjs
.p1KeyBindings
[BUTTON_L
]);
2011 settings
.setValue("p1k_right", vjs
.p1KeyBindings
[BUTTON_R
]);
2012 settings
.setValue("p1k_c", vjs
.p1KeyBindings
[BUTTON_C
]);
2013 settings
.setValue("p1k_b", vjs
.p1KeyBindings
[BUTTON_B
]);
2014 settings
.setValue("p1k_a", vjs
.p1KeyBindings
[BUTTON_A
]);
2015 settings
.setValue("p1k_option", vjs
.p1KeyBindings
[BUTTON_OPTION
]);
2016 settings
.setValue("p1k_pause", vjs
.p1KeyBindings
[BUTTON_PAUSE
]);
2017 settings
.setValue("p1k_0", vjs
.p1KeyBindings
[BUTTON_0
]);
2018 settings
.setValue("p1k_1", vjs
.p1KeyBindings
[BUTTON_1
]);
2019 settings
.setValue("p1k_2", vjs
.p1KeyBindings
[BUTTON_2
]);
2020 settings
.setValue("p1k_3", vjs
.p1KeyBindings
[BUTTON_3
]);
2021 settings
.setValue("p1k_4", vjs
.p1KeyBindings
[BUTTON_4
]);
2022 settings
.setValue("p1k_5", vjs
.p1KeyBindings
[BUTTON_5
]);
2023 settings
.setValue("p1k_6", vjs
.p1KeyBindings
[BUTTON_6
]);
2024 settings
.setValue("p1k_7", vjs
.p1KeyBindings
[BUTTON_7
]);
2025 settings
.setValue("p1k_8", vjs
.p1KeyBindings
[BUTTON_8
]);
2026 settings
.setValue("p1k_9", vjs
.p1KeyBindings
[BUTTON_9
]);
2027 settings
.setValue("p1k_pound", vjs
.p1KeyBindings
[BUTTON_d
]);
2028 settings
.setValue("p1k_star", vjs
.p1KeyBindings
[BUTTON_s
]);
2030 settings
.setValue("p2k_up", vjs
.p2KeyBindings
[BUTTON_U
]);
2031 settings
.setValue("p2k_down", vjs
.p2KeyBindings
[BUTTON_D
]);
2032 settings
.setValue("p2k_left", vjs
.p2KeyBindings
[BUTTON_L
]);
2033 settings
.setValue("p2k_right", vjs
.p2KeyBindings
[BUTTON_R
]);
2034 settings
.setValue("p2k_c", vjs
.p2KeyBindings
[BUTTON_C
]);
2035 settings
.setValue("p2k_b", vjs
.p2KeyBindings
[BUTTON_B
]);
2036 settings
.setValue("p2k_a", vjs
.p2KeyBindings
[BUTTON_A
]);
2037 settings
.setValue("p2k_option", vjs
.p2KeyBindings
[BUTTON_OPTION
]);
2038 settings
.setValue("p2k_pause", vjs
.p2KeyBindings
[BUTTON_PAUSE
]);
2039 settings
.setValue("p2k_0", vjs
.p2KeyBindings
[BUTTON_0
]);
2040 settings
.setValue("p2k_1", vjs
.p2KeyBindings
[BUTTON_1
]);
2041 settings
.setValue("p2k_2", vjs
.p2KeyBindings
[BUTTON_2
]);
2042 settings
.setValue("p2k_3", vjs
.p2KeyBindings
[BUTTON_3
]);
2043 settings
.setValue("p2k_4", vjs
.p2KeyBindings
[BUTTON_4
]);
2044 settings
.setValue("p2k_5", vjs
.p2KeyBindings
[BUTTON_5
]);
2045 settings
.setValue("p2k_6", vjs
.p2KeyBindings
[BUTTON_6
]);
2046 settings
.setValue("p2k_7", vjs
.p2KeyBindings
[BUTTON_7
]);
2047 settings
.setValue("p2k_8", vjs
.p2KeyBindings
[BUTTON_8
]);
2048 settings
.setValue("p2k_9", vjs
.p2KeyBindings
[BUTTON_9
]);
2049 settings
.setValue("p2k_pound", vjs
.p2KeyBindings
[BUTTON_d
]);
2050 settings
.setValue("p2k_star", vjs
.p2KeyBindings
[BUTTON_s
]);
2053 WriteProfiles(&settings
);
2057 // Save the UI settings
2058 void MainWin::WriteUISettings(void)
2063 // Point on the emulator settings
2064 QSettings
settings("Underground Software", "Virtual Jaguar");
2065 settings
.beginGroup("ui");
2067 // Emulator UI information
2068 settings
.setValue("pos", pos());
2069 settings
.setValue("size", size());
2070 settings
.setValue("cartLoadPos", filePickWin
->pos());
2072 // Video output information
2073 settings
.setValue("zoom", zoomLevel
);
2075 // Alpine debug UI information (also needed by the Debugger)
2076 if (vjs
.hardwareTypeAlpine
|| vjs
.softTypeDebugger
)
2078 settings
.setValue("cpuBrowseWinPos", cpuBrowseWin
->pos());
2079 settings
.setValue("cpuBrowseWinIsVisible", cpuBrowseWin
->isVisible());
2080 settings
.setValue("memBrowseWinPos", memBrowseWin
->pos());
2081 settings
.setValue("memBrowseWinIsVisible", memBrowseWin
->isVisible());
2082 settings
.setValue("stackBrowseWinPos", stackBrowseWin
->pos());
2083 settings
.setValue("stackBrowseWinIsVisible", stackBrowseWin
->isVisible());
2084 settings
.setValue("stackBrowseWinSize", stackBrowseWin
->size());
2085 settings
.setValue("emuStatusWinPos", emuStatusWin
->pos());
2086 settings
.setValue("emuStatusWinIsVisible", emuStatusWin
->isVisible());
2087 settings
.setValue("opBrowseWinPos", opBrowseWin
->pos());
2088 settings
.setValue("opBrowseWinIsVisible", opBrowseWin
->isVisible());
2089 settings
.setValue("opBrowseWinSize", opBrowseWin
->size());
2090 settings
.setValue("riscDasmBrowseWinPos", riscDasmBrowseWin
->pos());
2091 settings
.setValue("riscDasmBrowseWinIsVisible", riscDasmBrowseWin
->isVisible());
2092 settings
.setValue("m68kDasmBrowseWinPos", m68kDasmBrowseWin
->pos());
2093 settings
.setValue("m68kDasmBrowseWinIsVisible", m68kDasmBrowseWin
->isVisible());
2096 // Debugger UI information
2097 if (vjs
.softTypeDebugger
)
2100 settings
.setValue("m68kDasmWinPos", m68kDasmWin
->pos());
2101 //settings.setValue("m68kDasmWinIsVisible", m68kDasmWin->isVisible());
2102 settings
.setValue("GPUDasmWinPos", GPUDasmWin
->pos());
2103 settings
.setValue("DSPDasmWinPos", DSPDasmWin
->pos());
2105 settings
.setValue("allWatchBrowseWinPos", allWatchBrowseWin
->pos());
2106 settings
.setValue("allWatchBrowseWinIsVisible", allWatchBrowseWin
->isVisible());
2107 settings
.setValue("allWatchBrowseWinSize", allWatchBrowseWin
->size());
2108 settings
.setValue("LocalBrowseWinPos", LocalBrowseWin
->pos());
2109 settings
.setValue("LocalBrowseWinIsVisible", LocalBrowseWin
->isVisible());
2110 settings
.setValue("LocalBrowseWinSize", LocalBrowseWin
->size());
2111 settings
.setValue("heapallocatorBrowseWinPos", heapallocatorBrowseWin
->pos());
2112 settings
.setValue("heapallocatorBrowseWinIsVisible", heapallocatorBrowseWin
->isVisible());
2113 settings
.setValue("heapallocatorBrowseWinSize", heapallocatorBrowseWin
->size());
2114 settings
.setValue("exceptionVectorTableBrowseWinPos", exceptionvectortableBrowseWin
->pos());
2115 settings
.setValue("exceptionVectorTableBrowseWinIsVisible", exceptionvectortableBrowseWin
->isVisible());
2116 settings
.setValue("exceptionVectorTableBrowseWinSize", exceptionvectortableBrowseWin
->size());
2117 settings
.setValue("CallStackBrowseWinPos", CallStackBrowseWin
->pos());
2118 settings
.setValue("CallStackBrowseWinIsVisible", CallStackBrowseWin
->isVisible());
2119 settings
.setValue("CallStackBrowseWinSize", CallStackBrowseWin
->size());
2120 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2122 sprintf(mem1Name
, "mem1BrowseWinPos[%i]", (unsigned int)i
);
2123 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->pos());
2124 sprintf(mem1Name
, "mem1BrowseWinIsVisible[%i]", (unsigned int)i
);
2125 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->isVisible());
2126 sprintf(mem1Name
, "mem1BrowseWinSize[%i]", (unsigned int)i
);
2127 settings
.setValue(mem1Name
, mem1BrowseWin
[i
]->size());
2131 settings
.endGroup();
2135 // Refresh alpine debug windows
2136 void MainWin::RefreshAlpineWindows(void)
2138 cpuBrowseWin
->RefreshContents();
2139 memBrowseWin
->RefreshContents();
2140 stackBrowseWin
->RefreshContents();
2141 emuStatusWin
->RefreshContents();
2142 opBrowseWin
->RefreshContents();
2143 riscDasmBrowseWin
->RefreshContents();
2144 m68kDasmBrowseWin
->RefreshContents();
2148 // Reset soft debugger windows
2149 void MainWin::DebuggerResetWindows(void)
2151 if (vjs
.softTypeDebugger
)
2153 allWatchBrowseWin
->Reset();
2154 heapallocatorBrowseWin
->Reset();
2156 //ResetAlpineWindows();
2161 // Refresh soft debugger & alpine debug windows
2162 void MainWin::DebuggerRefreshWindows(void)
2166 if (vjs
.softTypeDebugger
)
2168 m68kDasmWin
->RefreshContents();
2169 GPUDasmWin
->RefreshContents();
2170 DSPDasmWin
->RefreshContents();
2171 allWatchBrowseWin
->RefreshContents();
2172 LocalBrowseWin
->RefreshContents();
2173 CallStackBrowseWin
->RefreshContents();
2174 heapallocatorBrowseWin
->RefreshContents();
2175 for (i
= 0; i
< vjs
.nbrmemory1browserwindow
; i
++)
2177 mem1BrowseWin
[i
]->RefreshContents(i
);
2180 RefreshAlpineWindows();