uxn

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

commit 4cbb661f4847cb822009bd4dded3b263c63b83fe
parent 0fd288de79a225fcd20d776203abde215634e166
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Wed,  5 Jan 2022 17:27:01 +0000

Implement System/vector for debugging.

Diffstat:
Mprojects/examples/blank.tal | 4++--
Msrc/devices/system.c | 11+++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal @@ -22,9 +22,9 @@ ( devices ) -|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 +|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &r $2 &g $2 &b $2 &debug $1 &halt $1 |10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1 -|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |40 @Audio1 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 |50 @Audio2 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 diff --git a/src/devices/system.c b/src/devices/system.c @@ -25,6 +25,16 @@ static const char *errors[] = { int uxn_halt(Uxn *u, Uint8 error, Uint16 addr) { + Device *d = &u->dev[0]; + Uint16 vec = d->vector; + if(vec) { + d->vector = 0; /* need to rearm to run System/vector again */ + DEVPOKE16(0x4, addr); + d->dat[0x6] = error; + if(error != 2) /* working stack overflow has special treatment */ + vec += 0x0004; + return uxn_eval(u, vec); + } fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr); return 0; } @@ -45,6 +55,7 @@ void system_deo(Device *d, Uint8 port) { switch(port) { + case 0x1: DEVPEEK16(d->vector, 0x0); break; case 0x2: d->u->wst.ptr = d->dat[port]; break; case 0x3: d->u->rst.ptr = d->dat[port]; break; default: system_deo_special(d, port);