(screen) Tiny improvement to drawing pointer

This commit is contained in:
Devine Lu Linvega 2024-01-20 17:14:55 -08:00
parent b1f81dcd69
commit 2eb7c87af6
2 changed files with 15 additions and 15 deletions

View File

@ -17,9 +17,9 @@
@on-mouse ( -> ) @on-mouse ( -> )
( | clear background ) ( | clear background )
#0000 DUP2 .Screen/x DEO2 ( #0000 DUP2 .Screen/x DEO2
.Screen/y DEO2 .Screen/y DEO2
#80 .Screen/pixel DEO #80 .Screen/pixel DEO )
<draw-guide> <draw-guide>
( | cursor ) ( | cursor )
#41 ;cursor-icn <update-cursor> #41 ;cursor-icn <update-cursor>

View File

@ -89,6 +89,7 @@ screen_change(int x1, int y1, int x2, int y2)
if(x2 > uxn_screen.x2) uxn_screen.x2 = x2; if(x2 > uxn_screen.x2) uxn_screen.x2 = x2;
if(y2 > uxn_screen.y2) uxn_screen.y2 = y2; if(y2 > uxn_screen.y2) uxn_screen.y2 = y2;
} }
/* clang-format off */ /* clang-format off */
static Uint8 icons[] = { static Uint8 icons[] = {
@ -302,24 +303,23 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port)
Uint8 twobpp = !!(ctrl & 0x80); Uint8 twobpp = !!(ctrl & 0x80);
Uint8 color = ctrl & 0xf; Uint8 color = ctrl & 0xf;
Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg; Uint8 *layer = ctrl & 0x40 ? uxn_screen.fg : uxn_screen.bg;
int fx = ctrl & 0x10 ? -1 : 1; int fx = ctrl & 0x10 ? -1 : 1, fy = ctrl & 0x20 ? -1 : 1;
int fy = ctrl & 0x20 ? -1 : 1; int x1, x2, y1, y2, x = rX, y = rY;
int x1, x2, y1, y2;
int dxy = rDX * fy, dyx = rDY * fx, addr_incr = rMA << (1 + twobpp); int dxy = rDX * fy, dyx = rDY * fx, addr_incr = rMA << (1 + twobpp);
if(twobpp) if(twobpp)
for(i = 0; i <= rML; i++, rA += addr_incr) for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
screen_2bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy); screen_2bpp(layer, &ram[rA], x, y, color, fx, fy);
else else
for(i = 0; i <= rML; i++, rA += addr_incr) for(i = 0; i <= rML; i++, x += dyx, y += dxy, rA += addr_incr)
screen_1bpp(layer, &ram[rA], rX + dyx * i, rY + dxy * i, color, fx, fy); screen_1bpp(layer, &ram[rA], x, y, color, fx, fy);
if(fx == -1) if(fx < 0)
x1 = rX + dyx * rML, x2 = rX; x1 = x, x2 = rX;
else else
x1 = rX, x2 = rX + dyx * rML; x1 = rX, x2 = x;
if(fy == -1) if(fy < 0)
y1 = rY + dxy * rML, y2 = rY; y1 = y, y2 = rY;
else else
y1 = rY, y2 = rY + dxy * rML; y1 = rY, y2 = y;
screen_change(x1, y1, x2 + 8, y2 + 8); screen_change(x1, y1, x2 + 8, y2 + 8);
if(rMX) rX += rDX * fx; if(rMX) rX += rDX * fx;
if(rMY) rY += rDY * fy; if(rMY) rY += rDY * fy;