From 1369a3aedabd18e6ae4a85f0d7bd978497ffa06d Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 9 Aug 2019 23:01:15 -0400 Subject: [PATCH] ootw: c4: laser right works --- ootw/laser.s | 100 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 18 deletions(-) diff --git a/ootw/laser.s b/ootw/laser.s index 3668b59f..867de550 100644 --- a/ootw/laser.s +++ b/ootw/laser.s @@ -12,10 +12,10 @@ laser0_out: .byte $0 laser0_start: .byte $0 -laser0_end: .byte $0 +laser0_length: .byte $0 laser0_y: .byte $0 laser0_direction: .byte $0 - +laser0_count: .byte $0 ;========================= ; fire laser @@ -26,8 +26,15 @@ fire_laser: lda laser0_out bne done_fire_laser + ; activate laser slot + inc laser0_out + ; reset count + + lda #0 + sta laser0_count + ; set y lda PHYSICIST_Y @@ -35,6 +42,8 @@ fire_laser: adc #4 sta laser0_y + ; set direction + lda DIRECTION sta laser0_direction @@ -43,15 +52,16 @@ fire_laser: ; set x - laser_left: - ldx PHYSICIST_X - dex - stx laser0_end - lda #0 + lda PHYSICIST_X + sec + sbc #10 sta laser0_start + lda #10 + sta laser0_length + jmp done_fire_laser laser_right: @@ -61,10 +71,8 @@ laser_right: adc #5 sta laser0_start - sec - lda #39 - sbc TEMP - sta laser0_end + lda #10 + sta laser0_length done_fire_laser: rts @@ -86,7 +94,7 @@ draw_laser: sta hlin_mask_smc+1 ldy laser0_y - ldx laser0_end + ldx laser0_length lda laser0_start jsr hlin @@ -104,23 +112,79 @@ move_laser: lda laser0_out beq done_move_laser + ; slow down laser + lda laser0_count + and #$3 + bne no_move_laser + + lda laser0_direction + bne move_laser_right + +move_laser_left: + + lda laser0_count + and #$fe + beq still_shooting_left + +continue_shooting_left: + lda laser0_start + sec + sbc #20 + sta laser0_start + +still_shooting_left: + lda #20 + sta laser0_length + +laser_edge_detect_left: + + lda laser0_start + clc + adc laser0_length + bmi disable_laser + + jmp no_move_laser + + +move_laser_right: + + lda laser0_count + cmp #4 + bcc still_starting_right + cmp #8 + bcc still_shooting_right + +continue_shooting_right: lda laser0_start clc adc #10 sta laser0_start - cmp #39 + +still_shooting_right: + lda #20 + sta laser0_length + +still_starting_right: + +laser_edge_detect_right: + + ; detect if totally off screen + lda laser0_start + cmp #40 bcs disable_laser - lda laser0_start clc - adc #20 + adc laser0_length cmp #40 - bcc done_laser_len ; blt + bcc no_move_laser lda #39 + sec + sbc laser0_start + sta laser0_length -done_laser_len: - sta laser0_end +no_move_laser: + inc laser0_count done_move_laser: