From 96aa54e4962989f3dd8ace23c2658a35c4e3cace Mon Sep 17 00:00:00 2001 From: Jean-Paul Mari Date: Sun, 18 Apr 2021 08:32:31 -0400 Subject: [PATCH] Added video output display in a specific window --- Win-VS2017/virtualjaguar.vcxproj | 7 +- Win-VS2017/virtualjaguar.vcxproj.filters | 3 + docs/vj_HistoryNotes.txt | 1 + src/debugger/VideoWin.cpp | 152 ++++++++++++++++++++--- src/debugger/VideoWin.h | 16 ++- src/gui/mainwin.cpp | 35 ++++-- src/gui/mainwin.h | 10 +- 7 files changed, 182 insertions(+), 42 deletions(-) diff --git a/Win-VS2017/virtualjaguar.vcxproj b/Win-VS2017/virtualjaguar.vcxproj index 88f263a..0ea0c9b 100644 --- a/Win-VS2017/virtualjaguar.vcxproj +++ b/Win-VS2017/virtualjaguar.vcxproj @@ -82,7 +82,7 @@ false - qtmain.lib;Qt5OpenGL.lib;shell32.lib;jaguarcore.lib;zlib-1.2.11_vs2017_x64.lib;m68000.lib;gdi32.lib;user32.lib;SDL-1.2.15_vs2017_x64.lib;libelf-0.8.13_vs2017_x64.lib;legacy_stdio_definitions.lib;OpenGL32.lib;libdwarf_x64.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;opengl32.lib;glu32.lib;Ws2_32.lib;imm32.lib;winmm.lib;Advapi32.lib;dxguid.lib;%(AdditionalDependencies) + Qt5PlatformCompositorSupport.lib;qtmain.lib;Qt5OpenGL.lib;shell32.lib;jaguarcore.lib;zlib-1.2.11_vs2017_x64.lib;m68000.lib;gdi32.lib;user32.lib;SDL-1.2.15_vs2017_x64.lib;libelf-0.8.13_vs2017_x64.lib;legacy_stdio_definitions.lib;OpenGL32.lib;libdwarf_x64.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Widgets.lib;opengl32.lib;glu32.lib;Ws2_32.lib;imm32.lib;winmm.lib;Advapi32.lib;dxguid.lib;%(AdditionalDependencies) $(QTDIR)\lib;$(QTDIR)\plugins\platforms;obj;..\src\m68000\obj;C:\SDK\zlib\zlib-1.2.11\lib;C:\SDK\SDL\SDL-1.2.15\lib\x64\static;C:\SDK\Elf\libelf-0.8.13\lib;m68000\x64\Release;jaguarcore\x64\Release;C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib\x64;C:\SDK\DWARF\libdwarf-20210305-VS2017\lib;%(AdditionalLibraryDirectories) "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) true @@ -298,7 +298,7 @@ true - false + true @@ -458,6 +458,9 @@ true + + true + diff --git a/Win-VS2017/virtualjaguar.vcxproj.filters b/Win-VS2017/virtualjaguar.vcxproj.filters index c3f4fcd..8ccbb7f 100644 --- a/Win-VS2017/virtualjaguar.vcxproj.filters +++ b/Win-VS2017/virtualjaguar.vcxproj.filters @@ -204,6 +204,9 @@ Generated Files + + + Generated Files Generated Files diff --git a/docs/vj_HistoryNotes.txt b/docs/vj_HistoryNotes.txt index 94efdb5..cbbfebe 100644 --- a/docs/vj_HistoryNotes.txt +++ b/docs/vj_HistoryNotes.txt @@ -38,6 +38,7 @@ Release 5 (TBA) 24) Improve the DWARF source line number reporting 25) Added a #line in the call stack window 26) Add a search feature in the all watches window +27) Added video output display in a specific window Release 4a (15th August 2019) ----------------------------- diff --git a/src/debugger/VideoWin.cpp b/src/debugger/VideoWin.cpp index b1120f6..e2b4def 100644 --- a/src/debugger/VideoWin.cpp +++ b/src/debugger/VideoWin.cpp @@ -1,5 +1,5 @@ // -// VideoWin.cpp: Windows video display +// VideoWin.cpp: Video output window // // by Jean-Paul Mari // @@ -8,16 +8,25 @@ // WHO WHEN WHAT // --- ---------- ------------------------------------------------------------ // JPM 06/23/2016 Created this file +// JPM April/2021 Added video output display in the window #include "VideoWin.h" +#include "tom.h" +#include "settings.h" //#include "mainwin.h" // -VideoOutputWindow::VideoOutputWindow(QWidget * parent/*= 0*/) : QWidget(parent), -layout(new QHBoxLayout), text(new QLabel) +VideoOutputWindow::VideoOutputWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog), +layout(new QVBoxLayout), +hbox1(new QHBoxLayout) +//gl(new GLWidget) +//layout(0), +//hbox1(0) +//statusbar(new QStatusBar), +//text(new QTextBrowser) { - setWindowTitle(tr("Video windows")); + setWindowTitle(tr("Output Video")); //setCentralWidget(videoWidget); // QFont fixedFont("Lucida Console", 8, QFont::Normal); @@ -25,35 +34,144 @@ layout(new QHBoxLayout), text(new QLabel) // fixedFont.setStyleHint(QFont::TypeWriter); // text->setFont(fixedFont); // setLayout(layout); +#if 0 + QHBoxLayout * hbox1 = new QHBoxLayout; + hbox1->addWidget(gl); + layout->addLayout(hbox1); -// layout->addWidget(text); + gl->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL)); +#endif + //layout->addWidget(statusbar); + //statusbar->setStyleSheet("background-color: lightgreen; font: bold"); + //layout->addWidget(text); + //layout->addWidget(gl); - QWidget* myWidget = new QWidget; - myWidget->setStyleSheet("QWidget{ background: red; }"); + //QWidget* myWidget = new QWidget; + //myWidget->setStyleSheet("QWidget{ background: red; }"); - GLWidget *glWidget = new GLWidget; + //GLWidget *glWidget = new GLWidget; //QHBoxLayout *mainLayout = new QHBoxLayout; - layout->addWidget(myWidget); - layout->setContentsMargins(100, 100, 100, 100); - setLayout(layout); + //layout->addWidget(myWidget); + //layout->setContentsMargins(100, 100, 100, 100); + //setLayout(layout); + + //hbox1->addWidget(gl); + //layout->addLayout(hbox1); + //setLayout(layout); +} + + +// +void VideoOutputWindow::SetupVideo(GLWidget *Lt) +{ + if (isVisible()) + { + //layout = new QVBoxLayout; + //hbox1 = new QHBoxLayout; + // QHBoxLayout * hbox1 = new QHBoxLayout; + //Lt->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL)); + //QHBoxLayout * hbox1 = new QHBoxLayout; + hbox1->addWidget(Lt); + //hbox1->replaceWidget(gl, Lt); + layout->addLayout(hbox1); + setLayout(layout); + //layout->addLayout(hbox1); + //setLayout(layout); + //layout->addLayout(hbox1); + //setLayout(layout); + //show(); + //resize(100, 100); + //adjustSize(); + glViewport(0, 0, (VIRTUAL_SCREEN_WIDTH * 2), (vjs.hardwareTypeNTSC ? (VIRTUAL_SCREEN_HEIGHT_NTSC * 2) : (VIRTUAL_SCREEN_HEIGHT_PAL * 2))); + //adjustSize(); + //resize(minimumWidth(), minimumHeight()); + } } // Refresh / Display the window contents void VideoOutputWindow::RefreshContents(GLWidget *Lt) { - layout->addWidget(Lt); - setLayout(layout); -// QString memDump; +#if 0 + if (isVisible()) + { + for (uint32_t i = 0; i < (uint32_t)(Lt->textureWidth * Lt->rasterHeight); i++) + { + uint32_t pixel = Lt->buffer[i]; + uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF; + pixel = ((r + g + b) / 3) & 0x00FF; + gl->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8); + } + + gl->updateGL(); + //adjustSize(); + } +#endif +#if 0 + if (isVisible()) + { + + QHBoxLayout * hbox1 = new QHBoxLayout; + hbox1->addWidget(Lt); + layout->addLayout(hbox1); + setLayout(layout); + + //gl->setFixedSize(VIRTUAL_SCREEN_WIDTH, (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL)); -// memDump += QString("Test"); +#if 0 + for (uint32_t y = 0; y < Lt->rasterHeight; y++) + { + if (vjs.hardwareTypeNTSC) + { + memcpy(gl->buffer + (y * gl->textureWidth), Lt + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t)); + } + else + { + memcpy(gl->buffer + (y * gl->textureWidth), Lt + (y * VIRTUAL_SCREEN_WIDTH), VIRTUAL_SCREEN_WIDTH * sizeof(uint32_t)); + } + } +#endif +#if 0 + for (uint32_t i = 0; i < (uint32_t)(Lt->textureWidth * Lt->rasterHeight); i++) + { + uint32_t pixel = Lt->buffer[i]; + uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF; + pixel = ((r + g + b) / 3) & 0x00FF; + gl->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8); + } +#else + //gl->updateGL(); -// text->clear(); -// text->setText(memDump); + //layout->addWidget(Lt); + //setLayout(layout); + // QString memDump; + + // memDump += QString("Test"); + + // text->clear(); + // text->setText(memDump); + + //adjustSize(); +#endif + } +#endif +} + + +// +void VideoOutputWindow::keyPressEvent(QKeyEvent * e) +{ + if (e->key() == Qt::Key_Escape) + { + hide(); + } } // VideoOutputWindow::~VideoOutputWindow() { + //delete gl; + delete hbox1; + delete layout; } diff --git a/src/debugger/VideoWin.h b/src/debugger/VideoWin.h index 0b0ae1b..9818eff 100644 --- a/src/debugger/VideoWin.h +++ b/src/debugger/VideoWin.h @@ -1,8 +1,8 @@ // -// VideoWin.h: Credits where credits are due ;-) +// VideoWin.h: Video output +// +// by Jean-Paul Mari // -// based on the work from James Hammons -// (C) 2010 Underground Software // #ifndef __VIDEOWIN_H__ @@ -22,13 +22,17 @@ class VideoOutputWindow : public QWidget public slots: // void DefineAllKeys(void); void RefreshContents(GLWidget *Lt); + void SetupVideo(GLWidget *Lt); protected: - //void keyPressEvent(QKeyEvent *); + void keyPressEvent(QKeyEvent *); private: - QHBoxLayout *layout; - QLabel * text; + QVBoxLayout *layout; + QHBoxLayout *hbox1; + //QTextBrowser * text; + //QStatusBar *statusbar; + GLWidget *gl; }; #endif // __VIDEOWIN_H__ diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 0202537..7fb2f3d 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -28,7 +28,7 @@ // JPM Aug./2019 Update texts descriptions, set cartridge view menu for debugger mode only, added a HW registers browser and source level tracing // JPM Marc./2020 Added the step over for source level tracing // RG Jan./2021 Linux build fixes -// JPM Apr./2021 Handle number of M68K cycles used in tracing mode +// JPM Apr./2021 Handle number of M68K cycles used in tracing mode, added video output display in a window // // FIXED: @@ -94,7 +94,7 @@ #include "m68000/m68kinterface.h" #include "debugger/DBGManager.h" -//#include "debugger/VideoWin.h" +#include "debugger/VideoWin.h" //#include "debugger/DasmWin.h" #include "debugger/SourcesWin.h" #include "debugger/m68kDasmWin.h" @@ -206,7 +206,8 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), // Windows debugger mode features if (vjs.softTypeDebugger) { - //VideoOutputWin = new VideoOutputWindow(this); + VideoOutputWin = new VideoOutputWindow(this); + //VideoOutputWin->show(); //VideoOutputWin->setCentralWidget() //DasmWin = new DasmWindow(); //DasmWin = new DasmWindow(this); @@ -442,9 +443,9 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), saveDumpAsAct->setDisabled(false); connect(saveDumpAsAct, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin())); - //VideoOutputAct = new QAction(tr("Output Video"), this); - //VideoOutputAct->setStatusTip(tr("Shows the output video window")); - //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin())); + VideoOutputAct = new QAction(tr("Output Video"), this); + VideoOutputAct->setStatusTip(tr("Shows the output video window")); + connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin())); //DasmAct = new QAction(tr("Disassembly"), this); //DasmAct->setStatusTip(tr("Shows the disassembly window")); @@ -581,11 +582,9 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false), debugWindowExceptionMenu = debugWindowsMenu->addMenu(tr("&Exception")); debugWindowExceptionMenu->addAction(exceptionVectorTableBrowseAct); debugWindowsMenu->addSeparator(); -#if 0 debugWindowOutputMenu = debugWindowsMenu->addMenu(tr("&Output")); debugWindowOutputMenu->addAction(VideoOutputAct); debugWindowsMenu->addSeparator(); -#endif debugWindowsWatchMenu = debugWindowsMenu->addMenu(tr("&Watch")); debugWindowsWatchMenu->addAction(allWatchBrowseAct); debugWindowsMenu->addAction(LocalBrowseAct); @@ -1189,6 +1188,7 @@ static uint32_t refresh = 0; //if (!vjs.softTypeDebugger) videoWidget->updateGL(); + //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL; // FPS handling // Approach: We use a ring buffer to store times (in ms) over a given @@ -1332,6 +1332,7 @@ void MainWin::ToggleRunState(void) } videoWidget->updateGL(); + //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL; cpuBrowseWin->HoldBPM(); cpuBrowseWin->HandleBPMContinue(); @@ -1671,6 +1672,7 @@ void MainWin::FrameAdvance(void) JaguarExecuteNew(); //if (!vjs.softTypeDebugger) videoWidget->updateGL(); + //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL; ToggleRunState(); // Need to execute 1 frames' worth of DSP thread as well :-/ @@ -1863,17 +1865,17 @@ void MainWin::ShowDasmWin(void) // -#if 0 void MainWin::ShowVideoOutputWin(void) { //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget); //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output"))); //VideoOutputWindowCentrale->show(); //memBrowseWin->show(); - //VideoOutputWin->show(); + VideoOutputWin->show(); + VideoOutputWin->SetupVideo(videoWidget); + //VideoOutputWin->adjustSize(); //VideoOutputWin->RefreshContents(videoWidget); } -#endif // Resize video window based on zoom factor @@ -2179,6 +2181,13 @@ void MainWin::ReadUISettings(void) size = settings.value("SaveDumpAsWinSize", QSize(400, 400)).toSize(); SaveDumpAsWin->resize(size); + // save output video UI information + pos = settings.value("VideoOutputWinPos", QPoint(200, 200)).toPoint(); + VideoOutputWin->move(pos); + settings.value("VideoOutputWinIsVisible", false).toBool() ? ShowVideoOutputWin() : void(); + size = settings.value("VideoOutputWinSize", QSize(400, 400)).toSize(); + VideoOutputWin->resize(size); + // Breakpoints UI information pos = settings.value("BreakpointsWinPos", QPoint(200, 200)).toPoint(); BreakpointsWin->move(pos); @@ -2411,6 +2420,9 @@ void MainWin::WriteUISettings(void) settings.setValue("SaveDumpAsWinPos", SaveDumpAsWin->pos()); settings.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin->isVisible()); settings.setValue("SaveDumpAsWinSize", SaveDumpAsWin->size()); + settings.setValue("VideoOutputWinPos", VideoOutputWin->pos()); + settings.setValue("VideoOutputWinIsVisible", VideoOutputWin->isVisible()); + settings.setValue("VideoOutputWinSize", VideoOutputWin->size()); for (i = 0; i < vjs.nbrmemory1browserwindow; i++) { @@ -2505,6 +2517,7 @@ void MainWin::DebuggerRefreshWindows(void) { if (vjs.softTypeDebugger) { + //VideoOutputWin->RefreshContents(videoWidget); FilesrcListWin->RefreshContents(); SourcesWin->RefreshContents(); m68kDasmWin->RefreshContents(); diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index 84a3b25..515f9e0 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -22,7 +22,7 @@ class GLWidget; class AboutWindow; class HelpWindow; class FilePickerWindow; -//class VideoOutputWindow; +class VideoOutputWindow; //class DasmWindow; class EmuStatusWindow; @@ -117,10 +117,8 @@ class MainWin: public QMainWindow void DisableAllBreakpoints(void); void ShowSaveDumpAsWin(void); void SelectdasmtabWidget(const int); -#if 0 void ShowVideoOutputWin(void); - void ShowDasmWin(void); -#endif + //void ShowDasmWin(void); void ShowCartFilesListWin(void); // Alpine void ShowMemoryBrowserWin(void); @@ -156,7 +154,7 @@ class MainWin: public QMainWindow M68KDasmBrowserWindow *m68kDasmBrowseWin; RISCDasmBrowserWindow *riscDasmBrowseWin; HWRegsBrowserWindow *hwRegsBrowseWin; - //VideoOutputWindow *VideoOutputWin; + VideoOutputWindow *VideoOutputWin; AllWatchBrowserWindow *allWatchBrowseWin; LocalBrowserWindow *LocalBrowseWin; CallStackBrowserWindow *CallStackBrowseWin; @@ -248,7 +246,7 @@ class MainWin: public QMainWindow QAction *traceStepOverAct; QAction *traceStepIntoAct; QAction *restartAct; - //QAction *VideoOutputAct; + QAction *VideoOutputAct; QAction *heapallocatorBrowseAct; QAction *allWatchBrowseAct; QAction *LocalBrowseAct; -- 2.20.1