Added a vertical sync test pattern to Qt GUI.

This commit is contained in:
mjbudd77 2021-12-13 20:48:30 -05:00
parent c72eac9970
commit 74a48e92d6
5 changed files with 58 additions and 12 deletions

View File

@ -42,7 +42,7 @@ extern int rerecord_display;
ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent) ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
: QDialog( 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; QHBoxLayout *main_hbox, *hbox1, *hbox;
QLabel *lbl; QLabel *lbl;
QPushButton *button; QPushButton *button;
@ -205,6 +205,16 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
setComboBoxFromProperty( inputDisplaySel , "SDL.InputDisplay"); 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( autoRegion , "SDL.AutoDetectPAL");
setCheckBoxFromProperty( new_PPU_ena , "SDL.NewPPU"); setCheckBoxFromProperty( new_PPU_ena , "SDL.NewPPU");
setCheckBoxFromProperty( frmskipcbx , "SDL.Frameskip"); setCheckBoxFromProperty( frmskipcbx , "SDL.Frameskip");
@ -349,6 +359,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
gbox = new QGroupBox( tr("Overlay Options") ); gbox = new QGroupBox( tr("Overlay Options") );
vbox3 = new QVBoxLayout(); vbox3 = new QVBoxLayout();
vbox4 = new QVBoxLayout(); vbox4 = new QVBoxLayout();
vbox5 = new QVBoxLayout();
vbox = new QVBoxLayout(); vbox = new QVBoxLayout();
vbox3->addWidget( gbox, 1 ); vbox3->addWidget( gbox, 1 );
@ -366,6 +377,11 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
vbox->addWidget( gbox ); vbox->addWidget( gbox );
vbox4->addWidget( inputDisplaySel ); vbox4->addWidget( inputDisplaySel );
gbox = new QGroupBox( tr("Test Pattern:") );
gbox->setLayout( vbox5 );
vbox->addWidget( gbox );
vbox5->addWidget( videoTest );
gbox = new QGroupBox( tr("Drawing Area") ); gbox = new QGroupBox( tr("Drawing Area") );
vbox2 = new QVBoxLayout(); vbox2 = new QVBoxLayout();
grid = new QGridLayout(); grid = new QGridLayout();
@ -952,6 +968,11 @@ void ConsoleVideoConfDialog_t::inputDisplayChanged(int index)
g_config->save (); g_config->save ();
} }
//---------------------------------------------------- //----------------------------------------------------
void ConsoleVideoConfDialog_t::testPatternChanged(int index)
{
nes_shm->video.test = videoTest->itemData(index).toInt();
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::aspectChanged(int index) void ConsoleVideoConfDialog_t::aspectChanged(int index)
{ {
int aspectID; int aspectID;

View File

@ -37,6 +37,7 @@ class ConsoleVideoConfDialog_t : public QDialog
QComboBox *cursorSelect; QComboBox *cursorSelect;
QComboBox *aspectSelect; QComboBox *aspectSelect;
QComboBox *inputDisplaySel; QComboBox *inputDisplaySel;
QComboBox *videoTest;
QCheckBox *autoRegion; QCheckBox *autoRegion;
QCheckBox *vsync_ena; QCheckBox *vsync_ena;
QCheckBox *gl_LF_chkBox; QCheckBox *gl_LF_chkBox;
@ -95,6 +96,7 @@ class ConsoleVideoConfDialog_t : public QDialog
void regionChanged(int index); void regionChanged(int index);
void driverChanged(int index); void driverChanged(int index);
void scalerChanged(int index); void scalerChanged(int index);
void testPatternChanged(int index);
void cursorShapeChanged(int index); void cursorShapeChanged(int index);
void cursorVisChanged(int value); void cursorVisChanged(int value);
void drawInputAidsChanged(int value); void drawInputAidsChanged(int value);

View File

@ -4253,16 +4253,16 @@ void consoleWin_t::transferVideoBuffer(void)
{ {
if ( nes_shm->blitUpdated ) if ( nes_shm->blitUpdated )
{ {
nes_shm->blitUpdated = 0;
if ( viewport_SDL ) if ( viewport_SDL )
{ {
viewport_SDL->transfer2LocalBuffer(); viewport_SDL->transfer2LocalBuffer();
nes_shm->blitUpdated = 0;
viewport_SDL->render(); viewport_SDL->render();
} }
else if ( viewport_GL ) else if ( viewport_GL )
{ {
viewport_GL->transfer2LocalBuffer(); viewport_GL->transfer2LocalBuffer();
nes_shm->blitUpdated = 0;
viewport_GL->update(); viewport_GL->update();
} }
} }

View File

@ -29,6 +29,7 @@ struct nes_shm_t
int yscale; int yscale;
int xyRatio; int xyRatio;
int preScaler; int preScaler;
int test;
} video; } video;
char runEmulator; char runEmulator;

View File

@ -393,20 +393,34 @@ void LockConsole(){}
///Currently unimplemented. ///Currently unimplemented.
void UnlockConsole(){} void UnlockConsole(){}
static int testPattern = 0; static void vsync_test(void)
static void WriteTestPattern(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; k=0;
for (i=0; i<GL_NES_WIDTH; i++) for (j=0; j<nes_shm->video.nrow; j++)
{ {
for (j=0; j<GL_NES_HEIGHT; j++) for (i=0; i<nes_shm->video.ncol; i++)
{
l = ((i+ofs) % cycleLen);
if ( l < halfCycleLen )
{ {
nes_shm->pixbuf[k] = 0xffffffff; k++; nes_shm->pixbuf[k] = 0xffffffff; k++;
} }
else
{
nes_shm->pixbuf[k] = 0x00000000; k++;
} }
}
}
ofs = (ofs + 1) % nes_shm->video.ncol;
} }
static void static void
@ -455,9 +469,17 @@ doBlitScreen(uint8_t *XBuf, uint8_t *dest)
if ( dest == NULL ) return; 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 else
{ {