uxn-utils/cli/icnuf1/icnuf1.tal

83 lines
1.3 KiB
Tal

( uxncli format-c.rom file.bin )
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@src $40
|0100
@on-reset ( -> )
;on-console .Console/vector DEO2
BRK
@on-console ( -> )
[ LIT2r =src ]
( read input ) .Console/read DEI DUP #20 LTH OVR #7f GTH ORA ?&>end
STH2kr slen #003f GTH2 ?&>end
STH2kr scap STA
POP2r BRK &>end
POP
( | read )
STH2r .File/name DEO2
#0800 .File/length DEO2
;icn .File/read DEO2
( | convert )
<convert>
#800f DEO
BRK
@<copy-tiles> ( a b -- )
OVR phex/b #2018 DEO
DUP phex/b #0a18 DEO
POP2
JMP2r
@<convert> ( -- )
#0000
&l ( -- )
( | print pos )
( y ) DUP #15 SFT OVR #01 AND ADD #40 SFT STH
( x ) DUP #01 SFT #0f AND
( merge ) STHr ORA
OVR <copy-tiles>
INC DUP ?&l
POP2
JMP2r
@blank [ ffff ffff ffff ffff ]
(
@|stdlib )
@slen ( str* -- len* )
DUP2 scap SWP2 SUB2 JMP2r
@scap ( str* -- end* )
LDAk #00 NEQ [ JMP JMP2r ]
&w ( -- )
INC2 LDAk ?&w
JMP2r
@phex ( short* -- )
SWP phex/b
&b ( -- )
DUP #04 SFT phex/c
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
JMP2r
@pstr ( str* -- )
&while ( -- )
LDAk #18 DEO
INC2 LDAk ?&while
POP2 JMP2r
@icn $800
@uf1 $800