Browse code

Simpler putchr(), not the best but..

neauoire authored on 01/08/2021 00:00:25
Showing 1 changed files
... ...
@@ -16,9 +16,8 @@ void
16 16
 clear(Ppu *p)
17 17
 {
18 18
 	int i, sz = p->height * p->width;
19
-	for(i = 0; i < sz; ++i) {
20
-		p->pixels[i] = 0;
21
-	}
19
+	for(i = 0; i < sz; ++i)
20
+		p->pixels[i] = 0x00;
22 21
 }
23 22
 
24 23
 void
... ...
@@ -41,28 +40,24 @@ puticn(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint
41 40
 					layer,
42 41
 					x + (flipx ? 7 - h : h),
43 42
 					y + (flipy ? 7 - v : v),
44
-					ch1 ? color % 4 : color / 4);
43
+					ch1 ? (color & 0x3) : (color >> 0x2));
45 44
 		}
46 45
 }
47 46
 
48 47
 void
49 48
 putchr(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy)
50 49
 {
51
-	Uint8 k1 = 1, k2 = 2;
52 50
 	Uint16 v, h;
53
-	if(!(color & 1)) {
54
-		++color;
55
-		k1 = 2, k2 = 1;
56
-	}
57 51
 	for(v = 0; v < 8; v++)
58 52
 		for(h = 0; h < 8; h++) {
59 53
 			Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color;
60 54
 			Uint8 ch2 = ((sprite[v + 8] >> (7 - h)) & 0x1) * color;
61
-			putpixel(p,
62
-				layer,
63
-				x + (flipx ? 7 - h : h),
64
-				y + (flipy ? 7 - v : v),
65
-				((ch1 * k1 + ch2 * k2) + color / 4) & 0x3);
55
+			if(ch1 + ch2 || (color != 0x05 && color != 0x0a && color != 0x0f))
56
+				putpixel(p,
57
+					layer,
58
+					x + (flipx ? 7 - h : h),
59
+					y + (flipy ? 7 - v : v),
60
+					((ch1 ? (color & 0x3) : (color >> 0x2)) + (ch2 ? (color & 0x3) : (color >> 0x2)) * 2) & 0x3);
66 61
 		}
67 62
 }
68 63