uxn

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

commit 1b04e0814bbe1a1837e5f61a407a5af0ef3ff141
parent 11c9ec8b49ae650005a3b7bd74269ff58ab09635
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Sun,  6 Mar 2022 13:36:47 +0000

(draft) Add looping functionality to Screen/auto.

Diffstat:
Aprojects/examples/devices/screen.auto.tal | 30++++++++++++++++++++++++++++++
Msrc/devices/screen.c | 16++++++++++++----
2 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/projects/examples/devices/screen.auto.tal b/projects/examples/devices/screen.auto.tal @@ -0,0 +1,30 @@ +( devices ) + +|00 @System &vector $2 &wst $1 &rst $1 &swsz $1 &swap $1 &pad $2 &r $2 &g $2 &b $2 &debug $1 &halt $1 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 + +( variables ) + +|0000 + +( program ) + +|0100 ( -> ) + ( theme ) + #0fe5 .System/r DEO2 + #0fc5 .System/g DEO2 + #0f25 .System/b DEO2 + + #35 .Screen/auto DEO + + ;font #0210 ADD2 .Screen/addr DEO2 + #3400 &loop + #04 .Screen/sprite DEO + INC + GTHk ,&loop JCN + +BRK + +~projects/assets/msx01x02.tal + + diff --git a/src/devices/screen.c b/src/devices/screen.c @@ -157,7 +157,7 @@ screen_deo(Device *d, Uint8 port) break; } case 0xf: { - Uint16 x, y, addr; + Uint16 x, y, addr, auto_i; Uint8 twobpp = !!(d->dat[0xf] & 0x80); Layer *layer = (d->dat[0xf] & 0x40) ? &uxn_screen.fg : &uxn_screen.bg; DEVPEEK16(x, 0x8); @@ -166,9 +166,17 @@ screen_deo(Device *d, Uint8 port) if(addr > 0xfff8 - twobpp * 8) 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); - if(d->dat[0x6] & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */ - if(d->dat[0x6] & 0x01) DEVPOKE16(0x8, x + 8); /* auto x+8 */ - if(d->dat[0x6] & 0x02) DEVPOKE16(0xa, y + 8); /* auto y+8 */ + 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)); + } + if(auto_i & 0x04) DEVPOKE16(0xc, addr + 8 + twobpp * 8); /* auto addr+length */ break; } }