Browse code

Added more color blending modes for chrs

Andrew Alderwick authored on 31/07/2021 22:21:13
Showing 1 changed files
... ...
@@ -48,7 +48,12 @@ puticn(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint
48 48
 void
49 49
 putchr(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint8 flipx, Uint8 flipy)
50 50
 {
51
+	Uint8 k1 = 1, k2 = 2;
51 52
 	Uint16 v, h;
53
+	if(!(color & 1)) {
54
+		++color;
55
+		k1 = 2, k2 = 1;
56
+	}
52 57
 	for(v = 0; v < 8; v++)
53 58
 		for(h = 0; h < 8; h++) {
54 59
 			Uint8 ch1 = ((sprite[v] >> (7 - h)) & 0x1) * color;
... ...
@@ -57,7 +62,7 @@ putchr(Ppu *p, Uint8 layer, Uint16 x, Uint16 y, Uint8 *sprite, Uint8 color, Uint
57 62
 				layer,
58 63
 				x + (flipx ? 7 - h : h),
59 64
 				y + (flipy ? 7 - v : v),
60
-				((ch1 + ch2 * 2) + color / 4) & 0x3);
65
+				((ch1 * k1 + ch2 * k2) + color / 4) & 0x3);
61 66
 		}
62 67
 }
63 68