Added video output display in a specific window
authorJean-Paul Mari <djipi.mari@gmail.com>
Sun, 18 Apr 2021 12:32:31 +0000 (08:32 -0400)
committerJean-Paul Mari <djipi.mari@gmail.com>
Sun, 18 Apr 2021 12:32:31 +0000 (08:32 -0400)
Win-VS2017/virtualjaguar.vcxproj
Win-VS2017/virtualjaguar.vcxproj.filters
docs/vj_HistoryNotes.txt
src/debugger/VideoWin.cpp
src/debugger/VideoWin.h
src/gui/mainwin.cpp
src/gui/mainwin.h

index 88f263a..0ea0c9b 100644 (file)
@@ -82,7 +82,7 @@
       <MinimalRebuild>false</MinimalRebuild>\r
     </ClCompile>\r
     <Link>\r
-      <AdditionalDependencies>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)</AdditionalDependencies>\r
+      <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)</AdditionalDependencies>\r
       <AdditionalLibraryDirectories>$(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)</AdditionalLibraryDirectories>\r
       <AdditionalOptions>"/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions)</AdditionalOptions>\r
       <DataExecutionPrevention>true</DataExecutionPrevention>\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>\r
     </ClCompile>\r
     <ClCompile Include="GeneratedFiles\Debug\moc_VideoWin.cpp">\r
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>\r
     </ClCompile>\r
     <ClCompile Include="..\src\debugger\DasmWin.cpp" />\r
     <ClCompile Include="..\src\debugger\DBGManager.cpp" />\r
     <ClCompile Include="GeneratedFiles\Release\moc_stackbrowser.cpp">\r
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>\r
     </ClCompile>\r
+    <ClCompile Include="GeneratedFiles\Release\moc_VideoWin.cpp">\r
+      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>\r
+    </ClCompile>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <CustomBuild Include="..\src\debugger\BreakpointsWin.h">\r
index c3f4fcd..8ccbb7f 100644 (file)
     </ClCompile>\r
     <ClCompile Include="GeneratedFiles\Debug\moc_VideoWin.cpp">\r
       <Filter>Generated Files</Filter>\r
+    </ClCompile>\r
+       <ClCompile Include="GeneratedFiles\Release\moc_VideoWin.cpp">\r
+      <Filter>Generated Files</Filter>\r
     </ClCompile>\r
     <ClCompile Include="GeneratedFiles\Debug\moc_stackbrowser.cpp">\r
       <Filter>Generated Files</Filter>\r
index 94efdb5..cbbfebe 100644 (file)
@@ -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)
 -----------------------------
index b1120f6..e2b4def 100644 (file)
@@ -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;
 }
index 0b0ae1b..9818eff 100644 (file)
@@ -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__
index 0202537..7fb2f3d 100644 (file)
@@ -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\r
 // JPM  Marc./2020  Added the step over for source level tracing\r
 //  RG   Jan./2021  Linux build fixes\r
-// JPM   Apr./2021  Handle number of M68K cycles used in tracing mode\r
+// JPM   Apr./2021  Handle number of M68K cycles used in tracing mode, added video output display in a window\r
 //\r
 \r
 // FIXED:\r
@@ -94,7 +94,7 @@
 #include "m68000/m68kinterface.h"\r
 \r
 #include "debugger/DBGManager.h"\r
-//#include "debugger/VideoWin.h"\r
+#include "debugger/VideoWin.h"\r
 //#include "debugger/DasmWin.h"\r
 #include "debugger/SourcesWin.h"\r
 #include "debugger/m68kDasmWin.h"\r
@@ -206,7 +206,8 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
        // Windows debugger mode features\r
        if (vjs.softTypeDebugger)\r
        {\r
-               //VideoOutputWin = new VideoOutputWindow(this);\r
+               VideoOutputWin = new VideoOutputWindow(this);\r
+               //VideoOutputWin->show();\r
                //VideoOutputWin->setCentralWidget()\r
                //DasmWin = new DasmWindow();\r
                //DasmWin = new DasmWindow(this);\r
@@ -442,9 +443,9 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                saveDumpAsAct->setDisabled(false);\r
                connect(saveDumpAsAct, SIGNAL(triggered()), this, SLOT(ShowSaveDumpAsWin()));\r
 \r
-               //VideoOutputAct = new QAction(tr("Output Video"), this);\r
-               //VideoOutputAct->setStatusTip(tr("Shows the output video window"));\r
-               //connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));\r
+               VideoOutputAct = new QAction(tr("Output Video"), this);\r
+               VideoOutputAct->setStatusTip(tr("Shows the output video window"));\r
+               connect(VideoOutputAct, SIGNAL(triggered()), this, SLOT(ShowVideoOutputWin()));\r
 \r
                //DasmAct = new QAction(tr("Disassembly"), this);\r
                //DasmAct->setStatusTip(tr("Shows the disassembly window"));\r
@@ -581,11 +582,9 @@ MainWin::MainWin(bool autoRun): running(true), powerButtonOn(false),
                        debugWindowExceptionMenu = debugWindowsMenu->addMenu(tr("&Exception"));\r
                        debugWindowExceptionMenu->addAction(exceptionVectorTableBrowseAct);\r
                        debugWindowsMenu->addSeparator();\r
-#if 0\r
                        debugWindowOutputMenu = debugWindowsMenu->addMenu(tr("&Output"));\r
                        debugWindowOutputMenu->addAction(VideoOutputAct);\r
                        debugWindowsMenu->addSeparator();\r
-#endif\r
                        debugWindowsWatchMenu = debugWindowsMenu->addMenu(tr("&Watch"));\r
                        debugWindowsWatchMenu->addAction(allWatchBrowseAct);\r
                        debugWindowsMenu->addAction(LocalBrowseAct);\r
@@ -1189,6 +1188,7 @@ static uint32_t refresh = 0;
 \r
        //if (!vjs.softTypeDebugger)\r
                videoWidget->updateGL();\r
+               //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL;\r
 \r
        // FPS handling\r
        // Approach: We use a ring buffer to store times (in ms) over a given\r
@@ -1332,6 +1332,7 @@ void MainWin::ToggleRunState(void)
                        }\r
 \r
                        videoWidget->updateGL();\r
+                       //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL;\r
 \r
                        cpuBrowseWin->HoldBPM();\r
                        cpuBrowseWin->HandleBPMContinue();\r
@@ -1671,6 +1672,7 @@ void MainWin::FrameAdvance(void)
        JaguarExecuteNew();\r
        //if (!vjs.softTypeDebugger)\r
                videoWidget->updateGL();\r
+               //vjs.softTypeDebugger ? VideoOutputWin->RefreshContents(videoWidget) : NULL;\r
        ToggleRunState();\r
        // Need to execute 1 frames' worth of DSP thread as well :-/\r
 \r
@@ -1863,17 +1865,17 @@ void    MainWin::ShowDasmWin(void)
 \r
 \r
 // \r
-#if 0\r
 void MainWin::ShowVideoOutputWin(void)\r
 {\r
        //VideoOutputWindowCentrale = mainWindowCentrale->addSubWindow(videoWidget);\r
        //VideoOutputWindowCentrale->setWindowTitle(QString(tr("Video output")));\r
        //VideoOutputWindowCentrale->show();\r
        //memBrowseWin->show();\r
-       //VideoOutputWin->show();\r
+       VideoOutputWin->show();\r
+       VideoOutputWin->SetupVideo(videoWidget);\r
+       //VideoOutputWin->adjustSize();\r
        //VideoOutputWin->RefreshContents(videoWidget);\r
 }\r
-#endif\r
 \r
 \r
 // Resize video window based on zoom factor\r
@@ -2179,6 +2181,13 @@ void MainWin::ReadUISettings(void)
                size = settings.value("SaveDumpAsWinSize", QSize(400, 400)).toSize();\r
                SaveDumpAsWin->resize(size);\r
 \r
+               // save output video UI information\r
+               pos = settings.value("VideoOutputWinPos", QPoint(200, 200)).toPoint();\r
+               VideoOutputWin->move(pos);\r
+               settings.value("VideoOutputWinIsVisible", false).toBool() ? ShowVideoOutputWin() : void();\r
+               size = settings.value("VideoOutputWinSize", QSize(400, 400)).toSize();\r
+               VideoOutputWin->resize(size);\r
+\r
                // Breakpoints UI information\r
                pos = settings.value("BreakpointsWinPos", QPoint(200, 200)).toPoint();\r
                BreakpointsWin->move(pos);\r
@@ -2411,6 +2420,9 @@ void MainWin::WriteUISettings(void)
                settings.setValue("SaveDumpAsWinPos", SaveDumpAsWin->pos());\r
                settings.setValue("SaveDumpAsWinIsVisible", SaveDumpAsWin->isVisible());\r
                settings.setValue("SaveDumpAsWinSize", SaveDumpAsWin->size());\r
+               settings.setValue("VideoOutputWinPos", VideoOutputWin->pos());\r
+               settings.setValue("VideoOutputWinIsVisible", VideoOutputWin->isVisible());\r
+               settings.setValue("VideoOutputWinSize", VideoOutputWin->size());\r
 \r
                for (i = 0; i < vjs.nbrmemory1browserwindow; i++)\r
                {\r
@@ -2505,6 +2517,7 @@ void MainWin::DebuggerRefreshWindows(void)
 {\r
        if (vjs.softTypeDebugger)\r
        {\r
+               //VideoOutputWin->RefreshContents(videoWidget);\r
                FilesrcListWin->RefreshContents();\r
                SourcesWin->RefreshContents();\r
                m68kDasmWin->RefreshContents();\r
index 84a3b25..515f9e0 100644 (file)
@@ -22,7 +22,7 @@ class GLWidget;
 class AboutWindow;\r
 class HelpWindow;\r
 class FilePickerWindow;\r
-//class VideoOutputWindow;\r
+class VideoOutputWindow;\r
 //class DasmWindow;\r
 class EmuStatusWindow;\r
 \r
@@ -117,10 +117,8 @@ class MainWin: public QMainWindow
                void DisableAllBreakpoints(void);\r
                void ShowSaveDumpAsWin(void);\r
                void SelectdasmtabWidget(const int);\r
-#if 0\r
                void ShowVideoOutputWin(void);\r
-               void ShowDasmWin(void);\r
-#endif\r
+               //void ShowDasmWin(void);\r
                void ShowCartFilesListWin(void);\r
                // Alpine\r
                void ShowMemoryBrowserWin(void);\r
@@ -156,7 +154,7 @@ class MainWin: public QMainWindow
                M68KDasmBrowserWindow *m68kDasmBrowseWin;\r
                RISCDasmBrowserWindow *riscDasmBrowseWin;\r
                HWRegsBrowserWindow *hwRegsBrowseWin;\r
-               //VideoOutputWindow *VideoOutputWin;\r
+               VideoOutputWindow *VideoOutputWin;\r
                AllWatchBrowserWindow *allWatchBrowseWin;\r
                LocalBrowserWindow *LocalBrowseWin;\r
                CallStackBrowserWindow *CallStackBrowseWin;\r
@@ -248,7 +246,7 @@ class MainWin: public QMainWindow
                QAction *traceStepOverAct;\r
                QAction *traceStepIntoAct;\r
                QAction *restartAct;\r
-               //QAction *VideoOutputAct;\r
+               QAction *VideoOutputAct;\r
                QAction *heapallocatorBrowseAct;\r
                QAction *allWatchBrowseAct;\r
                QAction *LocalBrowseAct;\r