This shows how each pixel contributes to two output pixels, with the even pixels being at one offset, and the odd ones being shifted to the right by one output pixel:
Code: Select all
0022446688...
-113355779...
It can be optimized quite a bit. The biggest win would come from mixing pairs of pixels in a 32-bit integer and unrolling the loop a few times.
I just wanted to show that you don't need the NTSC filter to get decet hires.
Code: Select all
/* Use for 16-bit RGB pixels */
#define MASK 0x0821
/* Use for 15-bit BGR/RGB pixels */
#define MASK 0x0421
/* Use if you've already interleved your source SNES pixels */
void blit_hires_row( const unsigned short* in, unsigned short* out )
{
unsigned prev = 0;
int n = 512;
while ( n-- )
{
unsigned cur = *in++;
*out++ = (prev + cur - ((prev ^ cur) & MASK)) >> 1;
prev = cur;
}
}
/* Use if you have the even and odd pixels drawn into separate buffers */
void blit_hires_row( const unsigned short* even_in,
const unsigned short* odd_in, unsigned short* out )
{
unsigned odd = 0;
int n = 256;
while ( n-- )
{
unsigned even = *even_in++;
*out++ = (odd + even - ((odd ^ even) & MASK)) >> 1;
odd = *odd_in++;
*out++ = (odd + even - ((odd ^ even) & MASK)) >> 1;
}
}