commit 0a0d2ae
Devine Lu Linvega
·
2026-02-18 18:35:55 +0000 UTC
parent 4a0607f
Tightened sprite drawing
1 files changed,
+14,
-19
+14,
-19
1@@ -524,30 +524,25 @@ screen_deo_sprite(void)
2 const int ctrl = dev[0x2f];
3 const int flipx = ctrl & 0x10, dx = flipx ? -rDY : rDY;
4 const int flipy = ctrl & 0x20, dy = flipy ? -rDX : rDX;
5+ const int row_start = flipx ? 0 : 7, row_delta = flipx ? 1 : -1;
6+ const int col_start = flipy ? 7 : 0, col_delta = flipy ? -1 : 1;
7 const int layer = ctrl & 0x40, layer_mask = layer ? 0x3 : 0xc;
8- const int row_step = flipy ? -1 : 1, row_start = flipy ? 7 : 0;
9- const int is_2bpp = ctrl >> 7;
10- const int addr_incr = rMA << (is_2bpp + 1);
11+ const int mode_2bpp = ctrl >> 7, addr_2bpp = mode_2bpp ? rMA << 2 : rMA << 1;
12 const int blend = ctrl & 0xf;
13- const Uint8 opaque_mask = alpha_lut[blend];
14- const Uint8 *table = blend_lut[blend][layer >> 6];
15- for(i = 0; i <= rML; i++, x += dx, y += dy, rA += addr_incr) {
16+ const Uint8 opaque = alpha_lut[blend], *table = blend_lut[blend][layer >> 6];
17+ for(i = 0; i <= rML; i++, x += dx, y += dy, rA += addr_2bpp) {
18 const Uint16 x0 = x + 8, y0 = y + 8;
19 if(x0 + 8 >= screen_wmar2 || y0 + 8 >= screen_hmar2) continue;
20 Uint8 *dst = screen_layers + y0 * screen_wmar2 + x0;
21- const Uint8 *rowptr = &ram[rA + row_start];
22- for(j = 0; j < 8; j++, dst += screen_wmar2, rowptr += row_step) {
23- Uint8 *d = dst, bits1 = rowptr[0], bits2 = is_2bpp ? rowptr[8] : 0;
24- if(flipx)
25- for(int k = 0; k < 8; k++, d++, bits1 >>= 1, bits2 >>= 1) {
26- const int color = (bits1 & 1) | ((bits2 << 1) & 2);
27- if(opaque_mask || color) *d = (*d & layer_mask) | table[color];
28- }
29- else
30- for(int k = 0; k < 8; k++, d++, bits1 <<= 1, bits2 <<= 1) {
31- const int color = (bits1 >> 7) | ((bits2 >> 6) & 2);
32- if(opaque_mask || color) *d = (*d & layer_mask) | table[color];
33- }
34+ const Uint8 *col = &ram[rA + col_start];
35+ for(j = 0; j < 8; j++, dst += screen_wmar2, col += col_delta) {
36+ Uint8 *d = dst;
37+ const int ch1 = *col, ch2 = mode_2bpp ? col[8] : 0;
38+ for(int k = 0, row = row_start; k < 8; k++, d++, row += row_delta) {
39+ const int color = ((ch1 >> row) & 1) | (((ch2 >> row) & 1) << 1);
40+ if(opaque || color)
41+ *d = (*d & layer_mask) | table[color];
42+ }
43 }
44 }
45 if(!screen_reqdraw) {