From 12c5b1921cab2eda42434984a89fe7dc8788db91 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 20 Aug 2019 13:49:27 -0400 Subject: [PATCH] ootw: c2: can now shoot friend (if going right) --- ootw/collision.s | 103 ++++++++++++++++++++++++++++++++++++++++++-- ootw/dummy_friend.s | 16 +++++++ ootw/friend.s | 17 ++++---- ootw/ootw_c2_jail.s | 4 +- ootw/ootw_c4.s | 1 + ootw/ootw_c5.s | 2 +- 6 files changed, 128 insertions(+), 15 deletions(-) create mode 100644 ootw/dummy_friend.s diff --git a/ootw/collision.s b/ootw/collision.s index 79159eba..19e27f94 100644 --- a/ootw/collision.s +++ b/ootw/collision.s @@ -96,7 +96,7 @@ done_recalc_walk_right_collision: ;============================= ;============================= ; far right limit is LEVEL_RIGHT - ; any LOCKED or CLOSED doors stop things + ; any LOCKED or CLOSED doors with SAME_Y to left of LEVEL_RIGHT ; any shield stops things ; our friend stops things ; any enemies stop things @@ -106,6 +106,9 @@ calc_gun_right_collision: lda #$00 sta RIGHT_SHOOT_TARGET + ;===================================================================== + ; by default set it to left limit (which is often but not always a wall) + lda RIGHT_LIMIT and #$7f sta RIGHT_SHOOT_LIMIT @@ -123,8 +126,14 @@ calc_gun_right_doors: ldy #0 calc_gun_right_door_loop: - lda PHYSICIST_X + ; only if on same level + lda (DOOR_Y),Y + clc + adc #4 + cmp PHYSICIST_Y + bne calc_gun_right_door_continue + lda PHYSICIST_X cmp (DOOR_X),Y bcs calc_gun_right_door_continue ; bge @@ -153,6 +162,86 @@ calc_gun_right_door_continue: done_calc_gun_right_door_collision: + ;========================== + ; adjust for shield + +calc_gun_right_shield: + + lda SHIELD_OUT + beq done_calc_gun_right_shield_collision + + ldx #0 +calc_gun_right_shield_loop: + + ; FIXME: check for on same level? + + lda shield_out,X + beq calc_gun_right_shield_continue + + lda PHYSICIST_X + cmp shield_x,X + bcs calc_gun_right_shield_continue ; bge + + ; be sure closer than current max limit + lda RIGHT_SHOOT_LIMIT + cmp shield_x,X + bcc calc_gun_right_shield_continue ; blt + +calc_gun_right_shield_there: + + lda shield_x,X + sta RIGHT_SHOOT_LIMIT + + txa ; set target if hit + ora #TARGET_SHIELD + sta RIGHT_SHOOT_TARGET + + ; can't early exit + +calc_gun_right_shield_continue: + inx + cpx #MAX_SHIELDS + bne calc_gun_right_shield_loop + +done_calc_gun_right_shield_collision: + + + ;========================== + ; adjust for friend + +calc_gun_right_friend: + + lda friend_room + cmp WHICH_ROOM + bne done_calc_gun_right_friend_collision + + lda PHYSICIST_X + cmp friend_x + bcs calc_gun_right_friend_continue ; bge + + ; only if closer than previous found + lda RIGHT_SHOOT_LIMIT + cmp friend_x + bcc calc_gun_right_friend_continue ; blt + + lda friend_state + cmp #F_DISINTEGRATING + beq calc_gun_right_friend_continue + +calc_gun_right_friend_there: + ; early exit + lda friend_x + sta RIGHT_SHOOT_LIMIT + + ; set target if hit + lda #TARGET_FRIEND + sta RIGHT_SHOOT_TARGET + +calc_gun_right_friend_continue: + +done_calc_gun_right_friend_collision: + + ;========================== ; adjust for alien @@ -172,12 +261,16 @@ calc_gun_right_alien_loop: cmp alien_x,X bcs calc_gun_right_alien_continue ; bge + ; only if closer than previous found + lda RIGHT_SHOOT_LIMIT + cmp alien_x,X + bcc calc_gun_right_alien_continue ; blt + lda alien_state,X cmp #A_DISINTEGRATING beq calc_gun_right_alien_continue calc_gun_right_alien_there: - ; early exit lda alien_x,X sta RIGHT_SHOOT_LIMIT @@ -185,7 +278,7 @@ calc_gun_right_alien_there: ora #TARGET_ALIEN sta RIGHT_SHOOT_TARGET - jmp done_calc_gun_right_alien_collision + ; can't early exit calc_gun_right_alien_continue: inx @@ -193,6 +286,8 @@ calc_gun_right_alien_continue: bne calc_gun_right_alien_loop done_calc_gun_right_alien_collision: + + rts diff --git a/ootw/dummy_friend.s b/ootw/dummy_friend.s new file mode 100644 index 00000000..d62c46fc --- /dev/null +++ b/ootw/dummy_friend.s @@ -0,0 +1,16 @@ +; Include on levels where there is no friend + + +F_STANDING = 0 +F_WALKING = 1 +F_RUNNING = 2 +F_CROUCHING = 3 +F_TURNING = 4 +F_KEYPAD = 5 +F_OPEN_VENT = 6 +F_DISINTEGRATING= 7 + +friend_state: +friend_x: +friend_room: +.byte $ff diff --git a/ootw/friend.s b/ootw/friend.s index 46eb7495..57ecd074 100644 --- a/ootw/friend.s +++ b/ootw/friend.s @@ -8,6 +8,11 @@ friend_gait: .byte 0 friend_direction: .byte 0 friend_ai_state: .byte 0 +FAI_FOLLOWING = 0 +FAI_RUNTO_PANEL = 1 +FAI_OPENING_PANEL = 2 +FAI_END_L2 = 3 + F_STANDING = 0 F_WALKING = 1 F_RUNNING = 2 @@ -17,14 +22,6 @@ F_KEYPAD = 5 F_OPEN_VENT = 6 F_DISINTEGRATING= 7 - -FAI_FOLLOWING = 0 -FAI_RUNTO_PANEL = 1 -FAI_OPENING_PANEL = 2 -FAI_END_L2 = 3 - - - fai_table_lo: .byte