From 33738a7cc9f9311de0c6f76c3b3f53d52b65bb2d Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 22 Aug 2019 12:21:18 -0400 Subject: [PATCH] ootw: aliens can shoot. also make laser collision code generic --- ootw/TODO | 7 ++++++ ootw/alien.s | 8 ++++++- ootw/alien_laser.s | 12 ++++++++++ ootw/blast.s | 5 +++++ ootw/collision.s | 28 ++++++++++------------- ootw/laser.s | 33 +++++++++++++++++++++++----- ootw/ootw_c5.s | 1 + ootw/ootw_graphics/sprites/alien.inc | 16 ++++++++++++++ ootw/zp.inc | 6 ++--- 9 files changed, 90 insertions(+), 26 deletions(-) diff --git a/ootw/TODO b/ootw/TODO index ff672253..145c4fd6 100644 --- a/ootw/TODO +++ b/ootw/TODO @@ -9,6 +9,11 @@ TODO Before release: l2 -- move doors to final behavior (break room one needs to be locked) + l2 -- re-activate opening cutscene + + l2 -- shield up in alien hallway + + shooting through shield is broken MISSING SPRITES: ================ @@ -45,6 +50,8 @@ BEHAVIOR DIFFERENCES: we call down. also I think if you wait long enough more aliens appear if you try to go left. + - should be able to crouch/shoot + - should be able to blast/shield * gun behavior: - doors/walls should explode outward away from blast diff --git a/ootw/alien.s b/ootw/alien.s index fffe6844..430e8e83 100644 --- a/ootw/alien.s +++ b/ootw/alien.s @@ -179,8 +179,14 @@ done_move_alien_standing: ; shooting move_alien_shooting: - + lda FRAMEL + and #$3f + bne done_alien_shooting_now + + jsr fire_alien_laser + +done_alien_shooting_now: jmp done_move_alien diff --git a/ootw/alien_laser.s b/ootw/alien_laser.s index 0cd9b07a..af2a4ddc 100644 --- a/ootw/alien_laser.s +++ b/ootw/alien_laser.s @@ -22,6 +22,11 @@ fire_alien_laser: lda laser1_out bne done_fire_alien_laser + lda alien_x,X + sta COLLISION_X + lda alien_y,X + sta COLLISION_Y + ; activate laser slot inc laser1_out @@ -51,9 +56,12 @@ fire_alien_laser: ; set x alien_laser_left: + stx LASER_TEMP jsr calc_gun_left_collision + ldx LASER_TEMP + lda alien_x,X ; dex sta laser1_end @@ -67,8 +75,12 @@ alien_laser_left: alien_laser_right: + stx LASER_TEMP + jsr calc_gun_right_collision + ldx LASER_TEMP + lda alien_x,X clc adc #5 diff --git a/ootw/blast.s b/ootw/blast.s index 7f3f4998..8d8bd200 100644 --- a/ootw/blast.s +++ b/ootw/blast.s @@ -16,6 +16,11 @@ fire_blast: lda blast0_out bne done_fire_blast + lda PHYSICIST_X + sta COLLISION_X + lda PHYSICIST_Y + sta COLLISION_Y + ; activate blast slot inc blast0_out diff --git a/ootw/collision.s b/ootw/collision.s index cd9b8f88..aa23e478 100644 --- a/ootw/collision.s +++ b/ootw/collision.s @@ -4,10 +4,6 @@ TARGET_SHIELD = $20 TARGET_FRIEND = $30 TARGET_ALIEN = $40 -; FIXME!!!! -; if doors/aliens/shields then stop check if X passing them. URGH. - - ;============================= ;============================= @@ -140,10 +136,10 @@ calc_gun_right_door_loop: lda (DOOR_Y),Y clc adc #4 - cmp PHYSICIST_Y + cmp COLLISION_Y bne calc_gun_right_door_continue - lda PHYSICIST_X + lda COLLISION_X cmp (DOOR_X),Y bcs calc_gun_right_door_continue ; bge @@ -188,7 +184,7 @@ calc_gun_right_shield_loop: lda shield_out,X beq calc_gun_right_shield_continue - lda PHYSICIST_X + lda COLLISION_X cmp shield_x,X bcs calc_gun_right_shield_continue ; bge @@ -225,7 +221,7 @@ calc_gun_right_friend: cmp WHICH_ROOM bne done_calc_gun_right_friend_collision - lda PHYSICIST_X + lda COLLISION_X cmp friend_x bcs calc_gun_right_friend_continue ; bge @@ -269,10 +265,10 @@ calc_gun_right_alien_loop: ; only if on same level lda alien_y,X - cmp PHYSICIST_Y + cmp COLLISION_Y bne calc_gun_right_alien_continue - lda PHYSICIST_X + lda COLLISION_X cmp alien_x,X bcs calc_gun_right_alien_continue ; bge @@ -354,10 +350,10 @@ calc_gun_left_door_loop: lda (DOOR_Y),Y clc adc #4 - cmp PHYSICIST_Y + cmp COLLISION_Y bne calc_gun_left_door_continue - lda PHYSICIST_X + lda COLLISION_X cmp (DOOR_X),Y bcc calc_gun_left_door_continue ; blt @@ -400,7 +396,7 @@ calc_gun_left_shield_loop: lda shield_out,X beq calc_gun_left_shield_continue - lda PHYSICIST_X + lda COLLISION_X cmp shield_x,X bcc calc_gun_left_shield_continue ; blt @@ -438,7 +434,7 @@ calc_gun_left_friend: cmp WHICH_ROOM bne done_calc_gun_left_friend_collision - lda PHYSICIST_X + lda COLLISION_X cmp friend_x bcc calc_gun_left_friend_continue ; blt @@ -482,10 +478,10 @@ calc_gun_left_alien_loop: ; only if on same level lda alien_y,X - cmp PHYSICIST_Y + cmp COLLISION_Y bne calc_gun_left_alien_continue - lda PHYSICIST_X + lda COLLISION_X cmp alien_x,X bcc calc_gun_left_alien_continue ; blt diff --git a/ootw/laser.s b/ootw/laser.s index 5c9553ec..863a1b54 100644 --- a/ootw/laser.s +++ b/ootw/laser.s @@ -13,6 +13,8 @@ ; should handle shooting while crouching +MAX_LASERS = 2 + laser_out: laser0_out: .byte $0 laser1_out: .byte $0 @@ -42,6 +44,10 @@ laser1_count: .byte $0 ;========================= fire_laser: + lda PHYSICIST_X + sta COLLISION_X + lda PHYSICIST_Y + sta COLLISION_Y lda laser0_out bne done_fire_laser @@ -112,33 +118,48 @@ done_fire_laser: rts + + ;==================== ; draw laser ;==================== draw_laser: - lda laser0_out + ldx #0 +draw_laser_loop: + lda laser_out,X beq done_draw_laser + txa + pha ; save X on stack + lda #$10 sta hlin_color_smc+1 lda #$0f sta hlin_mask_smc+1 - ldy laser0_y + ldy laser_y,X sec - lda laser0_end - sbc laser0_start - tax + lda laser_end,X + sbc laser_start,X + sta LASER_TEMP - lda laser0_start + lda laser_start,X + + ldx LASER_TEMP jsr hlin + pla ; restore X from stack + tax + done_draw_laser: + inx + cpx #MAX_LASERS + bne draw_laser_loop rts diff --git a/ootw/ootw_c5.s b/ootw/ootw_c5.s index 79dcb456..ce6c14a6 100644 --- a/ootw/ootw_c5.s +++ b/ootw/ootw_c5.s @@ -97,6 +97,7 @@ end_message: .include "gun.s" .include "laser.s" +.include "alien_laser.s" .include "blast.s" .include "shield.s" diff --git a/ootw/ootw_graphics/sprites/alien.inc b/ootw/ootw_graphics/sprites/alien.inc index dde6e0c7..a7283e73 100644 --- a/ootw/ootw_graphics/sprites/alien.inc +++ b/ootw/ootw_graphics/sprites/alien.inc @@ -581,4 +581,20 @@ alien_disintegrating_14: ; 8 +;===================== +;===================== +; SHOOTING +;===================== +;===================== + +alien_shoot_sprite: + .byte $5,$8 + .byte $aa,$7a,$f7,$7f,$aa + .byte $aa,$77,$07,$00,$aa + .byte $0a,$aa,$00,$77,$aa + .byte $aa,$a7,$17,$10,$aa + .byte $aa,$aa,$00,$00,$aa + .byte $aa,$aa,$77,$a5,$5a + .byte $aa,$aa,$07,$aa,$05 + .byte $aa,$0a,$00,$0a,$00 diff --git a/ootw/zp.inc b/ootw/zp.inc index d4752be3..be5b530d 100644 --- a/ootw/zp.inc +++ b/ootw/zp.inc @@ -56,9 +56,6 @@ LETTERD = $67 LETTER = $68 BLARGH = $69 - -;ZPOS = $78 - AY_REGISTERS = $70 A_FINE_TONE = $70 A_COARSE_TONE = $71 @@ -94,6 +91,8 @@ PT3_TEMP = $8A ; More zero-page addresses ; we try not to conflict with anything DOS, MONITOR or BASIC related +COLLISION_X = $BE +COLLISION_Y = $BF DOOR_STATUS = $C0 DOOR_STATUS_H = $C1 @@ -111,6 +110,7 @@ BEAST_DEAD = $CB ; 1 VENT_OPEN = $CC ; 2 INTRO_REPEAT = $CD ; INTRO +LASER_TEMP = $CE ; 2+ LEFT_SHOOT_TARGET = $CF ; ALL RIGHT_SHOOT_TARGET = $D0 ; ALL