uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 789fb0cd8b1b2fb6818370c5bf935c63371d78a0
parent d6691fddef77d74fc86f479f2b0abde5c8f55af4
Author: neauoire <aliceffekt@gmail.com>
Date:   Sat,  5 Aug 2023 09:59:08 -0700

(screen.c) Faster sprite drawing

Diffstat:
Msrc/devices/screen.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -185,16 +185,18 @@ screen_deo(Uint8 *ram, Uint8 *d, Uint8 port) Uint8 length = move >> 4; Uint8 twobpp = !!(ctrl & 0x80); Uint8 *layer = (ctrl & 0x40) ? uxn_screen.fg : uxn_screen.bg; + Uint8 color = ctrl & 0xf; Uint16 x = PEEK2(d + 0x8), dx = (move & 0x1) << 3; Uint16 y = PEEK2(d + 0xa), dy = (move & 0x2) << 2; - Uint16 addr = PEEK2(d + 0xc); + Uint16 addr = PEEK2(d + 0xc), addr_incr = (move & 0x4) << (1 + twobpp); int flipx = (ctrl & 0x10), fx = flipx ? -1 : 1; int flipy = (ctrl & 0x20), fy = flipy ? -1 : 1; + Uint16 dyx = dy * fx, dxy = dx * fy; for(i = 0; i <= length; i++) { - screen_blit(layer, ram, addr, x + dy * i * fx, y + dx * i * fy, ctrl & 0xf, flipx, flipy, twobpp); - addr += (move & 0x4) << (1 + twobpp); + screen_blit(layer, ram, addr, x + dyx * i, y + dxy * i, color, flipx, flipy, twobpp); + addr += addr_incr; } - screen_change(x, y, x + dy * length * fx + 8, y + dx * length * fy + 8); + screen_change(x, y, x + dyx * length + 8, y + dxy * length + 8); if(move & 0x1) POKE2(d + 0x8, x + dx * fx); /* auto x+8 */ if(move & 0x2) POKE2(d + 0xa, y + dy * fy); /* auto y+8 */ if(move & 0x4) POKE2(d + 0xc, addr); /* auto addr+length */