2024-03-30 04:55:12 +00:00
|
|
|
;======================
|
|
|
|
; check touching things
|
|
|
|
;======================
|
|
|
|
; do head, than foot
|
2024-04-01 04:49:20 +00:00
|
|
|
; FIXME: should we check both left/right head/feet
|
2024-03-30 04:55:12 +00:00
|
|
|
check_items:
|
2024-03-30 05:05:25 +00:00
|
|
|
|
|
|
|
; check if going out door
|
|
|
|
|
2024-03-30 04:55:12 +00:00
|
|
|
jsr check_door
|
|
|
|
|
2024-03-30 05:05:25 +00:00
|
|
|
; check if touching enemy
|
|
|
|
|
|
|
|
jsr check_enemy
|
|
|
|
|
|
|
|
; check head items
|
|
|
|
|
2024-04-01 05:25:52 +00:00
|
|
|
ldx KEEN_HEAD_POINTER_L
|
|
|
|
jsr check_item
|
|
|
|
ldx KEEN_HEAD_POINTER_R
|
2024-03-30 04:55:12 +00:00
|
|
|
jsr check_item
|
|
|
|
|
2024-03-30 05:05:25 +00:00
|
|
|
; check feet items
|
|
|
|
|
2024-04-01 05:25:52 +00:00
|
|
|
ldx KEEN_FOOT_POINTER_L
|
|
|
|
jsr check_item
|
|
|
|
|
|
|
|
ldx KEEN_FOOT_POINTER_R
|
2024-03-30 04:55:12 +00:00
|
|
|
; fallthrough
|
2024-03-10 05:44:20 +00:00
|
|
|
|
|
|
|
;==================
|
|
|
|
; check for items
|
|
|
|
;==================
|
2024-03-29 05:34:20 +00:00
|
|
|
|
2024-03-10 05:44:20 +00:00
|
|
|
check_item:
|
2024-03-30 04:55:12 +00:00
|
|
|
lda tilemap,X
|
2024-03-10 05:44:20 +00:00
|
|
|
|
2024-03-30 04:55:12 +00:00
|
|
|
do_check_item:
|
2024-03-18 05:16:13 +00:00
|
|
|
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
|
|
|
|
|
2024-03-20 05:40:58 +00:00
|
|
|
beq get_laser_gun
|
|
|
|
|
|
|
|
; otherwise look up points and add it
|
2024-03-18 05:16:13 +00:00
|
|
|
|
2024-03-20 05:40:58 +00:00
|
|
|
tay
|
|
|
|
lda score_lookup,Y
|
|
|
|
jsr inc_score
|
|
|
|
jmp done_item_pickup
|
2024-03-18 05:16:13 +00:00
|
|
|
|
2024-03-20 05:40:58 +00:00
|
|
|
get_laser_gun:
|
2024-03-20 05:45:37 +00:00
|
|
|
lda RAYGUNS
|
|
|
|
clc
|
|
|
|
sed
|
|
|
|
adc #$05
|
|
|
|
sta RAYGUNS
|
|
|
|
cld
|
|
|
|
|
|
|
|
jmp done_item_pickup
|
2024-03-18 05:16:13 +00:00
|
|
|
|
2024-03-20 05:40:58 +00:00
|
|
|
; keycards go here too...
|
|
|
|
get_keycard:
|
|
|
|
|
|
|
|
done_item_pickup:
|
2024-03-18 05:16:13 +00:00
|
|
|
|
2024-03-30 04:55:12 +00:00
|
|
|
; erase small tilemap
|
2024-03-18 05:16:13 +00:00
|
|
|
|
|
|
|
lda #1 ; plain tile
|
|
|
|
sta tilemap,X
|
2024-03-10 05:44:20 +00:00
|
|
|
|
2024-03-18 05:16:13 +00:00
|
|
|
; big tilemap:
|
2024-03-30 04:55:12 +00:00
|
|
|
; to find... urgh
|
|
|
|
; X is currently (KEEN_Y/4)*20)+(KEEN_X/2)
|
2024-04-01 05:25:52 +00:00
|
|
|
; (X mod 20) = KEEN_X/2
|
|
|
|
; X/20 = KEEN_Y/4
|
|
|
|
;
|
|
|
|
|
|
|
|
lda div20_table,X
|
2024-03-18 05:16:13 +00:00
|
|
|
|
2024-04-01 05:25:52 +00:00
|
|
|
; lda KEEN_Y ; divide by 4 as tile 4 blocks tall
|
|
|
|
; lsr
|
|
|
|
; lsr
|
2024-03-18 05:16:13 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2024-04-01 05:25:52 +00:00
|
|
|
lda mod20_table,X
|
|
|
|
|
|
|
|
; lda KEEN_X
|
|
|
|
; lsr
|
2024-03-18 05:16:13 +00:00
|
|
|
tay
|
|
|
|
|
2024-04-01 05:25:52 +00:00
|
|
|
lda #1 ; background tile
|
2024-03-18 05:16:13 +00:00
|
|
|
btc_smc:
|
|
|
|
sta $b000,Y
|
|
|
|
|
|
|
|
; play sound
|
|
|
|
jsr pickup_noise
|
|
|
|
|
2024-03-10 05:44:20 +00:00
|
|
|
|
|
|
|
done_check_item:
|
|
|
|
rts
|
2024-03-20 05:40:58 +00:00
|
|
|
|
2024-03-30 04:55:12 +00:00
|
|
|
;==========================
|
|
|
|
; check if feet at door
|
|
|
|
;==========================
|
|
|
|
check_door:
|
|
|
|
lda KEEN_FOOT_TILE1
|
|
|
|
cmp #11 ; door tile
|
|
|
|
beq at_door
|
|
|
|
lda KEEN_FOOT_TILE2
|
|
|
|
cmp #11
|
|
|
|
bne done_check_door
|
|
|
|
|
|
|
|
at_door:
|
|
|
|
inc LEVEL_OVER
|
|
|
|
; TODO: mark level complete somehow
|
|
|
|
jsr exit_music
|
|
|
|
done_check_door:
|
|
|
|
rts
|
2024-03-20 05:40:58 +00:00
|
|
|
|
2024-03-30 05:05:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
;=============================
|
|
|
|
; check if feet touching enemy
|
|
|
|
;=============================
|
|
|
|
; level1 at least you can't touch with head?
|
|
|
|
check_enemy:
|
|
|
|
lda KEEN_FOOT_TILE1
|
|
|
|
cmp #21 ; green tentacles
|
|
|
|
beq touched_enemy
|
|
|
|
cmp #22 ; clam thing
|
|
|
|
beq touched_enemy
|
|
|
|
|
|
|
|
lda KEEN_FOOT_TILE2
|
|
|
|
cmp #21 ; green tentacles
|
|
|
|
beq touched_enemy
|
|
|
|
cmp #22 ; clam thing
|
|
|
|
bne done_check_enemy
|
|
|
|
|
|
|
|
touched_enemy:
|
|
|
|
dec KEENS
|
|
|
|
inc LEVEL_OVER
|
|
|
|
; TODO: ANIMATION
|
|
|
|
; TODO: enemy music
|
|
|
|
;jsr exit_music
|
|
|
|
done_check_enemy:
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2024-03-20 05:40:58 +00:00
|
|
|
score_lookup:
|
|
|
|
.byte $00,$01,$10,$05,$02,$50 ; BCD
|
|
|
|
; 0 = laser gun
|
|
|
|
; 1 = lollipop 100 pts
|
|
|
|
; 2 = book 1000 pts
|
|
|
|
; 3 = pizza 500 pts
|
|
|
|
; 4 = carbonated beverage 200 pts
|
|
|
|
; ? = bear 5000 pts
|
2024-04-01 05:25:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
; bit of a hack
|
|
|
|
; TODO: auto-generate at startup
|
|
|
|
|
|
|
|
div20_table:
|
|
|
|
.byte 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
|
|
|
|
.byte 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1
|
|
|
|
.byte 2,2,2,2,2, 2,2,2,2,2, 2,2,2,2,2, 2,2,2,2,2
|
|
|
|
.byte 3,3,3,3,3, 3,3,3,3,3, 3,3,3,3,3, 3,3,3,3,3
|
|
|
|
.byte 4,4,4,4,4, 4,4,4,4,4, 4,4,4,4,4, 4,4,4,4,4
|
|
|
|
.byte 5,5,5,5,5, 5,5,5,5,5, 5,5,5,5,5, 5,5,5,5,5
|
|
|
|
.byte 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6, 6,6,6,6,6
|
|
|
|
.byte 7,7,7,7,7, 7,7,7,7,7, 7,7,7,7,7, 7,7,7,7,7
|
|
|
|
.byte 8,8,8,8,8, 8,8,8,8,8, 8,8,8,8,8, 8,8,8,8,8
|
|
|
|
.byte 9,9,9,9,9, 9,9,9,9,9, 9,9,9,9,9, 9,9,9,9,9
|
|
|
|
.byte 10,10,10,10,10, 10,10,10,10,10, 10,10,10,10,10, 10,10,10,10,10
|
|
|
|
.byte 11,11,11,11,11, 11,11,11,11,11, 11,11,11,11,11, 11,11,11,11,11
|
|
|
|
.byte 12,12,12,12,12, 12,12,12,12,12, 12,12,12,12,12 ;, 12,12,12,12,12
|
|
|
|
|
|
|
|
|
|
|
|
mod20_table:
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
|
|
|
|
.byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
|
|
|
|
|