2019-03-23 17:20:43 +00:00
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
;======================================
|
|
|
|
; handle keypress
|
|
|
|
;======================================
|
|
|
|
|
2019-03-23 15:44:45 +00:00
|
|
|
; A or <- : start moving left
|
|
|
|
; D or -> : start moving right
|
2019-07-11 16:30:34 +00:00
|
|
|
; W or up : jump or elevator/transporter up
|
|
|
|
; S or down : crouch or pickup or elevator/transporter down
|
2019-08-14 15:26:17 +00:00
|
|
|
; L : charge gun
|
2019-03-23 15:44:45 +00:00
|
|
|
; space : action
|
|
|
|
; escape : quit
|
|
|
|
|
|
|
|
; if left: if running right, walk right
|
|
|
|
; if walk right, stand right
|
|
|
|
; if stand right, stand left
|
|
|
|
; if stand left, walk left
|
|
|
|
; if walk left, run left
|
2019-08-17 19:27:17 +00:00
|
|
|
; if up: if crouching, stand up
|
|
|
|
; if standing, jump
|
|
|
|
; if walking, jump
|
|
|
|
; if running, run-jump
|
|
|
|
; if down: if standing, crouch
|
|
|
|
; if walking, crouch
|
|
|
|
; if if running, slide-crouch
|
2019-03-23 15:44:45 +00:00
|
|
|
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
handle_keypress:
|
|
|
|
|
2019-03-15 17:47:41 +00:00
|
|
|
lda PHYSICIST_STATE
|
2019-08-16 15:49:40 +00:00
|
|
|
bmi no_keypress ; ignore keypress if dying/action
|
2019-03-15 17:47:41 +00:00
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
lda KEYPRESS ; 4
|
|
|
|
bmi keypress ; 3
|
2019-03-15 17:47:41 +00:00
|
|
|
no_keypress:
|
2019-03-17 05:28:42 +00:00
|
|
|
bit KEYRESET ; clear
|
|
|
|
; avoid keeping old keys around
|
2019-01-19 03:27:01 +00:00
|
|
|
rts ; nothing pressed, return
|
|
|
|
|
|
|
|
keypress:
|
|
|
|
; -1
|
|
|
|
|
|
|
|
and #$7f ; clear high bit
|
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;======================
|
|
|
|
; check escape
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
check_quit:
|
2019-03-15 17:00:47 +00:00
|
|
|
cmp #27 ; quit if ESCAPE pressed
|
2019-03-23 17:20:43 +00:00
|
|
|
bne check_left
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
;=====================
|
|
|
|
; QUIT
|
|
|
|
;=====================
|
2019-01-19 03:27:01 +00:00
|
|
|
quit:
|
|
|
|
lda #$ff ; could just dec
|
|
|
|
sta GAME_OVER
|
|
|
|
rts
|
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;======================
|
|
|
|
; check left
|
|
|
|
check_left:
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #'A'
|
2019-03-23 17:20:43 +00:00
|
|
|
beq left_pressed
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #$8 ; left arrow
|
2019-03-23 17:20:43 +00:00
|
|
|
bne check_right
|
2019-03-15 17:00:47 +00:00
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-15 17:00:47 +00:00
|
|
|
;====================
|
2019-08-16 15:13:51 +00:00
|
|
|
;====================
|
|
|
|
; Left/A Pressed
|
|
|
|
;====================
|
2019-03-15 17:00:47 +00:00
|
|
|
;====================
|
2019-03-23 17:20:43 +00:00
|
|
|
left_pressed:
|
2019-08-16 15:13:51 +00:00
|
|
|
inc GUN_FIRE ; fire gun if charging
|
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
; left==0
|
2019-01-19 03:27:01 +00:00
|
|
|
lda DIRECTION ; if facing right, turn to face left
|
2019-03-23 17:20:43 +00:00
|
|
|
bne left_going_right
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
left_going_left:
|
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_STANDING
|
|
|
|
beq walk_left
|
2019-08-09 04:37:07 +00:00
|
|
|
cmp #P_SHOOTING
|
|
|
|
beq walk_left
|
2019-03-23 17:20:43 +00:00
|
|
|
cmp #P_WALKING
|
|
|
|
beq run_left
|
2019-08-16 15:49:40 +00:00
|
|
|
and #STATE_CROUCHING
|
|
|
|
bne stand_left
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;=============================
|
|
|
|
; already running, do nothing?
|
|
|
|
rts
|
2019-03-16 18:17:20 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
left_going_right:
|
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_RUNNING
|
|
|
|
beq walk_right
|
|
|
|
cmp #P_WALKING
|
|
|
|
beq stand_right
|
|
|
|
cmp #P_STANDING
|
|
|
|
beq stand_left
|
2019-08-09 04:37:07 +00:00
|
|
|
cmp #P_SHOOTING
|
|
|
|
beq stand_left
|
2019-08-16 15:49:40 +00:00
|
|
|
and #STATE_CROUCHING
|
|
|
|
bne stand_left
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;===========================
|
|
|
|
; otherwise?
|
|
|
|
rts
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;========================
|
|
|
|
; check for right pressed
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
check_right:
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #'D'
|
2019-03-23 17:20:43 +00:00
|
|
|
beq right_pressed
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #$15
|
2019-03-23 17:20:43 +00:00
|
|
|
bne check_up
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
;===================
|
2019-08-16 15:13:51 +00:00
|
|
|
;===================
|
|
|
|
; Right/D Pressed
|
|
|
|
;===================
|
2019-03-15 17:00:47 +00:00
|
|
|
;===================
|
2019-03-23 17:20:43 +00:00
|
|
|
right_pressed:
|
2019-08-16 15:13:51 +00:00
|
|
|
inc GUN_FIRE ; fire if charging
|
2019-03-10 06:21:35 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
; right==1
|
2019-08-16 15:13:51 +00:00
|
|
|
lda DIRECTION ; if facing left, turn to face right
|
2019-03-23 17:20:43 +00:00
|
|
|
beq right_going_left
|
2019-03-10 06:21:35 +00:00
|
|
|
|
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
right_going_right:
|
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_STANDING
|
|
|
|
beq walk_right
|
2019-08-09 04:37:07 +00:00
|
|
|
cmp #P_SHOOTING
|
|
|
|
beq walk_right
|
2019-03-23 17:20:43 +00:00
|
|
|
cmp #P_WALKING
|
|
|
|
beq run_right
|
2019-08-16 15:49:40 +00:00
|
|
|
and #STATE_CROUCHING
|
|
|
|
bne stand_right
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;=============================
|
|
|
|
; already running, do nothing?
|
|
|
|
rts
|
2019-01-19 03:32:55 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
right_going_left:
|
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_RUNNING
|
|
|
|
beq walk_left
|
|
|
|
cmp #P_WALKING
|
|
|
|
beq stand_left
|
|
|
|
cmp #P_STANDING
|
|
|
|
beq stand_right
|
2019-08-09 04:37:07 +00:00
|
|
|
cmp #P_SHOOTING
|
|
|
|
beq stand_right
|
2019-08-16 15:49:40 +00:00
|
|
|
and #STATE_CROUCHING
|
|
|
|
bne stand_right
|
|
|
|
|
2019-01-19 03:32:55 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;===========================
|
|
|
|
; otherwise?
|
|
|
|
rts
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-10 06:21:35 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;=====================
|
|
|
|
; Left, direction=0
|
|
|
|
; Right, direction=1
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
stand_left:
|
|
|
|
lda #0 ; left
|
2019-01-19 03:27:01 +00:00
|
|
|
sta DIRECTION
|
2019-03-23 17:20:43 +00:00
|
|
|
sta GAIT
|
|
|
|
lda #P_STANDING
|
|
|
|
beq update_state
|
2019-03-15 17:00:47 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
walk_left:
|
|
|
|
lda #P_WALKING
|
|
|
|
bne update_state
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
run_left:
|
|
|
|
lda #P_RUNNING
|
2019-03-23 17:20:43 +00:00
|
|
|
bne update_state
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
stand_right:
|
|
|
|
lda #0
|
|
|
|
sta GAIT
|
|
|
|
lda #1 ; just inc DIRECTION?
|
|
|
|
sta DIRECTION
|
|
|
|
lda #P_STANDING
|
|
|
|
beq update_state
|
2019-03-15 17:00:47 +00:00
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
walk_right:
|
|
|
|
lda #P_WALKING
|
|
|
|
bne update_state
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
run_right:
|
|
|
|
lda #P_RUNNING
|
2019-03-23 17:20:43 +00:00
|
|
|
bne update_state
|
|
|
|
|
|
|
|
update_state:
|
2019-03-15 17:00:47 +00:00
|
|
|
sta PHYSICIST_STATE
|
2019-03-23 17:20:43 +00:00
|
|
|
bit KEYRESET
|
|
|
|
rts
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-23 17:20:43 +00:00
|
|
|
;=====================
|
|
|
|
; check up
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
check_up:
|
|
|
|
cmp #'W'
|
|
|
|
beq up
|
|
|
|
cmp #$0B
|
|
|
|
bne check_down
|
|
|
|
up:
|
2019-08-16 15:13:51 +00:00
|
|
|
;=============================
|
|
|
|
;=============================
|
|
|
|
; Up/W Pressed -- Jump, Get up
|
|
|
|
;=============================
|
|
|
|
;=============================
|
2019-03-15 17:00:47 +00:00
|
|
|
|
2019-08-16 17:15:07 +00:00
|
|
|
lda PHYSICIST_STATE ; shoot if charging
|
|
|
|
cmp #P_CROUCH_SHOOTING
|
|
|
|
beq up_no_fire
|
|
|
|
|
2019-08-14 19:38:36 +00:00
|
|
|
inc GUN_FIRE
|
2019-08-16 17:15:07 +00:00
|
|
|
up_no_fire:
|
2019-08-14 19:38:36 +00:00
|
|
|
|
2019-07-11 16:30:34 +00:00
|
|
|
lda ON_ELEVATOR
|
|
|
|
beq up_not_elevator
|
|
|
|
|
|
|
|
up_on_elevator:
|
|
|
|
lda #P_ELEVATING_UP
|
2019-08-16 15:13:51 +00:00
|
|
|
jmp change_state_clear_gait
|
2019-07-11 16:30:34 +00:00
|
|
|
|
|
|
|
up_not_elevator:
|
|
|
|
|
2019-08-16 15:13:51 +00:00
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_CROUCHING
|
|
|
|
beq stand_up
|
|
|
|
cmp #P_CROUCH_SHOOTING
|
|
|
|
beq stand_up_shoot
|
2019-08-17 19:27:17 +00:00
|
|
|
cmp #P_RUNNING
|
|
|
|
beq run_jump
|
2019-08-16 15:13:51 +00:00
|
|
|
|
|
|
|
up_jump:
|
2019-03-15 17:00:47 +00:00
|
|
|
lda #P_JUMPING
|
2019-08-16 15:13:51 +00:00
|
|
|
jmp change_state_clear_gait
|
|
|
|
|
2019-08-17 19:27:17 +00:00
|
|
|
run_jump:
|
|
|
|
lda #P_JUMPING|STATE_RUNNING
|
|
|
|
jmp change_state_clear_gait
|
|
|
|
|
2019-08-16 15:13:51 +00:00
|
|
|
stand_up:
|
|
|
|
lda #P_STANDING
|
|
|
|
jmp change_state_clear_gait
|
|
|
|
|
|
|
|
stand_up_shoot:
|
|
|
|
lda #P_SHOOTING
|
|
|
|
jmp change_state_clear_gait
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
|
2019-08-16 15:13:51 +00:00
|
|
|
;==========================
|
2019-01-19 03:27:01 +00:00
|
|
|
check_down:
|
|
|
|
cmp #'S'
|
|
|
|
beq down
|
|
|
|
cmp #$0A
|
2019-08-14 15:26:17 +00:00
|
|
|
bne check_gun
|
2019-03-15 17:00:47 +00:00
|
|
|
|
2019-08-16 15:13:51 +00:00
|
|
|
;==========================
|
|
|
|
;==========================
|
|
|
|
; Down/S Pressed -- Crouch
|
|
|
|
;==========================
|
|
|
|
;==========================
|
2019-01-19 03:27:01 +00:00
|
|
|
down:
|
2019-07-11 16:30:34 +00:00
|
|
|
|
2019-08-16 17:15:07 +00:00
|
|
|
lda PHYSICIST_STATE ; shoot if charging
|
|
|
|
cmp #P_SHOOTING
|
|
|
|
beq down_no_fire
|
|
|
|
|
|
|
|
inc GUN_FIRE
|
|
|
|
down_no_fire:
|
|
|
|
|
2019-07-11 16:30:34 +00:00
|
|
|
lda ON_ELEVATOR
|
|
|
|
beq down_not_elevator
|
|
|
|
|
|
|
|
down_on_elevator:
|
|
|
|
lda #P_ELEVATING_DOWN
|
2019-08-16 15:13:51 +00:00
|
|
|
jmp change_state_clear_gait
|
2019-07-11 16:30:34 +00:00
|
|
|
|
|
|
|
down_not_elevator:
|
2019-08-16 15:13:51 +00:00
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_SHOOTING
|
|
|
|
bne start_crouch
|
|
|
|
|
2019-08-17 19:27:17 +00:00
|
|
|
start_crouch_shoot:
|
|
|
|
and #STATE_RUNNING
|
|
|
|
ora #P_CROUCH_SHOOTING
|
2019-08-16 15:13:51 +00:00
|
|
|
jmp change_state_clear_gait
|
|
|
|
|
|
|
|
start_crouch:
|
2019-08-17 19:27:17 +00:00
|
|
|
and #STATE_RUNNING
|
|
|
|
ora #P_CROUCHING
|
2019-08-16 15:13:51 +00:00
|
|
|
jmp change_state_clear_gait
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-08-16 15:13:51 +00:00
|
|
|
|
|
|
|
;==========================
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-08-14 15:26:17 +00:00
|
|
|
check_gun:
|
|
|
|
cmp #'L'
|
|
|
|
bne check_space
|
2019-08-14 17:29:11 +00:00
|
|
|
|
|
|
|
;======================
|
|
|
|
; 'L' to charge gun
|
|
|
|
;======================
|
2019-08-14 19:38:36 +00:00
|
|
|
charge_gun:
|
2019-08-17 05:37:03 +00:00
|
|
|
lda HAVE_GUN ; only if have gun
|
|
|
|
beq done_keypress
|
2019-08-14 19:38:36 +00:00
|
|
|
|
|
|
|
lda GUN_STATE
|
|
|
|
beq not_already_firing
|
|
|
|
|
2019-08-16 17:15:07 +00:00
|
|
|
inc GUN_FIRE ; if charging, fire
|
2019-08-14 15:26:17 +00:00
|
|
|
|
|
|
|
jmp done_keypress
|
|
|
|
|
2019-08-14 19:38:36 +00:00
|
|
|
not_already_firing:
|
|
|
|
|
|
|
|
inc GUN_STATE
|
|
|
|
|
2019-08-16 17:15:07 +00:00
|
|
|
lda PHYSICIST_STATE
|
|
|
|
and #STATE_CROUCHING
|
2019-08-16 17:53:37 +00:00
|
|
|
beq crouch_charge
|
2019-08-16 17:15:07 +00:00
|
|
|
ldy #P_CROUCH_SHOOTING
|
|
|
|
bne crouch_charge_go ; bra
|
|
|
|
crouch_charge:
|
|
|
|
ldy #P_SHOOTING
|
|
|
|
crouch_charge_go:
|
|
|
|
sty PHYSICIST_STATE
|
2019-08-14 19:38:36 +00:00
|
|
|
|
|
|
|
jmp shoot
|
|
|
|
|
2019-08-14 15:26:17 +00:00
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
check_space:
|
|
|
|
cmp #' '
|
|
|
|
beq space
|
2019-08-16 17:15:07 +00:00
|
|
|
; cmp #$15 ; ascii 21=??
|
|
|
|
jmp unknown
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
;======================
|
2019-08-16 20:32:59 +00:00
|
|
|
; SPACE -- Kick or shoot
|
2019-03-15 17:00:47 +00:00
|
|
|
;======================
|
2019-01-19 03:27:01 +00:00
|
|
|
space:
|
2019-08-09 04:37:07 +00:00
|
|
|
lda HAVE_GUN
|
|
|
|
beq kick
|
2019-08-14 19:38:36 +00:00
|
|
|
|
2019-08-16 17:15:07 +00:00
|
|
|
; shoot pressed
|
|
|
|
|
|
|
|
inc GUN_FIRE ; if charging, shoot
|
2019-08-09 04:37:07 +00:00
|
|
|
shoot:
|
2019-08-16 17:15:07 +00:00
|
|
|
lda PHYSICIST_STATE ; if in stance, then shoot
|
2019-08-10 01:46:04 +00:00
|
|
|
cmp #P_SHOOTING
|
2019-08-16 17:15:07 +00:00
|
|
|
beq in_position
|
|
|
|
cmp #P_CROUCH_SHOOTING
|
2019-08-10 01:46:04 +00:00
|
|
|
bne no_stance
|
|
|
|
|
2019-08-16 17:15:07 +00:00
|
|
|
in_position:
|
2019-08-10 01:46:04 +00:00
|
|
|
lda #1
|
|
|
|
sta LASER_OUT
|
2019-08-16 17:15:07 +00:00
|
|
|
jmp done_keypress
|
2019-08-10 01:46:04 +00:00
|
|
|
|
|
|
|
no_stance:
|
2019-08-16 17:15:07 +00:00
|
|
|
and #STATE_CROUCHING
|
|
|
|
beq stand_stance
|
|
|
|
|
|
|
|
crouch_stance:
|
|
|
|
lda #P_CROUCH_SHOOTING
|
|
|
|
jmp change_state_clear_gait
|
|
|
|
|
|
|
|
stand_stance:
|
2019-08-09 04:37:07 +00:00
|
|
|
lda #P_SHOOTING
|
2019-08-16 15:13:51 +00:00
|
|
|
jmp change_state_clear_gait
|
2019-08-09 04:37:07 +00:00
|
|
|
|
|
|
|
kick:
|
2019-08-16 20:32:59 +00:00
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_CROUCHING
|
|
|
|
bne kick_standing
|
|
|
|
|
|
|
|
lda #P_CROUCH_KICKING
|
|
|
|
jmp kick_final
|
|
|
|
|
|
|
|
kick_standing:
|
2019-03-15 16:28:46 +00:00
|
|
|
lda #P_KICKING
|
2019-08-16 20:32:59 +00:00
|
|
|
kick_final:
|
2019-03-15 16:28:46 +00:00
|
|
|
sta PHYSICIST_STATE
|
2019-01-19 03:27:01 +00:00
|
|
|
lda #15
|
|
|
|
sta GAIT
|
|
|
|
unknown:
|
|
|
|
done_keypress:
|
|
|
|
bit KEYRESET ; clear the keyboard strobe ; 4
|
|
|
|
|
|
|
|
rts ; 6
|
2019-08-16 15:13:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
change_state_clear_gait:
|
|
|
|
sta PHYSICIST_STATE
|
|
|
|
lda #0
|
|
|
|
sta GAIT
|
|
|
|
jmp done_keypress
|