NTSC filter was missing the newer more accurate support for emphasis (was using an old 1-emph-per-blit approximation)

This commit is contained in:
Brad Smith 2018-06-19 23:06:55 -04:00
parent 386545e063
commit e8c61d1b23
4 changed files with 15 additions and 10 deletions

View File

@ -242,15 +242,16 @@ void nes_ntsc_init( nes_ntsc_t* ntsc, nes_ntsc_setup_t const* setup, int bpp )
#ifndef NES_NTSC_NO_BLITTERS #ifndef NES_NTSC_NO_BLITTERS
void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* input, long in_row_width, void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* input, NES_NTSC_IN_T const* inputD, long in_row_width,
int burst_phase, int emphasis, int in_width, int in_height, void* rgb_out, long out_pitch ) int burst_phase, int in_width, int in_height, void* rgb_out, long out_pitch )
{ {
int chunk_count = (in_width - 1) / nes_ntsc_in_chunk; int chunk_count = (in_width - 1) / nes_ntsc_in_chunk;
for ( ; in_height; --in_height ) for ( ; in_height; --in_height )
{ {
NES_NTSC_IN_T const* line_in = input; NES_NTSC_IN_T const* line_in = input;
NES_NTSC_BEGIN_ROW( ntsc, burst_phase, nes_ntsc_black, nes_ntsc_black, NES_NTSC_ADJ_IN( *line_in ) ); NES_NTSC_IN_T const* line_inD = inputD;
NES_NTSC_BEGIN_ROW( ntsc, burst_phase, nes_ntsc_black, nes_ntsc_black, NES_NTSC_ADJ_IN( *line_in, *line_inD ) );
nes_ntsc_out_t* restrict line_out = (nes_ntsc_out_t*) rgb_out; nes_ntsc_out_t* restrict line_out = (nes_ntsc_out_t*) rgb_out;
int n; int n;
++line_in; ++line_in;
@ -259,20 +260,21 @@ void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* input, long in_
{ {
/* order of input and output pixels must not be altered */ /* order of input and output pixels must not be altered */
NES_NTSC_COLOR_IN( 0, NES_NTSC_ADJ_IN( line_in [0] ) ); NES_NTSC_COLOR_IN( 0, NES_NTSC_ADJ_IN( line_in [0], line_inD [0] ) );
NES_NTSC_RGB_OUT( 0, line_out [0], OutputDepth ); NES_NTSC_RGB_OUT( 0, line_out [0], OutputDepth );
NES_NTSC_RGB_OUT( 1, line_out [1], OutputDepth ); NES_NTSC_RGB_OUT( 1, line_out [1], OutputDepth );
NES_NTSC_COLOR_IN( 1, NES_NTSC_ADJ_IN( line_in [1] ) ); NES_NTSC_COLOR_IN( 1, NES_NTSC_ADJ_IN( line_in [1], line_inD [1] ) );
NES_NTSC_RGB_OUT( 2, line_out [2], OutputDepth ); NES_NTSC_RGB_OUT( 2, line_out [2], OutputDepth );
NES_NTSC_RGB_OUT( 3, line_out [3], OutputDepth ); NES_NTSC_RGB_OUT( 3, line_out [3], OutputDepth );
NES_NTSC_COLOR_IN( 2, NES_NTSC_ADJ_IN( line_in [2] ) ); NES_NTSC_COLOR_IN( 2, NES_NTSC_ADJ_IN( line_in [2], line_inD [2] ) );
NES_NTSC_RGB_OUT( 4, line_out [4], OutputDepth ); NES_NTSC_RGB_OUT( 4, line_out [4], OutputDepth );
NES_NTSC_RGB_OUT( 5, line_out [5], OutputDepth ); NES_NTSC_RGB_OUT( 5, line_out [5], OutputDepth );
NES_NTSC_RGB_OUT( 6, line_out [6], OutputDepth ); NES_NTSC_RGB_OUT( 6, line_out [6], OutputDepth );
line_in += 3; line_in += 3;
line_inD += 3;
line_out += rescale_out; line_out += rescale_out;
} }
@ -293,6 +295,7 @@ void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* input, long in_
burst_phase = (burst_phase + 1) % nes_ntsc_burst_count; burst_phase = (burst_phase + 1) % nes_ntsc_burst_count;
input += in_row_width; input += in_row_width;
inputD += in_row_width;
} }
} }

View File

@ -61,8 +61,8 @@ In_row_width is the number of pixels to get to the next input row. Emphasis is
the emphasis bits to bitwise-OR with all pixels in the input data. Out_pitch the emphasis bits to bitwise-OR with all pixels in the input data. Out_pitch
is the number of *bytes* to get to the next output row. Output pixel format is the number of *bytes* to get to the next output row. Output pixel format
is set by NES_NTSC_OUT_DEPTH (defaults to 16-bit RGB). */ is set by NES_NTSC_OUT_DEPTH (defaults to 16-bit RGB). */
void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* nes_in, void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* nes_in, NES_NTSC_IN_T const* nes_inD,
long in_row_width, int burst_phase, int emphasis, int in_width, long in_row_width, int burst_phase, int in_width,
int in_height, void* rgb_out, long out_pitch ); int in_height, void* rgb_out, long out_pitch );
/* Number of output pixels written by blitter for given input width. Width might /* Number of output pixels written by blitter for given input width. Width might

View File

@ -21,7 +21,7 @@ if you enable emphasis above. */
// CUSTOM: (XBuf uses bit 0x80, and has palettes above 0x3f for LUA) // CUSTOM: (XBuf uses bit 0x80, and has palettes above 0x3f for LUA)
/* Each raw pixel input value is passed through this. You might want to mask /* Each raw pixel input value is passed through this. You might want to mask
the pixel index if you use the high bits as flags, etc. */ the pixel index if you use the high bits as flags, etc. */
#define NES_NTSC_ADJ_IN( in ) ((in & 0x3f) | emphasis) #define NES_NTSC_ADJ_IN( in, inD ) ((in & 0x3F) | (inD << 6))
/* For each pixel, this is the basic operation: /* For each pixel, this is the basic operation:
output_color = color_palette [NES_NTSC_ADJ_IN( NES_NTSC_IN_T )] */ output_color = color_palette [NES_NTSC_ADJ_IN( NES_NTSC_IN_T )] */

View File

@ -811,7 +811,9 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale,
int outxr = 301; int outxr = 301;
//if(xr == 282) outxr = 282; //hack for windows //if(xr == 282) outxr = 282; //hack for windows
burst_phase ^= 1; burst_phase ^= 1;
nes_ntsc_blit( nes_ntsc, (unsigned char*)src, xr, burst_phase, (PPU[1] >> 5) << 6, xr, yr, ntscblit, (2*outxr) * Bpp );
u8* srcD = XDBuf + (src-XBuf); // get deemphasis buffer
nes_ntsc_blit( nes_ntsc, (unsigned char*)src, (unsigned char*)srcD, xr, burst_phase, xr, yr, ntscblit, (2*outxr) * Bpp );
const uint8 *in = ntscblit + (Bpp * xscale); const uint8 *in = ntscblit + (Bpp * xscale);
uint8 *out = dest; uint8 *out = dest;