uxn-utils/gui/dads/dads.tal

362 lines
12 KiB
Tal

( uxnemu life.rom )
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &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
|30 @Audio0 &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1
|80 @Controller &vector $2 &button $1 &key $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &wheel $1
|0000
@world &frame $1 &count $2
@anchor &x $2 &y $2 &x2 $2 &y2 $2
@pointer &x $2 &y $2
|0100 ( -> )
( theme )
#970f .System/r DEO2
#7d0f .System/g DEO2
#8c0f .System/b DEO2
( resize )
#0070 .Screen/width DEO2
#0088 .Screen/height DEO2
( vectors )
;on-mouse .Mouse/vector DEO2
draw-border
draw-blocks
BRK
(
@|vectors )
@on-mouse ( -> )
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn update-cursor
.Mouse/state DEI ?&on-touch
BRK
&on-touch ( -> )
.Mouse/x DEI2 #0008 SUB2 NIP #18 DIV
.Mouse/y DEI2 #0008 SUB2 NIP #18 DIV
try-move
#00 .Mouse/state DEO
BRK
(
@|core )
@pick ( x y -- <block>* )
,&t STR2
#0900
&l
#00 OVR #0006 MUL2 ;game ADD2 [ LIT2 &t $2 ] is-at ?&found
INC GTHk ?&l
POP2
#ffff
JMP2r
&found ( bounds* -- block* )
NIP #00 SWP #0006 MUL2 ;game ADD2
JMP2r
@is-at ( block* x y -- f )
OVR2 LDA2 STH2
SWP2 INC2 INC2 LDA2 SUB2
STHr LTH
SWP STHr LTH AND
JMP2r
@try-move ( x y -- )
pick DUP2 #ffff EQU2 ?&blank
OVR2 phex #0a18 DEO
( up )
DUP2 #00ff can-move phex/b #0a18 DEO
( right )
DUP2 #0001 can-move phex/b #0a18 DEO
( down )
DUP2 #0100 can-move phex/b #0a18 DEO
( left )
DUP2 #ff00 can-move phex/b #0a18 DEO
POP2
JMP2r
&blank ( block* -- )
POP2
JMP2r
@is-free ( x y -- f )
POP2 #00
JMP2r
@can-move ( block* x y -- f )
OVR2 ,&self STR2
OVR2 STH2 INC2r INC2r LDA2r
STHr ADD ,&offy STR
STHr ADD ,&offx STR
LDA2
,&height STR
,&width STR
[ LIT2 &height $1 00 ]
&v
STHk
[ LIT2 &width $1 00 ]
&h
DUP [ LIT &offx $1 ] ADD
STHkr [ LIT &offy $1 ] ADD
pick
DUP2 #ffff EQU2 ?&blank
DUP2 [ LIT2 &self $2 ] EQU2 ?&blank
POP2 POP2 POP2 POPr #00 JMP2r
&blank
POP2
INC GTHk ?&h
POP2 POPr
INC GTHk ?&v
POP2
#01
JMP2r
@game ( size, pos ) [
&a 0202 0000 =draw-a
&b 0201 0200 =draw-b
&v 0201 0201 =draw-v
&w 0101 0002 =draw-w
&x 0101 0102 =draw-x
&d 0102 0003 =draw-d
&y 0102 0103 =draw-y
&z 0201 0203 =draw-z
&c 0201 0204 =draw-c ]
(
@|drawing )
@draw-blocks ( -- )
#0900
&l
#00 OVR draw-block
INC GTHk ?&l
POP2
JMP2r
@draw-block ( id* -- )
#0006 MUL2 ;game ADD2
INC2 INC2 LDA2k to-screen
INC2 INC2 LDA2 JSR2
JMP2r
@to-screen ( x y -- )
#00 SWP #0018 MUL2 #0008 ADD2 .Screen/y DEO2
#00 SWP #0018 MUL2 #0008 ADD2 .Screen/x DEO2
JMP2r
@draw-a ( -- ) ;blocks-chr/a .Screen/addr DEO2 #56 .Screen/auto DEO #06 !draw-times
@draw-x ( -- ) ;blocks-chr/x !draw-11
@draw-w ( -- ) ;blocks-chr/w
@draw-11 ( addr* -- ) .Screen/addr DEO2 #26 .Screen/auto DEO #03 !draw-times
@draw-c ( -- ) ;blocks-chr/c !draw-21
@draw-v ( -- ) ;blocks-chr/v !draw-21
@draw-z ( -- ) ;blocks-chr/z !draw-21
@draw-b ( -- ) ;blocks-chr/b
@draw-21 ( addr* -- ) .Screen/addr DEO2 #56 .Screen/auto DEO #03 !draw-times
@draw-y ( -- ) ;blocks-chr/y !draw-12
@draw-d ( -- ) ;blocks-chr/d
@draw-12 ( addr* -- ) .Screen/addr DEO2 #26 .Screen/auto DEO #06 !draw-times
@draw-times ( times -- )
#00 SWP SUB
&l
#81 .Screen/sprite DEO
INC DUP ?&l
POP
JMP2r
@draw-border ( -- )
( top corners )
#00 .Screen/auto DEO
#0000 .Screen/y DEO2
#0000 .Screen/x DEO2
;frame-chr/tl .Screen/addr DEO2
#81 .Screen/sprite DEO
#0068 .Screen/x DEO2
;frame-chr/tr .Screen/addr DEO2
#81 .Screen/sprite DEO
( bottom corners )
#0080 .Screen/y DEO2
#0000 .Screen/x DEO2
;frame-chr/bl .Screen/addr DEO2
#81 .Screen/sprite DEO
#0068 .Screen/x DEO2
;frame-chr/br .Screen/addr DEO2
#81 .Screen/sprite DEO
( hor lengths )
#b2 .Screen/auto DEO
#0008 .Screen/x DEO2
#0000 .Screen/y DEO2
;frame-chr/tc .Screen/addr DEO2
#81 .Screen/sprite DEO
#0080 .Screen/y DEO2
;frame-chr/bc .Screen/addr DEO2
#81 .Screen/sprite DEO
( ver lengths )
#e1 .Screen/auto DEO
#0000 .Screen/x DEO2
#0008 .Screen/y DEO2
;frame-chr/ml .Screen/addr DEO2
#81 .Screen/sprite DEO
#0068 .Screen/x DEO2
;frame-chr/mr .Screen/addr DEO2
#81 .Screen/sprite DEO
JMP2r
@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
(
@|stdlib )
@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
(
@|assets )
@cursor-icn
[ 80c0 e0f0 f8e0 1000 ]
@frame-chr
&tl [ 0000 0000 0101 0000 0000 001f 1f1f 1f1e ]
&tc [ 0000 0000 8383 0000 0000 00ff ffff ff00 ]
&tr [ 0000 0000 0000 0030 0000 00f8 f8f8 f878 ]
&ml [ 0c0c 0000 0000 000c 1e1e 1e1e 1e1e 1e1e ]
&mr [ 3000 0000 0000 3030 7878 7878 7878 7878 ]
&bl [ 0c00 0000 0000 0000 1e1f 1f1f 1f00 0000 ]
&bc [ 0000 c1c1 0000 0000 00ff ffff ff00 0000 ]
&br [ 0000 8080 0000 0000 78f8 f8f8 f800 0000 ]
@blocks-chr
&a [
003f 7b77 6f5c 7b7b 3f7f ffff ffff ffff 00df bb77 eedd 7b77 dfff ffff ffff ffff
00ff bb77 eedd bb77 ffff ffff ffff ffff 00ff bb77 eedd bbf7 ffff ffff ffff ffff
00ff bb77 eedd bb77 ffff ffff ffff ffff 00fc be76 eede ba76 fcfe ffff ffff ffff
6b58 7b7b 7b5b 3b7f ffff ffff ffff ffff 6e5d 7b77 6e5d 7bf7 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff fefd bb77 eedd bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eede ba76 eedc ba76 ffff ffff fffe ffff
6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff eefd bb77 eedd bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eedd bb77 eedd bb7f ffff ffff ffff ffff
eedf bb77 eedd bb77 ffff ffff ffff ffff eede ba76 eede ba76 ffff ffff ffff ffff
6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff eedd bb77 eedf bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eedd bb77 eedd bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eede ba76 eede ba76 ffff ffff ffff ffff
6e5d 7b77 6e5d 3b77 ffff ffff ffff 7fff eedd bb77 eedd bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eedd bb77 eedd bb77 ffff ffff ffff ffff
eedd bb77 fedd bb77 ffff ffff ffff ffff eede ba76 eede ba76 ffff ffff ffff ffff
6e5d 7b77 6e7d 3f00 ffff ffff ffff 7f3f eedd bb77 eedd ff00 ffff ffff ffff ffff
eedd bb77 eedd ff00 ffff ffff ffff ffff eedd bb77 eedd ff00 ffff ffff ffff ffff
eedd bb77 eedd bf00 ffff ffff ffff ffbf eede ba76 eede fc00 ffff ffff ffff fefc ]
&b [
003f 7d6e 777b 5d6e 3f7f ffff ffff ffff 00ff ddee 77bb ddee ffff ffff ffff ffff
00fb ddee 77bb ddee fbff ffff ffff ffff 00ff ddee 7fbb ddee ffff ffff ffff ffff
00ff ddee 77ba deee ffff ffff ffff ffff 00fc defe f63a dede fcfe ffff ffff ffff
777b 5d6e 777b 5d6e ffff ffff ffff ffff 77bf dfee 77bb ddee ffff ffff ffff ffff
77bb ddee 77bb ddee ffff ffff ffff ffff 77bb ddee 77bb ddee ffff ffff ffff ffff
76fa deee 76fa deef ffff ffff ffff ffff d63a dede d6da 3cfe ffff ffff ffff feff
777b 5f6e 777b 3f00 ffff ffff ffff 7f3f 77fb ddee 77bb ff00 ffff ffff ffff ffff
77bb ddee 77bb ff00 ffff ffff ffff ffff 77bb ddee 77bb fd00 ffff ffff ffff fffd
77bb ddee 77bb ff00 ffff ffff ffff ffff 76ba deee 76be fc00 ffff ffff ffff fefc ]
&v [
003f 7b77 6e5d 7b77 3f7f ffff ffff ffff 00fd bb77 eedd bb77 fdff ffff ffff ffff
00ff bb77 eedd bb77 ffff ffff ffff ffff 00ff bb77 eedd bb77 ffff ffff ffff ffff
00ff bb77 eedd bb77 ffff ffff ffff ffff 00fc be76 eedc ba76 fcfe ffff fffe ffff
6e5d 7b77 6f5d 7b77 ffff ffff ffff ffff eedd bb77 eedd bb77 ffff ffff ffff ffff
eedd fb77 eedd bb77 ffff ffff ffff ffff eedf bf77 eedd bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eede ba76 eede faf6 ffff ffff ffff ffff
6e5d 7b77 6e7d 3f00 ffff ffff ffff 7f3f eedd bb77 eedd bf00 ffff ffff ffff ffbf
eedd bb77 eedd ff00 ffff ffff ffff ffff eedd bb77 eedd ff00 ffff ffff ffff ffff
eedd bb77 eedd ff00 ffff ffff ffff ffff eede ba76 eede fc00 ffff ffff ffff fefc ]
&w [
003f 7b77 6e5d 7b77 3f7f ffff ffff ffff 00fd bb77 eedd bf77 fdff ffff ffff ffff
00fc be76 eede ba76 fcfe ffff ffff ffff 6e5d 7b77 6e5d 3b77 ffff ffff ffff 7fff
eedd bb77 dead db77 ffff ffff ffff ffff eede ba76 eede ba76 ffff ffff ffff ffff
6e5d 7b77 6e7d 3f00 ffff ffff ffff 7f3f eedd bb77 eedd ff00 ffff ffff ffff ffff
eede ba76 eede bc00 ffff ffff ffff febc ]
&x [
003f 7d6e 777b 5d6e 3f7f ffff ffff ffff 00ff ddee 77bb ddee ffff ffff ffff ffff
00fc deee 76ba deee fcfe ffff ffff ffff 777b 5d6e 7f7b 5d6e ffff ffff ffff ffff
77bb ddef 77bb ddee ffff ffff ffff ffff 76ba deee 76ba dcee ffff ffff ffff feff
777b 5d6e 777b 3f00 ffff ffff ffff 7f3f 77bb ddee 77bb ff00 ffff ffff ffff ffff
f6ba deee 76be fc00 ffff ffff ffff fefc ]
&d [
003f 7d6e 777b 5d6e 3f7f ffff ffff ffff 00ff ddee 77bb ddee ffff ffff ffff ffff
00fc deee 76ba deee fcfe ffff ffff ffff 777b 5d6e 777b 5d6e ffff ffff ffff ffff
77bb fdee 77bb ddfe ffff ffff ffff ffff 76ba deee 76ba deee ffff ffff ffff ffff
777b 5d6e 777b 5d6e ffff ffff ffff ffff 77bb ddee 77fb ddee ffff ffff ffff ffff
76ba deee 76ba deee ffff ffff ffff ffff 777b 5d6e 777b 5d6e ffff ffff ffff ffff
77bb ddee 77bb ddee ffff ffff ffff ffff 76ba deee 76ba deee ffff ffff ffff ffff
7778 5b6b 7b7b 5b6b ffff ffff ffff ffff f7fb 5d6e 777b 5f6e ffff ffff ffff ffff
76ba deee 76ba defe ffff ffff ffff ffff 7b7b 586f 777b 3f00 ffff ffff ffff 7f3f
777b ddee 77bb fd00 ffff ffff ffff fffd 76ba deee 76be fc00 ffff ffff ffff fefc ]
&y [
003f 7b77 6e5d 7b77 3f7f ffff ffff ffff 00ff bb77 eedd bf77 ffff ffff ffff ffff
00dc be76 eede ba76 dcfe ffff ffff ffff 6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff
eefd bb77 eedd bb77 ffff ffff ffff ffff eede ba76 eede ba76 ffff ffff ffff ffff
6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff eedd bb77 eedd bb77 ffff ffff ffff ffff
eede ba76 eede ba76 ffff ffff ffff ffff 6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff eede ba76 eede ba76 ffff ffff ffff ffff
6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff fedf bbff eedd bb77 ffff ffff ffff ffff
eede fa76 eede ba76 ffff ffff ffff ffff 6e5d 7b77 6e7d 3f00 ffff ffff ffff 7f3f
eedd bb77 eedd ff00 ffff ffff ffff ffff fefe ba76 eede fc00 ffff ffff ffff fefc ]
&z [
003f 7d6e 777b 5f6e 3f7f ffff ffff ffff 00ff ddee 77bb ddee ffff ffff ffff ffff
00ff ddee 77bb ddee ffff ffff ffff ffff 00ff ddee 77bb ddee ffff ffff ffff ffff
00bf ddee 77bb dfee bfff ffff ffff ffff 00fc deee 76ba deee fcfe ffff ffff ffff
777b 5d6e 777b 5d6e ffff ffff ffff ffff 77bb ddee 77bb ddee ffff ffff ffff ffff
77bb ddee 77bb dfee ffff ffff ffff ffff 77bb ddee 77bb ddee ffff ffff ffff ffff
77bb ddee 77bb dfee ffff ffff ffff ffff 76ba deee 76ba deee ffff ffff ffff ffff
777b 5d6e 777b 3f00 ffff ffff ffff 7f3f 77bb ddee 77bb ff00 ffff ffff ffff ffff
77bb ddee 77bb ff00 ffff ffff ffff ffff 77bb ddee 77bb ff00 ffff ffff ffff ffff
77bb ddee 77bb ff00 ffff ffff ffff ffff 76ba deee 76be fc00 ffff ffff ffff fefc ]
&c [
003f 7b77 6e5d 7b77 3f7f ffff ffff ffff 00df bb77 eedd bf77 dfff ffff ffff ffff
00ff bb77 eedd bb77 ffff ffff ffff ffff 00ff bb77 eedd bf77 ffff ffff ffff ffff
00ff bb77 eedd bb77 ffff ffff ffff ffff 00fc be76 eede ba76 fcfe ffff ffff ffff
6e5d 7b77 6e5d 7b77 ffff ffff ffff ffff fedd bb77 eedd bb77 ffff ffff ffff ffff
eedd bb77 eedd bb77 ffff ffff ffff ffff fedd bb77 eedd bf77 ffff ffff ffff ffff
efdf ba76 eede ba76 ffff ffff ffff ffff fe3e dad6 fefc faf6 ffff ffff fffe ffff
6e5d 7b77 6e7d 3f00 ffff ffff ffff 7f3f eedd bb77 eedd fb00 ffff ffff ffff fffb
eedd bb77 eedd ff00 ffff ffff ffff ffff eedd bb77 eedd ff00 ffff ffff ffff ffff
eede bb77 eedd ff00 ffff ffff ffff ffff dede 3af6 eede fc00 ffff ffff ffff fefc ]