ootw: split out room edge detection

now we can jump on run to other rooms

still a bit buggy.  Also hit the NMOS 6502 jump table bug
This commit is contained in:
Vince Weaver 2019-03-16 14:17:20 -04:00
parent 9b2822c706
commit 2d31fc5f30
6 changed files with 98 additions and 19 deletions

View File

@ -7,6 +7,8 @@ handle_keypress:
lda PHYSICIST_STATE
cmp #P_COLLAPSING ; ignore keypress if dying
beq no_keypress
cmp #P_JUMPING ; ignore keypress if jumping
beq no_keypress
lda KEYPRESS ; 4
bmi keypress ; 3
@ -59,15 +61,16 @@ walk_left:
dec PHYSICIST_X ; walk left
no_move_left:
lda PHYSICIST_X
cmp LEFT_LIMIT
bpl just_fine_left
too_far_left:
inc PHYSICIST_X
lda #1
sta GAME_OVER
just_fine_left:
; 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
@ -104,18 +107,18 @@ walk_right:
inc PHYSICIST_X
no_move_right:
lda PHYSICIST_X
cmp RIGHT_LIMIT
bne just_fine_right
too_far_right:
; lda PHYSICIST_X
; cmp RIGHT_LIMIT
; bne just_fine_right
;too_far_right:
dec PHYSICIST_X
; dec PHYSICIST_X
lda #2
sta GAME_OVER
; lda #2
; sta GAME_OVER
just_fine_right:
;just_fine_right:
jmp done_keypress

View File

@ -169,6 +169,12 @@ cavern_loop:
jsr handle_keypress
;===============
; check room limits
jsr check_screen_limit
;===============
; draw physicist

View File

@ -65,6 +65,12 @@ mesa_loop:
jsr handle_keypress
;===============================
; check limits
jsr check_screen_limit
;===============
; draw physicist

View File

@ -272,6 +272,10 @@ no_tentacle:
jsr handle_keypress
;===============================
; check limits
jsr check_screen_limit
;===============
; draw physicist
@ -343,7 +347,7 @@ not_to_right:
cmp #$1
bne not_done_pool
lda #37
lda #36
sta PHYSICIST_X
jmp ootw_rope

View File

@ -71,6 +71,11 @@ rope_loop:
jsr handle_keypress
;===============================
; check screen limits
jsr check_screen_limit
;===============
; draw physicist
@ -152,7 +157,7 @@ rope_frame_no_oflo:
; check if done this level
cmp #$2
bne not_done_rope
bne check_cliff_edge
lda #0
sta PHYSICIST_X
@ -160,8 +165,19 @@ rope_frame_no_oflo:
jmp ootw_pool
not_done_rope:
; at edge of cliff
check_cliff_edge:
cmp #$1
bne not_done_rope
lda #0
sta GAME_OVER
lda #11
sta PHYSICIST_X
not_done_rope:
; loop forever
jmp rope_loop

View File

@ -15,9 +15,16 @@ pstate_table_hi:
.byte >physicist_jumping
.byte >physicist_collapsing
; Urgh, make sure this doesn't end up at $FF or you hit the
; NMOS 6502 bug
.align 2
pjump:
.word $0000
.align 1
;======================================
; draw physicist
;======================================
@ -247,3 +254,40 @@ facing_left:
facing_right:
jmp put_sprite_flipped
;======================================
; Check screen limits
;======================================
check_screen_limit:
lda PHYSICIST_X
cmp LEFT_LIMIT
bpl just_fine_left ; (bge==bcs)
too_far_left:
; inc PHYSICIST_X
lda #1
sta GAME_OVER
rts
just_fine_left:
; Check right edige of screen
lda PHYSICIST_X
cmp RIGHT_LIMIT
bcc just_fine_right ; blt
too_far_right:
; dec PHYSICIST_X
lda #2
sta GAME_OVER
just_fine_right:
rts