2023-07-13 01:54:31 -04:00
|
|
|
( uxncli hx.rom file.bin )
|
|
|
|
|
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &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
|
|
|
|
@uxn &pc $2 &src $2 &dst $2 &err $1 &2 $1
|
|
|
|
@emu &sleep $1
|
|
|
|
|
|
|
|
|0100
|
|
|
|
|
|
|
|
@on-reset ( -> )
|
|
|
|
.Console/type DEI ?&>has-arg
|
|
|
|
;Dict/usage <perr>
|
|
|
|
#010f DEO
|
|
|
|
BRK &>has-arg
|
|
|
|
;on-waitsrc .Console/vector DEO2
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-waitsrc ( -> )
|
|
|
|
.Console/read DEI .src skey ?on-ready
|
|
|
|
BRK
|
|
|
|
|
|
|
|
@on-ready ( -> )
|
2023-07-13 13:23:52 -04:00
|
|
|
;src load-rom reset run #800f DEO
|
2023-07-13 01:54:31 -04:00
|
|
|
BRK
|
|
|
|
|
|
|
|
(
|
|
|
|
@|emu )
|
|
|
|
|
|
|
|
@load-rom ( filename* -- )
|
|
|
|
.File/name DEO2
|
2023-07-13 13:23:52 -04:00
|
|
|
#fff0 ;rom/reset SUB2 .File/length DEO2
|
|
|
|
;rom/reset .File/read DEO2
|
|
|
|
.File/success DEI2 #fff0 ;rom/reset SUB2 EQU2 ?&err-overflow
|
2023-07-13 01:54:31 -04:00
|
|
|
.File/success DEI2 #0000 EQU2 ?&err-empty
|
|
|
|
JMP2r
|
|
|
|
&err-empty ( -- )
|
|
|
|
( TODO ) JMP2r
|
|
|
|
&err-overflow ( -- )
|
|
|
|
( TODO ) JMP2r
|
|
|
|
|
|
|
|
@run ( -- )
|
|
|
|
[ LIT2 00 -emu/sleep ] STZ
|
|
|
|
#0000
|
|
|
|
&w ( -- )
|
|
|
|
step .uxn/err LDZ ?&err
|
|
|
|
.emu/sleep LDZ ?&end
|
|
|
|
INC2 ORAk ?&w
|
|
|
|
&end POP2
|
|
|
|
( TODO: Catch too long ) JMP2r
|
|
|
|
&err ( -- )
|
|
|
|
POP2 #00 ;wst/ptr STA
|
|
|
|
#00 ;rst/ptr STA
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@send ( v* p* -- )
|
2023-07-13 02:01:15 -04:00
|
|
|
NIP
|
|
|
|
( | handlers )
|
|
|
|
DUP #0e NEQ ?&>no-debug
|
2023-07-13 01:54:31 -04:00
|
|
|
&>no-debug
|
|
|
|
DUP #0f NEQ ?&>no-halt
|
|
|
|
&>no-halt
|
2023-07-13 02:01:15 -04:00
|
|
|
DUP #18 NEQ ?&>no-out
|
|
|
|
POP #18 DEO
|
|
|
|
POP JMP2r &>no-out
|
|
|
|
DUP #19 NEQ ?&>no-err
|
|
|
|
POP #19 DEO
|
|
|
|
POP JMP2r &>no-err
|
|
|
|
( | error )
|
2023-07-13 13:23:52 -04:00
|
|
|
LIT "! #18 DEO
|
2023-07-13 02:01:15 -04:00
|
|
|
<phex>/b
|
|
|
|
#2018 DEO
|
|
|
|
<phex>
|
|
|
|
#0a18 DEO
|
|
|
|
JMP2r
|
2023-07-13 01:54:31 -04:00
|
|
|
|
|
|
|
@halt ( opcode -- )
|
|
|
|
#01 .emu/sleep STZ
|
|
|
|
<phex>/b
|
|
|
|
#0a18 DEO
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
|
|
|
@skey ( key buf -- proc )
|
|
|
|
OVR #21 LTH ?&eval
|
|
|
|
#00 SWP sput #00 JMP2r
|
|
|
|
&eval ( -- )
|
|
|
|
POP2 #01 JMP2r
|
|
|
|
|
|
|
|
@scap ( str* -- end* )
|
|
|
|
!&a
|
|
|
|
&w ( -- )
|
|
|
|
INC2 &a LDAk ?&w
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@sput ( chr str* -- )
|
|
|
|
scap INC2k #00 ROT ROT STA
|
|
|
|
STA
|
|
|
|
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* -- )
|
|
|
|
!&a
|
|
|
|
&w ( -- )
|
|
|
|
LDAk #19 DEO
|
|
|
|
INC2 &a LDAk ?&w
|
|
|
|
POP2 JMP2r
|
|
|
|
|
|
|
|
@<print-str> ( str* -- )
|
|
|
|
&w ( -- )
|
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 LDAk ?&w
|
|
|
|
POP2 JMP2r
|
|
|
|
|
|
|
|
(
|
|
|
|
@|res )
|
|
|
|
|
|
|
|
@Dict &usage "usage: 20 "uxnvm.rom 20 "game.rom 0a $1
|
|
|
|
~vm.tal
|
|
|
|
|