2 ; Copyright (C) 2010 Kent Hansen.
4 ; This program is free software; you can redistribute it and/or modify
5 ; it under the terms of the GNU General Public License as published by
6 ; the Free Software Foundation; either version 3 of the License, or
7 ; (at your option) any later version.
9 ; This program is distributed in the hope that it will be useful,
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ; GNU General Public License for more details.
14 ; You should have received a copy of the GNU General Public License
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 .
include "common/sprite.h"
30 .
public initialize_starfield
31 .
public update_starfield
33 .
proc initialize_starfield
34 jsr initialize_target_lists
51 .
proc calculate_manhattan_length
52 lda targets_1.pos_y.
int,y
55 lda targets_1.pos_x.
int,y
61 + sta manhattan_length
78 and #
$18 : lsr
: lsr
: lsr
81 lda targets_1.pos_y.
int,y
84 lda targets_1.pos_x.
int,y
93 and #
$18 : lsr
: lsr
: lsr
96 lda targets_1.pos_y.
int,y
99 lda targets_1.pos_x.
int,y
108 ldy active_targets_head
111 cpy #
$FF ; end of list?
118 lda targets_1.pos_y.
int,y
122 lda targets_1.pos_x.
int,y
127 jsr calculate_manhattan_length
139 lda free_targets_list
141 sty free_targets_list
143 ; remove from active targets list
144 cpy active_targets_tail
146 sta active_targets_tail
151 sty active_targets_head
153 + sta targets_2.next
,x
157 .
proc maybe_spawn_star
163 ; grab target from free list
164 ldx free_targets_list
167 ; don't spawn, no free targets now
169 + lda targets_2.next
,x
170 sta free_targets_list
173 sta targets_1.pos_y.frac
,x
174 sta targets_1.pos_x.frac
,x
184 lda
@@quadrant_start_y_hi,y
185 sta targets_1.pos_y.
int,x
186 lda
@@quadrant_start_x_hi,y
187 sta targets_1.pos_x.
int,x
193 sta targets_2.speed_y.frac
,x
195 sta targets_2.speed_y.
int,x
197 sta targets_2.speed_x.frac
,x
199 sta targets_2.speed_x.
int,x
205 lda targets_2.speed_x.frac
,x
208 sta targets_2.speed_x.frac
,x
209 lda targets_2.speed_x.
int,x
212 sta targets_2.speed_x.
int,x
217 lda targets_2.speed_y.frac
,x
220 sta targets_2.speed_y.frac
,x
221 lda targets_2.speed_y.
int,x
224 sta targets_2.speed_y.
int,x
225 + jmp add_to_active_targets_list
226 @@quadrant_start_x_hi:
228 @@quadrant_start_y_hi:
231 .
db $19,$39,$59,$79,$99,$B9,$D9,$F9
233 .
db $00,$00,$00,$00,$00,$00,$00,$00
235 .
db $FE,$F9,$EF,$E1,$CC,$B0,$86,$38
237 .
db $00,$00,$00,$00,$00,$00,$00,$00
240 .
db 0+0,8+6,16+5,24+4
241 .
db 0+3,8+2,16+7,24+7
242 .
db 0+1,8+5,16+4,24+5
243 .
db 0+6,8+7,16+0,24+2
244 .
db 0+2,8+4,16+3,24+6
245 .
db 0+5,8+0,16+1,24+1
246 .
db 0+7,8+3,16+6,24+3
247 .
db 0+4,8+1,16+2,24+0
249 .
db 0+0,8+1,16+2,24+3
250 .
db 0+4,8+5,16+6,24+7
251 .
db 0+1,8+2,16+3,24+0
252 .
db 0+5,8+6,16+7,24+4
253 .
db 0+2,8+3,16+0,24+1
254 .
db 0+6,8+7,16+4,24+5
255 .
db 0+3,8+0,16+1,24+2
256 .
db 0+7,8+4,16+5,24+6
260 .
proc update_starfield