uxn-utils/gui/romviz/romviz.tal

353 lines
6.8 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
2023-04-05 16:21:09 -04:00
@page $1
2023-04-05 13:40:06 -04:00
|0100 ( -> )
;await-src .Console/vector DEO2
BRK
@await-src ( -> )
.Console/read DEI .src skey ?on-ready
BRK
@on-ready ( -> )
( theme ) [
2023-04-05 14:07:29 -04:00
#fc1e .System/r DEO2
2023-04-05 13:53:53 -04:00
#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
2023-04-05 14:23:41 -04:00
load-symbols
2023-04-05 14:07:29 -04:00
redraw
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 ( -> )
2023-04-05 16:21:09 -04:00
.Mouse/state DEI #01 NEQ ?&no-next
.page LDZk INC SWP STZ
#00 .Mouse/state DEO
redraw
BRK
&no-next
( prev )
.page LDZk #01 SUB SWP STZ
#00 .Mouse/state DEO
redraw
2023-04-05 13:53:53 -04:00
BRK
2023-04-05 16:21:09 -04:00
(
@|core )
2023-04-05 14:23:41 -04:00
@load-symbols ( -- )
;src
DUP2 scap STH2k ;&ext SWP2 scpy
.File/name DEO2
#8000 .File/length DEO2
;symbols .File/read DEO2
#00 STH2r STA
JMP2r
&ext ".sym $1
@find-symbol ( addr* -- sym* )
,&t STR2
;symbols
&l
LDA2k INC2 [ LIT2 &t $2 ] GTH2 ?&end
INC2k INC2 LDA #00 EQU ?&end
INC2 INC2 scap INC2 !&l
&end
JMP2r
@addr-pos ( addr* -- x* y* )
STH2k
( pixel x ) #000f AND2
( block x ) STH2kr #48 SFT2 ADD2 #00ff AND2
DUP2 ADD2 #0020 ADD2
( pixel y ) STHk2r #04 SFT2 #000f AND2
( block y ) STH2r #4c SFT2 ADD2
DUP2 ADD2 #0020 ADD2
JMP2r
2023-04-05 16:21:09 -04:00
@set-page ( id -- )
;src .File/name DEO2
#8000 .File/length DEO2
#00 EQUk ?&e
&l
#8000
DUP2 .File/read DEO2
.File/read DEO2
INC GTHk ?&l
&e
POP2
#0001 .File/length DEO2
JMP2r
2023-04-05 13:53:53 -04:00
(
@|drawing )
2023-04-05 14:07:29 -04:00
@redraw ( -- )
2023-04-05 13:40:06 -04:00
2023-04-05 16:21:09 -04:00
.page LDZ set-page
draw-clear
2023-04-05 14:44:45 -04:00
#00 .Screen/auto DEO
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
2023-04-05 16:21:09 -04:00
[ LIT &buf $1 ] STH2kr
draw-cell INC2r
2023-04-05 14:44:45 -04:00
STH2kr #0000 EQU2 ?&eof
2023-04-05 13:40:06 -04:00
!&stream &eof
2023-04-05 16:21:09 -04:00
( page )
#01 ;draw-chr/color STA
#01e0 .Screen/x DEO2
2023-04-05 14:44:45 -04:00
#0010 .Screen/y DEO2
#01 .Screen/auto DEO
2023-04-05 16:21:09 -04:00
.page LDZ draw-byte
( size )
#0200 .Screen/x DEO2
2023-04-05 14:44:45 -04:00
STH2r draw-short
2023-04-05 14:07:29 -04:00
( filename )
#0020 .Screen/x DEO2
2023-04-05 14:23:41 -04:00
#01 ;draw-chr/color STA
2023-04-05 16:21:09 -04:00
;src
2023-04-05 13:40:06 -04:00
2023-04-05 14:23:41 -04:00
!draw-str
2023-04-05 13:40:06 -04:00
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 16:21:09 -04:00
@draw-clear ( -- )
#f1 .Screen/auto DEO
#0400
&v
#0020 .Screen/x DEO2
#00 OVR #70 SFT2 #0020 ADD2 .Screen/y DEO2
#c0 &h #00 .Screen/sprite DEO INC DUP ?&h POP
INC GTHk ?&v
POP2
@draw-grid ( -- )
#0020
DUP2 .Screen/x DEO2
.Screen/y DEO2
#0801
&v
#00 OVR #60 SFT2 #0020 ADD2 .Screen/x DEO2
#0020 .Screen/y DEO2
draw-linev
INC GTHk ?&v POP2
#0801
&h
#0020 .Screen/x DEO2
#00 OVR #60 SFT2 #0020 ADD2 .Screen/y DEO2
draw-lineh
INC GTHk ?&h POP2
( draw labels )
#0020 .Screen/x DEO2
#0120 .Screen/y DEO2
#04 ;draw-chr/color STA
#8000 draw-short
JMP2r
@draw-linev ( -- )
#02 .Screen/auto DEO
;linev-icn .Screen/addr DEO2
#4000
&v
#05 .Screen/sprite DEO
INC GTHk ?&v
POP2
JMP2r
@draw-lineh ( -- )
#01 .Screen/auto DEO
;lineh-icn .Screen/addr DEO2
#4000
&v
#05 .Screen/sprite DEO
INC GTHk ?&v
POP2
JMP2r
2023-04-05 14:07:29 -04:00
@draw-short ( short* -- )
SWP draw-byte
@draw-byte ( byte -- )
DUP #04 SFT draw-hex
@draw-hex ( char -- )
#0f AND DUP #09 GTH #27 MUL ADD #30 ADD
@draw-chr ( char -- )
#20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2
[ LIT &color 01 ] .Screen/sprite DEO
JMP2r
@draw-str ( str* -- )
LDAk #01 SUB #7f GTH ?&skip
#01 .Screen/auto DEO
&w
LDAk draw-chr
INC2 LDAk ?&w
&skip
POP2
JMP2r
2023-04-05 13:53:53 -04:00
2023-04-05 14:07:29 -04:00
@draw-cell ( byte addr* -- )
2023-04-05 13:40:06 -04:00
addr-pos .Screen/y DEO2 .Screen/x DEO2
2023-04-05 14:23:41 -04:00
DUP ?&no-null
2023-04-05 14:44:45 -04:00
POP ( .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
2023-04-05 14:23:41 -04:00
(
@|stdlib )
2023-04-05 13:40:06 -04:00
2023-04-05 14:23:41 -04:00
@scpy ( src* dst* -- ) OVR2 LDA ?&e POP2 POP2 JMP2r &e STH2 &w LDAk STH2kr STA INC2r INC2 LDAk ?&w POP2 #00 STH2r STA JMP2r
2023-04-05 13:40:06 -04:00
@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 ]
2023-04-05 16:21:09 -04:00
@linev-icn [
8000 8000 8000 8000 ]
@lineh-icn [
aa00 0000 0000 0000 ]
2023-04-05 14:07:29 -04:00
@font ( atari8 ) [
0000 0000 0000 0000 6060 6060 6000 6000
6666 6600 0000 0000 006c fe6c 6cfe 6c00
183e 603c 067c 1800 0066 6c18 3066 4600
386c 3870 decc 7600 6060 6000 0000 0000
1c30 3030 3030 1c00 380c 0c0c 0c0c 3800
0066 3cff 3c66 0000 0018 187e 1818 0000
0000 0000 0030 3060 0000 007e 0000 0000
0000 0000 0018 1800 0306 0c18 3060 c000
3c66 6e76 6666 3c00 1838 1818 1818 7e00
3c66 060c 1830 7e00 7e0c 180c 0666 3c00
0c1c 3c6c 7e0c 0c00 7e60 7c06 0666 3c00
3c60 607c 6666 3c00 7e06 0c18 3030 3000
3c66 663c 6666 3c00 3c66 663e 060c 3800
0018 1800 0018 1800 0018 1800 1818 3000
0c18 3060 3018 0c00 0000 7e00 007e 0000
3018 0c06 0c18 3000 3c66 060c 1800 1800
3c66 6e6a 6e60 3e00 183c 6666 7e66 6600
7c66 667c 6666 7c00 3c66 6060 6066 3c00
786c 6666 666c 7800 7e60 607c 6060 7e00
7e60 607c 6060 6000 3e60 606e 6666 3e00
6666 667e 6666 6600 3c18 1818 1818 3c00
3e06 0606 0666 3c00 666c 7870 786c 6600
6060 6060 6060 7e00 c6ee fed6 c6c6 c600
6676 7e7e 6e66 6600 3c66 6666 6666 3c00
7c66 667c 6060 6000 3c66 6666 766c 3600
7c66 667c 6c66 6600 3c66 603c 0666 3c00
7e18 1818 1818 1800 6666 6666 6666 3e00
6666 6666 663c 1800 c6c6 c6d6 feee c600
6666 3c18 3c66 6600 6666 663c 1818 1800
7e06 0c18 3060 7e00 3c30 3030 3030 3c00
c060 3018 0c06 0300 3c0c 0c0c 0c0c 3c00
1038 6cc6 0000 0000 0000 0000 0000 fe00
0060 3018 0000 0000 0000 3c06 3e66 3e00
6060 7c66 6666 7c00 0000 3c60 6060 3c00
0606 3e66 6666 3e00 0000 3c66 7e60 3c00
1c30 7c30 3030 3000 0000 3e66 663e 067c
6060 7c66 6666 6600 1800 3818 1818 3c00
1800 1818 1818 1870 6060 666c 786c 6600
3818 1818 1818 3c00 0000 ecfe d6c6 c600
0000 7c66 6666 6600 0000 3c66 6666 3c00
0000 7c66 6666 7c60 0000 3e66 6666 3e06
0000 7c66 6060 6000 0000 3e60 3c06 7c00
0018 7e18 1818 0e00 0000 6666 6666 3e00
0000 6666 663c 1800 0000 c6c6 d67c 6c00
0000 663c 183c 6600 0000 6666 663e 067c
0000 7e0c 1830 7e00 1c30 3060 3030 1c00
1818 1818 1818 1818 380c 0c06 0c0c 3800
0000 60f2 9e0c 0000 3c42 9985 8599 423c ]
2023-04-05 14:23:41 -04:00
(
@|memory )
@symbols
2023-04-05 13:53:53 -04:00