2019-01-19 03:27:01 +00:00
|
|
|
;======================================
|
|
|
|
; handle keypress
|
|
|
|
;======================================
|
|
|
|
|
|
|
|
handle_keypress:
|
|
|
|
|
2019-03-15 17:47:41 +00:00
|
|
|
lda PHYSICIST_STATE
|
|
|
|
cmp #P_COLLAPSING ; ignore keypress if dying
|
|
|
|
beq no_keypress
|
|
|
|
|
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-01-19 03:27:01 +00:00
|
|
|
|
|
|
|
rts ; nothing pressed, return
|
|
|
|
|
|
|
|
keypress:
|
|
|
|
; -1
|
|
|
|
|
|
|
|
and #$7f ; clear high bit
|
|
|
|
|
|
|
|
check_quit:
|
2019-03-15 17:00:47 +00:00
|
|
|
cmp #27 ; quit if ESCAPE pressed
|
|
|
|
bne check_walk_left
|
|
|
|
|
|
|
|
;=====================
|
|
|
|
; QUIT
|
|
|
|
;=====================
|
2019-01-19 03:27:01 +00:00
|
|
|
quit:
|
|
|
|
lda #$ff ; could just dec
|
|
|
|
sta GAME_OVER
|
|
|
|
rts
|
|
|
|
|
2019-03-15 17:00:47 +00:00
|
|
|
check_walk_left:
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #'A'
|
2019-03-15 17:00:47 +00:00
|
|
|
beq walk_left
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #$8 ; left arrow
|
2019-03-15 17:00:47 +00:00
|
|
|
bne check_walk_right
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-15 17:00:47 +00:00
|
|
|
;====================
|
|
|
|
; Walk left
|
|
|
|
;====================
|
|
|
|
walk_left:
|
2019-01-19 03:27:01 +00:00
|
|
|
|
2019-03-15 16:28:46 +00:00
|
|
|
lda #P_WALKING
|
|
|
|
sta PHYSICIST_STATE ; stand from crouching
|
2019-01-19 03:27:01 +00:00
|
|
|
|
|
|
|
lda DIRECTION ; if facing right, turn to face left
|
|
|
|
bne face_left
|
|
|
|
|
2019-03-10 06:21:35 +00:00
|
|
|
inc GAIT ; cycle through animation
|
|
|
|
|
|
|
|
lda GAIT
|
|
|
|
and #$7
|
|
|
|
cmp #$4
|
|
|
|
bne no_move_left
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
dec PHYSICIST_X ; walk left
|
|
|
|
|
2019-03-10 06:21:35 +00:00
|
|
|
no_move_left:
|
2019-01-19 03:27:01 +00:00
|
|
|
lda PHYSICIST_X
|
|
|
|
cmp LEFT_LIMIT
|
|
|
|
bpl just_fine_left
|
|
|
|
too_far_left:
|
|
|
|
inc PHYSICIST_X
|
|
|
|
lda #1
|
|
|
|
sta GAME_OVER
|
|
|
|
|
|
|
|
just_fine_left:
|
|
|
|
|
|
|
|
jmp done_keypress ; done
|
|
|
|
|
|
|
|
face_left:
|
|
|
|
lda #0
|
|
|
|
sta DIRECTION
|
|
|
|
sta GAIT
|
|
|
|
jmp done_keypress
|
|
|
|
|
2019-03-15 17:00:47 +00:00
|
|
|
check_walk_right:
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #'D'
|
2019-03-15 17:00:47 +00:00
|
|
|
beq walk_right
|
2019-01-19 03:27:01 +00:00
|
|
|
cmp #$15
|
2019-03-15 17:00:47 +00:00
|
|
|
bne check_run_left
|
|
|
|
|
|
|
|
|
|
|
|
;===================
|
|
|
|
; Walk Right
|
|
|
|
;===================
|
|
|
|
walk_right:
|
2019-03-15 16:28:46 +00:00
|
|
|
lda #P_WALKING
|
|
|
|
sta PHYSICIST_STATE
|
2019-01-19 03:27:01 +00:00
|
|
|
|
|
|
|
lda DIRECTION
|
|
|
|
beq face_right
|
|
|
|
|
2019-03-10 06:21:35 +00:00
|
|
|
inc GAIT
|
|
|
|
|
|
|
|
lda GAIT
|
|
|
|
and #$7
|
|
|
|
cmp #$4
|
|
|
|
bne no_move_right
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
inc PHYSICIST_X
|
2019-03-10 06:21:35 +00:00
|
|
|
no_move_right:
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
lda PHYSICIST_X
|
|
|
|
cmp RIGHT_LIMIT
|
|
|
|
bne just_fine_right
|
|
|
|
too_far_right:
|
|
|
|
|
2019-01-19 03:32:55 +00:00
|
|
|
dec PHYSICIST_X
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
lda #2
|
|
|
|
sta GAME_OVER
|
2019-01-19 03:32:55 +00:00
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
|
|
|
|
just_fine_right:
|
2019-03-10 06:21:35 +00:00
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
jmp done_keypress
|
|
|
|
|
|
|
|
face_right:
|
|
|
|
lda #0
|
|
|
|
sta GAIT
|
|
|
|
lda #1
|
|
|
|
sta DIRECTION
|
|
|
|
jmp done_keypress
|
|
|
|
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
check_run_left:
|
|
|
|
cmp #'Q'
|
|
|
|
bne check_run_right
|
|
|
|
|
|
|
|
|
|
|
|
;====================
|
|
|
|
; Run left
|
|
|
|
;====================
|
|
|
|
run_left:
|
|
|
|
|
|
|
|
lda #P_RUNNING
|
|
|
|
sta PHYSICIST_STATE ; stand from crouching
|
|
|
|
|
|
|
|
lda DIRECTION ; if facing right, turn to face left
|
|
|
|
bne face_left
|
|
|
|
|
|
|
|
inc GAIT ; cycle through animation
|
|
|
|
inc GAIT ; cycle through animation
|
|
|
|
|
|
|
|
dec PHYSICIST_X ; walk left
|
|
|
|
|
|
|
|
jmp no_move_left
|
|
|
|
|
|
|
|
|
|
|
|
check_run_right:
|
|
|
|
cmp #'E'
|
|
|
|
bne check_up
|
|
|
|
|
|
|
|
;===================
|
|
|
|
; Run Right
|
|
|
|
;===================
|
|
|
|
run_right:
|
|
|
|
lda #P_RUNNING
|
|
|
|
sta PHYSICIST_STATE
|
|
|
|
|
|
|
|
lda DIRECTION
|
|
|
|
beq face_right
|
|
|
|
|
|
|
|
inc GAIT
|
|
|
|
inc GAIT
|
|
|
|
|
|
|
|
inc PHYSICIST_X
|
|
|
|
|
|
|
|
jmp no_move_right
|
|
|
|
|
|
|
|
check_up:
|
|
|
|
cmp #'W'
|
|
|
|
beq up
|
|
|
|
cmp #$0B
|
|
|
|
bne check_down
|
|
|
|
up:
|
|
|
|
;========================
|
|
|
|
; Jump
|
|
|
|
;========================
|
|
|
|
|
|
|
|
lda #P_JUMPING
|
|
|
|
sta PHYSICIST_STATE
|
|
|
|
lda #0
|
|
|
|
sta GAIT
|
|
|
|
|
|
|
|
jmp done_keypress
|
|
|
|
|
2019-01-19 03:27:01 +00:00
|
|
|
check_down:
|
|
|
|
cmp #'S'
|
|
|
|
beq down
|
|
|
|
cmp #$0A
|
|
|
|
bne check_space
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
;======================
|
|
|
|
; Crouch
|
|
|
|
;======================
|
2019-01-19 03:27:01 +00:00
|
|
|
down:
|
2019-03-15 16:28:46 +00:00
|
|
|
lda #P_CROUCHING
|
|
|
|
sta PHYSICIST_STATE
|
2019-01-19 03:27:01 +00:00
|
|
|
lda #0
|
|
|
|
sta GAIT
|
|
|
|
|
|
|
|
jmp done_keypress
|
|
|
|
|
|
|
|
check_space:
|
|
|
|
cmp #' '
|
|
|
|
beq space
|
|
|
|
cmp #$15
|
|
|
|
bne unknown
|
2019-03-15 17:00:47 +00:00
|
|
|
|
|
|
|
;======================
|
|
|
|
; Kick
|
|
|
|
;======================
|
2019-01-19 03:27:01 +00:00
|
|
|
space:
|
2019-03-15 16:28:46 +00:00
|
|
|
lda #P_KICKING
|
|
|
|
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
|
|
|
|
|
|
|
|
|