From 74a48e92d6e40c5462495b59fcdae0f135374400 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Mon, 13 Dec 2021 20:48:30 -0500 Subject: [PATCH] Added a vertical sync test pattern to Qt GUI. --- src/drivers/Qt/ConsoleVideoConf.cpp | 23 ++++++++++++++++- src/drivers/Qt/ConsoleVideoConf.h | 2 ++ src/drivers/Qt/ConsoleWindow.cpp | 4 +-- src/drivers/Qt/nes_shm.h | 1 + src/drivers/Qt/sdl-video.cpp | 40 ++++++++++++++++++++++------- 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/drivers/Qt/ConsoleVideoConf.cpp b/src/drivers/Qt/ConsoleVideoConf.cpp index 54803663..659f637b 100644 --- a/src/drivers/Qt/ConsoleVideoConf.cpp +++ b/src/drivers/Qt/ConsoleVideoConf.cpp @@ -42,7 +42,7 @@ extern int rerecord_display; ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) : QDialog( parent ) { - QVBoxLayout *main_vbox, *vbox1, *vbox2, *vbox3, *vbox4, *vbox; + QVBoxLayout *main_vbox, *vbox1, *vbox2, *vbox3, *vbox4, *vbox5, *vbox; QHBoxLayout *main_hbox, *hbox1, *hbox; QLabel *lbl; QPushButton *button; @@ -205,6 +205,16 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) setComboBoxFromProperty( inputDisplaySel , "SDL.InputDisplay"); + // Input Display Select + videoTest = new QComboBox(); + + videoTest->addItem( tr("None") , 0 ); + videoTest->addItem( tr("Vertical Sync"), 1 ); + + videoTest->setCurrentIndex( nes_shm->video.test ); + + connect(videoTest, SIGNAL(currentIndexChanged(int)), this, SLOT(testPatternChanged(int)) ); + setCheckBoxFromProperty( autoRegion , "SDL.AutoDetectPAL"); setCheckBoxFromProperty( new_PPU_ena , "SDL.NewPPU"); setCheckBoxFromProperty( frmskipcbx , "SDL.Frameskip"); @@ -349,6 +359,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) gbox = new QGroupBox( tr("Overlay Options") ); vbox3 = new QVBoxLayout(); vbox4 = new QVBoxLayout(); + vbox5 = new QVBoxLayout(); vbox = new QVBoxLayout(); vbox3->addWidget( gbox, 1 ); @@ -366,6 +377,11 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) vbox->addWidget( gbox ); vbox4->addWidget( inputDisplaySel ); + gbox = new QGroupBox( tr("Test Pattern:") ); + gbox->setLayout( vbox5 ); + vbox->addWidget( gbox ); + vbox5->addWidget( videoTest ); + gbox = new QGroupBox( tr("Drawing Area") ); vbox2 = new QVBoxLayout(); grid = new QGridLayout(); @@ -952,6 +968,11 @@ void ConsoleVideoConfDialog_t::inputDisplayChanged(int index) g_config->save (); } //---------------------------------------------------- +void ConsoleVideoConfDialog_t::testPatternChanged(int index) +{ + nes_shm->video.test = videoTest->itemData(index).toInt(); +} +//---------------------------------------------------- void ConsoleVideoConfDialog_t::aspectChanged(int index) { int aspectID; diff --git a/src/drivers/Qt/ConsoleVideoConf.h b/src/drivers/Qt/ConsoleVideoConf.h index 1b869cf0..cabaad26 100644 --- a/src/drivers/Qt/ConsoleVideoConf.h +++ b/src/drivers/Qt/ConsoleVideoConf.h @@ -37,6 +37,7 @@ class ConsoleVideoConfDialog_t : public QDialog QComboBox *cursorSelect; QComboBox *aspectSelect; QComboBox *inputDisplaySel; + QComboBox *videoTest; QCheckBox *autoRegion; QCheckBox *vsync_ena; QCheckBox *gl_LF_chkBox; @@ -95,6 +96,7 @@ class ConsoleVideoConfDialog_t : public QDialog void regionChanged(int index); void driverChanged(int index); void scalerChanged(int index); + void testPatternChanged(int index); void cursorShapeChanged(int index); void cursorVisChanged(int value); void drawInputAidsChanged(int value); diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 50671376..274a93c0 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -4253,16 +4253,16 @@ void consoleWin_t::transferVideoBuffer(void) { if ( nes_shm->blitUpdated ) { - nes_shm->blitUpdated = 0; - if ( viewport_SDL ) { viewport_SDL->transfer2LocalBuffer(); + nes_shm->blitUpdated = 0; viewport_SDL->render(); } else if ( viewport_GL ) { viewport_GL->transfer2LocalBuffer(); + nes_shm->blitUpdated = 0; viewport_GL->update(); } } diff --git a/src/drivers/Qt/nes_shm.h b/src/drivers/Qt/nes_shm.h index 96e8118c..ce83a131 100644 --- a/src/drivers/Qt/nes_shm.h +++ b/src/drivers/Qt/nes_shm.h @@ -29,6 +29,7 @@ struct nes_shm_t int yscale; int xyRatio; int preScaler; + int test; } video; char runEmulator; diff --git a/src/drivers/Qt/sdl-video.cpp b/src/drivers/Qt/sdl-video.cpp index 6496ed45..bc08c1de 100644 --- a/src/drivers/Qt/sdl-video.cpp +++ b/src/drivers/Qt/sdl-video.cpp @@ -393,20 +393,34 @@ void LockConsole(){} ///Currently unimplemented. void UnlockConsole(){} -static int testPattern = 0; - -static void WriteTestPattern(void) +static void vsync_test(void) { - int i, j, k; + int i, j, k, l; + int cycleLen, halfCycleLen; + static int ofs = 0; + + cycleLen = nes_shm->video.ncol / 4; + + halfCycleLen = cycleLen / 2; k=0; - for (i=0; ivideo.nrow; j++) { - for (j=0; jvideo.ncol; i++) { - nes_shm->pixbuf[k] = 0xffffffff; k++; + l = ((i+ofs) % cycleLen); + + if ( l < halfCycleLen ) + { + nes_shm->pixbuf[k] = 0xffffffff; k++; + } + else + { + nes_shm->pixbuf[k] = 0x00000000; k++; + } } } + ofs = (ofs + 1) % nes_shm->video.ncol; } static void @@ -455,9 +469,17 @@ doBlitScreen(uint8_t *XBuf, uint8_t *dest) if ( dest == NULL ) return; - if ( testPattern ) + if ( nes_shm->video.test ) { - WriteTestPattern(); + switch ( nes_shm->video.test ) + { + case 1: + vsync_test(); + break; + default: + // Unknown Test Pattern + break; + } } else {