From 314dd5a4319494a821f50088df781bf66fd9670b Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Sun, 6 Mar 2022 16:20:16 +0000 Subject: [PATCH] screen/auto: Replace draft looping with block width control. --- projects/examples/devices/screen.auto.tal | 2 +- src/devices/screen.c | 26 +++++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/projects/examples/devices/screen.auto.tal b/projects/examples/devices/screen.auto.tal index e5ef608..494c2ab 100644 --- a/projects/examples/devices/screen.auto.tal +++ b/projects/examples/devices/screen.auto.tal @@ -18,7 +18,7 @@ #35 .Screen/auto DEO ;font #0210 ADD2 .Screen/addr DEO2 - #3400 &loop + #0d00 &loop #04 .Screen/sprite DEO INC GTHk ,&loop JCN diff --git a/src/devices/screen.c b/src/devices/screen.c index 1f1dbd4..83cfeab 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -157,26 +157,24 @@ screen_deo(Device *d, Uint8 port) break; } case 0xf: { - Uint16 x, y, addr, auto_i; - Uint8 twobpp = !!(d->dat[0xf] & 0x80); + Uint16 x, y, dx, dy, addr; + Uint8 i, n, twobpp = !!(d->dat[0xf] & 0x80); Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; DEVPEEK16(x, 0x8); DEVPEEK16(y, 0xa); DEVPEEK16(addr, 0xc); - if(addr > 0xfff8 - twobpp * 8) + n = d->dat[0x6] >> 4; + dx = (d->dat[0x6] & 0x01) << 3; + dy = (d->dat[0x6] & 0x02) << 2; + if(addr > 0xfff8 - twobpp * 8 * (n + 1)) return; - screen_blit(&uxn_screen, layer, x, y, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp); - auto_i = d->dat[0x6] + 0x40; - if((auto_i >> 6) > ((auto_i & 0x30) >> 4)) { - d->dat[0x6] = auto_i & 0x3f; - DEVPOKE16(0x8, x + ((auto_i & 0x01) << 3) - ((auto_i & 0x02) * (auto_i & 0x30) >> 2)); - DEVPOKE16(0xa, y + ((auto_i & 0x02) << 2) - ((auto_i & 0x01) * (auto_i & 0x30) >> 1)); - } else { - d->dat[0x6] = auto_i; - DEVPOKE16(0x8, x + ((auto_i & 0x02) << 2)); - DEVPOKE16(0xa, y + ((auto_i & 0x01) << 3)); + for(i = 0; i <= n; i++) { + screen_blit(&uxn_screen, layer, x + dy * i, y + dx * i, &d->u->ram[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp); + addr += (d->dat[0x6] & 0x04) << (1 + twobpp); } - if(auto_i & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */ + DEVPOKE16(0xc, addr); /* auto addr+length */ + DEVPOKE16(0x8, x + dx); /* auto x+8 */ + DEVPOKE16(0xa, y + dy); /* auto y+8 */ break; } }