commit 44741f9

Devine Lu Linvega  ·  2026-01-08 00:34:43 +0000 UTC
parent 1d4215f
Trying to precompute the 8 pixels
1 files changed,  +30, -32
+30, -32
 1@@ -442,24 +442,6 @@ static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY;
 2 
 3 void emu_redraw(void), emu_resize(void);
 4 
 5-static const Uint8 blending[16][2][4] = {
 6-	{{0, 0, 1, 2}, {0, 0, 4, 8}},
 7-	{{0, 1, 2, 3}, {0, 4, 8, 12}},
 8-	{{0, 2, 3, 1}, {0, 8, 12, 4}},
 9-	{{0, 3, 1, 2}, {0, 12, 4, 8}},
10-	{{1, 0, 1, 2}, {4, 0, 4, 8}},
11-	{{0, 1, 2, 3}, {0, 4, 8, 12}},
12-	{{1, 2, 3, 1}, {4, 8, 12, 4}},
13-	{{1, 3, 1, 2}, {4, 12, 4, 8}},
14-	{{2, 0, 1, 2}, {8, 0, 4, 8}},
15-	{{2, 1, 2, 3}, {8, 4, 8, 12}},
16-	{{0, 2, 3, 1}, {0, 8, 12, 4}},
17-	{{2, 3, 1, 2}, {8, 12, 4, 8}},
18-	{{3, 0, 1, 2}, {12, 0, 4, 8}},
19-	{{3, 1, 2, 3}, {12, 4, 8, 12}},
20-	{{3, 2, 3, 1}, {12, 8, 12, 4}},
21-	{{0, 3, 1, 2}, {0, 12, 4, 8}}};
22-
23 static void
24 screen_change(const int x1, const int y1, const int x2, const int y2)
25 {
26@@ -606,6 +588,24 @@ screen_deo_pixel(void)
27 	}
28 }
29 
30+static const Uint8 blending[16][2][4] = {
31+	{{0, 0, 1, 2}, {0, 0, 4, 8}},
32+	{{0, 1, 2, 3}, {0, 4, 8, 12}},
33+	{{0, 2, 3, 1}, {0, 8, 12, 4}},
34+	{{0, 3, 1, 2}, {0, 12, 4, 8}},
35+	{{1, 0, 1, 2}, {4, 0, 4, 8}},
36+	{{0, 1, 2, 3}, {0, 4, 8, 12}},
37+	{{1, 2, 3, 1}, {4, 8, 12, 4}},
38+	{{1, 3, 1, 2}, {4, 12, 4, 8}},
39+	{{2, 0, 1, 2}, {8, 0, 4, 8}},
40+	{{2, 1, 2, 3}, {8, 4, 8, 12}},
41+	{{0, 2, 3, 1}, {0, 8, 12, 4}},
42+	{{2, 3, 1, 2}, {8, 12, 4, 8}},
43+	{{3, 0, 1, 2}, {12, 0, 4, 8}},
44+	{{3, 1, 2, 3}, {12, 4, 8, 12}},
45+	{{3, 2, 3, 1}, {12, 8, 12, 4}},
46+	{{0, 3, 1, 2}, {0, 12, 4, 8}}};
47+
48 static void
49 screen_deo_sprite(void)
50 {
51@@ -619,6 +619,7 @@ screen_deo_sprite(void)
52 		fx = -1, qfx = 0, dyx = -rDY;
53 	else
54 		fx = 1, qfx = 7, dyx = rDY;
55+
56 	if(ctrl & 0x20)
57 		fy = -1, qfy = 7, dxy = -rDX;
58 	else
59@@ -638,29 +639,26 @@ screen_deo_sprite(void)
60 			const Uint8 *sch1 = &ram[rA + qfy];
61 			const Uint8 *sch2 = is_2bpp ? sch1 + 8 : NULL;
62 			for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy) {
63-				int qx = qfx;
64 				int ch1 = *sch1;
65 				int ch2 = is_2bpp ? (*sch2 << 1) : 0;
66+				Uint8 pixels[8];
67 				int px;
68 				for(px = 0; px < 8; px++) {
69-					int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
70-					if(opaque || color)
71-						dst[px] = (dst[px] & layer_mask) | table[color];
72-					qx -= fx;
73+					int idx = (fx > 0) ? (7 - px) : px;
74+					pixels[px] = ((ch1 >> idx) & 1) | ((ch2 >> idx) & 2);
75+				}
76+				for(px = 0; px < 8; px++) {
77+					if(opaque || pixels[px])
78+						dst[px] = (dst[px] & layer_mask) | table[pixels[px]];
79 				}
80 			}
81 		}
82 	}
83 	if(!screen_reqdraw) {
84-		int x1, x2, y1, y2;
85-		if(fx < 0)
86-			x1 = x, x2 = rX;
87-		else
88-			x1 = rX, x2 = x;
89-		if(fy < 0)
90-			y1 = y, y2 = rY;
91-		else
92-			y1 = rY, y2 = y;
93+		int x1 = (fx < 0) ? x : rX;
94+		int x2 = (fx < 0) ? rX : x;
95+		int y1 = (fy < 0) ? y : rY;
96+		int y2 = (fy < 0) ? rY : y;
97 		screen_change(x1 - 8, y1 - 8, x2 + 8, y2 + 8);
98 	}
99 	if(rMX) rX += rDX * fx;