commit 42e87b0

Devine Lu Linvega  ·  2025-08-13 23:34:25 +0000 UTC
parent 80f3b51
Faster blending
1 files changed,  +6, -6
+6, -6
 1@@ -563,13 +563,15 @@ static void
 2 screen_draw_sprite(void)
 3 {
 4 	const int ctrl = dev[0x2f];
 5-	const int blend = ctrl & 0xf, opaque = blend % 5;
 6+	const int blend = ctrl & 0xf;
 7+	const int above = ctrl & 0x40;
 8+	const int opaque = blend % 5;
 9 	const int fx = ctrl & 0x10 ? -1 : 1, fy = ctrl & 0x20 ? -1 : 1;
10 	const int qfx = fx > 0 ? 7 : 0, qfy = fy < 0 ? 7 : 0;
11 	const int dxy = fy * rDX, dyx = fx * rDY;
12 	const int wmar = MAR(uxn_screen.width), wmar2 = MAR2(uxn_screen.width);
13 	const int hmar2 = MAR2(uxn_screen.height);
14-	const int above = ctrl & 0x40;
15+	const Uint8 *table = blending[blend];
16 	int i, x1, x2, y1, y2, ax, ay, qx, qy, x = rX, y = rY;
17 	if(ctrl & 0x80) {
18 		const int addr_incr = rMA << 2;
19@@ -585,8 +587,7 @@ screen_draw_sprite(void)
20 						const int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
21 						if(opaque || color) {
22 							const int src = uxn_screen.bg[ax];
23-							const int clr = blending[blend][color];
24-							uxn_screen.bg[ax] = above ? (src & 0x3) | clr << 2 : (src & 0xc) | clr;
25+							uxn_screen.bg[ax] = above ? (src & 0x3) | table[color] << 2 : (src & 0xc) | table[color];
26 						}
27 					}
28 				}
29@@ -606,8 +607,7 @@ screen_draw_sprite(void)
30 						const int color = (ch1 >> qx) & 1;
31 						if(opaque || color) {
32 							const int src = uxn_screen.bg[ax];
33-							const int clr = blending[blend][color];
34-							uxn_screen.bg[ax] = above ? (src & 0x3) | clr << 2 : (src & 0xc) | clr;
35+							uxn_screen.bg[ax] = above ? (src & 0x3) | table[color] << 2 : (src & 0xc) | table[color];
36 						}
37 					}
38 				}