0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-12-02 02:27:25 +00:00
uxn/projects/examples/demos/polycat.tal

146 lines
3.4 KiB
Tal
Raw Normal View History

2022-03-25 19:05:11 +00:00
( Polycat:
A cat with one eye, and the hind and tail of a lizard.
Original character by Rekka Bellum )
2021-04-30 19:08:24 +00:00
2022-03-25 19:05:11 +00:00
|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixeld $1 &sprite $1
|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
2021-04-30 19:08:24 +00:00
|0000
2022-03-25 19:05:11 +00:00
@cat &x $2 &y $2 &timer $1
@pointer &x $2 &y $2
2021-04-30 19:08:24 +00:00
|0100 ( -> )
2022-03-14 03:39:03 +00:00
( theme )
#0a3f .System/r DEO2
#05df .System/g DEO2
2021-04-30 19:08:24 +00:00
#0caf .System/b DEO2
2022-01-03 18:19:08 +00:00
( DOS resolution )
#0140 .Screen/width DEO2
#00c8 .Screen/height DEO2
2021-04-30 19:08:24 +00:00
( vectors )
;on-mouse .Mouse/vector DEO2
2022-01-03 18:19:08 +00:00
( find center )
2022-03-14 03:39:03 +00:00
.Screen/width DEI2 #01 SFT2 .cat/x STZ2
.Screen/height DEI2 #01 SFT2 .cat/y STZ2
2022-03-25 19:05:11 +00:00
( draw ground )
#f6 .Screen/auto DEO
.cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
;ground .Screen/addr DEO2
#01 .Screen/sprite DEO
2022-01-03 18:19:08 +00:00
( init )
#ff ;draw-eye/last STA
#ff ;draw-tail/last STA
2022-03-25 19:05:11 +00:00
( set screen mode auto-x )
#05 .Screen/auto DEO
2022-01-03 18:19:08 +00:00
,draw-polycat JSR
2021-04-30 19:08:24 +00:00
BRK
@draw-polycat ( -- )
( ears )
2021-05-11 18:14:52 +00:00
.cat/y LDZ2 .Screen/y DEO2
2022-01-03 18:19:08 +00:00
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
2021-04-30 19:08:24 +00:00
;ears .Screen/addr DEO2
2022-01-03 18:19:08 +00:00
#81 .Screen/sprite DEOk DEO
( body )
.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
;body .Screen/addr DEO2
#81 .Screen/sprite DEO
2022-01-03 18:19:08 +00:00
( eye/tail )
#00 ,draw-eye JSR
2022-08-14 19:17:44 +00:00
#00 ;draw-tail ( .. )
2021-04-30 19:08:24 +00:00
2022-08-14 19:17:44 +00:00
JMP2
2021-04-30 19:08:24 +00:00
2022-01-03 18:19:08 +00:00
@on-mouse ( -> )
2021-04-30 19:08:24 +00:00
2022-01-03 18:19:08 +00:00
.Mouse/x DEI2 .cat/x LDZ2 GTH2 #50 SFT
.Mouse/y DEI2 .cat/y LDZ2 GTH2 #60 SFT
ADD ,draw-eye JSR
.cat/timer LDZ INC [ DUP ] .cat/timer STZ
#04 SFT ,draw-tail JSR
,draw-cursor JSR
2021-04-30 19:08:24 +00:00
2022-01-03 18:19:08 +00:00
BRK
2021-04-30 19:08:24 +00:00
2022-01-03 18:19:08 +00:00
@draw-eye ( quad -- )
DUP ,&last LDR NEQ ,&changed JCN
POP JMP2r &changed
( only redraw on change )
#00 OVR ;eye ADD2 .Screen/addr DEO2
2022-01-03 18:19:08 +00:00
.cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
#81 .Screen/sprite DEOk DEO
,&last STR
JMP2r
&last $1
@draw-tail ( frame -- )
2022-03-14 16:55:31 +00:00
STHk ,&last LDR NEQ ,&changed JCN
POPr JMP2r &changed
2022-01-03 18:19:08 +00:00
( only redraw on change )
2022-03-14 16:55:31 +00:00
STHr #00 OVR ;frames ADD2 LDA
2022-03-14 03:39:03 +00:00
#00 SWP #40 SFT2 ;body/tail ADD2
2022-01-03 18:19:08 +00:00
.Screen/addr DEO2
.cat/x LDZ2 .Screen/x DEO2
2021-05-12 18:58:31 +00:00
.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
2022-01-03 18:19:08 +00:00
#81 .Screen/sprite DEO
,&last STR
2021-04-30 19:08:24 +00:00
2022-01-03 18:19:08 +00:00
JMP2r
&last $1
2021-04-30 19:08:24 +00:00
@draw-cursor ( -- )
2022-01-03 18:19:08 +00:00
( last cursor )
2022-03-14 03:39:03 +00:00
;cursor STH2k .Screen/addr DEO2
.pointer/x LDZ2 .Screen/x DEO2
.pointer/y LDZ2 .Screen/y DEO2
#40 .Screen/sprite DEO
2022-01-03 18:19:08 +00:00
( new cursor )
2022-03-14 03:39:03 +00:00
STH2r .Screen/addr DEO2
2021-07-09 18:38:45 +00:00
.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
2022-03-14 03:39:03 +00:00
.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
2022-01-03 18:19:08 +00:00
#41 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO
2021-05-01 16:13:14 +00:00
2022-01-03 18:19:08 +00:00
JMP2r
2021-04-30 19:08:24 +00:00
2022-03-14 03:39:03 +00:00
@cursor
80c0 e0f0 f8e0 1000
2022-01-03 18:19:08 +00:00
@frames
00 01 02 03 02 01 00 00
00 00 00 00 00 00 00 00
2022-03-14 03:39:03 +00:00
@ears
2021-04-30 19:08:24 +00:00
081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
2022-03-14 03:39:03 +00:00
081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f
@eye
2021-04-30 19:08:24 +00: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
2022-03-14 03:39:03 +00:00
@body
2021-04-30 19:08:24 +00:00
0707 0707 0302 0200 0107 0707 0300 0000
2022-01-03 18:19:08 +00:00
&tail
2021-04-30 19:08:24 +00:00
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
2022-03-14 03:39:03 +00:00
e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400
@ground
2021-05-01 16:13:14 +00:00
bf00 5c02 0202 020c ef10 6f90 8080 8074
2022-03-14 03:39:03 +00:00
ff00 fe01 0100 0116 fd00 3c40 4040 4028