commit 92fa022
Devine Lu Linvega
·
2025-12-30 23:03:28 +0000 UTC
parent d414493
Only recompute bounds when they are needed
1 files changed,
+20,
-15
+20,
-15
1@@ -581,8 +581,8 @@ screen_draw_pixel(void)
2 static void
3 screen_draw_sprite(void)
4 {
5- int i, x1, x2, y1, y2, ay, by, qy, x = rX, y = rY, layer_mask;
6- int fx, fy, qfx, qfy, dxy, dyx;
7+ int i, qy, x = rX, y = rY, layer_mask;
8+ int fx, fy, qfx, qfy, dxy, dyx, row;
9 const Uint8 *table;
10 const int ctrl = dev[0x2f];
11 const int blend = ctrl & 0xf;
12@@ -606,9 +606,10 @@ screen_draw_sprite(void)
13 if(xmar2 == xmar + 8 && xmar2 < screen_wmar2 && ymar2 < screen_hmar2) {
14 const Uint8 *sprite = &ram[rA];
15 const Uint16 ymar = y + 8;
16- for(ay = ymar * screen_wmar2, by = ymar2 * screen_wmar2, qy = qfy; ay < by; ay += screen_wmar2, qy += fy) {
17+ const int height = ymar2 - ymar;
18+ Uint8 *dst = &screen_layers[xmar + ymar * screen_wmar2];
19+ for(row = 0, qy = qfy; row < height; row++, dst += screen_wmar2, qy += fy) {
20 const int ch1 = sprite[qy], ch2 = sprite[qy + 8] << 1;
21- Uint8 *dst = &screen_layers[xmar + ay];
22 if(opaque) {
23 o2BPP(0) o2BPP(1) o2BPP(2) o2BPP(3) o2BPP(4) o2BPP(5) o2BPP(6) o2BPP(7)
24 } else {
25@@ -624,9 +625,10 @@ screen_draw_sprite(void)
26 if(xmar2 == xmar + 8 && xmar2 < screen_wmar2 && ymar2 < screen_hmar2) {
27 const Uint8 *sprite = &ram[rA];
28 const Uint16 ymar = y + 8;
29- for(ay = ymar * screen_wmar2, by = ymar2 * screen_wmar2, qy = qfy; ay < by; ay += screen_wmar2, qy += fy) {
30+ const int height = ymar2 - ymar;
31+ Uint8 *dst = &screen_layers[xmar + ymar * screen_wmar2];
32+ for(row = 0, qy = qfy; row < height; row++, dst += screen_wmar2, qy += fy) {
33 const int ch1 = sprite[qy];
34- Uint8 *dst = &screen_layers[xmar + ay];
35 if(opaque) {
36 o1BPP(0) o1BPP(1) o1BPP(2) o1BPP(3) o1BPP(4) o1BPP(5) o1BPP(6) o1BPP(7)
37 } else {
38@@ -636,15 +638,18 @@ screen_draw_sprite(void)
39 }
40 }
41 }
42- if(fx < 0)
43- x1 = x, x2 = rX;
44- else
45- x1 = rX, x2 = x;
46- if(fy < 0)
47- y1 = y, y2 = rY;
48- else
49- y1 = rY, y2 = y;
50- if(!screen_reqdraw) screen_change(x1 - 8, y1 - 8, x2 + 8, y2 + 8);
51+ if(!screen_reqdraw) {
52+ int x1, x2, y1, y2;
53+ if(fx < 0)
54+ x1 = x, x2 = rX;
55+ else
56+ x1 = rX, x2 = x;
57+ if(fy < 0)
58+ y1 = y, y2 = rY;
59+ else
60+ y1 = rY, y2 = y;
61+ screen_change(x1 - 8, y1 - 8, x2 + 8, y2 + 8);
62+ }
63 if(rMX) rX += rDX * fx;
64 if(rMY) rY += rDY * fy;
65 }