dos33fsprogs/ootw/blast.s

348 lines
4.1 KiB
ArmAsm
Raw Normal View History

2019-08-14 17:29:11 +00:00
; Handle blast
blast0_out: .byte $0
blast0_start: .byte $0
blast0_end: .byte $0
blast0_y: .byte $0
blast0_direction: .byte $0
blast0_count: .byte $0
;=========================
; fire blast
;=========================
fire_blast:
lda blast0_out
bne done_fire_blast
lda PHYSICIST_X
; FIXME: if facing right, add 5 to this value
; to allow shooting through shield
sta COLLISION_X
lda PHYSICIST_Y
sta COLLISION_Y
2019-08-14 17:29:11 +00:00
; activate blast slot
inc blast0_out
; reduce gun charge
; FIXME: don't shoot if too low
lda GUN_CHARGE
sec
sbc #10
sta GUN_CHARGE
; reset blast count
2019-08-14 17:29:11 +00:00
lda #0
sta blast0_count
; set y
lda PHYSICIST_Y
clc
adc #4
2019-08-16 17:53:37 +00:00
ldx PHYSICIST_STATE
cpx #P_CROUCH_SHOOTING
bne blast_ypos_done
blast_crouch:
clc
adc #4
blast_ypos_done:
2019-08-14 17:29:11 +00:00
sta blast0_y
; set direction
lda DIRECTION
sta blast0_direction
beq blast_left
bne blast_right
; set x
blast_left:
2019-08-15 18:24:46 +00:00
jsr calc_gun_left_collision
2019-08-14 17:29:11 +00:00
ldx PHYSICIST_X
dex
stx blast0_end
txa
sec
sbc #10
sta blast0_start
jmp done_fire_blast
blast_right:
2019-08-15 18:24:46 +00:00
jsr calc_gun_right_collision
2019-08-14 17:29:11 +00:00
lda PHYSICIST_X
clc
adc #5
sta blast0_start
clc
adc #10
sta blast0_end
done_fire_blast:
rts
;====================
; draw blast
;====================
draw_blast:
lda blast0_out
beq done_draw_blast
lda #$fe
2019-08-14 17:29:11 +00:00
sta hlin_color_smc+1
lda #$00
sta hlin_mask_smc+1
ldy blast0_y
sec
lda blast0_end
sbc blast0_start
tax
lda blast0_start
jsr hlin
ldy blast0_y
sty YPOS
lda blast0_direction
beq blast_going_left
ldy blast0_end
jmp blast_going_done
blast_going_left:
ldy blast0_start
blast_going_done:
sty XPOS
lda #<gun_charge_sprite8
sta INL
lda #>gun_charge_sprite8
sta INH
jsr put_sprite_crop
2019-08-14 17:29:11 +00:00
done_draw_blast:
rts
;===================
; move blast
;===================
move_blast:
lda blast0_out
beq done_move_blast
; slow down blast
lda blast0_count
and #$3
bne no_move_blast
lda blast0_direction
bne move_blast_right
move_blast_left:
lda blast0_count
cmp #4
bcc still_starting_blast_left
cmp #8
bcc still_shooting_blast_left
continue_shooting_blast_left:
still_shooting_blast_left:
lda blast0_end
sec
sbc #10
sta blast0_end
still_starting_blast_left:
lda blast0_start
sec
sbc #10
sta blast0_start
blast_edge_detect_left:
lda blast0_end
2019-08-15 18:24:46 +00:00
cmp LEFT_SHOOT_LIMIT
2019-08-15 19:12:34 +00:00
bmi disable_blast_left
2019-08-14 17:29:11 +00:00
lda blast0_start
2019-08-15 18:24:46 +00:00
cmp LEFT_SHOOT_LIMIT
2019-08-14 17:29:11 +00:00
bpl no_move_blast
2019-08-15 18:24:46 +00:00
lda LEFT_SHOOT_LIMIT
2019-08-14 17:29:11 +00:00
sta blast0_start
jmp no_move_blast
move_blast_right:
lda blast0_count
cmp #4
bcc still_starting_blast_right
cmp #8
bcc still_shooting_blast_right
continue_shooting_blast_right:
lda blast0_start
clc
adc #10
sta blast0_start
still_shooting_blast_right:
lda blast0_end
clc
adc #10
sta blast0_end
still_starting_blast_right:
blast_edge_detect_right:
; detect if totally off screen
lda blast0_start
2019-08-15 18:24:46 +00:00
cmp RIGHT_SHOOT_LIMIT
2019-08-15 19:12:34 +00:00
bcs disable_blast_right
2019-08-14 17:29:11 +00:00
lda blast0_end
2019-08-15 18:24:46 +00:00
cmp RIGHT_SHOOT_LIMIT
2019-08-14 17:29:11 +00:00
bcc no_move_blast
2019-08-15 18:24:46 +00:00
lda RIGHT_SHOOT_LIMIT
2019-08-14 17:29:11 +00:00
sta blast0_end
no_move_blast:
inc blast0_count
done_move_blast:
rts
2019-08-15 20:27:02 +00:00
;=====================
; hit something, left
;=====================
2019-08-15 19:12:34 +00:00
disable_blast_left:
lda LEFT_SHOOT_TARGET
jmp blast_something_common
;==================
; hit something, right
;==================
disable_blast_right:
lda RIGHT_SHOOT_TARGET
;=========================
; blash something, common
;=========================
blast_something_common:
2019-08-15 19:12:34 +00:00
ldx #0
stx blast0_out
2019-08-15 20:27:02 +00:00
tax
and #$f0
cmp #TARGET_DOOR
beq blast_door
2019-08-15 20:27:02 +00:00
cmp #TARGET_ALIEN
beq blast_alien
cmp #TARGET_FRIEND
beq blast_friend
cmp #TARGET_SHIELD
beq blast_shield
2019-08-15 20:27:02 +00:00
jmp done_blasting_common
2019-08-15 20:27:02 +00:00
blast_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_blasting_common
2019-08-15 19:12:34 +00:00
blast_friend:
2019-08-15 20:27:02 +00:00
lda #F_DISINTEGRATING
sta friend_state
2019-08-15 19:12:34 +00:00
lda #FAI_DISINTEGRATING
sta friend_ai_state
2019-08-15 19:12:34 +00:00
lda #0
sta friend_gait
2019-08-15 19:12:34 +00:00
jmp done_blasting_common
2019-08-15 20:27:02 +00:00
blast_shield:
2019-08-15 19:12:34 +00:00
; FIXME: need animation for this
2019-08-15 20:27:02 +00:00
txa
and #$f
tax
lda #0
sta shield_out,X
2019-08-15 20:27:02 +00:00
dec SHIELD_OUT
2019-08-15 20:27:02 +00:00
jmp done_blasting_common
blast_door:
; FIXME: change direction based on blast
2019-08-15 19:12:34 +00:00
txa
and #$f
2019-08-16 18:34:16 +00:00
tay
2019-08-15 19:12:34 +00:00
lda #DOOR_STATUS_EXPLODING1
2019-08-16 18:34:16 +00:00
sta (DOOR_STATUS),Y
2019-08-15 19:12:34 +00:00
jsr recalc_walk_collision
2019-08-15 20:27:02 +00:00
done_blasting_common:
2019-08-15 20:27:02 +00:00
2019-08-14 17:29:11 +00:00
rts