ootw: c4: add blast support

This commit is contained in:
Vince Weaver 2019-08-14 13:29:11 -04:00
parent eb980e6584
commit 5494cad14e
5 changed files with 235 additions and 4 deletions

View File

@ -62,7 +62,7 @@ ootw_c2.o: ootw_c2.s \
gr_hlin.s gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \
keyboard.s gr_run_sequence.s audio.s \
physicist.s alien.s friend.s \
door.s laser.s shield.s \
door.s laser.s shield.s blast.s \
ootw_c2_miners.s \
ootw_graphics/sprites/physicist.inc \
ootw_graphics/sprites/alien.inc \
@ -98,7 +98,7 @@ ootw_c4.o: ootw_c4.s \
gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.s \
keyboard.s gr_run_sequence.s physicist.s \
ootw_c4_city.s ootw_c4_action.s \
door.s laser.s shield.s \
door.s laser.s shield.s blast.s \
ootw_graphics/sprites/physicist.inc \
ootw_graphics/l4city/ootw_c4_city.inc
ca65 -o ootw_c4.o ootw_c4.s -l ootw_c4.lst

204
ootw/blast.s Normal file
View File

@ -0,0 +1,204 @@
; 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
; activate blast slot
inc blast0_out
; reset count
lda #0
sta blast0_count
; set y
lda PHYSICIST_Y
clc
adc #4
sta blast0_y
; set direction
lda DIRECTION
sta blast0_direction
beq blast_left
bne blast_right
; set x
blast_left:
ldx PHYSICIST_X
dex
stx blast0_end
txa
sec
sbc #10
sta blast0_start
jmp done_fire_blast
blast_right:
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 #$f6
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
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
bmi disable_blast
lda blast0_start
bpl no_move_blast
lda #0
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
cmp #40
bcs disable_blast
lda blast0_end
cmp #40
bcc no_move_blast
lda #39
sta blast0_end
no_move_blast:
inc blast0_count
done_move_blast:
rts
disable_blast:
lda #0
sta blast0_out
rts

View File

@ -273,9 +273,14 @@ down_not_elevator:
check_gun:
cmp #'L'
bne check_space
;======================
; 'L' to charge gun
;======================
handle_gun:
lda #1
sta ACTIVATE_SHIELD
; sta ACTIVATE_SHIELD
sta ACTIVATE_BLAST
jmp done_keypress

View File

@ -105,6 +105,7 @@ end_message:
.include "door.s"
.include "laser.s"
.include "shield.s"
.include "blast.s"
.include "ootw_c4_action.s"

View File

@ -638,6 +638,16 @@ no_activate_shield:
lda #0
sta ACTIVATE_SHIELD
;================
; fire blast
;================
lda ACTIVATE_BLAST
beq no_fire_blast
jsr fire_blast
no_fire_blast:
lda #0
sta ACTIVATE_BLAST
;================
@ -646,13 +656,24 @@ no_activate_shield:
jsr move_laser
;================
; draw laser
;================
jsr draw_laser
;================
; move blast
;================
jsr move_blast
;================
; draw blast
;================
jsr draw_blast
;================
; draw shields
;================