uxn

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

commit 274edad29da18a28a1e5e81031b4492a44a596e3
parent e309ebf6e88b460a838a2229dd7ab55714ca80e9
Author: neauoire <aliceffekt@gmail.com>
Date:   Mon, 28 Jun 2021 09:40:29 -0700

Simplified console

Diffstat:
Mprojects/examples/blank.tal | 2+-
Mprojects/examples/demos/darena.tal | 4----
Mprojects/examples/demos/drum-rack.tal | 1-
Mprojects/examples/demos/musictracker.tal | 1-
Mprojects/examples/demos/neralie.tal | 1-
Mprojects/examples/demos/piano.tal | 4++--
Mprojects/examples/devices/console.echo.tal | 15++++++++++-----
Mprojects/examples/devices/console.tal | 4++--
Mprojects/examples/devices/controller.keys.tal | 4----
Mprojects/examples/gui/hover.tal | 3---
Mprojects/examples/gui/picture.tal | 1-
Mprojects/examples/gui/shapes.tal | 1-
Aprojects/software/hexes.tal | 32++++++++++++++++++++++++++++++++
Msrc/devices/ppu.c | 8--------
Msrc/uxnemu.c | 12++----------
15 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/projects/examples/blank.tal b/projects/examples/blank.tal @@ -11,7 +11,7 @@ ( devices ) |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $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 ] diff --git a/projects/examples/demos/darena.tal b/projects/examples/demos/darena.tal @@ -2,9 +2,6 @@ ( an open-ended game of rocks and sand ) ( contributed by and cc0 sejo 12021 ) -%DEBUG { .Console/byte DEO #0a .Console/char DEO } -%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO } - ( parameters ) %nrocks { #1f } %nrocks-1 { #1e } @@ -37,7 +34,6 @@ ( devices ) |00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] -|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ] diff --git a/projects/examples/demos/drum-rack.tal b/projects/examples/demos/drum-rack.tal @@ -24,7 +24,6 @@ ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $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 ] diff --git a/projects/examples/demos/musictracker.tal b/projects/examples/demos/musictracker.tal @@ -23,7 +23,6 @@ ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ] |40 @Audio1 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &len $2 &addr $2 &volume $1 &pitch $1 ] diff --git a/projects/examples/demos/neralie.tal b/projects/examples/demos/neralie.tal @@ -13,7 +13,6 @@ ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal @@ -19,7 +19,7 @@ ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &rbyte $1 &pad $5 &char $1 &wbyte $1 &short $2 &string $2 ] +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |70 @Midi [ &vector $2 &channel $1 &note $1 &velocity $1 ] @@ -155,7 +155,7 @@ BRK @on-message ( -> ) - .Console/rbyte DEI ;play JSR2 + .Console/read DEI ;play JSR2 ;draw-octave JSR2 BRK diff --git a/projects/examples/devices/console.echo.tal b/projects/examples/devices/console.echo.tal @@ -1,14 +1,20 @@ ( dev/console ) -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] +%RTN { JMP2r } + +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ] ( init ) |0100 ( -> ) + ;on-stdin .Console/vector DEO2 + BRK @on-stdin ( -> ) - .Console/char DEI .Console/byte DEO - #0a .Console/char DEO -BRK -\ No newline at end of file + + .Console/read DEI .Console/write DEO + +BRK + diff --git a/projects/examples/devices/console.tal b/projects/examples/devices/console.tal @@ -1,6 +1,6 @@ ( dev/console ) -|10 @Console [ &pad $8 &char ] +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ] ( init ) @@ -9,7 +9,7 @@ ;hello-word &loop - ( send ) LDAk .Console/char DEO + ( send ) LDAk .Console/write DEO ( incr ) #0001 ADD2 ( loop ) LDAk ,&loop JCN POP2 diff --git a/projects/examples/devices/controller.keys.tal b/projects/examples/devices/controller.keys.tal @@ -8,13 +8,9 @@ %RTN { JMP2r } %TOS { #00 SWP } -%DEBUG { .Console/byte DEO #0a .Console/char DEO } -%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO } - ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ] diff --git a/projects/examples/gui/hover.tal b/projects/examples/gui/hover.tal @@ -1,13 +1,10 @@ ( GUI Hover ) %RTN { JMP2r } -%DEBUG { .Console/byte DEO #0a .Console/char DEO } -%DEBUG2 { .Console/short DEO2 #0a .Console/char DEO } ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] diff --git a/projects/examples/gui/picture.tal b/projects/examples/gui/picture.tal @@ -6,7 +6,6 @@ ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |a0 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ] diff --git a/projects/examples/gui/shapes.tal b/projects/examples/gui/shapes.tal @@ -17,7 +17,6 @@ ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|10 @Console [ &vector $2 &pad $6 &char $1 &byte $1 &short $2 &string $2 ] |20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] ( variables ) diff --git a/projects/software/hexes.tal b/projects/software/hexes.tal @@ -0,0 +1,32 @@ +( hexes + + A small utility that prints incoming console messages as hex values. ) + +%RTN { JMP2r } + +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 ] + +( init ) + +|0100 ( -> ) + + ;on-message .Console/vector DEO2 + +BRK + +@on-message ( -> ) + + .Console/read DEI ,print-hex JSR + +BRK + +@print-hex ( value -- ) + + STHk #04 SFT ,&parse JSR .Console/write DEO + STHr #0f AND ,&parse JSR .Console/write DEO + RTN + &parse ( value -- char ) + DUP #09 GTH ,&above JCN #30 ADD RTN &above #09 SUB #60 ADD RTN + +RTN + diff --git a/src/devices/ppu.c b/src/devices/ppu.c @@ -30,14 +30,6 @@ static Uint8 font[][8] = { {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x82, 0x7c}, {0x00, 0x7c, 0x82, 0x80, 0xf0, 0x80, 0x80, 0x80}}; -Uint8 -readpixel(Uint8 *sprite, Uint8 h, Uint8 v) -{ - Uint8 ch1 = ((sprite[v] >> h) & 0x1); - Uint8 ch2 = (((sprite[v + 8] >> h) & 0x1) << 1); - return ch1 + ch2; -} - void clear(Ppu *p) { diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -235,16 +235,8 @@ system_talk(Device *d, Uint8 b0, Uint8 w) void console_talk(Device *d, Uint8 b0, Uint8 w) { - char buffer[7], *p = buffer; - int len = 0; - if(!w) return; - switch(b0) { - case 0x8: len = 1, p = (char *)&d->dat[0x8]; break; - case 0x9: len = sprintf(p, "0x%02x", d->dat[0x9]); break; - case 0xb: len = sprintf(p, "0x%04x", mempeek16(d->dat, 0xa)); break; - case 0xd: len = strlen(p = (char *)&d->mem[mempeek16(d->dat, 0xc)]); break; - } - if(len) write(1, p, len); + if(w && b0 == 0x8) + write(1, (char *)&d->dat[0x8], 1); } void