ootw: c4: initial shields implementation

This commit is contained in:
Vince Weaver 2019-08-14 11:26:17 -04:00
parent 1984553ef3
commit 95e311c40d
6 changed files with 312 additions and 5 deletions

View File

@ -59,9 +59,10 @@ OOTW_C2: ootw_c2.o
ootw_c2.o: ootw_c2.s \
gr_copy.s gr_copy_offset.s gr_fast_clear.s gr_pageflip.s gr_unrle.s \
gr_putsprite.s gr_putsprite_flipped.s gr_putsprite_crop.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 \
ootw_c2_miners.s \
ootw_graphics/sprites/physicist.inc \
ootw_graphics/sprites/alien.inc \
@ -93,11 +94,11 @@ OOTW_C4: ootw_c4.o
ootw_c4.o: ootw_c4.s \
gr_copy.s gr_twoscreen_scroll.s gr_fast_clear.s gr_pageflip.s \
gr_unrle.s gr_hlin.s laser.s \
gr_unrle.s gr_hlin.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 \
door.s laser.s shield.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

View File

@ -7,6 +7,7 @@
; D or -> : start moving right
; W or up : jump or elevator/transporter up
; S or down : crouch or pickup or elevator/transporter down
; L : charge gun
; space : action
; escape : quit
@ -244,7 +245,7 @@ check_down:
cmp #'S'
beq down
cmp #$0A
bne check_space
bne check_gun
;======================
; DOWN -- Crouch
@ -269,10 +270,20 @@ down_not_elevator:
jmp done_keypress
check_gun:
cmp #'L'
bne check_space
handle_gun:
lda #1
sta ACTIVATE_SHIELD
jmp done_keypress
check_space:
cmp #' '
beq space
cmp #$15
cmp #$15 ; ascii 21=??
bne unknown
;======================

View File

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

View File

@ -78,6 +78,10 @@ ootw_city_init:
;===========================
;===========================
ootw_city:
;============================
; init shields
jsr init_shields
;==============================
@ -623,6 +627,18 @@ no_fire_laser:
lda #0
sta LASER_OUT
;================
; activate_shield
;================
lda ACTIVATE_SHIELD
beq no_activate_shield
jsr activate_shield
no_activate_shield:
lda #0
sta ACTIVATE_SHIELD
;================
; move laser
@ -637,7 +653,11 @@ no_fire_laser:
jsr draw_laser
;================
; draw shields
;================
jsr draw_shields
;========================
; draw foreground cover

265
ootw/shield.s Normal file
View File

@ -0,0 +1,265 @@
; Handle shield
; when pressed, find empty slot? Up to 3?
; gradually expire, flash when done
; should update the laser range when start/stop
; destroyed by blast. Weakened by laser?
MAX_SHIELDS = 3
shield_out:
shield0_out: .byte $0
shield1_out: .byte $0
shield2_out: .byte $0
shield_x:
shield0_x: .byte $0
shield1_x: .byte $0
shield2_x: .byte $0
shield_y:
shield0_y: .byte $0
shield1_y: .byte $0
shield2_y: .byte $0
shield_count:
shield0_count: .byte $0
shield1_count: .byte $0
shield2_count: .byte $0
;=========================
; activate_shield
;=========================
activate_shield:
lda SHIELD_OUT
cmp #MAX_SHIELDS
beq done_activate_shield
; find slot
ldx #0
activate_shield_loop:
lda shield_out,X
beq found_shield_slot
inx
bne activate_shield_loop ; bra
found_shield_slot:
; take the slot
inc SHIELD_OUT
inc shield_out,X
; reset count
lda #0
sta shield_count,X
; set y
lda PHYSICIST_Y
sta shield_y,X
; set x
lda DIRECTION
bne shield_right
shield_left:
ldy PHYSICIST_X
dey
tya
sta shield_x,X
jmp done_activate_shield
shield_right:
lda PHYSICIST_X
clc
adc #5
sta shield_x,X
done_activate_shield:
rts
;====================
; draw shields
;====================
draw_shields:
lda SHIELD_OUT
beq done_draw_shields
ldx #0
draw_shields_loop:
lda shield_out,X
beq draw_shields_loop_continue
lda shield_x,X
sta XPOS
lda shield_y,X
sta YPOS
lda #<shield_high1_sprite
sta INL
lda #>shield_high1_sprite
sta INH
txa
pha
jsr put_sprite
pla
tax
draw_shields_loop_continue:
inx
cpx #MAX_SHIELDS
bne draw_shields_loop
done_draw_shields:
rts
;===================
; update shields
;===================
update_shields:
; 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
rts
;====================
; init shields
;====================
init_shields:
ldx #0
stx SHIELD_OUT
init_shields_loop:
lda #0
sta shield_out,X
inx
cpx #MAX_SHIELDS
bne init_shields_loop
rts
shield_flash_sprite:
.byte 1,8
.byte $f3
.byte $ff
.byte $ff
.byte $ff
.byte $ff
.byte $3f
.byte $AA
.byte $AA
shield_start_sprite:
.byte 1,8
.byte $11
.byte $11
.byte $11
.byte $11
.byte $11
.byte $11
.byte $11
.byte $11
shield_high1_sprite:
.byte 1,8
.byte $BA
.byte $3A
.byte $A1
.byte $A1
.byte $BA
.byte $A3
.byte $BA
.byte $13
shield_high2_sprite:
.byte 1,8
.byte $3A
.byte $1A
.byte $3A
.byte $AA
.byte $AB
.byte $3A
.byte $1B
.byte $3A
shield_medium1_sprite:
.byte 1,8
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
shield_medium2_sprite:
.byte 1,8
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
shield_low1_sprite:
.byte 1,8
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
shield_low2_sprite:
.byte 1,8
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA

View File

@ -118,6 +118,15 @@ LZ4_DONE = $96
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
ACTIVATE_BLAST = $D6 ; 2+
ACTIVATE_SHIELD = $D7 ; 2+
BLAST_OUT = $D8 ; 2+
SHIELD_OUT = $D9 ; 2+
ALIEN_OUT = $DA ; 2+
LASER_OUT = $DB ; 2+