commit 1d4215f

Devine Lu Linvega  ·  2026-01-08 00:17:19 +0000 UTC
parent 307e474
Cleanup
1 files changed,  +20, -50
+20, -50
  1@@ -615,71 +615,42 @@ screen_deo_sprite(void)
  2 	const int ctrl = dev[0x2f];
  3 	const int blend = ctrl & 0xf;
  4 	const int opaque = blend % 5;
  5-
  6 	if(ctrl & 0x10)
  7 		fx = -1, qfx = 0, dyx = -rDY;
  8 	else
  9 		fx = 1, qfx = 7, dyx = rDY;
 10-
 11 	if(ctrl & 0x20)
 12 		fy = -1, qfy = 7, dxy = -rDX;
 13 	else
 14 		fy = 1, qfy = 0, dxy = rDX;
 15-
 16 	if(ctrl & 0x40)
 17 		layer_mask = 0x3, table = blending[blend][1];
 18 	else
 19 		layer_mask = 0xc, table = blending[blend][0];
 20-
 21-	if(ctrl & 0x80) {
 22-		/* 2bpp sprite */
 23-		const int addr_incr = rMA << 2;
 24-		const int stride = screen_wmar2;
 25-		for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
 26-			const Uint16 xmar = x + 8, ymar = y + 8;
 27-			const Uint16 xmar2 = x + 16, ymar2 = y + 16;
 28-			if(xmar2 == xmar + 8 && ymar2 == ymar + 8 && xmar2 < stride && ymar2 < screen_hmar2) {
 29-				Uint8 *dst = &screen_layers[xmar + ymar * stride];
 30-				const Uint8 *sch1 = &ram[rA + qfy], *sch2 = sch1 + 8;
 31-				for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy) {
 32-					int qx = qfx;
 33-					int ch1 = *sch1;
 34-					int ch2 = *sch2 << 1;
 35-					int px;
 36-					for(px = 0; px < 8; px++) {
 37-						int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
 38-						if(opaque || color)
 39-							dst[px] = (dst[px] & layer_mask) | table[color];
 40-						qx -= fx;
 41-					}
 42-				}
 43-			}
 44-		}
 45-	} else {
 46-		/* 1bpp sprite */
 47-		const int addr_incr = rMA << 1;
 48-		const int stride = screen_wmar2;
 49-		for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
 50-			const Uint16 xmar = x + 8, ymar = y + 8;
 51-			const Uint16 xmar2 = x + 16, ymar2 = y + 16;
 52-			if(xmar2 == xmar + 8 && ymar2 == ymar + 8 && xmar2 < stride && ymar2 < screen_hmar2) {
 53-				Uint8 *dst = &screen_layers[xmar + ymar * stride];
 54-				const Uint8 *sch1 = &ram[rA + qfy];
 55-				for(row = 0; row < 8; row++, dst += stride, sch1 += fy) {
 56-					int qx = qfx;
 57-					int ch1 = *sch1;
 58-					int px;
 59-					for(px = 0; px < 8; px++) {
 60-						int color = (ch1 >> qx) & 1;
 61-						if(opaque || color)
 62-							dst[px] = (dst[px] & layer_mask) | table[color];
 63-						qx -= fx;
 64-					}
 65+	const int is_2bpp = (ctrl & 0x80) != 0;
 66+	const int addr_incr = rMA << (is_2bpp ? 2 : 1);
 67+	const int stride = screen_wmar2;
 68+	for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
 69+		const Uint16 xmar = x + 8, ymar = y + 8;
 70+		const Uint16 xmar2 = x + 16, ymar2 = y + 16;
 71+		if(xmar2 == xmar + 8 && ymar2 == ymar + 8 && xmar2 < stride && ymar2 < screen_hmar2) {
 72+			Uint8 *dst = &screen_layers[xmar + ymar * stride];
 73+			const Uint8 *sch1 = &ram[rA + qfy];
 74+			const Uint8 *sch2 = is_2bpp ? sch1 + 8 : NULL;
 75+			for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy) {
 76+				int qx = qfx;
 77+				int ch1 = *sch1;
 78+				int ch2 = is_2bpp ? (*sch2 << 1) : 0;
 79+				int px;
 80+				for(px = 0; px < 8; px++) {
 81+					int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
 82+					if(opaque || color)
 83+						dst[px] = (dst[px] & layer_mask) | table[color];
 84+					qx -= fx;
 85 				}
 86 			}
 87 		}
 88 	}
 89-
 90 	if(!screen_reqdraw) {
 91 		int x1, x2, y1, y2;
 92 		if(fx < 0)
 93@@ -692,7 +663,6 @@ screen_deo_sprite(void)
 94 			y1 = rY, y2 = y;
 95 		screen_change(x1 - 8, y1 - 8, x2 + 8, y2 + 8);
 96 	}
 97-
 98 	if(rMX) rX += rDX * fx;
 99 	if(rMY) rY += rDY * fy;
100 }