git @ Cat's Eye Technologies SixtyPical / cac23cc
Two kinds of actor. We now need vector tables! Cat's Eye Technologies 8 years ago
1 changed file(s) with 50 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
2929 reserve byte[16] actor_pos_lo
3030
3131 reserve vector dispatch_state
32
33 reserve byte[18] press_fire_msg: "PRESS FIRE TO PLAY"
32 reserve vector dispatch_logic
33
34 reserve byte[18] press_fire_msg: "PRESS`FIRE`TO`PLAY"
3435
3536 routine calculate_new_position outputs (new_position) {
3637 clc
141142 lda #$04
142143 sta actor_pos_hi, y
143144 tya
145 clc
146 asl .a
147 asl .a
144148 sta actor_pos_lo, y
145149 iny
146150 cpy #8
166170 jmp (save_cinv)
167171 }
168172
173 routine logic_player {
174 jsr read_stick
175 jsr calculate_new_position
176 jsr check_new_position_in_bounds
177 if bcs {
178 lda #32
179 ldy #0
180 sta (position), y
181 copy new_position position
182 lda #81
183 ldy #0
184 sta (position), y
185 } else { }
186 }
187
188 routine logic_obstacle {
189 lda #0
190 sta >delta
191 lda #1
192 sta <delta
193 jsr calculate_new_position
194 jsr check_new_position_in_bounds
195 if bcs {
196 lda #32
197 ldy #0
198 sta (position), y
199 copy new_position position
200 lda #82
201 ldy #0
202 sta (position), y
203 } else { }
204 }
205
206 routine indirect_jsr_logic {
207 jmp (dispatch_logic)
208 }
209
169210 routine state_play_game {
170211 reserve byte save_x
171212 ldx #0
177218 lda actor_pos_lo, x
178219 sta <position
179220
180 jsr read_stick
181 jsr calculate_new_position
182 jsr check_new_position_in_bounds
183 if bcs {
184 lda #32
185 ldy #0
186 sta (position), y
187 copy new_position position
188 lda #81
189 ldy #0
190 sta (position), y
191 } else { }
221 cpx #0
222 if beq {
223 copy routine logic_player to dispatch_logic
224 } else {
225 copy routine logic_obstacle to dispatch_logic
226 }
227 jsr indirect_jsr_logic
192228
193229 ldx save_x
194230 lda >position