Added scanline start/end entry boxes for NTSC and PAL/Dendy to Qt Video config window.

This commit is contained in:
mjbudd77 2021-02-23 21:04:50 -05:00
parent c544c137f5
commit e3f2970dcd
8 changed files with 338 additions and 26 deletions

View File

@ -27,6 +27,7 @@
#include "Qt/config.h"
#include "Qt/fceuWrapper.h"
#include "Qt/ConsoleWindow.h"
#include "Qt/ConsoleUtilities.h"
#include "Qt/ConsoleVideoConf.h"
#include "Qt/nes_shm.h"
@ -34,17 +35,39 @@
ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
: QDialog( parent )
{
QVBoxLayout *main_vbox;
QHBoxLayout *hbox1;
QVBoxLayout *main_vbox, *vbox1, *vbox2;
QHBoxLayout *main_hbox, *hbox1;
QLabel *lbl;
QPushButton *button;
QStyle *style;
QGroupBox *gbox;
QGridLayout *grid;
fceuDecIntValidtor *validator;
QFont font;
int opt, fontCharWidth;
char stmp[128];
font.setFamily("Courier New");
font.setStyle( QFont::StyleNormal );
font.setStyleHint( QFont::Monospace );
QFontMetrics fm(font);
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
fontCharWidth = fm.horizontalAdvance(QLatin1Char('2'));
#else
fontCharWidth = fm.width(QLatin1Char('2'));
#endif
style = this->style();
setWindowTitle( tr("Video Config") );
main_vbox = new QVBoxLayout();
main_hbox = new QHBoxLayout();
vbox1 = new QVBoxLayout();
main_vbox->addLayout( main_hbox );
main_hbox->addLayout( vbox1 );
// Video Driver Select
lbl = new QLabel( tr("Driver:") );
@ -59,7 +82,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
hbox1->addWidget( lbl );
hbox1->addWidget( driverSelect );
main_vbox->addLayout( hbox1 );
vbox1->addLayout( hbox1 );
// Video Driver Select
lbl = new QLabel( tr("Scaler:") );
@ -82,7 +105,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
hbox1->addWidget( lbl );
hbox1->addWidget( scalerSelect );
main_vbox->addLayout( hbox1 );
vbox1->addLayout( hbox1 );
// Enable OpenGL Linear Filter Checkbox
gl_LF_chkBox = new QCheckBox( tr("Enable OpenGL Linear Filter") );
@ -91,7 +114,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
connect(gl_LF_chkBox , SIGNAL(stateChanged(int)), this, SLOT(openGL_linearFilterChanged(int)) );
main_vbox->addWidget( gl_LF_chkBox );
vbox1->addWidget( gl_LF_chkBox );
// Region Select
lbl = new QLabel( tr("Region:") );
@ -115,7 +138,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
hbox1->addWidget( lbl );
hbox1->addWidget( regionSelect );
main_vbox->addLayout( hbox1 );
vbox1->addLayout( hbox1 );
// Enable New PPU Checkbox
new_PPU_ena = new QCheckBox( tr("Enable New PPU") );
@ -127,7 +150,7 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
sprtLimCbx = new QCheckBox( tr("Disable Sprite Limit") );
// Clip Sides Checkbox
clipSidesCbx = new QCheckBox( tr("Clip Sides") );
clipSidesCbx = new QCheckBox( tr("Clip Left/Right Sides (8 px on each)") );
// Show FPS Checkbox
showFPS_cbx = new QCheckBox( tr("Show FPS") );
@ -166,13 +189,13 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
connect(sqrPixCbx , SIGNAL(stateChanged(int)), this, SLOT(sqrPixChanged(int)) );
connect(autoScaleCbx, SIGNAL(stateChanged(int)), this, SLOT(autoScaleChanged(int)) );
main_vbox->addWidget( new_PPU_ena );
main_vbox->addWidget( frmskipcbx );
main_vbox->addWidget( sprtLimCbx );
main_vbox->addWidget( clipSidesCbx);
main_vbox->addWidget( showFPS_cbx );
main_vbox->addWidget( autoScaleCbx);
main_vbox->addWidget( sqrPixCbx );
vbox1->addWidget( new_PPU_ena );
vbox1->addWidget( frmskipcbx );
vbox1->addWidget( sprtLimCbx );
//vbox1->addWidget( clipSidesCbx);
vbox1->addWidget( showFPS_cbx );
vbox1->addWidget( autoScaleCbx);
vbox1->addWidget( sqrPixCbx );
xScaleBox = new QDoubleSpinBox(this);
yScaleBox = new QDoubleSpinBox(this);
@ -210,12 +233,12 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
hbox1 = new QHBoxLayout();
hbox1->addWidget( xScaleLabel );
hbox1->addWidget( xScaleBox );
main_vbox->addLayout( hbox1 );
vbox1->addLayout( hbox1 );
hbox1 = new QHBoxLayout();
hbox1->addWidget( yScaleLabel );
hbox1->addWidget( yScaleBox );
main_vbox->addLayout( hbox1 );
vbox1->addLayout( hbox1 );
if ( sqrPixCbx->isChecked() )
{
@ -237,6 +260,83 @@ ConsoleVideoConfDialog_t::ConsoleVideoConfDialog_t(QWidget *parent)
main_vbox->addLayout( hbox1 );
gbox = new QGroupBox( tr("Drawing Area") );
vbox2 = new QVBoxLayout();
grid = new QGridLayout();
main_hbox->addLayout( vbox2 );
vbox2->addWidget( gbox, 1 );
vbox2->addStretch( 5 );
gbox->setLayout(grid);
ntsc_start = new QLineEdit();
ntsc_end = new QLineEdit();
pal_start = new QLineEdit();
pal_end = new QLineEdit();
validator = new fceuDecIntValidtor( 0, 239, this );
ntsc_start->setFont( font );
ntsc_start->setMaxLength( 3 );
ntsc_start->setValidator( validator );
ntsc_start->setAlignment(Qt::AlignCenter);
ntsc_start->setMaximumWidth( 8 * fontCharWidth );
ntsc_start->setCursorPosition(0);
validator = new fceuDecIntValidtor( 0, 239, this );
ntsc_end->setFont( font );
ntsc_end->setMaxLength( 3 );
ntsc_end->setValidator( validator );
ntsc_end->setAlignment(Qt::AlignCenter);
ntsc_end->setMaximumWidth( 8 * fontCharWidth );
ntsc_end->setCursorPosition(0);
validator = new fceuDecIntValidtor( 0, 239, this );
pal_start->setFont( font );
pal_start->setMaxLength( 3 );
pal_start->setValidator( validator );
pal_start->setAlignment(Qt::AlignCenter);
pal_start->setMaximumWidth( 8 * fontCharWidth );
pal_start->setCursorPosition(0);
validator = new fceuDecIntValidtor( 0, 239, this );
pal_end->setFont( font );
pal_end->setMaxLength( 3 );
pal_end->setValidator( validator );
pal_end->setAlignment(Qt::AlignCenter);
pal_end->setMaximumWidth( 8 * fontCharWidth );
pal_end->setCursorPosition(0);
g_config->getOption("SDL.ScanLineStartNTSC", &opt);
sprintf( stmp, "%i", opt );
ntsc_start->setText( tr(stmp) );
g_config->getOption("SDL.ScanLineEndNTSC", &opt);
sprintf( stmp, "%i", opt );
ntsc_end->setText( tr(stmp) );
g_config->getOption("SDL.ScanLineStartPAL", &opt);
sprintf( stmp, "%i", opt );
pal_start->setText( tr(stmp) );
g_config->getOption("SDL.ScanLineEndPAL", &opt);
sprintf( stmp, "%i", opt );
pal_end->setText( tr(stmp) );
connect( ntsc_start, SIGNAL(textEdited(const QString &)), this, SLOT(ntscStartScanLineChanged(const QString &)));
connect( ntsc_end , SIGNAL(textEdited(const QString &)), this, SLOT(ntscEndScanLineChanged(const QString &)));
connect( pal_start , SIGNAL(textEdited(const QString &)), this, SLOT(palStartScanLineChanged(const QString &)));
connect( pal_end , SIGNAL(textEdited(const QString &)), this, SLOT(palEndScanLineChanged(const QString &)));
grid->addWidget( new QLabel( tr("NTSC") ) , 0, 1, Qt::AlignLeft);
grid->addWidget( new QLabel( tr("PAL/Dendy") ) , 0, 2, Qt::AlignLeft);
grid->addWidget( new QLabel( tr("First Line:") ), 1, 0, Qt::AlignLeft);
grid->addWidget( new QLabel( tr("Last Line:") ), 2, 0, Qt::AlignLeft);
grid->addWidget( ntsc_start, 1, 1, Qt::AlignLeft);
grid->addWidget( pal_start , 1, 2, Qt::AlignLeft);
grid->addWidget( ntsc_end , 2, 1, Qt::AlignLeft);
grid->addWidget( pal_end , 2, 2, Qt::AlignLeft);
grid->addWidget( clipSidesCbx, 3, 0, 1, 3);
setLayout( main_vbox );
}
@ -270,6 +370,68 @@ void ConsoleVideoConfDialog_t::resetVideo(void)
fceuWrapperUnLock();
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::ntscStartScanLineChanged(const QString &txt)
{
int opt;
std::string s;
s = txt.toStdString();
if ( s.size() > 0 )
{
opt = strtoul( s.c_str(), NULL, 10 );
g_config->setOption("SDL.ScanLineStartNTSC", opt);
printf("NTSC Start: %i \n", opt );
}
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::ntscEndScanLineChanged(const QString &txt)
{
int opt;
std::string s;
s = txt.toStdString();
if ( s.size() > 0 )
{
opt = strtoul( s.c_str(), NULL, 10 );
g_config->setOption("SDL.ScanLineEndNTSC", opt);
}
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::palStartScanLineChanged(const QString &txt)
{
int opt;
std::string s;
s = txt.toStdString();
if ( s.size() > 0 )
{
opt = strtoul( s.c_str(), NULL, 10 );
g_config->setOption("SDL.ScanLineStartPAL", opt);
}
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::palEndScanLineChanged(const QString &txt)
{
int opt;
std::string s;
s = txt.toStdString();
if ( s.size() > 0 )
{
opt = strtoul( s.c_str(), NULL, 10 );
g_config->setOption("SDL.ScanLineEndPAL", opt);
}
}
//----------------------------------------------------
void ConsoleVideoConfDialog_t::setCheckBoxFromProperty( QCheckBox *cbx, const char *property )
{
int pval;

View File

@ -11,6 +11,7 @@
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QSlider>
#include <QFrame>
@ -43,6 +44,10 @@ class ConsoleVideoConfDialog_t : public QDialog
QDoubleSpinBox *yScaleBox;
QLabel *xScaleLabel;
QLabel *yScaleLabel;
QLineEdit *ntsc_start;
QLineEdit *ntsc_end;
QLineEdit *pal_start;
QLineEdit *pal_end;
void setCheckBoxFromProperty( QCheckBox *cbx, const char *property );
void setComboBoxFromProperty( QComboBox *cbx, const char *property );
@ -52,7 +57,7 @@ class ConsoleVideoConfDialog_t : public QDialog
QSize calcNewScreenSize(void);
public slots:
void closeWindow(void);
void closeWindow(void);
private slots:
void openGL_linearFilterChanged( int value );
@ -67,6 +72,10 @@ class ConsoleVideoConfDialog_t : public QDialog
void driverChanged(int index);
void scalerChanged(int index);
void applyChanges( void );
void ntscStartScanLineChanged(const QString &);
void ntscEndScanLineChanged(const QString &);
void palStartScanLineChanged(const QString &);
void palEndScanLineChanged(const QString &);
};

View File

@ -160,6 +160,29 @@ consoleWin_t::consoleWin_t(QWidget *parent)
#endif
}
g_config->getOption( "SDL.WinSizeX", &xWinSize );
g_config->getOption( "SDL.WinSizeY", &yWinSize );
if ( (xWinSize >= 256) && (yWinSize >= 256) )
{
this->resize( xWinSize, yWinSize );
}
else
{
QSize reqSize = calcRequiredSize();
this->resize( reqSize );
}
g_config->getOption( "SDL.Fullscreen", &setFullScreen );
g_config->setOption( "SDL.Fullscreen", 0 ); // Reset full screen config parameter to false so it is never saved this way
if ( setFullScreen )
{
this->showFullScreen();
}
recentRomMenuReset = false;
}
@ -236,6 +259,54 @@ consoleWin_t::~consoleWin_t(void)
}
QSize consoleWin_t::calcRequiredSize(void)
{
QSize out( GL_NES_WIDTH, GL_NES_HEIGHT );
QSize w, v;
double xscale, yscale;
int texture_width = nes_shm->video.ncol;
int texture_height = nes_shm->video.nrow;
int l=0, r=texture_width;
int t=0, b=texture_height;
int dw=0, dh=0, rw, rh;
bool sqrPixChkd = true;
CalcVideoDimensions();
w = size();
if ( viewport_GL )
{
v = viewport_GL->size();
sqrPixChkd = viewport_GL->getSqrPixelOpt();
xscale = viewport_GL->getScaleX();
yscale = viewport_GL->getScaleY();
}
else if ( viewport_SDL )
{
v = viewport_SDL->size();
sqrPixChkd = viewport_SDL->getSqrPixelOpt();
xscale = viewport_SDL->getScaleX();
yscale = viewport_SDL->getScaleY();
}
dw = 0;
dh = menubar->height();
if ( sqrPixChkd )
{
yscale = xscale * (double)nes_shm->video.xyRatio;
}
rw=(int)((r-l)*xscale);
rh=(int)((b-t)*yscale);
out.setWidth( rw + dw );
out.setHeight( rh + dh );
return out;
}
void consoleWin_t::setCyclePeriodms( int ms )
{
// If timer is already running, it will be restarted.

View File

@ -116,6 +116,8 @@ class consoleWin_t : public QMainWindow
void addRecentRom( const char *rom );
QSize calcRequiredSize(void);
protected:
consoleMenuBar *menubar;

View File

@ -241,8 +241,10 @@ InitConfig()
config->addOption("ntsccolor", "SDL.NTSCpalette", 0);
// scanline settings
config->addOption("slstart", "SDL.ScanLineStart", 0);
config->addOption("slend", "SDL.ScanLineEnd", 239);
config->addOption("SDL.ScanLineStartNTSC", 0+8);
config->addOption("SDL.ScanLineEndNTSC", 239-8);
config->addOption("SDL.ScanLineStartPAL", 0);
config->addOption("SDL.ScanLineEndPAL", 239);
// video controls
config->addOption('f', "fullscreen", "SDL.Fullscreen", 0);
@ -253,8 +255,8 @@ InitConfig()
config->addOption('y', "yres", "SDL.YResolution", 0);
config->addOption("SDL.LastXRes", 0);
config->addOption("SDL.LastYRes", 0);
config->addOption("SDL.WinSizeX", 512);
config->addOption("SDL.WinSizeY", 512);
config->addOption("SDL.WinSizeX", 0);
config->addOption("SDL.WinSizeY", 0);
config->addOption("doublebuf", "SDL.DoubleBuffering", 1);
config->addOption("autoscale", "SDL.AutoScale", 1);
config->addOption("keepratio", "SDL.KeepRatio", 1);
@ -540,7 +542,8 @@ InitConfig()
void
UpdateEMUCore(Config *config)
{
int ntsccol, ntsctint, ntschue, flag, region, start, end;
int ntsccol, ntsctint, ntschue, flag, region;
int startNTSC, endNTSC, startPAL, endPAL;
std::string cpalette;
config->getOption("SDL.NTSCpalette", &ntsccol);
@ -565,8 +568,10 @@ UpdateEMUCore(Config *config)
config->getOption("SDL.DisableSpriteLimit", &flag);
FCEUI_DisableSpriteLimitation(flag ? 1 : 0);
config->getOption("SDL.ScanLineStart", &start);
config->getOption("SDL.ScanLineEnd", &end);
config->getOption("SDL.ScanLineStartNTSC", &startNTSC);
config->getOption("SDL.ScanLineEndNTSC", &endNTSC);
config->getOption("SDL.ScanLineStartPAL", &startPAL);
config->getOption("SDL.ScanLineEndPAL", &endPAL);
#if DOING_SCANLINE_CHECKS
for(int i = 0; i < 2; x++) {
@ -575,6 +580,6 @@ UpdateEMUCore(Config *config)
}
#endif
FCEUI_SetRenderedLines(start + 8, end - 8, start, end);
FCEUI_SetRenderedLines(startNTSC, endNTSC, startPAL, endPAL);
}

View File

@ -24,6 +24,7 @@ uint32 *GetJSOr(void);
int InitVideo(FCEUGI *gi);
int KillVideo(void);
void CalcVideoDimensions(void);
void BlitScreen(uint8 *XBuf);
void LockConsole(void);
void UnlockConsole(void);

View File

@ -34,7 +34,7 @@ nes_shm_t *open_nes_shm(void)
memset( vaddr, 0, sizeof(struct nes_shm_t));
vaddr->video.ncol = 256;
vaddr->video.ncol = 240;
vaddr->video.nrow = 256;
vaddr->video.pitch = 256 * 4;
vaddr->video.scale = 1;

View File

@ -140,9 +140,65 @@ void FCEUD_VideoChanged()
PAL = 0; // NTSC and Dendy
}
void CalcVideoDimensions(void)
{
g_config->getOption("SDL.SpecialFilter", &s_sponge);
FCEUI_GetCurrentVidSystem(&s_srendline, &s_erendline);
s_tlines = s_erendline - s_srendline + 1;
nes_shm->video.preScaler = s_sponge;
switch ( s_sponge )
{
case 0: // None
nes_shm->video.scale = 1;
break;
case 1: // hq2x
case 2: // Scale2x
case 3: // NTSC 2x
case 6: // Prescale2x
nes_shm->video.scale = 2;
break;
case 4: // hq3x
case 5: // Scale3x
case 7: // Prescale3x
nes_shm->video.scale = 3;
break;
case 8: // Prescale4x
nes_shm->video.scale = 4;
break;
case 9: // PAL
nes_shm->video.scale = 3;
break;
}
int iScale = nes_shm->video.scale;
if ( s_sponge == 3 )
{
nes_shm->video.ncol = iScale*301;
}
else
{
nes_shm->video.ncol = iScale*NWIDTH;
}
if ( s_sponge == 9 )
{
nes_shm->video.nrow = 1*s_tlines;
nes_shm->video.xyRatio = 3;
}
else
{
nes_shm->video.nrow = iScale*s_tlines;
nes_shm->video.xyRatio = 1;
}
nes_shm->video.pitch = nes_shm->video.ncol * 4;
}
int InitVideo(FCEUGI *gi)
{
int doublebuf, xstretch, ystretch, xres, yres, show_fps;
int startNTSC, endNTSC, startPAL, endPAL;
FCEUI_printf("Initializing video...");
@ -159,8 +215,14 @@ int InitVideo(FCEUGI *gi)
g_config->getOption("SDL.ShowFPS", &show_fps);
//g_config->getOption("SDL.XScale", &s_exs);
//g_config->getOption("SDL.YScale", &s_eys);
g_config->getOption("SDL.ScanLineStartNTSC", &startNTSC);
g_config->getOption("SDL.ScanLineEndNTSC", &endNTSC);
g_config->getOption("SDL.ScanLineStartPAL", &startPAL);
g_config->getOption("SDL.ScanLineEndPAL", &endPAL);
uint32_t rmask, gmask, bmask;
FCEUI_SetRenderedLines(startNTSC, endNTSC, startPAL, endPAL);
s_exs = 1.0;
s_eys = 1.0;
xres = gui_draw_area_width;