dos33fsprogs/ootw/laser.s

300 lines
3.6 KiB
ArmAsm
Raw Normal View History

2019-08-15 20:27:02 +00:00
; FIXME: merge a lot of the target code
2019-08-10 01:46:04 +00:00
; Handle laser
2019-08-10 02:25:10 +00:00
; should handle multiple at once?
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
; when pressed, find empty slot?
; initially 10 wide, from gun to right or left
; expand to 20 wide
; stop when encounter door, enemy, or edge of screen
; should bounds check carefully
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
; should handle shooting while crouching
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
laser0_out: .byte $0
laser0_start: .byte $0
laser0_end: .byte $0
2019-08-10 02:25:10 +00:00
laser0_y: .byte $0
laser0_direction: .byte $0
2019-08-10 03:01:15 +00:00
laser0_count: .byte $0
2019-08-10 02:25:10 +00:00
;=========================
; fire laser
;=========================
fire_laser:
lda laser0_out
bne done_fire_laser
2019-08-10 03:01:15 +00:00
; activate laser slot
2019-08-10 02:25:10 +00:00
inc laser0_out
2019-08-10 03:01:15 +00:00
; reset count
lda #0
sta laser0_count
2019-08-10 02:25:10 +00:00
; set y
2019-08-10 01:46:04 +00:00
lda PHYSICIST_Y
clc
adc #4
2019-08-16 17:53:37 +00:00
ldx PHYSICIST_STATE
cpx #P_CROUCH_SHOOTING
bne laser_crouch_done
laser_crouch:
clc
adc #4
laser_crouch_done:
2019-08-10 02:25:10 +00:00
sta laser0_y
2019-08-10 01:46:04 +00:00
2019-08-10 03:01:15 +00:00
; set direction
2019-08-10 01:46:04 +00:00
lda DIRECTION
2019-08-10 02:25:10 +00:00
sta laser0_direction
2019-08-10 01:46:04 +00:00
beq laser_left
bne laser_right
2019-08-10 02:25:10 +00:00
; set x
2019-08-10 01:46:04 +00:00
laser_left:
2019-08-15 18:12:32 +00:00
jsr calc_gun_left_collision
ldx PHYSICIST_X
dex
stx laser0_end
txa
2019-08-10 03:01:15 +00:00
sec
sbc #10
2019-08-10 02:25:10 +00:00
sta laser0_start
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
jmp done_fire_laser
2019-08-10 01:46:04 +00:00
laser_right:
2019-08-15 18:12:32 +00:00
jsr calc_gun_right_collision
2019-08-10 01:46:04 +00:00
lda PHYSICIST_X
clc
adc #5
2019-08-10 02:25:10 +00:00
sta laser0_start
2019-08-10 01:46:04 +00:00
clc
adc #10
sta laser0_end
2019-08-10 02:25:10 +00:00
done_fire_laser:
rts
;====================
; draw laser
;====================
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
draw_laser:
2019-08-10 01:46:04 +00:00
2019-08-10 02:25:10 +00:00
lda laser0_out
beq done_draw_laser
lda #$10
sta hlin_color_smc+1
lda #$0f
sta hlin_mask_smc+1
ldy laser0_y
sec
lda laser0_end
sbc laser0_start
tax
2019-08-10 02:25:10 +00:00
lda laser0_start
2019-08-10 01:46:04 +00:00
jsr hlin
2019-08-10 02:25:10 +00:00
done_draw_laser:
2019-08-10 01:46:04 +00:00
rts
2019-08-10 02:25:10 +00:00
;===================
; move laser
;===================
move_laser:
lda laser0_out
beq done_move_laser
2019-08-10 03:01:15 +00:00
; 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
cmp #4
bcc still_starting_left
cmp #8
bcc still_shooting_left
2019-08-10 03:01:15 +00:00
continue_shooting_left:
still_shooting_left:
lda laser0_end
sec
sbc #10
sta laser0_end
still_starting_left:
2019-08-10 03:01:15 +00:00
lda laser0_start
sec
sbc #10
2019-08-10 03:01:15 +00:00
sta laser0_start
laser_edge_detect_left:
lda laser0_end
2019-08-15 18:12:32 +00:00
cmp LEFT_SHOOT_LIMIT
2019-08-15 20:27:02 +00:00
bmi disable_laser_left
2019-08-10 03:01:15 +00:00
lda laser0_start
2019-08-15 18:12:32 +00:00
cmp LEFT_SHOOT_LIMIT
bpl no_move_laser
2019-08-15 18:12:32 +00:00
lda LEFT_SHOOT_LIMIT
sta laser0_start
2019-08-10 03:01:15 +00:00
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:
2019-08-10 02:25:10 +00:00
lda laser0_start
clc
adc #10
sta laser0_start
2019-08-10 03:01:15 +00:00
still_shooting_right:
lda laser0_end
clc
adc #10
sta laser0_end
2019-08-10 03:01:15 +00:00
still_starting_right:
laser_edge_detect_right:
; detect if totally off screen
2019-08-10 02:25:10 +00:00
lda laser0_start
2019-08-15 18:12:32 +00:00
cmp RIGHT_SHOOT_LIMIT
2019-08-15 20:27:02 +00:00
bcs disable_laser_right
2019-08-10 03:01:15 +00:00
lda laser0_end
2019-08-15 18:12:32 +00:00
cmp RIGHT_SHOOT_LIMIT
2019-08-10 03:01:15 +00:00
bcc no_move_laser
2019-08-10 02:25:10 +00:00
2019-08-15 18:12:32 +00:00
lda RIGHT_SHOOT_LIMIT
sta laser0_end
2019-08-10 02:25:10 +00:00
2019-08-10 03:01:15 +00:00
no_move_laser:
inc laser0_count
2019-08-10 02:25:10 +00:00
done_move_laser:
rts
2019-08-15 20:27:02 +00:00
;===================
; hit something, left
2019-08-15 20:27:02 +00:00
;===================
disable_laser_left:
lda LEFT_SHOOT_TARGET
jmp hit_something_common
;====================
; hit something, right
;====================
disable_laser_right:
lda RIGHT_SHOOT_TARGET
;======================
; hit something, common
;======================
hit_something_common:
; disable laser
ldx #0
stx laser0_out
2019-08-15 20:27:02 +00:00
tax
and #$f0
cmp #TARGET_ALIEN
beq laser_hit_alien
cmp #TARGET_FRIEND
beq laser_hit_friend
; FIXME: reduce shields if hit them?
jmp done_hit_something
2019-08-15 20:27:02 +00:00
laser_hit_alien:
2019-08-15 20:27:02 +00:00
txa
and #$f
tax
lda #A_DISINTEGRATING
sta alien_state,X
lda #0
sta alien_gait,X
jmp done_hit_something
2019-08-15 20:27:02 +00:00
laser_hit_friend:
2019-08-15 20:27:02 +00:00
lda #F_DISINTEGRATING
sta friend_state
2019-08-15 20:27:02 +00:00
lda #FAI_DISINTEGRATING
sta friend_ai_state
2019-08-15 20:27:02 +00:00
lda #0
sta friend_gait
2019-08-15 20:27:02 +00:00
; jmp done_hit_something
2019-08-15 20:27:02 +00:00
done_hit_something:
2019-08-15 20:27:02 +00:00
rts
2019-08-15 20:27:02 +00:00
2019-08-10 02:25:10 +00:00
2019-08-15 20:27:02 +00:00