From f5278f3a13f04c003a935f7c9a99994bf376cecd Mon Sep 17 00:00:00 2001 From: neauoire Date: Fri, 7 Jan 2022 16:46:50 -0800 Subject: [PATCH 01/39] Removed device vector variable --- src/devices/controller.c | 8 ++++---- src/devices/file.c | 3 --- src/devices/mouse.c | 8 ++++---- src/devices/screen.c | 1 - src/devices/system.c | 9 +++++---- src/uxn.h | 2 +- src/uxncli.c | 7 +++---- src/uxnemu.c | 11 +++++------ 8 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/devices/controller.c b/src/devices/controller.c index cfc19e7..261b05f 100644 --- a/src/devices/controller.c +++ b/src/devices/controller.c @@ -18,7 +18,7 @@ controller_down(Device *d, Uint8 mask) { if(mask) { d->dat[2] |= mask; - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); } } @@ -27,7 +27,7 @@ controller_up(Device *d, Uint8 mask) { if(mask) { d->dat[2] &= (~mask); - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); } } @@ -36,7 +36,7 @@ controller_key(Device *d, Uint8 key) { if(key) { d->dat[3] = key; - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); d->dat[3] = 0x00; } } @@ -46,7 +46,7 @@ controller_special(Device *d, Uint8 key) { if(key) { d->dat[4] = key; - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); d->dat[4] = 0x00; } } \ No newline at end of file diff --git a/src/devices/file.c b/src/devices/file.c index b3b76f2..f5b8b8f 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -146,9 +146,6 @@ file_deo(Device *d, Uint8 port) { Uint16 a, b, res; switch(port) { - case 0x1: - DEVPEEK16(d->vector, 0x0); - break; case 0x5: DEVPEEK16(a, 0x4); DEVPEEK16(b, 0xa); diff --git a/src/devices/mouse.c b/src/devices/mouse.c index dacd2ab..d96a367 100644 --- a/src/devices/mouse.c +++ b/src/devices/mouse.c @@ -17,14 +17,14 @@ void mouse_down(Device *d, Uint8 mask) { d->dat[6] |= mask; - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); } void mouse_up(Device *d, Uint8 mask) { d->dat[6] &= (~mask); - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); } void @@ -32,7 +32,7 @@ mouse_pos(Device *d, Uint16 x, Uint16 y) { DEVPOKE16(0x2, x); DEVPOKE16(0x4, y); - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); } void @@ -40,7 +40,7 @@ mouse_scroll(Device *d, Uint16 x, Uint16 y) { DEVPOKE16(0xa, x); DEVPOKE16(0xc, -y); - uxn_eval(d->u, d->vector); + uxn_eval(d->u, GETVECTOR(d)); DEVPOKE16(0xa, 0); DEVPOKE16(0xc, 0); } diff --git a/src/devices/screen.c b/src/devices/screen.c index 0d733ec..3f8df56 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -127,7 +127,6 @@ void screen_deo(Device *d, Uint8 port) { switch(port) { - case 0x1: DEVPEEK16(d->vector, 0x0); break; case 0x5: if(!FIXED_SIZE) { Uint16 w, h; diff --git a/src/devices/system.c b/src/devices/system.c index aaf198c..be7af1f 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -28,12 +28,14 @@ int uxn_halt(Uxn *u, Uint8 error, Uint16 addr) { Device *d = &u->dev[0]; - Uint16 vec = d->vector; + Uint16 vec = GETVECTOR(d); DEVPOKE16(0x4, addr); d->dat[0x6] = error; - uxn_eval(&supervisor, supervisor.dev[0].vector); + uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[0])); if(vec) { - d->vector = 0; /* need to rearm to run System/vector again */ + /* need to rearm to run System/vector again */ + d->dat[0] = 0; + d->dat[1] = 0; if(error != 2) /* working stack overflow has special treatment */ vec += 0x0004; return uxn_eval(u, vec); @@ -58,7 +60,6 @@ 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); diff --git a/src/uxn.h b/src/uxn.h index 797b414..722abd6 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -27,6 +27,7 @@ typedef unsigned int Uint32; #define DEVPEEK16(o, x) { (o) = (d->dat[(x)] << 8) + d->dat[(x) + 1]; } #define DEVPOKE16(x, y) { d->dat[(x)] = (y) >> 8; d->dat[(x) + 1] = (y); } +#define GETVECTOR(d) ((d)->dat[0] << 8 | (d)->dat[1]) /* clang-format on */ @@ -37,7 +38,6 @@ typedef struct { typedef struct Device { struct Uxn *u; Uint8 *dat, *mem; - Uint16 vector; Uint8 (*dei)(struct Device *d, Uint8); void (*deo)(struct Device *d, Uint8); } Device; diff --git a/src/uxncli.c b/src/uxncli.c index c2fc1eb..c4ff951 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -60,8 +60,6 @@ system_deo_special(Device *d, Uint8 port) static void console_deo(Device *d, Uint8 port) { - if(port == 0x1) - DEVPEEK16(d->vector, 0x0); if(port > 0x7) write(port - 0x7, (char *)&d->dat[port], 1); } @@ -75,7 +73,8 @@ nil_dei(Device *d, Uint8 port) static void nil_deo(Device *d, Uint8 port) { - if(port == 0x1) DEVPEEK16(d->vector, 0x0); + (void)d; + (void)port; } #pragma mark - Generics @@ -84,7 +83,7 @@ static int console_input(Uxn *u, char c) { devconsole->dat[0x2] = c; - return uxn_eval(u, devconsole->vector); + return uxn_eval(u, GETVECTOR(devconsole)); } static void diff --git a/src/uxnemu.c b/src/uxnemu.c index 00442de..c877130 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -180,8 +180,6 @@ system_deo_special(Device *d, Uint8 port) static void console_deo(Device *d, Uint8 port) { - if(port == 0x1) - DEVPEEK16(d->vector, 0x0); if(port > 0x7) write(port - 0x7, (char *)&d->dat[port], 1); } @@ -228,7 +226,8 @@ nil_dei(Device *d, Uint8 port) static void nil_deo(Device *d, Uint8 port) { - if(port == 0x1) DEVPEEK16(d->vector, 0x0); + (void)d; + (void)port; } /* Boot */ @@ -409,7 +408,7 @@ static int console_input(Uxn *u, char c) { devconsole->dat[0x2] = c; - return uxn_eval(u, devconsole->vector); + return uxn_eval(u, GETVECTOR(devconsole)); } static int @@ -483,8 +482,8 @@ run(Uxn *u) console_input(u, event.cbutton.button); } if(devsystem->dat[0xe]) - uxn_eval(&supervisor, supervisor.dev[2].vector); - uxn_eval(u, devscreen->vector); + uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[2])); + uxn_eval(u, GETVECTOR(devscreen)); if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe]) redraw(); if(!BENCH) { From c866b0938a906c877626656d6215acf1e2ce0892 Mon Sep 17 00:00:00 2001 From: neauoire Date: Fri, 7 Jan 2022 16:51:43 -0800 Subject: [PATCH 02/39] Use proper memory size --- src/uxncli.c | 6 +++--- src/uxnemu.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uxncli.c b/src/uxncli.c index c4ff951..8ffa594 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -103,7 +103,7 @@ load(Uxn *u, char *filepath) FILE *f; int r; if(!(f = fopen(filepath, "rb"))) return 0; - r = fread(u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM, f); + r = fread(u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM, f); fclose(f); if(r < 1) return 0; fprintf(stderr, "Loaded %s\n", filepath); @@ -118,8 +118,8 @@ main(int argc, char **argv) Uxn u; int i, loaded = 0; - shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8)); - memory = (Uint8 *)calloc(0xffff, sizeof(Uint8)); + shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST))) return error("Boot", "Failed"); diff --git a/src/uxnemu.c b/src/uxnemu.c index c877130..c814744 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -238,7 +238,7 @@ load(Uxn *u, char *rom) SDL_RWops *f; int r; if(!(f = SDL_RWFromFile(rom, "rb"))) return 0; - r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0xffff - PAGE_PROGRAM); + r = f->read(f, u->ram + PAGE_PROGRAM, 1, 0x10000 - PAGE_PROGRAM); f->close(f); if(r < 1) return 0; fprintf(stderr, "Loaded %s\n", rom); @@ -251,8 +251,8 @@ static Uint8 *shadow, *memory; static int start(Uxn *u, char *rom) { - memory = (Uint8 *)calloc(0xffff, sizeof(Uint8)); - shadow = (Uint8 *)calloc(0xffff, sizeof(Uint8)); + memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8)); if(!uxn_boot(&supervisor, shadow, shadow + VISOR_DEV, (Stack *)(shadow + VISOR_WST), (Stack *)(shadow + VISOR_RST))) return error("Boot", "Failed to start uxn."); From 78f38e80e59fd2ad4cbc2002aab42cbcb344e533 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 09:07:32 -0800 Subject: [PATCH 03/39] Added TODOs --- TODO | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..8ee7ae0 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +# TODOs + +- Emulation controls should be handled by the supervisor. +- Overlap the supervisor device page with the core device page. +- The boot rom should display "no roms" when the list is empty. +- From 5004ee1339386838c17f8d311f2462f91adebc1f Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 10:03:21 -0800 Subject: [PATCH 04/39] The file device cannot write on the supervisor --- projects/software/supervisor.tal | 8 ++++++-- src/devices/file.c | 8 ++++---- src/devices/file.h | 2 ++ src/uxncli.c | 9 +++++---- src/uxnemu.c | 16 +++++++++------- 5 files changed, 26 insertions(+), 17 deletions(-) diff --git a/projects/software/supervisor.tal b/projects/software/supervisor.tal index 0802cb2..04eba6b 100644 --- a/projects/software/supervisor.tal +++ b/projects/software/supervisor.tal @@ -67,7 +67,7 @@ BRK @on-button ( -> ) - .Controller/func DEI + .Controller/func DEI DUP DEBUG DUP #02 ! ,&no-f2 JCN ;toggle-debugger JSR2 &no-f2 @@ -124,7 +124,8 @@ BRK @toggle-debugger ( -- ) - ( toggle debug ) #fd0e STH2k LDA #00 = STH2r STA + ( toggle debug ) + ( #fd0e STH2k LDA #00 = STH2r STA ) RTN @@ -133,6 +134,9 @@ RTN ( clear devices/stacks ) #fd00 #0300 ;mclr JSR2 + ( load rom ) + + RTN &boot-path "boot.rom $1 diff --git a/src/devices/file.c b/src/devices/file.c index d803ba6..5a2206b 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -149,7 +149,7 @@ file_deo(Device *d, Uint8 port) case 0x5: DEVPEEK16(a, 0x4); DEVPEEK16(b, 0xa); - res = file_stat(&d->mem[a], b); + res = file_stat(&memory[a], b); DEVPOKE16(0x2, res); break; case 0x6: @@ -158,19 +158,19 @@ file_deo(Device *d, Uint8 port) break; case 0x9: DEVPEEK16(a, 0x8); - res = file_init(&d->mem[a]); + res = file_init(&memory[a]); DEVPOKE16(0x2, res); break; case 0xd: DEVPEEK16(a, 0xc); DEVPEEK16(b, 0xa); - res = file_read(&d->mem[a], b); + res = file_read(&memory[a], b); DEVPOKE16(0x2, res); break; case 0xf: DEVPEEK16(a, 0xe); DEVPEEK16(b, 0xa); - res = file_write(&d->mem[a], b, d->dat[0x7]); + res = file_write(&memory[a], b, d->dat[0x7]); DEVPOKE16(0x2, res); break; } diff --git a/src/devices/file.h b/src/devices/file.h index 26c4ff1..9df401d 100644 --- a/src/devices/file.h +++ b/src/devices/file.h @@ -11,3 +11,5 @@ WITH REGARD TO THIS SOFTWARE. */ void file_deo(Device *d, Uint8 port); + +extern Uint8 *memory; \ No newline at end of file diff --git a/src/uxncli.c b/src/uxncli.c index 8ffa594..319401f 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -4,6 +4,9 @@ #include #include "uxn.h" + +Uint8 *supervisor_memory, *memory; + #include "devices/system.h" #include "devices/file.h" #include "devices/datetime.h" @@ -110,17 +113,15 @@ load(Uxn *u, char *filepath) return 1; } -static Uint8 *shadow, *memory; - int main(int argc, char **argv) { Uxn u; int i, loaded = 0; - shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(&u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST))) + if(!uxn_boot(&u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST))) return error("Boot", "Failed"); /* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c index c814744..95fde74 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -1,8 +1,11 @@ #include #include #include + #include "uxn.h" +Uint8 *supervisor_memory, *memory; + #pragma GCC diagnostic push #pragma clang diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" @@ -246,17 +249,15 @@ load(Uxn *u, char *rom) return 1; } -static Uint8 *shadow, *memory; - static int start(Uxn *u, char *rom) { memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - shadow = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(&supervisor, shadow, shadow + VISOR_DEV, (Stack *)(shadow + VISOR_WST), (Stack *)(shadow + VISOR_RST))) + if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST))) return error("Boot", "Failed to start uxn."); - if(!uxn_boot(u, memory, shadow + PAGE_DEV, (Stack *)(shadow + PAGE_WST), (Stack *)(shadow + PAGE_RST))) + if(!uxn_boot(u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST))) return error("Boot", "Failed to start uxn."); if(!load(&supervisor, "supervisor.rom")) error("Supervisor", "No debugger found."); @@ -458,10 +459,11 @@ run(Uxn *u) controller_key(devctrl, get_key(&event)); else if(get_button(&event)) controller_down(devctrl, get_button(&event)); - /* else if(get_fkey(&event)) - controller_special(&supervisor.dev[0x8], get_fkey(&event)); */ else do_shortcut(u, &event); + /* function keys are sent to supervisor */ + if(get_fkey(&event)) + controller_special(&supervisor.dev[0x8], get_fkey(&event)); ksym = event.key.keysym.sym; if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym) break; From 35b0d84ceb038346f4a69784d6f8bf09b7416ae4 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 13:34:26 -0800 Subject: [PATCH 05/39] (boot.tal) Optimizaitons --- projects/software/boot.tal | 347 ++++++++++++++----------------------- 1 file changed, 131 insertions(+), 216 deletions(-) diff --git a/projects/software/boot.tal b/projects/software/boot.tal index 6c3fb7a..a87cba3 100644 --- a/projects/software/boot.tal +++ b/projects/software/boot.tal @@ -5,22 +5,18 @@ %++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } -%8// { #03 SFT2 } -%10** { #40 SFT2 } %10// { #04 SFT2 } +%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } +%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 } +%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 } +%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 } +%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 } -%MIN2 { LTH2k JMP SWP2 POP2 } -%MOD { DIVk MUL SUB } -%DEC { #01 - } %RTN { JMP2r } %TOS { #00 SWP } -%SWP? { #01 JCN SWP } %SWP2? { #01 JCN SWP2 } -%BRK? { #01 JCN BRK } -%RTN? { #01 JCN RTN } -%DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO } -%DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO } - -%SEL-ENTRY { ;dir/entries #00 .browser/sel LDZ DUP2 ADD2 ADD2 } +%AUTO-NONE { #00 .Screen/auto DEO } +%AUTO-XADDR { #05 .Screen/auto DEO } +%AUTO-YADDR { #06 .Screen/auto DEO } ( devices ) @@ -40,8 +36,8 @@ @pointer &x $2 &y $2 @browser - &x $2 &y $2 - &sel $1 &last $1 + &x $2 &y $2 &x2 $2 &y2 $2 + &sel $1 &last $1 &scroll $1 ( init ) @@ -63,18 +59,15 @@ #0100 .Audio0/length DEO2 #dd .Audio0/volume DEO ( TODO: turn ON ) - ( determine max visible file length ) - .Screen/width DEI2 8// #00ff MIN2 NIP - ;draw-browser/clear-length STA - ( place ) #0088 .browser/x STZ2 #0010 .browser/y STZ2 + .Screen/height DEI2 #33 SFT2 #0011 -- .browser/y2 STZ2 ( draw mascot ) #0010 #0010 #0060 #0060 ;mascot-icn #01 ;draw-icn JSR2 - ;read-dir JSR2 + ;load-dir JSR2 ( theme support ) ;load-theme JSR2 @@ -104,154 +97,116 @@ BRK .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 #41 .Mouse/state DEI #01 = + .Screen/sprite DEO + ( within browser ) + .Mouse/y DEI2 .browser/y LDZ2 << ,&outside JCN + .Mouse/y DEI2 .browser/y2 LDZ2 >> ,&outside JCN + ( select choice ) .Mouse/y DEI2 .browser/y LDZ2 -- 10// NIP ;select-file JSR2 + ( run choice ) .Mouse/state DEI #00 = ,&no-click JCN .browser/sel LDZ ;run-file JSR2 &no-click + &outside + BRK @on-button ( -> ) + ( controller ) .Controller/button DEI DUP #10 ! ,&no-up JCN - .browser/sel LDZ DEC ;select-file JSR2 + .browser/sel LDZ #00 = ,&no-up JCN + .browser/sel LDZ #01 - ;select-file JSR2 POP BRK &no-up DUP #20 ! ,&no-down JCN - .browser/sel LDZ INC ;select-file JSR2 + .browser/sel LDZ INC ;dir/lines LDA = ,&no-down JCN + .browser/sel LDZ INC ;select-file JSR2 POP BRK &no-down DUP #01 ! ,&no-a JCN - .browser/sel LDZ ;run-file JSR2 + .browser/sel LDZ ;run-file JSR2 POP BRK &no-a POP + ( keyboard ) .Controller/key DEI DUP #0d ! ,&no-enter JCN .browser/sel LDZ ;run-file JSR2 - POP + POP BRK &no-enter POP BRK -@read-dir ( -- ) +@load-dir ( -- ) ;dir/path .File/name DEO2 #1000 .File/length DEO2 ;dir/data .File/read DEO2 + .File/success DEI2 ;dir/length STA2 - ( separate into lines ) - #00 ;dir/data STH2k + ( split with null-char ) + ;dir/data &while - LDAk #0a ! ,&no-lb JCN - STAk - STH2r ;add-entry JSR2 - INC2 STH2k ,&while JMP - &no-lb INC2 LDAk ,&while JCN - POP2r POP2 POP -RTN - -@add-entry ( line* -- ) - DUP2 ;filter-entry JSR2 ,&ignored JCN - - ( just add entry to end for now, FIXME sort entries ) - ;dir/entries - #00 ;dir/lines LDA DUP2 ADD2 - ADD2 - STA2 - ;dir/lines LDAk INC ROT ROT STA - #0000 - - &ignored + LDAk #1f > ,&no-lb JCN + STH2k #00 STH2r STA + ;dir/lines LDA INC ;dir/lines STA + &no-lb + INC2 LDAk ,&while JCN POP2 -RTN -@filter-entry ( line* -- ignore-flag ) - POP2 #00 RTN @select-file ( id -- ) - ( clamp id to useful values ) - DUP #fc LTH ,¬-negative JCN - DUP EOR - ¬-negative - ;dir/lines LDA DEC LTHk SWP? POP + ( has changed ) DUP .browser/last LDZ ! ,&has-changed JCN POP RTN &has-changed - DUP ;scroll-browser JSR2 + #00 ;draw-browser JSR2 - .browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ TOS 10** ++ ] - #0010 #0010 - ;hand-icn #00 ;draw-icn JSR2 - - DUP - .browser/sel STZ - DUP - .browser/last STZ + DUP .browser/sel STZ + DUP .browser/last STZ #30 + .Audio0/pitch DEO - ;draw-browser JSR2 - .browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ TOS 10** ++ ] - #0010 #0010 - ;hand-icn #02 ;draw-icn JSR2 + ;follow-selection JSR2 + #01 ;draw-browser JSR2 + + ( draw mascot ) #0010 #0010 #0060 #0060 ;mascot-icn [ .browser/sel LDZ #03 AND TOS #0480 ** ++ ] #01 ;draw-icn JSR2 RTN -( Scroll the browser to accomodate off-screen line items ) -@scroll-browser ( id -- ) - ( Check whether the selection moved up or down ) - .browser/last LDZ OVR SWP SUB #80 AND ,&negative JCN +@follow-selection ( -- ) - &positive ( The selection moved down ) - ( Calculate the id currently at the bottom of the screen ) - .Screen/height DEI2 .browser/y LDZ2 #0010 ++ -- 10// NIP - GTH ,&scroll-up JCN [ RTN ] - &scroll-up - .browser/y LDZ2k #0010 -- ROT STZ2 - RTN - - &negative ( The selection moved up ) - ( Calculate the id currently at the top of the screen ) - ( TODO make a macro constant for y initial pos ) - #0010 .browser/y LDZ2 -- 10// NIP - - LTH ,&scroll-down JCN [ RTN ] - &scroll-down - .browser/y LDZ2k #0010 ++ ROT STZ2 ( Decrement y by 0x10 ) - RTN - -@run-file ( id -- ) - - SEL-ENTRY LDA2 - #0005 ++ DUP2 ;print-string JSR2 - #0a .Console/write DEO - - DUP2 ;check-rom JSR2 ,&valid JCN - POP2 RTN - - &valid - ;load-rom JSR2 + .browser/y2 LDZ2 .browser/y LDZ2 -- 10// NIP #01 - .browser/sel LDZ + DUP2 > ,&below JCN + DUP2 SWP - .browser/scroll STZ + POP2 RTN + &below + POP2 + #00 .browser/scroll STZ RTN -@print-string ( addr* -- ) +@run-file ( id -- ) - &loop - LDAk .Console/write DEO - INC2 LDAk ,&loop JCN - POP2 + ;get-entry JSR2 #0005 ++ + + DUP2 ;check-rom JSR2 ,&valid JCN + POP2 RTN + &valid + + ;load-rom JSR2 RTN @@ -261,86 +216,45 @@ RTN RTN -@draw-browser ( -- ) +@draw-browser ( mask -- ) - .browser/x LDZ2 .Screen/x DEO2 - .browser/y LDZ2 .Screen/y DEO2 - SEL-ENTRY ;dir/entries - &outer ( selected-entry* this-entry* ) - .Screen/y DEI2 #0010 LTH2 ,&inc JCN ( Don't draw anything in the first row ) - EQU2k #0c * #01 + STH - LDA2k ORAk #00 = ,&end JCN - ,&clear JSR - STHr ,&draw-one JSR - .browser/x LDZ2 .Screen/x DEO2 - &inc .Screen/y DEI2 #0010 ++ .Screen/y DEO2 - INC2 INC2 ,&outer JMP - &end - POP2 POP2 POP2 POPr -RTN - - &draw-one ( line* color -- ) STH + + ( draw hand ) + .browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ .browser/scroll LDZ - TOS 10** ++ ] + #0010 #0010 + ;hand-icn STHkr #03 * ;draw-icn JSR2 + ( draw files ) + .browser/y2 LDZ2 .browser/y LDZ2 -- 10// NIP #00 &loop - ( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2 - ( top-draw ) STHkr .Screen/sprite DEO - ( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2 - ( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2 - ( bottom-draw ) STHkr .Screen/sprite DEO - ( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2 - ( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - &skip - INC2 LDAk ,&loop JCN - POP2 POPr -RTN - - &clear ( -- ) - .Screen/x DEI2k ( Stash the current x pos ) - - ( Clear the screen ) - ( Clear length gets set in init ) - LIT2 &clear-length 00 00 - &clear-loop - #00 .Screen/sprite DEO - .Screen/y DEI2k #0008 ++ ROT DEO2 - #00 .Screen/sprite DEO - .Screen/y DEI2k #0008 -- ROT DEO2 - .Screen/x DEI2k #0008 ++ ROT DEO2 - INC NEQk ,&clear-loop JCN + .browser/x LDZ2 .Screen/x DEO2 + DUP TOS 10** .browser/y LDZ2 ++ .Screen/y DEO2 + DUP .browser/scroll LDZ + ;get-entry JSR2 #01 STHkr * ;draw-str JSR2 + INC GTHk ,&loop JCN POP2 - ROT DEO2 -RTN -@draw-time ( -- ) - - .DateTime/day DEI - DUP #0f AND ;hex-char JSR2 ;&date-str #0009 ++ STA - #04 SFT ;hex-char JSR2 ;&date-str #0008 ++ STA - .DateTime/month DEI - DUP #0f AND ;hex-char JSR2 ;&date-str #0006 ++ STA - #04 SFT ;hex-char JSR2 ;&date-str #0005 ++ STA - .DateTime/year DEI2 - DUP #0f AND ;hex-char JSR2 ;&date-str #0003 ++ STA - #04 SFT ;hex-char JSR2 ;&date-str #0002 ++ STA - DUP #0f AND ;hex-char JSR2 ;&date-str INC2 STA - #04 SFT ;hex-char JSR2 ;&date-str STA - - .DateTime/second DEI - DUP #0f AND ;hex-char JSR2 ;&time-str #0007 ++ STA - #04 SFT ;hex-char JSR2 ;&time-str #0006 ++ STA - .DateTime/minute DEI - DUP #0f AND ;hex-char JSR2 ;&time-str #0004 ++ STA - #04 SFT ;hex-char JSR2 ;&time-str #0003 ++ STA - .DateTime/hour DEI - DUP #0f AND ;hex-char JSR2 ;&time-str INC2 STA - #04 SFT ;hex-char JSR2 ;&time-str STA - - #0020 #0080 ;&date-str #01 ;draw-label JSR2 - #0080 #0080 ;&time-str #02 ;draw-label JSR2 + POPr + +RTN + +@get-entry ( id -- addr* ) + + ( limit ) STH + ( counter ) LITr 00 + ;dir/length LDA2 #0000 + &loop + EQUkr STHr #00 = ,&no-reached JCN + POP2r NIP2 ;dir/data ++ RTN + &no-reached + DUP2 ;dir/data ++ LDA #00 ! ,&no-lb JCN + INCr + &no-lb + INC2 GTH2k ,&loop JCN + POP2 POP2 + POP2r + ;dir/data RTN - &date-str "0000-00-00 $1 - &time-str "00:00:00 $1 @hex-char ( hex -- char ) @@ -350,43 +264,64 @@ RTN @draw-icn ( x* y* width* height* addr* color -- ) + AUTO-XADDR ( load ) STH .Screen/addr DEO2 ,&height STR2 ,&width STR2 ,&y STR2 ,&x STR2 ,&height LDR2 #0000 &ver ( save ) DUP2 ,&y LDR2 ADD2 .Screen/y DEO2 + ,&x LDR2 .Screen/x DEO2 ,&width LDR2 #0000 &hor - ( save ) DUP2 ,&x LDR2 ADD2 .Screen/x DEO2 ( draw ) STHkr .Screen/sprite DEO - ( incr ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2 #0008 ADD2 GTH2k ,&hor JCN POP2 POP2 #0008 ADD2 GTH2k ,&ver JCN POP2 POP2 POPr + AUTO-NONE RTN &x $2 &y $2 &width $2 &height $2 -@draw-label ( x* y* addr* color -- ) +@draw-str ( text* color -- ) - STH STH2 - .Screen/y DEO2 - .Screen/x DEO2 - STH2r - &loop - ( top-addr ) LDAk #20 - TOS #0010 MUL2 ;font ++ .Screen/addr DEO2 - ( top-draw ) STHkr .Screen/sprite DEO - ( bottom-addr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2 - ( next-y ) .Screen/y DEI2 #0008 ++ .Screen/y DEO2 - ( bottom-draw ) STHkr .Screen/sprite DEO - ( prev-y ) .Screen/y DEI2 #0008 -- .Screen/y DEO2 - ( move ) .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - INC2 LDAk ,&loop JCN - POP2 POPr + AUTO-YADDR + STH + &while + LDAk STHkr ,draw-char JSR + INC2 LDAk ,&while JCN + POP2 + POPr RTN +@draw-short ( short* color -- ) + + STH SWP STHkr ,draw-byte JSR + STHr ,draw-byte JSR + +RTN + +@draw-byte ( byte color -- ) + + STH + DUP #04 SFT ,&parse JSR STHkr ,draw-char JSR + #0f AND ,&parse JSR STHr ,draw-char JSR + +RTN + &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r + &above #57 ADD JMP2r + +@draw-char ( char color -- ) + + SWP + [ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2 + .Screen/sprite DEOk DEO + .Screen/x DEI2k #0008 ++ ROT DEO2 + .Screen/y DEI2k #0010 -- ROT DEO2 + +JMP2r + ( theme ) @theme-txt ".theme $1 @@ -406,25 +341,6 @@ RTN RTN -( helpers ) - -@print-hex ( value* -- ) - - &short ( value* -- ) - SWP ,&echo JSR - &byte ( value -- ) - ,&echo JSR - RTN - - &echo ( 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 + RTN &above #09 - #60 + RTN - -RTN - @pointer-icn 80c0 e0f0 f8e0 1000 @hand-icn @@ -432,7 +348,6 @@ RTN 0000 0000 0000 fc02 8180 8080 8040 3f00 fc20 c020 c020 c000 - @sin-pcm 8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7 @@ -460,5 +375,5 @@ RTN @dir &path ". $1 &lines $1 - &entries $100 + &length $2 &data From e6ac67d01b309711c50bbbb8fde3919a5268b152 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 14:00:33 -0800 Subject: [PATCH 06/39] (bool.tal) Added mouse scroll --- projects/software/boot.tal | 70 ++++++++++++++++++++++++++++++++------ 1 file changed, 60 insertions(+), 10 deletions(-) diff --git a/projects/software/boot.tal b/projects/software/boot.tal index a87cba3..4b03b9f 100644 --- a/projects/software/boot.tal +++ b/projects/software/boot.tal @@ -18,6 +18,14 @@ %AUTO-XADDR { #05 .Screen/auto DEO } %AUTO-YADDR { #06 .Screen/auto DEO } +%HALT { #010f DEO } +%EMIT { #18 DEO } +%PRINT { ;print-str JSR2 #0a EMIT } +%DEBUG { ;print-hex/byte JSR2 #0a EMIT } +%DEBUG2 { ;print-hex JSR2 #0a EMIT } + +%LINES-COUNT { .browser/y2 LDZ2 .browser/y LDZ2 -- 10// NIP } + ( devices ) |00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 @@ -25,7 +33,7 @@ |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 |80 @Controller &vector $2 &button $1 &key $1 -|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1 +|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 |a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 |b0 @DateTime &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 @@ -97,13 +105,26 @@ BRK .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 #41 .Mouse/state DEI #01 = + .Screen/sprite DEO + ( wheel ) + .Mouse/scrolly INC DEI + DUP #ff ! ,&no-up JCN + .browser/scroll LDZ #00 = ,&no-up JCN + DUP .browser/scroll LDZ + ;scroll-to JSR2 + &no-up + + DUP #01 ! ,&no-down JCN + .browser/scroll LDZ ;dir/lines LDA = ,&no-down JCN + DUP .browser/scroll LDZ + ;scroll-to JSR2 + &no-down + POP + ( within browser ) .Mouse/y DEI2 .browser/y LDZ2 << ,&outside JCN - .Mouse/y DEI2 .browser/y2 LDZ2 >> ,&outside JCN + .Mouse/y DEI2 .browser/y2 LDZ2 #0010 -- >> ,&outside JCN ( select choice ) .Mouse/y DEI2 .browser/y LDZ2 -- - 10// NIP ;select-file JSR2 + 10// NIP .browser/scroll LDZ + ;select-file JSR2 ( run choice ) .Mouse/state DEI #00 = ,&no-click JCN @@ -143,6 +164,24 @@ BRK BRK +@scroll-to ( line -- ) + + STH + ( more lines than visible ) + ;dir/lines LDA LINES-COUNT + DUP2 > ,&can-scroll JCN + POPr POP2 RTN + &can-scroll + ( less than max scroll ) + - INC STHkr > ,&valid-scroll JCN + POPr RTN + &valid-scroll + #00 ;draw-browser JSR2 + STHr .browser/scroll STZ + #01 ;draw-browser JSR2 + +RTN + @load-dir ( -- ) ;dir/path .File/name DEO2 @@ -188,16 +227,27 @@ RTN @follow-selection ( -- ) - .browser/y2 LDZ2 .browser/y LDZ2 -- 10// NIP #01 - .browser/sel LDZ - DUP2 > ,&below JCN - DUP2 SWP - .browser/scroll STZ - POP2 RTN - &below + LINES-COUNT .browser/sel LDZ .browser/scroll LDZ - + + DUP2 > ,&no-down JCN + .browser/scroll LDZ INC .browser/scroll STZ + &no-down POP2 - #00 .browser/scroll STZ RTN +@print-hex ( value* -- ) + + SWP ,&byte JSR + &byte ( byte -- ) + STHk #04 SFT ,&parse JSR #18 DEO + STHr #0f AND ,&parse JSR #18 DEO + JMP2r + &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r + &above #57 ADD JMP2r + +JMP2r + @run-file ( id -- ) ;get-entry JSR2 #0005 ++ @@ -225,7 +275,7 @@ RTN #0010 #0010 ;hand-icn STHkr #03 * ;draw-icn JSR2 ( draw files ) - .browser/y2 LDZ2 .browser/y LDZ2 -- 10// NIP #00 + LINES-COUNT #00 &loop .browser/x LDZ2 .Screen/x DEO2 DUP TOS 10** .browser/y LDZ2 ++ .Screen/y DEO2 From 715205f2ddd4c23027f326017cbef1c43e5b2b44 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 14:13:36 -0800 Subject: [PATCH 07/39] (boot.tal) Fixed issue with scroll --- projects/software/boot.tal | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/projects/software/boot.tal b/projects/software/boot.tal index 4b03b9f..b28b4fc 100644 --- a/projects/software/boot.tal +++ b/projects/software/boot.tal @@ -228,14 +228,25 @@ RTN @follow-selection ( -- ) LINES-COUNT .browser/sel LDZ .browser/scroll LDZ - - DUP2 > ,&no-down JCN - .browser/scroll LDZ INC .browser/scroll STZ + .browser/scroll LDZ INC ;scroll-to JSR2 &no-down + DUP2 SWP < ,&no-up JCN + .browser/sel LDZ ;scroll-to JSR2 + &no-up POP2 RTN +@print-str ( string* -- ) + + #0001 SUB2 + &while + INC2 LDAk DUP #18 DEO ,&while JCN + POP2 + +JMP2r + @print-hex ( value* -- ) SWP ,&byte JSR From e89ad768aa890df8a24638723b9aa5acc0550b24 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 17:22:04 -0800 Subject: [PATCH 08/39] (boot.tal) Added little folder icons --- projects/software/boot.tal | 238 +++++++++++++++++++++++-------------- 1 file changed, 149 insertions(+), 89 deletions(-) diff --git a/projects/software/boot.tal b/projects/software/boot.tal index b28b4fc..e4d72b8 100644 --- a/projects/software/boot.tal +++ b/projects/software/boot.tal @@ -11,6 +11,8 @@ %10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 } %20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 } +%40** { #60 SFT2 } + %RTN { JMP2r } %TOS { #00 SWP } @@ -52,9 +54,9 @@ |0100 ( -> ) ( theme ) - #f077 .System/r DEO2 - #f00c .System/g DEO2 - #f02a .System/b DEO2 + #f079 .System/r DEO2 + #f0c2 .System/g DEO2 + #f0a4 .System/b DEO2 ( vectors ) ;on-frame .Screen/vector DEO2 @@ -111,7 +113,6 @@ BRK .browser/scroll LDZ #00 = ,&no-up JCN DUP .browser/scroll LDZ + ;scroll-to JSR2 &no-up - DUP #01 ! ,&no-down JCN .browser/scroll LDZ ;dir/lines LDA = ,&no-down JCN DUP .browser/scroll LDZ + ;scroll-to JSR2 @@ -121,16 +122,13 @@ BRK ( within browser ) .Mouse/y DEI2 .browser/y LDZ2 << ,&outside JCN .Mouse/y DEI2 .browser/y2 LDZ2 #0010 -- >> ,&outside JCN - ( select choice ) .Mouse/y DEI2 .browser/y LDZ2 -- 10// NIP .browser/scroll LDZ + ;select-file JSR2 - ( run choice ) .Mouse/state DEI #00 = ,&no-click JCN .browser/sel LDZ ;run-file JSR2 &no-click - &outside BRK @@ -142,11 +140,13 @@ BRK DUP #10 ! ,&no-up JCN .browser/sel LDZ #00 = ,&no-up JCN .browser/sel LDZ #01 - ;select-file JSR2 + ;follow-selection JSR2 POP BRK &no-up DUP #20 ! ,&no-down JCN .browser/sel LDZ INC ;dir/lines LDA = ,&no-down JCN .browser/sel LDZ INC ;select-file JSR2 + ;follow-selection JSR2 POP BRK &no-down DUP #01 ! ,&no-a JCN @@ -164,6 +164,67 @@ BRK BRK +@load-dir ( -- ) + + ;dir/path .File/name DEO2 + #1000 .File/length DEO2 + ;dir/data .File/read DEO2 + .File/success DEI2 ;dir/length STA2 + + ( split with null-char ) + ;dir/data + &while + LDAk #1f > ,&no-lb JCN + ( split ) STH2k #00 STH2r STA + ( count lines ) ;dir/lines LDA INC ;dir/lines STA + &no-lb + INC2 LDAk ,&while JCN + POP2 + +RTN + +@select-file ( id -- ) + + ( has changed ) + DUP .browser/last LDZ ! ,&has-changed JCN + POP RTN + &has-changed + + #00 ;draw-browser JSR2 + DUP .browser/sel STZ + DUP .browser/last STZ + #30 + .Audio0/pitch DEO + #01 ;draw-browser JSR2 + + ( draw mascot ) + #0010 #0010 #0060 #0060 + ;mascot-icn [ .browser/sel LDZ #03 AND TOS #0480 ** ++ ] #01 + ;draw-icn JSR2 + + ( draw position ) + AUTO-YADDR + #0010 .Screen/x DEO2 + #0080 .Screen/y DEO2 + .browser/sel LDZ #02 ;draw-byte JSR2 + LIT '/ #02 ;draw-char JSR2 + ;dir/lines LDA #01 - #02 ;draw-byte JSR2 + AUTO-NONE + +RTN + +@follow-selection ( -- ) + + LINES-COUNT .browser/sel LDZ .browser/scroll LDZ - + DUP2 > ,&no-down JCN + .browser/scroll LDZ INC ,scroll-to JSR + &no-down + DUP2 SWP < ,&no-up JCN + .browser/sel LDZ ,scroll-to JSR + &no-up + POP2 + +RTN + @scroll-to ( line -- ) STH @@ -182,83 +243,6 @@ BRK RTN -@load-dir ( -- ) - - ;dir/path .File/name DEO2 - #1000 .File/length DEO2 - ;dir/data .File/read DEO2 - .File/success DEI2 ;dir/length STA2 - - ( split with null-char ) - ;dir/data - &while - LDAk #1f > ,&no-lb JCN - STH2k #00 STH2r STA - ;dir/lines LDA INC ;dir/lines STA - &no-lb - INC2 LDAk ,&while JCN - POP2 - -RTN - -@select-file ( id -- ) - - ( has changed ) - DUP .browser/last LDZ ! ,&has-changed JCN - POP RTN - &has-changed - - #00 ;draw-browser JSR2 - - DUP .browser/sel STZ - DUP .browser/last STZ - #30 + .Audio0/pitch DEO - - ;follow-selection JSR2 - - #01 ;draw-browser JSR2 - - ( draw mascot ) - #0010 #0010 #0060 #0060 - ;mascot-icn [ .browser/sel LDZ #03 AND TOS #0480 ** ++ ] #01 - ;draw-icn JSR2 - -RTN - -@follow-selection ( -- ) - - LINES-COUNT .browser/sel LDZ .browser/scroll LDZ - - DUP2 > ,&no-down JCN - .browser/scroll LDZ INC ;scroll-to JSR2 - &no-down - DUP2 SWP < ,&no-up JCN - .browser/sel LDZ ;scroll-to JSR2 - &no-up - POP2 - -RTN - -@print-str ( string* -- ) - - #0001 SUB2 - &while - INC2 LDAk DUP #18 DEO ,&while JCN - POP2 - -JMP2r - -@print-hex ( value* -- ) - - SWP ,&byte JSR - &byte ( byte -- ) - STHk #04 SFT ,&parse JSR #18 DEO - STHr #0f AND ,&parse JSR #18 DEO - JMP2r - &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r - &above #57 ADD JMP2r - -JMP2r - @run-file ( id -- ) ;get-entry JSR2 #0005 ++ @@ -282,15 +266,18 @@ RTN STH ( draw hand ) - .browser/x LDZ2 #0018 -- .browser/y LDZ2 [ .browser/sel LDZ .browser/scroll LDZ - TOS 10** ++ ] + .browser/x LDZ2 #0018 -- .browser/y LDZ2 + .browser/sel LDZ .browser/scroll LDZ - TOS 10** ++ #0010 #0010 - ;hand-icn STHkr #03 * ;draw-icn JSR2 + ;hand-icn STHkr #02 * ;draw-icn JSR2 ( draw files ) LINES-COUNT #00 &loop .browser/x LDZ2 .Screen/x DEO2 DUP TOS 10** .browser/y LDZ2 ++ .Screen/y DEO2 - DUP .browser/scroll LDZ + ;get-entry JSR2 #01 STHkr * ;draw-str JSR2 + DUP .browser/scroll LDZ + ;get-entry JSR2 + DUP2 ;get-type JSR2 ;draw-type JSR2 + #01 STHkr * ;draw-str JSR2 INC GTHk ,&loop JCN POP2 @@ -298,6 +285,13 @@ RTN RTN +@get-type ( line* -- type ) + + ;scap JSR2 #0004 -- ;&rom-ext ;scmp JSR2 + +RTN + &rom-ext ".rom $1 + @get-entry ( id -- addr* ) ( limit ) STH @@ -317,9 +311,20 @@ RTN RTN -@hex-char ( hex -- char ) +@draw-type ( type -- ) - DUP #09 GTH #04 JCN #30 + RTN #57 + + STHk TOS 20** ;file-icns ++ .Screen/addr DEO2 + AUTO-XADDR + #02 STHkr - .Screen/sprite DEOk DEO + + .Screen/x DEI2k #0010 -- ROT DEO2 + .Screen/y DEI2k #0008 ++ ROT DEO2 + + #02 STHr - .Screen/sprite DEOk DEO + + .Screen/x DEI2k #0008 ++ ROT DEO2 + .Screen/y DEI2k #0008 -- ROT DEO2 + AUTO-NONE RTN @@ -402,6 +407,52 @@ JMP2r RTN +( helpers ) + +@print-str ( string* -- ) + + #0001 SUB2 + &while + INC2 LDAk DUP #18 DEO ,&while JCN + POP2 + +JMP2r + +@print-hex ( value* -- ) + + SWP ,&byte JSR + &byte ( byte -- ) + STHk #04 SFT ,&parse JSR #18 DEO + STHr #0f AND ,&parse JSR #18 DEO + JMP2r + &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r + &above #57 ADD JMP2r + +JMP2r + +@scmp ( a* b* -- flag ) + + STH2 + &loop + LDAk LDAkr STHr = ,¬-diff JCN + POP2 POP2r #00 RTN + ¬-diff + LDAk LDAkr STHr #0000 !! ,¬-end JCN + POP2 POP2r #01 RTN + ¬-end + INC2 INC2r + ,&loop JMP + POP2 POP2r #00 + +RTN + +@scap ( str* -- str-end* ) + + ( clamp ) LDAk #00 ! JMP RTN + &while INC2 LDAk ,&while JCN + +RTN + @pointer-icn 80c0 e0f0 f8e0 1000 @hand-icn @@ -409,6 +460,15 @@ RTN 0000 0000 0000 fc02 8180 8080 8040 3f00 fc20 c020 c020 c000 +@file-icns + 003f 3f30 3f30 3f30 + 00fc fc0c fc0c fc0c + 3f33 3f3f 3f3f 3f00 + fcfc fcc4 c8d0 e000 + 003f 3f30 3132 3231 + 00fc fc0c 8c4c 4c8c + 303f 3f3f 3f3f 3f00 + 0cfc fcc4 c8d0 e000 @sin-pcm 8083 8689 8c8f 9295 989b 9ea1 a4a7 aaad b0b3 b6b9 bbbe c1c3 c6c9 cbce d0d2 d5d7 From 3ed8a61625113d964d12a13dbfddb100dd1981fd Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 17:42:38 -0800 Subject: [PATCH 09/39] (boot.tal) Fixed issue with empty folders --- projects/software/boot.tal | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/projects/software/boot.tal b/projects/software/boot.tal index e4d72b8..77d6ae4 100644 --- a/projects/software/boot.tal +++ b/projects/software/boot.tal @@ -189,6 +189,10 @@ RTN DUP .browser/last LDZ ! ,&has-changed JCN POP RTN &has-changed + ( beyond ) + DUP ;dir/lines LDA < ,&valid JCN + POP RTN + &valid #00 ;draw-browser JSR2 DUP .browser/sel STZ @@ -263,6 +267,9 @@ RTN @draw-browser ( mask -- ) + ( when empty ) + ;dir/lines LDA #01 = ;draw-browser-empty JCN2 + STH ( draw hand ) @@ -273,18 +280,32 @@ RTN ( draw files ) LINES-COUNT #00 &loop + ( reached end ) + DUP INC ;dir/lines LDA > ,&end JCN + ( has file ) .browser/x LDZ2 .Screen/x DEO2 DUP TOS 10** .browser/y LDZ2 ++ .Screen/y DEO2 DUP .browser/scroll LDZ + ;get-entry JSR2 DUP2 ;get-type JSR2 ;draw-type JSR2 #01 STHkr * ;draw-str JSR2 INC GTHk ,&loop JCN + &end POP2 POPr RTN +@draw-browser-empty ( mask -- ) + + POP + .browser/x LDZ2 .Screen/x DEO2 + .browser/y LDZ2 .Screen/y DEO2 + ;&empty-txt #01 ;draw-str JSR2 + +RTN + &empty-txt "Empty 20 "Folder $1 + @get-type ( line* -- type ) ;scap JSR2 #0004 -- ;&rom-ext ;scmp JSR2 From 37497060dc2fd2e07951d01838429879885850ea Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 8 Jan 2022 19:38:53 -0800 Subject: [PATCH 10/39] Removed stdlib from screen header --- src/devices/screen.c | 2 ++ src/devices/screen.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/devices/screen.c b/src/devices/screen.c index 77cdf79..a0abe5a 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -1,3 +1,5 @@ +#include + #include "../uxn.h" #include "screen.h" diff --git a/src/devices/screen.h b/src/devices/screen.h index 7ddb8d6..306b43b 100644 --- a/src/devices/screen.h +++ b/src/devices/screen.h @@ -1,5 +1,3 @@ -#include - /* Copyright (c) 2021 Devine Lu Linvega Copyright (c) 2021 Andrew Alderwick From a8c384daec01a61346c813a297d4a4e619a7b634 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 9 Jan 2022 13:07:48 -0800 Subject: [PATCH 11/39] (animation.tal) Minor optimizations --- projects/examples/gui/animation.tal | 55 ++++++++++++++++------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/projects/examples/gui/animation.tal b/projects/examples/gui/animation.tal index 9463ee6..a66970d 100644 --- a/projects/examples/gui/animation.tal +++ b/projects/examples/gui/animation.tal @@ -1,15 +1,18 @@ ( GUI Animation ) %2// { #01 SFT2 } +%AUTO-XADDR { #05 .Screen/auto DEO } ( devices ) -|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $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 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |0000 -@dvd [ &x $2 &y $2 &dx $1 &dy $1 ] +@dvd + &x $2 &y $2 + &dx $1 &dy $1 ( program ) @@ -27,52 +30,54 @@ .Screen/width DEI2 2// .dvd/x STZ2 .Screen/height DEI2 2// .dvd/y STZ2 + AUTO-XADDR + #01 ;draw-dvd JSR2 BRK @on-frame ( -> ) - ( clear ) #00 ;draw-dvd JSR2 + #00 ;draw-dvd JSR2 + ( case: hit-right ) .dvd/x LDZ2 .Screen/width DEI2 #0020 SUB2 EQU2 ( case: hit-left ) .dvd/x LDZ2 #0000 EQU2 #0000 EQU2 ,&no-flipx JCN - .dvd/dx LDZ #00 EQU .dvd/dx STZ &no-flipx + .dvd/dx LDZk #00 EQU SWP STZ &no-flipx + ( case: hit-bottom ) .dvd/y LDZ2 .Screen/height DEI2 #0010 SUB2 EQU2 ( case: hit-top ) .dvd/y LDZ2 #0000 EQU2 #0000 EQU2 ,&no-flipy JCN - .dvd/dy LDZ #00 EQU .dvd/dy STZ &no-flipy + .dvd/dy LDZk #00 EQU SWP STZ &no-flipy + ( incr ) .dvd/x LDZ2 #0001 #00 .dvd/dx LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/x STZ2 ( incr ) .dvd/y LDZ2 #0001 #00 .dvd/dy LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/y STZ2 - ( draw ) #01 ;draw-dvd JSR2 + + #01 ;draw-dvd JSR2 BRK @draw-dvd ( color -- ) - ( stash ) STH + STH ;dvd_icn .Screen/addr DEO2 - [ .dvd/y LDZ2 #0010 ADD2 ] .dvd/y LDZ2 - &ver - DUP2 .Screen/y DEO2 - [ .dvd/x LDZ2 #0020 ADD2 ] .dvd/x LDZ2 - &hor - DUP2 .Screen/x DEO2 - ( draw ) STHkr .Screen/sprite DEO - ( next ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2 - ( incr ) #0008 ADD2 - GTH2k ,&hor JCN - POP2 POP2 - ( incr ) #0008 ADD2 - GTH2k ,&ver JCN - POP2 POP2 - ( destroy ) POPr + .dvd/x LDZ2 .Screen/x DEO2 + .dvd/y LDZ2 .Screen/y DEO2 + #0800 + &loop + DUP #04 NEQ ,&no-lb JCN + .Screen/x DEI2k #0020 SUB2 ROT DEO2 + .Screen/y DEI2k #0008 ADD2 ROT DEO2 + &no-lb + STHkr .Screen/sprite DEO + INC GTHk ,&loop JCN + POP2 + POPr JMP2r -@dvd_icn [ +@dvd_icn ( 4 x 2 ) 001f 3f38 3838 787f 00fe fe7e 7777 e3c3 000f 1f3b 7b77 e7c7 00fc fe8f 8707 0efc 7f00 000f ff7f 0700 0301 00ff f0f8 ff00 8700 00ff 7f7f ff00 f000 00e0 fcfc 8000 -] \ No newline at end of file From 4657fe24908e369dceaf21d9bc12bf3683e0b678 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 9 Jan 2022 17:04:54 -0800 Subject: [PATCH 12/39] (gui/label.tal) Use UF2 properly --- projects/examples/demos/font.tal | 194 --------- projects/examples/gui/label.tal | 692 ++++++++++++++++++++++++++----- projects/software/supervisor.tal | 4 +- 3 files changed, 599 insertions(+), 291 deletions(-) delete mode 100644 projects/examples/demos/font.tal diff --git a/projects/examples/demos/font.tal b/projects/examples/demos/font.tal deleted file mode 100644 index 0118089..0000000 --- a/projects/examples/demos/font.tal +++ /dev/null @@ -1,194 +0,0 @@ -( uxnasm projects/examples/demos/font.tal bin/font.rom && uxnemu bin/font.rom ) - -%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } -%< { LTH } %> { GTH } %= { EQU } %! { NEQ } -%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } -%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } - -%RTN { JMP2r } -%TOS { #00 SWP } - -%GET-WIDTH { TOS ;font-data ++ LDA } -%GET-GLYPH { TOS #50 SFT2 ;font-data/glyphs ++ } - -%AUTO-NONE { #00 .Screen/auto DEO } -%AUTO-X { #01 .Screen/auto DEO } -%AUTO-Y { #02 .Screen/auto DEO } -%AUTO-ADDR { #04 .Screen/auto DEO } -%AUTO-X-ADDR { #05 .Screen/auto DEO } -%AUTO-Y-ADDR { #06 .Screen/auto DEO } - -( devices ) - -|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 -|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 -|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 - -( variables ) - -|0000 - -( init ) - -|0100 ( -> ) - - ( theme ) - #0fa7 .System/r DEO2 - #0fa7 .System/g DEO2 - #0fa7 .System/b DEO2 - - ( load font ) - #4900 .File/length DEO2 - ;font-path-large .File/name DEO2 - ;font-data .File/read DEO2 - ( draw label ) - #0020 #0020 ;title #01 ;draw-uf3 JSR2 - - ( load font ) - #2100 .File/length DEO2 - ;font-path-medium .File/name DEO2 - ;font-data .File/read DEO2 - ( draw label ) - #0020 #0048 ;body #02 ;draw-uf2 JSR2 - - ( load font ) - #0900 .File/length DEO2 - ;font-path-small .File/name DEO2 - ;font-data .File/read DEO2 - ( draw label ) - #0030 #00b8 ;footer #03 ;draw-uf1 JSR2 - -BRK - -@draw-uf1 ( x* y* text* color -- ) - - STH - SWP2 .Screen/y DEO2 - SWP2 DUP2 .Screen/x DEO2 SWP2 - &loop - LDAk - DUP #0a ! ,&no-linebreak JCN - ( move down ) STH OVR2 .Screen/x DEO2 STHr - ( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2 - POP ,&continue JMP &no-linebreak - ( get addr ) STHk TOS #30 SFT2 ;font-data #0100 ++ ++ .Screen/addr DEO2 - ( get width ) STHr TOS ;font-data ++ LDA TOS - ( draw ) STHkr .Screen/sprite DEO - ( use width ) .Screen/x DEI2 ++ .Screen/x DEO2 - &continue - ( incr addr ) INC2 - LDAk ,&loop JCN - POP2 POP2 POPr - -RTN - -@draw-uf2 ( x* y* text* color -- ) - - STH - SWP2 .Screen/y DEO2 - SWP2 .Screen/x DEO2 - AUTO-Y-ADDR - &while - LDAk #0a ! ,&no-linebreak JCN - ( reset ) #0020 .Screen/x DEO2 - ( down ) .Screen/y DEI2k #0010 ++ ROT DEO2 - ,&continue JMP &no-linebreak - LDAk STHkr ,&sprite JSR - &continue - INC2 LDAk ,&while JCN - POP2 POPr - AUTO-NONE - RTN - - &sprite ( char color -- ) - .Screen/x DEI2 STH2 - .Screen/y DEI2 STH2 - ( glyph ) OVR GET-GLYPH .Screen/addr DEO2 - DUP .Screen/sprite DEOk DEO - STH2kr .Screen/y DEO2 - SWP GET-WIDTH - DUP #09 < ,&narrow JCN - .Screen/x DEI2k #0008 ++ ROT DEO2 - OVR .Screen/sprite DEOk DEO - STH2kr .Screen/y DEO2 - &narrow - POP2r - ( width ) TOS STH2r ++ .Screen/x DEO2 - POP - RTN - -RTN - -@draw-uf3 ( x* y* text* color -- ) - - STH - SWP2 .Screen/y DEO2 - SWP2 DUP2 .Screen/x DEO2 SWP2 - &loop - LDAk - DUP #0a ! ,&no-linebreak JCN - ( move down ) OVR2 .Screen/x DEO2 - ( incr y ) .Screen/y DEI2 #0010 ++ .Screen/y DEO2 - POP ,&continue JMP &no-linebreak - STHkr ,&sprite JSR - &continue - ( incr addr ) INC2 - LDAk ,&loop JCN - POP2 POP2 POPr - RTN - - &sprite ( char color -- ) - STH - ( get addr ) DUP TOS #30 SFT2 #30 SFT2k ROT POP ADD2 ;font-data #0100 ++ ++ .Screen/addr DEO2 - ( get width ) TOS ;font-data ++ LDA TOS - #0300 - &ver - #0300 - &hor - STHkr .Screen/sprite DEO - .Screen/x DEI2 #0008 ++ .Screen/x DEO2 - .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2 - INC GTHk ,&hor JCN - POP2 - .Screen/y DEI2 #0008 ++ .Screen/y DEO2 - .Screen/x DEI2 #0018 -- .Screen/x DEO2 - INC GTHk ,&ver JCN - POP2 - .Screen/y DEI2 #0018 -- .Screen/y DEO2 - ( use width ) .Screen/x DEI2 ++ .Screen/x DEO2 - POPr - RTN - -RTN - -@title - 5468 6520 466f 6720 486f 726e $1 - -@body - 4927 6c6c 206d 616b 6520 6120 736f 756e - 6420 7468 6174 2773 2073 6f20 616c 6f6e - 6520 0a74 6861 7420 6e6f 206f 6e65 2063 - 616e 206d 6973 7320 6974 2c20 7468 6174 - 2077 686f 6576 6572 200a 6865 6172 7320 - 6974 2077 696c 6c20 7765 6570 2069 6e20 - 7468 6569 7220 736f 756c 732c 200a 616e - 6420 6865 6172 7468 7320 7769 6c6c 2073 - 6565 6d20 7761 726d 6572 2c20 0a61 6e64 - 2062 6569 6e67 2069 6e73 6964 6520 7769 - 6c6c 2073 6565 6d20 6265 7474 6572 200a - 746f 2061 6c6c 2077 686f 2068 6561 7220 - 6974 2069 6e20 7468 6520 6469 7374 616e - 7420 746f 776e 732e 20 $1 - -@footer - 2d20 4279 2052 6179 2042 7261 6462 7572 - 79 $1 - -@font-path-large - "projects/fonts/geneva24.uf3 $1 -@font-path-medium - "projects/fonts/venice14.uf2 $1 -@font-path-small - "projects/fonts/atari8.uf1 $1 - -@font-data $100 &glyphs \ No newline at end of file diff --git a/projects/examples/gui/label.tal b/projects/examples/gui/label.tal index 3c1c61f..76493c1 100644 --- a/projects/examples/gui/label.tal +++ b/projects/examples/gui/label.tal @@ -1,13 +1,37 @@ ( GUI Labels ) +%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } +%< { LTH } %> { GTH } %= { EQU } %! { NEQ } +%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } +%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } + +%=~ { EQUk NIP } %!~ { NEQk NIP } +%<~ { LTHk NIP } %>~ { GTHk NIP } + +%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } +%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 } +%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 } +%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 } +%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 } + +%IS-VALID { DUP #1f > SWP #7f < AND } + %RTN { JMP2r } -%2// { #01 SFT2 } -%8** { #30 SFT2 } +%TOS { #00 SWP } +%AUTO-NONE { #00 .Screen/auto DEO } +%AUTO-Y { #02 .Screen/auto DEO } +%AUTO-YADDR { #06 .Screen/auto DEO } + +%HALT { #010f DEO } +%EMIT { #18 DEO } +%PRINT { ;print-str JSR2 #0a EMIT } +%DEBUG { ;print-hex/byte JSR2 #0a EMIT } +%DEBUG2 { ;print-hex JSR2 #0a EMIT } ( devices ) |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &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 ( variables ) @@ -21,118 +45,596 @@ |0100 ( theme ) - #0f0f .System/r DEO2 - #0fff .System/g DEO2 - #0ff0 .System/b DEO2 + #f0d7 .System/r DEO2 + #f0de .System/g DEO2 + #f0dc .System/b DEO2 ( find screen center ) .Screen/width DEI2 2// .center/x STZ2 .Screen/height DEI2 2// .center/y STZ2 - ( draw ver line ) - .center/x LDZ2 .Screen/x DEO2 #0000 .Screen/y DEO2 - &draw-ver - ( draw ) #02 .Screen/pixel DEO - ( incr ) .Screen/y DEI2 #0002 ADD2 .Screen/y DEO2 - .Screen/y DEI2 .Screen/height DEI2 LTH2 ,&draw-ver JCN + ( ver ) + AUTO-Y + #0000 .Screen/y DEO2 + .center/x LDZ2 .Screen/x DEO2 + .Screen/height DEI2 #0000 + &ver + #43 .Screen/pixel DEO + .Screen/y DEI2k INC2 ROT DEO2 + INC2 GTH2k ,&ver JCN + POP2 POP2 - .center/x LDZ2 .center/y LDZ2 #0010 SUB2 #0c ;text1 ;draw-label-left JSR2 - .center/x LDZ2 .center/y LDZ2 #0c ;text2 ;draw-label-middle JSR2 - .center/x LDZ2 .center/y LDZ2 #0010 ADD2 #0c ;text3 ;draw-label-right JSR2 - .center/x LDZ2 .center/y LDZ2 #0020 ADD2 #0c ;text4 ;draw-label-middle JSR2 - .center/x LDZ2 .center/y LDZ2 #0030 ADD2 #0c ;text5 ;draw-label-middle JSR2 + .center/x LDZ2 .Screen/x DEO2 + .center/y LDZ2 #0020 -- .Screen/y DEO2 + ;left-txt #09 ;draw-uf2 JSR2 + + .center/x LDZ2 .Screen/x DEO2 + .center/y LDZ2 .Screen/y DEO2 + ;center-txt #09 ;draw-uf2-center JSR2 + + .center/x LDZ2 .Screen/x DEO2 + .center/y LDZ2 #0020 ++ .Screen/y DEO2 + ;right-txt #09 ;draw-uf2-right JSR2 + +BRK + +@draw-uf2-center ( text* color -- ) + + STH + DUP2 ,get-width JSR 2// .Screen/x DEI2 SWP2 -- .Screen/x DEO2 + STHr ,draw-uf2 JSR RTN -@draw-label-left ( x y color addr -- ) - - ( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 .Screen/x DEO2 - .label/addr LDZ2 - &loop - ( draw ) LDAk #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/sprite DEO - ( incr ) INC2 - ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 - LDAk ,&loop JCN +@draw-uf2-right ( text* color -- ) + + STH + DUP2 ,get-width JSR .Screen/x DEI2 SWP2 -- .Screen/x DEO2 + STHr ,draw-uf2 JSR + +RTN + +@get-width ( text* -- width* ) + + LIT2r 0000 + &while + LDAk TOS ;font ++ LDA TOS STH2 ADD2r + INC2 LDAk ,&while JCN POP2 + STH2r RTN -@draw-label-middle ( x y color addr -- ) - - ( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 - ( align ) .label/addr LDZ2 ;get-text-length JSR2 8** 2// SUB2 .Screen/x DEO2 - .label/addr LDZ2 - &loop - ( draw ) LDAk #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/sprite DEO - ( incr ) INC2 - ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 - LDAk ,&loop JCN - POP2 +@draw-uf2 ( text* color -- ) + + STH + AUTO-YADDR + &while + LDAk STHkr ,draw-glyph JSR + INC2 LDAk ,&while JCN + POP2 POPr + AUTO-NONE RTN -@draw-label-right ( x y color addr -- ) - - ( load ) .label/addr STZ2 .label/color STZ .Screen/y DEO2 - ( align ) .label/addr LDZ2 ;get-text-length JSR2 8** SUB2 .Screen/x DEO2 - .label/addr LDZ2 - &loop - ( draw ) LDAk #00 SWP 8** ;font ADD2 .Screen/addr DEO2 .label/color LDZ .Screen/sprite DEO - ( incr ) INC2 - ( incr ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 - LDAk ,&loop JCN - POP2 +@draw-glyph ( char color -- ) + + .Screen/x DEI2 STH2 + .Screen/y DEI2 STH2 + ( glyph ) OVR ,get-glyph JSR .Screen/addr DEO2 + DUP .Screen/sprite DEOk DEO + STH2kr .Screen/y DEO2 + ( get width ) SWP TOS ;font ++ LDA + DUP #09 < ,&narrow JCN + .Screen/x DEI2k #0008 ++ ROT DEO2 + OVR .Screen/sprite DEOk DEO + STH2kr .Screen/y DEO2 + &narrow + POP2r + ( width ) TOS STH2r ++ .Screen/x DEO2 + POP RTN -@get-text-length ( label* -- length ) - - #0000 ( counter ) - &loop - ( incr ) INC2 OVR2 OVR2 ADD2 - LDA ,&loop JCN - NIP2 +@get-glyph ( char -- addr* ) + + #09 =~ ,&tab JCN ( tab ) + #0a =~ ,&linebreak JCN ( linebreak ) + #0d =~ ,&linebreak JCN ( linebreak ) + DUP IS-VALID ,&valid JCN + POP ;unknown-icn RTN + &linebreak + POP ;linebreak-icn RTN + &tab + POP ;tab-icn RTN + &valid + TOS 20** ;font + #0100 ++ ++ RTN -@font ( spectrum-zx font ) -[ - 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 - 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 - 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 - 0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800 - 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800 - 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038 - 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000 - 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000 - 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 - 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000 - 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800 - 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000 - 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00 - 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 - 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810 - 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800 - 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00 - 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00 - 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200 - 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00 - 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00 - 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200 - 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00 - 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00 - 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00 - 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c - 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400 - 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800 - 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800 - 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 - 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00 - 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c -] +@print-hex ( value* -- ) -@text1 [ "Left 20 "Aligned 00 ] -@text2 [ "Middle 20 "Aligned 00 ] -@text3 [ "Right 20 "Aligned 00 ] -@text4 [ "even 00 ] -@text5 [ "odd 00 ] \ No newline at end of file + SWP ,&byte JSR + &byte ( byte -- ) + STHk #04 SFT ,&parse JSR #18 DEO + STHr #0f AND ,&parse JSR #18 DEO + JMP2r + &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r + &above #57 ADD JMP2r + +JMP2r + +@left-txt "Left 20 "Aligned 20 "Label $1 +@center-txt "Center 20 "Aligned 20 "Label $1 +@right-txt "Right 20 "Aligned 20 "Label $1 + +@unknown-icn + aa55 aa55 aa55 aa55 + aa55 aa55 aa55 aa55 + aa55 aa55 aa55 aa55 + aa55 aa55 aa55 aa55 +@tab-icn + 0000 0000 0000 1008 + 1000 0000 0000 0000 + 0000 0000 0000 0000 + 0000 0000 0000 0000 +@linebreak-icn + 0000 0000 0000 1028 + 1000 0000 0000 0000 + 0000 0000 0000 0000 + 0000 0000 0000 0000 + +@font ( venice14 ) + 0000 0000 0000 0000 0009 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0505 0809 080c 0d05 0707 0a09 0609 0608 + 0808 0808 0908 0808 0808 0505 0708 0709 + 000d 0a08 0b0a 090a 0c08 070c 090e 0c09 + 0a09 0c08 090b 0a0d 0d0a 0906 0806 0809 + 0509 0807 0a07 0708 0906 0609 050f 0a08 + 0908 0707 060a 090e 0a09 0807 0507 0800 + 0d0d 080a 0c09 0b09 0909 0909 0907 0707 + 0707 0606 0606 0a08 0808 0808 0a0a 0a0a + 0000 0000 0000 000a 0000 0005 0000 1009 + 0000 0000 0000 0000 0000 0000 0000 0c08 + 0905 0000 0000 000a 0a00 080d 0d09 0e0c + 090c 0808 0505 0000 0907 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3030 3030 3030 3000 3030 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 2424 2400 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 1212 7f24 24fe 4848 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 1038 5450 7038 1c14 5438 1000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3748 494b 360d 1a32 6241 0000 0000 + 0000 c0c0 8000 0080 4040 4080 0000 0000 + 0000 1c22 261c 1835 6343 463c 0000 0000 + 0000 0000 0000 e090 1020 8060 0000 0000 + 0000 2020 2000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0008 1030 2060 6060 6020 3010 0800 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0020 1018 080c 0c0c 0c08 1810 2000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0012 0c3f 0c12 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0008 0808 7f08 0808 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 3030 1020 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 7f00 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 3030 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0206 040c 0818 1030 2060 4000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3c66 6666 6666 6666 663c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0818 3818 1818 1818 183c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3c46 8606 0c18 3060 c2fc 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 7e8c 1830 7c06 4686 8c78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 040c 1c2c 4c8d fe0c 0c1e 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 7c62 6078 0c06 0606 4c38 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 1c22 606c 7666 6666 663c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 7e86 060c 0c18 1830 3030 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3c66 6666 3c66 6666 663c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3c66 6666 666e 3606 4438 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0030 3000 0000 3030 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0030 3000 0000 3030 1020 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0c18 3060 3018 0c00 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 7e00 7e00 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 6030 180c 1830 6000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3c46 0606 0c18 1000 1010 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0001 0200 0001 0306 7f98 30e0 0000 0000 + 00c0 6060 e0e0 6060 e060 6038 0000 0000 + 0010 7eb3 b333 3e31 3131 31ff 0000 0000 + 0000 0000 0000 0080 8080 8000 0000 0000 + 0000 7cc2 c2c4 c0c0 c0c2 c478 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0010 7fb1 b030 3030 3030 30ff 0000 0000 + 0000 0080 c0c0 c0c0 c0c0 8000 0000 0000 + 0010 7fb0 b030 3e30 3030 30ff 0000 0000 + 0000 8080 0000 0000 0040 8000 0000 0000 + 0010 7fb0 b030 3e30 3030 30e0 0000 0000 + 0000 8080 0000 0000 0000 0000 0000 0000 + 0000 3f61 c2c0 cfc3 c3c7 cb73 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0000 71b1 b131 7fb1 3131 31e1 0000 0000 + 00e0 8080 8080 8080 8090 a0c0 0000 0000 + 0000 7898 9818 1818 1819 1a1c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 7898 9818 1818 1818 1818 1810 20c0 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 70b1 b336 3c38 3c36 33e1 0000 0000 + 0000 c080 0000 0000 0010 20c0 0000 0000 + 0000 3860 6060 6060 6060 61fe 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0000 70b8 bd2e 2420 2020 20c0 0000 0000 + 0000 70e0 6060 6060 6064 6870 0000 0000 + 0000 70b8 bc2e 2723 2120 20c0 0000 0000 + 0000 6040 4040 40c0 c0c0 4040 0000 0000 + 0000 3c46 c3c3 c3c3 c3c2 4438 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 7fb1 b131 313f 3030 30e0 0000 0000 + 0000 0080 8080 8000 0000 0000 0000 0000 + 0000 3c46 c3c3 c3c3 c3d3 4a3c 0402 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0010 7fb1 b131 313f 3633 31e0 0000 0000 + 0000 0080 8080 8000 0000 90e0 0000 0000 + 0000 7cc2 e470 381c 4e86 c67c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 7f8c 8c0c 0c0c 0c0c 0c38 0000 0000 + 0000 8000 0000 0000 0000 0000 0000 0000 + 0000 61e1 6161 6161 6365 6931 0000 0000 + 0000 8080 8080 8080 80a0 c080 0000 0000 + 0000 61e3 6161 6163 666c 7870 0000 0000 + 0000 0080 8080 8000 0000 0000 0000 0000 + 0000 60e0 6060 6266 6e76 6747 0000 0000 + 0000 2070 3030 3030 60c0 8000 0000 0000 + 0000 60b0 980d 0707 0d18 3060 0000 0000 + 0000 3060 c080 0000 80c8 6830 0000 0000 + 0000 61e1 6161 6161 6163 6539 0101 021c + 0000 8080 8080 8080 8080 8080 8000 0000 + 0000 7f83 860c 1830 60c0 c1fe 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0078 6060 6060 6060 6060 6060 7800 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 4060 2030 1018 080c 0406 0200 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0078 1818 1818 1818 1818 1818 7800 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0010 2844 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 00ff 0000 0000 + 0000 0000 0000 0000 0000 0080 0000 0000 + 0040 2010 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0070 c0c0 c0dc e6c6 c6c6 ccf8 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 007c c4c0 c0c4 c870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0003 0606 067e c6c6 c6ce d667 0000 0000 + 0080 0000 0000 0000 0040 8000 0000 0000 + 0000 0000 007c c4c8 d0e2 c478 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 001c 3030 3078 3030 3030 3030 3030 20c0 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 007e c6c6 c6ce d666 0604 0830 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0070 c0c0 c0ce d6e6 c6c6 c7c6 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0000 2040 0060 e060 6064 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 1020 0030 70b0 3030 3030 3020 4080 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0070 c0c0 c0d8 e4c4 f8d8 cdc6 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0070 c0c0 c0c0 c0c0 c0c8 d0e0 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0067 eb73 6363 6363 0000 0000 + 0000 0000 0038 5898 181a 1c18 0000 0000 + 0000 0000 0067 eb73 6363 6363 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0000 0000 007c c6c6 c6c6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 006e f363 6363 667c 6060 60c0 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 007e c6c6 c6ce d666 0606 0706 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 006c f060 6060 7060 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0078 c4c0 780c 8c78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0020 60f8 6060 6064 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0063 e363 6367 6b33 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0000 0000 0042 e763 6264 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0042 e763 676b 7363 0000 0000 + 0000 0000 0010 3818 1020 4080 0000 0000 + 0000 0000 0061 b21c 0c16 2341 0000 0000 + 0000 0000 0000 0000 0000 4080 0000 0000 + 0000 0000 0063 e363 6367 6b33 0302 0438 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 007e 860c 1830 61fe 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 1830 3030 3060 3030 3030 3018 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 2020 2020 2020 2020 2020 2020 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3018 1818 180c 1818 1818 1830 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 4c00 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0001 0200 0001 0306 7f98 30e0 0000 0000 + 00c0 6060 e0e0 6060 e060 6038 0000 0000 + 0001 0200 0001 0306 7f98 30e0 0000 0000 + c0c0 6060 e0e0 6060 e060 6038 0000 0000 + 0000 7cc2 c2c4 c0c0 c0c2 c478 1010 2000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0010 7fb0 b030 3e30 3030 30ff 0000 0000 + 0000 8080 0000 0000 0040 8000 0000 0000 + 1300 70b8 bc2e 2723 2120 20c0 0000 0000 + 0000 6040 4040 40c0 c0c0 4040 0000 0000 + 0000 3c46 c3c3 c3c3 c3c2 4438 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 61e1 6161 6161 6365 6931 0000 0000 + 0000 8080 8080 8080 80a0 c080 0000 0000 + 0008 1000 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0010 0800 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 1028 4400 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0000 2400 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0032 4c00 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 1824 2418 007e c6c6 c6ce d766 0000 0000 + 0000 0000 0000 0000 0080 0000 0000 0000 + 0000 0000 007c c4c0 c0c4 c870 1010 2000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0008 1000 007c c4c8 d0e2 c478 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0020 1000 007c c4c8 d0e2 c478 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 1028 4400 007c c4c8 d0e2 c478 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 4800 007c c4c8 d0e2 c478 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0020 4000 0060 e060 6064 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0040 2000 0060 e060 6064 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 2050 8800 0060 e060 6064 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 9000 0060 e060 6064 6870 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0019 2600 0067 eb73 6363 6363 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0008 1000 007c c6c6 c6c6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0020 1000 007c c6c6 c6c6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 1028 4400 007c c6c6 c6c6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 2400 007c c6c6 c6c6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0032 4c00 007c c6c6 c6c6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0008 1000 0063 e363 6367 6b33 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0010 0800 0063 e363 6367 6b33 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0814 2200 0063 e363 6367 6b33 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0000 2400 0063 e363 6367 6b33 0000 0000 + 0000 0000 0000 0000 0040 8000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 1e33 3333 3631 3131 33e6 0000 0000 + 0000 0000 0000 0000 8080 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0010 2040 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0001 0200 0001 0306 7f98 30e1 0000 0000 + 00c0 7f61 e0e0 7c60 e060 61fe 0000 0000 + 0000 3d42 c7cb cbd3 d3e2 44b8 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 007d c6c6 c6cf d663 0000 0000 + 0000 0000 00e0 2040 8010 20c0 0000 0000 + 0000 0000 007c c6ce d6e6 cc78 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0808 0008 1830 6060 623c 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 6060 0060 6060 6060 6060 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0009 1224 4824 1209 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0024 1209 0409 1224 0000 0000 + 0000 0000 0000 0000 8000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0001 0200 0001 0306 7f98 30e0 0000 0000 + 00c0 6060 e0e0 6060 e060 6038 0000 0000 + 0001 0200 0001 0306 7f98 30e0 0000 0000 + 00c0 6060 e0e0 6060 e060 6038 0000 0000 + 4c00 3c46 c3c3 c3c3 c3c2 4438 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3f47 c3c3 c3c3 c3c3 473b 0000 0000 + 0000 f808 0000 e000 0004 08f0 0000 0000 + 0000 0000 007d c6c6 c6c7 ce79 0000 0000 + 0000 0000 00e0 2040 8010 20c0 0000 0000 + 0000 0000 0000 7f00 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 7f00 0000 0000 0000 0000 + 0000 0000 0000 e000 0000 0000 0000 0000 + 0000 2448 6c6c 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3636 1224 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 2040 6060 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 3030 1020 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 2400 0063 e363 6367 6b33 0302 0438 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0070 98ce 6438 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 diff --git a/projects/software/supervisor.tal b/projects/software/supervisor.tal index 04eba6b..1d3f20a 100644 --- a/projects/software/supervisor.tal +++ b/projects/software/supervisor.tal @@ -148,12 +148,12 @@ RTN ( working stack ) #0010 .Screen/y DEO2 DUP2 #0018 ** #0010 ++ .Screen/x DEO2 - DUP #fe00 LDA ( ptr ) EQU #41 + STH + DUP #fe00 LDA ( ptr ) EQU #4b + STH DUP2 #fe01 ++ LDA STHr ;draw-byte JSR2 ( return stack ) #0028 .Screen/y DEO2 DUP2 #0018 ** #0010 ++ .Screen/x DEO2 - DUP #ff00 LDA ( ptr ) EQU #41 + STH + DUP #ff00 LDA ( ptr ) EQU #4b + STH DUP2 #ff01 ++ LDA STHr ;draw-byte JSR2 INC2 GTH2k ,&wst JCN POP2 POP2 From 91560c6d2413a8a106ae72f293dd39245f9d93b7 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sun, 9 Jan 2022 18:13:18 -0800 Subject: [PATCH 13/39] (picture.tal) Added example of drawing a picture --- projects/examples/gui/picture.tal | 313 ++++++++++++++++++++ projects/examples/gui/proportional-font.tal | 121 -------- projects/pictures/macpaint4020.bit | Bin 16384 -> 0 bytes 3 files changed, 313 insertions(+), 121 deletions(-) create mode 100644 projects/examples/gui/picture.tal delete mode 100644 projects/examples/gui/proportional-font.tal delete mode 100644 projects/pictures/macpaint4020.bit diff --git a/projects/examples/gui/picture.tal b/projects/examples/gui/picture.tal new file mode 100644 index 0000000..7b2315a --- /dev/null +++ b/projects/examples/gui/picture.tal @@ -0,0 +1,313 @@ +( GUI Picture ) + +%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } +%< { LTH } %> { GTH } %= { EQU } %! { NEQ } +%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } +%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } + +%AUTO-NONE { #00 .Screen/auto DEO } +%AUTO-XADDR { #05 .Screen/auto DEO } + +( devices ) + +|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &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 ) + #f0d7 .System/r DEO2 + #f0de .System/g DEO2 + #f0dc .System/b DEO2 + + #0030 .Screen/x DEO2 + #0030 .Screen/y DEO2 + ;picture-icn #20 #10 #01 ;draw-icn JSR2 + +BRK + +@draw-icn ( addr* width height color -- ) + + AUTO-XADDR + STH + ( set bounds ) ,&height STR ,&width STR .Screen/addr DEO2 + ( set origin ) .Screen/x DEI2 ,&x STR2 + LIT &height $1 #00 + &ver + LIT2 &x $2 .Screen/x DEO2 + LIT &width $1 #00 + &hor + STHkr .Screen/sprite DEO + INC GTHk ,&hor JCN + POP2 + .Screen/y DEI2k #0008 ++ ROT DEO2 + INC GTHk ,&ver JCN + POP2 + POPr + AUTO-NONE + +JMP2r + +@picture-icn ( akane2010.bit 20 x 10 ) + 0000 0000 0000 0000 2b41 2341 2b41 2341 + 8881 8081 8880 8080 0a00 2000 8800 2000 + 8004 2004 8804 2a04 0000 0000 8000 0000 + 0307 0f0f 0f1f 1f5f ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff fff7 ffff efdf + fbf7 efd7 efdf af5f fffd fbfd fbf5 ebd7 + eaf5 ead5 ead5 aa55 ab55 ab55 ab57 ab57 + fbf7 ebd7 ebd7 ab57 ffff ffff ffff fbf7 + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff fefc + 80c0 8000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 2a54 2a54 2a54 2a54 + 8800 2200 8800 2200 8800 2200 8800 2200 + 0000 0000 0000 0000 2b41 2341 2b41 2341 + 8880 8080 8880 a080 8800 2000 8800 2000 + 8a05 2a05 8f0f 2a15 aa55 aafd ffff aa45 + bf7f ff7f ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff fefd ffff ffff ffff be7c + ffff ffff 8a00 0200 befd fafd fe1f 2307 + bf5f bf7d bad5 eaf5 ead5 aa55 aa55 aa55 + aa55 aa55 aa55 aa55 aa55 aa55 aa55 ab57 + af57 af7f ffc5 a307 fbf7 ff9f 1f1f 8f9f + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff fefd faf5 eaff ff5f + 0055 aa55 aaff ffff 0055 aa55 aaff ffff + 0055 aadf aaff ffff aa55 aad5 aaff ffff + 8840 aa77 aaff ffff 8800 aaff aaff ffff + 0000 0000 0000 0000 2b41 2341 2b41 2241 + 8800 a000 8800 a004 8804 2004 8000 2240 + 8810 0810 a010 2010 0200 0000 0000 0000 + bf3f 3f1f 0f07 0303 ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffd7 ab55 + faf5 faf5 eaf5 eaf5 f870 e240 8840 8240 + 8800 2200 8841 233f 8f1f 3f7f ffff ffff + fadd eac1 e2c1 c2c1 aa55 aa55 aa55 aa55 + aa55 aa55 aa54 a040 ae54 a854 a855 2f07 + 8f1f 1f3f bfff ffff 8f87 8f85 8205 2a05 + ffdf af5f bf7f bf77 ffff ffff ffff ffff + fefd f8c0 80c0 80c0 aa55 2a15 0a15 0a15 + ab55 8000 8000 8000 fe55 0200 0800 2200 + aa55 2200 8800 2200 eb77 2a54 2a54 2a54 + ff55 2000 8800 2000 ff55 0000 0000 2000 + 0000 0000 0000 0000 2a41 2241 2b41 2341 + 8804 a004 8004 a004 0840 aa40 8850 8210 + a010 2040 a040 2040 0000 0000 0000 0000 + 0301 0000 0000 0000 ffff ff7f 7f3f 3b07 + ffff ffff ffff ffff ffff ffff ffff ffff + feff fefd fefd fefd aa55 aa55 aa55 aa55 + eaf5 fafd fafd fefd 8840 a250 a854 aa54 + bf1f 2f07 8800 8055 ffff fefc e800 0a54 + 8201 2000 8000 8010 aa54 2800 0000 0000 + 0000 0000 0000 0000 0301 0000 0000 0200 + fefc fa70 8801 aa50 8a05 0a05 0201 0303 + ef57 af5f af5f bf7f ffff ffff ffff ffff + c0c0 a2c0 8880 a280 0a15 0a15 8a15 0a15 + 0000 0000 8000 2000 0800 0200 0800 2000 + 0800 2200 8800 0000 2a54 2a55 2a55 2a57 + 8800 2000 a0ff ffff 8000 2000 a8ff ffff + 0000 0000 0000 0001 ab41 a341 ab5f ffff + 8004 a804 8eff ffff 8010 a200 a0c0 e2c1 + 8040 80c0 80c0 8000 0000 0000 0000 0000 + 0000 0000 0000 0000 0301 0101 0000 0000 + ffff ffff ff7f 1f0f ffff ffff ffff ffff + fefd feff feff ffff aa55 aa55 aa55 aad5 + feff feff fe7f fe7f aa54 aa55 aa55 aa54 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0800 0000 0000 0000 0000 0000 0000 0000 + 0000 0001 0205 0a05 8040 2040 e070 e040 + 0000 0000 0000 0000 0307 0307 0707 0f07 + ffff ffff ffff ffff ffff fefc fefc fcfc + 8207 3f7f 7f7f 7f7f 8aff ffff ffff ffff + 08c0 faf8 fcfc feff 8800 2000 8800 2000 + 0000 2000 0000 0000 2b57 2f57 2b55 2a54 + ffff ffff ffff ffff ffff ffff ffff ffff + 0b03 0307 0707 0f1f ffff ffff ffff ffff + ffff ffff ffff ffff e0f1 f9f1 faf3 faf7 + 8000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0707 0301 0000 0000 ffff ffff ff7f 3f1f + ffff ffff ffff ffff eaf5 fafd feff ffff + fe7d be7f be7d ffff aa54 aa54 aa54 aad5 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0201 0000 0000 0001 e040 0000 0000 0040 + 0000 0000 0000 0000 0f07 0f07 0f0f 0f1f + ffff ffff fffe fcfc f8f0 c280 0800 2200 + be7f 3e15 8a01 2205 ff5f af55 ab55 ab55 + feff ffff ffff bf7f 8000 2000 8800 a201 + 8800 2000 0000 00f7 2854 2854 2854 28f4 + ff7f bf57 af5f 2f57 ffff ffff ffff ffff + 0f1f 0f07 0707 0707 ffff ffff ffff ffff + ffff ffff fefd faf5 e2c4 8604 8844 a854 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0f03 0100 0000 0000 + ffff ff7f 0f07 0a05 ffff ffff ffff ff7f + ffff ffff ffff ffff eaf5 fafd feff ffff + 8000 8040 a0d0 e8d4 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0200 0000 0000 0000 8000 0000 0000 0000 + 0000 0000 0001 0305 0f1f 3f7c f8f0 8201 + e8c4 2a11 a840 a200 8800 2200 2005 2000 + 8215 2e57 2a55 aa55 aa55 aa55 aa55 3a15 + fe7c f8f0 e840 a250 0307 2f1f 8f1f 2f0f + ffff ffff ffff ffff f8fc fefc feff fef0 + ab57 2b15 0a55 0a01 ffff feff ea55 8040 + 0301 0005 aa10 0805 ffff ff5f aa05 2000 + eaf5 ead5 aa55 aa41 8810 b810 2070 2040 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0000 0000 0000 0000 0000 0204 0a10 + 0000 0000 a805 2200 0000 0000 0040 2805 + 0a05 0a10 2a41 a200 af57 a840 8844 0a10 + ffff ff7f 8f01 2004 ffff ffff ffff ff7f + aed5 aad5 aad5 aad5 80c0 a85d ab55 aa55 + 0000 0000 a054 aa55 0000 0000 0000 a055 + 0000 0000 0000 0045 0000 0071 fa7c faf0 + 0810 a240 0800 2001 0a04 0254 a850 8200 + 0800 2200 8800 2200 8800 2200 8804 2a00 + 8a05 2201 8a01 2001 a8d0 a0c4 8a54 a040 + 2801 2000 8800 0250 8f01 8240 a011 2211 + af55 a040 8051 a815 e0c0 c240 8800 a200 + 0840 2200 aa10 2214 2a05 2000 8800 2200 + 8a00 2000 8000 2200 2a00 2200 8800 2200 + a214 2301 8000 2210 e040 80c0 6070 2010 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0000 0001 0204 0814 2840 a200 8800 2200 + 8800 2200 8800 2200 8b10 2240 0800 a200 + a855 2200 8800 2200 2040 a240 a810 2a04 + 8810 2200 0845 a800 bf7f 3a11 3805 2301 + aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 + aa55 aa55 aa55 aa55 aa55 aa55 aa75 fa7f + ef75 bb5d bb5f bb5f f8f8 fafc f8fc fcfc + 8800 2201 8801 2201 0800 2200 0801 2204 + 8800 2200 0850 2800 8010 0240 a810 2210 + 8a01 2000 8800 2200 0800 a200 8800 2240 + a840 2200 a800 2200 8801 2a04 8805 2204 + 8add aa45 8a14 2015 8800 a200 8800 a280 + 8804 2804 8004 2204 8800 2200 8800 2200 + 8800 0200 8840 0240 8800 2200 8800 2001 + 8800 0240 8800 2200 b010 1810 b810 1810 + 0000 0000 0000 0000 0000 0000 0000 0001 + 0810 2240 8800 a200 8800 2200 8800 2201 + 8801 2241 8a00 a204 8800 2200 8800 2200 + 8800 2200 8800 2200 8a00 2201 8800 2200 + 8a01 2200 0800 a200 0a05 aa75 aa05 2201 + aa55 aa55 aa55 aa55 aa55 aa55 aa55 aa55 + aa55 aa55 aa55 aa55 bf7f bf5f af47 8301 + bbd7 fbf1 f8fd feff fefc fefc fefe fefe + 8801 2241 2a05 2200 0040 8200 8800 0200 + 0000 a204 a840 2200 0a50 8200 8800 2200 + a010 2200 8801 2200 8800 2200 2800 a240 + a800 2205 8205 2205 8a04 2254 a855 ab55 + 3e15 2a75 ead5 aa55 82d5 ea75 aa75 aa75 + a85c aa50 a850 aa50 8800 2200 8800 2200 + 0800 a200 8800 a200 8a01 2000 8801 2001 + 0800 2200 8800 2200 8810 2810 8814 2804 + 0000 0000 0000 0000 0204 0004 0810 0210 + 8800 2200 8800 2200 8801 2001 8801 2200 + 0804 2a00 0810 a200 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8801 2200 + 0840 0240 a800 a210 8800 2200 8800 2200 + 2a14 2200 8800 2200 aa00 8040 a804 2200 + a800 0000 0000 8050 0000 0000 0000 0001 + ff7f 3f1f 3f71 8200 feff feff ffff ff7f + 8800 2200 88f0 fafc a804 2200 aa11 0210 + 8800 2200 0800 a200 8800 2200 8800 2200 + 8800 2200 8800 2200 0840 2240 a800 221f + 8a01 2205 8205 befd a850 a854 a855 a955 + ff7f ffdd badd ba5d eaf5 ea75 ea75 ead5 + a850 aa50 a850 a250 8800 2a04 8a00 2200 + 0800 0250 0800 0254 8011 2200 8800 2201 + 0800 2055 aa55 aad5 8810 2040 a040 a040 + 0000 0000 0000 0200 2800 2240 0840 0240 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8800 2200 + 0850 2210 881c 2804 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8a05 2200 8004 0f1f 0244 a818 9810 b2f0 + 8800 2200 8800 2200 bf1f 2f1f 8f0f 2f07 + feff ffff ffff ffff 0090 e2f0 e0f0 f8fc + 8840 2200 a800 2210 8800 2200 8800 2200 + 8800 2200 8800 2200 9f1f 2f0f 8f07 2305 + fefd fefd fefd fefd ab51 aa57 aa57 ae55 + ba5d ba55 aa55 aa55 ead5 ead5 aad5 aad5 + a857 bf7f ff7f ffff afff ffff ffff ffff + 80f5 ffff ffff ffff 8855 faf0 f8f8 f8fd + aad5 aa55 2a55 2a55 a075 aa40 a040 a055 + 0850 aa01 0201 0055 0840 8240 2800 2270 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8a01 2001 8800 2200 8800 a2c0 a850 2834 + 8800 2200 8800 2200 8800 2200 8800 2200 + bf7f ff7f ff7f 7f7f e8f0 e2f0 f0f0 fafc + 8800 2200 8800 2200 8f0f 2f1f 9f1f 3f7f + ffff ffff fffd fefd fcfd fef5 aa55 ab57 + 0050 e0f1 fafd eed5 0874 ae57 af5f be5d + 8800 22c0 b85c aa5c 8a04 2200 8800 2200 + fe7d 3e3d be1d 2e05 ae55 ae55 ae7d ee5d + ab55 ab55 ab57 aa57 aa55 ab55 ab57 ab57 + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff fefc + ead5 eaf5 eaf5 aa15 bf5f bf5f bf5d aa51 + feff ffff ff75 aa40 e8f0 eae4 e064 a210 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8800 2200 8800 2200 8800 2200 8800 2201 + 8800 2005 8810 2200 8800 8200 8800 2200 + 8800 2200 8800 2200 ba14 2a05 8607 2301 + 0800 2210 0804 a200 8800 2201 8a04 2850 + 7f7f ff7f 3f1f 3f1f fcfe ffff ffff f8fc + 8801 8fff ffff fe7d ffff ffff ebd7 af57 + feff ead7 abd5 aa55 ab55 aa55 ab75 faf5 + aed7 aa57 fa50 a0c1 be5f fa50 0000 0255 + b878 f87c 2f17 aa40 8800 2200 8840 2010 + 8a05 2a05 0a1d 0a1d ae5d ae5d ae5d ee5d + aa55 ae55 aa5d ba55 af5f ab5f bb77 ab77 + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff fefc fefc fefc feff + 0a15 0a05 0a05 0255 a850 a850 a850 a854 + 8040 0000 0800 0814 2211 2010 2010 2210 + 8800 2200 0800 2200 8800 2200 8800 2200 + 8800 2200 8800 2200 8a04 2a10 a840 0200 + 0800 2200 8800 2015 8800 2200 8800 a800 + 8800 2200 8800 2240 8801 2201 8801 2001 + 88c0 aad5 aad5 aa55 2000 ba55 aa55 aa57 + 8f1f af5f afff bf7f fafd fcfc faf5 faff + 3a55 0e07 0301 80c0 aa55 eaf5 fbff ff7f + aa55 ab7f ffff ffff fb75 f8f0 e0c0 80c0 + 8a14 0800 0000 0000 aa00 0000 0000 0000 + 0004 0201 0001 0001 2010 2040 8880 a001 + 3e15 2040 e0f4 feff ef55 0000 0000 80d0 + fa55 0a15 0a15 0a15 bf77 a347 a347 83c7 + ffff ffff ffff ffff ffff ffff ffff ffff + ffff ffff ffff ffff ffff ffff ffff ffff + feff feff ffff aad5 af57 af57 ab57 ab55 + ffff ffff ffff aa55 e8f0 e2e0 e8e0 a240 + 8800 2200 8800 2200 8800 2200 8800 2200 + 8801 2204 8000 2810 0800 2204 8810 2240 + 2040 2200 8800 2200 8800 2200 8800 2200 + 8000 2a04 8a00 2211 8a07 2e0d 8a1d 3a7d + aa55 aa55 aa55 aa55 ae55 af57 ab55 abff + ffff ffff ffff ffff ffff ffff ffff ffff + e0c0 e0f0 f8f0 f8f0 3f1f 0f07 0301 0001 + ffff ffff fefe fefc 8000 8000 0000 0000 + 0000 0000 0000 0000 0000 0000 0000 0000 + 0001 0001 0000 0000 8303 8343 8343 8343 + ffff ffff ffff ffff faff ffff ffff fbf7 + bafd ffff bfdf ff5f ef7f ffff af5f af5f + ffff ffff ffff ffff ffff ffff ffff ffff diff --git a/projects/examples/gui/proportional-font.tal b/projects/examples/gui/proportional-font.tal deleted file mode 100644 index b159431..0000000 --- a/projects/examples/gui/proportional-font.tal +++ /dev/null @@ -1,121 +0,0 @@ -( GUI Proportional font ) - -( devices ) - -|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] -|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] - -( variables ) - -|0000 - -( program ) - -|0100 - - ( theme ) #0f9f .System/r DEO2 #0f3f .System/g DEO2 #0f30 .System/b DEO2 - - #0000 ;draw JSR2 - #0001 ;draw JSR2 - #0002 ;draw JSR2 - -BRK - -@draw ( extra-spacing* -- ) - STH2 - ;text - &loop - LDAk - DUP #00 EQU ,&end JCN - DUP #0a EQU ,&linefeed JCN - #0005 SFT2 ;font ADD2 - DUP2 .Screen/addr DEO2 - #09 .Screen/sprite DEO - ,get-x-advance JSR .Screen/x DEI2 ADD2 STH2kr ADD2 .Screen/x DEO2 - &next - INC2 - ,&loop JMP - - &linefeed - POP - #0000 .Screen/x DEO2 - #0008 .Screen/y DEI2 ADD2 STH2kr ADD2 .Screen/y DEO2 - ,&next JMP - - &end - POP POP2 POP2r - JMP2r - -@get-x-advance ( font-char-addr* -- advance* ) - ( Save two 00 bytes for later use ) - #0000 SWP2 - ( First, load the eight bytes that make up the character ) - LDA2k SWP2 #0002 ADD2 - LDA2k SWP2 #0002 ADD2 - LDA2k SWP2 #0002 ADD2 - LDA2 - ( OR all the bytes together, so we know which columns contain filled pixels ) - ORA2 ORA2 ORA2 ORA - ( Find the lowest set bit (using one of the 00 bytes at the top, but not consuming it) ) - SUBk AND - ( Convert the nine possible values (00-80) into an offset into the magic table (00-08). ) - ( They get jumbled up with these two operations, but each possible value remains unique ) - #a3 MUL #16 DIV - ( Load the byte from the magic table, return a short (consuming/returning the 00 bytes at the top) ) - ;&magic ADD2 LDA - JMP2r - ( The magic table performs the last bit of arithmetic we want: - * the advance in x should be one more than the number of columns with filled pixels, - * with a maximum of 8, and - * a minimum of 3. ) - &magic - 03 ( lowest set bit is 00, 0 columns wide ) - 06 ( lowest set bit is 08, 5 columns wide ) - 05 ( lowest set bit is 10, 4 columns wide ) - 08 ( lowest set bit is 02, 7 columns wide ) - 04 ( lowest set bit is 20, 3 columns wide ) - 03 ( lowest set bit is 80, 1 column wide ) - 07 ( lowest set bit is 04, 6 columns wide ) - 08 ( lowest set bit is 01, 8 columns wide ) - 03 ( lowest set bit is 40, 2 columns wide ) - -@font ( spectrum-zx font, with each character moved to be flush left in its cell ) -[ - 0000 0000 0000 0000 0000 4800 fc78 0000 0000 4800 7884 0000 0000 d8f8 f870 2000 - 0020 70f8 f870 2000 0070 70f8 d820 7000 0020 70f8 f820 7000 0000 00c0 c000 0000 - 00fc 8484 8484 fc00 0000 6090 9060 0000 0030 4884 8448 3000 003c 0c74 9490 6000 - 0070 88d8 20f8 2000 0030 2020 20e0 e000 007c 4444 44cc cc00 0000 2088 0088 2000 - 0000 80c0 e0c0 8000 0000 2060 e060 2000 0040 e000 00e0 4000 00a0 a0a0 a000 a000 - 007c 9494 7414 1400 0018 608c c418 6000 0000 0000 0000 ffff 0040 e000 e040 00e0 - 0020 70a8 2020 2000 0020 2020 a870 2000 0000 1008 fc08 1000 0000 2040 fc40 2000 - 0000 8080 fc00 0000 0000 0048 cc48 0000 0000 2070 f800 0000 0000 00f8 7020 0000 - 0000 0000 0000 0000 0080 8080 8000 8000 00a0 a000 0000 0000 0048 fc48 48fc 4800 - 0020 78a0 7028 f020 0084 0810 2040 8400 0060 9064 9888 7400 0040 8000 0000 0000 - 0040 8080 8080 4000 0080 4040 4040 8000 0000 5020 f820 5000 0000 2020 f820 2000 - 0000 0000 0040 4080 0000 0000 f000 0000 0000 0000 0000 8000 0000 0810 2040 8000 - 0078 8c94 a4c4 7800 0060 a020 2020 f800 0078 8404 7880 fc00 0078 8438 0484 7800 - 0010 3050 90fc 1000 00fc 80f8 0484 7800 0078 80f8 8484 7800 00fc 0408 1020 2000 - 0078 8478 8484 7800 0078 8484 7c04 7800 0000 0080 0000 8000 0000 4000 0040 4080 - 0000 2040 8040 2000 0000 00f8 00f8 0000 0000 8040 2040 8000 0078 8404 1800 1000 - 0078 84b4 a884 7800 0030 4884 fc84 8400 00f8 84f8 8484 f800 0078 8480 8084 7800 - 00f0 8884 8488 f000 00fc 80f8 8080 fc00 007c 8080 f880 8000 0078 8480 9c84 7800 - 0084 84fc 8484 8400 00f8 2020 2020 f800 0004 0404 8484 7800 0088 90e0 9088 8400 - 0080 8080 8080 fc00 0084 ccb4 8484 8400 0084 c4a4 948c 8400 0078 8484 8484 7800 - 00f8 8484 f880 8000 0078 8484 a494 7800 00f8 8484 f888 8400 0078 8078 0484 7800 - 00fe 1010 1010 1000 0084 8484 8484 7800 0084 8484 8448 3000 0084 8484 b4cc 8400 - 0084 4830 3048 8400 0082 4428 1010 1000 00fc 0810 2040 fc00 00c0 8080 8080 c000 - 0080 4020 1008 0400 00c0 4040 4040 c000 0020 5088 0000 0000 0000 0000 0000 fc00 - 0080 4000 0000 0000 0000 7008 7888 7800 0080 80f0 8888 f000 0000 7880 8080 7800 - 0008 0878 8888 7800 0000 7088 f080 7800 0060 80e0 8080 8000 0000 7088 8878 0870 - 0080 80b0 c888 8800 0040 00c0 4040 2000 0010 0010 1010 9060 0080 90a0 c0a0 9000 - 0080 8080 8080 6000 0000 d0a8 a8a8 a800 0000 b0c8 8888 8800 0000 7088 8888 7000 - 0000 f088 88f0 8080 0000 7888 8878 080c 0000 b0c0 8080 8000 0000 7080 7008 f000 - 0040 40f0 4040 3000 0000 8888 8888 7000 0000 8888 5050 2000 0000 88a8 a8a8 5000 - 0000 8850 2050 8800 0000 8888 8878 0870 0000 f810 2040 f800 0060 4080 8040 6000 - 0080 8080 8080 8000 00c0 4020 2040 c000 0000 0064 9800 0000 3c42 99a1 a199 423c -] - -@text "Are 20 "proportional 20 "fonts 20 "a 20 "good 20 "idea? 0a 0a - "The 20 "jury 20 "is 20 "still 20 "out, 20 "but 20 "one 20 "thing 20 "is 20 "certain: 0a - "it 20 "is 20 "possible 20 "to 20 "print 20 "with 20 "these 20 "fonts 20 "in 20 "Uxn. 0a 0a 0a 00 - diff --git a/projects/pictures/macpaint4020.bit b/projects/pictures/macpaint4020.bit deleted file mode 100644 index 6aee9cbc3642534443028cb2fa1dd3fee9ab8684..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHOe{5679sl}AZ6`B{4PQYIw8~~Vj)>beEWXy z?m2OO%yE8D2l2i5KK|Z&cfNO@yYKhz-bIP18VLg-gceJIf~ad?49`pl#pmPtPTNkI zzB%o>#bV+5u+}K<3qIiJ^SzLEpUvUmx*o8}^xibAjog*GnJ*-D;OI2-gHxuT;plJ( z#Ao38?D_!Qmgxddw)At|rxkMq7?+s-+)lTfr@LFs=dI;>Byw2ZuS*oaYyN%?qaO6Q zNI3ZzVO6;(D1{CrUmqSebeV|Y+w4OD*vW;kG`M5)^mS}%6o97NO-)TB^1cU{kHkHF zpM%5(;J8~`TiXkO@m#!1>2F7V^a8-E^`Vl3p&9v+dk5Cf-Qsq;odEqLEdWeDFea~og>Nf6-l$)?6reN?};wzI_m#XAo5G>!wbwT)}d!)7S}1x}kK4}Zt)ZfR-3 z-{tk)ycp{#_db4;q9)61dza6kkJ`wGN)Q`7U zw^tMQJRtWS7^n}BEt?lrRh=(=Vv~OprBewUv4E$DEs(42khqs1?q~8(+*3g6EmphT z4vK+a!2)^^yGl@3%gV}BjNl7OM!9CS0$8nn5ZG zJ;$DIZd)gThkM99g@yRHIi9f*?WgP28M6WaPCiETyznV9Pvrj^U|#;wMq*|%BMiA8 zBIF^Lkl4riG>fSZ>+kPF6;g=YbDdL<=~u5J<%ow~?d8ZP9jFual%8|XM>U#RFJd3{ zO#D+8A%yO~OI=e{hSs0>r*x~+ywAUBB7OXe%unMSZGlYu(;VJrw_Bfo{=N59T?O@} zpBy;g@_0D;7&!~SR_qN1BA}twGmQE<<3C5A`)RdA3oM3zai^vR0sx*sfRB2N%3j>B zs!?4><^hI7p_0u}Y5#vU!~cuSPvabIflU0*wEm&;gOw?rIsgW)t3@x$bWK?QHO;@x z?G2P8T@1YNIMDEIw0`HS>K>W+$9mEH-}>Y76Zv-ht{L^A(6P%QoceLG7rOFDR3pH{ zTDSjdOuzEs$hiUHzBB=0LKa>fOk%kfuVugW7v)FMe{y-;{U8(n=>Aa{SWg_lT`~rt zP%uC!*k{o^m#YwUW&{ETq2PaFDz*Nj>}yE=kZ8X}0U59HS9vQCX@BQu64?sj7?v~D z*>FGX3%hzx|fC z0z=pvE{!tAhDU}mW(>|?4=3C#u~cH8MDzNH)D4L=GAJKFlF;dNc7{6>or(Ji!G7-Z zUl3KJIOfBk<0=5fh0@}M(N4e6T?4pPl1g-dN}d$(L)wyo?m*H!ouCx zFJ14xjygoq4ifT!I5|uIVwTSDs~XyUare;f`^Y_ooaY}M0QFniyCl>#fy6)U0DL-# zq+>d9PssV7x&Mc08AUi5fS#Tney^^bmU-M9RS@$dyZwwz_i?n?UYB}A;<6z%{w4p! zJ$?S6Fi(YtdAhFi@K^amlM-n!Wv1Ys85a{%*S7B#Va@Ol;4taYB0h)tAY=nbXm;rG z1XP%`7kvG>>aHct|L_OSpMU@T=Dz^Mn%<4Yt^uqM1On@EH}zUM%9j8H<+lO0?cKZg zH^}~}#@F*sy#dhb@p?R$saBU{)jpGWRN`XOkMR2!;{R{RedRR&*Xy}NaWYIY9-_?3 z8;3r37NT)K+1JMrzf!ubu%Lv{I2I~dgZxv~aR*ok_5uEd_Wx-O(3rH@sPjk2FrX}n zf1WcpqJ{Xsf!xzajQ`(B{wHxhOp*j<;O19Ufj;EC@1z0#A|0l*S!5-MN2Uyo&e6VYvYYK6Vkq_OZ3%|Lu0}!cyZOj|uQzkJNMj&tGa|N@ZM3fu1P-aRoRr%4fDw zJO#mJxp=WkltcXE3Q(^8b9enG#=XTV5W6#H-|&dHf9M6c9;M|0%6R7lfBTp1{;xT^ zxY^8$Nkx`9^XJqh{>5fyOix~hma_j<>nk>X&sS6G#64gyEpJu^lOv*>BfFjpmuzxR zWx4({pSMRoqP~nrX!4KybB`rt%YRRgSSe{gKh@gWdg?0d^u}T_Zvm8S4U|~7egMG(Cnh!8t6iLA z;$JkZIqn%4yx7$KuNsxQ@Cr=M|0kx;|17Q=sk`WXGl|CIEFv`kE_-U3l10Y!TUVEV z<@=&nvADp=3t94?URkc;8XW(YDw+7_h0nZR=S=f;2O!yhv9&yWAwap!-Bc=>1We-t79$p!$_-^5ei`2PZ- z3bFxTwf(35IG-%mFMK@EF?tVAz$530Zk*f__iU9giRG3w)D6%n`K7-8m&0G3@0k~q zmWhAsv%67K zv@6P}zuT|)!$ZeE8p2KIDv1NDg~_ToPU+(}aD(eDItvyb&3|WK)&6qcGmx)rup>F? z`r}V;T=17hH8UUbU)?plFl|8?c0z1vv_&47u$QWIC8$c*<&os^FoB_(NccN z^U1%z8B`Rot@Dn0M@EVUclpDp;@L# Date: Fri, 7 Jan 2022 00:06:42 +0000 Subject: [PATCH 14/39] Correct cast for snprintf --- src/devices/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/file.c b/src/devices/file.c index 5a2206b..039017f 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -57,7 +57,7 @@ get_entry(char *p, Uint16 len, const char *pathname, const char *basename, int f else if(S_ISDIR(st.st_mode)) return snprintf(p, len, "---- %s\n", basename); else if(st.st_size < 0x10000) - return snprintf(p, len, "%04x %s\n", (Uint16)st.st_size, basename); + return snprintf(p, len, "%04x %s\n", (unsigned int)st.st_size, basename); else return snprintf(p, len, "???? %s\n", basename); } From 9fcb0c335bd74e1d1d4d09a74d8fdff9c2eedc6c Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 10 Jan 2022 11:35:45 +0000 Subject: [PATCH 15/39] Remove use of snprintf. --- src/devices/file.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/devices/file.c b/src/devices/file.c index 039017f..28d7f63 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -13,8 +13,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#define _POSIX_C_SOURCE 200809L - #include #include #include @@ -53,13 +51,13 @@ get_entry(char *p, Uint16 len, const char *pathname, const char *basename, int f if(len < strlen(basename) + 7) return 0; if(stat(pathname, &st)) - return fail_nonzero ? snprintf(p, len, "!!!! %s\n", basename) : 0; + return fail_nonzero ? sprintf(p, "!!!! %s\n", basename) : 0; else if(S_ISDIR(st.st_mode)) - return snprintf(p, len, "---- %s\n", basename); + return sprintf(p, "---- %s\n", basename); else if(st.st_size < 0x10000) - return snprintf(p, len, "%04x %s\n", (unsigned int)st.st_size, basename); + return sprintf(p, "%04x %s\n", (unsigned int)st.st_size, basename); else - return snprintf(p, len, "???? %s\n", basename); + return sprintf(p, "???? %s\n", basename); } static Uint16 @@ -72,7 +70,10 @@ file_read_dir(char *dest, Uint16 len) Uint16 n; if(de->d_name[0] == '.' && de->d_name[1] == '\0') continue; - snprintf(pathname, sizeof(pathname), "%s/%s", current_filename, de->d_name); + if(strlen(current_filename) + 1 + strlen(de->d_name) < sizeof(pathname)) + sprintf(pathname, "%s/%s", current_filename, de->d_name); + else + pathname[0] = '\0'; n = get_entry(p, len, pathname, de->d_name, 1); if(!n) break; p += n; From 4134cef4b81917f8460142fd01f721c515ef9e87 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Mon, 10 Jan 2022 16:34:01 +0000 Subject: [PATCH 16/39] Add 9front automated build. --- .build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.build.yml b/.build.yml index f09d466..9ed8ff3 100644 --- a/.build.yml +++ b/.build.yml @@ -10,6 +10,7 @@ environment: SSH_HOST_KEYS: | [w1.uxn-build.ald.nu]:2222 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP+IYCB4JrKklFjWSMRkPBTqUjBqUuhlDQy6/X3l8xj5 [m1.uxn-build.ald.nu]:2223 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDvWVqlHh3XQ5ziEbT55K896/mW2BVDdkU6hWgIfU9md + [p1.uxn-build.ald.nu]:2224 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAgduGa60Tx3PsnEaJDyUzmPmpzGYmDeLFtLcVoU5tJs secrets: - 138ad607-a4ec-4d74-88a1-8f3be2ba2d03 sources: @@ -21,7 +22,7 @@ tasks: umask 077 mkdir -p ~/.ssh printf '%s\n' "${SSH_HOST_KEYS}" > ~/.ssh/known_hosts - printf 'User build\nStrictHostKeyChecking yes\nCheckHostIP no\nHost win\nHostName w1.uxn-build.ald.nu\nPort 2222\nHost mac\nHostName m1.uxn-build.ald.nu\nPort 2223\n' > ~/.ssh/config + printf 'User build\nStrictHostKeyChecking yes\nCheckHostIP no\nHost win\nHostName w1.uxn-build.ald.nu\nPort 2222\nHost mac\nHostName m1.uxn-build.ald.nu\nPort 2223\nHost 9front\nHostName p1.uxn-build.ald.nu\nPort 2224\n' > ~/.ssh/config - build-linux: | cd uxn ./build.sh --no-run @@ -46,3 +47,5 @@ tasks: } acurl -f "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz acurl -f "https://pages.sr.ht/publish/${SITE}" -Fcontent=@out.tar.gz -Fprotocol=GEMINI + - build-9front: | + ssh 9front "$(cd uxn && git rev-parse HEAD)" From bdef6c3dbdf8f9c55d3c96531b760ba188bec734 Mon Sep 17 00:00:00 2001 From: Vlad-Stefan Harbuz Date: Mon, 10 Jan 2022 20:20:44 +0100 Subject: [PATCH 17/39] add uxn resources to README.md Signed-off-by: Vlad-Stefan Harbuz --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f6a6445..f6dc83b 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,14 @@ uxnemu orca.rom | shim ## Need a hand? -Find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn). +The following resources are a good place to start: + +* [XXIIVV — uxntal](https://wiki.xxiivv.com/site/uxntal.html) +* [XXIIVV — uxntal cheatsheet](https://wiki.xxiivv.com/site/uxntal_cheatsheet.html) +* [XXIIVV — uxntal reference](https://wiki.xxiivv.com/site/uxntal_reference.html) +* [compudanzas — uxn tutorial](https://compudanzas.net/uxn_tutorial.html) + +You can also find us in [`#uxn` on irc.esper.net](ircs://irc.esper.net:6697/#uxn). ## Contributing From 38d2c7cbd742f4b5e99bd3c942919c09f7437c6b Mon Sep 17 00:00:00 2001 From: neauoire Date: Mon, 10 Jan 2022 20:35:34 -0800 Subject: [PATCH 18/39] (boot.rom) Renamed to launcher.rom --- README.md | 4 +- build.sh | 6 +-- projects/examples/demos/piano.tal | 2 +- projects/software/{boot.tal => launcher.tal} | 0 projects/software/supervisor.tal | 56 +++++++++++++++++--- src/devices/screen.c | 3 -- src/devices/screen.h | 3 +- src/uxnemu.c | 25 +++++---- 8 files changed, 67 insertions(+), 32 deletions(-) rename projects/software/{boot.tal => launcher.tal} (100%) diff --git a/README.md b/README.md index f6dc83b..b7c6cc8 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler If you wish to build the emulator without graphics mode: ```sh -cc src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli +cc src/devices/datetime.c src/devices/system.c src/devices/file.c src/uxn.c -DNDEBUG -Os -g0 -s src/uxncli.c -o bin/uxncli ``` ### Plan 9 @@ -94,7 +94,7 @@ uxnemu orca.rom | shim - `F1` toggle zoom - `F2` toggle debug - `F3` capture screen -- `F4` load boot.rom +- `F4` load launcher.rom ### Buttons diff --git a/build.sh b/build.sh index 6c96432..feed083 100755 --- a/build.sh +++ b/build.sh @@ -37,7 +37,7 @@ rm -f ./bin/uxnasm rm -f ./bin/uxnemu rm -f ./bin/uxncli rm -f ./bin/supervisor.rom -rm -f ./bin/boot.rom +rm -f ./bin/launcher.rom rm -f ./bin/asma.rom # When clang-format is present @@ -110,8 +110,8 @@ fi echo "Assembling(supervisor).." ./bin/uxnasm projects/software/supervisor.tal bin/supervisor.rom -echo "Assembling(boot).." -./bin/uxnasm projects/software/boot.tal bin/boot.rom +echo "Assembling(launcher).." +./bin/uxnasm projects/software/launcher.tal bin/launcher.rom echo "Assembling(asma).." ./bin/uxnasm projects/software/asma.tal bin/asma.rom diff --git a/projects/examples/demos/piano.tal b/projects/examples/demos/piano.tal index 76bf2b8..f3cf5a5 100644 --- a/projects/examples/demos/piano.tal +++ b/projects/examples/demos/piano.tal @@ -6,7 +6,7 @@ %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } %!~ { NEQk NIP } -%HALT { #01 #0f DEO } +%HALT { #010f DEO } %RTN { JMP2r } %TOS { #00 SWP } diff --git a/projects/software/boot.tal b/projects/software/launcher.tal similarity index 100% rename from projects/software/boot.tal rename to projects/software/launcher.tal diff --git a/projects/software/supervisor.tal b/projects/software/supervisor.tal index 1d3f20a..956573f 100644 --- a/projects/software/supervisor.tal +++ b/projects/software/supervisor.tal @@ -22,8 +22,11 @@ %2// { #01 SFT2 } %8** { #30 SFT2 } -%EADDR { #fd04 } -%ECODE { #fd06 } +%SYS_EADDR { #fd04 } +%SYS_ECODE { #fd06 } +%SYS_DEBUG { #fd0e } +%WST { #fe00 } +%RST { #ff00 } ( devices ) @@ -56,6 +59,11 @@ ;on-frame .Screen/vector DEO2 ;on-button .Controller/vector DEO2 + ( print initial memory ) + SYS_DEBUG LDA #00 = ,&no-debug JCN + ;print-stacks JSR2 + &no-debug + BRK @on-frame ( -> ) @@ -116,9 +124,9 @@ BRK ;at-txt #4f ;draw-str JSR2 - EADDR LDA2 #47 ;draw-short JSR2 + SYS_EADDR LDA2 #47 ;draw-short JSR2 - #0000 EADDR STA2 + #0000 SYS_EADDR STA2 BRK @@ -136,9 +144,8 @@ RTN ( load rom ) - RTN - &boot-path "boot.rom $1 + &boot-path "launcher.rom $1 @draw-stacks ( -- ) @@ -148,12 +155,12 @@ RTN ( working stack ) #0010 .Screen/y DEO2 DUP2 #0018 ** #0010 ++ .Screen/x DEO2 - DUP #fe00 LDA ( ptr ) EQU #4b + STH + DUP #fe00 LDA ( ptr ) EQU #41 + STH DUP2 #fe01 ++ LDA STHr ;draw-byte JSR2 ( return stack ) #0028 .Screen/y DEO2 DUP2 #0018 ** #0010 ++ .Screen/x DEO2 - DUP #ff00 LDA ( ptr ) EQU #4b + STH + DUP #ff00 LDA ( ptr ) EQU #41 + STH DUP2 #ff01 ++ LDA STHr ;draw-byte JSR2 INC2 GTH2k ,&wst JCN POP2 POP2 @@ -235,6 +242,39 @@ JMP2r JMP2r +@print-stacks ( -- ) + + #0a EMIT + WST ;&wst-txt ,print-stack JSR + RST ;&rst-txt ,print-stack JSR + +RTN + &wst-txt "Working-stack $1 + &rst-txt "Return-stack $1 + +@print-stack ( addr* name* -- ) + + PRINT + ( keep ptr ) LDAk STH + ( keep counter ) LITr 00 + ( skip ptr ) INC2 + DUP2 #0020 ++ SWP2 + &loop + ( print cell ) + EQUkr STHr #3b * #20 + EMIT + LDAk ;print-hex/byte JSR2 + EQUkr STHr #3d * #20 + EMIT + ( break into columns ) + SUB2k #0001 -- #0007 AND2 #0000 !! ,&no-lb JCN + #0a EMIT + &no-lb + INCr + INC2 GTH2k ,&loop JCN + POP2 POP2 + POP2r + +RTN + @print-hex ( value* -- ) SWP ,&byte JSR diff --git a/src/devices/screen.c b/src/devices/screen.c index a0abe5a..4f1fbea 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -83,7 +83,6 @@ screen_resize(UxnScreen *p, Uint16 width, Uint16 height) if(bg && fg && pixels) { p->width = width; p->height = height; - p->pixels = pixels; screen_clear(p, &p->bg); screen_clear(p, &p->fg); } @@ -119,8 +118,6 @@ screen_dei(Device *d, Uint8 port) case 0x3: return uxn_screen.width; case 0x4: return uxn_screen.height >> 8; case 0x5: return uxn_screen.height; - case 0x6: - default: return d->dat[port]; } } diff --git a/src/devices/screen.h b/src/devices/screen.h index 306b43b..e64fa05 100644 --- a/src/devices/screen.h +++ b/src/devices/screen.h @@ -13,8 +13,7 @@ WITH REGARD TO THIS SOFTWARE. #define FIXED_SIZE 0 typedef struct Layer { - Uint8 *pixels; - Uint8 changed; + Uint8 *pixels, changed; } Layer; typedef struct UxnScreen { diff --git a/src/uxnemu.c b/src/uxnemu.c index 95fde74..00178a4 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -255,15 +255,10 @@ start(Uxn *u, char *rom) memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST))) - return error("Boot", "Failed to start uxn."); if(!uxn_boot(u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST))) return error("Boot", "Failed to start uxn."); - if(!load(&supervisor, "supervisor.rom")) - error("Supervisor", "No debugger found."); if(!load(u, rom)) return error("Boot", "Failed to load rom."); - /* system */ devsystem = uxn_port(u, 0x0, system_dei, system_deo); /* console */ devconsole = uxn_port(u, 0x1, nil_dei, console_deo); /* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo); @@ -282,16 +277,20 @@ start(Uxn *u, char *rom) /* unused */ uxn_port(u, 0xf, nil_dei, nil_deo); /* Supervisor */ - uxn_port(&supervisor, 0x0, system_dei, system_deo); - uxn_port(&supervisor, 0x1, nil_dei, console_deo); - uxn_port(&supervisor, 0x2, screen_dei, screen_deo); - uxn_port(&supervisor, 0x8, nil_dei, nil_deo); - - uxn_eval(&supervisor, PAGE_PROGRAM); + if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST))) + return error("Boot", "Failed to start uxn."); + if(!load(&supervisor, "supervisor.rom")) + error("Supervisor", "No debugger found."); + /* system */ uxn_port(&supervisor, 0x0, system_dei, system_deo); + /* console */ uxn_port(&supervisor, 0x1, nil_dei, console_deo); + /* screen */ uxn_port(&supervisor, 0x2, screen_dei, screen_deo); + /* control */ uxn_port(&supervisor, 0x8, nil_dei, nil_deo); if(!uxn_eval(u, PAGE_PROGRAM)) return error("Boot", "Failed to start rom."); + uxn_eval(&supervisor, PAGE_PROGRAM); + return 1; } @@ -330,7 +329,7 @@ static void restart(Uxn *u) { set_size(WIDTH, HEIGHT, 1); - start(u, "boot.rom"); + start(u, "launcher.rom"); } static Uint8 @@ -527,7 +526,7 @@ main(int argc, char **argv) console_input(&u, '\n'); } } - if(!loaded && !start(&u, "boot.rom")) + if(!loaded && !start(&u, "launcher.rom")) return error("usage", "uxnemu [-s scale] file.rom"); run(&u); SDL_Quit(); From ede186b22684fa6908bfd8c3a33027753ea89d81 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 11 Jan 2022 11:07:25 -0800 Subject: [PATCH 19/39] Minor cleanup --- src/uxncli.c | 16 ++++++++-------- src/uxnemu.c | 4 +--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/uxncli.c b/src/uxncli.c index 319401f..e879e33 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "uxn.h" @@ -63,8 +62,12 @@ system_deo_special(Device *d, Uint8 port) static void console_deo(Device *d, Uint8 port) { - if(port > 0x7) - write(port - 0x7, (char *)&d->dat[port], 1); + FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr + : 0; + if(fd) { + fputc(d->dat[port], fd); + fflush(fd); + } } static Uint8 @@ -92,12 +95,9 @@ console_input(Uxn *u, char c) static void run(Uxn *u) { - Uint16 vec; Device *d = devconsole; - while((!u->dev[0].dat[0xf]) && (read(0, &devconsole->dat[0x2], 1) > 0)) { - DEVPEEK16(vec, 0); - uxn_eval(u, vec); - } + while((!u->dev[0].dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) + uxn_eval(u, GETVECTOR(d)); } static int diff --git a/src/uxnemu.c b/src/uxnemu.c index 00178a4..51aa735 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -434,9 +434,7 @@ run(Uxn *u) /* Audio */ else if(event.type >= audio0_event && event.type < audio0_event + POLYPHONY) { Device *d = devaudio0 + (event.type - audio0_event); - Uint16 res; - DEVPEEK16(res, 0x00); - uxn_eval(u, res); + uxn_eval(u, GETVECTOR(d)); } /* Mouse */ else if(event.type == SDL_MOUSEMOTION) From cd30b48665e491d1cb61a9b64bda016e7cf011d1 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 11 Jan 2022 14:16:27 -0800 Subject: [PATCH 20/39] Rename memory banks --- src/devices/file.c | 8 ++++---- src/devices/file.h | 2 +- src/uxncli.c | 8 ++++---- src/uxnemu.c | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/devices/file.c b/src/devices/file.c index 28d7f63..60d03b3 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -150,7 +150,7 @@ file_deo(Device *d, Uint8 port) case 0x5: DEVPEEK16(a, 0x4); DEVPEEK16(b, 0xa); - res = file_stat(&memory[a], b); + res = file_stat(&bank1[a], b); DEVPOKE16(0x2, res); break; case 0x6: @@ -159,19 +159,19 @@ file_deo(Device *d, Uint8 port) break; case 0x9: DEVPEEK16(a, 0x8); - res = file_init(&memory[a]); + res = file_init(&bank1[a]); DEVPOKE16(0x2, res); break; case 0xd: DEVPEEK16(a, 0xc); DEVPEEK16(b, 0xa); - res = file_read(&memory[a], b); + res = file_read(&bank1[a], b); DEVPOKE16(0x2, res); break; case 0xf: DEVPEEK16(a, 0xe); DEVPEEK16(b, 0xa); - res = file_write(&memory[a], b, d->dat[0x7]); + res = file_write(&bank1[a], b, d->dat[0x7]); DEVPOKE16(0x2, res); break; } diff --git a/src/devices/file.h b/src/devices/file.h index 9df401d..0a1d8bc 100644 --- a/src/devices/file.h +++ b/src/devices/file.h @@ -12,4 +12,4 @@ WITH REGARD TO THIS SOFTWARE. void file_deo(Device *d, Uint8 port); -extern Uint8 *memory; \ No newline at end of file +extern Uint8 *bank1; \ No newline at end of file diff --git a/src/uxncli.c b/src/uxncli.c index e879e33..719a83a 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -4,7 +4,7 @@ #include "uxn.h" -Uint8 *supervisor_memory, *memory; +Uint8 *bank0, *bank1; #include "devices/system.h" #include "devices/file.h" @@ -119,9 +119,9 @@ main(int argc, char **argv) Uxn u; int i, loaded = 0; - supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(&u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST))) + bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + bank1 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + if(!uxn_boot(&u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) return error("Boot", "Failed"); /* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c index 51aa735..f9e9b08 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -4,7 +4,7 @@ #include "uxn.h" -Uint8 *supervisor_memory, *memory; +Uint8 *bank0, *bank1; #pragma GCC diagnostic push #pragma clang diagnostic push @@ -252,10 +252,10 @@ load(Uxn *u, char *rom) static int start(Uxn *u, char *rom) { - memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - supervisor_memory = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + bank1 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(u, memory, supervisor_memory + PAGE_DEV, (Stack *)(supervisor_memory + PAGE_WST), (Stack *)(supervisor_memory + PAGE_RST))) + if(!uxn_boot(u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) return error("Boot", "Failed to start uxn."); if(!load(u, rom)) return error("Boot", "Failed to load rom."); @@ -277,7 +277,7 @@ start(Uxn *u, char *rom) /* unused */ uxn_port(u, 0xf, nil_dei, nil_deo); /* Supervisor */ - if(!uxn_boot(&supervisor, supervisor_memory, supervisor_memory + VISOR_DEV, (Stack *)(supervisor_memory + VISOR_WST), (Stack *)(supervisor_memory + VISOR_RST))) + if(!uxn_boot(&supervisor, bank0, bank0 + VISOR_DEV, (Stack *)(bank0 + VISOR_WST), (Stack *)(bank0 + VISOR_RST))) return error("Boot", "Failed to start uxn."); if(!load(&supervisor, "supervisor.rom")) error("Supervisor", "No debugger found."); From 61c7f9f0c19f8548b97cc98725f392e1d65776c5 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 11 Jan 2022 14:38:55 -0800 Subject: [PATCH 21/39] Removed device globals --- src/uxncli.c | 21 +++++++-------------- src/uxnemu.c | 9 +++++---- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/uxncli.c b/src/uxncli.c index 719a83a..4f50d3a 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -21,10 +21,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -#pragma mark - Core - -static Device *devsystem, *devconsole; - static int error(char *msg, const char *err) { @@ -48,8 +44,6 @@ inspect(Stack *s, char *name) } } -#pragma mark - Devices - void system_deo_special(Device *d, Uint8 port) { @@ -83,20 +77,19 @@ nil_deo(Device *d, Uint8 port) (void)port; } -#pragma mark - Generics - static int console_input(Uxn *u, char c) { - devconsole->dat[0x2] = c; - return uxn_eval(u, GETVECTOR(devconsole)); + Device *d = &u->dev[1]; + d->dat[0x2] = c; + return uxn_eval(u, GETVECTOR(d)); } static void run(Uxn *u) { - Device *d = devconsole; - while((!u->dev[0].dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) + Device *d = &u->dev[0]; + while((!d->dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) uxn_eval(u, GETVECTOR(d)); } @@ -124,8 +117,8 @@ main(int argc, char **argv) if(!uxn_boot(&u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) return error("Boot", "Failed"); - /* system */ devsystem = uxn_port(&u, 0x0, system_dei, system_deo); - /* console */ devconsole = uxn_port(&u, 0x1, nil_dei, console_deo); + /* system */ uxn_port(&u, 0x0, system_dei, system_deo); + /* console */ uxn_port(&u, 0x1, nil_dei, console_deo); /* empty */ uxn_port(&u, 0x2, nil_dei, nil_deo); /* empty */ uxn_port(&u, 0x3, nil_dei, nil_deo); /* empty */ uxn_port(&u, 0x4, nil_dei, nil_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c index f9e9b08..a33cff8 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -45,7 +45,7 @@ static SDL_Rect gRect; /* devices */ -static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0, *devconsole; +static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0; static Uint8 zoom = 1; static Uint32 stdin_event, audio0_event; @@ -260,7 +260,7 @@ start(Uxn *u, char *rom) if(!load(u, rom)) return error("Boot", "Failed to load rom."); /* system */ devsystem = uxn_port(u, 0x0, system_dei, system_deo); - /* console */ devconsole = uxn_port(u, 0x1, nil_dei, console_deo); + /* console */ uxn_port(u, 0x1, nil_dei, console_deo); /* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo); /* audio0 */ devaudio0 = uxn_port(u, 0x3, audio_dei, audio_deo); /* audio1 */ uxn_port(u, 0x4, audio_dei, audio_deo); @@ -407,8 +407,9 @@ do_shortcut(Uxn *u, SDL_Event *event) static int console_input(Uxn *u, char c) { - devconsole->dat[0x2] = c; - return uxn_eval(u, GETVECTOR(devconsole)); + Device *d = &u->dev[1]; + d->dat[0x2] = c; + return uxn_eval(u, GETVECTOR(d)); } static int From 06b694d4061f0e7e78ad2efadd0d5b9525936c5b Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 11 Jan 2022 14:51:25 -0800 Subject: [PATCH 22/39] Removed ram helper in uxn --- src/devices/screen.c | 2 +- src/uxn.c | 7 +++---- src/uxn.h | 4 ++-- src/uxnemu.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/devices/screen.c b/src/devices/screen.c index 4f1fbea..a836a79 100644 --- a/src/devices/screen.c +++ b/src/devices/screen.c @@ -151,7 +151,7 @@ screen_deo(Device *d, Uint8 port) DEVPEEK16(x, 0x8); DEVPEEK16(y, 0xa); DEVPEEK16(addr, 0xc); - screen_blit(&uxn_screen, layer, x, y, &d->mem[addr], d->dat[0xf] & 0xf, d->dat[0xf] & 0x10, d->dat[0xf] & 0x20, twobpp); + 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 */ diff --git a/src/uxn.c b/src/uxn.c index 4cc92fd..fcfedfc 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -108,14 +108,14 @@ err: /* clang-format on */ int -uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devpage, Stack *wst, Stack *rst) +uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst) { Uint32 i; char *cptr = (char *)u; for(i = 0; i < sizeof(*u); i++) cptr[i] = 0x00; u->ram = ram; - u->devpage = devpage; + u->devices = devices; u->wst = wst; u->rst = rst; return 1; @@ -126,9 +126,8 @@ uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)( { Device *d = &u->dev[id]; d->u = u; - d->mem = u->ram; + d->dat = u->devices + id * 0x10; d->dei = deifn; d->deo = deofn; - d->dat = u->devpage + id * 0x10; return d; } diff --git a/src/uxn.h b/src/uxn.h index 722abd6..a56646f 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -43,12 +43,12 @@ typedef struct Device { } Device; typedef struct Uxn { - Uint8 *ram, *devpage; + Uint8 *ram, *devices; Stack *wst, *rst; Device dev[16]; } Uxn; -int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devpage, Stack *wst, Stack *rst); +int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst); int uxn_eval(Uxn *u, Uint16 pc); int uxn_halt(Uxn *u, Uint8 error, Uint16 addr); Device *uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *, Uint8), void (*deofn)(Device *, Uint8)); diff --git a/src/uxnemu.c b/src/uxnemu.c index a33cff8..6498fce 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -210,7 +210,7 @@ audio_deo(Device *d, Uint8 port) DEVPEEK16(adsr, 0x8); DEVPEEK16(c->len, 0xa); DEVPEEK16(addr, 0xc); - c->addr = &d->mem[addr]; + c->addr = &d->u->ram[addr]; c->volume[0] = d->dat[0xe] >> 4; c->volume[1] = d->dat[0xe] & 0xf; c->repeat = !(d->dat[0xf] & 0x80); From 5e2bb92e4c1f4cd26e0828a3c9738f1f85104f50 Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 11 Jan 2022 15:13:12 -0800 Subject: [PATCH 23/39] Removed unistd from uxncli --- src/uxncli.c | 86 +++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/src/uxncli.c b/src/uxncli.c index 4f50d3a..3f58180 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -1,6 +1,5 @@ #include #include -#include #include "uxn.h" @@ -89,8 +88,11 @@ static void run(Uxn *u) { Device *d = &u->dev[0]; - while((!d->dat[0xf]) && (read(0, &d->dat[0x2], 1) > 0)) - uxn_eval(u, GETVECTOR(d)); + while(!d->dat[0xf]) { + int c = fgetc(stdin); + if(c != EOF) + console_input(u, (Uint8)c); + } } static int @@ -106,50 +108,50 @@ load(Uxn *u, char *filepath) return 1; } +static int +start(Uxn *u) +{ + bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + bank1 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); + if(!uxn_boot(u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) + return error("Boot", "Failed"); + /* system */ uxn_port(u, 0x0, system_dei, system_deo); + /* console */ uxn_port(u, 0x1, nil_dei, console_deo); + /* empty */ uxn_port(u, 0x2, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x3, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x4, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x5, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x6, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x7, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x8, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0x9, nil_dei, nil_deo); + /* file */ uxn_port(u, 0xa, nil_dei, file_deo); + /* datetime */ uxn_port(u, 0xb, datetime_dei, nil_deo); + /* empty */ uxn_port(u, 0xc, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0xd, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0xe, nil_dei, nil_deo); + /* empty */ uxn_port(u, 0xf, nil_dei, nil_deo); + return 1; +} + int main(int argc, char **argv) { Uxn u; - int i, loaded = 0; - - bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - bank1 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(&u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) - return error("Boot", "Failed"); - - /* system */ uxn_port(&u, 0x0, system_dei, system_deo); - /* console */ uxn_port(&u, 0x1, nil_dei, console_deo); - /* empty */ uxn_port(&u, 0x2, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x3, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x4, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x5, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x6, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x7, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x8, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0x9, nil_dei, nil_deo); - /* file */ uxn_port(&u, 0xa, nil_dei, file_deo); - /* datetime */ uxn_port(&u, 0xb, datetime_dei, nil_deo); - /* empty */ uxn_port(&u, 0xc, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0xd, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0xe, nil_dei, nil_deo); - /* empty */ uxn_port(&u, 0xf, nil_dei, nil_deo); - - for(i = 1; i < argc; i++) { - if(!loaded++) { - if(!load(&u, argv[i])) - return error("Load", "Failed"); - if(!uxn_eval(&u, PAGE_PROGRAM)) - return error("Init", "Failed"); - } else { - char *p = argv[i]; - while(*p) console_input(&u, *p++); - console_input(&u, '\n'); - } + int i; + if(argc < 2) + return error("Usage", "uxncli game.rom args"); + if(!start(&u)) + return error("Start", "Failed"); + if(!load(&u, argv[1])) + return error("Load", "Failed"); + if(!uxn_eval(&u, PAGE_PROGRAM)) + return error("Init", "Failed"); + for(i = 2; i < argc; i++) { + char *p = argv[i]; + while(*p) console_input(&u, *p++); + console_input(&u, '\n'); } - if(!loaded) - return error("Input", "Missing"); - run(&u); - return 0; } From b1ba95336c5208bbf0f7a15b294007e9ccf9bfbc Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Tue, 11 Jan 2022 23:50:41 +0000 Subject: [PATCH 24/39] Remove unistd.h from uxnemu.c. --- src/uxnemu.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/uxnemu.c b/src/uxnemu.c index 6498fce..785b4ed 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -1,5 +1,4 @@ #include -#include #include #include "uxn.h" @@ -90,7 +89,7 @@ stdin_handler(void *p) { SDL_Event event; event.type = stdin_event; - while(read(0, &event.cbutton.button, 1) > 0) + while(fread(&event.cbutton.button, 1, 1, stdin) > 0) SDL_PushEvent(&event); return 0; (void)p; @@ -183,8 +182,12 @@ system_deo_special(Device *d, Uint8 port) static void console_deo(Device *d, Uint8 port) { - if(port > 0x7) - write(port - 0x7, (char *)&d->dat[port], 1); + FILE *fd = port == 0x8 ? stdout : port == 0x9 ? stderr + : 0; + if(fd) { + fputc(d->dat[port], fd); + fflush(fd); + } } static Uint8 From 41de322a75b0d505529d97f2f7844eb0e1ae8158 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Wed, 12 Jan 2022 11:33:49 +0000 Subject: [PATCH 25/39] Add support for interrupting Uxn during execution. --- projects/library/debugger.tal | 7 ++++--- src/uxn.c | 13 +++++++++---- src/uxn.h | 1 + src/uxncli.c | 6 ++++++ src/uxnemu.c | 6 ++++++ 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/projects/library/debugger.tal b/projects/library/debugger.tal index c11d3e6..384eb44 100644 --- a/projects/library/debugger.tal +++ b/projects/library/debugger.tal @@ -22,7 +22,7 @@ The debugger will catch stack errors that arise after that point. @debug ( pc* -- ) #0001 SUB2 .System/eaddr DEO2 - .System/ecode DEIk #f8 AND #06 EOR SWP DEO + .System/ecode DEIk #07 EOR SWP DEO ,debug-vector/main JMP @debug-vector ( -> ) @@ -126,18 +126,19 @@ The debugger will catch stack errors that arise after that point. :&rst-msg :&overflow-msg :&wst-msg :&divzero-msg :&rst-msg :&divzero-msg + :&emulator-msg :&interrupt-msg :&userdef-msg :&breakpoint-msg - :&userdef-msg :&custom-msg &halted-msg "Halted: 2000 ( #0002, at 0x0100 ) &wst-msg "Working-stack 2000 &rst-msg "Return-stack 2000 + &emulator-msg "Emulator 2000 &userdef-msg "User-defined 2000 &underflow-msg "underflow 00 &overflow-msg "overflow 00 &divzero-msg "division 20 "by 20 "zero 00 + &interrupt-msg "interrupt 00 &breakpoint-msg "breakpoint 00 - &custom-msg "custom 20 "error 00 &executing-msg 20 "executing 2000 &at-msg 20 "at 20 "0x 00 &contents-msg "contents: 00 diff --git a/src/uxn.c b/src/uxn.c index fcfedfc..a95edb3 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -29,12 +29,12 @@ WITH REGARD TO THIS SOFTWARE. #define DEVR(o, d, x) { dev = (d); o = dev->dei(dev, (x) & 0x0f); if(bs) { o = (o << 8) + dev->dei(dev, ((x) + 1) & 0x0f); } } #define DEVW8(x, y) { dev->dat[(x) & 0xf] = y; dev->deo(dev, (x) & 0x0f); } #define DEVW(d, x, y) { dev = (d); if(bs) { DEVW8((x), (y) >> 8); DEVW8((x) + 1, (y)); } else { DEVW8((x), (y)) } } -#define WARP(x) { if(bs) pc = (x); else pc += (Sint8)(x); } int uxn_eval(Uxn *u, Uint16 pc) { unsigned int a, b, c, j, k, bs, instr, errcode; + Uint16 warp_count = 0; Uint8 kptr, *sp; Stack *src, *dst; Device *dev; @@ -72,9 +72,9 @@ uxn_eval(Uxn *u, Uint16 pc) case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) break; case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) break; case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) break; - case 0x0c: /* JMP */ POP(a) WARP(a) break; - case 0x0d: /* JCN */ POP(a) POP8(b) if(b) WARP(a) break; - case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) WARP(a) break; + case 0x0c: /* JMP */ POP(a) goto warp; + case 0x0d: /* JCN */ POP(a) POP8(b) if(b) goto warp; break; + case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) goto warp; case 0x0f: /* STH */ POP(a) PUSH(dst, a) break; /* Memory */ case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break; @@ -95,6 +95,11 @@ uxn_eval(Uxn *u, Uint16 pc) case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break; case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) break; } + continue; + + warp: + if(bs) pc = a; else pc += (Sint8)(a); + if(!++warp_count && uxn_interrupt(u)) return uxn_halt(u, 6, pc - 1); } return 1; diff --git a/src/uxn.h b/src/uxn.h index a56646f..5181365 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -51,4 +51,5 @@ typedef struct Uxn { int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst); int uxn_eval(Uxn *u, Uint16 pc); int uxn_halt(Uxn *u, Uint8 error, Uint16 addr); +int uxn_interrupt(Uxn *u); Device *uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *, Uint8), void (*deofn)(Device *, Uint8)); diff --git a/src/uxncli.c b/src/uxncli.c index 3f58180..058238e 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -20,6 +20,12 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +int +uxn_interrupt(Uxn *u) +{ + return 0; +} + static int error(char *msg, const char *err) { diff --git a/src/uxnemu.c b/src/uxnemu.c index 785b4ed..e8b0959 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -84,6 +84,12 @@ audio_finished_handler(UxnAudio *c) SDL_PushEvent(&event); } +int +uxn_interrupt(Uxn *u) +{ + return 0; +} + static int stdin_handler(void *p) { From 696ef03f12d18aa3d2ccfa67407e9ec8f160af15 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Wed, 12 Jan 2022 13:09:45 +0000 Subject: [PATCH 26/39] Remove goto/label for jumps. --- src/uxn.c | 67 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/src/uxn.c b/src/uxn.c index a95edb3..538e09b 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -59,45 +59,44 @@ uxn_eval(Uxn *u, Uint16 pc) switch(instr & 0x1f) { /* Stack */ case 0x00: /* LIT */ if(bs) { PEEK16(a, pc) PUSH16(src, a) pc += 2; } - else { a = u->ram[pc]; PUSH8(src, a) pc++; } break; - case 0x01: /* INC */ POP(a) PUSH(src, a + 1) break; - case 0x02: /* POP */ POP(a) break; - case 0x03: /* DUP */ POP(a) PUSH(src, a) PUSH(src, a) break; - case 0x04: /* NIP */ POP(a) POP(b) PUSH(src, a) break; - case 0x05: /* SWP */ POP(a) POP(b) PUSH(src, a) PUSH(src, b) break; - case 0x06: /* OVR */ POP(a) POP(b) PUSH(src, b) PUSH(src, a) PUSH(src, b) break; - case 0x07: /* ROT */ POP(a) POP(b) POP(c) PUSH(src, b) PUSH(src, a) PUSH(src, c) break; + else { a = u->ram[pc]; PUSH8(src, a) pc++; } continue; + case 0x01: /* INC */ POP(a) PUSH(src, a + 1) continue; + case 0x02: /* POP */ POP(a) continue; + case 0x03: /* DUP */ POP(a) PUSH(src, a) PUSH(src, a) continue; + case 0x04: /* NIP */ POP(a) POP(b) PUSH(src, a) continue; + case 0x05: /* SWP */ POP(a) POP(b) PUSH(src, a) PUSH(src, b) continue; + case 0x06: /* OVR */ POP(a) POP(b) PUSH(src, b) PUSH(src, a) PUSH(src, b) continue; + case 0x07: /* ROT */ POP(a) POP(b) POP(c) PUSH(src, b) PUSH(src, a) PUSH(src, c) continue; /* Logic */ - case 0x08: /* EQU */ POP(a) POP(b) PUSH8(src, b == a) break; - case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) break; - case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) break; - case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) break; - case 0x0c: /* JMP */ POP(a) goto warp; - case 0x0d: /* JCN */ POP(a) POP8(b) if(b) goto warp; break; - case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) goto warp; - case 0x0f: /* STH */ POP(a) PUSH(dst, a) break; + case 0x08: /* EQU */ POP(a) POP(b) PUSH8(src, b == a) continue; + case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(src, b != a) continue; + case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(src, b > a) continue; + case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(src, b < a) continue; + case 0x0c: /* JMP */ POP(a) break; + case 0x0d: /* JCN */ POP(a) POP8(b) if(b) break; continue; + case 0x0e: /* JSR */ POP(a) PUSH16(dst, pc) break; + case 0x0f: /* STH */ POP(a) PUSH(dst, a) continue; /* Memory */ - case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) break; - case 0x11: /* STZ */ POP8(a) POP(b) POKE(a, b) break; - case 0x12: /* LDR */ POP8(a) PEEK(b, pc + (Sint8)a) PUSH(src, b) break; - case 0x13: /* STR */ POP8(a) POP(b) c = pc + (Sint8)a; POKE(c, b) break; - case 0x14: /* LDA */ POP16(a) PEEK(b, a) PUSH(src, b) break; - case 0x15: /* STA */ POP16(a) POP(b) POKE(a, b) break; - case 0x16: /* DEI */ POP8(a) DEVR(b, &u->dev[a >> 4], a) PUSH(src, b) break; - case 0x17: /* DEO */ POP8(a) POP(b) DEVW(&u->dev[a >> 4], a, b) break; + case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(src, b) continue; + case 0x11: /* STZ */ POP8(a) POP(b) POKE(a, b) continue; + case 0x12: /* LDR */ POP8(a) PEEK(b, pc + (Sint8)a) PUSH(src, b) continue; + case 0x13: /* STR */ POP8(a) POP(b) c = pc + (Sint8)a; POKE(c, b) continue; + case 0x14: /* LDA */ POP16(a) PEEK(b, a) PUSH(src, b) continue; + case 0x15: /* STA */ POP16(a) POP(b) POKE(a, b) continue; + case 0x16: /* DEI */ POP8(a) DEVR(b, &u->dev[a >> 4], a) PUSH(src, b) continue; + case 0x17: /* DEO */ POP8(a) POP(b) DEVW(&u->dev[a >> 4], a, b) continue; /* Arithmetic */ - case 0x18: /* ADD */ POP(a) POP(b) PUSH(src, b + a) break; - case 0x19: /* SUB */ POP(a) POP(b) PUSH(src, b - a) break; - case 0x1a: /* MUL */ POP(a) POP(b) PUSH(src, (Uint32)b * a) break; - case 0x1b: /* DIV */ POP(a) POP(b) if(a == 0) { errcode = 4; goto err; } PUSH(src, b / a) break; - case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) break; - case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) break; - case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) break; - case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) break; + case 0x18: /* ADD */ POP(a) POP(b) PUSH(src, b + a) continue; + case 0x19: /* SUB */ POP(a) POP(b) PUSH(src, b - a) continue; + case 0x1a: /* MUL */ POP(a) POP(b) PUSH(src, (Uint32)b * a) continue; + case 0x1b: /* DIV */ POP(a) POP(b) if(a == 0) { errcode = 4; goto err; } PUSH(src, b / a) continue; + case 0x1c: /* AND */ POP(a) POP(b) PUSH(src, b & a) continue; + case 0x1d: /* ORA */ POP(a) POP(b) PUSH(src, b | a) continue; + case 0x1e: /* EOR */ POP(a) POP(b) PUSH(src, b ^ a) continue; + case 0x1f: /* SFT */ POP8(a) POP(b) c = b >> (a & 0x0f) << ((a & 0xf0) >> 4); PUSH(src, c) continue; } - continue; - warp: + /* Jump to a */ if(bs) pc = a; else pc += (Sint8)(a); if(!++warp_count && uxn_interrupt(u)) return uxn_halt(u, 6, pc - 1); } From 0518385a6d466c4feaf7cd39495f9369dcdfe017 Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 12 Jan 2022 11:54:19 -0800 Subject: [PATCH 27/39] Added uxn32 and uxn16 chr pictures --- projects/pictures/uxn16.chr | Bin 0 -> 95 bytes projects/pictures/uxn32.chr | Bin 0 -> 319 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 projects/pictures/uxn16.chr create mode 100644 projects/pictures/uxn32.chr diff --git a/projects/pictures/uxn16.chr b/projects/pictures/uxn16.chr new file mode 100644 index 0000000000000000000000000000000000000000..9b4e21b78d23640ab30e9088d29ec7a2c92bd2e3 GIT binary patch literal 95 zcmezW@6SIVIQJh$r#l-L7Z-2*52bt0ojZ5t(6j$Ay0{()?Cbx-=mrJ|fYDGci~<0n Cd@XkX literal 0 HcmV?d00001 diff --git a/projects/pictures/uxn32.chr b/projects/pictures/uxn32.chr new file mode 100644 index 0000000000000000000000000000000000000000..afd48b8158344850a266e357c948d5e2460e816a GIT binary patch literal 319 zcma)#u?>JQ3x;+H$MTE&kcHAu9jP9Mtseg?E}JG4#T(5b`{ZMA3vXq#My5uhzjWdrD_ M-@A7K{XGBb0%r5DlK=n! literal 0 HcmV?d00001 From 459855d825456ce153c74cad4c959b42dec7644c Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 12 Jan 2022 18:40:51 -0800 Subject: [PATCH 28/39] Removed supervisor --- TODO | 6 - build.sh | 3 - projects/software/supervisor.tal | 314 ------------------------------- src/devices/file.c | 8 +- src/devices/file.h | 2 +- src/devices/system.c | 11 +- src/devices/system.h | 2 - src/uxn.c | 12 +- src/uxn.h | 8 +- src/uxncli.c | 10 +- src/uxnemu.c | 39 +--- 11 files changed, 25 insertions(+), 390 deletions(-) delete mode 100644 TODO delete mode 100644 projects/software/supervisor.tal diff --git a/TODO b/TODO deleted file mode 100644 index 8ee7ae0..0000000 --- a/TODO +++ /dev/null @@ -1,6 +0,0 @@ -# TODOs - -- Emulation controls should be handled by the supervisor. -- Overlap the supervisor device page with the core device page. -- The boot rom should display "no roms" when the list is empty. -- diff --git a/build.sh b/build.sh index feed083..e61df47 100755 --- a/build.sh +++ b/build.sh @@ -36,7 +36,6 @@ echo "Cleaning.." rm -f ./bin/uxnasm rm -f ./bin/uxnemu rm -f ./bin/uxncli -rm -f ./bin/supervisor.rom rm -f ./bin/launcher.rom rm -f ./bin/asma.rom @@ -108,8 +107,6 @@ then cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/ fi -echo "Assembling(supervisor).." -./bin/uxnasm projects/software/supervisor.tal bin/supervisor.rom echo "Assembling(launcher).." ./bin/uxnasm projects/software/launcher.tal bin/launcher.rom echo "Assembling(asma).." diff --git a/projects/software/supervisor.tal b/projects/software/supervisor.tal deleted file mode 100644 index 956573f..0000000 --- a/projects/software/supervisor.tal +++ /dev/null @@ -1,314 +0,0 @@ -( launcher ) - -%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } -%< { LTH } %> { GTH } %= { EQU } %! { NEQ } -%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } -%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } - -%AUTO-X { #01 .Screen/auto DEO } -%AUTO-Y { #02 .Screen/auto DEO } -%AUTO-YADDR { #06 .Screen/auto DEO } - -%HALT { #010f DEO } -%EMIT { #18 DEO } -%PRINT { ;print-str JSR2 #0a EMIT } -%DEBUG { ;print-hex/byte JSR2 #0a EMIT } -%DEBUG2 { ;print-hex JSR2 #0a EMIT } - -%MODALW { #0024 } -%MODALH { #0009 } - -%RTN { JMP2r } -%2// { #01 SFT2 } -%8** { #30 SFT2 } - -%SYS_EADDR { #fd04 } -%SYS_ECODE { #fd06 } -%SYS_DEBUG { #fd0e } -%WST { #fe00 } -%RST { #ff00 } - -( devices ) - -|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &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 -|80 @Controller &vector $2 &button $1 &key $1 &func $1 - -( variables ) - -|0000 - -@center - &x $2 &y $2 -@modal - &x $2 &y $2 - -( init ) - -|0100 ( -> ) - - .Screen/width DEI2 2// - DUP2 .center/x STZ2 - MODALW #31 SFT2 -- .modal/x STZ2 - .Screen/height DEI2 2// - DUP2 .center/y STZ2 - MODALH #31 SFT2 -- .modal/y STZ2 - - ( vectors ) - ;on-error .System/vector DEO2 - ;on-frame .Screen/vector DEO2 - ;on-button .Controller/vector DEO2 - - ( print initial memory ) - SYS_DEBUG LDA #00 = ,&no-debug JCN - ;print-stacks JSR2 - &no-debug - -BRK - -@on-frame ( -> ) - - ;draw-cross JSR2 - ;draw-stacks JSR2 - -BRK - -@on-button ( -> ) - - .Controller/func DEI DUP DEBUG - DUP #02 ! ,&no-f2 JCN - ;toggle-debugger JSR2 - &no-f2 - DUP #08 ! ,&no-f4 JCN - ;reboot JSR2 - &no-f4 - POP - -BRK - -@on-error ( -> ) - - ( background ) - #00 .Screen/auto DEO - ;bg-icn .Screen/addr DEO2 - MODALH #0000 - &ver - DUP2 8** .modal/y LDZ2 ++ .Screen/y DEO2 - MODALW #0000 - &hor - DUP2 8** .modal/x LDZ2 ++ .Screen/x DEO2 - #42 .Screen/sprite DEO - INC2 GTH2k ,&hor JCN - POP2 POP2 - INC2 GTH2k ,&ver JCN - POP2 POP2 - - ( corners ) - ;corner-icn .Screen/addr DEO2 - .modal/x LDZ2 .Screen/x DEO2 - .modal/y LDZ2 .Screen/y DEO2 - #42 .Screen/sprite DEO - .modal/x LDZ2 MODALW #0001 -- 8** ++ .Screen/x DEO2 - #52 .Screen/sprite DEO - - .modal/y LDZ2 MODALH #0001 -- 8** ++ .Screen/y DEO2 - #72 .Screen/sprite DEO - - .modal/x LDZ2 .Screen/x DEO2 - #62 .Screen/sprite DEO - - ( text ) - .modal/x LDZ2 #0010 ++ .Screen/x DEO2 - .modal/y LDZ2 #0010 ++ .Screen/y DEO2 - ;error-txts/0 #4f ;draw-str JSR2 - - ;at-txt #4f ;draw-str JSR2 - - SYS_EADDR LDA2 #47 ;draw-short JSR2 - - #0000 SYS_EADDR STA2 - -BRK - -@toggle-debugger ( -- ) - - ( toggle debug ) - ( #fd0e STH2k LDA #00 = STH2r STA ) - -RTN - -@reboot ( -- ) - - ( clear devices/stacks ) - #fd00 #0300 ;mclr JSR2 - - ( load rom ) - -RTN - &boot-path "launcher.rom $1 - -@draw-stacks ( -- ) - - AUTO-YADDR - #0010 #0000 - &wst - ( working stack ) - #0010 .Screen/y DEO2 - DUP2 #0018 ** #0010 ++ .Screen/x DEO2 - DUP #fe00 LDA ( ptr ) EQU #41 + STH - DUP2 #fe01 ++ LDA STHr ;draw-byte JSR2 - ( return stack ) - #0028 .Screen/y DEO2 - DUP2 #0018 ** #0010 ++ .Screen/x DEO2 - DUP #ff00 LDA ( ptr ) EQU #41 + STH - DUP2 #ff01 ++ LDA STHr ;draw-byte JSR2 - INC2 GTH2k ,&wst JCN - POP2 POP2 - -RTN - -@draw-cross ( -- ) - - ( ver ) - AUTO-Y - #0000 .Screen/y DEO2 - .center/x LDZ2 .Screen/x DEO2 - .Screen/height DEI2 #0000 - &ver - #43 .Screen/pixel DEO - .Screen/y DEI2k INC2 ROT DEO2 - INC2 GTH2k ,&ver JCN - POP2 POP2 - - ( hor ) - AUTO-X - #0000 .Screen/x DEO2 - .center/y LDZ2 .Screen/y DEO2 - .Screen/width DEI2 #0000 - &hor - #43 .Screen/pixel DEO - .Screen/x DEI2k INC2 ROT DEO2 - INC2 GTH2k ,&hor JCN - POP2 POP2 - -RTN - -@draw-str ( text* color -- ) - - AUTO-YADDR - STH - &while - LDAk STHkr ,draw-char JSR - INC2 LDAk ,&while JCN - POP2 - POPr - -RTN - -@draw-short ( short* color -- ) - - STH SWP STHkr ,draw-byte JSR - STHr ,draw-byte JSR - -RTN - -@draw-byte ( byte color -- ) - - STH - DUP #04 SFT ,&parse JSR STHkr ,draw-char JSR - #0f AND ,&parse JSR STHr ,draw-char JSR - -RTN - &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r - &above #57 ADD JMP2r - -@draw-char ( char color -- ) - - SWP - [ #20 - #00 SWP #40 SFT2 ;font ++ ] .Screen/addr DEO2 - .Screen/sprite DEOk DEO - .Screen/x DEI2k #0008 ++ ROT DEO2 - .Screen/y DEI2k #0010 -- ROT DEO2 - -JMP2r - -@mclr ( addr* len* -- ) - - OVR2 ++ SWP2 - &loop - STH2k #00 STH2r STA - INC2 GTH2k ,&loop JCN - POP2 POP2 - -JMP2r - -@print-stacks ( -- ) - - #0a EMIT - WST ;&wst-txt ,print-stack JSR - RST ;&rst-txt ,print-stack JSR - -RTN - &wst-txt "Working-stack $1 - &rst-txt "Return-stack $1 - -@print-stack ( addr* name* -- ) - - PRINT - ( keep ptr ) LDAk STH - ( keep counter ) LITr 00 - ( skip ptr ) INC2 - DUP2 #0020 ++ SWP2 - &loop - ( print cell ) - EQUkr STHr #3b * #20 + EMIT - LDAk ;print-hex/byte JSR2 - EQUkr STHr #3d * #20 + EMIT - ( break into columns ) - SUB2k #0001 -- #0007 AND2 #0000 !! ,&no-lb JCN - #0a EMIT - &no-lb - INCr - INC2 GTH2k ,&loop JCN - POP2 POP2 - POP2r - -RTN - -@print-hex ( value* -- ) - - SWP ,&byte JSR - &byte ( byte -- ) - STHk #04 SFT ,&parse JSR #18 DEO - STHr #0f AND ,&parse JSR #18 DEO - JMP2r - &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r - &above #57 ADD JMP2r - -JMP2r - -@print-str ( string* -- ) - - #0001 SUB2 - &while - INC2 LDAk DUP #18 DEO ,&while JCN - POP2 - -JMP2r - -@error-txts - &0 "Working-stack 20 "underflow $1 - &1 "Return-stack 20 "underflow $1 - &2 "Working-stack 20 "overflow $1 - &3 "Return-stack 20 "overflow $1 - &4 "Working-stack 20 "division 20 "by 20 "zero $1 - &5 "Return-stack 20 "division 20 "by 20 "zero $1 -@at-txt - ', 20 "at 20 $1 - -@bg-icn - ffff ffff ffff ffff -@corner-icn - 1f7f 7fff ffff ffff - -~projects/assets/msx01x02.tal \ No newline at end of file diff --git a/src/devices/file.c b/src/devices/file.c index 60d03b3..cddf629 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -150,7 +150,7 @@ file_deo(Device *d, Uint8 port) case 0x5: DEVPEEK16(a, 0x4); DEVPEEK16(b, 0xa); - res = file_stat(&bank1[a], b); + res = file_stat(&bank0[a], b); DEVPOKE16(0x2, res); break; case 0x6: @@ -159,19 +159,19 @@ file_deo(Device *d, Uint8 port) break; case 0x9: DEVPEEK16(a, 0x8); - res = file_init(&bank1[a]); + res = file_init(&bank0[a]); DEVPOKE16(0x2, res); break; case 0xd: DEVPEEK16(a, 0xc); DEVPEEK16(b, 0xa); - res = file_read(&bank1[a], b); + res = file_read(&bank0[a], b); DEVPOKE16(0x2, res); break; case 0xf: DEVPEEK16(a, 0xe); DEVPEEK16(b, 0xa); - res = file_write(&bank1[a], b, d->dat[0x7]); + res = file_write(&bank0[a], b, d->dat[0x7]); DEVPOKE16(0x2, res); break; } diff --git a/src/devices/file.h b/src/devices/file.h index 0a1d8bc..b8fa33f 100644 --- a/src/devices/file.h +++ b/src/devices/file.h @@ -12,4 +12,4 @@ WITH REGARD TO THIS SOFTWARE. void file_deo(Device *d, Uint8 port); -extern Uint8 *bank1; \ No newline at end of file +extern Uint8 *bank0; \ No newline at end of file diff --git a/src/devices/system.c b/src/devices/system.c index be7af1f..4d9bbec 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -14,8 +14,6 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ -Uxn supervisor; - static const char *errors[] = { "Working-stack underflow", "Return-stack underflow", @@ -31,7 +29,6 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr) Uint16 vec = GETVECTOR(d); DEVPOKE16(0x4, addr); d->dat[0x6] = error; - uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[0])); if(vec) { /* need to rearm to run System/vector again */ d->dat[0] = 0; @@ -50,8 +47,8 @@ Uint8 system_dei(Device *d, Uint8 port) { switch(port) { - case 0x2: return d->u->wst->ptr; - case 0x3: return d->u->rst->ptr; + case 0x2: return d->u->wst.ptr; + case 0x3: return d->u->rst.ptr; default: return d->dat[port]; } } @@ -60,8 +57,8 @@ void system_deo(Device *d, Uint8 port) { switch(port) { - case 0x2: d->u->wst->ptr = d->dat[port]; break; - case 0x3: d->u->rst->ptr = d->dat[port]; 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); } } diff --git a/src/devices/system.h b/src/devices/system.h index 7d40337..35f81a6 100644 --- a/src/devices/system.h +++ b/src/devices/system.h @@ -12,5 +12,3 @@ WITH REGARD TO THIS SOFTWARE. Uint8 system_dei(Device *d, Uint8 port); void system_deo(Device *d, Uint8 port); void system_deo_special(Device *d, Uint8 port); - -extern Uxn supervisor; diff --git a/src/uxn.c b/src/uxn.c index 538e09b..0012b69 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -39,13 +39,13 @@ uxn_eval(Uxn *u, Uint16 pc) Stack *src, *dst; Device *dev; if(!pc || u->dev[0].dat[0xf]) return 0; - if(u->wst->ptr > 0xf8) u->wst->ptr = 0xf8; + if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8; while((instr = u->ram[pc++])) { /* Return Mode */ if(instr & 0x40) { - src = u->rst; dst = u->wst; + src = &u->rst; dst = &u->wst; } else { - src = u->wst; dst = u->rst; + src = &u->wst; dst = &u->rst; } /* Keep Mode */ if(instr & 0x80) { @@ -112,16 +112,13 @@ err: /* clang-format on */ int -uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst) +uxn_boot(Uxn *u, Uint8 *ram) { Uint32 i; char *cptr = (char *)u; for(i = 0; i < sizeof(*u); i++) cptr[i] = 0x00; u->ram = ram; - u->devices = devices; - u->wst = wst; - u->rst = rst; return 1; } @@ -130,7 +127,6 @@ uxn_port(Uxn *u, Uint8 id, Uint8 (*deifn)(Device *d, Uint8 port), void (*deofn)( { Device *d = &u->dev[id]; d->u = u; - d->dat = u->devices + id * 0x10; d->dei = deifn; d->deo = deofn; return d; diff --git a/src/uxn.h b/src/uxn.h index 5181365..5151be5 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -37,18 +37,18 @@ typedef struct { typedef struct Device { struct Uxn *u; - Uint8 *dat, *mem; + Uint8 dat[16], *mem; Uint8 (*dei)(struct Device *d, Uint8); void (*deo)(struct Device *d, Uint8); } Device; typedef struct Uxn { - Uint8 *ram, *devices; - Stack *wst, *rst; + Uint8 *ram; + Stack wst, rst; Device dev[16]; } Uxn; -int uxn_boot(Uxn *u, Uint8 *ram, Uint8 *devices, Stack *wst, Stack *rst); +int uxn_boot(Uxn *u, Uint8 *ram); int uxn_eval(Uxn *u, Uint16 pc); int uxn_halt(Uxn *u, Uint8 error, Uint16 addr); int uxn_interrupt(Uxn *u); diff --git a/src/uxncli.c b/src/uxncli.c index 058238e..eb0133b 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -3,7 +3,7 @@ #include "uxn.h" -Uint8 *bank0, *bank1; +Uint8 *bank0; #include "devices/system.h" #include "devices/file.h" @@ -23,6 +23,7 @@ WITH REGARD TO THIS SOFTWARE. int uxn_interrupt(Uxn *u) { + (void)u; return 0; } @@ -53,8 +54,8 @@ void system_deo_special(Device *d, Uint8 port) { if(port == 0xe) { - inspect(d->u->wst, "Working-stack"); - inspect(d->u->rst, "Return-stack"); + inspect(&d->u->wst, "Working-stack"); + inspect(&d->u->rst, "Return-stack"); } } @@ -118,8 +119,7 @@ static int start(Uxn *u) { bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - bank1 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) + if(!uxn_boot(u, bank0)) return error("Boot", "Failed"); /* system */ uxn_port(u, 0x0, system_dei, system_deo); /* console */ uxn_port(u, 0x1, nil_dei, console_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c index e8b0959..71e9b97 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -3,7 +3,7 @@ #include "uxn.h" -Uint8 *bank0, *bank1; +Uint8 *bank0; #pragma GCC diagnostic push #pragma clang diagnostic push @@ -87,6 +87,7 @@ audio_finished_handler(UxnAudio *c) int uxn_interrupt(Uxn *u) { + (void)u; return 0; } @@ -261,10 +262,9 @@ load(Uxn *u, char *rom) static int start(Uxn *u, char *rom) { - bank1 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(u, bank1, bank0 + PAGE_DEV, (Stack *)(bank0 + PAGE_WST), (Stack *)(bank0 + PAGE_RST))) + if(!uxn_boot(u, bank0)) return error("Boot", "Failed to start uxn."); if(!load(u, rom)) return error("Boot", "Failed to load rom."); @@ -285,21 +285,9 @@ start(Uxn *u, char *rom) /* unused */ uxn_port(u, 0xe, nil_dei, nil_deo); /* unused */ uxn_port(u, 0xf, nil_dei, nil_deo); - /* Supervisor */ - if(!uxn_boot(&supervisor, bank0, bank0 + VISOR_DEV, (Stack *)(bank0 + VISOR_WST), (Stack *)(bank0 + VISOR_RST))) - return error("Boot", "Failed to start uxn."); - if(!load(&supervisor, "supervisor.rom")) - error("Supervisor", "No debugger found."); - /* system */ uxn_port(&supervisor, 0x0, system_dei, system_deo); - /* console */ uxn_port(&supervisor, 0x1, nil_dei, console_deo); - /* screen */ uxn_port(&supervisor, 0x2, screen_dei, screen_deo); - /* control */ uxn_port(&supervisor, 0x8, nil_dei, nil_deo); - if(!uxn_eval(u, PAGE_PROGRAM)) return error("Boot", "Failed to start rom."); - uxn_eval(&supervisor, PAGE_PROGRAM); - return 1; } @@ -357,22 +345,6 @@ get_button(SDL_Event *event) return 0x00; } -static Uint8 -get_fkey(SDL_Event *event) -{ - switch(event->key.keysym.sym) { - case SDLK_F1: return 0x01; - case SDLK_F2: return 0x02; - case SDLK_F3: return 0x04; - case SDLK_F4: return 0x08; - case SDLK_F5: return 0x10; - case SDLK_F6: return 0x20; - case SDLK_F7: return 0x40; - case SDLK_F8: return 0x80; - } - return 0x00; -} - static Uint8 get_button_joystick(SDL_Event *event) { @@ -468,9 +440,6 @@ run(Uxn *u) controller_down(devctrl, get_button(&event)); else do_shortcut(u, &event); - /* function keys are sent to supervisor */ - if(get_fkey(&event)) - controller_special(&supervisor.dev[0x8], get_fkey(&event)); ksym = event.key.keysym.sym; if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym) break; @@ -490,8 +459,6 @@ run(Uxn *u) else if(event.type == stdin_event) console_input(u, event.cbutton.button); } - if(devsystem->dat[0xe]) - uxn_eval(&supervisor, GETVECTOR(&supervisor.dev[2])); uxn_eval(u, GETVECTOR(devscreen)); if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe]) redraw(); From 6a6a2ec3835034d4bcc45668acccb866bc4ff486 Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 12 Jan 2022 18:56:59 -0800 Subject: [PATCH 29/39] Removed external memory bank --- src/devices/file.c | 8 ++++---- src/devices/file.h | 2 -- src/uxncli.c | 6 +----- src/uxnemu.c | 6 +----- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/devices/file.c b/src/devices/file.c index cddf629..fb972eb 100644 --- a/src/devices/file.c +++ b/src/devices/file.c @@ -150,7 +150,7 @@ file_deo(Device *d, Uint8 port) case 0x5: DEVPEEK16(a, 0x4); DEVPEEK16(b, 0xa); - res = file_stat(&bank0[a], b); + res = file_stat(&d->u->ram[a], b); DEVPOKE16(0x2, res); break; case 0x6: @@ -159,19 +159,19 @@ file_deo(Device *d, Uint8 port) break; case 0x9: DEVPEEK16(a, 0x8); - res = file_init(&bank0[a]); + res = file_init(&d->u->ram[a]); DEVPOKE16(0x2, res); break; case 0xd: DEVPEEK16(a, 0xc); DEVPEEK16(b, 0xa); - res = file_read(&bank0[a], b); + res = file_read(&d->u->ram[a], b); DEVPOKE16(0x2, res); break; case 0xf: DEVPEEK16(a, 0xe); DEVPEEK16(b, 0xa); - res = file_write(&bank0[a], b, d->dat[0x7]); + res = file_write(&d->u->ram[a], b, d->dat[0x7]); DEVPOKE16(0x2, res); break; } diff --git a/src/devices/file.h b/src/devices/file.h index b8fa33f..26c4ff1 100644 --- a/src/devices/file.h +++ b/src/devices/file.h @@ -11,5 +11,3 @@ WITH REGARD TO THIS SOFTWARE. */ void file_deo(Device *d, Uint8 port); - -extern Uint8 *bank0; \ No newline at end of file diff --git a/src/uxncli.c b/src/uxncli.c index eb0133b..12a7f65 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -2,9 +2,6 @@ #include #include "uxn.h" - -Uint8 *bank0; - #include "devices/system.h" #include "devices/file.h" #include "devices/datetime.h" @@ -118,8 +115,7 @@ load(Uxn *u, char *filepath) static int start(Uxn *u) { - bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - if(!uxn_boot(u, bank0)) + if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)))) return error("Boot", "Failed"); /* system */ uxn_port(u, 0x0, system_dei, system_deo); /* console */ uxn_port(u, 0x1, nil_dei, console_deo); diff --git a/src/uxnemu.c b/src/uxnemu.c index 71e9b97..dbb33ec 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -3,8 +3,6 @@ #include "uxn.h" -Uint8 *bank0; - #pragma GCC diagnostic push #pragma clang diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" @@ -262,9 +260,7 @@ load(Uxn *u, char *rom) static int start(Uxn *u, char *rom) { - bank0 = (Uint8 *)calloc(0x10000, sizeof(Uint8)); - - if(!uxn_boot(u, bank0)) + if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)))) return error("Boot", "Failed to start uxn."); if(!load(u, rom)) return error("Boot", "Failed to load rom."); From ee4308196a639f1ce5ec5c07ee4c5ec4b2c0f8e6 Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 12 Jan 2022 21:22:33 -0800 Subject: [PATCH 30/39] Starting a debugging device --- build.sh | 6 ++++-- mkfile | 7 ++++--- src/devices/debug.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ src/devices/debug.h | 19 +++++++++++++++++ src/uxn.h | 2 +- src/uxncli.c | 1 + src/uxnemu.c | 5 ++--- 7 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 src/devices/debug.c create mode 100644 src/devices/debug.h diff --git a/build.sh b/build.sh index e61df47..a1884d3 100755 --- a/build.sh +++ b/build.sh @@ -60,6 +60,8 @@ then clang-format -i src/devices/controller.c clang-format -i src/devices/datetime.h clang-format -i src/devices/datetime.c + clang-format -i src/devices/debug.h + clang-format -i src/devices/debug.c clang-format -i src/uxnasm.c clang-format -i src/uxnemu.c clang-format -i src/uxncli.c @@ -98,8 +100,8 @@ fi echo "Building.." ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm -${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu -${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli +${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu +${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/uxncli.c -o bin/uxncli if [ -d "$HOME/bin" ] then diff --git a/mkfile b/mkfile index bf42d9f..8e269bd 100644 --- a/mkfile +++ b/mkfile @@ -9,6 +9,7 @@ HFILES=\ src/devices/audio.h\ src/devices/controller.h\ src/devices/datetime.h\ + src/devices/debug.h\ src/devices/file.h\ src/devices/mouse.h\ src/devices/screen.h\ @@ -33,19 +34,19 @@ bin: %.rom:Q: %.tal bin/uxnasm bin/uxnasm $stem.tal $target >/dev/null -bin/uxncli: file.$O datetime.$O system.$O uxncli.$O uxn.$O +bin/uxncli: file.$O datetime.$O debug.$O system.$O uxncli.$O uxn.$O $LD $LDFLAGS -o $target $prereq bin/uxnasm: uxnasm.$O $LD $LDFLAGS -o $target $prereq -bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O +bin/uxnemu: audio.$O controller.$O datetime.$O debug.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O $LD $LDFLAGS -o $target $prereq (uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c $CC $CFLAGS -Isrc -o $target src/$stem1.c -(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c +(audio|controller|datetime|debug|file|mouse|screen|system)\.$O:R: src/devices/\1.c $CC $CFLAGS -Isrc -o $target src/devices/$stem1.c nuke:V: clean diff --git a/src/devices/debug.c b/src/devices/debug.c new file mode 100644 index 0000000..2721134 --- /dev/null +++ b/src/devices/debug.c @@ -0,0 +1,50 @@ +#include + +#include "../uxn.h" +#include "debug.h" + +/* +Copyright (c) 2021 Devine Lu Linvega +Copyright (c) 2021 Andrew Alderwick + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE. +*/ + +static void +inspect(Stack *s, char *name) +{ + Uint8 x, y; + fprintf(stderr, "\n%s\n", name); + for(y = 0; y < 0x04; y++) { + for(x = 0; x < 0x08; x++) { + Uint8 p = y * 0x08 + x; + fprintf(stderr, + p == s->ptr ? "[%02x]" : " %02x ", + s->dat[p]); + } + fprintf(stderr, "\n"); + } +} + +/* IO */ + +Uint8 +debug_dei(Device *d, Uint8 port) +{ + DebugDevice *debug = (DebugDevice *)d; + return d->dat[port]; +} + +void +debug_deo(Device *d, Uint8 port) +{ + (void)d; + (void)port; + inspect(&d->u->wst, "Working-stack"); + inspect(&d->u->rst, "Return-stack"); +} diff --git a/src/devices/debug.h b/src/devices/debug.h new file mode 100644 index 0000000..e141bd9 --- /dev/null +++ b/src/devices/debug.h @@ -0,0 +1,19 @@ +/* +Copyright (c) 2021 Devine Lu Linvega +Copyright (c) 2021 Andrew Alderwick + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE. +*/ + +typedef struct DebugDevice { + Device device; + struct UxnScreen *screen; +} DebugDevice; + +Uint8 debug_dei(Device *d, Uint8 port); +void debug_deo(Device *d, Uint8 port); \ No newline at end of file diff --git a/src/uxn.h b/src/uxn.h index 5151be5..226747b 100644 --- a/src/uxn.h +++ b/src/uxn.h @@ -37,7 +37,7 @@ typedef struct { typedef struct Device { struct Uxn *u; - Uint8 dat[16], *mem; + Uint8 dat[16]; Uint8 (*dei)(struct Device *d, Uint8); void (*deo)(struct Device *d, Uint8); } Device; diff --git a/src/uxncli.c b/src/uxncli.c index 12a7f65..ffa3352 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -5,6 +5,7 @@ #include "devices/system.h" #include "devices/file.h" #include "devices/datetime.h" +#include "devices/debug.h" /* Copyright (c) 2021 Devine Lu Linvega diff --git a/src/uxnemu.c b/src/uxnemu.c index dbb33ec..5560d6b 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -15,6 +15,7 @@ #include "devices/controller.h" #include "devices/mouse.h" #include "devices/datetime.h" +#include "devices/debug.h" #pragma GCC diagnostic pop #pragma clang diagnostic pop @@ -279,11 +280,9 @@ start(Uxn *u, char *rom) /* unused */ uxn_port(u, 0xc, nil_dei, nil_deo); /* unused */ uxn_port(u, 0xd, nil_dei, nil_deo); /* unused */ uxn_port(u, 0xe, nil_dei, nil_deo); - /* unused */ uxn_port(u, 0xf, nil_dei, nil_deo); - + /* unused */ uxn_port(u, 0xf, debug_dei, debug_deo); if(!uxn_eval(u, PAGE_PROGRAM)) return error("Boot", "Failed to start rom."); - return 1; } From 031f63a13c3e78c1c022b6eed4bac0ad909e9a9a Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 13 Jan 2022 08:25:59 -0800 Subject: [PATCH 31/39] Print stack with DEO on 0x0f --- build.sh | 6 ++---- mkfile | 7 +++---- src/devices/system.c | 20 ++++++++++++++++++++ src/devices/system.h | 5 +++++ src/uxncli.c | 1 - src/uxnemu.c | 3 +-- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index a1884d3..e61df47 100755 --- a/build.sh +++ b/build.sh @@ -60,8 +60,6 @@ then clang-format -i src/devices/controller.c clang-format -i src/devices/datetime.h clang-format -i src/devices/datetime.c - clang-format -i src/devices/debug.h - clang-format -i src/devices/debug.c clang-format -i src/uxnasm.c clang-format -i src/uxnemu.c clang-format -i src/uxncli.c @@ -100,8 +98,8 @@ fi echo "Building.." ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm -${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu -${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/debug.c src/uxncli.c -o bin/uxncli +${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu +${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli if [ -d "$HOME/bin" ] then diff --git a/mkfile b/mkfile index 8e269bd..bf42d9f 100644 --- a/mkfile +++ b/mkfile @@ -9,7 +9,6 @@ HFILES=\ src/devices/audio.h\ src/devices/controller.h\ src/devices/datetime.h\ - src/devices/debug.h\ src/devices/file.h\ src/devices/mouse.h\ src/devices/screen.h\ @@ -34,19 +33,19 @@ bin: %.rom:Q: %.tal bin/uxnasm bin/uxnasm $stem.tal $target >/dev/null -bin/uxncli: file.$O datetime.$O debug.$O system.$O uxncli.$O uxn.$O +bin/uxncli: file.$O datetime.$O system.$O uxncli.$O uxn.$O $LD $LDFLAGS -o $target $prereq bin/uxnasm: uxnasm.$O $LD $LDFLAGS -o $target $prereq -bin/uxnemu: audio.$O controller.$O datetime.$O debug.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O +bin/uxnemu: audio.$O controller.$O datetime.$O file.$O mouse.$O screen.$O system.$O uxn.$O uxnemu.$O $LD $LDFLAGS -o $target $prereq (uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c $CC $CFLAGS -Isrc -o $target src/$stem1.c -(audio|controller|datetime|debug|file|mouse|screen|system)\.$O:R: src/devices/\1.c +(audio|controller|datetime|file|mouse|screen|system)\.$O:R: src/devices/\1.c $CC $CFLAGS -Isrc -o $target src/devices/$stem1.c nuke:V: clean diff --git a/src/devices/system.c b/src/devices/system.c index 4d9bbec..c807ff1 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -22,6 +22,22 @@ static const char *errors[] = { "Working-stack division by zero", "Return-stack division by zero"}; +static void +inspect(Stack *s, char *name) +{ + Uint8 x, y; + fprintf(stderr, "\n%s\n", name); + for(y = 0; y < 0x04; y++) { + for(x = 0; x < 0x08; x++) { + Uint8 p = y * 0x08 + x; + fprintf(stderr, + p == s->ptr ? "[%02x]" : " %02x ", + s->dat[p]); + } + fprintf(stderr, "\n"); + } +} + int uxn_halt(Uxn *u, Uint8 error, Uint16 addr) { @@ -59,6 +75,10 @@ system_deo(Device *d, Uint8 port) switch(port) { case 0x2: d->u->wst.ptr = d->dat[port]; break; case 0x3: d->u->rst.ptr = d->dat[port]; break; + case 0xe: + inspect(&d->u->wst, "Working-stack"); + inspect(&d->u->rst, "Return-stack"); + break; default: system_deo_special(d, port); } } diff --git a/src/devices/system.h b/src/devices/system.h index 35f81a6..cca011e 100644 --- a/src/devices/system.h +++ b/src/devices/system.h @@ -9,6 +9,11 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE. */ +typedef struct SystemDevice { + Device device; + struct UxnScreen *screen; +} SystemDevice; + Uint8 system_dei(Device *d, Uint8 port); void system_deo(Device *d, Uint8 port); void system_deo_special(Device *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c index ffa3352..12a7f65 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -5,7 +5,6 @@ #include "devices/system.h" #include "devices/file.h" #include "devices/datetime.h" -#include "devices/debug.h" /* Copyright (c) 2021 Devine Lu Linvega diff --git a/src/uxnemu.c b/src/uxnemu.c index 5560d6b..2361167 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -15,7 +15,6 @@ #include "devices/controller.h" #include "devices/mouse.h" #include "devices/datetime.h" -#include "devices/debug.h" #pragma GCC diagnostic pop #pragma clang diagnostic pop @@ -280,7 +279,7 @@ start(Uxn *u, char *rom) /* unused */ uxn_port(u, 0xc, nil_dei, nil_deo); /* unused */ uxn_port(u, 0xd, nil_dei, nil_deo); /* unused */ uxn_port(u, 0xe, nil_dei, nil_deo); - /* unused */ uxn_port(u, 0xf, debug_dei, debug_deo); + /* unused */ uxn_port(u, 0xf, nil_dei, nil_deo); if(!uxn_eval(u, PAGE_PROGRAM)) return error("Boot", "Failed to start rom."); return 1; From 44a7f5ef0eed389b2d169e5d86e71ffdbd513a36 Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 13 Jan 2022 08:26:35 -0800 Subject: [PATCH 32/39] Removed old debug files --- src/devices/debug.c | 50 --------------------------------------------- src/devices/debug.h | 19 ----------------- 2 files changed, 69 deletions(-) delete mode 100644 src/devices/debug.c delete mode 100644 src/devices/debug.h diff --git a/src/devices/debug.c b/src/devices/debug.c deleted file mode 100644 index 2721134..0000000 --- a/src/devices/debug.c +++ /dev/null @@ -1,50 +0,0 @@ -#include - -#include "../uxn.h" -#include "debug.h" - -/* -Copyright (c) 2021 Devine Lu Linvega -Copyright (c) 2021 Andrew Alderwick - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE. -*/ - -static void -inspect(Stack *s, char *name) -{ - Uint8 x, y; - fprintf(stderr, "\n%s\n", name); - for(y = 0; y < 0x04; y++) { - for(x = 0; x < 0x08; x++) { - Uint8 p = y * 0x08 + x; - fprintf(stderr, - p == s->ptr ? "[%02x]" : " %02x ", - s->dat[p]); - } - fprintf(stderr, "\n"); - } -} - -/* IO */ - -Uint8 -debug_dei(Device *d, Uint8 port) -{ - DebugDevice *debug = (DebugDevice *)d; - return d->dat[port]; -} - -void -debug_deo(Device *d, Uint8 port) -{ - (void)d; - (void)port; - inspect(&d->u->wst, "Working-stack"); - inspect(&d->u->rst, "Return-stack"); -} diff --git a/src/devices/debug.h b/src/devices/debug.h deleted file mode 100644 index e141bd9..0000000 --- a/src/devices/debug.h +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright (c) 2021 Devine Lu Linvega -Copyright (c) 2021 Andrew Alderwick - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE. -*/ - -typedef struct DebugDevice { - Device device; - struct UxnScreen *screen; -} DebugDevice; - -Uint8 debug_dei(Device *d, Uint8 port); -void debug_deo(Device *d, Uint8 port); \ No newline at end of file From f1cc022e9b90c66afc93b1e75ce7a9aa27ae4076 Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 13 Jan 2022 08:34:32 -0800 Subject: [PATCH 33/39] Uxncli now uses the system_inspect --- src/devices/system.c | 13 ++++++++----- src/devices/system.h | 1 + src/uxncli.c | 21 +-------------------- src/uxnemu.c | 2 +- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/devices/system.c b/src/devices/system.c index c807ff1..42ad4ad 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -23,7 +23,7 @@ static const char *errors[] = { "Return-stack division by zero"}; static void -inspect(Stack *s, char *name) +print_stack(Stack *s, char *name) { Uint8 x, y; fprintf(stderr, "\n%s\n", name); @@ -57,6 +57,12 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr) return 0; } +void +system_inspect(Uxn *u){ + print_stack(&u->wst, "Working-stack"); + print_stack(&u->rst, "Return-stack"); +} + /* IO */ Uint8 @@ -75,10 +81,7 @@ system_deo(Device *d, Uint8 port) switch(port) { case 0x2: d->u->wst.ptr = d->dat[port]; break; case 0x3: d->u->rst.ptr = d->dat[port]; break; - case 0xe: - inspect(&d->u->wst, "Working-stack"); - inspect(&d->u->rst, "Return-stack"); - break; + case 0xe: system_inspect(d->u); break; default: system_deo_special(d, port); } } diff --git a/src/devices/system.h b/src/devices/system.h index cca011e..114d2d1 100644 --- a/src/devices/system.h +++ b/src/devices/system.h @@ -14,6 +14,7 @@ typedef struct SystemDevice { struct UxnScreen *screen; } SystemDevice; +void system_inspect(Uxn *u); Uint8 system_dei(Device *d, Uint8 port); void system_deo(Device *d, Uint8 port); void system_deo_special(Device *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c index 12a7f65..f3af6f0 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -31,29 +31,10 @@ error(char *msg, const char *err) return 0; } -static void -inspect(Stack *s, char *name) -{ - Uint8 x, y; - fprintf(stderr, "\n%s\n", name); - for(y = 0; y < 0x04; y++) { - for(x = 0; x < 0x08; x++) { - Uint8 p = y * 0x08 + x; - fprintf(stderr, - p == s->ptr ? "[%02x]" : " %02x ", - s->dat[p]); - } - fprintf(stderr, "\n"); - } -} - void system_deo_special(Device *d, Uint8 port) { - if(port == 0xe) { - inspect(&d->u->wst, "Working-stack"); - inspect(&d->u->rst, "Return-stack"); - } + } static void diff --git a/src/uxnemu.c b/src/uxnemu.c index 2361167..3ccfe32 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -372,7 +372,7 @@ do_shortcut(Uxn *u, SDL_Event *event) if(event->key.keysym.sym == SDLK_F1) set_zoom(zoom > 2 ? 1 : zoom + 1); else if(event->key.keysym.sym == SDLK_F2) - toggle_debugger(); + system_inspect(u); else if(event->key.keysym.sym == SDLK_F3) capture_screen(); else if(event->key.keysym.sym == SDLK_F4) From b48db8278f8ea1cbda496860070bf20a144b5fdd Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 13 Jan 2022 10:25:31 -0800 Subject: [PATCH 34/39] (monospace.tal) Added a 8x8 label drawing example --- projects/examples/gui/monospace.tal | 155 ++++++++++++++++++++++++++++ src/devices/system.c | 34 +++--- src/devices/system.h | 1 + src/uxncli.c | 1 - src/uxnemu.c | 14 +-- 5 files changed, 176 insertions(+), 29 deletions(-) create mode 100644 projects/examples/gui/monospace.tal diff --git a/projects/examples/gui/monospace.tal b/projects/examples/gui/monospace.tal new file mode 100644 index 0000000..65522af --- /dev/null +++ b/projects/examples/gui/monospace.tal @@ -0,0 +1,155 @@ +( Draw a 8x8 font ) + +%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } +%< { LTH } %> { GTH } %= { EQU } %! { NEQ } +%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } +%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } + +%AUTO-X { #01 .Screen/auto DEO } + +( devices ) + +|00 @System &vector $2 &wst $1 &rst $1 &eaddr $2 &ecode $1 &pad $1 &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 ) + #f05d .System/r DEO2 + #f0cd .System/g DEO2 + #f0ad .System/b DEO2 + + ( draw hello world ) + #0010 .Screen/x DEO2 + #0010 .Screen/y DEO2 + ;hello-txt #01 ;draw-uf1 JSR2 + + ( draw long text ) + #0010 .Screen/x DEO2 + #0030 .Screen/y DEO2 + ;long-txt #02 ;draw-uf1-linebreaks JSR2 + +BRK + +@draw-uf1 ( string* color -- ) + + AUTO-X + STH + &while + ( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2 + ( draw ) STHkr .Screen/sprite DEO + INC2 LDAk ,&while JCN + POPr + +JMP2r + +@draw-uf1-linebreaks ( string* color -- ) + + .Screen/x DEI2 ,&anchor STR2 + AUTO-X + STH + &while + LDAk #0a ! ,&no-lb JCN + ( rewind ) LIT2 &anchor $2 .Screen/x DEO2 + ( skip line ) .Screen/y DEI2k #0008 ++ ROT DEO2 + ,&end JMP + &no-lb + ( get sprite ) LDAk #20 - #00 SWP #30 SFT2 ;font ++ .Screen/addr DEO2 + ( draw ) STHkr .Screen/sprite DEO + &end + INC2 LDAk ,&while JCN + POPr + +JMP2r + +@hello-txt "Hello 20 "Uxn! $1 + +@long-txt + 5275 7374 6963 2043 6f6d 7075 7469 6e67 + 2072 6566 6572 7320 746f 2074 6865 2063 + 6f6e 7374 7275 6374 696f 6e20 0a6f 6620 + 6361 6c63 756c 6174 696f 6e20 6d61 6368 + 696e 6573 2075 7369 6e67 2070 7265 2d69 + 6e64 7573 7472 6961 6c20 0a6f 7220 6576 + 656e 2070 7265 2d68 6973 746f 7269 6320 + 7465 6368 6e6f 6c6f 6779 2e20 0a0a 4974 + 2072 6576 6561 6c73 2061 2068 6973 746f + 7279 206f 6620 636f 6d70 7574 696e 6720 + 6173 2074 6865 200a 7061 7374 696d 6520 + 6f66 2064 696c 6574 7461 6e74 6573 2c20 + 616d 6174 6575 7220 7363 6965 6e74 6973 + 7473 0a61 6e64 2074 6162 756c 6174 6f72 + 7320 7768 6f20 636f 6e73 7472 7563 7420 + 6d61 6368 696e 6573 2074 6f20 0a6d 616e + 6970 756c 6174 6520 6162 7374 7261 6374 + 2073 796d 626f 6c73 2077 6974 6820 6e6f + 2070 7261 6374 6963 616c 200a 6170 706c + 6963 6174 696f 6e2e 2041 7320 7468 6573 + 6520 6d61 6368 696e 6573 2061 7265 2067 + 656e 6572 616c 6c79 200a 6c65 7373 2065 + 6666 6963 6965 6e74 2074 6861 6e20 636f + 6e76 656e 7469 6f6e 616c 2070 656e 6369 + 6c20 616e 6420 0a70 6170 6572 2063 6f6d + 7075 7461 7469 6f6e 2c20 7468 6579 2061 + 6c6c 7564 6520 746f 2061 206d 6f72 6520 + 0a65 7069 6375 7265 616e 2070 7261 6374 + 6963 6520 6f66 2063 6f6d 7075 7469 6e67 + 2066 6f72 2070 6c65 6173 7572 6520 0a72 + 6174 6865 7220 7468 616e 2070 726f 6475 + 6374 696f 6e2e + +@font ( bbcmicro ) + 0000 0000 0000 0000 1818 1818 1800 1800 + 6c6c 6c00 0000 0000 3636 7f36 7f36 3600 + 0c3f 683e 0b7e 1800 6066 0c18 3066 0600 + 386c 6c38 6d66 3b00 0c18 3000 0000 0000 + 0c18 3030 3018 0c00 3018 0c0c 0c18 3000 + 0018 7e3c 7e18 0000 0018 187e 1818 0000 + 0000 0000 0018 1830 0000 007e 0000 0000 + 0000 0000 0018 1800 0006 0c18 3060 0000 + 3c66 6e7e 7666 3c00 1838 1818 1818 7e00 + 3c66 060c 1830 7e00 3c66 061c 0666 3c00 + 0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00 + 1c30 607c 6666 3c00 7e06 0c18 3030 3000 + 3c66 663c 6666 3c00 3c66 663e 060c 3800 + 0000 1818 0018 1800 0000 1818 0018 1830 + 0c18 3060 3018 0c00 0000 7e00 7e00 0000 + 3018 0c06 0c18 3000 3c66 0c18 1800 1800 + 3c66 6e6a 6e60 3c00 3c66 667e 6666 6600 + 7c66 667c 6666 7c00 3c66 6060 6066 3c00 + 786c 6666 666c 7800 7e60 607c 6060 7e00 + 7e60 607c 6060 6000 3c66 606e 6666 3c00 + 6666 667e 6666 6600 7e18 1818 1818 7e00 + 3e0c 0c0c 0c6c 3800 666c 7870 786c 6600 + 6060 6060 6060 7e00 6377 7f6b 6b63 6300 + 6666 767e 6e66 6600 3c66 6666 6666 3c00 + 7c66 667c 6060 6000 3c66 6666 6a6c 3600 + 7c66 667c 6c66 6600 3c66 603c 0666 3c00 + 7e18 1818 1818 1800 6666 6666 6666 3c00 + 6666 6666 663c 1800 6363 6b6b 7f77 6300 + 6666 3c18 3c66 6600 6666 663c 1818 1800 + 7e06 0c18 3060 7e00 7c60 6060 6060 7c00 + 0060 3018 0c06 0000 3e06 0606 0606 3e00 + 183c 6642 0000 0000 0000 0000 0000 00ff + 1c36 307c 3030 7e00 0000 3c06 3e66 3e00 + 6060 7c66 6666 7c00 0000 3c66 6066 3c00 + 0606 3e66 6666 3e00 0000 3c66 7e60 3c00 + 1c30 307c 3030 3000 0000 3e66 663e 063c + 6060 7c66 6666 6600 1800 3818 1818 3c00 + 1800 3818 1818 1870 6060 666c 786c 6600 + 3818 1818 1818 3c00 0000 367f 6b6b 6300 + 0000 7c66 6666 6600 0000 3c66 6666 3c00 + 0000 7c66 667c 6060 0000 3e66 663e 0607 + 0000 6c76 6060 6000 0000 3e60 3c06 7c00 + 3030 7c30 3030 1c00 0000 6666 6666 3e00 + 0000 6666 663c 1800 0000 636b 6b7f 3600 + 0000 663c 183c 6600 0000 6666 663e 063c + 0000 7e0c 1830 7e00 0c18 1870 1818 0c00 + 1818 1800 1818 1800 3018 180e 1818 3000 + 316b 4600 0000 0000 ffff ffff ffff ffff diff --git a/src/devices/system.c b/src/devices/system.c index 42ad4ad..1b46994 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -23,19 +23,22 @@ static const char *errors[] = { "Return-stack division by zero"}; static void -print_stack(Stack *s, char *name) +system_print(Stack *s, char *name) { - Uint8 x, y; - fprintf(stderr, "\n%s\n", name); - for(y = 0; y < 0x04; y++) { - for(x = 0; x < 0x08; x++) { - Uint8 p = y * 0x08 + x; - fprintf(stderr, - p == s->ptr ? "[%02x]" : " %02x ", - s->dat[p]); - } - fprintf(stderr, "\n"); - } + Uint8 i; + fprintf(stderr, "<%s> ", name); + for(i = 0; i < s->ptr; i++) + fprintf(stderr, i == s->ptr ? "[%02x]" : " %02x ", s->dat[i]); + if(!i) + fprintf(stderr, "empty"); + fprintf(stderr, "\n"); +} + +void +system_inspect(Uxn *u) +{ + system_print(&u->wst, "wst"); + system_print(&u->rst, "rst"); } int @@ -53,16 +56,11 @@ uxn_halt(Uxn *u, Uint8 error, Uint16 addr) vec += 0x0004; return uxn_eval(u, vec); } + system_inspect(u); fprintf(stderr, "Halted: %s#%04x, at 0x%04x\n", errors[error], u->ram[addr], addr); return 0; } -void -system_inspect(Uxn *u){ - print_stack(&u->wst, "Working-stack"); - print_stack(&u->rst, "Return-stack"); -} - /* IO */ Uint8 diff --git a/src/devices/system.h b/src/devices/system.h index 114d2d1..6bdc847 100644 --- a/src/devices/system.h +++ b/src/devices/system.h @@ -15,6 +15,7 @@ typedef struct SystemDevice { } SystemDevice; void system_inspect(Uxn *u); + Uint8 system_dei(Device *d, Uint8 port); void system_deo(Device *d, Uint8 port); void system_deo_special(Device *d, Uint8 port); diff --git a/src/uxncli.c b/src/uxncli.c index f3af6f0..867cdb2 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -34,7 +34,6 @@ error(char *msg, const char *err) void system_deo_special(Device *d, Uint8 port) { - } static void diff --git a/src/uxnemu.c b/src/uxnemu.c index 3ccfe32..7cbc100 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -42,7 +42,7 @@ static SDL_Rect gRect; /* devices */ -static Device *devsystem, *devscreen, *devmouse, *devctrl, *devaudio0; +static Device *devscreen, *devmouse, *devctrl, *devaudio0; static Uint8 zoom = 1; static Uint32 stdin_event, audio0_event; @@ -292,13 +292,6 @@ set_zoom(Uint8 scale) set_window_size(gWindow, (uxn_screen.width + PAD * 2) * zoom, (uxn_screen.height + PAD * 2) * zoom); } -static void -toggle_debugger(void) -{ - devsystem->dat[0xe] = !devsystem->dat[0xe]; - screen_clear(&uxn_screen, &uxn_screen.fg); -} - static void capture_screen(void) { @@ -390,8 +383,9 @@ console_input(Uxn *u, char c) static int run(Uxn *u) { + Device *devsys = &u->dev[0]; redraw(); - while(!devsystem->dat[0xf]) { + while(!devsys->dat[0xf]) { SDL_Event event; double elapsed, begin; if(!BENCH) @@ -454,7 +448,7 @@ run(Uxn *u) console_input(u, event.cbutton.button); } uxn_eval(u, GETVECTOR(devscreen)); - if(uxn_screen.fg.changed || uxn_screen.bg.changed || devsystem->dat[0xe]) + if(uxn_screen.fg.changed || uxn_screen.bg.changed) redraw(); if(!BENCH) { elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f; From fc659b909491a000e42ae177ac59137dd4c1efed Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 13 Jan 2022 10:55:02 -0800 Subject: [PATCH 35/39] Removed devsystem --- src/uxnemu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uxnemu.c b/src/uxnemu.c index 7cbc100..faa4e62 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -264,7 +264,7 @@ start(Uxn *u, char *rom) return error("Boot", "Failed to start uxn."); if(!load(u, rom)) return error("Boot", "Failed to load rom."); - /* system */ devsystem = uxn_port(u, 0x0, system_dei, system_deo); + /* system */ uxn_port(u, 0x0, system_dei, system_deo); /* console */ uxn_port(u, 0x1, nil_dei, console_deo); /* screen */ devscreen = uxn_port(u, 0x2, screen_dei, screen_deo); /* audio0 */ devaudio0 = uxn_port(u, 0x3, audio_dei, audio_deo); From 4ea8cc2819554ce40c943f38a1ac9860b13bfd4c Mon Sep 17 00:00:00 2001 From: neauoire Date: Thu, 13 Jan 2022 14:52:37 -0800 Subject: [PATCH 36/39] Removed extra specing around bytes in stack printing --- src/devices/system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/system.c b/src/devices/system.c index 1b46994..b0dca4c 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -28,7 +28,7 @@ system_print(Stack *s, char *name) Uint8 i; fprintf(stderr, "<%s> ", name); for(i = 0; i < s->ptr; i++) - fprintf(stderr, i == s->ptr ? "[%02x]" : " %02x ", s->dat[i]); + fprintf(stderr, "%02x ", s->dat[i]); if(!i) fprintf(stderr, "empty"); fprintf(stderr, "\n"); From 2c47425c41976e23c9c28d1cb98a9fe3fbe3b31b Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Fri, 14 Jan 2022 07:59:42 +0000 Subject: [PATCH 37/39] Remove trailing space in stack printing --- src/devices/system.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/devices/system.c b/src/devices/system.c index b0dca4c..b34a32e 100644 --- a/src/devices/system.c +++ b/src/devices/system.c @@ -26,11 +26,11 @@ static void system_print(Stack *s, char *name) { Uint8 i; - fprintf(stderr, "<%s> ", name); + fprintf(stderr, "<%s>", name); for(i = 0; i < s->ptr; i++) - fprintf(stderr, "%02x ", s->dat[i]); + fprintf(stderr, " %02x", s->dat[i]); if(!i) - fprintf(stderr, "empty"); + fprintf(stderr, " empty"); fprintf(stderr, "\n"); } From bec7096c0b32907a449ee7dc789d4024b567d8fb Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 15 Jan 2022 10:13:20 -0800 Subject: [PATCH 38/39] Implemented proper decimal mode --- projects/software/calc.tal | 378 ++++++++++++++++++------------------- 1 file changed, 181 insertions(+), 197 deletions(-) diff --git a/projects/software/calc.tal b/projects/software/calc.tal index 326a0b4..b2cabc1 100644 --- a/projects/software/calc.tal +++ b/projects/software/calc.tal @@ -2,33 +2,35 @@ a simple calculator uxnasm projects/software/calc.tal bin/calc.rom && uxnemu bin/calc.rom ) -%+ { ADD } %- { SUB } %/ { DIV } -%< { LTH } %> { GTH } %= { EQU } %! { NEQ } -%++ { ADD2 } %-- { SUB2 } %// { DIV2 } +%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } +%< { LTH } %> { GTH } %= { EQU } %! { NEQ } +%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } +%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } +%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 } +%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 } +%10* { #40 SFT } %10/ { #04 SFT } %10** { #40 SFT2 } %10// { #04 SFT2 } +%20* { #50 SFT } %20/ { #05 SFT } %20** { #50 SFT2 } %20// { #05 SFT2 } + +%2MOD { #01 AND } %2MOD2 { #0001 AND2 } +%4MOD { #03 AND } %4MOD2 { #0003 AND2 } +%8MOD { #07 AND } %8MOD2 { #0007 AND2 } +%10MOD { #0f AND } %10MOD2 { #000f AND2 } + %!~ { NEQk NIP } -%2* { #10 SFT } -%4* { #20 SFT } %4/ { #02 SFT } -%8* { #30 SFT } %8/ { #03 SFT } -%2** { #10 SFT2 } %2// { #01 SFT2 } -%4** { #20 SFT2 } -%8** { #30 SFT2 } %8// { #03 SFT2 } -%10** { #40 SFT2 } %10// { #04 SFT2 } -%20** { #50 SFT2 } - -%2MOD2 { #0001 AND2 } -%4MOD { #03 AND } %4MOD2 { #0003 AND2 } -%8MOD { #07 AND } - %DEBUG { ;print-hex/byte JSR2 #0a .Console/write DEO } %DEBUG2 { ;print-hex/short JSR2 #0a .Console/write DEO } +%AUTO-NONE { #00 .Screen/auto DEO } +%AUTO-X { #01 .Screen/auto DEO } +%AUTO-XADDR { #05 .Screen/auto DEO } +%AUTO-YADDR { #06 .Screen/auto DEO } + %RELEASE-MOUSE { #0096 DEO } %RTN { JMP2r } -%BRK? { #01 JCN BRK } %RTN? { #01 JCN RTN } %TOS { #00 SWP } @@ -47,7 +49,8 @@ |0000 @input - &length $1 &value $2 + &value $2 + &mode $1 @stack &length $1 &items $10 @@ -82,7 +85,7 @@ ;on-button .Controller/vector DEO2 ( setup synth ) - #0110 .Audio0/adsr DEO2 + #0010 .Audio0/adsr DEO2 ;sin-pcm .Audio0/addr DEO2 #0100 .Audio0/length DEO2 #dd .Audio0/volume DEO @@ -120,13 +123,11 @@ BRK .Controller/key DEI ( generics ) - #00 !~ ,&no-release JCN ;redraw JSR2 POP BRK &no-release + #00 !~ ,&no-empty JCN ;redraw JSR2 POP BRK &no-empty + #09 !~ ,&no-tab JCN ;toggle-mode JSR2 POP BRK &no-tab #0d !~ ,&no-enter JCN ;do-push JSR2 POP BRK &no-enter #1b !~ ,&no-esc JCN ;do-pop JSR2 POP BRK &no-esc - #08 !~ ,&no-backspace JCN - .input/value LDZ2 #04 SFT2 .input/value STZ2 - #ff ;draw-input JSR2 POP BRK - &no-backspace + #08 !~ ,&no-backspace JCN ;do-erase JSR2 POP BRK &no-backspace ( arithmetic ) LIT '+ !~ ,&no-add JCN ;do-add JSR2 POP BRK &no-add LIT '- !~ ,&no-sub JCN ;do-sub JSR2 POP BRK &no-sub @@ -156,50 +157,59 @@ BRK .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 #41 .Mouse/state DEI #01 = + .Screen/sprite DEO - ( handle events ) .Mouse/state DEI .pointer/last LDZ + ( down ) DUP2 #0100 !! ,&no-down JCN - .Mouse/state DEI .pointer/last STZ - POP2 .Mouse/x DEI2 .Mouse/y DEI2 OVR2 OVR2 .keypad-frame ;within-rect JSR2 ;click-keypad JCN2 OVR2 OVR2 .input-frame ;within-rect JSR2 ;click-input JCN2 OVR2 OVR2 .modpad-frame ;within-rect JSR2 ;click-modpad JCN2 OVR2 OVR2 .bitpad-frame ;within-rect JSR2 ;click-bitpad JCN2 POP2 POP2 - BRK &no-down + ( up ) DUP2 #0001 !! ,&no-up JCN - .Mouse/state DEI .pointer/last STZ - POP2 ;redraw JSR2 BRK + ;redraw JSR2 &no-up POP2 + ( record ) .Mouse/state DEI .pointer/last STZ BRK -@click-keypad ( x* y* -> ) +@click-keypad ( state* x* y* -> ) ( y ) .keypad-frame/y LDZ2 -- #24 SFT2 ( x ) SWP2 .keypad-frame/x LDZ2 -- 10// 4MOD2 - ( value ) ++ ;keypad/layout ++ LDA - ;push-input JSR2 - - RELEASE-MOUSE + ( value ) ++ ;keypad/layout ++ LDA ;push-input JSR2 + RELEASE-MOUSE POP2 BRK -@click-modpad ( x* y* -> ) +@click-modpad ( state* x* y* -> ) ( y ) .modpad-frame/y LDZ2 -- #24 SFT2 NIP STH ( x ) .modpad-frame/x LDZ2 -- 10// ( lookup ) STHr + 2** ;keypad/ops ++ LDA2 JSR2 ;draw-bitpad JSR2 - RELEASE-MOUSE + RELEASE-MOUSE POP2 BRK -@click-bitpad ( x* y* -> ) +@click-input ( state* x* y* -> ) + + POP2 + .input-frame/x LDZ2 -- 8// NIP + DUP #00 ! ,&no-push JCN + ;do-push JSR2 &no-push + DUP #01 ! ,&no-pop JCN + ;do-pop JSR2 &no-pop + POP + RELEASE-MOUSE POP2 + +BRK + +@click-bitpad ( state* x* y* -> ) ( y ) .bitpad-frame/y LDZ2 -- 8// NIP 8* STH ( x ) .bitpad-frame/x LDZ2 -- 8// NIP @@ -213,22 +223,8 @@ BRK .input/value STZ2 ;draw-bitpad JSR2 - RELEASE-MOUSE - -BRK - -@click-input ( x* y* -> ) - - POP2 - .input-frame/x LDZ2 -- 8// NIP - DUP #00 ! ,&no-push JCN - ;do-push JSR2 - &no-push - DUP #01 ! ,&no-pop JCN - ;do-pop JSR2 - &no-pop - POP - RELEASE-MOUSE + #ff ;draw-input JSR2 + RELEASE-MOUSE POP2 BRK @@ -236,8 +232,9 @@ BRK DUP #50 + .Audio0/pitch DEO DUP TOS ;keypad/series ++ LDA ;draw-keypad JSR2 - TOS .input/value LDZ2 10** ++ .input/value STZ2 - ( INCZ ) .input/length LDZk INC SWP STZ + ( hex/dec ) + TOS .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] ** + ++ .input/value STZ2 #ff ;draw-input JSR2 ;draw-bitpad JSR2 @@ -263,13 +260,20 @@ RTN RTN +@toggle-mode ( -- ) + + .input/mode LDZk #00 = SWP STZ + ;redraw JSR2 + +RTN + @do-push ( -- ) .input/value LDZ2 ADD #00 > JMP RTN .stack/length LDZ #07 < JMP RTN - #40 .Audio0/pitch DEO .input/value LDZ2 ;push JSR2 + ;draw-bitpad JSR2 RTN @@ -282,6 +286,7 @@ RTN ;draw-stack JSR2 &continue #01 ;draw-input JSR2 + ;draw-bitpad JSR2 RTN @@ -397,17 +402,22 @@ RTN RTN +@do-erase ( -- ) + + .input/value LDZ2 #04 SFT2 .input/value STZ2 + #ff ;draw-input JSR2 + ;draw-bitpad JSR2 + +RTN + @key-value ( key -- value ) - DUP #2f > OVR #3a < #0101 !! ,&no-num JCN - #30 - RTN - &no-num - DUP #60 > OVR #67 < #0101 !! ,&no-lc JCN - #57 - RTN ( #61 - #0a + ) - &no-lc - DUP #40 > OVR #47 < #0101 !! ,&no-uc JCN - #37 - RTN ( #41 - #0a + ) - &no-uc + DUP #2f > OVR #3a < #0101 !! ,&no-num JCN + #30 - RTN &no-num + DUP #60 > OVR #67 < #0101 !! ,&no-lc JCN + #57 - RTN ( #61 - #0a + ) &no-lc + DUP #40 > OVR #47 < #0101 !! ,&no-uc JCN + #37 - RTN ( #41 - #0a + ) &no-uc POP #00 RTN @@ -418,7 +428,22 @@ RTN #ff ;draw-modpad JSR2 #ff ;draw-input JSR2 ;draw-bitpad JSR2 - ,draw-stack JSR + ;draw-mode JSR2 + ;draw-stack JSR2 + + #0010 .Screen/x DEO2 + #0010 .Screen/y DEO2 + +RTN + +@draw-mode ( -- ) + + AUTO-XADDR + .input-frame/x LDZ2 .Screen/x DEO2 + .input-frame/y LDZ2 #0014 -- .Screen/y DEO2 + ;modes #00 .input/mode LDZ #0018 MUL2 ++ .Screen/addr DEO2 + #02 .input/mode LDZ + .Screen/sprite DEOk DEOk DEO + AUTO-NONE RTN @@ -426,99 +451,39 @@ RTN #08 #00 &loop + .input-frame/x LDZ2 #0018 ++ .Screen/x DEO2 + DUP TOS 8** .input-frame/y LDZ2 ++ #004c -- .Screen/y DEO2 ( color ) DUP #08 .stack/length LDZ - #01 - > STH - ( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2 STH2 - ( y ) DUP TOS 8** .input-frame/y LDZ2 ++ #004c -- STH2 - ( x ) .input-frame/x LDZ2 #0020 ++ STH2r STH2r STHr ,draw-short JSR + ( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2 + STHr ;draw-number JSR2 INC GTHk ,&loop JCN POP2 RTN -@draw-short ( x* y* value* color -- ) - - STH STH2 - .Screen/y DEO2 - #0020 ++ .Screen/x DEO2 - #0400 - &loop - .Screen/x DEI2 #0008 -- .Screen/x DEO2 - ( value ) DUP STH2kr ROT 4* SFT2 #000f AND2 - ( value glyph ) 8** ;font-hex ++ .Screen/addr DEO2 - ( get color ) ROTr STHkr - ( place stack ) ROTr ROTr - ( no leading zeros ) - OVR STH2kr ,get-length JSR < ,&visible JCN - POP #00 - &visible - ( draw ) .Screen/sprite DEO - INC GTHk ,&loop JCN - POP2 - POP2r POPr - -RTN - -@get-length ( short* -- length ) - - DUP2 #1000 << ,&no4 JCN POP2 #04 RTN &no4 - DUP2 #0100 << ,&no3 JCN POP2 #03 RTN &no3 - DUP2 #0010 << ,&no2 JCN POP2 #02 RTN &no2 - #0000 !! - -RTN - -@draw-decimal ( -- ) - - .bitpad-frame/y2 LDZ2 #0008 ++ .Screen/y DEO2 - .center/x LDZ2 #0014 -- .Screen/x DEO2 - #01 .Screen/auto DEO - - .input/value LDZ2 - ( 10,000 ) #2710 DIV2k DUP2 NIP ,&digit JSR [ MUL2 SUB2 ] - ( 1,000 ) #03e8 DIV2k DUP2 NIP ,&digit JSR [ MUL2 SUB2 ] - ( 100 ) #0064 DIV2k DUP2 NIP ,&digit JSR [ MUL2 SUB2 NIP ] - ( 10 ) #0a DIVk DUP ,&digit JSR [ MUL SUB ] - ( 1 ) ,&digit JSR - #00 .Screen/auto DEO - -RTN - &digit ( num -- ) - 8* TOS ;font-hex ++ .Screen/addr DEO2 - #03 .Screen/sprite DEO - RTN - @draw-input ( key -- ) STH - ( draw value ) - .input-frame/x LDZ2 #0020 ++ - .input-frame/y LDZ2 #0003 ++ - .input/value LDZ2 - #02 - ;draw-short JSR2 - + .input-frame/x LDZ2 #0018 ++ .Screen/x DEO2 + .input-frame/y LDZ2 #0003 ++ .Screen/y DEO2 + .input/value LDZ2 #02 ;draw-number JSR2 ( controls ) .input-frame/x LDZ2 .input-frame/y LDZ2 ;stack-icns/push [ STHkr #00 = ] #02 ;draw-key-thin JSR2 - .input-frame/x LDZ2 #0008 ++ .input-frame/y LDZ2 ;stack-icns/pop [ STHkr #01 = ] #03 ;draw-key-thin JSR2 - ( line ) .input-frame/x LDZ2 .input-frame/x2 LDZ2 .input-frame/y LDZ2 #0004 -- #02 ;line-hor-dotted JSR2 - POPr - ;draw-decimal JSR2 - RTN @draw-keypad ( key -- ) @@ -559,7 +524,7 @@ RTN @draw-bitpad ( -- ) - #10 #00 + #1000 &loop ( y ) DUP 8/ TOS 8** .bitpad-frame/y LDZ2 ++ .Screen/y DEO2 ( x ) DUP 8MOD TOS 8** .bitpad-frame/x LDZ2 ++ .Screen/x DEO2 @@ -573,7 +538,7 @@ RTN @draw-key ( x* y* glyph* state color -- ) - ( auto x addr ) #05 .Screen/auto DEO + ( auto x addr ) AUTO-XADDR ( color ) ,&color STR ( state ) ,&state STR ( glyph ) ,&glyph STR2 @@ -591,30 +556,57 @@ RTN .Screen/x DEI2 #000c -- .Screen/x DEO2 .Screen/y DEI2 #0005 -- .Screen/y DEO2 ,&color LDR [ ,&state LDR #09 MUL + ] .Screen/sprite DEO - ( auto none ) #00 .Screen/auto DEO + ( auto none ) AUTO-NONE RTN &color $1 &state $1 &glyph $2 @draw-key-thin ( x* y* glyph* state color -- ) - ( auto y addr ) #06 .Screen/auto DEO - ( color ) ,&color STR - ( state ) ,&state STR - ( glyph ) ,&glyph STR2 - ( state ) ;button-thin-icns [ #00 ,&state LDR 10** ++ ] .Screen/addr DEO2 - ( y ) .Screen/y DEO2 - ( x ) .Screen/x DEO2 - ( draw background ) - ,&color LDR .Screen/sprite DEOk DEO + AUTO-YADDR + ,&color STR ,&state STR ,&glyph STR2 + ( frame ) + ;button-thin-icns #00 [ LIT &state $1 ] 10** ++ .Screen/addr DEO2 + .Screen/y DEO2 .Screen/x DEO2 + [ LIT &color $1 ] .Screen/sprite DEOk DEO ( glyph ) - ,&glyph LDR2 .Screen/addr DEO2 + [ LIT2 &glyph $2 ] .Screen/addr DEO2 .Screen/y DEI2 #000c -- .Screen/y DEO2 #05 .Screen/sprite DEO - ( auto none ) #00 .Screen/auto DEO + AUTO-NONE + +RTN + +@draw-number ( number* color -- ) + + ,&color STR + .input/mode LDZ ,&decimal JCN + ( hexadecimal ) + AUTO-X + ,&color LDR #00 ,&color STR + #00 ,&digit JSR ,&color STR + SWP + STHk #04 SFT ,&digit JSR + STHr #0f AND ,&digit JSR + STHk #04 SFT ,&digit JSR + STHr #0f AND ,&digit JSR + AUTO-NONE + RTN + &decimal + AUTO-X + #2710 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2 + #03e8 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2 + #0064 DIV2k DUP2 NIP ,&digit JSR MUL2 SUB2 NIP + #0a DIVk DUP ,&digit JSR MUL SUB + ,&digit JSR + AUTO-NONE + RTN + &digit + 8* TOS ;font-hex ++ .Screen/addr DEO2 + LIT &color $1 .Screen/sprite DEO + RTN RTN - &color $1 &state $1 &glyph $2 ( theme ) @@ -645,12 +637,8 @@ RTN ( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN POP2 POP2 POPr #01 -RTN - &skip - POP2 POP2 POPr - #00 - -RTN +RTN + &skip POP2 POP2 POPr #00 RTN @line-hor-dotted ( x0* x1* y* color -- ) @@ -665,38 +653,24 @@ RTN RTN @print-hex ( value* -- ) - - &short ( value* -- ) - SWP ,&echo JSR - &byte ( value -- ) - ,&echo JSR - RTN - &echo ( 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 + RTN &above #09 - #60 + RTN + SWP ,&byte JSR + &byte ( byte -- ) + STHk #04 SFT ,&parse JSR #18 DEO + STHr #0f AND ,&parse JSR #18 DEO + JMP2r + &parse ( byte -- char ) DUP #09 GTH ,&above JCN #30 ADD JMP2r + &above #57 ADD JMP2r -RTN +JMP2r @keypad &layout - 0708 090f - 0405 060e - 0102 030d - 000a 0b0c + 0708 090f 0405 060e 0102 030d 000a 0b0c &series - 0c08 090a - 0405 0600 - 0102 0d0e - 0f0b 0703 + 0c08 090a 0405 0600 0102 0d0e 0f0b 0703 &color - 0101 0102 - 0101 0102 - 0101 0102 - 0102 0202 + 0101 0102 0101 0102 0101 0102 0102 0202 &ops :do-add :do-sub :do-mul :do-div :do-and :do-ora :do-eor :do-not @@ -727,7 +701,17 @@ RTN 007c 8282 7c82 827c 007c 8282 7e02 827c 007c 8202 7e82 827e 00fc 8282 fc82 82fc 007c 8280 8080 827c 00fc 8282 8282 82fc - 007c 8280 f080 827c 007c 8280 f080 8080 + 007e 8080 fe80 807e 007c 8280 f080 8080 + +@modes + ( hex ) + 0082 8282 fe82 8282 + 007e 8080 fe80 807e + 0082 4428 1028 4482 + ( dec ) + 00fc 8282 8282 82fc + 007e 8080 fe80 807e + 007c 8280 8080 827c @mod-icns 0010 1010 fe10 1010 @@ -742,35 +726,35 @@ RTN @button-icns ( outline ) - 3f40 8080 8080 8080 - f804 0202 0202 0202 - 8080 8080 8040 3f00 - 0202 0202 0204 f800 + 3f40 8080 8080 8080 + f804 0202 0202 0202 + 8080 8080 8040 3f00 + 0202 0202 0204 f800 ( full ) - 3f7f ffff ffff ffff - f8fc fefe fefe fefe - ffff ffff ff7f 3f00 - fefe fefe fefc f800 + 3f7f ffff ffff ffff + f8fc fefe fefe fefe + ffff ffff ff7f 3f00 + fefe fefe fefc f800 @button-thin-icns ( outline ) - 3844 8282 8282 8282 - 8282 8282 8244 3800 + 3844 8282 8282 8282 + 8282 8282 8244 3800 ( full ) - 387c fefe fefe fefe - fefe fefe fe7c 3800 + 387c fefe fefe fefe + fefe fefe fe7c 3800 @bit-icns ( outline ) - 3844 8282 8244 3800 + 3844 8282 8244 3800 ( full ) - 387c fefe fe7c 3800 + 387c fefe fe7c 3800 @stack-icns &push - 0000 1028 1000 0000 + 0000 1028 1000 0000 &pop - 0000 2810 2800 0000 + 0000 2810 2800 0000 @pointer-icn 80c0 e0f0 f8e0 1000 From 2ead7840fddecd15812e217c66094c6c6d4c3e3b Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 15 Jan 2022 11:15:47 -0800 Subject: [PATCH 39/39] Launcher now assembles tal files --- projects/software/launcher.tal | 58 ++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/projects/software/launcher.tal b/projects/software/launcher.tal index 77d6ae4..9ecd0b6 100644 --- a/projects/software/launcher.tal +++ b/projects/software/launcher.tal @@ -63,6 +63,11 @@ ;on-button .Controller/vector DEO2 ;on-mouse .Mouse/vector DEO2 + ( asma debugger ) + #0d ;asma/log-level STA + + ;asma-heap ;heap STA2 + ( setup synth ) #0102 .Audio0/adsr DEO2 ;sin-pcm .Audio0/addr DEO2 @@ -252,16 +257,33 @@ RTN ;get-entry JSR2 #0005 ++ DUP2 ;check-rom JSR2 ,&valid JCN + + ( check if tal file ) + + DUP2 ;scap JSR2 #0004 -- ;&tal-ext ;scmp JSR2 #01 ! ,&no-tal JCN + DUP2 ;&output-path ;scpy JSR2 + ;&rom-ext ;&output-path ;scat JSR2 + ;&output-path ;asma-assemble-file JSR2 + ;load-dir JSR2 + ;redraw JSR2 + RTN + &no-tal + POP2 RTN &valid ;load-rom JSR2 RTN + &tal-ext ".tal $1 + &rom-ext ".rom $1 + &output-path $20 @redraw ( -- ) - ( unused ) + ( force selection ) + #ff .browser/last STZ + #00 ;select-file JSR2 RTN @@ -451,6 +473,12 @@ JMP2r JMP2r +@scat ( src* dst* -- ) + + DUP2 ,slen JSR ++ ,scpy JSR + +JMP2r + @scmp ( a* b* -- flag ) STH2 @@ -467,6 +495,17 @@ JMP2r RTN +@scpy ( src* dst* -- ) + + STH2 + &while + LDAk STH2kr STA INC2r + INC2 LDAk ,&while JCN + POP2 + #00 STH2r STA + +JMP2r + @scap ( str* -- str-end* ) ( clamp ) LDAk #00 ! JMP RTN @@ -474,6 +513,12 @@ RTN RTN +@slen ( str* -- len* ) + + DUP2 ,scap JSR SWP2 -- + +JMP2r + @pointer-icn 80c0 e0f0 f8e0 1000 @hand-icn @@ -518,4 +563,13 @@ RTN &path ". $1 &lines $1 &length $2 - &data + &data $1000 + +( assembler memory ) + +~projects/library/asma.tal + +@asma-heap +|e000 &end @asma-read-buffer +|f800 &end @asma-write-buffer +|ffff &end