0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-16 03:05:06 +00:00
uxn/projects/examples/gui/animation.tal

78 lines
1.7 KiB
Tal
Raw Normal View History

2021-04-21 19:00:31 +00:00
( GUI Animation )
2021-05-24 21:36:15 +00:00
%2// { #01 SFT2 }
( devices )
2021-04-21 19:00:31 +00:00
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ]
2021-04-21 19:00:31 +00:00
|0000
2021-04-21 19:00:31 +00:00
@dvd [ &x $2 &y $2 &dx $1 &dy $1 ]
( program )
|0100 ( -> )
( theme )
#4cfd .System/r DEO2
#4cf3 .System/g DEO2
#dcf2 .System/b DEO2
2021-04-29 04:00:39 +00:00
2021-04-21 19:00:31 +00:00
( vectors )
;on-frame .Screen/vector DEO2
2021-04-29 04:00:39 +00:00
2021-04-21 19:00:31 +00:00
( starting position )
2021-05-24 21:36:15 +00:00
.Screen/width DEI2 2// .dvd/x STZ2
.Screen/height DEI2 2// .dvd/y STZ2
2021-04-29 04:00:39 +00:00
#01 ;draw-dvd JSR2
2021-04-21 19:00:31 +00:00
BRK
@on-frame ( -> )
( clear ) #00 ;draw-dvd JSR2
2021-05-11 18:14:52 +00:00
( case: hit-right ) .dvd/x LDZ2 .Screen/width DEI2 #0020 SUB2 EQU2
( case: hit-left ) .dvd/x LDZ2 #0000 EQU2
2021-05-11 18:12:07 +00:00
#0000 EQU2 ,&no-flipx JCN
2021-05-11 18:14:52 +00:00
.dvd/dx LDZ #00 EQU .dvd/dx STZ &no-flipx
( case: hit-bottom ) .dvd/y LDZ2 .Screen/height DEI2 #0010 SUB2 EQU2
( case: hit-top ) .dvd/y LDZ2 #0000 EQU2
2021-05-11 18:12:07 +00:00
#0000 EQU2 ,&no-flipy JCN
2021-05-11 18:14:52 +00:00
.dvd/dy LDZ #00 EQU .dvd/dy STZ &no-flipy
( incr ) .dvd/x LDZ2 #0001 #00 .dvd/dx LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/x STZ2
( incr ) .dvd/y LDZ2 #0001 #00 .dvd/dy LDZ #00 EQU DUP2 ADD2 SUB2 ADD2 .dvd/y STZ2
( draw ) #01 ;draw-dvd JSR2
2021-04-21 19:00:31 +00:00
BRK
@draw-dvd ( color -- )
2021-04-23 02:57:47 +00:00
( stash ) STH
;dvd_icn .Screen/addr DEO2
2021-08-18 02:17:47 +00:00
[ .dvd/y LDZ2 #0010 ADD2 ] .dvd/y LDZ2
2021-04-21 19:00:31 +00:00
&ver
2021-08-18 02:17:47 +00:00
DUP2 .Screen/y DEO2
[ .dvd/x LDZ2 #0020 ADD2 ] .dvd/x LDZ2
2021-04-21 19:00:31 +00:00
&hor
2021-08-18 02:17:47 +00:00
DUP2 .Screen/x DEO2
( draw ) STHkr .Screen/sprite DEO
( next ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
2021-08-18 02:17:47 +00:00
( incr ) #0008 ADD2
GTH2k ,&hor JCN
2021-04-21 19:00:31 +00:00
POP2 POP2
2021-08-18 02:17:47 +00:00
( incr ) #0008 ADD2
GTH2k ,&ver JCN
2021-04-21 19:00:31 +00:00
POP2 POP2
2021-04-23 02:57:47 +00:00
( destroy ) POPr
2021-04-21 19:00:31 +00:00
JMP2r
@dvd_icn [
001f 3f38 3838 787f 00fe fe7e 7777 e3c3
000f 1f3b 7b77 e7c7 00fc fe8f 8707 0efc
7f00 000f ff7f 0700 0301 00ff f0f8 ff00
8700 00ff 7f7f ff00 f000 00e0 fcfc 8000
]