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
|
|
|
|
|
|
|
|
|0100
|
|
|
|
|
|
|
|
@on-reset ( -> )
|
|
|
|
.Console/type DEI ?&>has-arg
|
2023-07-13 13:57:48 -04:00
|
|
|
;dict/usage <print-str>
|
2023-07-13 01:54:31 -04:00
|
|
|
#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:49:49 -04:00
|
|
|
<reset>
|
|
|
|
;src load-rom run #800f DEO
|
2023-07-13 01:54:31 -04:00
|
|
|
BRK
|
|
|
|
|
|
|
|
(
|
|
|
|
@|emu )
|
|
|
|
|
|
|
|
@load-rom ( filename* -- )
|
|
|
|
.File/name DEO2
|
2023-07-13 13:49:49 -04:00
|
|
|
#fff0 ;rom/reset SUB2 DUP2 .File/length DEO2
|
2023-07-13 13:23:52 -04:00
|
|
|
;rom/reset .File/read DEO2
|
2023-07-13 13:49:49 -04:00
|
|
|
.File/success DEI2 SUB2 <print-dec>
|
|
|
|
;dict/bytes-free !<print-str>
|
2023-07-13 01:54:31 -04:00
|
|
|
|
|
|
|
@run ( -- )
|
2023-07-13 14:09:55 -04:00
|
|
|
<step>
|
|
|
|
.uxn/err LDZ ?&err
|
|
|
|
?run
|
2023-07-13 14:40:44 -04:00
|
|
|
;<step>/count LDA2 <print-dec>
|
|
|
|
;dict/cycles <print-str>
|
|
|
|
JMP2r
|
2023-07-13 13:57:48 -04:00
|
|
|
&err ( opcode -- )
|
|
|
|
POP !<reset>
|
2023-07-13 01:54:31 -04:00
|
|
|
|
2023-07-13 13:49:49 -04:00
|
|
|
@halt ( opcode -- opcode )
|
|
|
|
JMP2r
|
|
|
|
|
2023-07-13 14:40:44 -04:00
|
|
|
@emu-deo ( v p -- )
|
2023-07-13 02:01:15 -04:00
|
|
|
( | handlers )
|
|
|
|
DUP #0e NEQ ?&>no-debug
|
2023-07-13 14:40:44 -04:00
|
|
|
POP2 JMP2r &>no-debug
|
2023-07-13 01:54:31 -04:00
|
|
|
DUP #0f NEQ ?&>no-halt
|
2023-07-13 14:40:44 -04:00
|
|
|
POP2 JMP2r &>no-halt
|
2023-07-13 02:01:15 -04:00
|
|
|
DUP #18 NEQ ?&>no-out
|
2023-07-13 14:40:44 -04:00
|
|
|
DEO
|
2023-07-13 13:57:48 -04:00
|
|
|
JMP2r &>no-out
|
2023-07-13 02:01:15 -04:00
|
|
|
DUP #19 NEQ ?&>no-err
|
2023-07-13 14:40:44 -04:00
|
|
|
DEO
|
2023-07-13 13:57:48 -04:00
|
|
|
JMP2r &>no-err
|
2023-07-13 02:01:15 -04:00
|
|
|
( | error )
|
2023-07-13 13:57:48 -04:00
|
|
|
;dict/err-device <print-str>
|
2023-07-13 14:09:55 -04:00
|
|
|
<print-hex>/b
|
2023-07-13 02:01:15 -04:00
|
|
|
#0a18 DEO
|
2023-07-13 14:40:44 -04:00
|
|
|
POP JMP2r
|
2023-07-13 01:54:31 -04:00
|
|
|
|
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
|
|
|
@skey ( key buf -- proc )
|
|
|
|
OVR #21 LTH ?&eval
|
|
|
|
#00 SWP sput #00 JMP2r
|
|
|
|
&eval ( -- )
|
|
|
|
POP2 #01 JMP2r
|
|
|
|
|
|
|
|
@scap ( str* -- end* )
|
2023-07-13 13:49:49 -04:00
|
|
|
!&
|
2023-07-13 01:54:31 -04:00
|
|
|
&w ( -- )
|
2023-07-13 13:49:49 -04:00
|
|
|
INC2 & LDAk ?&w
|
2023-07-13 01:54:31 -04:00
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@sput ( chr str* -- )
|
2023-07-13 13:49:49 -04:00
|
|
|
scap/ ROT #00 SWP2 STA2
|
2023-07-13 01:54:31 -04:00
|
|
|
JMP2r
|
|
|
|
|
2023-07-13 14:09:55 -04:00
|
|
|
@<print-hex> ( short* -- )
|
|
|
|
SWP <print-hex>/b
|
2023-07-13 01:54:31 -04:00
|
|
|
&b ( -- )
|
2023-07-13 14:09:55 -04:00
|
|
|
DUP #04 SFT <print-hex>/c
|
2023-07-13 01:54:31 -04:00
|
|
|
&c ( -- )
|
|
|
|
#0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD #18 DEO
|
|
|
|
JMP2r
|
|
|
|
|
2023-07-13 13:49:49 -04:00
|
|
|
@<print-str> ( str* -- )
|
2023-07-13 01:54:31 -04:00
|
|
|
&w ( -- )
|
|
|
|
LDAk #19 DEO
|
2023-07-13 13:49:49 -04:00
|
|
|
INC2 LDAk ?&w
|
2023-07-13 01:54:31 -04:00
|
|
|
POP2 JMP2r
|
|
|
|
|
2023-07-13 13:49:49 -04:00
|
|
|
@<print-dec> ( short* -- )
|
|
|
|
#2710 [ LIT2r 00fb ]
|
2023-07-13 01:54:31 -04:00
|
|
|
&w ( -- )
|
2023-07-13 13:49:49 -04:00
|
|
|
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&>skip
|
|
|
|
DUP LIT "0 ADD #19 DEO
|
|
|
|
INCr &>skip
|
|
|
|
POP2 #000a DIV2 SWPr INCr STHkr ?&w
|
|
|
|
POP2r POP2 POP2 JMP2r
|
2023-07-13 01:54:31 -04:00
|
|
|
|
|
|
|
(
|
|
|
|
@|res )
|
|
|
|
|
2023-07-13 13:49:49 -04:00
|
|
|
@dict &usage "usage: 20 "uxnvm.rom 20 "game.rom 0a $1
|
|
|
|
&bytes-free 20 "bytes 20 "free. 0a $1
|
2023-07-13 13:57:48 -04:00
|
|
|
&err-device "Unsupported 20 "device: 20 $1
|
2023-07-13 14:09:55 -04:00
|
|
|
&cycles 20 "cycles. 0a $1
|
2023-07-13 13:49:49 -04:00
|
|
|
|
2023-07-13 01:54:31 -04:00
|
|
|
~vm.tal
|
|
|
|
|