commit 307e474

Devine Lu Linvega  ·  2026-01-08 00:02:54 +0000 UTC
parent 402e2ad
Removed screen macros..
1 files changed,  +35, -33
+35, -33
  1@@ -606,25 +606,6 @@ screen_deo_pixel(void)
  2 	}
  3 }
  4 
  5-/* clang-format off */
  6-
  7-#define PUT_PIXEL(n, op) if(op | color) dst[n] = (dst[n] & layer_mask) | table[color];
  8-#define GET_COLOR(depth) const int color = depth ? (((ch1 >> qx) & 1) | ((ch2 >> qx) & 2)) : (ch1 >> qx) & 1;
  9-
 10-#define PUT_PIXELS(n,op,depth,c1,c2) {\
 11-	int qx = qfx; const int ch1 = c1, ch2 = c2;\
 12-	{GET_COLOR(depth) PUT_PIXEL(0, op); qx -= fx; }\
 13-	{GET_COLOR(depth) PUT_PIXEL(1, op); qx -= fx; }\
 14-	{GET_COLOR(depth) PUT_PIXEL(2, op); qx -= fx; }\
 15-	{GET_COLOR(depth) PUT_PIXEL(3, op); qx -= fx; }\
 16-	{GET_COLOR(depth) PUT_PIXEL(4, op); qx -= fx; }\
 17-	{GET_COLOR(depth) PUT_PIXEL(5, op); qx -= fx; }\
 18-	{GET_COLOR(depth) PUT_PIXEL(6, op); qx -= fx; }\
 19-	{GET_COLOR(depth) PUT_PIXEL(7, op); qx -= fx; }\
 20-}
 21-
 22-/* clang-format on */
 23-
 24 static void
 25 screen_deo_sprite(void)
 26 {
 27@@ -634,51 +615,71 @@ screen_deo_sprite(void)
 28 	const int ctrl = dev[0x2f];
 29 	const int blend = ctrl & 0xf;
 30 	const int opaque = blend % 5;
 31+
 32 	if(ctrl & 0x10)
 33 		fx = -1, qfx = 0, dyx = -rDY;
 34 	else
 35 		fx = 1, qfx = 7, dyx = rDY;
 36+
 37 	if(ctrl & 0x20)
 38 		fy = -1, qfy = 7, dxy = -rDX;
 39 	else
 40 		fy = 1, qfy = 0, dxy = rDX;
 41+
 42 	if(ctrl & 0x40)
 43 		layer_mask = 0x3, table = blending[blend][1];
 44 	else
 45 		layer_mask = 0xc, table = blending[blend][0];
 46+
 47 	if(ctrl & 0x80) {
 48+		/* 2bpp sprite */
 49 		const int addr_incr = rMA << 2;
 50 		const int stride = screen_wmar2;
 51 		for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
 52-			const Uint16 xmar2 = x + 16, ymar2 = y + 16, xmar = x + 8, ymar = y + 8;
 53+			const Uint16 xmar = x + 8, ymar = y + 8;
 54+			const Uint16 xmar2 = x + 16, ymar2 = y + 16;
 55 			if(xmar2 == xmar + 8 && ymar2 == ymar + 8 && xmar2 < stride && ymar2 < screen_hmar2) {
 56 				Uint8 *dst = &screen_layers[xmar + ymar * stride];
 57 				const Uint8 *sch1 = &ram[rA + qfy], *sch2 = sch1 + 8;
 58-				if(opaque)
 59-					for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy)
 60-						PUT_PIXELS(n, 1, 1, *sch1, *sch2 << 1)
 61-				else
 62-					for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy)
 63-						PUT_PIXELS(n, 0, 1, *sch1, *sch2 << 1)
 64+				for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy) {
 65+					int qx = qfx;
 66+					int ch1 = *sch1;
 67+					int ch2 = *sch2 << 1;
 68+					int px;
 69+					for(px = 0; px < 8; px++) {
 70+						int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
 71+						if(opaque || color)
 72+							dst[px] = (dst[px] & layer_mask) | table[color];
 73+						qx -= fx;
 74+					}
 75+				}
 76 			}
 77 		}
 78 	} else {
 79+		/* 1bpp sprite */
 80 		const int addr_incr = rMA << 1;
 81 		const int stride = screen_wmar2;
 82 		for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
 83-			const Uint16 xmar2 = x + 16, ymar2 = y + 16, xmar = x + 8, ymar = y + 8;
 84+			const Uint16 xmar = x + 8, ymar = y + 8;
 85+			const Uint16 xmar2 = x + 16, ymar2 = y + 16;
 86 			if(xmar2 == xmar + 8 && ymar2 == ymar + 8 && xmar2 < stride && ymar2 < screen_hmar2) {
 87 				Uint8 *dst = &screen_layers[xmar + ymar * stride];
 88 				const Uint8 *sch1 = &ram[rA + qfy];
 89-				if(opaque)
 90-					for(row = 0; row < 8; row++, dst += stride, sch1 += fy)
 91-						PUT_PIXELS(n, 1, 0, *sch1, 0)
 92-				else
 93-					for(row = 0; row < 8; row++, dst += stride, sch1 += fy)
 94-						PUT_PIXELS(n, 0, 0, *sch1, 0)
 95+				for(row = 0; row < 8; row++, dst += stride, sch1 += fy) {
 96+					int qx = qfx;
 97+					int ch1 = *sch1;
 98+					int px;
 99+					for(px = 0; px < 8; px++) {
100+						int color = (ch1 >> qx) & 1;
101+						if(opaque || color)
102+							dst[px] = (dst[px] & layer_mask) | table[color];
103+						qx -= fx;
104+					}
105+				}
106 			}
107 		}
108 	}
109+
110 	if(!screen_reqdraw) {
111 		int x1, x2, y1, y2;
112 		if(fx < 0)
113@@ -691,6 +692,7 @@ screen_deo_sprite(void)
114 			y1 = rY, y2 = y;
115 		screen_change(x1 - 8, y1 - 8, x2 + 8, y2 + 8);
116 	}
117+
118 	if(rMX) rX += rDX * fx;
119 	if(rMY) rY += rDY * fy;
120 }