diff --git a/src/drivers/common/nes_ntsc.c b/src/drivers/common/nes_ntsc.c index 36c8eb15..c0edbb36 100644 --- a/src/drivers/common/nes_ntsc.c +++ b/src/drivers/common/nes_ntsc.c @@ -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 -void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* input, long in_row_width, - int burst_phase, int emphasis, int in_width, int in_height, void* rgb_out, long out_pitch ) +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 in_width, int in_height, void* rgb_out, long out_pitch ) { int chunk_count = (in_width - 1) / nes_ntsc_in_chunk; for ( ; in_height; --in_height ) { 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; int n; ++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 */ - 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( 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( 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( 5, line_out [5], OutputDepth ); NES_NTSC_RGB_OUT( 6, line_out [6], OutputDepth ); line_in += 3; + line_inD += 3; 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; input += in_row_width; + inputD += in_row_width; } } diff --git a/src/drivers/common/nes_ntsc.h b/src/drivers/common/nes_ntsc.h index 8b629c69..7b148167 100644 --- a/src/drivers/common/nes_ntsc.h +++ b/src/drivers/common/nes_ntsc.h @@ -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 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). */ -void nes_ntsc_blit( nes_ntsc_t const* ntsc, NES_NTSC_IN_T const* nes_in, - long in_row_width, int burst_phase, int emphasis, int in_width, +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 in_width, int in_height, void* rgb_out, long out_pitch ); /* Number of output pixels written by blitter for given input width. Width might diff --git a/src/drivers/common/nes_ntsc_config.h b/src/drivers/common/nes_ntsc_config.h index 4808ac27..0dcf6263 100644 --- a/src/drivers/common/nes_ntsc_config.h +++ b/src/drivers/common/nes_ntsc_config.h @@ -21,7 +21,7 @@ if you enable emphasis above. */ // 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 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: output_color = color_palette [NES_NTSC_ADJ_IN( NES_NTSC_IN_T )] */ diff --git a/src/drivers/common/vidblit.cpp b/src/drivers/common/vidblit.cpp index fc881f53..7a3eb0f9 100644 --- a/src/drivers/common/vidblit.cpp +++ b/src/drivers/common/vidblit.cpp @@ -811,7 +811,9 @@ void Blit8ToHigh(uint8 *src, uint8 *dest, int xr, int yr, int pitch, int xscale, int outxr = 301; //if(xr == 282) outxr = 282; //hack for windows 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); uint8 *out = dest;