commit 5a5ec67
neauoire
·
2022-04-03 17:43:13 +0000 UTC
parent 0dc0f63
Removed etc/
2 files changed,
+4,
-550
M
build.sh
M
build.sh
+4,
-2
1@@ -19,5 +19,7 @@ else
2 gcc -std=c89 -D_POSIX_C_SOURCE=199309L -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli
3 fi
4
5-echo "Running.."
6-uxnasm etc/repl.tal bin/repl.rom && bin/uxn11 bin/repl.rom
7+echo "Done."
8+
9+# echo "Running.."
10+# uxnasm etc/repl.tal bin/repl.rom && bin/uxn11 bin/repl.rom
+0,
-548
1@@ -1,548 +0,0 @@
2-( REPL )
3-
4-|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2
5-|10 @Console &vector $2 &read $1 &pad $5 &write $1
6-|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
7-|80 @Controller &vector $2 &button $1 &key $1
8-|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
9-|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
10-
11-|0000
12-
13- @input $80
14- @token $40
15- @p &ptr $2 &len $2
16- @l &ptr $2
17-
18-|0100 ( -> )
19-
20- ( theme )
21- #0f5f .System/r DEO2
22- #0fcd .System/g DEO2
23- #0fa3 .System/b DEO2
24- #15 .Screen/auto DEO
25- ( vectors )
26- ;on-button .Controller/vector DEO2
27-
28- ( load prefabs )
29- ;prefabs/play-note-txt ;add-label JSR2
30- ;prefabs/draw-line-txt ;add-label JSR2
31- ;prefabs/list-files-txt ;add-label JSR2
32- ;prefabs/load-file-txt ;add-label JSR2
33-
34- ( draw )
35- #01 ;draw-input JSR2
36- #01 ;draw-stack JSR2
37- #01 ;draw-program JSR2
38- #01 ;draw-labels JSR2
39- ;draw-status JSR2
40-
41- #010e DEO
42-
43-BRK
44-
45-@on-button ( -> )
46-
47- .Controller/key DEI
48- [ #0d ] EQUk NIP ,&validate JCN
49- [ #08 ] EQUk NIP ,&erase JCN
50- [ #20 ] LTHk NIP ,&end JCN
51- [ #7e ] GTHk NIP ,&end JCN
52- ;input ;slen JSR2 NIP #80 LTH ,&append JCN
53- &end
54- POP
55-
56-BRK
57- &append ( char -> ) #00 ;draw-input JSR2 ;input ;sput JSR2 #01 ;draw-input JSR2 BRK
58- &erase ( char -> ) #00 ;draw-input JSR2 ;input ;spop JSR2 #01 ;draw-input JSR2 BRK
59- &validate ( char -> ) #00 ;draw-input JSR2 ;input ;sput JSR2 ;input ;parse JSR2 ;input #0080 ;mclr JSR2 BRK
60-
61-@parse ( addr* -- )
62-
63- #00 ;draw-stack JSR2
64-
65- &while
66- LDAk #20 GTH ,&no-space JCN
67- ;do-token JSR2
68- ,&continue JMP
69- &no-space
70- LDAk ;token ;sput JSR2
71- &continue
72- INC2 LDAk ,&while JCN
73- POP2
74- #01 ;draw-program JSR2
75-
76- ( set return )
77- ;&end ;write-litshort JSR2 #2c ;write-byte JSR2
78- ( time to evaluate program )
79- ( borrow wst ) #ff .System/wst DEO
80- ;dst JMP2
81- &end
82- ( released wst ) #00 .System/wst DEO
83- #01 ;draw-stack JSR2
84-
85- ;dst .p/len LDZ2 #0004 ADD2 ;mclr JSR2
86- #0000 .p/len STZ2
87- #0000 .p/ptr STZ2
88-
89-JMP2r
90-
91-@do-token ( -- )
92-
93- ;token LDAk LIT '# NEQ ,&no-lithex JCN
94- DUP2 INC2 ;do-lithex JSR2 ,&end JMP
95- &no-lithex
96- DUP2 ;is-opcode JSR2 #00 EQU ,&no-opcode JCN
97- DUP2 ;find-opcode JSR2 ;write-byte JSR2
98- &no-opcode
99- &end
100- POP2
101- ;token #0040 ;mclr JSR2
102-
103-JMP2r
104-
105-@is-opcode ( string* -- flag )
106-
107- DUP2 ;opcodes/brk ,scmp3 JSR ,find-opcode/on-brk JCN
108-
109-@find-opcode ( name* -- byte )
110-
111- STH2
112- #2000
113- &loop
114- #00 OVR #03 MUL ;opcodes ADD2 STH2kr ,scmp3 JSR ,&on-found JCN
115- INC GTHk ,&loop JCN
116- POP2 POP2r #00
117-
118-JMP2r
119- &on-found NIP STH2r ,find-mode JSR ADD JMP2r
120- &on-brk POP2 #01 JMP2r
121-
122-@find-mode ( mode* -- byte )
123-
124- LITr 00
125- ;opcodes OVR2 ,scmp3 JSR #70 SFT STH ADDr
126- INC2 INC2 INC2
127- LDAk #00 EQU ,&end JCN
128- &while
129- LDAk LIT '2 EQU #50 SFT STH ADDr
130- LDAk LIT 'r EQU #60 SFT STH ADDr
131- LDAk LIT 'k EQU #70 SFT STH ADDr
132- INC2 LDAk ,&while JCN
133- &end
134- POP2 STHr
135-
136-JMP2r
137-
138-@scmp3 ( a[3]* b[3]* -- flag )
139-
140- LDA2k STH2 INC2 INC2 SWP2
141- LDA2k STH2 INC2 INC2 EQU2r
142- LDA STH LDA STH EQUr
143- ANDr STHr
144-
145-JMP2r
146-
147-@add-label ( label* -- )
148-
149- #aaaa .l/ptr LDZ2 ;labels ADD2 STA2
150-
151- .l/ptr LDZ2k INC2 INC2 ROT STZ2
152-
153- DUP2
154- .l/ptr LDZ2 ;labels ADD2 ;scpy JSR2
155- ;slen JSR2 INC2 STH2
156-
157- .l/ptr LDZ2k STH2r ADD2 ROT STZ2
158- #0a18 DEO
159-
160-JMP2r
161-
162-@do-lithex ( t* -- )
163-
164- DUP2 ;slen JSR2 #0004 EQU2 ,&on-short JCN
165- DUP2 ;slen JSR2 #0002 EQU2 ,&on-byte JCN
166-
167-;err/lithx ;print-err JMP2
168-
169- &on-short ;sshort JSR2 ;write-litshort JMP2
170- &on-byte ;sbyte JSR2 ;write-litbyte JMP2
171-
172-@write-litbyte ( byte -- )
173-
174- ( LITk ) #80 SWP ,write-short JMP
175-
176-@write-litshort ( short* -- )
177-
178- ( LIT2k ) #a0 ,write-byte JSR
179-
180-@write-short ( short -- )
181-
182- SWP ,write-byte JSR
183-
184-@write-byte ( byte -- )
185-
186- ;dst .p/ptr LDZ2 STH2k ADD2 STA
187- INC2r STH2kr .p/ptr STZ2
188- STH2r .p/len STZ2
189-
190-JMP2r
191-
192-( drawing )
193-
194-@draw-status ( -- )
195-
196- .Screen/width DEI2 #0060 SUB2 .Screen/x DEO2
197- .Screen/height DEI2 #0010 SUB2 .Screen/y DEO2
198- .l/ptr LDZ2 #01 ;draw-short JSR2
199- LIT '/ #01 ;draw-char JSR2
200- #0000 ;labels SUB2 #01 ;draw-short JSR2
201-
202-JMP2r
203-
204-@draw-labels ( color -- )
205-
206- POP
207- #0020 .Screen/x DEO2
208- #00d0 .Screen/y DEO2
209- ;symbols-txt #02 ;draw-str JSR2
210- .Screen/y DEI2k #0010 ADD2 ROT DEO2
211-
212- ;labels
213- &while
214- DUP2 INC2 INC2 #01 ;draw-str JSR2
215- .Screen/x DEI2k #0008 ADD2 ROT DEO2
216- ;scap JSR2 INC2 LDA2k #0000 NEQ2 ,&while JCN
217- POP2
218-
219-JMP2r
220-
221-@draw-input ( color -- )
222-
223- STH
224- ( flower )
225- #0010 .Screen/x DEO2
226- #0020 .Screen/y DEO2
227- ;flowers-icn #00 ;input ;slen JSR2 ADD #06 DIVk MUL SUB #50 SFT2 ADD2 .Screen/addr DEO2
228- #81 .Screen/sprite DEO
229- #00 .Screen/sprite DEO
230- ;prompt-txt #02 ;draw-str JSR2
231- ;input #01 STHkr MUL ;draw-str JSR2
232- LIT '_ #03 STHr MUL ;draw-char JSR2
233-
234-JMP2r
235-
236-@draw-stack ( color -- )
237-
238- ( highlight last item )
239- STH
240- ( position )
241- #0020 .Screen/x DEO2
242- #0050 .Screen/y DEO2
243- ;stack-txt #02 ;draw-str JSR2
244- #ffff LDA #ff00 STHr ,draw-memory JSR
245-
246-JMP2r
247-
248-@draw-program ( color -- )
249-
250- STH
251- #0020 .Screen/x DEO2
252- #0090 .Screen/y DEO2
253- ;program-txt #02 ;draw-str JSR2
254- #10 ;dst STHr ,draw-memory JSR
255-
256-JMP2r
257-
258-@draw-memory ( length addr* color -- )
259-
260- STH
261- ,&addr STR2
262- .Screen/x DEI2 ,&anchor STR2
263- #00
264- &loop
265- DUP #07 AND ,&no-lb JCN
266- [ LIT2 &anchor $2 ] .Screen/x DEO2
267- .Screen/y DEI2k #0010 ADD2 ROT DEO2
268- &no-lb
269- #00 OVR [ LIT2 &addr $2 ] ADD2 LDA #01 STHkr MUL ,draw-byte JSR
270- .Screen/x DEI2k #0008 ADD2 ROT DEO2
271- INC GTHk ,&loop JCN
272- POP2
273- POPr
274-
275-JMP2r
276-
277-@draw-short ( short* color -- )
278-
279- STH SWP STHkr ,draw-byte JSR STHr
280-
281-@draw-byte ( byte color -- )
282-
283- STH DUP #04 SFT STHkr ,draw-hex JSR #0f AND STHr
284-
285-@draw-hex ( char color -- )
286-
287- SWP #0f AND [ DUP #09 GTH #07 MUL ADD #30 ADD ] SWP
288-
289-@draw-char ( char color -- )
290-
291- SWP #20 SUB #00 SWP #40 SFT2 ;font ADD2 .Screen/addr DEO2
292- .Screen/sprite DEO
293-
294-JMP2r
295-
296-@draw-str ( text* color -- )
297-
298- STH
299- &while
300- LDAk STHkr ,draw-char JSR
301- INC2 LDAk ,&while JCN
302- POP2
303- POPr
304-
305-JMP2r
306-
307-( utils )
308-
309-@slen ( str* -- len* )
310-
311- DUP2 ,scap JSR SWP2 SUB2
312-
313-JMP2r
314-
315-@scap ( str* -- end* )
316-
317- LDAk #00 NEQ JMP JMP2r
318- &while INC2 LDAk ,&while JCN
319-
320-JMP2r
321-
322-@sput ( char str* -- )
323-
324- ,scap JSR STA
325-
326-JMP2r
327-
328-@spop ( str* -- )
329-
330- LDAk ,&no-null JCN
331- POP2 JMP2r &no-null
332- #00 ROT ROT ,scap JSR #0001 SUB2 STA
333-
334-JMP2r
335-
336-@scat ( src* dst* -- )
337-
338- DUP2 ,slen JSR ADD2
339-
340-@scpy ( src* dst* -- )
341-
342- STH2
343- &while
344- LDAk STH2kr STA INC2r
345- INC2 LDAk ,&while JCN
346- POP2
347- #00 STH2r STA
348-
349-JMP2r
350-
351-@chex ( char -- value )
352-
353- DUP #2f GTH OVR #3a LTH AND ,&number JCN
354- DUP #60 GTH OVR #67 LTH AND ,&lc JCN
355- POP #00
356-
357-JMP2r
358- &number #30 SUB JMP2r
359- &lc #57 SUB JMP2r
360-
361-@mclr ( addr* len* -- )
362-
363- OVR2 ADD2 SWP2
364- &loop
365- STH2k #00 STH2r STA
366- INC2 GTH2k ,&loop JCN
367- POP2 POP2
368-
369-JMP2r
370-
371-@print ( short* -- )
372-
373- &short ( short* -- ) SWP ,&byte JSR
374- &byte ( byte -- ) DUP #04 SFT ,&char JSR
375- &char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
376-
377-JMP2r
378-
379-@sshort ( str* -- short* )
380-
381- INC2k INC2 ,sbyte JSR STH
382- ,sbyte JSR STHr
383-
384-JMP2r
385-
386-@sbyte ( str* -- byte )
387-
388- LDAk ,chex JSR STH
389- INC2 LDA ,chex JSR
390- STHr #40 SFT ADD
391-
392-JMP2r
393-
394-@print-err ( token* err* -- )
395-
396- LIT '! .Console/write DEO
397- SWP2 ,print-str JSR #2018 DEO
398-
399-@print-str ( str* -- )
400-
401- &while
402- LDAk #18 DEO
403- INC2 LDAk ,&while JCN
404- POP2
405-
406-JMP2r
407-
408-( assets )
409-
410-@prompt-txt "Do 20 $1
411-@stack-txt "Stack 20 $1
412-@program-txt "Program 20 $1
413-@symbols-txt "Symbols 20 $1
414-
415-@opcodes
416- "LIT "INC "POP "DUP "NIP "SWP "OVR "ROT
417- "EQU "NEQ "GTH "LTH "JMP "JCN "JSR "STH
418- "LDZ "STZ "LDR "STR "LDA "STA "DEI "DEO
419- "ADD "SUB "MUL "DIV "AND "ORA "EOR "SFT
420- &brk "BRK
421-
422-@err
423- &lithx "LITHX $1 &label "LABEL $1 &token "TOKEN $1 &reslv "RESLV $1
424-
425-( prefabs )
426-
427-@prefabs
428- &play-note-txt "play-note $1
429- &draw-line-txt "draw-line $1
430- &list-files-txt "list-files $1
431- &load-file-txt "load-file $1
432-
433-@flowers-icn ( by elioat )
434- 0000 0020 1408 0810 40a0 4205 0200 40a0
435- 0810 103c 7e7e 3c18 4205 0234 7e7e 3c18
436- 0000 0020 100c 0818 0040 a042 0522 5024
437- 0008 083c 7e7e 3c18 0a04 002c 7e7e 3c18
438- 0000 0000 0000 000c 0000 0000 0000 0000
439- 1c10 083c 7e7e 3c18 0000 002c 7e7e 3c18
440- 0000 0000 0000 0004 0000 0000 0002 0502
441- 0810 103c 7e7e 3c18 0000 0034 7e7e 3c18
442- 0000 0000 0000 0010 0000 0000 0020 5225
443- 080c 083c 7e7e 3c18 0200 002c 7e7e 3c18
444- 0000 0000 0800 1800 0000 040a 2450 240a
445- 1010 103c 7e7e 3c18 0400 0034 7e7e 3c18
446-
447-@font ( msx816 )
448- 0000 0000 0000 0000 0000 0000 0000 0000
449- 0000 0020 2020 2020 2020 0000 2020 0000
450- 0000 006c 6c24 4800 0000 0000 0000 0000
451- 0000 0044 44fe 4444 4444 44fe 4444 0000
452- 0000 1010 7c92 9290 7c12 9292 7c10 1000
453- 0000 0040 a0a2 4408 1020 448a 0a04 0000
454- 0000 0070 8888 8850 2050 8a84 8c72 0000
455- 0000 0030 3010 2000 0000 0000 0000 0000
456- 0000 0004 0808 1010 1010 1008 0804 0000
457- 0000 0040 2020 1010 1010 1020 2040 0000
458- 0000 0000 0000 1054 3854 1000 0000 0000
459- 0000 0000 0010 1010 fe10 1010 0000 0000
460- 0000 0000 0000 0000 0000 0030 3010 2000
461- 0000 0000 0000 0000 fe00 0000 0000 0000
462- 0000 0000 0000 0000 0000 0000 3030 0000
463- 0000 0004 0404 0808 0810 1010 2020 0000
464- ( numbers )
465- 0000 0038 4482 8292 9292 8282 4438 0000
466- 0000 0010 3050 1010 1010 1010 1038 0000
467- 0000 0038 4482 8202 0c30 4080 80fe 0000
468- 0000 0038 4482 0204 3804 0282 4438 0000
469- 0000 0004 0c14 1424 2444 44fe 0404 0000
470- 0000 00fc 8080 80b8 c402 0282 4438 0000
471- 0000 0038 4482 80b8 c482 8282 4438 0000
472- 0000 00fe 8284 0808 1010 1010 1010 0000
473- 0000 0038 4482 8244 3844 8282 4438 0000
474- 0000 0038 4482 8282 463a 0282 4438 0000
475- 0000 0000 0000 3030 0000 0030 3000 0000
476- 0000 0000 0000 3030 0000 0030 3010 2000
477- 0000 0000 0408 1020 4020 1008 0400 0000
478- 0000 0000 0000 00fe 0000 fe00 0000 0000
479- 0000 0000 4020 1008 0408 1020 4000 0000
480- 0000 0038 4482 8202 0c10 1000 1010 0000
481- 0000 0038 4482 0262 9292 9292 926c 0000
482- 0000 0010 2844 8282 8282 fe82 8282 0000
483- 0000 00f8 8482 8284 f884 8282 84f8 0000
484- 0000 0038 4482 8080 8080 8082 4438 0000
485- 0000 00f8 4442 4242 4242 4242 44f8 0000
486- 0000 00fe 8080 8080 fc80 8080 80fe 0000
487- 0000 00fe 8080 8080 fc80 8080 8080 0000
488- 0000 0038 4482 8080 8e82 8282 463a 0000
489- 0000 0082 8282 8282 fe82 8282 8282 0000
490- 0000 0038 1010 1010 1010 1010 1038 0000
491- 0000 000e 0404 0404 0404 0484 8870 0000
492- 0000 0082 8488 90a0 c0a0 9088 8482 0000
493- 0000 0040 4040 4040 4040 4040 407e 0000
494- 0000 0082 c6aa 9292 8282 8282 8282 0000
495- 0000 0082 c2a2 a292 928a 8a86 8282 0000
496- 0000 0038 4482 8282 8282 8282 4438 0000
497- 0000 00f8 8482 8282 84f8 8080 8080 0000
498- 0000 0038 4482 8282 8282 bac6 443a 0000
499- 0000 00f8 8482 8284 f890 8884 8482 0000
500- 0000 0038 4482 8040 3804 0282 4438 0000
501- 0000 00fe 1010 1010 1010 1010 1010 0000
502- 0000 0082 8282 8282 8282 8282 827c 0000
503- 0000 0082 8282 8282 8282 8244 2810 0000
504- 0000 0082 8282 8282 9292 aaaa 4444 0000
505- 0000 0082 8282 4428 1028 4482 8282 0000
506- 0000 0082 8282 4428 1010 1010 1010 0000
507- 0000 00fe 0202 0408 1020 4080 80fe 0000
508- 0000 001c 1010 1010 1010 1010 101c 0000
509- 0000 0082 4428 10fe 1010 fe10 1010 0000
510- 0000 0070 1010 1010 1010 1010 1070 0000
511- 0000 0010 2844 8200 0000 0000 0000 0000
512- 0000 0000 0000 0000 0000 0000 00fe 0000
513- 0000 0060 6020 1000 0000 0000 0000 0000
514- 0000 0000 0000 7884 047c 8484 8c74 0000
515- 0000 0040 4040 5864 4242 4242 6458 0000
516- 0000 0000 0000 3844 8280 8082 4438 0000
517- 0000 0004 0404 344c 8484 8484 4c34 0000
518- 0000 0000 0000 3844 82fe 8082 4438 0000
519- 0000 0018 2420 7820 2020 2020 2020 0000
520- 0000 0000 0000 3a46 8282 8246 3a82 4438
521- 0000 0040 4040 5864 4242 4242 4242 0000
522- 0000 0010 1000 0010 1010 1010 1010 0000
523- 0000 0008 0800 0008 0808 0808 0808 4830
524- 0000 0040 4040 4244 4850 7048 4442 0000
525- 0000 0030 1010 1010 1010 1010 1010 0000
526- 0000 0000 0000 ec92 9292 9292 9292 0000
527- 0000 0000 0000 5c62 4242 4242 4242 0000
528- 0000 0000 0000 3844 8282 8282 4438 0000
529- 0000 0000 0000 5864 4242 4242 6458 4040
530- 0000 0000 0000 344c 8484 8484 4c34 0404
531- 0000 0000 0000 5864 4040 4040 4040 0000
532- 0000 0000 0000 7c82 807c 0202 827c 0000
533- 0000 0020 2020 f820 2020 2020 2418 0000
534- 0000 0000 0000 8484 8484 8484 8c74 0000
535- 0000 0000 0000 8282 4444 2828 1010 0000
536- 0000 0000 0000 8282 8292 92aa 4444 0000
537- 0000 0000 0000 8244 2810 1028 4482 0000
538- 0000 0000 0000 4242 4242 4222 1408 1060
539- 0000 0000 0000 fe04 0810 2040 80fe 0000
540- 0000 000c 1010 1010 2010 1010 100c 0000
541- 0000 1010 1010 0000 0000 1010 1010 0000
542- 0000 0060 1010 1010 0810 1010 1060 0000
543- 0000 0060 920c 0000 0000 0000 0000 0000
544-
545-@dst $1000
546-
547-( addr* label[length] )
548-
549-@labels