uxn

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

drool.tal (5499B)


      1 (
      2 	100r animated logo splash screen
      3 	by Andrew Alderwick, 2021
      4 	based on artwork by Hundred Rabbits
      5 )
      6 
      7 ( devices )
      8 
      9 |00 @System     [ &vector $2 &wst      $1 &rst    $1 &pad   $4 &r      $2 &g      $2 &b    $2 &debug  $1 &halt $1 ]
     10 |20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &pixel  $1 &sprite $1 ]
     11 |c0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour  $1 &minute $1 &second $1 &dotw $1 &doty   $2 &isdst $1 ]
     12 
     13 ( variables )
     14 
     15 |0000
     16 
     17 ( program )
     18 
     19 |0100 @Reset ( -> )
     20 	( seed prng (must be nonzero) )
     21 	#00 .DateTime/second DEI
     22 	#00 .DateTime/minute DEI #60 SFT2 EOR2
     23 	#00 .DateTime/hour   DEI #c0 SFT2 EOR2 ;prng/x STA2
     24 	#00 .DateTime/hour   DEI #04 SFT2
     25 	#00 .DateTime/day    DEI DUP2 ADD2 EOR2
     26 	#00 .DateTime/month  DEI #60 SFT2 EOR2
     27 	    .DateTime/year  DEI2 #a0 SFT2 EOR2 ;prng/y STA2
     28 	;prng/x LDA2 ;prng/y LDA2 EOR2
     29 
     30 	LIT2r =rabbits #0f05 &loop-x
     31 		#0f05 &loop-y
     32 			ROTk SWP STH2kr STA2 POP
     33 			INC2r INC2r
     34 			INC
     35 			GTHk ,&loop-y JCN
     36 			POP2
     37 		INC
     38 		GTHk ,&loop-x JCN
     39 		POP2 POP2r
     40 	( fall through )
     41 
     42 @repeat
     43 	;init-occupancy JSR2
     44 	#00 ;precalc-frame STA
     45 	;precalculate-vector .Screen/vector DEO2
     46 	BRK
     47 
     48 @init-occupancy ( -- )
     49 	#1400 &loop-y
     50 		#1400 &loop-x
     51 			ROTk #00 ;set-occupied JSR2 POP
     52 			INC
     53 			GTHk ,&loop-x JCN
     54 			POP2
     55 		INC
     56 		GTHk ,&loop-y JCN
     57 		POP2
     58 	;rabbits
     59 	DUP2 #00c8 ADD2 SWP2 &loop-rabbits
     60 		LDA2k #01 ;set-occupied JSR2
     61 		INC2 INC2
     62 		GTH2k ,&loop-rabbits JCN
     63 		POP2 POP2
     64 	JMP2r
     65 
     66 @precalculate-vector ( -> )
     67 	,precalculate JSR BRK
     68 
     69 @precalculate ( -- )
     70 	;rabbits #00c8 OVR ,precalc-frame LDR MUL2 ADD2 ( first rabbit address )
     71 	DUP2 #00c8 ADD2 SWP2 &loop-rabbits
     72 		DUP2 ,move-rabbit JSR
     73 		INC2 INC2
     74 		GTH2k ,&loop-rabbits JCN
     75 		POP2 POP2
     76 	,precalc-frame LDR INC DUP ,precalc-frame STR
     77 		#05 EQU JMP JMP2r
     78 	;display-init JSR2
     79 	;display .Screen/vector DEO2
     80 	JMP2r
     81 
     82 @precalc-frame $1
     83 
     84 @set-occupied ( x y value -- )
     85 	STH
     86 	#00 SWP #0014 MUL2 ( x yoffset* / value )
     87 	ROT #00 SWP ADD2 ( offset* / value )
     88 	;occupied ADD2 STH2 STAr
     89 	JMP2r
     90 
     91 @move-rabbit ( addr* -- )
     92 	STH2k LDA2 ( x y / addr* )
     93 	DUP2 #00 ,set-occupied JSR
     94 	;&possible-moves ( x y possible* / addr* )
     95 	OVR2 #01   SUB  ,&check-move JSR ( up )
     96 	OVR2 INC   INC  ,&check-move JSR ( down )
     97 	OVR2 #0100 SUB2 ,&check-move JSR ( left )
     98 	OVR2 #0100 ADD2 ,&check-move JSR ( right )
     99 	;&possible-moves SUB2 ( x y num-possible-times-2* / addr* )
    100 	DUP ,&can-move JCN
    101 	POP2
    102 	&write ( x y / addr* )
    103 	DUP2 #01 ,set-occupied JSR
    104 	STH2r #00c8 ADD2 STA2
    105 	JMP2r
    106 
    107 	&can-move ( x y num-possible-times-2* / addr* )
    108 	NIP2 ( num-possible-times-2* / addr* )
    109 	,prng JSR SWP2 DIV2k MUL2 SUB2 #fe AND ( chosen-move* / addr* )
    110 	;&possible-moves ADD2 LDA2
    111 	,&write JMP
    112 
    113 	&check-move ( possible* new-x new-y -- possible'* )
    114 	DUP2 ,get-occupied JSR ,&blocked JCN
    115 	OVR2r LIT2r 00c8 SUB2r ( possible* new-x new-y / previous-frame-addr* )
    116 		&check-history-loop
    117 		;rabbits INC2 STH2kr GTH2 ,&history-okay JCN
    118 		DUP2 STH2kr LDA2 EQU2 ,&history-clash JCN
    119 		LIT2r 00c8 SUB2r
    120 		,&check-history-loop JMP
    121 	&history-okay
    122 	POP2r
    123 	OVR2 STA2 INC2 INC2
    124 	JMP2r
    125 	&history-clash ( possible* new-x new-y / previous-frame-addr* )
    126 	POP2r
    127 	&blocked ( possible* new-x new-y )
    128 	POP2
    129 	JMP2r
    130 
    131 	&possible-moves $10
    132 
    133 @get-occupied ( x y -- value )
    134 	#00 SWP #0014 MUL2 ( x yoffset* )
    135 	ROT #00 SWP ADD2 ( offset* )
    136 	;occupied ADD2 LDA
    137 	JMP2r
    138 
    139 @prng ( -- number* )
    140 	LIT2 &x $2
    141 	DUP2 #50 SFT2 EOR2
    142 	DUP2 #03 SFT2 EOR2
    143 	LIT2 &y $2 DUP2 ,&x STR2
    144 	DUP2 #01 SFT2 EOR2 EOR2
    145 	,&y STR2k POP
    146 	JMP2r
    147 
    148 @display-init ( -- )
    149 	.Screen/width  DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/xoffset STA2
    150 	.Screen/height DEI2 #01 SFT2 #0050 SUB2 ;display-rabbit/yoffset STA2
    151 	;rabbit-sprite .Screen/addr DEO2
    152 	JMP2r
    153 
    154 @display-rabbit ( color n counter -- )
    155 	OVR LTHk ,&finish JCN
    156 	SUB ( color n timeline )
    157 	DUP #63 GTH ,&start JCN
    158 	#17 DIVk STHk MUL SUB ( color n stage-timeline / frame )
    159 	DUP #07 GTH ,&static JCN
    160 	( rabbit is in-between two frames )
    161 	#08 OVR SUB ,&from-weight STR
    162 	,&to-weight STR ( color n / frame )
    163 	#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2 ( color from-addr* )
    164 	LDA2k STH2 #00c8 ADD2 LDA2
    165 	&draw ( color to-x to-y / from-x from-y )
    166 	STHr ,&mix JSR LIT2 &yoffset $2 ADD2 .Screen/y DEO2
    167 	STHr ,&mix JSR LIT2 &xoffset $2 ADD2 .Screen/x DEO2
    168 	.Screen/sprite DEO
    169 	JMP2r
    170 
    171 	&mix ( to-z from-z -- mixed* )
    172 	    #00 SWP LIT2 00 &from-weight 00 MUL2 ( to-n from-mixed* )
    173 	ROT #00 SWP LIT2 00 &to-weight   00 MUL2 ADD2
    174 	JMP2r
    175 
    176 	&finish ( color n counter n )
    177 	POP
    178 	LITr ff ,&static JMP
    179 	&start ( color n counter )
    180 	LITr 04
    181 	&static ( color n counter / frame )
    182 	INCr
    183 	POP
    184 	#00 SWP DUP2 ADD2 ;rabbits ADD2 #00c8 #00 STHr MUL2 ADD2
    185 	LDA2 STH2k
    186 	,&draw JMP
    187 
    188 @display-counter $1
    189 
    190 @display ( -> )
    191 	,display-counter LDR #01 SUB DUP ,display-counter STR
    192 	DUP #f0 LTH ,&skip-palette JCN
    193 	#ff OVR SUB #00
    194 		DUP2 .System/r DEO2
    195 		DUP2 .System/g DEO2
    196 		     .System/b DEO2
    197 	&skip-palette
    198 	INCk #0000 &clear-loop
    199 		ROTk ;display-rabbit JSR2
    200 		INC
    201 		DUP #64 LTH ,&clear-loop JCN
    202 		POP2 POP
    203 	#0500 &draw-loop
    204 		ROTk ;display-rabbit JSR2
    205 		INC
    206 		DUP #64 LTH ,&draw-loop JCN
    207 	POP2
    208 	,&no-finish JCN
    209 	;sunset .Screen/vector DEO2
    210 	&no-finish
    211 	BRK
    212 
    213 @sunset ( -> )
    214 	;display-counter LDA #02 SUB DUP ;display-counter STA
    215 	DUP #1f GTH ,&skip-palette JCN
    216 	DUP #01 SFT #00
    217 		DUP2 .System/r DEO2
    218 		DUP2 .System/g DEO2
    219 		     .System/b DEO2
    220 	#6400 &draw-loop
    221 		#05 OVR #00 ;display-rabbit JSR2
    222 		INC
    223 		GTHk ,&draw-loop JCN
    224 		POP2
    225 	&skip-palette
    226 	,&no-finish JCN
    227 	;repeat JMP2
    228 	&no-finish
    229 	BRK
    230 
    231 @rabbit-sprite 003c 7e7e 7e7e 3c00
    232 
    233 @occupied $190
    234 
    235 @rabbits
    236