uxn-utils/gui/dads/dads.tal

350 lines
12 KiB
Tal
Raw Normal View History

2023-05-22 00:31:53 -04:00
( 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
|0100 ( -> )
( theme )
#970f .System/r DEO2
#7d0f .System/g DEO2
#8c0f .System/b DEO2
( resize )
2023-05-22 13:12:48 -04:00
#0070 .Screen/width DEO2
#0088 .Screen/height DEO2
2023-05-22 00:31:53 -04:00
( vectors )
;on-mouse .Mouse/vector DEO2
2023-05-22 13:12:48 -04:00
draw-border
2023-05-22 13:31:19 -04:00
draw-blocks
2023-05-22 00:31:53 -04:00
BRK
2023-05-22 13:12:48 -04:00
(
@|vectors )
2023-05-22 00:31:53 -04:00
@on-mouse ( -> )
2023-05-22 15:14:16 -04:00
[ LIT2 00 -Mouse/state ] DEI NEQ #41 ADD ;cursor-icn update-cursor
2023-05-22 13:31:19 -04:00
.Mouse/state DEI ?&on-touch
BRK
&on-touch ( -> )
.Mouse/x DEI2 #0008 SUB2 NIP #18 DIV
.Mouse/y DEI2 #0008 SUB2 NIP #18 DIV
2023-05-22 20:22:24 -04:00
;try-move ;try-move/cc .Mouse/state DEI #01 GTH [ JMP SWP2 POP2 ] JSR2
2023-05-22 13:31:19 -04:00
#00 .Mouse/state DEO
2023-05-22 00:31:53 -04:00
BRK
2023-05-22 14:43:47 -04:00
(
@|core )
@pick ( x y -- <block>* )
2023-05-22 19:44:50 -04:00
( clamp )
DUP #04 GTH ?&bounds
OVR #03 GTH ?&bounds
2023-05-22 14:43:47 -04:00
,&t STR2
#0900
&l
#00 OVR #0006 MUL2 ;game ADD2 [ LIT2 &t $2 ] is-at ?&found
INC GTHk ?&l
POP2
#ffff
JMP2r
2023-05-22 19:44:50 -04:00
&bounds ( bounds* -- 0* )
POP2 #0000
JMP2r
2023-05-22 14:43:47 -04:00
&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
2023-05-22 15:14:16 -04:00
@try-move ( x y -- )
2023-05-22 19:44:50 -04:00
pick
DUP2 #ffff EQU2 ?&blank
DUP2 #0000 EQU2 ?&blank
2023-05-22 20:12:43 -04:00
( up ) #00ff OVR2 OVR2 can-move ?&move POP2
( down ) #0100 OVR2 OVR2 can-move ?&move POP2
( left ) #ff00 OVR2 OVR2 can-move ?&move POP2
( right ) #0001 OVR2 OVR2 can-move ?&move POP2
2023-05-22 19:38:14 -04:00
POP2
2023-05-22 15:14:16 -04:00
JMP2r
2023-05-22 20:12:43 -04:00
&cc ( x y -- )
pick
DUP2 #ffff EQU2 ?&blank
DUP2 #0000 EQU2 ?&blank
( right ) #0001 OVR2 OVR2 can-move ?&move POP2
( left ) #ff00 OVR2 OVR2 can-move ?&move POP2
( down ) #0100 OVR2 OVR2 can-move ?&move POP2
( up ) #00ff OVR2 OVR2 can-move ?&move POP2
POP2
JMP2r
2023-05-22 20:00:58 -04:00
&move ( block* xy -- )
SWP2 STH2k clear-block
INC2r INC2r
SWP
LDAkr STHr ADD STH2kr STA INC2r
LDAkr STHr ADD STH2r STA
2023-05-22 20:22:24 -04:00
!draw-blocks
2023-05-22 15:14:16 -04:00
&blank ( block* -- )
POP2
JMP2r
@can-move ( block* x y -- f )
2023-05-22 19:38:14 -04:00
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
2023-05-22 13:31:19 -04:00
JMP2r
2023-05-22 13:12:48 -04:00
(
@|drawing )
2023-05-22 13:31:19 -04:00
@draw-blocks ( -- )
#0900
&l
#00 OVR draw-block
INC GTHk ?&l
POP2
JMP2r
2023-05-22 20:00:58 -04:00
@clear-block ( id* -- )
#00 ;draw-times/color STA
INC2 INC2 LDA2k to-screen
INC2 INC2 LDA2 JSR2
#81 ;draw-times/color STA
JMP2r
2023-05-22 13:31:19 -04:00
@draw-block ( id* -- )
#0006 MUL2 ;game ADD2
INC2 INC2 LDA2k to-screen
2023-05-22 20:22:24 -04:00
INC2 INC2 LDA2
JMP2
2023-05-22 13:31:19 -04:00
@to-screen ( x y -- )
2023-05-22 14:00:37 -04:00
#00 SWP #0018 MUL2 #0008 ADD2 .Screen/y DEO2
#00 SWP #0018 MUL2 #0008 ADD2 .Screen/x DEO2
2023-05-22 13:31:19 -04:00
JMP2r
2023-05-22 14:00:37 -04:00
@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
2023-05-22 20:22:24 -04:00
@draw-12 ( addr* -- ) .Screen/addr DEO2 #26 .Screen/auto DEO #06 ( >> )
2023-05-22 13:12:48 -04:00
@draw-times ( times -- )
#00 SWP SUB
&l
2023-05-22 20:00:58 -04:00
[ LIT &color 81 ] .Screen/sprite DEO
2023-05-22 13:12:48 -04:00
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
2023-05-22 13:31:19 -04:00
(
2023-05-22 20:22:24 -04:00
@|state )
2023-05-22 13:31:19 -04:00
2023-05-22 20:22:24 -04:00
@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 ]
2023-05-22 13:12:48 -04:00
(
@|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 ]
2023-05-22 00:31:53 -04:00
@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 ]