uxn-utils/gui/meta/meta.tal

252 lines
5.8 KiB
Tal
Raw Normal View History

2023-04-04 18:26:25 -04:00
( A little program to see a rom's metadata )
|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2
2023-11-17 14:31:05 -05:00
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
2023-04-04 18:26:25 -04:00
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
|b0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|0000
@src $40
2023-06-20 00:26:57 -04:00
|0100
2023-04-04 18:26:25 -04:00
2023-06-20 00:26:57 -04:00
@on-reset ( -> )
2023-04-04 18:26:25 -04:00
;meta #06 DEO2
#960f .System/r DEO2
#a70f .System/g DEO2
#a70f .System/b DEO2
#0150 .Screen/width DEO2
#0050 .Screen/height DEO2
2024-01-14 18:58:04 -05:00
[ LIT2 03 -Console/type ] DEI AND ?{ ;dict/usage <perr>/ }
2023-04-04 18:26:25 -04:00
;await-src .Console/vector DEO2
2023-06-20 00:26:57 -04:00
BRK
2023-04-04 18:26:25 -04:00
2023-06-20 00:26:57 -04:00
@meta
00
2023-04-04 18:26:25 -04:00
( name ) "Meta 0a
2023-11-17 14:19:58 -05:00
( details ) "A 20 "Metadata 20 "Viewer 0a
2023-04-04 18:26:25 -04:00
( author ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
2023-11-30 16:28:13 -05:00
( date ) "29 20 "Nov 20 "2023 $1
2023-11-17 14:19:58 -05:00
03
( skip ) 00 abcd
( skip ) 01 ef01
2023-06-20 00:26:57 -04:00
( icon ) 83 =appicon
2023-04-04 18:26:25 -04:00
(
@|vectors )
@await-src ( -> )
2023-11-17 14:19:58 -05:00
.Console/read DEI .src skey ?{ BRK }
;src has-metadata ?{
2023-11-17 15:11:34 -05:00
;dict/empty <pstr-ln>
2023-11-30 16:28:13 -05:00
;src <sclr>
2023-11-17 14:19:58 -05:00
BRK }
<load-metadata>
;metadata/body DUP2
2023-11-17 14:25:35 -05:00
( cli ) <pstr-ln>/
2023-11-17 14:19:58 -05:00
( gui ) <draw-metadata>
2023-11-30 16:28:13 -05:00
;src <sclr>
2023-06-20 00:26:57 -04:00
BRK
2023-04-04 18:26:25 -04:00
(
@|core )
@has-metadata ( src* -- bool )
.File/name DEO2
#0006 .File/length DEO2
;metadata/header .File/read DEO2
2023-06-20 00:26:57 -04:00
;metadata/deo LDA2 #0637 EQU2 JMP2r
2023-04-04 18:26:25 -04:00
2023-11-17 14:19:58 -05:00
@<load-metadata> ( -- )
;metadata/start LDA2 #0100 SUB2 <seek>
2023-06-20 00:26:57 -04:00
( | version )
2023-04-04 18:26:25 -04:00
#0001 .File/length DEO2
;metadata/version .File/read DEO2
2023-06-20 00:26:57 -04:00
( | body )
2023-04-04 18:26:25 -04:00
LIT2r =metadata/body
2023-06-20 00:26:57 -04:00
&s ( -- )
STH2kr DUP2 .File/read DEO2
INC2r LDA ?&s
2023-04-04 18:26:25 -04:00
POP2r
2023-06-20 00:26:57 -04:00
( | fields )
2023-11-17 14:19:58 -05:00
;metadata/length DUP2 .File/read DEO2
2023-06-20 00:26:57 -04:00
LDAk #03 MUL #00 SWP .File/length DEO2
INC2 .File/read DEO2
JMP2r
2023-04-04 18:26:25 -04:00
(
@|drawing )
2023-11-17 14:19:58 -05:00
@<draw-metadata> ( body* -- )
2023-11-30 16:28:13 -05:00
( | clear )
#0000 DUP2 .Screen/x DEO2
.Screen/y DEO2
2024-01-14 18:58:04 -05:00
[ LIT2 80 -Screen/pixel ] DEO
2023-11-30 16:28:13 -05:00
( | draw )
2023-04-04 18:26:25 -04:00
#004c .Screen/x DEO2
#0012 .Screen/y DEO2
2023-11-17 14:19:58 -05:00
<draw-txt>
2023-06-20 00:26:57 -04:00
( | find picture )
2023-11-17 14:19:58 -05:00
;metadata/length LDA #00
2023-06-20 00:26:57 -04:00
&l ( -- )
2023-11-17 14:19:58 -05:00
[ LIT2 09 18 ] DEO
#00 OVR #03 MUL ;metadata/fields ADD2
( icon ) LDAk #83 NEQ ?{ INC2k LDA2 <draw-icon> }
2023-11-17 14:25:35 -05:00
( byte ) LDAk <phex>/b
#2018 DEO
( shorts ) INC2 LDA2 <phex>
#0a18 DEO
2023-11-17 14:19:58 -05:00
INC GTHk ?&l
POP2 JMP2r
2023-04-04 18:26:25 -04:00
2023-06-20 00:26:57 -04:00
@<draw-icon> ( location* -- )
2023-11-17 14:19:58 -05:00
#0100 SUB2 <seek>
#0090 .File/length DEO2
2023-06-20 00:26:57 -04:00
;metadata/icon DUP2 .File/read DEO2
.Screen/addr DEO2
2023-04-04 18:26:25 -04:00
[ LIT2 26 -Screen/auto ] DEO
2023-06-20 00:26:57 -04:00
#001c DUP2 .Screen/x DEO2
.Screen/y DEO2
2023-11-17 14:19:58 -05:00
[ LIT2 81 -Screen/sprite ] DEOk DEOk DEO
2023-06-20 00:26:57 -04:00
JMP2r
@<draw-txt> ( txt* -- end* )
2023-04-04 18:26:25 -04:00
[ LIT2 01 -Screen/auto ] DEO
.Screen/x DEI2 ,&anchor STR2
2023-06-20 00:26:57 -04:00
&w ( -- )
2023-04-04 18:26:25 -04:00
LDAk #20 SUB #00 SWP #30 SFT2 ;font ADD2 .Screen/addr DEO2
[ LIT2 02 -Screen/sprite ] DEO
2023-11-17 14:19:58 -05:00
LDAk #0a NEQ ?{
2023-04-04 18:26:25 -04:00
[ LIT2 &anchor $2 ] .Screen/x DEO2
2023-11-17 14:19:58 -05:00
.Screen/y DEI2k #000c ADD2 ROT DEO2 }
2023-04-04 18:26:25 -04:00
INC2 LDAk ?&w
2023-11-17 14:19:58 -05:00
POP2 JMP2r
2023-04-04 18:26:25 -04:00
(
@|stdlib )
2023-11-17 14:19:58 -05:00
@<seek> ( length* -- )
2023-04-04 18:26:25 -04:00
.File/name DEI2k ROT DEO2
#0000 INC2k .File/length DEO2
2023-06-20 00:26:57 -04:00
&l ( -- )
2023-04-04 18:26:25 -04:00
;&b .File/read DEO2
INC2 GTH2k ?&l
2023-06-20 00:26:57 -04:00
POP2 POP2 JMP2r
2023-04-04 18:26:25 -04:00
&b $1
2023-06-20 00:26:57 -04:00
@scap ( str* -- end* )
2024-01-14 18:58:04 -05:00
INC2 & LDAk ?scap
2023-06-20 00:26:57 -04:00
JMP2r
2023-11-30 16:28:13 -05:00
@<sclr> ( str* -- )
#00 ROT ROT
&w ( -- )
STAk INC2 LDAk ?&w
STA
JMP2r
2023-06-20 00:26:57 -04:00
@skey ( key buf -- proc )
OVR #21 LTH ?&eval
2024-01-14 18:58:04 -05:00
#00 SWP scap/ STA
#00 JMP2r
2023-06-20 00:26:57 -04:00
&eval POP2 #01 JMP2r
2023-11-17 14:25:35 -05:00
@<phex> ( short* -- )
SWP <phex>/b
2023-11-17 14:19:58 -05:00
&b ( -- )
2023-11-17 14:25:35 -05:00
DUP #04 SFT <phex>/c
2023-11-17 14:19:58 -05:00
&c ( -- )
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
JMP2r
@<pstr-ln> ( str* -- )
2023-06-20 00:26:57 -04:00
&w ( -- )
LDAk #18 DEO
2023-11-17 14:25:35 -05:00
INC2 & LDAk ?&w
2023-11-17 14:19:58 -05:00
POP2 #0a18 DEO
JMP2r
2023-04-04 18:26:25 -04:00
2023-11-17 14:31:05 -05:00
@<perr> ( str* -- )
&w ( -- )
LDAk #19 DEO
INC2 & LDAk ?&w
POP2 JMP2r
2023-04-04 18:26:25 -04:00
(
@|assets )
2023-11-17 14:31:05 -05:00
@dict &usage "usage: 20 "meta.rom 20 "game.rom 0a $1
2023-04-04 18:26:25 -04:00
&empty "Metadata 20 "Missing $1
2023-11-17 14:19:58 -05:00
@appicon [
2023-06-20 00:26:57 -04:00
0000 3f20 2020 2020 ffff ffff ffff ffff
0000 ff18 0000 0000 ffff ffff ffff ffff
0000 fc04 0404 0404 ffff ffff ffff ffff
2020 2030 3020 2020 ffff ffff ffff ffff
0000 0000 0000 0000 ffff ffff ffff ffff
0404 040c 0c04 0404 ffff ffff ffff ffff
2020 2020 203f 0000 ffff ffff ffff ffff
0000 0000 18ff 0000 ffff ffff ffff ffff
0404 0404 04fc 0000 ffff ffff ffff ffff ]
2023-11-17 14:19:58 -05:00
@font [
2023-06-20 00:26:57 -04:00
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 ]
@metadata &header $1
&start $3
&deo $2
&version $1
2023-04-04 18:26:25 -04:00
&body $100
2023-11-17 14:19:58 -05:00
&length $1
&fields $ff
2023-04-04 18:26:25 -04:00
&icon $90