commit aa845f9
Devine Lu Linvega
·
2026-01-08 00:50:27 +0000 UTC
parent b686211
Made as many consts as I could in the sprite drawing
1 files changed,
+23,
-32
+23,
-32
1@@ -609,45 +609,36 @@ static const Uint8 blending[16][2][4] = {
2 static void
3 screen_deo_sprite(void)
4 {
5- int i, x = rX, y = rY, layer_mask;
6- int fx, fy, qfx, qfy, dxy, dyx, row;
7- const Uint8 *table;
8+ int i, row, px;
9+ int x = rX, y = rY;
10 const int ctrl = dev[0x2f];
11 const int blend = ctrl & 0xf;
12 const int opaque = blend % 5;
13- if(ctrl & 0x10)
14- fx = -1, qfx = 0, dyx = -rDY;
15- else
16- fx = 1, qfx = 7, dyx = rDY;
17-
18- if(ctrl & 0x20)
19- fy = -1, qfy = 7, dxy = -rDX;
20- else
21- fy = 1, qfy = 0, dxy = rDX;
22- if(ctrl & 0x40)
23- layer_mask = 0x3, table = blending[blend][1];
24- else
25- layer_mask = 0xc, table = blending[blend][0];
26+ const int fx = (ctrl & 0x10) ? -1 : 1;
27+ const int fy = (ctrl & 0x20) ? -1 : 1;
28+ const int qfx = (ctrl & 0x10) ? 0 : 7;
29+ const int qfy = (ctrl & 0x20) ? 7 : 0;
30+ const int dyx = fx * rDY;
31+ const int dxy = fy * rDX;
32+ const int layer_mask = (ctrl & 0x40) ? 0x3 : 0xc;
33+ const Uint8 *table = (ctrl & 0x40) ? blending[blend][1] : blending[blend][0];
34 const int is_2bpp = (ctrl & 0x80) != 0;
35 const int addr_incr = rMA << (is_2bpp ? 2 : 1);
36 const int stride = screen_wmar2;
37 for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr) {
38- const Uint16 xmar = x + 8, ymar = y + 8;
39- const Uint16 xmar2 = x + 16, ymar2 = y + 16;
40- if(xmar2 == xmar + 8 && ymar2 == ymar + 8 && xmar2 < stride && ymar2 < screen_hmar2) {
41- Uint8 *dst = &screen_layers[xmar + ymar * stride];
42- const Uint8 *sch1 = &ram[rA + qfy];
43- const Uint8 *sch2 = is_2bpp ? sch1 + 8 : NULL;
44- for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy) {
45- int qx = qfx;
46- int ch1 = *sch1;
47- int ch2 = is_2bpp ? (*sch2 << 1) : 0;
48- int px;
49- for(px = 0; px < 8; px++, qx -= fx) {
50- int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
51- if(opaque || color)
52- dst[px] = (dst[px] & layer_mask) | table[color];
53- }
54+ const Uint16 x0 = x + 8, y0 = y + 8;
55+ if(x0 + 8 >= stride || y0 + 8 >= screen_hmar2) continue;
56+ Uint8 *dst = &screen_layers[x0 + y0 * stride];
57+ const Uint8 *sch1 = &ram[rA + qfy];
58+ const Uint8 *sch2 = is_2bpp ? sch1 + 8 : NULL;
59+ for(row = 0; row < 8; row++, dst += stride, sch1 += fy, sch2 += fy) {
60+ int qx = qfx;
61+ int ch1 = *sch1;
62+ int ch2 = is_2bpp ? (*sch2 << 1) : 0;
63+ for(px = 0; px < 8; px++, qx -= fx) {
64+ int color = ((ch1 >> qx) & 1) | ((ch2 >> qx) & 2);
65+ if(opaque || color)
66+ dst[px] = (dst[px] & layer_mask) | table[color];
67 }
68 }
69 }