uxn-utils/gui/romviz/romviz.tal

136 lines
2.5 KiB
Tal
Raw Normal View History

2023-04-05 13:40:06 -04:00
( uxncli romviz.rom file.rom )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
2023-04-05 13:53:53 -04:00
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1
2023-04-05 13:40:06 -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
|0100 ( -> )
;await-src .Console/vector DEO2
BRK
@await-src ( -> )
.Console/read DEI .src skey ?on-ready
BRK
@on-ready ( -> )
( theme ) [
2023-04-05 13:53:53 -04:00
#f41e .System/r DEO2
#fa71 .System/g DEO2
#f4b1 .System/b DEO2 ]
2023-04-05 13:40:06 -04:00
( resize )
2023-04-05 13:53:53 -04:00
#0240
2023-04-05 13:40:06 -04:00
DUP2 .Screen/width DEO2
.Screen/height DEO2
draw-memory
2023-04-05 13:53:53 -04:00
;on-mouse .Mouse/vector DEO2
2023-04-05 13:40:06 -04:00
BRK
2023-04-05 13:53:53 -04:00
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn update-cursor
.Mouse/state DEI ?&on-mouse-down
BRK
&on-mouse-down ( -> )
( TODO: )
BRK
(
@|drawing )
2023-04-05 13:40:06 -04:00
@draw-memory ( -- )
;src .File/name DEO2
#0001 .File/length DEO2
2023-04-05 13:53:53 -04:00
;pixel-icn .Screen/addr DEO2
2023-04-05 13:40:06 -04:00
LIT2r 0000
&stream
;&buf .File/read DEO2
.File/success DEI2 #0000 EQU2 ?&eof
[ LIT &buf $1 ] STH2kr draw-byte INC2r
!&stream &eof
POP2r
JMP2r
2023-04-05 13:53:53 -04:00
@update-cursor ( color addr* -- )
[ LIT2 00 -Screen/auto ] DEO
#40 draw-cursor
.Mouse/x DEI2 ,draw-cursor/x STR2
.Mouse/y DEI2 ,draw-cursor/y STR2
.Screen/addr DEO2
@draw-cursor ( color -- )
[ LIT2 &x $2 ] .Screen/x DEO2
[ LIT2 &y $2 ] .Screen/y DEO2
.Screen/sprite DEO
JMP2r
2023-04-05 13:40:06 -04:00
(
@|stdlib )
@draw-byte ( byte addr* -- )
addr-pos .Screen/y DEO2 .Screen/x DEO2
DUP #00 NEQ ?&no-null
2023-04-05 13:53:53 -04:00
.Screen/sprite DEO JMP2r
2023-04-05 13:40:06 -04:00
&no-null
DUP #20 GTH ?&no-low
2023-04-05 13:53:53 -04:00
POP #05 .Screen/sprite DEO JMP2r
2023-04-05 13:40:06 -04:00
&no-low
#80 GTH ?&no-ascii
2023-04-05 13:53:53 -04:00
#0a .Screen/sprite DEO JMP2r
2023-04-05 13:40:06 -04:00
&no-ascii
2023-04-05 13:53:53 -04:00
#0f .Screen/sprite DEO
2023-04-05 13:40:06 -04:00
JMP2r
@addr-pos ( addr* -- x* y* )
STH2k
2023-04-05 13:53:53 -04:00
( pixel x ) #000f AND2
2023-04-05 13:40:06 -04:00
( block x ) STH2kr #48 SFT2 ADD2 #00ff AND2
2023-04-05 13:53:53 -04:00
#10 SFT2 #0020 ADD2
2023-04-05 13:40:06 -04:00
( pixel y ) STHk2r #04 SFT2 #000f AND2
2023-04-05 13:53:53 -04:00
( block y ) STH2r #4c SFT2 ADD2
#10 SFT2 #0020 ADD2
2023-04-05 13:40:06 -04:00
JMP2r
@skey ( key buf -- proc ) OVR #21 LTH ?&eval #00 SWP sput #00 JMP2r &eval POP2 #01 JMP2r
@scap ( str* -- end* ) LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r
@sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r
@pstr ( str* -- ) &w LDAk #18 DEO INC2 LDAk ?&w POP2 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
2023-04-05 13:53:53 -04:00
(
@|assets )
@pixel-icn [
c0c0 0000 0000 0000 ]
@cursor-icn [
80c0 e0f0 f8e0 1000 ]