From f2638cd69c81da9d169ae10b1de9a0f4637faed7 Mon Sep 17 00:00:00 2001 From: Fabio Cavallo Date: Mon, 16 Oct 2023 11:05:33 +0200 Subject: [PATCH] Adjusted the default values of the LMP88959 filters. --- src/gui/designer/wdgPALLMP88959Filter.ui | 55 ++- .../designer/wdgPALNESRGBLMP88959Filter.ui | 369 ++++++++++-------- src/gui/objSettings.cpp | 21 +- src/gui/settings.h | 8 +- src/gui/wdgNTSCFilter.cpp | 58 ++- src/gui/wdgNTSCFilter.hpp | 4 +- src/video/filters/ntsc.c | 15 +- src/video/filters/ntsc_lmp88959.c | 4 +- src/video/filters/ntsc_nesrgb_lmp88959.c | 6 +- src/video/filters/pal_lmp88959.c | 13 +- src/video/filters/pal_lmp88959.h | 3 +- src/video/filters/pal_nesrgb_lmp88959.c | 27 +- src/video/filters/pal_nesrgb_lmp88959.h | 3 +- src/video/opengl/shaders/no_filter.h | 2 +- 14 files changed, 340 insertions(+), 248 deletions(-) diff --git a/src/gui/designer/wdgPALLMP88959Filter.ui b/src/gui/designer/wdgPALLMP88959Filter.ui index d11ce89fc..985e9d73e 100644 --- a/src/gui/designer/wdgPALLMP88959Filter.ui +++ b/src/gui/designer/wdgPALLMP88959Filter.ui @@ -53,7 +53,7 @@ - + @@ -64,16 +64,6 @@ - - - - Qt::RightToLeft - - - MFields - - - @@ -229,7 +219,7 @@ - + @@ -426,6 +416,41 @@ + + + + + + Qt::LeftToRight + + + Chroma Correction + + + + + + + Qt::RightToLeft + + + MFields + + + + + + + + + + + + + :/icon/icons/default.svgz:/icon/icons/default.svgz + + + @@ -454,6 +479,9 @@ horizontalSlider_Chroma_Lag spinBox_Chroma_Lag pushButton_Chroma_Lag + checkBox_Chroma_Correction + checkBox_Merge_Fields + pushButton_Chroma_Correction_MFields horizontalSlider_Noise spinBox_Noise pushButton_Noise @@ -467,9 +495,8 @@ spinBox_Color_Phase pushButton_Color_Phase checkBox_Scanline - checkBox_Merge_Fields checkBox_Vertical_Blend - pushButton_Scanline_MFields_VBlend + pushButton_Scanline_VBlend pushButton_PAL_Parameters_reset diff --git a/src/gui/designer/wdgPALNESRGBLMP88959Filter.ui b/src/gui/designer/wdgPALNESRGBLMP88959Filter.ui index 960d59a58..e71394441 100644 --- a/src/gui/designer/wdgPALNESRGBLMP88959Filter.ui +++ b/src/gui/designer/wdgPALNESRGBLMP88959Filter.ui @@ -7,7 +7,7 @@ 0 0 566 - 146 + 176 @@ -28,19 +28,93 @@ - - + + + + White Point + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + 255 + + + Qt::Horizontal + + + + + QAbstractSpinBox::PlusMinus - 100 + 255 0 + + + + + + + + :/icon/icons/default.svgz:/icon/icons/default.svgz + + + + + + + Chroma Lag + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + QAbstractSpinBox::PlusMinus + + + -8 + + + 8 + + + + + + + QAbstractSpinBox::PlusMinus + + + 50 + + + + + + + 100 + + + Qt::Horizontal + + + @@ -51,8 +125,32 @@ - - + + + + Contrast + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + Qt::LeftToRight + + + Chroma Correction + + + + + + + @@ -62,23 +160,34 @@ - - - - QAbstractSpinBox::PlusMinus + + + + + + + + :/icon/icons/default.svgz:/icon/icons/default.svgz + + + + 255 + + Qt::Horizontal + - - - - Contrast + + + + 100 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + Qt::Horizontal @@ -93,31 +202,41 @@ - + Qt::Vertical - - + + - Noise + + + + + :/icon/icons/default.svgz:/icon/icons/default.svgz + + + + + + + Brightness Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - + + - + Noise - - - :/icon/icons/default.svgz:/icon/icons/default.svgz + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -134,58 +253,60 @@ - - + + + + QAbstractSpinBox::PlusMinus + 255 - - Qt::Horizontal - - - + + - Chroma Lag + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + :/icon/icons/default.svgz:/icon/icons/default.svgz - - + + - Brightness + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + :/icon/icons/default.svgz:/icon/icons/default.svgz - - + + - 100 + 255 Qt::Horizontal - - - - 100 + + + + Black Point - - Qt::Horizontal + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - + + @@ -195,13 +316,14 @@ - - - - QAbstractSpinBox::PlusMinus + + + + - - 50 + + + :/icon/icons/default.svgz:/icon/icons/default.svgz @@ -218,51 +340,40 @@ - - + + - + Saturation - - - :/icon/icons/default.svgz:/icon/icons/default.svgz + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - 255 - - - Qt::Horizontal + + + + QAbstractSpinBox::PlusMinus - - - - - 255 + 100 - - Qt::Horizontal + + 0 - - + + QAbstractSpinBox::PlusMinus - - -8 - - 8 + 100 - + @@ -286,92 +397,6 @@ - - - - White Point - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - QAbstractSpinBox::PlusMinus - - - 255 - - - 0 - - - - - - - Saturation - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Black Point - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - - - :/icon/icons/default.svgz:/icon/icons/default.svgz - - - - - - - QAbstractSpinBox::PlusMinus - - - 100 - - - - - - - - - - - :/icon/icons/default.svgz:/icon/icons/default.svgz - - - - - - - - - - - :/icon/icons/default.svgz:/icon/icons/default.svgz - - - @@ -400,6 +425,8 @@ horizontalSlider_Chroma_Lag spinBox_Chroma_Lag pushButton_Chroma_Lag + checkBox_Chroma_Correction + pushButton_Chroma_Correction horizontalSlider_Noise spinBox_Noise pushButton_Noise diff --git a/src/gui/objSettings.cpp b/src/gui/objSettings.cpp index b02139afd..7d32fe32f 100644 --- a/src/gui/objSettings.cpp +++ b/src/gui/objSettings.cpp @@ -1307,11 +1307,11 @@ void objSet::ntsc_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buffer) { if (splitted.count() == 10) { format->hue = splitted.at(0).toInt(); if ((format->hue < 0) || (format->hue > 255)) { - format->hue = 0; + format->hue = 8; } format->saturation = splitted.at(1).toInt(); if ((format->saturation < 0) || (format->saturation > 50)) { - format->saturation = 16; + format->saturation = 10; } format->contrast = splitted.at(2).toInt(); if ((format->contrast < 0) || (format->contrast > 255)) { @@ -1327,7 +1327,7 @@ void objSet::ntsc_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buffer) { } format->white_point = splitted.at(5).toInt(); if ((format->white_point < 0) || (format->white_point > 255)) { - format->white_point = 85; + format->white_point = 110; } format->noise = splitted.at(6).toInt(); if ((format->noise < 0) || (format->noise > 255)) { @@ -1365,11 +1365,11 @@ void objSet::ntsc_nesrgb_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buff if (splitted.count() == 9) { format->hue = splitted.at(0).toInt(); if ((format->hue < 0) || (format->hue > 255)) { - format->hue = 0; + format->hue = 8; } format->saturation = splitted.at(1).toInt(); if ((format->saturation < 0) || (format->saturation > 50)) { - format->saturation = 16; + format->saturation = 10; } format->contrast = splitted.at(2).toInt(); if ((format->contrast < 0) || (format->contrast > 255)) { @@ -1385,7 +1385,7 @@ void objSet::ntsc_nesrgb_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buff } format->white_point = splitted.at(5).toInt(); if ((format->white_point < 0) || (format->white_point > 255)) { - format->white_point = 85; + format->white_point = 110; } format->noise = splitted.at(6).toInt(); if ((format->noise < 0) || (format->noise > 255)) { @@ -1422,7 +1422,7 @@ void objSet::pal_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buffer) { if (splitted.count() == 12) { format->saturation = splitted.at(0).toInt(); if ((format->saturation < 0) || (format->saturation > 50)) { - format->saturation = 16; + format->saturation = 10; } format->contrast = splitted.at(1).toInt(); if ((format->contrast < 0) || (format->contrast > 255)) { @@ -1438,7 +1438,7 @@ void objSet::pal_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buffer) { } format->white_point = splitted.at(4).toInt(); if ((format->white_point < 0) || (format->white_point > 255)) { - format->white_point = 85; + format->white_point = 110; } format->noise = splitted.at(5).toInt(); if ((format->noise < 0) || (format->noise > 255)) { @@ -1487,7 +1487,7 @@ void objSet::pal_nesrgb_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buffe if (splitted.count() == 10) { format->saturation = splitted.at(0).toInt(); if ((format->saturation < 0) || (format->saturation > 50)) { - format->saturation = 16; + format->saturation = 10; } format->contrast = splitted.at(1).toInt(); if ((format->contrast < 0) || (format->contrast > 255)) { @@ -1503,7 +1503,7 @@ void objSet::pal_nesrgb_lmp88959_val_to_int(void *ntsc_frmt, const uTCHAR *buffe } format->white_point = splitted.at(4).toInt(); if ((format->white_point < 0) || (format->white_point > 255)) { - format->white_point = 85; + format->white_point = 110; } format->noise = splitted.at(5).toInt(); if ((format->noise < 0) || (format->noise > 255)) { @@ -1534,7 +1534,6 @@ QString objSet::pal_nesrgb_lmp88959_val(void *ntsc_frmt) { arg(round(format->chroma_correction & 0x01))); } - int objSet::channel_convert_index(int index) { switch (index) { default: diff --git a/src/gui/settings.h b/src/gui/settings.h index 4e8e21720..88013bb66 100644 --- a/src/gui/settings.h +++ b/src/gui/settings.h @@ -983,7 +983,7 @@ static const _settings main_cfg[] = { {0, NULL} }, { - uL("video"), uL("ntsc lmp88959 filter parameters"), uL("0,16,165,0,2,85,12,1,0,1"), + uL("video"), uL("ntsc lmp88959 filter parameters"), uL("0,10,165,0,2,110,12,0,1,0"), uL("# possible values: [hue : 0/255],[saturation : 0/50],[contrast : 0/255]," NEWLINE) uL("# [brightness: 0/255],[black point : 0/100],[white point : 0/255]," NEWLINE) uL("# [noise : 0/100],[merge fields: 0/1],[vertical blend: 0/1]," NEWLINE) @@ -992,7 +992,7 @@ static const _settings main_cfg[] = { {0, NULL} }, { - uL("video"), uL("ntsc nesrgb lmp88959 filter parameters"), uL("0,16,165,0,2,85,12,0,1"), + uL("video"), uL("ntsc nesrgb lmp88959 filter parameters"), uL("8,10,165,0,2,110,12,1,0"), uL("# possible values: [hue : 0/255],[saturation : 0/50],[contrast : 0/255]," NEWLINE) uL("# [brightness: 0/255],[black point : 0/100],[white point: 0/255]," NEWLINE) uL("# [noise : 0/100],[vertical blend: 0/1],[scanline : 0/1]"), @@ -1000,7 +1000,7 @@ static const _settings main_cfg[] = { {0, NULL} }, { - uL("video"), uL("pal lmp88959 filter parameters"), uL("16,165,0,2,85,12,0,0,1,0,1,1"), + uL("video"), uL("pal lmp88959 filter parameters"), uL("10,165,0,2,110,12,0,0,0,1,0,1"), uL("# possible values: [saturation : 0/50],[contrast : 0/255],[brightness : 0/255]," NEWLINE) uL("# [black point : 0/100],[white point: 0/255],[noise : 0/100]," NEWLINE) uL("# [color phase : 0/2],[chroma lag : -8/8],[merge fields: 0/1]," NEWLINE) @@ -1009,7 +1009,7 @@ static const _settings main_cfg[] = { {0, NULL} }, { - uL("video"), uL("pal nesrgb lmp88959 filter parameters"), uL("16,165,0,2,85,12,0,0,1,1"), + uL("video"), uL("pal nesrgb lmp88959 filter parameters"), uL("10,165,0,2,110,12,0,1,0,1"), uL("# possible values: [saturation : 0/50],[contrast : 0/255],[brightness: 0/255]," NEWLINE) uL("# [black point: 0/100],[white point : 0/255],[noise : 0/100]," NEWLINE) uL("# [chroma lag : -8/8],[vertical blend: 0/1],[scanline : 0/1]," NEWLINE) diff --git a/src/gui/wdgNTSCFilter.cpp b/src/gui/wdgNTSCFilter.cpp index 7dafb65d9..7d39ba84f 100644 --- a/src/gui/wdgNTSCFilter.cpp +++ b/src/gui/wdgNTSCFilter.cpp @@ -33,7 +33,7 @@ static const char parameters_desc[][15] = { }; wdgNTSCFilter::wdgNTSCFilter(QWidget *parent) : QWidget(parent) { - unsigned int i; + unsigned int i = 0; setupUi(this); @@ -209,7 +209,7 @@ static const char bisqwit_parameters_desc[][15] = { }; wdgNTSCBisqwitFilter::wdgNTSCBisqwitFilter(QWidget *parent) : QWidget(parent) { - unsigned int i; + unsigned int i = 0; setupUi(this); @@ -370,7 +370,7 @@ static const char ntsc_lmp88959_parameters_desc[][15] = { }; wdgNTSCLMP88959Filter::wdgNTSCLMP88959Filter(QWidget *parent) : QWidget(parent) { - unsigned int i; + unsigned int i = 0; setupUi(this); @@ -543,7 +543,7 @@ static const char ntsc_nesrgb_lmp88959_parameters_desc[][15] = { }; wdgNTSCNESRGBLMP88959Filter::wdgNTSCNESRGBLMP88959Filter(QWidget *parent) : QWidget(parent) { - unsigned int i; + unsigned int i = 0; setupUi(this); @@ -709,7 +709,7 @@ static const char pal_lmp88959_parameters_desc[][15] = { }; wdgPALLMP88959Filter::wdgPALLMP88959Filter(QWidget *parent) : QWidget(parent) { - unsigned int i; + unsigned int i = 0; setupUi(this); @@ -739,7 +739,11 @@ wdgPALLMP88959Filter::wdgPALLMP88959Filter(QWidget *parent) : QWidget(parent) { checkBox_Vertical_Blend->setProperty("myIndex", QVariant(2)); connect(checkBox_Vertical_Blend, SIGNAL(stateChanged(int)), this, SLOT(s_checkbox_changed(int))); - connect(pushButton_Scanline_MFields_VBlend, SIGNAL(clicked(bool)), this, SLOT(s_default_value_smv_clicked(bool))); + checkBox_Chroma_Correction->setProperty("myIndex", QVariant(3)); + connect(checkBox_Chroma_Correction, SIGNAL(stateChanged(int)), this, SLOT(s_checkbox_changed(int))); + + connect(pushButton_Chroma_Correction_MFields, SIGNAL(clicked(bool)), this, SLOT(s_default_value_cm_clicked(bool))); + connect(pushButton_Scanline_VBlend, SIGNAL(clicked(bool)), this, SLOT(s_default_value_sv_clicked(bool))); connect(pushButton_PAL_Parameters_reset, SIGNAL(clicked(bool)), this, SLOT(s_reset(bool))); } wdgPALLMP88959Filter::~wdgPALLMP88959Filter() = default; @@ -787,8 +791,9 @@ void wdgPALLMP88959Filter::set_sliders_spins(void) { qtHelper::spinbox_set_value(spinBox_Color_Phase, format->color_phase); qtHelper::spinbox_set_value(spinBox_Chroma_Lag, format->chroma_lag); - qtHelper::checkbox_set_checked(checkBox_Scanline, format->scanline); + qtHelper::checkbox_set_checked(checkBox_Chroma_Correction, format->chroma_correction); qtHelper::checkbox_set_checked(checkBox_Merge_Fields, format->merge_fields); + qtHelper::checkbox_set_checked(checkBox_Scanline, format->scanline); qtHelper::checkbox_set_checked(checkBox_Vertical_Blend, format->vertical_blend); } @@ -852,9 +857,9 @@ void wdgPALLMP88959Filter::s_checkbox_changed(int state) { case 2: format->vertical_blend = state > 0; break; -// case 3: -// format->chroma_correction = state > 0; -// break; + case 3: + format->chroma_correction = state > 0; + break; } pal_lmp88959_filter_parameters_changed(); gfx_thread_continue(); @@ -868,9 +873,16 @@ void wdgPALLMP88959Filter::s_default_value_clicked(UNUSED(bool checked)) { pal_lmp88959_filter_parameters_changed(); gfx_thread_continue(); } -void wdgPALLMP88959Filter::s_default_value_smv_clicked(UNUSED(bool checked)) { +void wdgPALLMP88959Filter::s_default_value_cm_clicked(UNUSED(bool checked)) { + gfx_thread_pause(); + pal_lmp88959_filter_parameter_cm_default(); + gui_update_ntsc_widgets(); + pal_lmp88959_filter_parameters_changed(); + gfx_thread_continue(); +} +void wdgPALLMP88959Filter::s_default_value_sv_clicked(UNUSED(bool checked)) { gfx_thread_pause(); - pal_lmp88959_filter_parameter_smv_default(); + pal_lmp88959_filter_parameter_sv_default(); gui_update_ntsc_widgets(); pal_lmp88959_filter_parameters_changed(); gfx_thread_continue(); @@ -890,7 +902,7 @@ static const char pal_nesrgb_lmp88959_parameters_desc[][15] = { }; wdgPALNESRGBLMP88959Filter::wdgPALNESRGBLMP88959Filter(QWidget *parent) : QWidget(parent) { - unsigned int i; + unsigned int i = 0; setupUi(this); @@ -917,6 +929,10 @@ wdgPALNESRGBLMP88959Filter::wdgPALNESRGBLMP88959Filter(QWidget *parent) : QWidge checkBox_Vertical_Blend->setProperty("myIndex", QVariant(1)); connect(checkBox_Vertical_Blend, SIGNAL(stateChanged(int)), this, SLOT(s_checkbox_changed(int))); + checkBox_Chroma_Correction->setProperty("myIndex", QVariant(2)); + connect(checkBox_Chroma_Correction, SIGNAL(stateChanged(int)), this, SLOT(s_checkbox_changed(int))); + + connect(pushButton_Chroma_Correction, SIGNAL(clicked(bool)), this, SLOT(s_default_value_c_clicked(bool))); connect(pushButton_Scanline_VBlend, SIGNAL(clicked(bool)), this, SLOT(s_default_value_sv_clicked(bool))); connect(pushButton_PAL_Parameters_reset, SIGNAL(clicked(bool)), this, SLOT(s_reset(bool))); } @@ -963,6 +979,7 @@ void wdgPALNESRGBLMP88959Filter::set_sliders_spins(void) { qtHelper::spinbox_set_value(spinBox_Noise, format->noise); qtHelper::spinbox_set_value(spinBox_Chroma_Lag, format->chroma_lag); + qtHelper::checkbox_set_checked(checkBox_Chroma_Correction, format->chroma_correction); qtHelper::checkbox_set_checked(checkBox_Scanline, format->scanline); qtHelper::checkbox_set_checked(checkBox_Vertical_Blend, format->vertical_blend); } @@ -1021,9 +1038,9 @@ void wdgPALNESRGBLMP88959Filter::s_checkbox_changed(int state) { case 1: format->vertical_blend = state > 0; break; -// case 2: -// format->chroma_correction = state > 0; -// break; + case 2: + format->chroma_correction = state > 0; + break; } pal_nesrgb_lmp88959_filter_parameters_changed(); gfx_thread_continue(); @@ -1037,9 +1054,16 @@ void wdgPALNESRGBLMP88959Filter::s_default_value_clicked(UNUSED(bool checked)) { pal_nesrgb_lmp88959_filter_parameters_changed(); gfx_thread_continue(); } +void wdgPALNESRGBLMP88959Filter::s_default_value_c_clicked(UNUSED(bool checked)) { + gfx_thread_pause(); + pal_nesrgb_lmp88959_filter_parameter_c_default(); + gui_update_ntsc_widgets(); + pal_nesrgb_lmp88959_filter_parameters_changed(); + gfx_thread_continue(); +} void wdgPALNESRGBLMP88959Filter::s_default_value_sv_clicked(UNUSED(bool checked)) { gfx_thread_pause(); - pal_nesrgb_lmp88959_filter_parameter_smv_default(); + pal_nesrgb_lmp88959_filter_parameter_sv_default(); gui_update_ntsc_widgets(); pal_nesrgb_lmp88959_filter_parameters_changed(); gfx_thread_continue(); diff --git a/src/gui/wdgNTSCFilter.hpp b/src/gui/wdgNTSCFilter.hpp index 8ea40e2a3..f9f8a56ff 100644 --- a/src/gui/wdgNTSCFilter.hpp +++ b/src/gui/wdgNTSCFilter.hpp @@ -158,7 +158,8 @@ class wdgPALLMP88959Filter : public QWidget, public Ui::wdgPALLMP88959Filter { void s_slider_spin_changed(int value); void s_checkbox_changed(int state); void s_default_value_clicked(bool checked); - void s_default_value_smv_clicked(bool checked); + void s_default_value_cm_clicked(bool checked); + void s_default_value_sv_clicked(bool checked); void s_reset(bool checked); }; @@ -185,6 +186,7 @@ class wdgPALNESRGBLMP88959Filter : public QWidget, public Ui::wdgPALNESRGBLMP889 void s_slider_spin_changed(int value); void s_checkbox_changed(int state); void s_default_value_clicked(bool checked); + void s_default_value_c_clicked(bool checked); void s_default_value_sv_clicked(bool checked); void s_reset(bool checked); }; diff --git a/src/video/filters/ntsc.c b/src/video/filters/ntsc.c index 50db741cd..3b766e37f 100644 --- a/src/video/filters/ntsc.c +++ b/src/video/filters/ntsc.c @@ -34,7 +34,8 @@ BYTE ntsc_init(void) { // quello per la paletta palette = nes_ntsc_composite; - if (!(ntsc_filter.ntsc = (nes_ntsc_t *)malloc(sizeof(nes_ntsc_t)))) { + ntsc_filter.ntsc = (nes_ntsc_t *)malloc(sizeof(nes_ntsc_t)); + if (!ntsc_filter.ntsc) { log_error(uL("ntsc;out of memory")); return (EXIT_ERROR); } @@ -98,7 +99,7 @@ void ntsc_set(nes_ntsc_t *ntsc, BYTE create_palette, BYTE color, const BYTE *pal } void ntsc_rgb_modifier(nes_ntsc_t *ntsc, BYTE *palette_out, SWORD min, SWORD red, SWORD green, SWORD blue) { _color_RGB *pRGB = (_color_RGB *)palette_out; - WORD i; + WORD i = 0; // prima ottengo la paletta monocromatica ntsc_set(ntsc, TRUE, PALETTE_MONO, 0, 0, palette_out); @@ -130,7 +131,7 @@ void ntsc_filter_parameters_default(void) { } } void ntsc_filter_parameter_default(int index) { - nes_ntsc_setup_t *format; + nes_ntsc_setup_t *format = NULL; switch (cfg->ntsc_format) { default: @@ -182,7 +183,7 @@ void ntsc_filter_parameter_default(int index) { } } void ntsc_filter_parameter_mv_default(void) { - nes_ntsc_setup_t *format; + nes_ntsc_setup_t *format = NULL; switch (cfg->ntsc_format) { default: @@ -201,7 +202,7 @@ void ntsc_filter_parameter_mv_default(void) { } void ntsc_surface(BYTE nidx) { static int burst_count = 0, burst_phase = 0; - int y; + int y = 0; if (gfx.filter.data.palette == NULL) { gfx.filter.data.palette = (void *)ntsc_filter.ntsc; @@ -228,12 +229,12 @@ void ntsc_surface(BYTE nidx) { for (y = ((gfx.filter.data.height / gfx.filter.factor) - 1); --y >= 0;) { unsigned char const *in = ((const unsigned char *)gfx.filter.data.pix) + (y * gfx.filter.data.pitch); unsigned char *out = ((unsigned char *)gfx.filter.data.pix) + ((y * gfx.filter.factor) * gfx.filter.data.pitch); - int n; + int n = 0; for (n = gfx.filter.data.width; n; --n) { unsigned prev = *(uint32_t *)in; unsigned next = *(uint32_t *)(in + gfx.filter.data.pitch); - unsigned mixed; + unsigned mixed = 0; // mix rgb without losing low bits mixed = ntsc_filter.format[cfg->ntsc_format].vertical_blend ? (prev + next + ((prev ^ next) & 0x030303)) >> 1 : prev; diff --git a/src/video/filters/ntsc_lmp88959.c b/src/video/filters/ntsc_lmp88959.c index 1899b2b7a..eff25b243 100644 --- a/src/video/filters/ntsc_lmp88959.c +++ b/src/video/filters/ntsc_lmp88959.c @@ -23,8 +23,8 @@ #define CRT_SYSTEM CRT_SYSTEM_NTSC #include "extra/NTSC-CRT/crt_core.h" -const _ntsc_lmp88959_setup_t ntsc_lmp88959_default = { 0, 16, 165, 0, 2, 85, 12, 1, 0, 1 }; -_ntsc_lmp88959_setup_t ntsc_lmp88959 = { 0, 16, 165, 0, 2, 85, 12, 1, 0, 1 }; +const _ntsc_lmp88959_setup_t ntsc_lmp88959_default = { 8, 10, 165, 0, 2, 110, 12, 0, 1, 0 }; +_ntsc_lmp88959_setup_t ntsc_lmp88959 = { 8, 10, 165, 0, 2, 110, 12, 0, 1, 0 }; static struct CRT crt = { 0 }; static struct NTSC_SETTINGS ntsc = { 0 }; static int field = 0; diff --git a/src/video/filters/ntsc_nesrgb_lmp88959.c b/src/video/filters/ntsc_nesrgb_lmp88959.c index 5070d61cc..e3b290fef 100644 --- a/src/video/filters/ntsc_nesrgb_lmp88959.c +++ b/src/video/filters/ntsc_nesrgb_lmp88959.c @@ -23,8 +23,8 @@ #define CRT_SYSTEM CRT_SYSTEM_NESRGB #include "extra/NTSC-CRT/crt_core_nesrgb.h" -const _ntsc_lmp88959_setup_t ntsc_nesrgb_lmp88959_default = { 0, 16, 165, 0, 2, 85, 12, 0, 0, 1 }; -_ntsc_lmp88959_setup_t ntsc_nesrgb_lmp88959 = { 0, 16, 165, 0, 2, 85, 12, 0, 0, 1 }; +const _ntsc_lmp88959_setup_t ntsc_nesrgb_lmp88959_default = { 8, 10, 165, 0, 2, 110, 12, 0, 1, 0 }; +_ntsc_lmp88959_setup_t ntsc_nesrgb_lmp88959 = { 8, 10, 165, 0, 2, 110, 12, 0, 1, 0 }; static struct CRT_NESRGB crt_nesrgb = { 0 }; static struct NTSC_SETTINGS ntsc_nesrgb = { 0 }; @@ -52,7 +52,7 @@ void ntsc_nesrgb_lmp88959_surface(BYTE nidx) { ntsc_nesrgb.palette = (uint32_t *)gfx.filter.data.palette; ntsc_nesrgb.w = SCR_COLUMNS; ntsc_nesrgb.h = SCR_ROWS; - ntsc_nesrgb.dot_crawl_offset = (ntsc_nesrgb.dot_crawl_offset + 1) % 2; + ntsc_nesrgb.dot_crawl_offset = (ntsc_nesrgb.dot_crawl_offset + 1) % 3; // ntsc_nesrgb.hue = ntsc_nesrgb_lmp88959.hue; crt_nesrgb_modulate(&crt_nesrgb, &ntsc_nesrgb); crt_nesrgb_demodulate(&crt_nesrgb, ntsc_nesrgb_lmp88959.noise); diff --git a/src/video/filters/pal_lmp88959.c b/src/video/filters/pal_lmp88959.c index ae3e5f447..69eb0fed8 100644 --- a/src/video/filters/pal_lmp88959.c +++ b/src/video/filters/pal_lmp88959.c @@ -24,8 +24,8 @@ #define PAL_SYSTEM PAL_SYSTEM_PAL #include "extra/PAL-CRT/pal_core.h" -const _pal_lmp88959_setup_t pal_lmp88959_default = { 16, 165, 0, 2, 85, 12, 0, 0, 1, 0, 1, 1 }; -_pal_lmp88959_setup_t pal_lmp88959 = { 16, 165, 0, 2, 85, 12, 0, 0, 1, 0, 1, 1 }; +const _pal_lmp88959_setup_t pal_lmp88959_default = { 10, 165, 0, 2, 110, 12, 0, 0, 0, 1, 0, 1 }; +_pal_lmp88959_setup_t pal_lmp88959 = { 10, 165, 0, 2, 110, 12, 0, 0, 0, 1, 0, 1 }; static struct PAL_CRT crt = { 0 }; static struct PAL_SETTINGS pal = { 0 }; static int field = 0; @@ -105,11 +105,16 @@ void pal_lmp88959_filter_parameter_default(int index) { break; } } -void pal_lmp88959_filter_parameter_smv_default(void) { +void pal_lmp88959_filter_parameter_cm_default(void) { const _pal_lmp88959_setup_t *format = &pal_lmp88959_default; - pal_lmp88959.scanline = format->scanline; + pal_lmp88959.chroma_correction = format->chroma_correction; pal_lmp88959.merge_fields = format->merge_fields; +} +void pal_lmp88959_filter_parameter_sv_default(void) { + const _pal_lmp88959_setup_t *format = &pal_lmp88959_default; + + pal_lmp88959.scanline = format->scanline; pal_lmp88959.vertical_blend = format->vertical_blend; } diff --git a/src/video/filters/pal_lmp88959.h b/src/video/filters/pal_lmp88959.h index 8ed8371ca..6ab77d5bd 100644 --- a/src/video/filters/pal_lmp88959.h +++ b/src/video/filters/pal_lmp88959.h @@ -51,7 +51,8 @@ EXTERNC void pal_lmp88959_filter_parameters_changed(void); EXTERNC void pal_lmp88959_filter_parameters_default(void); EXTERNC void pal_lmp88959_filter_parameter_default(int index); -EXTERNC void pal_lmp88959_filter_parameter_smv_default(void); +EXTERNC void pal_lmp88959_filter_parameter_cm_default(void); +EXTERNC void pal_lmp88959_filter_parameter_sv_default(void); #undef EXTERNC diff --git a/src/video/filters/pal_nesrgb_lmp88959.c b/src/video/filters/pal_nesrgb_lmp88959.c index 3781f493e..82083ec4a 100644 --- a/src/video/filters/pal_nesrgb_lmp88959.c +++ b/src/video/filters/pal_nesrgb_lmp88959.c @@ -24,15 +24,15 @@ #define PAL_SYSTEM PAL_SYSTEM_NESRGB #include "extra/PAL-CRT/pal_core_nesrgb.h" -const _pal_lmp88959_setup_t pal_nesrgb_lmp88959_default = { 16, 165, 0, 2, 85, 12, 0, 0, 0, 0, 1, 1 }; -_pal_lmp88959_setup_t pal_nesrgb_lmp88959 = { 16, 165, 0, 2, 85, 12, 0, 0, 0, 0, 1, 1 }; +const _pal_lmp88959_setup_t pal_nesrgb_lmp88959_default = { 10, 165, 0, 2, 110, 12, 0, 0, 0, 1, 0, 1 }; +_pal_lmp88959_setup_t pal_nesrgb_lmp88959 = { 10, 165, 0, 2, 110, 12, 0, 0, 0, 1, 0, 1 }; static struct PAL_CRT_NESRGB crt_nesrgb = { 0 }; -static struct PAL_SETTINGS pal_nergb = { 0 }; +static struct PAL_SETTINGS pal_nesrgb = { 0 }; static int field = 0; BYTE pal_nesrgb_lmp88959_init(void) { memset(&crt_nesrgb, 0x00, sizeof(crt_nesrgb)); - memset(&pal_nergb, 0x00, sizeof(pal_nergb)); + memset(&pal_nesrgb, 0x00, sizeof(pal_nesrgb)); field = 0; pal_nesrgb_init(&crt_nesrgb, 0, 0, PAL_PIX_FORMAT_BGRA, NULL); return (EXIT_OK); @@ -51,12 +51,12 @@ void pal_nesrgb_lmp88959_surface(BYTE nidx) { crt_nesrgb.scanlines = pal_nesrgb_lmp88959.scanline; crt_nesrgb.chroma_lag = pal_nesrgb_lmp88959.chroma_lag; crt_nesrgb.chroma_correction = pal_nesrgb_lmp88959.chroma_correction; - pal_nergb.data = (const unsigned char *)nes[nidx].p.ppu_screen.rd->data; - pal_nergb.format = PAL_PIX_FORMAT_BGRA; - pal_nergb.palette = (uint32_t *)gfx.filter.data.palette; - pal_nergb.w = SCR_COLUMNS; - pal_nergb.h = SCR_ROWS; - pal_nesrgb_modulate(&crt_nesrgb, &pal_nergb); + pal_nesrgb.data = (const unsigned char *)nes[nidx].p.ppu_screen.rd->data; + pal_nesrgb.format = PAL_PIX_FORMAT_BGRA; + pal_nesrgb.palette = (uint32_t *)gfx.filter.data.palette; + pal_nesrgb.w = SCR_COLUMNS; + pal_nesrgb.h = SCR_ROWS; + pal_nesrgb_modulate(&crt_nesrgb, &pal_nesrgb); pal_nesrgb_demodulate(&crt_nesrgb, pal_nesrgb_lmp88959.noise); lmp88959_phosphor_decay(); } @@ -95,7 +95,12 @@ void pal_nesrgb_lmp88959_filter_parameter_default(int index) { break; } } -void pal_nesrgb_lmp88959_filter_parameter_smv_default(void) { +void pal_nesrgb_lmp88959_filter_parameter_c_default(void) { + const _pal_lmp88959_setup_t *format = &pal_nesrgb_lmp88959_default; + + pal_nesrgb_lmp88959.chroma_correction = format->chroma_correction; +} +void pal_nesrgb_lmp88959_filter_parameter_sv_default(void) { const _pal_lmp88959_setup_t *format = &pal_nesrgb_lmp88959_default; pal_nesrgb_lmp88959.scanline = format->scanline; diff --git a/src/video/filters/pal_nesrgb_lmp88959.h b/src/video/filters/pal_nesrgb_lmp88959.h index 8131a4f9f..e675d5197 100644 --- a/src/video/filters/pal_nesrgb_lmp88959.h +++ b/src/video/filters/pal_nesrgb_lmp88959.h @@ -37,7 +37,8 @@ EXTERNC void pal_nesrgb_lmp88959_filter_parameters_changed(void); EXTERNC void pal_nesrgb_lmp88959_filter_parameters_default(void); EXTERNC void pal_nesrgb_lmp88959_filter_parameter_default(int index); -EXTERNC void pal_nesrgb_lmp88959_filter_parameter_smv_default(void); +EXTERNC void pal_nesrgb_lmp88959_filter_parameter_c_default(void); +EXTERNC void pal_nesrgb_lmp88959_filter_parameter_sv_default(void); #undef EXTERNC diff --git a/src/video/opengl/shaders/no_filter.h b/src/video/opengl/shaders/no_filter.h index 67a0976ca..90b4893a5 100644 --- a/src/video/opengl/shaders/no_filter.h +++ b/src/video/opengl/shaders/no_filter.h @@ -70,6 +70,6 @@ "void main()\n" "{\n" " FragColor = vec4(COMPAT_TEXTURE(Texture, TEX0.xy).rgb, 1.0);\n" -"} \n" +"}\n" "#endif\n" },