games/gb: better video scaler from games/nes

This commit is contained in:
glenda 2014-03-30 22:18:17 +01:00
parent 4d0a446123
commit 67eb30f0ca

View file

@ -32,25 +32,34 @@ resolvetile(u8int tx, u8int ty, u8int toy, int window, u8int* tnl1, u8int *tnl2)
static void static void
pixel(int x, int y, int val, int back) pixel(int x, int y, int val, int back)
{ {
int X, Y; int Y;
uchar *p; union { u8int c[4]; u32int l; } u;
u32int *p, l;
val = (3 - val) * 0x55; val = (3 - val) * 0x55;
if(scale > 1){ u.c[0] = val;
for(X = scale * x; X < scale * (x+1); X++) u.c[1] = val;
for(Y = scale * y; Y < scale * (y+1); Y++){ u.c[2] = val;
p = pic + Y * scale * 160 * 4 + X * 4; u.c[3] = back ? 0 : 0xFF;
p[0] = val; l = u.l;
p[1] = val; if(scale == 3){
p[2] = val; p = ((u32int*)pic) + y * 3 * 3 * 160 + 3 * x;
p[3] = back ? 0 : 0xFF; for(Y = 0; Y < 3; Y++){
*p++ = l;
*p++ = l;
*p = l;
p += 3 * 160 - 2;
} }
}else if(scale == 2){
p = ((u32int*)pic) + y * 2 * 2 * 160 + 2 * x;
*p++ = l;
*p = l;
p += 2 * 160 - 1;
*p++ = l;
*p = l;
}else{ }else{
p = pic + y*160*4 + x*4; p = ((u32int*)pic) + y * 160 + x;
p[0] = val; *p = l;
p[1] = val;
p[2] = val;
p[3] = back ? 0 : 0xFF;
} }
} }