void Renderer::FilterNtsc::BlitType(const Input& input,const Output& output,uint phase) const { NST_ASSERT( phase < 3 ); const uint bgcolor = this->bgColor; const Input::Pixel* NST_RESTRICT src = input.pixels; Pixel* NST_RESTRICT dst = static_cast<Pixel*>(output.pixels); const long pad = output.pitch - (NTSC_WIDTH-7) * sizeof(Pixel); phase &= lut.noFieldMerging; for (uint y=HEIGHT; y; --y) { NES_NTSC_BEGIN_ROW( &lut, phase, bgcolor, bgcolor, *src++ ); for (const Input::Pixel* const end=src+(NTSC_WIDTH/7*3-3); src != end; src += 3, dst += 7) { NES_NTSC_COLOR_IN( 0, src[0] ); NES_NTSC_RGB_OUT( 0, dst[0], BITS ); NES_NTSC_RGB_OUT( 1, dst[1], BITS ); NES_NTSC_COLOR_IN( 1, src[1] ); NES_NTSC_RGB_OUT( 2, dst[2], BITS ); NES_NTSC_RGB_OUT( 3, dst[3], BITS ); NES_NTSC_COLOR_IN( 2, src[2] ); NES_NTSC_RGB_OUT( 4, dst[4], BITS ); NES_NTSC_RGB_OUT( 5, dst[5], BITS ); NES_NTSC_RGB_OUT( 6, dst[6], BITS ); } NES_NTSC_COLOR_IN( 0, bgcolor ); NES_NTSC_RGB_OUT( 0, dst[0], BITS ); NES_NTSC_RGB_OUT( 1, dst[1], BITS ); NES_NTSC_COLOR_IN( 1, bgcolor ); NES_NTSC_RGB_OUT( 2, dst[2], BITS ); NES_NTSC_RGB_OUT( 3, dst[3], BITS ); NES_NTSC_COLOR_IN( 2, bgcolor ); NES_NTSC_RGB_OUT( 4, dst[4], BITS ); NES_NTSC_RGB_OUT( 5, dst[5], BITS ); NES_NTSC_RGB_OUT( 6, dst[6], BITS ); dst = reinterpret_cast<Pixel*>(reinterpret_cast<byte*>(dst) + pad); phase = (phase + 1) % 3; } }
void Nes_Blitter::blit( Nes_Emu& emu, void* out, long out_pitch ) { short const* palette = emu.frame().palette; int burst_phase = (setup_.ntsc.merge_fields ? 0 : emu.frame().burst_phase); long in_pitch = emu.frame().pitch; unsigned char* in = emu.frame().pixels + setup_.crop.top * in_pitch + setup_.crop.left; for ( int n = height; n; --n ) { unsigned char* line_in = in; in += in_pitch; BOOST::uint32_t* line_out = (BOOST::uint32_t*) out; out = (char*) out + out_pitch; NES_NTSC_BEGIN_ROW( ntsc, burst_phase, nes_ntsc_black, nes_ntsc_black, palette [*line_in] ); line_in [256] = 252; // loop reads 3 extra pixels, so set them to black line_in [257] = 252; line_in [258] = 252; line_in++; burst_phase = (burst_phase + 1) % nes_ntsc_burst_count; // assemble two 16-bit pixels into a 32-bit int for better performance #if BLARGG_BIG_ENDIAN #define COMBINE_PIXELS right |= left << 16; #else #define COMBINE_PIXELS right <<= 16; right |= left; #endif #define OUT_PIXEL( i ) \ if ( !(i & 1) ) {\ NES_NTSC_RGB_OUT( (i % 7), left, NES_BLITTER_OUT_DEPTH );\ if ( i > 1 ) line_out [(i/2)-1] = right;\ }\ else {\ NES_NTSC_RGB_OUT( (i % 7), right, NES_BLITTER_OUT_DEPTH );\ COMBINE_PIXELS;\ } for ( int n = chunk_count; n; --n ) { unsigned long left, right; NES_NTSC_COLOR_IN( 0, palette [line_in [0]] ); OUT_PIXEL( 0 ); OUT_PIXEL( 1 ); NES_NTSC_COLOR_IN( 1, palette [line_in [1]] ); OUT_PIXEL( 2 ); OUT_PIXEL( 3 ); NES_NTSC_COLOR_IN( 2, palette [line_in [2]] ); OUT_PIXEL( 4 ); OUT_PIXEL( 5 ); OUT_PIXEL( 6 ); NES_NTSC_COLOR_IN( 0, palette [line_in [3]] ); OUT_PIXEL( 7 ); OUT_PIXEL( 8 ); NES_NTSC_COLOR_IN( 1, palette [line_in [4]] ); OUT_PIXEL( 9 ); OUT_PIXEL( 10); NES_NTSC_COLOR_IN( 2, palette [line_in [5]] ); line_in += 6; OUT_PIXEL( 11 ); OUT_PIXEL( 12 ); OUT_PIXEL( 13 ); line_out [6] = right; line_out += 7; } } }