+
+void MainWin::ShowAboutWin(void)
+{
+ aboutWin->show();
+}
+
+
+void MainWin::ShowHelpWin(void)
+{
+ helpWin->show();
+}
+
+
+void MainWin::InsertCart(void)
+{
+ // Check to see if we did autorun, 'cause we didn't load anything in that
+ // case
+ if (!scannedSoftwareFolder)
+ {
+ filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
+ scannedSoftwareFolder = true;
+ }
+
+ // If the emulator is running, we pause it here and unpause it later
+ // if we dismiss the file selector without choosing anything
+ if (running && powerButtonOn)
+ {
+ ToggleRunState();
+ pauseForFileSelector = true;
+ }
+
+ filePickWin->show();
+}
+
+
+void MainWin::Unpause(void)
+{
+ // Here we unpause the emulator if it was paused when we went into the file selector
+ if (pauseForFileSelector)
+ {
+ pauseForFileSelector = false;
+
+ // Some nutter might have unpaused while in the file selector, so check for that
+ if (!running)
+ ToggleRunState();
+ }
+}
+
+
+void MainWin::LoadSoftware(QString file)
+{
+ running = false; // Prevent bad things(TM) from happening...
+ pauseForFileSelector = false; // Reset the file selector pause flag
+
+ char * biosPointer = jaguarBootROM;
+
+ if (vjs.hardwareTypeAlpine)
+ biosPointer = jaguarDevBootROM2;
+
+ memcpy(jagMemSpace + 0xE00000, biosPointer, 0x20000);
+
+ powerAct->setDisabled(false);
+ powerAct->setChecked(true);
+ powerButtonOn = false;
+ TogglePowerState();
+ // We have to load our software *after* the Jaguar RESET
+ cartridgeLoaded = JaguarLoadFile(file.toAscii().data());
+ SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack...
+
+ // This is icky because we've already done it
+// it gets worse :-P
+if (!vjs.useJaguarBIOS)
+ SET32(jaguarMainRAM, 4, jaguarRunAddress);
+
+ m68k_pulse_reset();
+
+ if (!vjs.hardwareTypeAlpine && !loadAndGo)
+ {
+ QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1")
+ .arg(filePickWin->GetSelectedPrettyName());
+ setWindowTitle(newTitle);
+ }
+}
+
+
+void MainWin::ToggleCDUsage(void)
+{
+ CDActive = !CDActive;
+
+ // Set up the Jaguar CD for execution, otherwise, clear memory
+ if (CDActive)
+ memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000);
+ else
+ memset(jagMemSpace + 0x800000, 0xFF, 0x40000);
+}
+
+
+void MainWin::FrameAdvance(void)
+{
+//printf("Frame Advance...\n");
+ // Execute 1 frame, then exit (only useful in Pause mode)
+ JaguarExecuteNew();
+ videoWidget->updateGL();
+ // Need to execute 1 frames' worth of DSP thread as well :-/
+#warning "!!! Need to execute the DSP thread for 1 frame too !!!"
+}
+
+
+void MainWin::SetFullScreen(bool state/*= true*/)
+{
+ if (state)
+ {
+ mainWinPosition = pos();
+ menuBar()->hide();
+ statusBar()->hide();
+ toolbar->hide();
+
+ if (debugbar)
+ debugbar->hide();
+
+ showFullScreen();
+ // This is needed because the fullscreen may happen on a different
+ // screen than screen 0:
+ int screenNum = QApplication::desktop()->screenNumber(videoWidget);
+// QRect r = QApplication::desktop()->availableGeometry(screenNum);
+ QRect r = QApplication::desktop()->screenGeometry(screenNum);
+ double targetWidth = (double)VIRTUAL_SCREEN_WIDTH,
+ targetHeight = (double)(vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL);
+ double aspectRatio = targetWidth / targetHeight;
+ // NOTE: Really should check here to see which dimension constrains the
+ // other. Right now, we assume that height is the constraint.
+ int newWidth = (int)(aspectRatio * (double)r.height());
+ videoWidget->offset = (r.width() - newWidth) / 2;
+ videoWidget->fullscreen = true;
+ videoWidget->outputWidth = newWidth;
+ videoWidget->setFixedSize(r.width(), r.height());
+ showFullScreen();
+ }
+ else
+ {
+ // Reset the video widget to windowed mode
+ videoWidget->offset = 0;
+ videoWidget->fullscreen = false;
+ menuBar()->show();
+ statusBar()->show();
+ toolbar->show();
+
+ if (debugbar)
+ debugbar->show();
+
+ showNormal();
+ ResizeMainWindow();
+ move(mainWinPosition);
+ }
+}
+
+
+void MainWin::ToggleFullScreen(void)
+{
+ fullScreen = !fullScreen;
+ SetFullScreen(fullScreen);
+}
+
+
+void MainWin::ShowMemoryBrowserWin(void)
+{
+ memBrowseWin->show();
+ memBrowseWin->RefreshContents();
+}
+
+
+void MainWin::ShowCPUBrowserWin(void)
+{
+ cpuBrowseWin->show();
+ cpuBrowseWin->RefreshContents();
+}
+
+
+void MainWin::ShowOPBrowserWin(void)
+{
+ opBrowseWin->show();
+ opBrowseWin->RefreshContents();
+}
+
+
+void MainWin::ShowM68KDasmBrowserWin(void)
+{
+ m68kDasmBrowseWin->show();
+ m68kDasmBrowseWin->RefreshContents();
+}
+
+
+void MainWin::ShowRISCDasmBrowserWin(void)
+{
+ riscDasmBrowseWin->show();
+ riscDasmBrowseWin->RefreshContents();
+}
+
+
+void MainWin::ResizeMainWindow(void)
+{
+ videoWidget->setFixedSize(zoomLevel * VIRTUAL_SCREEN_WIDTH,
+ zoomLevel * (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL));
+
+ // Show the test pattern if user requested plzDontKillMyComputer mode
+ if (!powerButtonOn && plzDontKillMyComputer)
+ {
+ for(uint32_t y=0; y<videoWidget->rasterHeight; y++)
+ {
+ memcpy(videoWidget->buffer + (y * videoWidget->textureWidth), testPattern + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t));
+ }
+ }
+
+ show();
+
+ for(int i=0; i<2; i++)
+ {
+ resize(0, 0);
+ usleep(2000);
+ QApplication::processEvents();
+ }
+}
+
+
+#warning "!!! Need to check the window geometry to see if the positions are legal !!!"
+// i.e., someone could drag it to another screen, close it, then disconnect that screen