commit 3d91406
Devine Lu Linvega
·
2026-01-12 18:28:15 +0000 UTC
parent 557b581
Removed precomputed layer for blend lut
1 files changed,
+25,
-22
+25,
-22
1@@ -427,23 +427,26 @@ static int screen_vector, *screen_pixels, screen_palette[16];
2 static int rX, rY, rA, rMX, rMY, rMA, rML, rDX, rDY;
3 static Uint8 *screen_layers;
4
5-static const Uint8 blend_lut[16][2][4] = {
6- {{0, 0, 1, 2}, {0, 0, 4, 8}},
7- {{0, 1, 2, 3}, {0, 4, 8, 12}},
8- {{0, 2, 3, 1}, {0, 8, 12, 4}},
9- {{0, 3, 1, 2}, {0, 12, 4, 8}},
10- {{1, 0, 1, 2}, {4, 0, 4, 8}},
11- {{0, 1, 2, 3}, {0, 4, 8, 12}},
12- {{1, 2, 3, 1}, {4, 8, 12, 4}},
13- {{1, 3, 1, 2}, {4, 12, 4, 8}},
14- {{2, 0, 1, 2}, {8, 0, 4, 8}},
15- {{2, 1, 2, 3}, {8, 4, 8, 12}},
16- {{0, 2, 3, 1}, {0, 8, 12, 4}},
17- {{2, 3, 1, 2}, {8, 12, 4, 8}},
18- {{3, 0, 1, 2}, {12, 0, 4, 8}},
19- {{3, 1, 2, 3}, {12, 4, 8, 12}},
20- {{3, 2, 3, 1}, {12, 8, 12, 4}},
21- {{0, 3, 1, 2}, {0, 12, 4, 8}}};
22+static const Uint8 blend_lut[16][4] = {
23+ {0, 0, 1, 2},
24+ {0, 1, 2, 3},
25+ {0, 2, 3, 1},
26+ {0, 3, 1, 2},
27+
28+ {1, 0, 1, 2},
29+ {1, 1, 2, 3},
30+ {1, 2, 3, 1},
31+ {1, 3, 1, 2},
32+
33+ {2, 0, 1, 2},
34+ {2, 1, 2, 3},
35+ {2, 2, 3, 1},
36+ {2, 3, 1, 2},
37+
38+ {3, 0, 1, 2},
39+ {3, 1, 2, 3},
40+ {3, 2, 3, 1},
41+ {2, 3, 1, 2}};
42
43 void emu_redraw(void), emu_resize(void);
44
45@@ -601,13 +604,13 @@ screen_deo_sprite(void)
46 const int dx = flipx ? -rDY : rDY, dy = flipy ? -rDX : rDX;
47 const int row_start = flipx ? 0 : 7, row_delta = flipx ? 1 : -1;
48 const int col_start = flipy ? 7 : 0, col_delta = flipy ? -1 : 1;
49- const int layer = ctrl & 0x40, layer_mask = layer ? 0x3 : 0xc;
50+ const int layer = ctrl & 0x40 ? 2 : 0, layer_mask = layer ? 0x3 : 0xc;
51 const int is_2bpp = ctrl & 0x80;
52 const int addr_incr = rMA << (is_2bpp ? 2 : 1);
53 const int stride = screen_wmar2;
54 const int blend = ctrl & 0xf;
55 const Uint8 opaque_mask = (blend % 5) ? 0xff : 0x00;
56- const Uint8 *table = blend_lut[blend][layer >> 6];
57+ const Uint8 *table = blend_lut[blend];
58 for(i = 0; i <= rML; i++, x += dx, y += dy, rA += addr_incr) {
59 const Uint16 x0 = x + 8, y0 = y + 8;
60 if(x0 + 8 >= stride || y0 + 8 >= screen_hmar2) continue;
61@@ -616,12 +619,12 @@ screen_deo_sprite(void)
62 for(j = 0; j < 8; j++, dst += stride, col += col_delta) {
63 const int ch1 = *col, ch2 = is_2bpp ? (col[8] << 1) : 0;
64 Uint8 *d = dst;
65- for(int px = 0, row = row_start; px < 8; px++, d++, row += row_delta) {
66+ for(int k = 0, row = row_start; k < 8; k++, d++, row += row_delta) {
67 const int bit = 1 << row;
68 const int color = ((ch1 & bit) ? 1 : 0) | ((ch2 & (bit << 1)) ? 2 : 0);
69 const Uint8 mask = -(!!(color | opaque_mask));
70- const Uint8 value = *d;
71- *d = (value & ~mask) | (((value & layer_mask) | table[color]) & mask);
72+ const Uint8 value = table[color] << layer;
73+ *d = (*d & ~mask) | (((*d & layer_mask) | value) & mask);
74 }
75 }
76 }