From 354ed0e01310bd2021036a00e087f2e6fa357367 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 9 Apr 2022 21:22:18 -0400 Subject: [PATCH] lemm: handle falling into the water --- games/lemm/Makefile | 1 + games/lemm/level4.s | 6 ++++++ games/lemm/move_lemming.s | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/games/lemm/Makefile b/games/lemm/Makefile index 7fc21f56..0ea12403 100644 --- a/games/lemm/Makefile +++ b/games/lemm/Makefile @@ -169,6 +169,7 @@ lemm.inc: generate_common LEMM ./generate_common -a 0x6000 -s erase_pointer lemm.lst >> lemm.inc ./generate_common -a 0x6000 -s update_remaining lemm.lst >> lemm.inc ./generate_common -a 0x6000 -s update_remaining_all lemm.lst >> lemm.inc + ./generate_common -a 0x6000 -s collision_check_hazzard lemm.lst >> lemm.inc #### diff --git a/games/lemm/level4.s b/games/lemm/level4.s index 3e97a2a7..301a114d 100644 --- a/games/lemm/level4.s +++ b/games/lemm/level4.s @@ -251,6 +251,12 @@ l4_door_is_open: jsr move_lemmings + ;========================= + ; extra check if in water + + jsr collision_check_hazzard + + jsr draw_lemming jsr handle_keypress diff --git a/games/lemm/move_lemming.s b/games/lemm/move_lemming.s index a1fa856a..67bc4a5a 100644 --- a/games/lemm/move_lemming.s +++ b/games/lemm/move_lemming.s @@ -993,3 +993,45 @@ exit_y2_smc: not_done_level: rts + + + + + + ;============================= + ; check if hit hazzard + ;============================= + ; TODO: make configurable +collision_check_hazzard: + ldy #0 + sty CURRENT_LEMMING + +check_hazzard_loop: + ldy CURRENT_LEMMING + lda lemming_y,Y + cmp #130 + bcs in_hazzard + + bcc continue_check_hazzard + +in_hazzard: + + lda lemming_status,Y + cmp #LEMMING_SPLATTING + beq continue_check_hazzard ; don't re-splat + + lda #LEMMING_SPLATTING + sta lemming_status,Y + + lda #0 + sta lemming_frame,Y + +continue_check_hazzard: + + inc CURRENT_LEMMING + lda CURRENT_LEMMING + cmp #MAX_LEMMINGS + bne check_hazzard_loop + + rts +