uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

polycat.tal (3458B)


      1 ( Polycat:
      2 	A cat with one eye, and the hind and tail of a lizard.
      3 	Original character by Rekka Bellum )
      4 
      5 |00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1
      6 |20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixeld $1 &sprite $1
      7 |90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2
      8 
      9 |0000
     10 
     11 @cat &x $2 &y $2 &timer $1
     12 @pointer &x $2 &y $2
     13 
     14 |0100 ( -> )
     15 	
     16 	( theme )
     17 	#0a3f .System/r DEO2
     18 	#05df .System/g DEO2
     19 	#0caf .System/b DEO2
     20 	( DOS resolution )
     21 	#0140 .Screen/width DEO2
     22 	#00c8 .Screen/height DEO2
     23 	( vectors )
     24 	;on-mouse .Mouse/vector DEO2
     25 	( find center )
     26 	.Screen/width DEI2 #01 SFT2 .cat/x STZ2
     27 	.Screen/height DEI2 #01 SFT2 .cat/y STZ2
     28 	( draw ground )
     29 	#f6 .Screen/auto DEO
     30 	.cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
     31 	.cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
     32 	;ground .Screen/addr DEO2
     33 	#01 .Screen/sprite DEO
     34 	( init )
     35 	#ff ;draw-eye/last STA
     36 	#ff ;draw-tail/last STA
     37 	( set screen mode auto-x )
     38 	#05 .Screen/auto DEO
     39 	,draw-polycat JSR
     40 
     41 BRK
     42 
     43 @draw-polycat ( -- )
     44 
     45 	( ears )
     46 	.cat/y LDZ2 .Screen/y DEO2
     47 	.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
     48 	;ears .Screen/addr DEO2
     49 	#81 .Screen/sprite DEOk DEO
     50 	( body )
     51 	.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
     52 	.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
     53 	;body .Screen/addr DEO2
     54 	#81 .Screen/sprite DEO
     55 	( eye/tail )
     56 	#00 ,draw-eye JSR
     57 	#00 ;draw-tail ( .. )
     58 
     59 JMP2
     60 
     61 @on-mouse ( -> )
     62 	
     63 	.Mouse/x DEI2 .cat/x LDZ2 GTH2 #50 SFT
     64 	.Mouse/y DEI2 .cat/y LDZ2 GTH2 #60 SFT
     65 		ADD ,draw-eye JSR
     66 	.cat/timer LDZ INC [ DUP ] .cat/timer STZ
     67 		#04 SFT ,draw-tail JSR
     68 	,draw-cursor JSR
     69 
     70 BRK
     71 
     72 @draw-eye ( quad -- )
     73 	
     74 	DUP ,&last LDR NEQ ,&changed JCN
     75 		POP JMP2r &changed
     76 	( only redraw on change )
     77 	#00 OVR ;eye ADD2 .Screen/addr DEO2
     78 	.cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
     79 	.cat/x LDZ2 #0008 SUB2 .Screen/x DEO2
     80 	#81 .Screen/sprite DEOk DEO
     81 	,&last STR
     82 
     83 JMP2r
     84 	&last $1
     85 
     86 @draw-tail ( frame -- )
     87 
     88 	STHk ,&last LDR NEQ ,&changed JCN
     89 		POPr JMP2r &changed
     90 	( only redraw on change )
     91 	STHr #00 OVR ;frames ADD2 LDA
     92 	#00 SWP #40 SFT2 ;body/tail ADD2
     93 		.Screen/addr DEO2
     94 	.cat/x LDZ2 .Screen/x DEO2
     95 	.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
     96 	#81 .Screen/sprite DEO
     97 	,&last STR
     98 
     99 JMP2r
    100 	&last $1
    101 
    102 @draw-cursor ( -- )
    103 	
    104 	( last cursor )
    105 	;cursor STH2k .Screen/addr DEO2
    106 	.pointer/x LDZ2 .Screen/x DEO2
    107 	.pointer/y LDZ2 .Screen/y DEO2
    108 	#40 .Screen/sprite DEO
    109 	( new cursor )
    110 	STH2r .Screen/addr DEO2
    111 	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2
    112 	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2
    113 	#41 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO
    114 
    115 JMP2r
    116 
    117 @cursor
    118 	80c0 e0f0 f8e0 1000
    119 @frames
    120 	00 01 02 03 02 01 00 00
    121 	00 00 00 00 00 00 00 00
    122 @ears
    123 	081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc
    124 	081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f
    125 @eye
    126 	ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f
    127 	ffff ffff fffe fcf0 87c3 c183 071e fcf0
    128 	ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f
    129 	ffff ffff fffe fcf0 f7fb f9f3 071e fcf0
    130 	ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f
    131 	ffff ffff fffe fcf0 0783 c1c3 871e fcf0
    132 	ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f
    133 	ffff ffff fffe fcf0 07f3 f9fb f71e fcf0
    134 @body
    135 	0707 0707 0302 0200 0107 0707 0300 0000
    136 	&tail
    137 	e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
    138 	e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000
    139 	e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000
    140 	e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000
    141 	0707 0707 0f08 1000 0307 0707 0f00 0000
    142 	e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400
    143 @ground
    144 	bf00 5c02 0202 020c ef10 6f90 8080 8074
    145 	ff00 fe01 0100 0116 fd00 3c40 4040 4028