Merge pull request #134 from mjbudd77/master
Qt SDL Gui Palette Config Window Updates
This commit is contained in:
commit
d7dac74d9a
3
INSTALL
3
INSTALL
|
@ -4,5 +4,6 @@ Users of Microsoft Visual Studio can use the solution files within the vc direct
|
||||||
is not installed, go to "Tools" > "Get Tools and Features". Select "Individual Components" and then install "C++ Windows XP Support for VS 2017 (v141) tools".
|
is not installed, go to "Tools" > "Get Tools and Features". Select "Individual Components" and then install "C++ Windows XP Support for VS 2017 (v141) tools".
|
||||||
These solution files will compile FCEUX and some included libraries for full functionality.
|
These solution files will compile FCEUX and some included libraries for full functionality.
|
||||||
|
|
||||||
CMake has been depreciated in favor of scons. However, if you wish to use it you can find the old cmake build files in the attic.
|
The SDL port build tool of choice has come full circle back to Cmake. The cmake build tool will compile the new Qt version of the SDL GUI.
|
||||||
|
The scons build tool will build the older GTK based GUI which currently only builds on Linux.
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,7 @@ void FCEUI_SetRenderedLines(int ntscf, int ntscl, int palf, int pall);
|
||||||
//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory.
|
//Sets the base directory(save states, snapshots, etc. are saved in directories below this directory.
|
||||||
void FCEUI_SetBaseDirectory(std::string const & dir);
|
void FCEUI_SetBaseDirectory(std::string const & dir);
|
||||||
|
|
||||||
|
bool FCEUI_GetUserPaletteAvail(void);
|
||||||
void FCEUI_SetUserPalette(uint8 *pal, int nEntries);
|
void FCEUI_SetUserPalette(uint8 *pal, int nEntries);
|
||||||
|
|
||||||
//Sets up sound code to render sound at the specified rate, in samples
|
//Sets up sound code to render sound at the specified rate, in samples
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// PaletteConf.cpp
|
// PaletteConf.cpp
|
||||||
//
|
//
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
#include <QTextEdit>
|
||||||
|
|
||||||
#include "Qt/PaletteConf.h"
|
#include "Qt/PaletteConf.h"
|
||||||
#include "Qt/main.h"
|
#include "Qt/main.h"
|
||||||
|
@ -9,6 +10,17 @@
|
||||||
#include "Qt/keyscan.h"
|
#include "Qt/keyscan.h"
|
||||||
#include "Qt/fceuWrapper.h"
|
#include "Qt/fceuWrapper.h"
|
||||||
|
|
||||||
|
#include "../../ppu.h"
|
||||||
|
|
||||||
|
extern bool force_grayscale;
|
||||||
|
|
||||||
|
static const char *commentText =
|
||||||
|
"Palette Selection uses the 1st Matching Condition:\n\
|
||||||
|
1. Game type is NSF (always uses fixed palette) \n\
|
||||||
|
2. Custom User Palette is Available and Enabled \n\
|
||||||
|
3. NTSC Color Emulation is Enabled \n\
|
||||||
|
4. Individual Game Palette is Available \n\
|
||||||
|
5. Default Built-in Palette ";
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||||
: QDialog( parent )
|
: QDialog( parent )
|
||||||
|
@ -18,10 +30,13 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||||
QGroupBox *frame;
|
QGroupBox *frame;
|
||||||
//QPushButton *closebutton;
|
//QPushButton *closebutton;
|
||||||
QPushButton *button;
|
QPushButton *button;
|
||||||
|
QTextEdit *comments;
|
||||||
int hue, tint;
|
int hue, tint;
|
||||||
char stmp[64];
|
char stmp[64];
|
||||||
std::string paletteFile;
|
std::string paletteFile;
|
||||||
|
|
||||||
|
resize( 512, 600 );
|
||||||
|
|
||||||
// sync with config
|
// sync with config
|
||||||
g_config->getOption ("SDL.Hue", &hue);
|
g_config->getOption ("SDL.Hue", &hue);
|
||||||
g_config->getOption ("SDL.Tint", &tint);
|
g_config->getOption ("SDL.Tint", &tint);
|
||||||
|
@ -31,8 +46,21 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||||
mainLayout = new QVBoxLayout();
|
mainLayout = new QVBoxLayout();
|
||||||
|
|
||||||
frame = new QGroupBox( tr("Custom Palette:") );
|
frame = new QGroupBox( tr("Custom Palette:") );
|
||||||
|
vbox = new QVBoxLayout();
|
||||||
hbox1 = new QHBoxLayout();
|
hbox1 = new QHBoxLayout();
|
||||||
|
|
||||||
|
useCustom = new QCheckBox( tr("Use Custom Palette") );
|
||||||
|
GrayScale = new QCheckBox( tr("Force Grayscale") );
|
||||||
|
deemphSwap = new QCheckBox( tr("De-emphasis Bit Swap") );
|
||||||
|
|
||||||
|
useCustom->setChecked( FCEUI_GetUserPaletteAvail() );
|
||||||
|
GrayScale->setChecked( force_grayscale );
|
||||||
|
deemphSwap->setChecked( paldeemphswap );
|
||||||
|
|
||||||
|
connect(useCustom , SIGNAL(stateChanged(int)), this, SLOT(use_Custom_Changed(int)) );
|
||||||
|
connect(GrayScale , SIGNAL(stateChanged(int)), this, SLOT(force_GrayScale_Changed(int)) );
|
||||||
|
connect(deemphSwap, SIGNAL(stateChanged(int)), this, SLOT(deemphswap_Changed(int)) );
|
||||||
|
|
||||||
button = new QPushButton( tr("Open Palette") );
|
button = new QPushButton( tr("Open Palette") );
|
||||||
hbox1->addWidget( button );
|
hbox1->addWidget( button );
|
||||||
|
|
||||||
|
@ -43,14 +71,20 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||||
custom_palette_path = new QLineEdit();
|
custom_palette_path = new QLineEdit();
|
||||||
custom_palette_path->setReadOnly(true);
|
custom_palette_path->setReadOnly(true);
|
||||||
custom_palette_path->setText( paletteFile.c_str() );
|
custom_palette_path->setText( paletteFile.c_str() );
|
||||||
hbox1->addWidget( custom_palette_path );
|
|
||||||
|
vbox->addWidget( useCustom );
|
||||||
|
vbox->addLayout( hbox1 );
|
||||||
|
vbox->addWidget( custom_palette_path );
|
||||||
|
vbox->addWidget( GrayScale );
|
||||||
|
vbox->addWidget( deemphSwap);
|
||||||
|
|
||||||
|
|
||||||
button = new QPushButton( tr("Clear") );
|
button = new QPushButton( tr("Clear") );
|
||||||
hbox1->addWidget( button );
|
hbox1->addWidget( button );
|
||||||
|
|
||||||
connect( button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void)) );
|
connect( button, SIGNAL(clicked(void)), this, SLOT(clearPalette(void)) );
|
||||||
|
|
||||||
frame->setLayout( hbox1 );
|
frame->setLayout( vbox );
|
||||||
|
|
||||||
mainLayout->addWidget( frame );
|
mainLayout->addWidget( frame );
|
||||||
|
|
||||||
|
@ -99,6 +133,14 @@ PaletteConfDialog_t::PaletteConfDialog_t(QWidget *parent)
|
||||||
|
|
||||||
mainLayout->addWidget( frame );
|
mainLayout->addWidget( frame );
|
||||||
|
|
||||||
|
comments = new QTextEdit();
|
||||||
|
|
||||||
|
comments->setText( commentText );
|
||||||
|
comments->moveCursor(QTextCursor::Start);
|
||||||
|
comments->setReadOnly(true);
|
||||||
|
|
||||||
|
mainLayout->addWidget( comments );
|
||||||
|
|
||||||
setLayout( mainLayout );
|
setLayout( mainLayout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +198,61 @@ void PaletteConfDialog_t::tintChanged(int v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
void PaletteConfDialog_t::use_Custom_Changed(int state)
|
||||||
|
{
|
||||||
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
//printf("Use Custom:%i \n", state );
|
||||||
|
|
||||||
|
g_config->getOption ("SDL.Palette", &filename);
|
||||||
|
|
||||||
|
if ( fceuWrapperTryLock() )
|
||||||
|
{
|
||||||
|
if ( value && (filename.size() > 0) )
|
||||||
|
{
|
||||||
|
LoadCPalette ( filename.c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FCEUI_SetUserPalette( NULL, 0);
|
||||||
|
}
|
||||||
|
fceuWrapperUnLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void PaletteConfDialog_t::force_GrayScale_Changed(int state)
|
||||||
|
{
|
||||||
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
||||||
|
if ( fceuWrapperTryLock() )
|
||||||
|
{
|
||||||
|
int e, h, t;
|
||||||
|
g_config->getOption ("SDL.NTSCpalette", &e);
|
||||||
|
g_config->getOption ("SDL.Hue", &h);
|
||||||
|
g_config->getOption ("SDL.Tint", &t);
|
||||||
|
force_grayscale = value ? true : false;
|
||||||
|
FCEUI_SetNTSCTH( e, t, h);
|
||||||
|
fceuWrapperUnLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
|
void PaletteConfDialog_t::deemphswap_Changed(int state)
|
||||||
|
{
|
||||||
|
int value = (state == Qt::Unchecked) ? 0 : 1;
|
||||||
|
|
||||||
|
if ( fceuWrapperTryLock() )
|
||||||
|
{
|
||||||
|
int e, h, t;
|
||||||
|
g_config->getOption ("SDL.NTSCpalette", &e);
|
||||||
|
g_config->getOption ("SDL.Hue", &h);
|
||||||
|
g_config->getOption ("SDL.Tint", &t);
|
||||||
|
paldeemphswap = value ? true : false;
|
||||||
|
FCEUI_SetNTSCTH( e, t, h);
|
||||||
|
fceuWrapperUnLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//----------------------------------------------------
|
||||||
void PaletteConfDialog_t::use_NTSC_Changed(int state)
|
void PaletteConfDialog_t::use_NTSC_Changed(int state)
|
||||||
{
|
{
|
||||||
int h, t;
|
int h, t;
|
||||||
|
@ -184,6 +281,7 @@ void PaletteConfDialog_t::clearPalette(void)
|
||||||
{
|
{
|
||||||
FCEUI_SetUserPalette( NULL, 0);
|
FCEUI_SetUserPalette( NULL, 0);
|
||||||
fceuWrapperUnLock();
|
fceuWrapperUnLock();
|
||||||
|
useCustom->setChecked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
@ -225,18 +323,22 @@ void PaletteConfDialog_t::openPaletteFile(void)
|
||||||
}
|
}
|
||||||
qDebug() << "selected file path : " << filename.toUtf8();
|
qDebug() << "selected file path : " << filename.toUtf8();
|
||||||
|
|
||||||
g_config->setOption ("SDL.Palette", filename.toStdString().c_str() );
|
|
||||||
g_config->setOption ("SDL.NTSCpalette", 0);
|
|
||||||
|
|
||||||
if ( fceuWrapperTryLock() )
|
if ( fceuWrapperTryLock() )
|
||||||
{
|
{
|
||||||
LoadCPalette ( filename.toStdString().c_str() );
|
if ( LoadCPalette ( filename.toStdString().c_str() ) )
|
||||||
|
{
|
||||||
|
g_config->setOption ("SDL.Palette", filename.toStdString().c_str() );
|
||||||
|
custom_palette_path->setText( filename.toStdString().c_str() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("Error: Failed to Load Palette File: %s \n", filename.toStdString().c_str() );
|
||||||
|
}
|
||||||
fceuWrapperUnLock();
|
fceuWrapperUnLock();
|
||||||
|
|
||||||
|
useCustom->setChecked( FCEUI_GetUserPaletteAvail() );
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_palette_path->setText( filename.toStdString().c_str() );
|
|
||||||
|
|
||||||
useNTSC->setChecked( 0 );
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@ class PaletteConfDialog_t : public QDialog
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QLineEdit *custom_palette_path;
|
QLineEdit *custom_palette_path;
|
||||||
|
QCheckBox *useCustom;
|
||||||
|
QCheckBox *GrayScale;
|
||||||
|
QCheckBox *deemphSwap;
|
||||||
QCheckBox *useNTSC;
|
QCheckBox *useNTSC;
|
||||||
QSlider *tintSlider;
|
QSlider *tintSlider;
|
||||||
QSlider *hueSlider;
|
QSlider *hueSlider;
|
||||||
|
@ -42,5 +45,8 @@ class PaletteConfDialog_t : public QDialog
|
||||||
void openPaletteFile(void);
|
void openPaletteFile(void);
|
||||||
void clearPalette(void);
|
void clearPalette(void);
|
||||||
void use_NTSC_Changed(int v);
|
void use_NTSC_Changed(int v);
|
||||||
|
void use_Custom_Changed(int v);
|
||||||
|
void force_GrayScale_Changed(int v);
|
||||||
|
void deemphswap_Changed(int v);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
|
|
||||||
// GLOBALS
|
// GLOBALS
|
||||||
extern Config *g_config;
|
extern Config *g_config;
|
||||||
|
extern bool force_grayscale;
|
||||||
|
|
||||||
// STATIC GLOBALS
|
// STATIC GLOBALS
|
||||||
static int s_curbpp = 0;
|
static int s_curbpp = 0;
|
||||||
|
@ -269,9 +270,21 @@ FCEUD_SetPalette(uint8 index,
|
||||||
uint8 g,
|
uint8 g,
|
||||||
uint8 b)
|
uint8 b)
|
||||||
{
|
{
|
||||||
s_psdl[index].r = r;
|
if ( force_grayscale )
|
||||||
s_psdl[index].g = g;
|
{
|
||||||
s_psdl[index].b = b;
|
// convert the palette entry to grayscale
|
||||||
|
int gray = ((float)r * 0.299 + (float)g * 0.587 + (float)b * 0.114);
|
||||||
|
|
||||||
|
s_psdl[index].r = gray;
|
||||||
|
s_psdl[index].g = gray;
|
||||||
|
s_psdl[index].b = gray;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s_psdl[index].r = r;
|
||||||
|
s_psdl[index].g = g;
|
||||||
|
s_psdl[index].b = b;
|
||||||
|
}
|
||||||
|
|
||||||
s_paletterefresh = 1;
|
s_paletterefresh = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,6 +289,11 @@ static void ApplyDeemphasisComplete(pal* pal512)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FCEUI_GetUserPaletteAvail( void )
|
||||||
|
{
|
||||||
|
return palette_user_available;
|
||||||
|
}
|
||||||
|
|
||||||
void FCEUI_SetUserPalette(uint8 *pal, int nEntries)
|
void FCEUI_SetUserPalette(uint8 *pal, int nEntries)
|
||||||
{
|
{
|
||||||
if(!pal)
|
if(!pal)
|
||||||
|
|
Loading…
Reference in New Issue