dos33fsprogs/games/keen/level1_items.s

250 lines
4.5 KiB
ArmAsm
Raw Normal View History

2024-03-30 04:55:12 +00:00
;======================
; check touching things
;======================
; do head, than foot
2024-04-05 20:45:40 +00:00
2024-03-30 04:55:12 +00:00
check_items:
2024-03-30 05:05:25 +00:00
2024-04-05 20:45:40 +00:00
;===================
; check head first
;===================
; if X==0, check TILEX and TILEX+1
; if X==1, check TILEX+1
2024-03-30 05:05:25 +00:00
2024-04-05 20:45:40 +00:00
clc
lda KEEN_TILEY
adc #>big_tilemap
sta INH
lda KEEN_TILEX
sta INL
2024-03-30 04:55:12 +00:00
2024-04-05 20:45:40 +00:00
lda KEEN_X
bne check_head_tilex1
;===================
; check head tilex
2024-03-30 05:05:25 +00:00
2024-04-05 20:45:40 +00:00
check_head_tilex:
; don't check door, only leave if feet at door
; check if touching enemy
2024-03-30 05:05:25 +00:00
jsr check_enemy
2024-04-05 20:45:40 +00:00
; check item
jsr check_item
check_head_tilex1:
inc INL
; don't check door, only leave if feet at door
2024-03-30 05:05:25 +00:00
2024-04-05 20:45:40 +00:00
; check if touching enemy
jsr check_enemy
; check items
jsr check_item
2024-04-05 20:45:40 +00:00
;========================
; check feet
check_feet:
inc INH ; point to next row
dec INL ; restore tile pointer
lda KEEN_X
bne check_feet_tilex1
check_feet_tilex:
; check if going out door
jsr check_door
; check if touching enemy
jsr check_enemy
; check item
2024-03-30 04:55:12 +00:00
jsr check_item
2024-04-05 20:45:40 +00:00
check_feet_tilex1:
inc INL
; check if going out door
jsr check_door
; check if touching enemy
jsr check_enemy
2024-03-30 05:05:25 +00:00
2024-04-05 20:45:40 +00:00
; check items
jsr check_item
2024-04-05 20:45:40 +00:00
rts ; FIXME: 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-04-05 20:45:40 +00:00
ldy #0
lda (INL),Y
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-04-05 20:45:40 +00:00
tax
lda score_lookup,X
2024-03-20 05:40:58 +00:00
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-04-05 20:45:40 +00:00
; erase big tilemap
2024-03-18 05:16:13 +00:00
lda #1 ; plain tile
2024-04-05 20:45:40 +00:00
sta (INL),Y
2024-03-10 05:44:20 +00:00
2024-04-05 20:45:40 +00:00
jsr copy_tilemap_subset
2024-03-18 05:16:13 +00:00
; play sound
2024-04-04 05:06:29 +00:00
ldy #SFX_GOTITEMSND
jsr play_sfx
2024-03-18 05:16:13 +00:00
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:
2024-04-05 20:45:40 +00:00
ldy #0
lda (INL),Y
2024-03-30 04:55:12 +00:00
cmp #11 ; door tile
bne done_check_door
at_door:
inc LEVEL_OVER
; TODO: mark level complete somehow
2024-04-04 05:06:29 +00:00
ldy #SFX_LVLDONESND
jsr play_sfx
2024-03-30 04:55:12 +00:00
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:
2024-04-05 20:45:40 +00:00
ldy #0
lda (INL),Y
2024-03-30 05:05:25 +00:00
cmp #21 ; green tentacles
beq touched_enemy
cmp #22 ; clam thing
bne done_check_enemy
touched_enemy:
dec KEENS
inc LEVEL_OVER
2024-04-04 05:06:29 +00:00
ldy #SFX_KEENDIESND
jsr play_sfx
2024-03-30 05:05:25 +00:00
; TODO: ANIMATION
2024-04-04 05:06:29 +00:00
; keen turns to head, flies up screen
; play game over music if out of keens
lda KEENS
bpl done_check_enemy
ldy #SFX_GAMEOVERSND
jsr play_sfx
2024-03-30 05:05:25 +00:00
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-05 20:45:40 +00:00
.if 0
; 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
2024-04-05 20:45:40 +00:00
.endif