diff --git a/Makefile b/Makefile index 808cd0628..0c4ff4289 100644 --- a/Makefile +++ b/Makefile @@ -95,7 +95,8 @@ MODULES := $(MODULES) MODULES += \ src/emucore \ src/gui \ - src/common + src/common \ + src/common/tv_filters ###################################################################### # The build rules follow - normally you should have no need to diff --git a/configure b/configure index 5ca5c58ac..b589003d6 100755 --- a/configure +++ b/configure @@ -20,7 +20,6 @@ _zlib=auto # default option behaviour yes/no _build_gl=yes -_build_tv=yes _build_windowed=yes _build_sound=yes _build_debugger=yes @@ -245,8 +244,6 @@ for ac_option in $@; do case "$ac_option" in --enable-gl) _build_gl=yes ;; --disable-gl) _build_gl=no ;; - --enable-tv) _build_tv=yes ;; - --disable-tv) _build_tv=no ;; --enable-windowed) _build_windowed=yes ;; --disable-windowed) _build_windowed=no ;; --enable-sound) _build_sound=yes ;; @@ -658,14 +655,6 @@ else echo fi -if test "$_build_tv" = "yes" ; then - echo_n " TV filtering enabled" - echo -else - echo_n " TV filtering disabled" - echo -fi - if test "$_build_windowed" = "yes" ; then echo_n " Windowed rendering modes enabled" echo @@ -757,7 +746,7 @@ CHEAT="$SRC/cheat" LIBPNG="$SRC/libpng" ZLIB="$SRC/zlib" -INCLUDES="-I$CORE -I$COMMON -I$GUI" +INCLUDES="-I$CORE -I$COMMON -I$TV -I$GUI" INCLUDES="$INCLUDES `$_sdlconfig --cflags`" if test "$_build_static" = yes ; then @@ -829,12 +818,6 @@ if test "$_build_gl" = yes ; then DEFINES="$DEFINES -DDISPLAY_OPENGL" fi -if test "$_build_tv" = yes ; then - DEFINES="$DEFINES -DDISPLAY_TV" - MODULES="$MODULES $TV" - INCLUDES="$INCLUDES -I$TV" -fi - if test "$_build_windowed" = yes ; then DEFINES="$DEFINES -DWINDOWED_SUPPORT" fi diff --git a/src/common/tv_filters/NTSCFilter.cxx b/src/common/tv_filters/NTSCFilter.cxx index 84457d96b..fbd0f89b4 100644 --- a/src/common/tv_filters/NTSCFilter.cxx +++ b/src/common/tv_filters/NTSCFilter.cxx @@ -17,8 +17,6 @@ // $Id$ //============================================================================ -#ifdef DISPLAY_TV - #include "NTSCFilter.hxx" #include @@ -37,10 +35,25 @@ NTSCFilter::~NTSCFilter() { } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void NTSCFilter::setTIAPalette(const uInt32* palette) +{ + // The TIA palette consists of 128 colours, but the palette array actually + // contains 256 entries, where only every second value is a valid colour + uInt8* ptr = myTIAPalette; + for(int i = 0; i < 256; i+=2) + { + *ptr++ = (palette[i] >> 16) & 0xff; + *ptr++ = (palette[i] >> 8) & 0xff; + *ptr++ = palette[i] & 0xff; + } + updateFilter(); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void NTSCFilter::updateFilter() { - double yiq_table[768]; + double yiq_table[384]; updateYIQTable(yiq_table, mySetup.burst_phase * M_PI); @@ -231,16 +244,16 @@ int NTSCFilter::FILTER_NTSC_Initialise(int *argc, char *argv[]) #endif // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void NTSCFilter::updateYIQTable(double yiq_table[768], double start_angle) +void NTSCFilter::updateYIQTable(double yiq_table[384], double start_angle) { const double start_saturation = 0.0; // calculated internally const double gamma = 1; // 1 - COLOURS_NTSC_setup.gamma / 2.0; - unsigned char *ext_ptr = NULL; //FIXME COLOURS_NTSC_external.palette; + uInt8* ext_ptr = myTIAPalette; int n; start_angle = - ((213.0f) * M_PI / 180.0f) - start_angle; - for (n = 0; n < 256; n ++) { + for (n = 0; n < 128; n ++) { /* Convert RGB values from external palette to YIQ. */ double r = (double)*ext_ptr++ / 255.0; double g = (double)*ext_ptr++ / 255.0; @@ -288,5 +301,3 @@ static char const * const preset_cfg_strings[NTSCFilter::PRESET_SIZE] = { "RGB", "MONOCHROME" }; - -#endif // DISPLAY_TV diff --git a/src/common/tv_filters/NTSCFilter.hxx b/src/common/tv_filters/NTSCFilter.hxx index f372e75a1..d92fda03d 100644 --- a/src/common/tv_filters/NTSCFilter.hxx +++ b/src/common/tv_filters/NTSCFilter.hxx @@ -20,8 +20,6 @@ #ifndef NTSC_FILTER_HXX #define NTSC_FILTER_HXX -#ifdef DISPLAY_TV - #include "bspf.hxx" #include "Array.hxx" #include "atari_ntsc.h" @@ -67,6 +65,11 @@ class NTSCFilter }; public: + /* Informs the NTSC filter about the current TIA palette. The filter + uses this as a baseline for calculating its own internal palette + in YIQ format. + */ + void setTIAPalette(const uInt32* palette); /* Restores default values for NTSC-filter-specific colour controls. updateFilter should be called afterwards to apply changes. */ @@ -95,7 +98,7 @@ class NTSCFilter are provided as parameters, because NTSC_FILTER needs to set these values according to its internal setup (burst_phase etc). */ - static void updateYIQTable(double yiq_table[768], double start_angle); + void updateYIQTable(double yiq_table[768], double start_angle); private: // Pointer to the NTSC filter structure @@ -104,6 +107,8 @@ class NTSCFilter // Contains controls used to adjust the palette in the NTSC filter atari_ntsc_setup_t mySetup; + uInt8 myTIAPalette[384]; // 128 colours by 3 components per colour + int myCurrentModeNum; Common::Array myModeList; @@ -111,6 +116,4 @@ class NTSCFilter static char const * const preset_cfg_strings[PRESET_SIZE]; }; -#endif // DISPLAY_TV - #endif diff --git a/src/common/tv_filters/atari_ntsc.c b/src/common/tv_filters/atari_ntsc.c index 485166757..a4477eec0 100644 --- a/src/common/tv_filters/atari_ntsc.c +++ b/src/common/tv_filters/atari_ntsc.c @@ -19,8 +19,6 @@ /* Based on nes_ntsc 0.2.2. http://www.slack.net/~ant/ */ -#ifdef DISPLAY_TV - #include "atari_ntsc.h" /* Copyright (C) 2006-2007 Shay Green. This module is free software; you @@ -393,5 +391,3 @@ void atari_ntsc_blit_bgra32( atari_ntsc_t const* ntsc, ATARI_NTSC_IN_T const* in } #endif - -#endif // DISPLAY_TV diff --git a/src/common/tv_filters/atari_ntsc.h b/src/common/tv_filters/atari_ntsc.h index 657bb6cff..925fa580b 100644 --- a/src/common/tv_filters/atari_ntsc.h +++ b/src/common/tv_filters/atari_ntsc.h @@ -17,8 +17,6 @@ // $Id$ //============================================================================ -#ifdef DISPLAY_TV - /* Atari TIA, CTIA, GTIA and MARIA NTSC video filter */ /* based on nes_ntsc 0.2.2 */ @@ -264,5 +262,3 @@ enum { #endif #endif - -#endif // DISPLAY_TV diff --git a/src/common/tv_filters/atari_ntsc_impl.h b/src/common/tv_filters/atari_ntsc_impl.h index e04dd16b8..774632167 100644 --- a/src/common/tv_filters/atari_ntsc_impl.h +++ b/src/common/tv_filters/atari_ntsc_impl.h @@ -17,8 +17,6 @@ // $Id$ //============================================================================ -#ifdef DISPLAY_TV - /* Based on nes_ntsc 0.2.2. http://www.slack.net/~ant/ */ /* Common implementation of NTSC filters */ @@ -474,5 +472,3 @@ static void correct_errors( atari_ntsc_rgb_t color, atari_ntsc_rgb_t* out ); #endif #endif - -#endif // DISPLAY_TV diff --git a/src/macosx/stella.xcodeproj/project.pbxproj b/src/macosx/stella.xcodeproj/project.pbxproj index 28e90f2f5..bca0aa780 100644 --- a/src/macosx/stella.xcodeproj/project.pbxproj +++ b/src/macosx/stella.xcodeproj/project.pbxproj @@ -1897,7 +1897,6 @@ HAVE_INTTYPES, HAVE_GETTIMEOFDAY, DISPLAY_OPENGL, - DISPLAY_TV, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, @@ -1960,7 +1959,6 @@ HAVE_INTTYPES, HAVE_GETTIMEOFDAY, DISPLAY_OPENGL, - DISPLAY_TV, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, @@ -2022,7 +2020,6 @@ HAVE_INTTYPES, HAVE_GETTIMEOFDAY, DISPLAY_OPENGL, - DISPLAY_TV, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, diff --git a/src/macosx/stella_intel.xcodeproj/project.pbxproj b/src/macosx/stella_intel.xcodeproj/project.pbxproj index b93f294b4..4ac8378d2 100644 --- a/src/macosx/stella_intel.xcodeproj/project.pbxproj +++ b/src/macosx/stella_intel.xcodeproj/project.pbxproj @@ -1881,7 +1881,6 @@ HAVE_INTTYPES, HAVE_GETTIMEOFDAY, DISPLAY_OPENGL, - DISPLAY_TV, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, @@ -1937,7 +1936,6 @@ HAVE_INTTYPES, HAVE_GETTIMEOFDAY, DISPLAY_OPENGL, - DISPLAY_TV, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT, @@ -1992,7 +1990,6 @@ HAVE_INTTYPES, HAVE_GETTIMEOFDAY, DISPLAY_OPENGL, - DISPLAY_TV, CHEATCODE_SUPPORT, DEBUGGER_SUPPORT, JOYSTICK_SUPPORT,