uxn/projects/examples/gui.animation.usm

76 lines
1.7 KiB
Plaintext
Raw Normal View History

2021-04-21 15:00:31 -04:00
( GUI Animation )
2021-04-22 22:57:47 -04:00
%%^! { .% DEI } %%~! { .% DEO }
%%*! { .% DEI2 } %%=! { .% DEO2 }
%%^ { .% PEK } %%~ { .% POK }
%%* { .% PEK2 } %%= { .% POK2 }
2021-04-21 15:00:31 -04: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 &color $1 ]
|0000
2021-04-21 15:00:31 -04:00
@dvd [ &x $2 &y $2 &dx $1 &dy $1 ]
( program )
|0100 ( -> )
( theme )
2021-04-22 22:57:47 -04:00
#4cfd System/r=!
#4cf3 System/g=!
#dcf2 System/b=!
2021-04-21 15:00:31 -04:00
( vectors )
2021-04-22 22:57:47 -04:00
;on-frame Screen/vector=!
2021-04-21 15:00:31 -04:00
( starting position )
2021-04-22 22:57:47 -04:00
Screen/width*! #0002 DIV2 dvd/x=
Screen/height*! #0002 DIV2 dvd/y=
2021-04-21 15:00:31 -04:00
#21 ;draw-dvd JSR2
BRK
@on-frame ( -> )
( clear ) #20 ;draw-dvd JSR2
2021-04-22 22:57:47 -04:00
( case: hit-right ) dvd/x* Screen/width*! #0020 SUB2 EQU2
( case: hit-left ) dvd/x* #0000 EQU2
2021-04-21 15:00:31 -04:00
#0000 EQU2 ,&no-flipx JNZ
2021-04-22 22:57:47 -04:00
dvd/dx^ #00 EQU dvd/dx~ &no-flipx
( case: hit-bottom ) dvd/y* Screen/height*! #0010 SUB2 EQU2
( case: hit-top ) dvd/y* #0000 EQU2
2021-04-21 15:00:31 -04:00
#0000 EQU2 ,&no-flipy JNZ
2021-04-22 22:57:47 -04:00
dvd/dy^ #00 EQU dvd/dy~ &no-flipy
( incr ) dvd/x* #0001 #00 dvd/dx^ #00 EQU #fffe MUL2 ADD2 ADD2 dvd/x=
( incr ) dvd/y* #0001 #00 dvd/dy^ #00 EQU #fffe MUL2 ADD2 ADD2 dvd/y=
2021-04-21 15:00:31 -04:00
( draw ) #21 ;draw-dvd JSR2
BRK
@draw-dvd ( color -- )
2021-04-22 22:57:47 -04:00
( stash ) STH
;dvd_icn Screen/addr=!
dvd/y* [ dvd/y* #0010 ADD2 ]
2021-04-21 15:00:31 -04:00
&ver
2021-04-22 22:57:47 -04:00
OVR2 Screen/y=!
dvd/x* [ dvd/x* #0020 ADD2 ]
2021-04-21 15:00:31 -04:00
&hor
2021-04-22 22:57:47 -04:00
OVR2 Screen/x=!
( draw ) DUPr STHr Screen/color~!
( next ) Screen/addr*! #0008 ADD2 Screen/addr=!
2021-04-21 15:00:31 -04:00
( incr ) SWP2 #0008 ADD2 SWP2
OVR2 OVR2 LTH2 ,&hor JNZ
POP2 POP2
( incr ) SWP2 #0008 ADD2 SWP2
OVR2 OVR2 LTH2 ,&ver JNZ
POP2 POP2
2021-04-22 22:57:47 -04:00
( destroy ) POPr
2021-04-21 15:00:31 -04: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
]