Make game more interesting (and 544 bytes long...)
Cat's Eye Technologies
8 years ago
18 | 18 | |
19 | 19 | reserve vector save_cinv |
20 | 20 | |
21 | // these are zero-page so that we can use them as indirect addresses | |
22 | // through which we write to screen memory | |
21 | 23 | assign word position $fb |
22 | 24 | assign word new_position $fd |
23 | 25 | |
26 | 28 | reserve word compare_target |
27 | 29 | |
28 | 30 | reserve word[16] actor_pos |
31 | reserve word[16] actor_delta | |
29 | 32 | |
30 | 33 | reserve vector dispatch_state |
31 | 34 | reserve vector dispatch_logic |
42 | 45 | sta >new_position |
43 | 46 | } |
44 | 47 | |
48 | // output is carry | |
45 | 49 | routine compare_new_pos { |
46 | 50 | lda >new_position |
47 | 51 | cmp >compare_target |
52 | 56 | } |
53 | 57 | } |
54 | 58 | |
59 | // output is carry | |
55 | 60 | routine check_new_position_in_bounds { |
56 | 61 | copy #$07e8 compare_target // just past bottom of screen |
57 | 62 | jsr compare_new_pos |
91 | 96 | } |
92 | 97 | } |
93 | 98 | |
94 | routine read_stick { | |
99 | routine read_stick outputs (delta) { | |
95 | 100 | lda #0 |
96 | 101 | sta <delta |
97 | 102 | sta >delta |
144 | 149 | asl .a |
145 | 150 | asl .a |
146 | 151 | copy .a <actor_pos, y |
152 | ||
153 | // sigh | |
154 | // copy #$0001 actor_delta, y | |
155 | copy #00 >actor_delta, y | |
156 | copy #40 <actor_delta, y | |
157 | ||
147 | 158 | iny |
148 | 159 | cpy #8 |
149 | 160 | } |
183 | 194 | } else { } |
184 | 195 | } |
185 | 196 | |
197 | routine reverse_delta { | |
198 | lda #40 | |
199 | cmp <delta | |
200 | if beq { | |
201 | // copy #-40 delta | |
202 | lda #216 | |
203 | sta <delta | |
204 | lda #255 | |
205 | sta >delta | |
206 | } else { | |
207 | // copy #40 delta | |
208 | lda #40 | |
209 | sta <delta | |
210 | lda #0 | |
211 | sta >delta | |
212 | } | |
213 | } | |
214 | ||
186 | 215 | routine logic_obstacle { |
187 | lda #0 | |
188 | sta >delta | |
189 | lda #1 | |
190 | sta <delta | |
191 | 216 | jsr calculate_new_position |
192 | 217 | jsr check_new_position_in_bounds |
193 | 218 | if bcs { |
198 | 223 | lda #82 |
199 | 224 | ldy #0 |
200 | 225 | sta (position), y |
201 | } else { } | |
226 | } else { | |
227 | jsr reverse_delta | |
228 | } | |
202 | 229 | } |
203 | 230 | |
204 | 231 | routine indirect_jsr_logic { |
212 | 239 | stx save_x |
213 | 240 | |
214 | 241 | copy actor_pos, x position |
242 | copy actor_delta, x delta | |
215 | 243 | |
216 | 244 | cpx #0 |
217 | 245 | if beq { |
223 | 251 | |
224 | 252 | ldx save_x |
225 | 253 | copy position actor_pos, x |
254 | copy delta actor_delta, x | |
226 | 255 | |
227 | 256 | inx |
228 | 257 | cpx #8 |