commit d40f67d
Devie Lu Linvega
·
2025-12-14 01:40:20 +0000 UTC
parent 21a0eb9
Removed unused files
5 files changed,
+0,
-466
+0,
-83
1@@ -1,83 +0,0 @@
2-( usage: uxncli console.rom foo "bar baz"
3-| Prints Welcome to Uxn!, and listens for incoming stdin events on enter. )
4-
5-|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
6-
7-|000
8-
9- @arg $40
10- @std $40
11-
12-|100
13-
14-@on-reset ( -> )
15- ;Dict/hello <print-str>
16- .Console/type DEI ?{
17- ( | no arguments )
18- ;on-std .Console/vector DEO2
19- BRK }
20- ;on-arg .Console/vector DEO2
21- BRK
22-
23-@on-arg ( -> )
24- [ LIT2 02 -Console/type ] DEI NEQ ?{
25- .Console/read DEI [ LIT2 00 &ptr -arg ] INCk ,&ptr STR
26- STZ2
27- BRK }
28- ;arg ;Dict/yousent <print-result>
29- [ LIT2 -arg _&ptr ] STR
30- [ LIT2 04 -Console/type ] DEI NEQ ?{ ;on-std .Console/vector DEO2 }
31- BRK
32-
33-@on-std ( -> )
34- [ LIT2 0a -Console/read ] DEI EQU ?{
35- .Console/read DEI [ LIT2 00 &ptr -std ] INCk ,&ptr STR
36- STZ2
37- BRK }
38- ;std DUP2 ;Dict/yousaid <print-result>
39- ;Dict/quit scmp ?{
40- [ LIT2 -std _&ptr ] STR
41- BRK }
42- ( quit ) #800f DEO
43- BRK
44-
45-@<print-result> ( buf* name* -- )
46- <print-str>
47- [ LIT2 "" 18 ] DEO
48- <print-str>/
49- [ LIT2 "" 18 ] DEO
50- [ LIT2 00 -Console/type ] DEI DUP ADD ;Types ADD2 LDA2 <print-str>/
51- #0a18 DEO
52- JMP2r
53-
54-@<print-str> ( str* -- )
55- LDAk #18 DEO
56- INC2 & LDAk ?<print-str>
57- POP2 JMP2r
58-
59-@scmp ( a* b* -- f )
60- STH2
61- &l ( a* b* -- f )
62- LDAk LDAkr STHr NEQk ?&d
63- DUP EOR EQUk ?&d
64- POP2 INC2 INC2r !&l
65-
66- &d ( a* c1 c2 b* -- f )
67- NIP2 POP2r EQU JMP2r
68-
69-(
70-@|assets )
71-
72-@Types =Dict/arg-none =Dict/arg-stdin =Dict/arg-data =Dict/arg-spacer =Dict/arg-end
73-
74-@Dict
75- &hello "Welcome 20 "to 20 "Uxn! 0a $1
76- &yousaid "You 20 "said: 20 $1
77- &yousent "You 20 "sent: 20 $1
78- &quit "quit $1
79- &arg-none "<none> $1
80- &arg-stdin "<stdin> $1
81- &arg-data "<data> $1
82- &arg-spacer "<spacer> $1
83- &arg-end "<end> $1
84-
+0,
-101
1@@ -1,101 +0,0 @@
2-#include "uxn.h"
3-#include <stdio.h>
4-
5-/*
6-Copyright (u) 2022-2023 Devine Lu Linvega, Andrew Alderwick, Andrew Richards
7-
8-Permission to use, copy, modify, and distribute this software for any
9-purpose with or without fee is hereby granted, provided that the above
10-copyright notice and this permission notice appear in all copies.
11-
12-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13-WITH REGARD TO THIS SOFTWARE.
14-*/
15-
16-/* a,b,c: general use. m2: byte/short mode flag.
17- tsp: macro temp stack ptr. ksp: "keep" mode copy of stack ptr. sp: ptr to stack ptr.
18- x,y: macro in params. o: macro out param. */
19-
20-#define HALT(c) { return uxn_halt(u, instr, (c), pc - 1); }
21-#define JUMP(x) { if(m2) pc = (x); else pc += (Sint8)(x); }
22-#define PUSH8(x) { if(s->ptr == 0xff) HALT(2) s->dat[s->ptr++] = (x); }
23-#define PUSH16(x) { if((tsp = s->ptr) >= 0xfe) HALT(2) t = (x); s->dat[tsp] = t >> 8; s->dat[tsp + 1] = t; s->ptr = tsp + 2; }
24-#define PUSH(x) { if(m2) { PUSH16(x) } else { PUSH8(x) } }
25-#define POP8(o) { if(*sp == 0x00) HALT(1) o = s->dat[--*sp]; }
26-#define POP16(o) { if((tsp = *sp) <= 0x01) HALT(1) o = s->dat[tsp - 1] | (s->dat[tsp - 2] << 8); *sp = tsp - 2; }
27-#define POP(o) { if(m2) { POP16(o) } else { POP8(o) } }
28-#define POKE(x, y) { if(m2) { t = (y); u->ram[(x)] = t >> 8; u->ram[(x) + 1] = t; } else { u->ram[(x)] = (y); } }
29-#define PEEK16(o, x) { o = (u->ram[(x)] << 8) | u->ram[(x) + 1]; }
30-#define PEEK(o, x) { if(m2) PEEK16(o, x) else o = u->ram[(x)]; }
31-#define DEO(a, b) { u->dev[(a)] = (b); if((deo_mask[(a) >> 4] >> ((a) & 0xf)) & 0x1) uxn_deo(u, (a)); }
32-#define DEI(a, b) { a = ((dei_mask[(b) >> 4] >> ((b) & 0xf)) & 0x1) ? uxn_dei(u, (b)) : u->dev[(b)]; }
33-
34-int
35-uxn_eval(Uxn *u, Uint16 pc)
36-{
37- Uint8 instr, opcode, m2, ksp, tsp, *sp;
38- Uint16 a, b, c, t;
39- Stack *s;
40- if(!pc || u->dev[0x0f]) return 0;
41- for(;;) {
42- instr = u->ram[pc++];
43- opcode = instr & 0x1f;
44- /* 2 Mode */ m2 = instr & 0x20;
45- /* r Mode */ s = instr & 0x40 ? &u->rst : &u->wst;
46- /* k Mode */ if(instr & 0x80) { ksp = s->ptr; sp = &ksp; } else sp = &s->ptr;
47- switch(opcode - (!opcode * (instr >> 5))) {
48- /* Immediate */
49- case -0x0: /* BRK */ return 1;
50- case -0x1: /* JCI */ POP8(b) if(!b) { pc += 2; break; } /* fall through */
51- case -0x2: /* JMI */ PEEK16(a, pc) pc += a + 2; break;
52- case -0x3: /* JSI */ s = &u->rst; PUSH16(pc + 2) PEEK16(a, pc) pc += a + 2; break;
53- case -0x4: /* LIT */
54- case -0x6: /* LITr */ a = u->ram[pc++]; PUSH8(a) break;
55- case -0x5: /* LIT2 */
56- case -0x7: /* LIT2r */ PEEK16(a, pc) PUSH16(a) pc += 2; break;
57- /* ALU */
58- case 0x01: /* INC */ POP(a) PUSH(a + 1) break;
59- case 0x02: /* POP */ POP(a) break;
60- case 0x03: /* NIP */ POP(a) POP(b) PUSH(a) break;
61- case 0x04: /* SWP */ POP(a) POP(b) PUSH(a) PUSH(b) break;
62- case 0x05: /* ROT */ POP(a) POP(b) POP(c) PUSH(b) PUSH(a) PUSH(c) break;
63- case 0x06: /* DUP */ POP(a) PUSH(a) PUSH(a) break;
64- case 0x07: /* OVR */ POP(a) POP(b) PUSH(b) PUSH(a) PUSH(b) break;
65- case 0x08: /* EQU */ POP(a) POP(b) PUSH8(b == a) break;
66- case 0x09: /* NEQ */ POP(a) POP(b) PUSH8(b != a) break;
67- case 0x0a: /* GTH */ POP(a) POP(b) PUSH8(b > a) break;
68- case 0x0b: /* LTH */ POP(a) POP(b) PUSH8(b < a) break;
69- case 0x0c: /* JMP */ POP(a) JUMP(a) break;
70- case 0x0d: /* JCN */ POP(a) POP8(b) if(b) JUMP(a) break;
71- case 0x0e: /* JSR */ POP(a) s = (instr & 0x40) ? &u->wst : &u->rst; PUSH16(pc) JUMP(a) break;
72- case 0x0f: /* STH */ POP(a) s = (instr & 0x40) ? &u->wst : &u->rst; PUSH(a) break;
73- case 0x10: /* LDZ */ POP8(a) PEEK(b, a) PUSH(b) break;
74- case 0x11: /* STZ */ POP8(a) POP(b) POKE(a, b) break;
75- case 0x12: /* LDR */ POP8(a) PEEK(b, pc + (Sint8)a) PUSH(b) break;
76- case 0x13: /* STR */ POP8(a) POP(b) POKE(pc + (Sint8)a, b) break;
77- case 0x14: /* LDA */ POP16(a) PEEK(b, a) PUSH(b) break;
78- case 0x15: /* STA */ POP16(a) POP(b) POKE(a, b) break;
79- case 0x16: /* DEI */ POP8(a) if(m2){ DEI(b, a) DEI(c, a + 1) PUSH16((b << 8) | c) } else { DEI(b, a) PUSH8(b) } break;
80- case 0x17: /* DEO */ POP8(a) if(m2){ POP(b) DEO(a, b >> 8) DEO(a + 1, b) } else { POP8(b) DEO(a, b) } break;
81- case 0x18: /* ADD */ POP(a) POP(b) PUSH(b + a) break;
82- case 0x19: /* SUB */ POP(a) POP(b) PUSH(b - a) break;
83- case 0x1a: /* MUL */ POP(a) POP(b) PUSH((Uint32)b * a) break;
84- case 0x1b: /* DIV */ POP(a) POP(b) if(!a) HALT(3) PUSH(b / a) break;
85- case 0x1c: /* AND */ POP(a) POP(b) PUSH(b & a) break;
86- case 0x1d: /* ORA */ POP(a) POP(b) PUSH(b | a) break;
87- case 0x1e: /* EOR */ POP(a) POP(b) PUSH(b ^ a) break;
88- case 0x1f: /* SFT */ POP8(a) POP(b) PUSH(b >> (a & 0x0f) << ((a & 0xf0) >> 4)) break;
89- }
90- }
91-}
92-
93-int
94-uxn_boot(Uxn *u, Uint8 *ram)
95-{
96- Uint32 i;
97- char *cptr = (char *)u;
98- for(i = 0; i < sizeof(*u); i++)
99- cptr[i] = 0;
100- u->ram = ram;
101- return 1;
102-}
+0,
-49
1@@ -1,49 +0,0 @@
2-/*
3-Copyright (c) 2021 Devine Lu Linvega
4-
5-Permission to use, copy, modify, and distribute this software for any
6-purpose with or without fee is hereby granted, provided that the above
7-copyright notice and this permission notice appear in all copies.
8-
9-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10-WITH REGARD TO THIS SOFTWARE.
11-*/
12-
13-#define PAGE_PROGRAM 0x0100
14-
15-/* clang-format off */
16-
17-#define POKE2(d, v) { (d)[0] = (v) >> 8; (d)[1] = (v); }
18-#define PEEK2(d) ((d)[0] << 8 | (d)[1])
19-
20-/* clang-format on */
21-
22-typedef unsigned char Uint8;
23-typedef signed char Sint8;
24-typedef unsigned short Uint16;
25-typedef signed short Sint16;
26-typedef unsigned int Uint32;
27-
28-typedef struct {
29- Uint8 dat[255], ptr;
30-} Stack;
31-
32-typedef struct Uxn {
33- Uint8 *ram, dev[256];
34- Stack wst, rst;
35- Uint8 (*dei)(struct Uxn *u, Uint8 addr);
36- void (*deo)(struct Uxn *u, Uint8 addr);
37-} Uxn;
38-
39-/* required functions */
40-
41-extern Uint8 uxn_dei(Uxn *u, Uint8 addr);
42-extern void uxn_deo(Uxn *u, Uint8 addr);
43-extern int uxn_halt(Uxn *u, Uint8 instr, Uint8 err, Uint16 addr);
44-extern Uint16 dei_mask[];
45-extern Uint16 deo_mask[];
46-
47-/* built-ins */
48-
49-int uxn_boot(Uxn *u, Uint8 *ram);
50-int uxn_eval(Uxn *u, Uint16 pc);
+0,
-33
1@@ -1,33 +0,0 @@
2-|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &exit $1
3-|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
4-|80 @Controller &vector $2 &button $1 &key $1
5-
6-|0100
7- ;on-controller .Controller/vector DEO2
8- BRK
9-
10-@on-controller ( -> BRK )
11- .Controller/button DEI
12- DUP #07 SFT #30 ADD .Console/write DEO
13- DUP #06 SFT #01 AND #30 ADD .Console/write DEO
14- DUP #05 SFT #01 AND #30 ADD .Console/write DEO
15- DUP #04 SFT #01 AND #30 ADD .Console/write DEO
16- #20 .Console/write DEO
17- DUP #03 SFT #01 AND #30 ADD .Console/write DEO
18- DUP #02 SFT #01 AND #30 ADD .Console/write DEO
19- DUP #01 SFT #01 AND #30 ADD .Console/write DEO
20- #01 AND #30 ADD .Console/write DEO
21- #20 .Console/write DEO
22- .Controller/key DEI
23- DUP emit-byte
24- #20 .Console/write DEO
25- #27 .Console/write DEO
26- .Console/write DEO
27- #27 .Console/write DEO
28- #0a .Console/write DEO
29-
30- .Controller/key DEI LIT "q NEQ ?{ #80 .System/exit DEO }
31- BRK
32-
33-@emit-byte DUP #04 SFT ,&hex JSR #0f AND !&hex
34-&hex #30 ADD DUP #39 GTH #27 MUL ADD #18 DEO JMP2r
+0,
-200
1@@ -1,200 +0,0 @@
2-( Mouse: Paint with 3 colors with each mouse button. )
3-
4-|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
5-|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
6-|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &modx $2 &mody $2
7-
8-|000
9-
10- @line &x2 $2 &y2 $2
11- @length $2
12- @frame $2
13- @pen &x $2 &y $2 &x2 $2 &y2 $2
14- @pointer &x $2 &y $2 &lastx $2 &lasty $2 &state $1
15-
16-|100
17-
18-@on-reset ( -> )
19- ;meta #06 DEO2
20- #0200 .Screen/height DEO2
21- ( theme )
22- #f0a8 .System/r DEO2
23- #f04f .System/g DEO2
24- #f0c2 .System/b DEO2
25- ( vectors ) ;on-mouse .Mouse/vector DEO2
26- ;on-frame .Screen/vector DEO2
27- <draw-mouse>
28- BRK
29-
30-@meta 00
31- &body ( name )
32- "Noodle 0a
33- ( details ) "A 20 "Drawing 20 "Program 0a
34- ( author ) "By 20 "Hundred 20 "Rabbits 0a
35- ( date ) "4 20 "Apr 20 "2025 00 02
36- ( icon ) 83 =appicon
37- ( mask ) 41 1705
38-
39-(
40-@|vectors )
41-
42-@on-frame ( -> )
43- .Mouse/state DEI ?{ ;run DUP2 JSR2 JSR2 }
44- BRK
45-
46-@on-mouse ( -> )
47- ( | clear last cursor )
48- .pointer/x LDZ2 .Screen/x DEO2
49- .pointer/y LDZ2 .Screen/y DEO2
50- ;fill-icn .Screen/addr DEO2
51- [ LIT2 40 -Screen/sprite ] DEO
52- <draw-mouse>
53- ( | draw new cursor )
54- ;pointer-icn .Screen/addr DEO2
55- #00 .Screen/auto DEO
56- .Mouse/x DEI2 DUP2 .pointer/x STZ2
57- .Screen/x DEO2
58- .Mouse/y DEI2 DUP2 .pointer/y STZ2
59- .Screen/y DEO2
60- #45 .Mouse/state DEI #00 NEQ #05 MUL ADD .Screen/sprite DEO
61- ( on down ) .Mouse/state DEI #00 NEQ .pointer/state LDZ #00 EQU AND ?on-mouse-down
62- ( on drag ) .Mouse/state DEI ?on-mouse-drag
63- .Mouse/state DEI .pointer/state STZ
64- BRK
65-
66-@on-mouse-down ( -> )
67- #0000 DUP2 .length STZ2
68- .frame STZ2
69- <clear-screen>
70- ( record start position ) .Mouse/x DEI2 DUP2 .pointer/x STZ2
71- .pointer/lastx STZ2
72- .Mouse/y DEI2 DUP2 .pointer/y STZ2
73- .pointer/lasty STZ2
74- .Mouse/state DEI .pointer/state STZ
75- BRK
76-
77-@on-mouse-drag ( -> )
78- ( record ) ;stroke .length LDZ2 #20 SFT2 ADD2 STH2
79- .pointer/x LDZ2 .pointer/lastx LDZ2 SUB2 STH2kr STA2
80- .pointer/y LDZ2 .pointer/lasty LDZ2 SUB2 STH2r INC2 INC2 STA2
81- ( move ptr ) .length LDZ2 INC2 .length STZ2
82- ( draw line ) .pointer/lastx LDZ2 .pointer/lasty LDZ2 .pointer/x LDZ2 .pointer/y LDZ2 #0a <draw-line>
83- ( record last position ) .Mouse/x DEI2 DUP2 .pointer/lastx STZ2
84- DUP2 .pen/x STZ2
85- .pen/x2 STZ2
86- .Mouse/y DEI2 DUP2 .pointer/lasty STZ2
87- DUP2 .pen/y STZ2
88- .pen/y2 STZ2
89- .Mouse/state DEI DUP #01 NEQ INC ;run/color STA
90- .pointer/state STZ
91- BRK
92-
93-(
94-@|main )
95-
96-@run ( -- )
97- ( read ) ;stroke .frame LDZ2 #20 SFT2 ADD2 STH2
98- .pen/x LDZ2 STH2kr LDA2 ADD2 .pen/x STZ2
99- .pen/y LDZ2 STH2r INC2 INC2 LDA2 ADD2 .pen/y STZ2
100- ( line ) .pen/x LDZ2 .pen/y LDZ2 .pen/x2 LDZ2 .pen/y2 LDZ2 .frame LDZ2 #01 SFT2 NIP #01 AND [ LIT &color $1 ] ADD INC #05 MUL <draw-line>
101- ( history ) .pen/x LDZ2 .pen/x2 STZ2
102- .pen/y LDZ2 .pen/y2 STZ2
103- ( incr frame ) .frame LDZ2 INC2 .length LDZ2 INC2
104- ( mod2 ) DIV2k MUL2 SUB2 .frame STZ2
105- JMP2r
106-
107-@<draw-mouse> ( -- )
108- ( clear ) #0010 DUP2 .Screen/x DEO2
109- .Screen/y DEO2
110- [ LIT2 16 -Screen/auto ] DEO
111- ;fill-icn .Screen/addr DEO2
112- [ LIT2 40 -Screen/sprite ] DEOk DEO
113- ( buttons ) #0300
114- &>l ( -- )
115- #01 OVR #40 SFT SFT .Mouse/state DEI AND #00 EQU ?{
116- #0010 .Screen/y DEO2
117- #00 OVR #40 SFT2 ;button-icn ADD2 .Screen/addr DEO2
118- [ LIT2 45 -Screen/sprite ] DEO }
119- INC GTHk ?&>l
120- POP2
121- ( outline ) #0010 .Screen/y DEO2
122- ;mouse-icn .Screen/addr DEO2
123- [ LIT2 16 -Screen/auto ] DEO
124- [ LIT2 4a -Screen/sprite ] DEOk DEO
125- JMP2r
126-
127-%abs2 {
128- DUP2 #0f SFT2 EQU #05 JCN
129- #0000 SWP2 SUB2 }
130-
131-%lts2 {
132- #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 }
133-
134-%gts2 {
135- #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 }
136-
137-@<draw-line> ( x1* y1* x2* y2* color -- )
138- ( load ) STH
139- [ LITr -Screen/sprite ] ;&y STA2
140- ;&x STA2
141- .line/y2 STZ2
142- .line/x2 STZ2
143- ;circle-icn .Screen/addr DEO2
144- ,&x LDR2 .line/x2 LDZ2 SUB2 abs2 ,&dx STR2
145- #0000 ,&y LDR2 .line/y2 LDZ2 SUB2 abs2 SUB2 ,&dy STR2
146- #ffff #00 .line/x2 LDZ2 ,&x LDR2 lts2 DUP2 ADD2 ADD2 ,&sx STR2
147- #ffff #00 .line/y2 LDZ2 ,&y LDR2 lts2 DUP2 ADD2 ADD2 ,&sy STR2
148- [ LIT2 &dx $2 ] [ LIT2 &dy $2 ] ADD2 ,&e1 STR2
149- &>l ( -- )
150- .line/x2 LDZ2 DUP2 .Screen/x DEO2
151- [ LIT2 &x $2 ] EQU2 .line/y2 LDZ2 DUP2 .Screen/y DEO2
152- [ LIT2 &y $2 ] EQU2 DEOkr
153- AND ?&end
154- [ LIT2 &e1 $2 ] DUP2 ADD2 DUP2 ,&dy LDR2 lts2 ?&skipy
155- ,&e1 LDR2 ,&dy LDR2 ADD2 ,&e1 STR2
156- .line/x2 LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x2 STZ2
157- &skipy ( -- )
158- ,&dx LDR2 gts2 ?&skipx
159- ,&e1 LDR2 ,&dx LDR2 ADD2 ,&e1 STR2
160- .line/y2 LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y2 STZ2
161- &skipx ( -- )
162- !&>l
163- &end POP2r JMP2r
164-
165-@<clear-screen> ( -- )
166- #0000 DUP2 .Screen/x DEO2
167- .Screen/y DEO2
168- [ LIT2 80 -Screen/pixel ] DEO
169- JMP2r
170-
171-@fill-icn [ ffff ffff ffff ffff ]
172-
173-@pointer-icn [ 80c0 e0f0 f8e0 1000 ]
174-
175-@circle-icn [ 187e 7eff ff7e 7e18 ]
176-
177-@mouse-icn [
178- 000d 1212 1212 121d 00b0 4848 4848 48b8
179- 1010 1010 1008 0700 0808 0808 0810 e000 ]
180-
181-@button-icn [
182- 000c 1e1e 1e1e 1e0c 0000 0000 0000 0000
183- 0001 0303 0303 0301 0080 c0c0 c0c0 c080
184- 0000 0000 0000 0000 0030 7878 7878 7830 ]
185-
186-@appicon [
187- 0000 0000 0000 0000 0000 0000 0000 0001
188- 0000 0000 0000 78fc 0c1e 1e07 037b 8503
189- 0000 0000 0000 0078 0000 0000 0000 7884
190- 0101 0303 0303 0303 0202 0404 0404 0707
191- feff fff9 f6e9 c9e6 0100 0006 0f1f 3fff
192- fcfc fefe fe7e 3e7c 0202 0101 0181 c3fe
193- 0301 0100 0000 0000 0703 0301 0000 0000
194- f9ff ffff 7f37 0500 ffff ffff ff7f 3f07
195- fcf8 f8f0 e0c0 0000 fefc fcf8 f0e0 c000 ]
196-
197-(
198-@|memory )
199-
200-@stroke
201-