commit 8788607

Devine Lu Linvega  ·  2025-12-30 20:09:59 +0000 UTC
parent 79c1964
Removed redundant variables in sprites
1 files changed,  +7, -9
+7, -9
 1@@ -588,15 +588,14 @@ screen_draw_sprite(void)
 2 	if(ctrl & 0x80) {
 3 		const int addr_incr = rMA << 2;
 4 		for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
 5-			const Uint16 ymar2 = MAR2(y), xmar2 = MAR2(x);
 6+			const Uint16 xmar2 = x + 16, ymar2 = y + 16;
 7 			if(xmar2 < screen_wmar2 && ymar2 < screen_hmar2) {
 8-				const Uint16 xmar = MAR(x), ymar = MAR(y);
 9 				const Uint8 *sprite = &ram[rA];
10+				const Uint16 xmar = x + 8, ymar = y + 8;
11 				for(ay = ymar * screen_wmar2, by = ymar2 * screen_wmar2, qy = qfy; ay < by; ay += screen_wmar2, qy += fy) {
12-					const int ch1 = sprite[qy];
13-					const int ch2 = sprite[qy + 8] << 1;
14+					const int ch1 = sprite[qy], ch2 = sprite[qy + 8] << 1;
15 					for(ax = xmar + ay, bx = xmar2 + ay, qx = qfx; ax < bx; ax++, qx -= fx) {
16-						const int color = (ch1 >> qx & 1) | (ch2 >> qx & 2);
17+						const int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
18 						if(opaque || color)
19 							screen_layers[ax] = (screen_layers[ax] & layer_mask) | table[color];
20 					}
21@@ -612,11 +611,10 @@ screen_draw_sprite(void)
22 				const Uint16 xmar = x + 8, ymar = y + 8;
23 				for(ay = ymar * screen_wmar2, by = ymar2 * screen_wmar2, qy = qfy; ay < by; ay += screen_wmar2, qy += fy) {
24 					const int ch1 = sprite[qy];
25-					Uint8 *dst = &screen_layers[xmar + ay];
26-					for(int px = 0, qx = qfx; px < 8; px++, qx -= fx, dst++) {
27+					for(ax = xmar + ay, bx = xmar2 + ay, qx = qfx; ax < bx; ax++, qx -= fx) {
28 						const int color = (ch1 >> qx) & 1;
29 						if(opaque || color)
30-							*dst = (*dst & layer_mask) | table[color];
31+							screen_layers[ax] = (screen_layers[ax] & layer_mask) | table[color];
32 					}
33 				}
34 			}
35@@ -1248,7 +1246,7 @@ main(int argc, char **argv)
36 {
37 	int i = 1;
38 	if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
39-		return !fprintf(stdout, "%s - Varvara Emulator, 29 Dec 2025.\n", argv[0]);
40+		return !fprintf(stdout, "%s - Varvara Emulator, 30 Dec 2025.\n", argv[0]);
41 	else if(argc == 1)
42 		return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
43 	else if(!system_boot(argv[i++], argc > 2))