From 6f60437a9ceef9fade40977c1d1a5bbbf78b8476 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Tue, 15 Aug 2017 17:49:59 -0230 Subject: [PATCH] Improve Blargg filters with cutoff on right side of screen (fixes #195). --- Changes.txt | 10 +++--- src/common/tv_filters/AtariNTSC.cxx | 55 +++++++++++++++++++++++++++-- src/common/tv_filters/AtariNTSC.hxx | 4 +-- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/Changes.txt b/Changes.txt index a1434a111..7a5e8b597 100644 --- a/Changes.txt +++ b/Changes.txt @@ -21,11 +21,13 @@ * Added preliminary support for multi-threading in the Blargg TV effects code. This is still a WIP; more improvements are coming. Related to - this, further optimized the TIA rendering code. Thanks to Thomas - Jentzsch for the bulk of the work in this area. + this, further optimized the TIA rendering code. Also added 'threads' + commandline argument and associated UI item to enable/disable + multi-threading. Thanks to Thomas Jentzsch for the bulk of the work + in this area. - * Added 'threads' commandline argument and associated UI item to - enable/disable multi-threading. + * Blargg TV effects now no longer cut off the right side of the image + (by several pixels) in certain cases. * Updated CDF scheme to latest version from Spiceware. In addition, this scheme now supports versioning, so older and newer ROMs will diff --git a/src/common/tv_filters/AtariNTSC.cxx b/src/common/tv_filters/AtariNTSC.cxx index 8079b9598..a16a3649a 100644 --- a/src/common/tv_filters/AtariNTSC.cxx +++ b/src/common/tv_filters/AtariNTSC.cxx @@ -151,7 +151,7 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width, } // finish final pixels - ATARI_NTSC_COLOR_IN(0, NTSC_black); + ATARI_NTSC_COLOR_IN(0, line_in[0]); ATARI_NTSC_RGB_OUT_8888(0, line_out[0]); ATARI_NTSC_RGB_OUT_8888(1, line_out[1]); ATARI_NTSC_RGB_OUT_8888(2, line_out[2]); @@ -162,6 +162,22 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width, ATARI_NTSC_RGB_OUT_8888(5, line_out[5]); ATARI_NTSC_RGB_OUT_8888(6, line_out[6]); + line_in += 2; + line_out += 7; + + ATARI_NTSC_COLOR_IN(0, NTSC_black); + ATARI_NTSC_RGB_OUT_8888(0, line_out[0]); + ATARI_NTSC_RGB_OUT_8888(1, line_out[1]); + ATARI_NTSC_RGB_OUT_8888(2, line_out[2]); + ATARI_NTSC_RGB_OUT_8888(3, line_out[3]); + + ATARI_NTSC_COLOR_IN(1, NTSC_black); + ATARI_NTSC_RGB_OUT_8888(4, line_out[4]); +#if 0 + ATARI_NTSC_RGB_OUT_8888(5, line_out[5]); + ATARI_NTSC_RGB_OUT_8888(6, line_out[6]); +#endif + atari_in += in_width; rgb_out = static_cast(rgb_out) + out_pitch; } @@ -208,7 +224,7 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_ } // finish final pixels - ATARI_NTSC_COLOR_IN(0, NTSC_black); + ATARI_NTSC_COLOR_IN(0, line_in[0]); ATARI_NTSC_RGB_OUT_8888(0, line_out[0]); ATARI_NTSC_RGB_OUT_8888(1, line_out[1]); ATARI_NTSC_RGB_OUT_8888(2, line_out[2]); @@ -219,8 +235,24 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_ ATARI_NTSC_RGB_OUT_8888(5, line_out[5]); ATARI_NTSC_RGB_OUT_8888(6, line_out[6]); + line_in += 2; + line_out += 7; + + ATARI_NTSC_COLOR_IN(0, NTSC_black); + ATARI_NTSC_RGB_OUT_8888(0, line_out[0]); + ATARI_NTSC_RGB_OUT_8888(1, line_out[1]); + ATARI_NTSC_RGB_OUT_8888(2, line_out[2]); + ATARI_NTSC_RGB_OUT_8888(3, line_out[3]); + + ATARI_NTSC_COLOR_IN(1, NTSC_black); + ATARI_NTSC_RGB_OUT_8888(4, line_out[4]); +#if 0 + ATARI_NTSC_RGB_OUT_8888(5, line_out[5]); + ATARI_NTSC_RGB_OUT_8888(6, line_out[6]); +#endif + // Do phosphor mode (blend the resulting frames) - // Note: The codes assumes that AtariNTSC::outWidth(kTIAW) == outPitch == 560 + // Note: The code assumes that AtariNTSC::outWidth(kTIAW) == outPitch == 565 for (uInt32 x = AtariNTSC::outWidth(in_width) / 8; x; --x) { // Store back into displayed frame buffer (for next frame) @@ -241,6 +273,23 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_ rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); bufofs++; } + // finish final pixels + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; +#if 0 + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; + rgb_in[bufofs] = getRGBPhosphor(out[bufofs], rgb_in[bufofs]); + bufofs++; +#endif atari_in += in_width; rgb_out = static_cast(rgb_out) + out_pitch; diff --git a/src/common/tv_filters/AtariNTSC.hxx b/src/common/tv_filters/AtariNTSC.hxx index 1ec08c8c0..d5dbecdda 100644 --- a/src/common/tv_filters/AtariNTSC.hxx +++ b/src/common/tv_filters/AtariNTSC.hxx @@ -102,14 +102,14 @@ class AtariNTSC // Might be rounded down slightly; use outWidth() on result to find // rounded value. static constexpr uInt32 inWidth( uInt32 out_width ) { - return (((out_width) / PIXEL_out_chunk - 1) * PIXEL_in_chunk + 1); + return (((out_width-5) / PIXEL_out_chunk - 1) * PIXEL_in_chunk + 1); } // Number of output pixels written by blitter for given input width. // Width might be rounded down slightly; use inWidth() on result to // find rounded value. Guaranteed not to round 160 down at all. static constexpr uInt32 outWidth(uInt32 in_width) { - return ((((in_width) - 1) / PIXEL_in_chunk + 1)* PIXEL_out_chunk); + return ((((in_width) - 1) / PIXEL_in_chunk + 1)* PIXEL_out_chunk) + 5; } private: