commit 4aa0753
Devine Lu Linvega
·
2026-02-18 03:40:06 +0000 UTC
parent 107c0a5
Faster sprite drawing
1 files changed,
+32,
-14
+32,
-14
1@@ -525,24 +525,42 @@ screen_deo_sprite(void)
2 const int row_start = flipx ? 0 : 7, row_delta = flipx ? 1 : -1;
3 const int col_start = flipy ? 7 : 0, col_delta = flipy ? -1 : 1;
4 const int layer = ctrl & 0x40, layer_mask = layer ? 0x3 : 0xc;
5- const int is_2bpp = ctrl & 0x80;
6- const int addr_incr = rMA << (is_2bpp ? 2 : 1);
7 const int stride = screen_wmar2;
8 const int blend = ctrl & 0xf;
9 const Uint8 opaque_mask = blend % 5;
10 const Uint8 *table = blend_lut[blend][layer >> 6];
11- for(i = 0; i <= rML; i++, x += dx, y += dy, rA += addr_incr) {
12- const Uint16 x0 = x + 8, y0 = y + 8;
13- if(x0 + 8 >= stride || y0 + 8 >= screen_hmar2) continue;
14- Uint8 *dst = screen_layers + y0 * stride + x0;
15- const Uint8 *col = &ram[rA + col_start];
16- for(j = 0; j < 8; j++, dst += stride, col += col_delta) {
17- Uint8 *d = dst;
18- const int ch1 = *col, ch2 = is_2bpp ? col[8] : 0;
19- for(int k = 0, row = row_start; k < 8; k++, d++, row += row_delta) {
20- const int color = ((ch1 >> row) & 1) | (((ch2 >> row) & 1) << 1);
21- if(opaque_mask || color)
22- *d = (*d & layer_mask) | table[color];
23+ if(ctrl & 0x80) {
24+ const int addr_incr = rMA << 2;
25+ for(i = 0; i <= rML; i++, x += dx, y += dy, rA += addr_incr) {
26+ const Uint16 x0 = x + 8, y0 = y + 8;
27+ if(x0 + 8 >= stride || y0 + 8 >= screen_hmar2) continue;
28+ Uint8 *dst = screen_layers + y0 * stride + x0;
29+ const Uint8 *col = &ram[rA + col_start];
30+ for(j = 0; j < 8; j++, dst += stride, col += col_delta) {
31+ Uint8 *d = dst;
32+ const int ch1 = *col, ch2 = col[8];
33+ for(int k = 0, row = row_start; k < 8; k++, d++, row += row_delta) {
34+ const int color = ((ch1 >> row) & 1) | (((ch2 >> row) & 1) << 1);
35+ if(opaque_mask || color)
36+ *d = (*d & layer_mask) | table[color];
37+ }
38+ }
39+ }
40+ } else {
41+ const int addr_incr = rMA << 1;
42+ for(i = 0; i <= rML; i++, x += dx, y += dy, rA += addr_incr) {
43+ const Uint16 x0 = x + 8, y0 = y + 8;
44+ if(x0 + 8 >= stride || y0 + 8 >= screen_hmar2) continue;
45+ Uint8 *dst = screen_layers + y0 * stride + x0;
46+ const Uint8 *col = &ram[rA + col_start];
47+ for(j = 0; j < 8; j++, dst += stride, col += col_delta) {
48+ Uint8 *d = dst;
49+ const int ch1 = *col;
50+ for(int k = 0, row = row_start; k < 8; k++, d++, row += row_delta) {
51+ const int color = (ch1 >> row) & 1;
52+ if(opaque_mask || color)
53+ *d = (*d & layer_mask) | table[color];
54+ }
55 }
56 }
57 }