ootw: c4: charging gun now works

This commit is contained in:
Vince Weaver 2019-08-14 15:38:36 -04:00
parent 5102dcfb75
commit 300ea24b95
7 changed files with 271 additions and 35 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 blast.s \
door.s laser.s shield.s blast.s gun.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 blast.s charger.s \
door.s laser.s shield.s blast.s gun.s charger.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

@ -17,6 +17,7 @@ BEHAVIOR DIFFERENCES:
- separate left facing vs right facing sprites
KNOWN BUGS:
+ ootw: pool monster grabs you a edge of pool (glitch)
+ intro: there's still a bit of a pause when the elevator door finishes opening
@ -29,7 +30,7 @@ General:
+ running: Missing one running frame (?)
+ ability to run+jump
+ ability to kick while crouching
+ ability to shoot whic crouching
+ ability to shoot while crouching
+ running then crouch, you slide a bit
* sprites_to_draw:
@ -39,12 +40,10 @@ General:
+ physicist swimming
+ beast tripping
+ physicist shot
+ alien shot
+ alien running
+ friend walking
+ friend running
* underwater:
+ ripples in water
@ -97,23 +96,17 @@ Level/Checkpoint #2:
+ music play when viewing city?
Level/Checkpoint #3:
+ smoke
+ Poisoning
+ Only show a window around us rolling
+ Fix animation speed of rolling
+ Actual game shakes the camera when you hit the ground after falling
Level/Checkpoint #4:
+ Falling as enter level
+ Implement gun recharger
+ Implement doors
+ Implement guard
+ Add friend/shooting foreground action
+ Allow falling into pit/spike
+ Allow jumping to platform
+ Allow exiting level
+ Implement doors
+ Implement guard (shooting, taunting)
Level/Checkpoint #5:
+ Falling as enter level
+ Allow falling into first pit
+ Falling as enter level
+ Allow falling into first pit
Pictures/Ending
+ Show some pictures
+ Do ending
+ Play music?

208
ootw/gun.s Normal file
View File

@ -0,0 +1,208 @@
;
; Gun behavior
;
; When 'L' pressed gun is charging
; we handle that here
handle_gun:
lda HAVE_GUN ; no gun, do nothing
beq done_gun
lda GUN_STATE ; gun not charging, do nothing
beq done_gun
lda GUN_FIRE ; if fired, fire it
bne fire_gun
; increment gun state
lda FRAMEL ; slow down
and #$7
bne done_inc_gun_state
inc GUN_STATE
; saturate
lda GUN_STATE
cmp #24
bne done_inc_gun_state
lda #21 ; wrap at end
sta GUN_STATE
done_inc_gun_state:
jmp done_gun
fire_gun:
; fire here
lda GUN_STATE
cmp #5
bcc done_gun ; too short, do nothing
cmp #21
bcs do_blast ; too long, blast
; shield
jsr activate_shield
jmp done_firing
do_blast:
jsr fire_blast
done_firing:
lda #0
sta GUN_STATE
done_gun:
lda #0
sta GUN_FIRE
rts
draw_gun:
lda HAVE_GUN ; no gun, do nothing
beq done_draw_gun
lda GUN_STATE ; gun not charging, do nothing
beq done_draw_gun
; set direction
lda DIRECTION
bne zap_right
zap_left:
ldx PHYSICIST_X
dex
dex
stx XPOS
jmp done_zap
zap_right:
lda PHYSICIST_X
clc
adc #5
sta XPOS
done_zap:
lda PHYSICIST_Y
clc
adc #4
sta YPOS
ldy GUN_STATE
lda gun_charge_progression,Y
tay
lda gun_charge_table_lo,Y
sta INL
lda gun_charge_table_hi,Y
sta INH
jsr put_sprite
done_draw_gun:
rts
; progression
gun_charge_progression:
.byte 0,0,0,1,2,3
.byte 4,5,6,4,5,6,4,5,6,4,5,6,4,5,6 ; 20
.byte 7,8,9
gun_charge_table_lo:
.byte <gun_charge_sprite0
.byte <gun_charge_sprite1
.byte <gun_charge_sprite2
.byte <gun_charge_sprite3
.byte <gun_charge_sprite4
.byte <gun_charge_sprite5
.byte <gun_charge_sprite6
.byte <gun_charge_sprite7
.byte <gun_charge_sprite8
.byte <gun_charge_sprite9
gun_charge_table_hi:
.byte >gun_charge_sprite0
.byte >gun_charge_sprite1
.byte >gun_charge_sprite2
.byte >gun_charge_sprite3
.byte >gun_charge_sprite4
.byte >gun_charge_sprite5
.byte >gun_charge_sprite6
.byte >gun_charge_sprite7
.byte >gun_charge_sprite8
.byte >gun_charge_sprite9
; startup
gun_charge_sprite0:
.byte 2,2
.byte $AA,$AA
.byte $AA,$AA
gun_charge_sprite1:
.byte 2,2
.byte $fA,$AA
.byte $AA,$AA
gun_charge_sprite2:
.byte 2,2
.byte $22,$AA
.byte $AA,$AA
gun_charge_sprite3:
.byte 2,2
.byte $ef,$eA
.byte $fe,$Ae
; medium
gun_charge_sprite4:
.byte 2,2
.byte $ff,$AA
.byte $Ae,$AA
gun_charge_sprite5:
.byte 2,2
.byte $ef,$AA
.byte $Ae,$AA
gun_charge_sprite6:
.byte 2,2
.byte $ef,$AA
.byte $Af,$AA
; large
gun_charge_sprite7:
.byte 2,2
.byte $fe,$fe
.byte $Ae,$Ae
gun_charge_sprite8:
.byte 2,2
.byte $fe,$fe
.byte $ef,$ef
gun_charge_sprite9:
.byte 2,2
.byte $ff,$ff
.byte $Ae,$Ae

View File

@ -75,6 +75,7 @@ check_left:
; Left Pressed
;====================
left_pressed:
inc GUN_FIRE
; left==0
lda DIRECTION ; if facing right, turn to face left
bne left_going_right
@ -126,6 +127,7 @@ check_right:
; Right Pressed
;===================
right_pressed:
inc GUN_FIRE
; right==1
lda DIRECTION ; if facing right, turn to face left
@ -222,6 +224,8 @@ up:
; UP -- Jump
;========================
inc GUN_FIRE
lda ON_ELEVATOR
beq up_not_elevator
@ -277,13 +281,24 @@ check_gun:
;======================
; 'L' to charge gun
;======================
handle_gun:
lda #1
; sta ACTIVATE_SHIELD
sta ACTIVATE_BLAST
charge_gun:
lda GUN_STATE
beq not_already_firing
inc GUN_FIRE
jmp done_keypress
not_already_firing:
inc GUN_STATE
lda #P_SHOOTING
sta PHYSICIST_STATE
jmp shoot
check_space:
cmp #' '
@ -297,6 +312,8 @@ check_space:
space:
lda HAVE_GUN
beq kick
inc GUN_FIRE
shoot:
lda PHYSICIST_STATE
cmp #P_SHOOTING

View File

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

View File

@ -15,6 +15,8 @@ ootw_city_init:
sta ALIEN_OUT
sta BLAST_OUT
sta CHARGER_COUNT
sta GUN_STATE
sta GUN_FIRE
lda #100
sta GUN_CHARGE
@ -654,29 +656,41 @@ no_fire_laser:
lda #0
sta LASER_OUT
;================
; handle gun
;================
jsr handle_gun
;================
; activate_shield
;================
lda ACTIVATE_SHIELD
beq no_activate_shield
jsr activate_shield
no_activate_shield:
lda #0
sta ACTIVATE_SHIELD
; lda ACTIVATE_SHIELD
; beq no_activate_shield
; jsr activate_shield
;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
; lda ACTIVATE_BLAST
; beq no_fire_blast
; jsr fire_blast
;no_fire_blast:
; lda #0
; sta ACTIVATE_BLAST
;================
; draw gun effect
;================
jsr draw_gun
;================
; move laser
;================

View File

@ -118,6 +118,9 @@ LZ4_DONE = $96
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
GUN_FIRE = $D4 ; 2+
GUN_STATE = $D5 ; 2+
ACTIVATE_BLAST = $D6 ; 2+