ootw: c4: laser right works

This commit is contained in:
Vince Weaver 2019-08-09 23:01:15 -04:00
parent 65351ca19c
commit 1369a3aeda

View File

@ -12,10 +12,10 @@
laser0_out: .byte $0 laser0_out: .byte $0
laser0_start: .byte $0 laser0_start: .byte $0
laser0_end: .byte $0 laser0_length: .byte $0
laser0_y: .byte $0 laser0_y: .byte $0
laser0_direction: .byte $0 laser0_direction: .byte $0
laser0_count: .byte $0
;========================= ;=========================
; fire laser ; fire laser
@ -26,8 +26,15 @@ fire_laser:
lda laser0_out lda laser0_out
bne done_fire_laser bne done_fire_laser
; activate laser slot
inc laser0_out inc laser0_out
; reset count
lda #0
sta laser0_count
; set y ; set y
lda PHYSICIST_Y lda PHYSICIST_Y
@ -35,6 +42,8 @@ fire_laser:
adc #4 adc #4
sta laser0_y sta laser0_y
; set direction
lda DIRECTION lda DIRECTION
sta laser0_direction sta laser0_direction
@ -43,15 +52,16 @@ fire_laser:
; set x ; set x
laser_left: laser_left:
ldx PHYSICIST_X lda PHYSICIST_X
dex sec
stx laser0_end sbc #10
lda #0
sta laser0_start sta laser0_start
lda #10
sta laser0_length
jmp done_fire_laser jmp done_fire_laser
laser_right: laser_right:
@ -61,10 +71,8 @@ laser_right:
adc #5 adc #5
sta laser0_start sta laser0_start
sec lda #10
lda #39 sta laser0_length
sbc TEMP
sta laser0_end
done_fire_laser: done_fire_laser:
rts rts
@ -86,7 +94,7 @@ draw_laser:
sta hlin_mask_smc+1 sta hlin_mask_smc+1
ldy laser0_y ldy laser0_y
ldx laser0_end ldx laser0_length
lda laser0_start lda laser0_start
jsr hlin jsr hlin
@ -104,23 +112,79 @@ move_laser:
lda laser0_out lda laser0_out
beq done_move_laser 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 lda laser0_start
clc clc
adc #10 adc #10
sta laser0_start 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 bcs disable_laser
lda laser0_start
clc clc
adc #20 adc laser0_length
cmp #40 cmp #40
bcc done_laser_len ; blt bcc no_move_laser
lda #39 lda #39
sec
sbc laser0_start
sta laser0_length
done_laser_len: no_move_laser:
sta laser0_end inc laser0_count
done_move_laser: done_move_laser: