uxn-utils/checksum/checksum.tal

65 lines
1.2 KiB
Tal
Raw Normal View History

2023-02-06 18:54:12 -05:00
( usage: uxncli checksum.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 ( -> )
;await-src .Console/vector DEO2
2023-02-06 19:01:00 -05:00
;dict/input pstr
2023-02-06 18:54:12 -05:00
BRK
@await-src ( -> )
.Console/read DEI .src skey
?on-ready
BRK
@on-ready ( -> )
2023-02-06 19:01:00 -05:00
#0a18 DEO
;src hash plong
#0a18 DEO
2023-02-06 18:54:12 -05:00
#010f DEO
BRK
@hash ( filename* -- x* y* )
.File/name DEO2
#0001 .File/length DEO2
#1234 ,&x STR2 #abcd ,&y STR2
#2443 ,&a STR2 #118d ,&b STR2
&w
;&c .File/read DEO2
[ LIT &c $1 ] DUP DUP2
[ LIT2 &x $2 ] [ LIT2 &a $2 ] MUL2 ADD2 ,&x STR2
[ LIT2 &y $2 ] [ LIT2 &b $2 ] MUL2 ADD2 ,&y STR2
2023-02-06 18:59:17 -05:00
.File/success DEI2 ORA ?&w
2023-02-06 18:54:12 -05:00
,&x LDR2 ,&y LDR2
JMP2r
@scap ( str* -- end* )
LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r
@sput ( chr str* -- )
scap STA JMP2r
@skey ( key buf -- proc )
OVR #21 LTH ?&eval #00 SWP sput #00 JMP2r &eval POP2 #01 JMP2r
@pstr ( str* -- )
&w LDAk #18 DEO INC2 LDAk ?&w POP2 JMP2r
@plong ( a* b* -> )
SWP2 plong/s
&s SWP plong/b
&b DUP #04 SFT plong/c
&c #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r
@dict
&input "Input(.tal): 20 $1