screen/auto: Replace draft looping with block width control.

This commit is contained in:
Andrew Alderwick 2022-03-06 16:20:16 +00:00
parent 941ac55f1f
commit 314dd5a431
2 changed files with 13 additions and 15 deletions

View File

@ -18,7 +18,7 @@
#35 .Screen/auto DEO #35 .Screen/auto DEO
;font #0210 ADD2 .Screen/addr DEO2 ;font #0210 ADD2 .Screen/addr DEO2
#3400 &loop #0d00 &loop
#04 .Screen/sprite DEO #04 .Screen/sprite DEO
INC INC
GTHk ,&loop JCN GTHk ,&loop JCN

View File

@ -157,26 +157,24 @@ screen_deo(Device *d, Uint8 port)
break; break;
} }
case 0xf: { case 0xf: {
Uint16 x, y, addr, auto_i; Uint16 x, y, dx, dy, addr;
Uint8 twobpp = !!(d->dat[0xf] & 0x80); Uint8 i, n, twobpp = !!(d->dat[0xf] & 0x80);
Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg;
DEVPEEK16(x, 0x8); DEVPEEK16(x, 0x8);
DEVPEEK16(y, 0xa); DEVPEEK16(y, 0xa);
DEVPEEK16(addr, 0xc); 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; 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); for(i = 0; i <= n; i++) {
auto_i = d->dat[0x6] + 0x40; 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);
if((auto_i >> 6) > ((auto_i & 0x30) >> 4)) { addr += (d->dat[0x6] & 0x04) << (1 + twobpp);
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));
} }
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; break;
} }
} }