commit 2eb7c87
Devine Lu Linvega
·
2024-01-21 01:14:55 +0000 UTC
parent b1f81dc
(screen) Tiny improvement to drawing pointer
2 files changed,
+15,
-15
+2,
-2
1@@ -17,9 +17,9 @@
2
3 @on-mouse ( -> )
4 ( | clear background )
5- #0000 DUP2 .Screen/x DEO2
6+ ( #0000 DUP2 .Screen/x DEO2
7 .Screen/y DEO2
8- #80 .Screen/pixel DEO
9+ #80 .Screen/pixel DEO )
10 <draw-guide>
11 ( | cursor )
12 #41 ;cursor-icn <update-cursor>
+13,
-13
1@@ -89,6 +89,7 @@ screen_change(int x1, int y1, int x2, int y2)
2 if(x2 > uxn_screen.x2) uxn_screen.x2 = x2;
3 if(y2 > uxn_screen.y2) uxn_screen.y2 = y2;
4 }
5+
6 /* clang-format off */
7
8 static Uint8 icons[] = {
9@@ -302,24 +303,23 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
10 Uint8 twobpp = !!(ctrl & 0x80);
11 Uint8 color = ctrl & 0xf;
12 Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
13- int fx = ctrl & 0x10 ? -1 : 1;
14- int fy = ctrl & 0x20 ? -1 : 1;
15- int x1, x2, y1, y2;
16+ int fx = ctrl & 0x10 ? -1 : 1, fy = ctrl & 0x20 ? -1 : 1;
17+ int x1, x2, y1, y2, x = rX, y = rY;
18 int dxy = rDX * fy, dyx = rDY * fx, addr_incr = rMA << (1 + twobpp);
19 if(twobpp)
20- for(i = 0; i <= rML; i++, rA += addr_incr)
21- screen_2bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy);
22+ for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
23+ screen_2bpp(layer, &ram[rA], x, y, color, fx, fy);
24 else
25- for(i = 0; i <= rML; i++, rA += addr_incr)
26- screen_1bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy);
27- if(fx == -1)
28- x1 = rX + dyx * rML, x2 = rX;
29+ for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
30+ screen_1bpp(layer, &ram[rA], x, y, color, fx, fy);
31+ if(fx < 0)
32+ x1 = x, x2 = rX;
33 else
34- x1 = rX, x2 = rX + dyx * rML;
35- if(fy == -1)
36- y1 = rY + dxy * rML, y2 = rY;
37+ x1 = rX, x2 = x;
38+ if(fy < 0)
39+ y1 = y, y2 = rY;
40 else
41- y1 = rY, y2 = rY + dxy * rML;
42+ y1 = rY, y2 = y;
43 screen_change(x1, y1, x2 + 8, y2 + 8);
44 if(rMX) rX += rDX * fx;
45 if(rMY) rY += rDY * fy;