uxn/projects/examples/demos/polycat.tal

168 lines
3.7 KiB
Tal
Raw Normal View History

2021-04-30 15:08:24 -04:00
( polycat )
%RTN { JMP2r }
2021-05-24 17:36:15 -04:00
%2// { #01 SFT2 }
%4// { #02 SFT2 }
2021-04-30 15:08:24 -04:00
( devices )
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ]
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ]
2021-05-31 18:08:34 -04:00
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
2021-04-30 15:08:24 -04:00
( variables )
|0000
@cat [ &x $2 &y $2 &timer $1 ]
@pointer [ &x $2 &y $2 ]
( program )
|0100 ( -> )
( theme )
#0a3f .System/r DEO2
#05df .System/g DEO2
#0caf .System/b DEO2
( find center )
2021-05-24 17:36:15 -04:00
.Screen/width DEI2 2// #0008 SUB2 .cat/x STZ2
.Screen/height DEI2 4// #0003 MUL2 #0018 SUB2 .cat/y STZ2
2021-04-30 15:08:24 -04:00
( vectors )
;on-mouse .Mouse/vector DEO2
;on-frame .Screen/vector DEO2
;draw-polycat JSR2
;draw-ground JSR2
BRK
@on-mouse ( -> )
;draw-cursor JSR2
2021-05-12 14:58:31 -04:00
.Mouse/x DEI2 .cat/x LDZ2 GTH2 #20 MUL
.Mouse/y DEI2 .cat/y LDZ2 GTH2 #40 MUL
2021-05-01 12:13:14 -04:00
ADD #00 SWP ;draw-eye JSR2
2021-04-30 15:08:24 -04:00
BRK
@on-frame ( -> )
2021-05-11 14:14:52 -04:00
.cat/timer LDZ #01 ADD [ DUP ] .cat/timer STZ
DUP ,&skip0 JCN #0000 ;draw-tail JSR2 &skip0
2021-05-11 14:12:07 -04:00
DUP #10 NEQ ,&skip1 JCN #0001 ;draw-tail JSR2 &skip1
DUP #20 NEQ ,&skip2 JCN #0002 ;draw-tail JSR2 &skip2
DUP #30 NEQ ,&skip3 JCN #0003 ;draw-tail JSR2 &skip3
DUP #40 NEQ ,&skip4 JCN #0002 ;draw-tail JSR2 &skip4
DUP #50 NEQ ,&skip5 JCN #0001 ;draw-tail JSR2 &skip5
2021-04-30 15:08:24 -04:00
POP
BRK
@draw-polycat ( -- )
( ears )
2021-05-11 14:14:52 -04:00
.cat/y LDZ2 .Screen/y DEO2
2021-05-12 21:28:45 -04:00
.cat/x LDZ2 STH2k #0008 SUB2 .Screen/x DEO2
2021-04-30 15:08:24 -04:00
;ears .Screen/addr DEO2
#41 .Screen/color DEO
2021-05-01 12:13:14 -04:00
STH2r .Screen/x DEO2
2021-05-12 14:58:31 -04:00
;ears #0010 ADD2 .Screen/addr DEO2
2021-04-30 15:08:24 -04:00
#41 .Screen/color DEO
2021-05-01 12:13:14 -04:00
#0000 ,draw-eye JSR
#0000 ,draw-tail JSR
2021-04-30 15:08:24 -04:00
RTN
@draw-eye ( quad* -- )
2021-05-12 14:58:31 -04:00
.cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
2021-05-12 21:28:45 -04:00
.cat/x LDZ2 STH2k #0008 SUB2 .Screen/x DEO2
2021-05-12 14:58:31 -04:00
DUP2 ;eye ADD2 .Screen/addr DEO2
2021-05-01 12:13:14 -04:00
( draw ) #41 .Screen/color DEO
STH2r .Screen/x DEO2
2021-05-12 14:58:31 -04:00
;eye #0010 ADD2 ADD2 .Screen/addr DEO2
2021-05-01 12:13:14 -04:00
( draw ) #41 .Screen/color DEO
2021-04-30 15:08:24 -04:00
RTN
@draw-tail ( frame* -- )
2021-05-12 14:58:31 -04:00
.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
2021-05-12 21:28:45 -04:00
.cat/x LDZ2 STH2k #0008 SUB2 .Screen/x DEO2
2021-04-30 15:08:24 -04:00
;body .Screen/addr DEO2
2021-05-01 12:13:14 -04:00
( draw ) #41 .Screen/color DEO
STH2r .Screen/x DEO2
2021-05-12 14:58:31 -04:00
#0010 MUL2 ;body #0010 ADD2 ADD2 .Screen/addr DEO2
2021-05-01 12:13:14 -04:00
( draw ) #41 .Screen/color DEO
2021-04-30 15:08:24 -04:00
RTN
@draw-cursor ( -- )
( clear last cursor )
2021-05-06 13:38:38 -04:00
;cursor .Screen/addr DEO2
2021-05-11 14:14:52 -04:00
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
2021-04-30 15:08:24 -04:00
#30 .Screen/color DEO
2021-05-01 12:13:14 -04:00
2021-04-30 15:08:24 -04:00
( record pointer positions )
2021-07-09 14:38:45 -04:00
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
2021-05-01 12:13:14 -04:00
2021-04-30 15:08:24 -04:00
( colorize on state )
#31 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/color DEO
RTN
@draw-ground ( -- )
2021-05-12 14:58:31 -04:00
.cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
2021-04-30 15:08:24 -04:00
;ground .Screen/addr DEO2
#00 #10
&loop
2021-05-01 12:13:14 -04:00
( draw ) #21 .Screen/color DEO
2021-05-12 14:58:31 -04:00
( sety ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
( setx ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
2021-05-01 12:13:14 -04:00
( incr ) SWP #01 ADD SWP
2021-05-12 14:58:31 -04:00
LTHk ,&loop JCN
2021-04-30 15:08:24 -04:00
POP2
RTN
2021-05-12 21:28:45 -04:00
@cursor
80c0 e0f0 f8e0 1000
2021-04-30 15:08:24 -04:00
2021-05-12 21:28:45 -04:00
@ears
2021-04-30 15:08:24 -04:00
081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
2021-05-12 21:28:45 -04:00
081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f
2021-04-30 15:08:24 -04:00
2021-05-12 21:28:45 -04:00
@eye
2021-04-30 15:08:24 -04:00
ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
ffff ffff fffe fcf0 87c3 c183 071e fcf0
ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
ffff ffff fffe fcf0 0783 c1c3 871e fcf0
ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
2021-05-12 21:28:45 -04:00
@body
2021-04-30 15:08:24 -04:00
0707 0707 0302 0200 0107 0707 0300 0000
e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
0707 0707 0f08 1000 0307 0707 0f00 0000
2021-05-12 21:28:45 -04:00
e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400
2021-04-30 15:08:24 -04:00
2021-05-12 21:28:45 -04:00
@ground
2021-05-01 12:13:14 -04:00
bf00 5c02 0202 020c ef10 6f90 8080 8074
2021-05-12 21:28:45 -04:00
ff00 fe01 0100 0116 fd00 3c40 4040 4028