diff --git a/ootw/Makefile b/ootw/Makefile index 7b54eb49..4beafc6f 100644 --- a/ootw/Makefile +++ b/ootw/Makefile @@ -68,6 +68,7 @@ ootw_c2.o: ootw_c2.s \ gr_copy.s gr_copy_offset.s gr_fast_clear.s gr_pageflip.s gr_unrle.s \ gr_hlin.s gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \ keyboard.s gr_run_sequence.s audio.s \ + alien_laser.s \ physicist.s alien.s friend.s \ collision.s door.s laser.s shield.s blast.s gun.s \ ootw_c2_miners.s \ @@ -105,7 +106,7 @@ ootw_c4.o: ootw_c4.s \ gr_unrle.s gr_hlin.s \ gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \ keyboard.s gr_run_sequence.s physicist.s \ - collision.s alien.s \ + collision.s alien.s alien_laser.s \ ootw_c4_city.s ootw_c4_action.s \ door.s laser.s shield.s blast.s gun.s charger.s \ ootw_graphics/sprites/physicist.inc \ diff --git a/ootw/alien.s b/ootw/alien.s index 6160b193..fffe6844 100644 --- a/ootw/alien.s +++ b/ootw/alien.s @@ -144,6 +144,13 @@ move_alien_standing: cmp alien_y,X bne done_move_alien_standing + ;================= + ; delay a bit so it doesn't happen instantaneously + + lda FRAMEL + and #$3f + bne done_move_alien_standing + lda PHYSICIST_X cmp alien_x,X bcs alien_face_right @@ -157,14 +164,23 @@ alien_face_right: alien_done_facing: sta alien_direction,X + ; change to shooting + + lda #A_SHOOTING + sta alien_state,X + done_move_alien_standing: + + jmp done_move_alien ;====================== ; shooting move_alien_shooting: + + jmp done_move_alien @@ -177,6 +193,7 @@ astate_table_lo: .byte alien_standing ; 00 @@ -187,6 +204,7 @@ astate_table_hi: .byte >alien_yelling ; 05 .byte >alien_shooting_up; 06 .byte >alien_disintegrating; 07 + .byte >alien_shooting ; 08 ; Urgh, make sure this doesn't end up at $FF or you hit the ; NMOS 6502 bug @@ -247,6 +265,20 @@ alien_standing: jmp finally_draw_alien +;================================== +; SHOOTING +;================================== + +alien_shooting: + + lda #alien_shoot_sprite + sta INH + + jmp finally_draw_alien + ;=================================== ; CROUCHING diff --git a/ootw/alien_laser.s b/ootw/alien_laser.s new file mode 100644 index 00000000..0cd9b07a --- /dev/null +++ b/ootw/alien_laser.s @@ -0,0 +1,84 @@ + +; Handle alien laser + +; uses laser1 slot + +; should handle multiple at once? + +;laser1_out: .byte $0 +;laser1_start: .byte $0 +;laser1_end: .byte $0 +;laser1_y: .byte $0 +;laser1_direction: .byte $0 +;laser1_count: .byte $0 + + ;========================= + ; fire alien laser + ;========================= + ; which alien in X + +fire_alien_laser: + + lda laser1_out + bne done_fire_alien_laser + + ; activate laser slot + + inc laser1_out + + ; reset count + + lda #0 + sta laser1_count + + ; set y + + ; assume for now no crouching + + lda alien_y,X + clc + adc #4 + sta laser1_y + + ; set direction + + lda alien_direction,X + sta laser1_direction + + beq alien_laser_left + bne alien_laser_right + + ; set x + +alien_laser_left: + + jsr calc_gun_left_collision + + lda alien_x,X +; dex + sta laser1_end + +; txa + sec + sbc #10 + sta laser1_start + + jmp done_fire_alien_laser + +alien_laser_right: + + jsr calc_gun_right_collision + + lda alien_x,X + clc + adc #5 + sta laser1_start + + clc + adc #10 + sta laser1_end + +done_fire_alien_laser: + rts + + diff --git a/ootw/laser.s b/ootw/laser.s index 00b45fdb..5c9553ec 100644 --- a/ootw/laser.s +++ b/ootw/laser.s @@ -13,12 +13,29 @@ ; should handle shooting while crouching +laser_out: laser0_out: .byte $0 +laser1_out: .byte $0 + +laser_start: laser0_start: .byte $0 +laser1_start: .byte $0 + +laser_end: laser0_end: .byte $0 +laser1_end: .byte $0 + +laser_y: laser0_y: .byte $0 +laser1_y: .byte $0 + +laser_direction: laser0_direction: .byte $0 +laser1_direction: .byte $0 + +laser_cout: laser0_count: .byte $0 +laser1_count: .byte $0 ;========================= ; fire laser diff --git a/ootw/ootw_c2.s b/ootw/ootw_c2.s index 69037de8..88983242 100644 --- a/ootw/ootw_c2.s +++ b/ootw/ootw_c2.s @@ -132,6 +132,7 @@ end_message: .include "gun.s" .include "blast.s" .include "laser.s" +.include "alien_laser.s" .include "shield.s" .include "door.s" .include "collision.s" diff --git a/ootw/ootw_c4.s b/ootw/ootw_c4.s index e9f7d630..da2942c9 100644 --- a/ootw/ootw_c4.s +++ b/ootw/ootw_c4.s @@ -110,6 +110,7 @@ end_message: .include "blast.s" .include "collision.s" .include "dummy_friend.s" +.include "alien_laser.s" .include "ootw_c4_action.s"