uxn-utils/cli/hx/hx.tal

97 lines
1.5 KiB
Tal
Raw Normal View History

2023-06-20 00:26:57 -04:00
( uxncli hx.rom file.bin )
2023-03-17 13:28:04 -04:00
2023-06-04 11:42:43 -04:00
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
2023-03-17 13:28:04 -04:00
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@src $40
2023-06-17 14:48:46 -04:00
|0100
2023-03-17 13:28:04 -04:00
2023-06-17 14:48:46 -04:00
@on-reset ( -> )
2023-08-06 12:39:40 -04:00
.Console/type DEI ?{
;Dict/usage <perr>/
2023-06-20 00:26:57 -04:00
#010f DEO
2023-08-06 12:39:40 -04:00
BRK }
2023-06-20 00:26:57 -04:00
;await-src .Console/vector DEO2
2023-06-17 14:48:46 -04:00
BRK
2023-03-17 13:28:04 -04:00
@await-src ( -> )
.Console/read DEI .src skey ?on-ready
2023-06-17 14:48:46 -04:00
BRK
2023-03-17 13:28:04 -04:00
@on-ready ( -> )
;src .File/name DEO2
2023-06-04 11:42:43 -04:00
#0001 .File/length DEO2
2023-08-06 12:39:40 -04:00
#0a19 DEO
#0000
2023-06-17 14:48:46 -04:00
&stream ( -- )
2023-06-04 11:42:43 -04:00
;&b .File/read DEO2
2023-03-17 13:28:04 -04:00
.File/success DEI2 #0000 EQU2 ?&eof
2023-06-17 14:48:46 -04:00
[ LIT &b $1 ] <phex>/b
2023-08-06 12:39:40 -04:00
INC2 DUP <print-spacer>
2023-06-17 14:48:46 -04:00
!&stream
&eof ( id -- )
2023-08-06 12:39:40 -04:00
#0a19 DEOk DEO
<pdec>
;Dict/bytes <perr>
;src <perr>
#0a19 DEO
2023-06-17 14:48:46 -04:00
#800f DEO
BRK
@<print-spacer> ( id -- )
2023-08-06 12:39:40 -04:00
DUP #0f AND ?{
2023-06-20 00:26:57 -04:00
POP #0a18 DEO
2023-08-06 12:39:40 -04:00
JMP2r }
#01 AND ?{ #2018 DEO }
2023-06-17 14:48:46 -04:00
JMP2r
2023-06-04 11:42:43 -04:00
(
@|stdlib )
@skey ( key buf -- proc )
2023-08-06 12:39:40 -04:00
OVR #21 LTH ?{
#00 SWP sput #00 JMP2r }
POP2 #01 JMP2r
2023-06-17 14:48:46 -04:00
2023-06-04 11:42:43 -04:00
@scap ( str* -- end* )
2023-06-17 14:48:46 -04:00
&w ( -- )
2023-08-06 12:39:40 -04:00
INC2 & LDAk ?&w
2023-06-17 14:48:46 -04:00
JMP2r
2023-06-04 11:42:43 -04:00
@sput ( chr str* -- )
2023-08-06 12:39:40 -04:00
scap/ ROT #00 SWP2 STA2
2023-06-17 14:48:46 -04:00
JMP2r
@<phex> ( short* -- )
SWP <phex>/b
&b ( -- )
DUP #04 SFT <phex>/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD #18 DEO
JMP2r
@<perr> ( err* -- )
&w ( -- )
LDAk #19 DEO
2023-08-06 12:39:40 -04:00
INC2 & LDAk ?&w
2023-06-17 14:48:46 -04:00
POP2 JMP2r
2023-06-04 11:42:43 -04:00
2023-08-06 12:39:40 -04:00
@<pdec> ( short* -- )
#2710 [ LIT2r 00fb ]
&w ( -- )
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
DUP [ LIT "0 ] ADD #19 DEO
INCr }
POP2 #000a DIV2 SWPr INCr STHkr ?&w
POP2r POP2 POP2 JMP2r
2023-06-04 11:42:43 -04:00
(
@|res )
2023-06-17 14:48:46 -04:00
@Dict &usage "usage: 20 "hx.rom 20 "input.bin 0a $1
2023-08-06 12:39:40 -04:00
&bytes 20 "bytes 20 "in 20 $1
2023-03-17 13:28:04 -04:00