git @ Cat's Eye Technologies SixtyPical / 439b827
Almost make the bouncing obstacles happen. It's... interesting. Chris Pressey 4 years ago
1 changed file(s) with 55 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
308308 //
309309
310310 routine enemy_logic
311 inputs pos, delta, joy2, screen
312 outputs pos, delta, screen, c
313 trashes a, x, y, z, n, v, ptr
314 {
315 copy ^screen, ptr
316 st off, c
317 add ptr, pos
318 ld y, 0
319
320 copy 82, [ptr] + y
311 inputs pos, delta, screen
312 outputs pos, delta, new_pos, screen, c
313 trashes a, x, y, z, n, v, ptr, compare_target
314 {
315 call calculate_new_position
316 call check_new_position_in_bounds
317
318 if c {
319 copy ^screen, ptr
320 st off, c
321 add ptr, new_pos
322 ld y, 0
323
324 // check collision.
325 copy [ptr] + y, a
326 // if "collision" is with your own self, treat it as if it's blank space!
327 cmp a, 82
328 if z {
329 ld a, 32
330 }
331 cmp a, 32
332 if z {
333 copy ^screen, ptr
334 st off, c
335 add ptr, pos
336 copy 32, [ptr] + y
337
338 copy new_pos, pos
339
340 copy ^screen, ptr
341 st off, c
342 add ptr, pos
343 copy 82, [ptr] + y
344
345 st off, c
346 } else {
347 st on, c
348 trash n
349 trash a
350 trash z
351 }
352
353 // FIXME these trashes, strictly speaking, probably shouldn't be needed,
354 // but currently the compiler cares too much about values that are
355 // initialized in one branch of an `if`, but not the other, but trashed
356 // at the end of the routine anyway.
357 trash ptr
358 trash y
359 trash a
360 } else {
361 copy word 0, compare_target
362 sub compare_target, delta
363 copy compare_target, delta
364 trash compare_target
365 }
321366
322367 st off, c
323368 }