commit 4ed3567

Devine Lu Linvega  ·  2025-12-31 00:05:07 +0000 UTC
parent 41853dd
Macroed row of pixels
1 files changed,  +21, -17
+21, -17
 1@@ -572,13 +572,19 @@ screen_draw_pixel(void)
 2 /* clang-format off */
 3 
 4 #define GET_SHIFT(n) const int qx = qfx - n * fx;
 5-#define PUT_PIXEL(n) { dst[n] = (dst[n] & layer_mask) | table[color]; }
 6-#define GET_1BPP const int color = (ch1 >> qx) & 1;
 7-#define GET_2BPP const int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
 8-#define o1BPP(n) { GET_SHIFT(n) GET_1BPP PUT_PIXEL(n) }
 9-#define a1BPP(n) { GET_SHIFT(n) GET_1BPP if(color) PUT_PIXEL(n) }
10-#define o2BPP(n) { GET_SHIFT(n) GET_2BPP PUT_PIXEL(n) }
11-#define a2BPP(n) { GET_SHIFT(n) GET_2BPP if(color) PUT_PIXEL(n) }
12+#define PUT_PIXEL(n, op) { if(op | color) dst[n] = (dst[n] & layer_mask) | table[color]; }
13+#define GET_COLOR(depth,ch1,ch2) const int color = depth ? (((ch1 >> qx) & 1) | ((ch2 >> qx) & 2)) : (ch1 >> qx) & 1;
14+
15+#define PUT_PIXELS(n,op,depth,ch1,ch2) {\
16+	{GET_SHIFT(0) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(0,op)}\
17+	{GET_SHIFT(1) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(1,op)}\
18+	{GET_SHIFT(2) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(2,op)}\
19+	{GET_SHIFT(3) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(3,op)}\
20+	{GET_SHIFT(4) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(4,op)}\
21+	{GET_SHIFT(5) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(5,op)}\
22+	{GET_SHIFT(6) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(6,op)}\
23+	{GET_SHIFT(7) GET_COLOR(depth,ch1,ch2) PUT_PIXEL(7,op)}\
24+}
25 
26 /* clang-format on */
27 
28@@ -614,11 +620,10 @@ screen_draw_sprite(void)
29 				Uint8 *dst = &screen_layers[xmar + ymar * screen_wmar2];
30 				for(row = 0, qy = qfy; row < height; row++, dst += screen_wmar2, qy += fy) {
31 					const int ch1 = sprite[qy], ch2 = sprite[qy + 8] << 1;
32-					if(opaque) {
33-						o2BPP(0) o2BPP(1) o2BPP(2) o2BPP(3) o2BPP(4) o2BPP(5) o2BPP(6) o2BPP(7)
34-					} else {
35-						a2BPP(0) a2BPP(1) a2BPP(2) a2BPP(3) a2BPP(4) a2BPP(5) a2BPP(6) a2BPP(7)
36-					}
37+					if(opaque)
38+						PUT_PIXELS(n, 1, 1, ch1, ch2)
39+					else
40+						PUT_PIXELS(n, 0, 1, ch1, ch2)
41 				}
42 			}
43 		}
44@@ -633,11 +638,10 @@ screen_draw_sprite(void)
45 				Uint8 *dst = &screen_layers[xmar + ymar * screen_wmar2];
46 				for(row = 0, qy = qfy; row < height; row++, dst += screen_wmar2, qy += fy) {
47 					const int ch1 = sprite[qy];
48-					if(opaque) {
49-						o1BPP(0) o1BPP(1) o1BPP(2) o1BPP(3) o1BPP(4) o1BPP(5) o1BPP(6) o1BPP(7)
50-					} else {
51-						a1BPP(0) a1BPP(1) a1BPP(2) a1BPP(3) a1BPP(4) a1BPP(5) a1BPP(6) a1BPP(7)
52-					}
53+					if(opaque)
54+						PUT_PIXELS(n, 1, 0, ch1, 0)
55+					else
56+						PUT_PIXELS(n, 0, 0, ch1, 0)
57 				}
58 			}
59 		}