keen: more work on item pickup

This commit is contained in:
Vince Weaver 2024-03-18 01:16:13 -04:00
parent e2327896d2
commit afaea8e59c
3 changed files with 81 additions and 11 deletions

View File

@ -2,10 +2,67 @@
;==================
; check for items
;==================
; X holds ??
; X holds tile offset of feet?
check_item:
lda tilemap,X
cmp #27
bcc done_check_item ; not an item
cmp #32
bcs done_check_item ; not an item
sec
sbc #27 ; subtract off to get index
; 0 = laser gun
; 1 = lollipop 100 pts
; 2 = book 1000 pts
; 3 = pizza 500 pts
; 4 = carbonated beverage 200 pts
; ? = bear 5000 pts
; keycards go here too...
; use value to update score
; erase
; FIXME: only erases small tilemap
; also need to update big
lda #1 ; plain tile
sta tilemap,X
; big tilemap:
; tilemap
lda KEEN_Y ; divide by 4 as tile 4 blocks tall
lsr
lsr
clc
adc TILEMAP_Y ; add in tilemap Y (each row 256 bytes)
adc #>big_tilemap ; add in offset of start
sta btc_smc+2
lda TILEMAP_X ; add in X offset of tilemap
sta btc_smc+1
lda KEEN_X
lsr
tay
iny ; why add 1????
lda #0 ; background tile
btc_smc:
sta $b000,Y
; play sound
jsr pickup_noise
.if 0
check_red_key:
lda tilemap,X
cmp #31 ; red key
@ -44,6 +101,6 @@ check_blue_key:
jsr update_status_bar
jmp keen_check_head
.endif
done_check_item:
rts

View File

@ -7,6 +7,10 @@
.include "hardware.inc"
.include "common_defines.inc"
MAX_TILE_X = 96 ; 116 - 20
MAX_TILE_Y = 5 ; (34 - 24)/2 (maybe?)
keen_start:
;===================
; init screen

View File

@ -76,7 +76,7 @@ dwr_noflo:
move_left:
;==============================
; Move Keen Right
; Move Keen Left
;==============================
; if (keen_x>=14) || (tilemap_x=0) walk
; otherwise, scroll
@ -124,7 +124,6 @@ done_move_keen:
;=========================
; keen collide
;=========================
keen_collide:
;==================
; check for item
@ -213,22 +212,25 @@ done_keen_collide:
;=========================
; check_jumping
; handle_jumping
;=========================
handle_jumping:
lda KEEN_JUMPING
beq done_handle_jumping
beq done_handle_jumping ; skip if not actually jumping
lda KEEN_Y
lda KEEN_Y ; make sure not off screen
beq dont_wrap_jump
dec KEEN_Y
dec KEEN_Y ; move up
dec KEEN_Y
dont_wrap_jump:
dec KEEN_JUMPING
bne done_handle_jumping
dec KEEN_JUMPING ; slow jump
bne done_handle_jumping ; if positive still going up
; otherwise hit peak, start falling
lda #1 ; avoid gap before falling triggered
sta KEEN_FALLING
@ -358,12 +360,19 @@ check_falling:
lda #1
sta KEEN_FALLING
; scroll but only if Y>=20 (YDEFAULT)
;===================================================
; scroll but only if KEEN_Y>=20 (YDEFAULT)
; and TILEMAP_Y < MAX_TILE_Y
lda TILEMAP_Y
cmp #MAX_TILE_Y
bcs keen_fall ; bge
lda KEEN_Y
cmp #YDEFAULT
bcs scroll_fall ; bge
keen_fall:
inc KEEN_Y
inc KEEN_Y
jmp done_check_falling