From 3850cb7879e09db33150aca48a66200020c6dd76 Mon Sep 17 00:00:00 2001 From: stephena Date: Sat, 12 May 2012 22:21:59 +0000 Subject: [PATCH] Blargg now has knobs! The TV effects settings are now accessible from the Video Settings UI. Still TODO is add key shortcuts for the various adjustable TV effects (contrast, brightness, etc). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2468 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/bspf.hxx | 1 + src/common/mainSDL.cxx | 1 + src/common/tv_filters/NTSCFilter.cxx | 113 +++++++++++---- src/common/tv_filters/NTSCFilter.hxx | 22 ++- src/emucore/EventHandler.cxx | 3 - src/emucore/FrameBuffer.cxx | 3 + src/emucore/Settings.cxx | 25 +++- src/gui/VideoDialog.cxx | 203 ++++++++++++++++++++++++--- src/gui/VideoDialog.hxx | 35 ++++- 9 files changed, 339 insertions(+), 67 deletions(-) diff --git a/src/common/bspf.hxx b/src/common/bspf.hxx index afbf60dd3..99176ed2b 100644 --- a/src/common/bspf.hxx +++ b/src/common/bspf.hxx @@ -121,6 +121,7 @@ template inline void BSPF_swap(T& a, T& b) { T tmp = a; a = b; b = t template inline T BSPF_abs (T x) { return (x>=0) ? x : -x; } template inline T BSPF_min (T a, T b) { return (a inline T BSPF_max (T a, T b) { return (a>b) ? a : b; } +template inline T BSPF_clamp (T a, T l, T u) { return (au) ? u : a; } // Convert integer to string inline string BSPF_toString(int num) diff --git a/src/common/mainSDL.cxx b/src/common/mainSDL.cxx index 7681782ec..771609ab3 100644 --- a/src/common/mainSDL.cxx +++ b/src/common/mainSDL.cxx @@ -66,6 +66,7 @@ OSystem* theOSystem = (OSystem*) NULL; int Cleanup() { theOSystem->logMessage("Cleanup from mainSDL\n", 2); + theOSystem->settings().saveConfig(); if(theOSystem) delete theOSystem; diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index bd89189c8..e74fa1d7e 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -19,22 +19,11 @@ #include "NTSCFilter.hxx" -// Limits for the adjustable values. -#define FILTER_NTSC_SHARPNESS_MIN -1.0 -#define FILTER_NTSC_SHARPNESS_MAX 1.0 -#define FILTER_NTSC_RESOLUTION_MIN -1.0 -#define FILTER_NTSC_RESOLUTION_MAX 1.0 -#define FILTER_NTSC_ARTIFACTS_MIN -1.0 -#define FILTER_NTSC_ARTIFACTS_MAX 1.0 -#define FILTER_NTSC_FRINGING_MIN -1.0 -#define FILTER_NTSC_FRINGING_MAX 1.0 -#define FILTER_NTSC_BLEED_MIN -1.0 -#define FILTER_NTSC_BLEED_MAX 1.0 - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NTSCFilter::NTSCFilter() : mySetup(atari_ntsc_composite), - myCustomSetup(atari_ntsc_composite) + myCustomSetup(atari_ntsc_composite), + myPreset(PRESET_OFF) { } @@ -61,8 +50,9 @@ void NTSCFilter::setTIAPalette(const uInt32* palette) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - string NTSCFilter::setPreset(Preset preset) { + myPreset = preset; string msg = "disabled"; - switch(preset) + switch(myPreset) { case PRESET_COMPOSITE: mySetup = atari_ntsc_composite; @@ -91,20 +81,87 @@ string NTSCFilter::setPreset(Preset preset) return msg; } -#if 0 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NTSCFilter::updateAdjustables(const atari_ntsc_setup_t& setup) +void NTSCFilter::loadConfig(const Settings& settings) { - myAdjustables.hue = setup.hue; - myAdjustables.saturation = setup.saturation; - myAdjustables.contrast = setup.contrast; - myAdjustables.brightness = setup.brightness; - myAdjustables.sharpness = setup.sharpness; - myAdjustables.gamma = setup.gamma; - myAdjustables.resolution = setup.resolution; - myAdjustables.artifacts = setup.artifacts; - myAdjustables.fringing = setup.fringing; - myAdjustables.bleed = setup.bleed; - myAdjustables.burst_phase = setup.burst_phase; + // Load adjustables for custom mode + myCustomSetup.hue = BSPF_clamp(settings.getFloat("tv_hue"), -1.0f, 1.0f); + myCustomSetup.saturation = BSPF_clamp(settings.getFloat("tv_saturation"), -1.0f, 1.0f); + myCustomSetup.contrast = BSPF_clamp(settings.getFloat("tv_contrast"), -1.0f, 1.0f); + myCustomSetup.brightness = BSPF_clamp(settings.getFloat("tv_brightness"), -1.0f, 1.0f); + myCustomSetup.sharpness = BSPF_clamp(settings.getFloat("tv_sharpness"), -1.0f, 1.0f); + myCustomSetup.gamma = BSPF_clamp(settings.getFloat("tv_gamma"), -1.0f, 1.0f); + myCustomSetup.resolution = BSPF_clamp(settings.getFloat("tv_resolution"), -1.0f, 1.0f); + myCustomSetup.artifacts = BSPF_clamp(settings.getFloat("tv_artifacts"), -1.0f, 1.0f); + myCustomSetup.fringing = BSPF_clamp(settings.getFloat("tv_fringing"), -1.0f, 1.0f); + myCustomSetup.bleed = BSPF_clamp(settings.getFloat("tv_bleed"), -1.0f, 1.0f); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void NTSCFilter::saveConfig(Settings& settings) const +{ + // Save adjustables for custom mode + settings.setFloat("tv_hue", myCustomSetup.hue); + settings.setFloat("tv_saturation", myCustomSetup.saturation); + settings.setFloat("tv_contrast", myCustomSetup.contrast); + settings.setFloat("tv_brightness", myCustomSetup.brightness); + settings.setFloat("tv_sharpness", myCustomSetup.sharpness); + settings.setFloat("tv_gamma", myCustomSetup.gamma); + settings.setFloat("tv_resolution", myCustomSetup.resolution); + settings.setFloat("tv_artifacts", myCustomSetup.artifacts); + settings.setFloat("tv_fringing", myCustomSetup.fringing); + settings.setFloat("tv_bleed", myCustomSetup.bleed); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset) +{ + switch(preset) + { + case PRESET_COMPOSITE: + convertToAdjustable(adjustable, atari_ntsc_composite); break; + case PRESET_SVIDEO: + convertToAdjustable(adjustable, atari_ntsc_svideo); break; + case PRESET_RGB: + convertToAdjustable(adjustable, atari_ntsc_rgb); break; + case PRESET_BAD: + convertToAdjustable(adjustable, atari_ntsc_bad); break; + case PRESET_CUSTOM: + convertToAdjustable(adjustable, myCustomSetup); break; + default: + break; + } +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void NTSCFilter::setCustomAdjustables(Adjustable& adjustable) +{ +#define SCALE_FROM_100(x) ((x/50.0)-1.0) + myCustomSetup.hue = SCALE_FROM_100(adjustable.hue); + myCustomSetup.saturation = SCALE_FROM_100(adjustable.saturation); + myCustomSetup.contrast = SCALE_FROM_100(adjustable.contrast); + myCustomSetup.brightness = SCALE_FROM_100(adjustable.brightness); + myCustomSetup.sharpness = SCALE_FROM_100(adjustable.sharpness); + myCustomSetup.gamma = SCALE_FROM_100(adjustable.gamma); + myCustomSetup.resolution = SCALE_FROM_100(adjustable.resolution); + myCustomSetup.artifacts = SCALE_FROM_100(adjustable.artifacts); + myCustomSetup.fringing = SCALE_FROM_100(adjustable.fringing); + myCustomSetup.bleed = SCALE_FROM_100(adjustable.bleed); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void NTSCFilter::convertToAdjustable(Adjustable& adjustable, + const atari_ntsc_setup_t& setup) const +{ +#define SCALE_TO_100(x) (uInt32)(50*(x+1.0)) + adjustable.hue = SCALE_TO_100(setup.hue); + adjustable.saturation = SCALE_TO_100(setup.saturation); + adjustable.contrast = SCALE_TO_100(setup.contrast); + adjustable.brightness = SCALE_TO_100(setup.brightness); + adjustable.sharpness = SCALE_TO_100(setup.sharpness); + adjustable.gamma = SCALE_TO_100(setup.gamma); + adjustable.resolution = SCALE_TO_100(setup.resolution); + adjustable.artifacts = SCALE_TO_100(setup.artifacts); + adjustable.fringing = SCALE_TO_100(setup.fringing); + adjustable.bleed = SCALE_TO_100(setup.bleed); } -#endif diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index 566c320e7..171c5e526 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -75,9 +75,19 @@ class NTSCFilter atari_ntsc_init(&myFilter, &mySetup, myTIAPalette); } + // Get adjustables for the given preset + // Values will be scaled to 0 - 100 range, independent of how + // they're actually stored internally + void getAdjustables(Adjustable& adjustable, Preset preset); + + // Set custom adjustables to given values + // Values will be scaled to 0 - 100 range, independent of how + // they're actually stored internally + void setCustomAdjustables(Adjustable& adjustable); + // Load and save NTSC-related settings void loadConfig(const Settings& settings); - void saveSettings(Settings& settings) const; + void saveConfig(Settings& settings) const; // Perform Blargg filtering on input buffer, place results in // output buffer @@ -98,6 +108,11 @@ class NTSCFilter dest_buf, dest_pitch); } + private: + // Convert from atari_ntsc_setup_t values to equivalent adjustables + void convertToAdjustable(Adjustable& adjustable, + const atari_ntsc_setup_t& setup) const; + private: // The NTSC filter structure atari_ntsc_t myFilter; @@ -110,9 +125,8 @@ class NTSCFilter // it is copied to mySetup) atari_ntsc_setup_t myCustomSetup; - // Contains adjustable settings for the current preset - // (including the custom mode) - Adjustable myAdjustables; + // Current preset in use + Preset myPreset; // 128 colours by 3 components per colour uInt8 myTIAPalette[128 * 3]; diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 85f9e4288..99bae3d40 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -1055,8 +1055,6 @@ void EventHandler::handleEvent(Event::Type event, int state) if((myState == S_EMULATE || myState == S_CMDMENU || myState == S_DEBUGGER) && state) { - myOSystem->settings().saveConfig(); - // Go back to the launcher, or immediately quit if(myOSystem->settings().getBool("exitlauncher") || myOSystem->launcherUsed()) @@ -1074,7 +1072,6 @@ void EventHandler::handleEvent(Event::Type event, int state) { saveKeyMapping(); saveJoyMapping(); - myOSystem->settings().saveConfig(); myOSystem->quit(); } return; diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 11b553367..2556d7cd9 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -53,6 +53,9 @@ FrameBuffer::FrameBuffer(OSystem* osystem) myMsg.surface = myStatsMsg.surface = NULL; myMsg.surfaceID = myStatsMsg.surfaceID = -1; myMsg.enabled = myStatsMsg.enabled = false; + + // Load NTSC filter settings + myNTSCFilter.loadConfig(myOSystem->settings()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 9c3a382ef..42632fee7 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -40,6 +40,7 @@ Settings::Settings(OSystem* osystem) setInternal("video", "soft"); // OpenGL specific options + setInternal("gl_inter", "false"); setInternal("gl_aspectn", "90"); setInternal("gl_aspectp", "100"); setInternal("gl_fsscale", "false"); @@ -60,19 +61,19 @@ Settings::Settings(OSystem* osystem) // TV filtering options setInternal("tv_filter", "0"); - setInternal("tv_inter", "false"); setInternal("tv_scanlines", "40"); setInternal("tv_scaninter", "true"); // TV options when using 'custom' mode + setInternal("tv_contrast", "0.0"); + setInternal("tv_brightness", "0.0"); + setInternal("tv_hue", "0.0"); + setInternal("tv_saturation", "0.0"); + setInternal("tv_gamma", "0.0"); setInternal("tv_sharpness", "0.0"); setInternal("tv_resolution", "0.0"); setInternal("tv_artifacts", "0.0"); setInternal("tv_fringing", "0.0"); setInternal("tv_bleed", "0.0"); - setInternal("tv_brightness", "0.0"); - setInternal("tv_contrast", "0.0"); - setInternal("tv_saturation", "0.0"); - setInternal("tv_gamma", "0.0"); // Sound options setInternal("sound", "true"); @@ -353,6 +354,16 @@ void Settings::usage() << " -tv_filter <0-5> Set TV effects off (0) or to specified mode (1-5)\n" << " -tv_scanlines <0-100> Set scanline intensity to percentage (0 disables completely)\n" << " -tv_scaninter <1|0> Enable interpolated (smooth) scanlines\n" + << " -tv_contrast Set TV effects custom contrast to value 1.0 - 1.0\n" + << " -tv_brightness Set TV effects custom brightness to value 1.0 - 1.0\n" + << " -tv_hue Set TV effects custom hue to value 1.0 - 1.0\n" + << " -tv_saturation Set TV effects custom saturation to value 1.0 - 1.0\n" + << " -tv_gamma Set TV effects custom gamma to value 1.0 - 1.0\n" + << " -tv_sharpness Set TV effects custom sharpness to value 1.0 - 1.0\n" + << " -tv_resolution Set TV effects custom resolution to value 1.0 - 1.0\n" + << " -tv_artifacts Set TV effects custom artifacts to value 1.0 - 1.0\n" + << " -tv_fringing Set TV effects custom fringing to value 1.0 - 1.0\n" + << " -tv_bleed Set TV effects custom bleed to value 1.0 - 1.0\n" << endl #endif << " -tia_filter Use the specified filter in emulation mode\n" @@ -458,6 +469,10 @@ void Settings::usage() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Settings::saveConfig() { + // Ask all subsystems to save their settings + if(&(myOSystem->frameBuffer())) + myOSystem->frameBuffer().ntsc().saveConfig(*this); + // Do a quick scan of the internal settings to see if any have // changed. If not, we don't need to save them at all. bool settingsChanged = false; diff --git a/src/gui/VideoDialog.cxx b/src/gui/VideoDialog.cxx index 24f0acd90..320c18c0a 100644 --- a/src/gui/VideoDialog.cxx +++ b/src/gui/VideoDialog.cxx @@ -242,7 +242,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, // 2) TV effects options wid.clear(); tabID = myTab->addTab(" TV Effects "); - xpos = ypos = 5; + xpos = ypos = 8; // TV Mode items.clear(); @@ -262,6 +262,7 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, // Custom adjustables (using macro voodoo) xpos += 8; ypos += 4; + int orig_ypos = ypos; pwidth = lwidth; lwidth = font.getStringWidth("Saturation: "); @@ -277,19 +278,52 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, myTV ## obj->setFlags(WIDGET_CLEARBG); \ ypos += lineHeight + 4 + CREATE_CUSTOM_SLIDERS(Contrast, "Contrast: "); + CREATE_CUSTOM_SLIDERS(Bright, "Brightness: "); + CREATE_CUSTOM_SLIDERS(Hue, "Hue: "); + CREATE_CUSTOM_SLIDERS(Satur, "Saturation: "); + CREATE_CUSTOM_SLIDERS(Gamma, "Gamma: "); CREATE_CUSTOM_SLIDERS(Sharp, "Sharpness: "); CREATE_CUSTOM_SLIDERS(Res, "Resolution: "); CREATE_CUSTOM_SLIDERS(Artifacts, "Artifacts: "); CREATE_CUSTOM_SLIDERS(Fringe, "Fringing: "); - CREATE_CUSTOM_SLIDERS(Blend, "Blending: "); - CREATE_CUSTOM_SLIDERS(Bright, "Brightness: "); - CREATE_CUSTOM_SLIDERS(Contrast, "Contrast: "); - CREATE_CUSTOM_SLIDERS(Satur, "Saturation: "); - CREATE_CUSTOM_SLIDERS(Gamma, "Gamma: "); + CREATE_CUSTOM_SLIDERS(Bleed, "Bleeding: "); + xpos += myTVContrast->getWidth() + myTVContrastLabel->getWidth() + 20; + ypos = orig_ypos; + // Scanline intensity and interpolation + myTVScanLabel = + new StaticTextWidget(myTab, font, xpos, ypos, font.getStringWidth("Scanline settings:"), + fontHeight, "Scanline settings:", kTextAlignLeft); + ypos += lineHeight; + xpos += 20; + lwidth = font.getStringWidth("Intensity: "); + pwidth = font.getMaxCharWidth() * 6; + CREATE_CUSTOM_SLIDERS(ScanIntense, "Intensity: "); + myTVScanInterpolate = new CheckboxWidget(myTab, font, xpos, ypos, + "Interpolation"); + wid.push_back(myTVScanInterpolate); + ypos += lineHeight + 4; + + // Adjustable presets + xpos -= 20; + int cloneWidth = font.getStringWidth("Clone Bad Adjust") + 20; +#define CREATE_CLONE_BUTTON(obj, desc) \ + myClone ## obj = \ + new ButtonWidget(myTab, font, xpos, ypos, cloneWidth, buttonHeight,\ + desc, kClone ## obj ##Cmd); \ + wid.push_back(myClone ## obj); \ + ypos += lineHeight + 10 + + ypos += lineHeight; + CREATE_CLONE_BUTTON(Composite, "Clone Composite"); + CREATE_CLONE_BUTTON(Svideo, "Clone S-Video"); + CREATE_CLONE_BUTTON(RGB, "Clone RGB"); + CREATE_CLONE_BUTTON(Bad, "Clone Bad Adjust"); + CREATE_CLONE_BUTTON(Custom, "Revert"); // Add items for tab 2 addToFocusList(wid, tabID); @@ -315,6 +349,39 @@ VideoDialog::VideoDialog(OSystem* osystem, DialogContainer* parent, myPAspectRatioLabel->clearFlags(WIDGET_ENABLED); myGLStretchCheckbox->clearFlags(WIDGET_ENABLED); myUseVSyncCheckbox->clearFlags(WIDGET_ENABLED); + + myTVMode->clearFlags(WIDGET_ENABLED); + myTVSharp->clearFlags(WIDGET_ENABLED); + myTVSharpLabel->clearFlags(WIDGET_ENABLED); + myTVHue->clearFlags(WIDGET_ENABLED); + myTVHueLabel->clearFlags(WIDGET_ENABLED); + myTVRes->clearFlags(WIDGET_ENABLED); + myTVResLabel->clearFlags(WIDGET_ENABLED); + myTVArtifacts->clearFlags(WIDGET_ENABLED); + myTVArtifactsLabel->clearFlags(WIDGET_ENABLED); + myTVFringe->clearFlags(WIDGET_ENABLED); + myTVFringeLabel->clearFlags(WIDGET_ENABLED); + myTVBleed->clearFlags(WIDGET_ENABLED); + myTVBleedLabel->clearFlags(WIDGET_ENABLED); + myTVBright->clearFlags(WIDGET_ENABLED); + myTVBrightLabel->clearFlags(WIDGET_ENABLED); + myTVContrast->clearFlags(WIDGET_ENABLED); + myTVContrastLabel->clearFlags(WIDGET_ENABLED); + myTVSatur->clearFlags(WIDGET_ENABLED); + myTVSaturLabel->clearFlags(WIDGET_ENABLED); + myTVGamma->clearFlags(WIDGET_ENABLED); + myTVGammaLabel->clearFlags(WIDGET_ENABLED); + + myTVScanLabel->clearFlags(WIDGET_ENABLED); + myTVScanIntense->clearFlags(WIDGET_ENABLED); + myTVScanIntenseLabel->clearFlags(WIDGET_ENABLED); + myTVScanInterpolate->clearFlags(WIDGET_ENABLED); + + myCloneComposite->clearFlags(WIDGET_ENABLED); + myCloneSvideo->clearFlags(WIDGET_ENABLED); + myCloneRGB->clearFlags(WIDGET_ENABLED); + myCloneBad->clearFlags(WIDGET_ENABLED); + myCloneCustom->clearFlags(WIDGET_ENABLED); #endif #ifndef WINDOWED_SUPPORT myFullscreenCheckbox->clearFlags(WIDGET_ENABLED); @@ -362,9 +429,9 @@ void VideoDialog::loadConfig() instance().settings().getString("timing"), "sleep"); // GL Filter setting -// FIXME - myGLFilterPopup->setSelected( - instance().settings().getString("gl_filter"), "nearest"); + const string& gl_inter = instance().settings().getBool("gl_inter") ? + "linear" : "nearest"; + myGLFilterPopup->setSelected(gl_inter, "nearest"); myGLFilterPopup->setEnabled(gl); // GL aspect ratio setting (NTSC and PAL) @@ -411,8 +478,16 @@ void VideoDialog::loadConfig() // TV Mode myTVMode->setSelected( instance().settings().getString("tv_filter"), "0"); - handleTVModeChange(instance().settings().getInt("tv_filter") == - (int)NTSCFilter::PRESET_CUSTOM); + int preset = instance().settings().getInt("tv_filter"); + handleTVModeChange((NTSCFilter::Preset)preset); + + // TV Custom adjustables + loadTVAdjustables(NTSCFilter::PRESET_CUSTOM); + + // TV scanline intensity and interpolation + myTVScanIntense->setValue(instance().settings().getInt("tv_scanlines")); + myTVScanIntenseLabel->setLabel(instance().settings().getString("tv_scanlines")); + myTVScanInterpolate->setState(instance().settings().getBool("tv_scaninter")); myTab->loadConfig(); } @@ -436,7 +511,8 @@ void VideoDialog::saveConfig() instance().settings().setString("timing", myFrameTimingPopup->getSelectedTag()); // GL Filter setting - instance().settings().setString("gl_filter", myGLFilterPopup->getSelectedTag()); + instance().settings().setBool("gl_inter", + myGLFilterPopup->getSelectedTag() == "linear" ? true : false); // GL aspect ratio setting (NTSC and PAL) instance().settings().setString("gl_aspectn", myNAspectRatioLabel->getLabel()); @@ -478,8 +554,23 @@ void VideoDialog::saveConfig() // TV Mode instance().settings().setString("tv_filter", myTVMode->getSelectedTag()); + // TV Custom adjustables + NTSCFilter::Adjustable adj; + adj.hue = myTVHue->getValue(); + adj.saturation = myTVSatur->getValue(); + adj.contrast = myTVContrast->getValue(); + adj.brightness = myTVBright->getValue(); + adj.sharpness = myTVSharp->getValue(); + adj.gamma = myTVGamma->getValue(); + adj.resolution = myTVRes->getValue(); + adj.artifacts = myTVArtifacts->getValue(); + adj.fringing = myTVFringe->getValue(); + adj.bleed = myTVBleed->getValue(); + instance().frameBuffer().ntsc().setCustomAdjustables(adj); - + // TV scanline intensity and interpolation + instance().settings().setString("tv_scanlines", myTVScanIntenseLabel->getLabel()); + instance().settings().setBool("tv_scaninter", myTVScanInterpolate->getState()); // Finally, issue a complete framebuffer re-initialization instance().createFrameBuffer(); @@ -512,9 +603,15 @@ void VideoDialog::setDefaults() myTVMode->setSelected("0", "0"); + // TV scanline intensity and interpolation + myTVScanIntense->setValue(40); + myTVScanIntenseLabel->setLabel("40"); + myTVScanInterpolate->setState(true); + // Make sure that mutually-exclusive items are not enabled at the same time handleFullscreenChange(true); - handleTVModeChange(false); + handleTVModeChange(NTSCFilter::PRESET_OFF); + loadTVAdjustables(NTSCFilter::PRESET_CUSTOM); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -527,18 +624,32 @@ void VideoDialog::handleFullscreenChange(bool enable) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void VideoDialog::handleTVModeChange(bool enable) +void VideoDialog::handleTVModeChange(NTSCFilter::Preset preset) { + bool enable = true, scanenable = true; + if(!instance().frameBuffer().type() == kDoubleBuffer) + { + enable = scanenable = false; + myTVMode->setEnabled(enable); + } + else + { + enable = preset == NTSCFilter::PRESET_CUSTOM; + scanenable = preset != NTSCFilter::PRESET_OFF; + } + myTVSharp->setEnabled(enable); myTVSharpLabel->setEnabled(enable); + myTVHue->setEnabled(enable); + myTVHueLabel->setEnabled(enable); myTVRes->setEnabled(enable); myTVResLabel->setEnabled(enable); myTVArtifacts->setEnabled(enable); myTVArtifactsLabel->setEnabled(enable); myTVFringe->setEnabled(enable); myTVFringeLabel->setEnabled(enable); - myTVBlend->setEnabled(enable); - myTVBlendLabel->setEnabled(enable); + myTVBleed->setEnabled(enable); + myTVBleedLabel->setEnabled(enable); myTVBright->setEnabled(enable); myTVBrightLabel->setEnabled(enable); myTVContrast->setEnabled(enable); @@ -547,10 +658,47 @@ void VideoDialog::handleTVModeChange(bool enable) myTVSaturLabel->setEnabled(enable); myTVGamma->setEnabled(enable); myTVGammaLabel->setEnabled(enable); + myCloneComposite->setEnabled(enable); + myCloneSvideo->setEnabled(enable); + myCloneRGB->setEnabled(enable); + myCloneBad->setEnabled(enable); + myCloneCustom->setEnabled(enable); + + myTVScanLabel->setEnabled(scanenable); + myTVScanIntense->setEnabled(scanenable); + myTVScanIntenseLabel->setEnabled(scanenable); + myTVScanInterpolate->setEnabled(scanenable); _dirty = true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void VideoDialog::loadTVAdjustables(NTSCFilter::Preset preset) +{ + NTSCFilter::Adjustable adj; + instance().frameBuffer().ntsc().getAdjustables(adj, (NTSCFilter::Preset)preset); + myTVSharp->setValue(adj.sharpness); + myTVSharpLabel->setValue(adj.sharpness); + myTVHue->setValue(adj.hue); + myTVHueLabel->setValue(adj.hue); + myTVRes->setValue(adj.resolution); + myTVResLabel->setValue(adj.resolution); + myTVArtifacts->setValue(adj.artifacts); + myTVArtifactsLabel->setValue(adj.artifacts); + myTVFringe->setValue(adj.fringing); + myTVFringeLabel->setValue(adj.fringing); + myTVBleed->setValue(adj.bleed); + myTVBleedLabel->setValue(adj.bleed); + myTVBright->setValue(adj.brightness); + myTVBrightLabel->setValue(adj.brightness); + myTVContrast->setValue(adj.contrast); + myTVContrastLabel->setValue(adj.contrast); + myTVSatur->setValue(adj.saturation); + myTVSaturLabel->setValue(adj.saturation); + myTVGamma->setValue(adj.gamma); + myTVGammaLabel->setValue(adj.gamma); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void VideoDialog::handleCommand(CommandSender* sender, int cmd, int data, int id) @@ -585,15 +733,20 @@ void VideoDialog::handleCommand(CommandSender* sender, int cmd, handleFullscreenChange(myFullscreenPopup->getSelectedTag() != "-1"); break; + case kTVModeChanged: + handleTVModeChange((NTSCFilter::Preset)atoi(myTVMode->getSelectedTag().c_str())); + case kTVSharpChanged: myTVSharpLabel->setValue(myTVSharp->getValue()); break; + case kTVHueChanged: myTVHueLabel->setValue(myTVHue->getValue()); + break; case kTVResChanged: myTVResLabel->setValue(myTVRes->getValue()); break; case kTVArtifactsChanged: myTVArtifactsLabel->setValue(myTVArtifacts->getValue()); break; case kTVFringeChanged: myTVFringeLabel->setValue(myTVFringe->getValue()); break; - case kTVBlendChanged: myTVBlendLabel->setValue(myTVBlend->getValue()); + case kTVBleedChanged: myTVBleedLabel->setValue(myTVBleed->getValue()); break; case kTVBrightChanged: myTVBrightLabel->setValue(myTVBright->getValue()); break; @@ -603,10 +756,18 @@ void VideoDialog::handleCommand(CommandSender* sender, int cmd, break; case kTVGammaChanged: myTVGammaLabel->setValue(myTVGamma->getValue()); break; + case kTVScanIntenseChanged: myTVScanIntenseLabel->setValue(myTVScanIntense->getValue()); + break; - case kTVModeChanged: - handleTVModeChange(atoi(myTVMode->getSelectedTag().c_str()) == - (int)NTSCFilter::PRESET_CUSTOM); + case kCloneCompositeCmd: loadTVAdjustables(NTSCFilter::PRESET_COMPOSITE); + break; + case kCloneSvideoCmd: loadTVAdjustables(NTSCFilter::PRESET_SVIDEO); + break; + case kCloneRGBCmd: loadTVAdjustables(NTSCFilter::PRESET_RGB); + break; + case kCloneBadCmd: loadTVAdjustables(NTSCFilter::PRESET_BAD); + break; + case kCloneCustomCmd: loadTVAdjustables(NTSCFilter::PRESET_CUSTOM); break; default: diff --git a/src/gui/VideoDialog.hxx b/src/gui/VideoDialog.hxx index 875d47db4..149409068 100644 --- a/src/gui/VideoDialog.hxx +++ b/src/gui/VideoDialog.hxx @@ -49,7 +49,8 @@ class VideoDialog : public Dialog void setDefaults(); void handleFullscreenChange(bool enable); - void handleTVModeChange(bool enable); + void handleTVModeChange(NTSCFilter::Preset); + void loadTVAdjustables(NTSCFilter::Preset preset); virtual void handleCommand(CommandSender* sender, int cmd, int data, int id); private: @@ -78,18 +79,20 @@ class VideoDialog : public Dialog CheckboxWidget* myCenterCheckbox; CheckboxWidget* myFastSCBiosCheckbox; - // TV effects options + // TV effects adjustables (custom mode) PopUpWidget* myTVMode; SliderWidget* myTVSharp; StaticTextWidget* myTVSharpLabel; + SliderWidget* myTVHue; + StaticTextWidget* myTVHueLabel; SliderWidget* myTVRes; StaticTextWidget* myTVResLabel; SliderWidget* myTVArtifacts; StaticTextWidget* myTVArtifactsLabel; SliderWidget* myTVFringe; StaticTextWidget* myTVFringeLabel; - SliderWidget* myTVBlend; - StaticTextWidget* myTVBlendLabel; + SliderWidget* myTVBleed; + StaticTextWidget* myTVBleedLabel; SliderWidget* myTVBright; StaticTextWidget* myTVBrightLabel; SliderWidget* myTVContrast; @@ -99,6 +102,19 @@ class VideoDialog : public Dialog SliderWidget* myTVGamma; StaticTextWidget* myTVGammaLabel; + // TV scanline intensity and interpolation + StaticTextWidget* myTVScanLabel; + SliderWidget* myTVScanIntense; + StaticTextWidget* myTVScanIntenseLabel; + CheckboxWidget* myTVScanInterpolate; + + // TV effects adjustables presets (custom mode) + ButtonWidget* myCloneComposite; + ButtonWidget* myCloneSvideo; + ButtonWidget* myCloneRGB; + ButtonWidget* myCloneBad; + ButtonWidget* myCloneCustom; + enum { kNAspectRatioChanged = 'VDan', kPAspectRatioChanged = 'VDap', @@ -107,15 +123,22 @@ class VideoDialog : public Dialog kTVModeChanged = 'VDtv', kTVSharpChanged = 'TVsh', + kTVHueChanged = 'TVhu', kTVResChanged = 'TVrs', kTVArtifactsChanged = 'TVar', kTVFringeChanged = 'TVfr', - kTVBlendChanged = 'TVbl', + kTVBleedChanged = 'TVbl', kTVBrightChanged = 'TVbr', kTVContrastChanged = 'TVct', kTVSaturChanged = 'TVsa', kTVGammaChanged = 'TVga', - kTVScanChanged = 'TVsc' + kTVScanIntenseChanged= 'TVsc', + + kCloneCompositeCmd = 'CLcp', + kCloneSvideoCmd = 'CLsv', + kCloneRGBCmd = 'CLrb', + kCloneBadCmd = 'CLbd', + kCloneCustomCmd = 'CLcu' }; };