duke: can exit level

This commit is contained in:
Vince Weaver 2020-12-16 12:55:05 -05:00
parent 296a583048
commit fff5f19d50
5 changed files with 182 additions and 11 deletions

View File

@ -7,7 +7,7 @@ key pickup noise
* NO BONUS message
* back to title screen
* are you sure message on quit
scroll bonus message
* scroll bonus message
sound:
~~~~~~
@ -24,8 +24,7 @@ walking right into objects, stand back one more (maybe and to mask?)
level1:
~~~~~~~
exit door, blue pillar, red key (all in basement?)
blue pillar?
tiles
~~~~~
@ -52,6 +51,7 @@ enemies:
~~~~~~~~
Little robot
green crawly
ability to die
items:
~~~~~~

View File

@ -3,9 +3,48 @@
up_action:
; set X and Y value
; convert tile values to X,Y
; X=((DUKE_X/2)-1)+TILEX
lda DUKE_X
lsr
sec
sbc #1
clc
adc TILEMAP_X
sta XPOS
; Y = (DUKEY/4)+TILEY
lda DUKE_Y
lsr
lsr
clc
adc TILEMAP_Y
sta YPOS
; $39,$22 = 57,34
; check if it's a key slot
check_red_keyhole:
; key slot is 280,148
; 280,148 (-80,-12) -> 200,136 -> (/4,/4) -> 50,34
lda XPOS
cmp #50
beq redkey_x
cmp #51
bne check_if_exit
redkey_x:
lda YPOS
cmp #34
bne check_if_exit
; check that we have the key
lda INVENTORY
and #INV_RED_KEY
@ -44,11 +83,116 @@ not_red_tile:
jsr copy_tilemap_subset
jmp done_up_action
; check if it's the exit
check_if_exit:
; exit is 296,148
; 296,148 (-80,-12) -> 216,136 -> (/4,/4) -> 54,34
lda XPOS
cmp #54
beq exit_x
cmp #55
bne done_up_action
exit_x:
lda YPOS
cmp #34
bne done_up_action
; check that we have the key
lda INVENTORY
and #INV_RED_KEY
beq done_up_action
lda #1
sta DOOR_ACTIVATED
sta FRAMEL ; restart timer
done_up_action:
rts
;==========================
; open the door, end level
;==========================
check_open_door:
lda DOOR_ACTIVATED
beq done_open_door
asl
tay
lda door_opening,Y
sta INL
lda door_opening+1,Y
sta INH
; need to find actual door location
; it's at 54,34
; Y is going to be at 20 unless something weird is going on
; X is going to be ((54-TILE_X)+2)*2
lda #56
sec
sbc TILEMAP_X
asl
sta XPOS
lda #20
sta YPOS
jsr put_sprite_crop
lda FRAMEL
and #$7
bne done_open_door
; increment
inc DOOR_ACTIVATED
lda DOOR_ACTIVATED
cmp #6
bne done_open_door
jsr level_end
done_open_door:
rts
door_opening:
.word door_sprite0
.word door_sprite0
.word door_sprite1
.word door_sprite2
.word door_sprite1
.word door_sprite0
door_sprite0:
.byte 4,4
.byte $15,$55,$55,$f5
.byte $55,$f5,$5f,$55
.byte $25,$25,$25,$25
.byte $55,$55,$55,$55
door_sprite1:
.byte 4,4
.byte $51,$f5,$f5,$5f
.byte $55,$05,$05,$50
.byte $05,$50,$50,$55
.byte $52,$55,$55,$52
door_sprite2:
.byte 4,4
.byte $f5,$05,$05,$f0
.byte $55,$00,$00,$55
.byte $55,$00,$00,$55
.byte $05,$50,$50,$25

View File

@ -45,6 +45,7 @@ duke_start:
sta DUKE_FALLING
sta DUKE_SHOOTING
sta KICK_UP_DUST
sta DOOR_ACTIVATED
lda #<enemy_data
sta ENEMY_DATAL
@ -140,6 +141,10 @@ duke_loop:
jsr draw_duke
; handle door opening
jsr check_open_door
; draw a status bar
jsr draw_status_bar

View File

@ -4,18 +4,23 @@ level_end:
bit KEYRESET ; clear keyboard
bit SET_TEXT
lda #' '|$80
sta clear_all_color+1
jsr clear_all
lda #12
sta drawbox_x1
lda #26
sta drawbox_x2
lda #8
lda #19
sta drawbox_y1
lda #12
lda #23
sta drawbox_y2
lda #21
sta bonus_text+1
scroll_bonus_loop:
lda #' '|$80
sta clear_all_color+1
jsr clear_all
jsr drawbox
jsr normal_text
@ -28,12 +33,26 @@ level_end:
jsr page_flip
lda #220
jsr WAIT
lda #220
jsr WAIT
level_end_wait:
lda KEYPRESS
bpl level_end_wait
bit KEYRESET
bmi really_end_level
dec drawbox_y1
dec drawbox_y2
dec bonus_text+1
lda drawbox_y1
bmi really_end_level
jmp scroll_bonus_loop
really_end_level:
bit KEYRESET
lda #NEXT_LEVEL
sta LEVEL_OVER
@ -41,6 +60,8 @@ really_end_level:
lda #LOAD_TITLE
sta WHICH_LOAD
jsr clear_all
rts
bonus_text:

View File

@ -113,6 +113,7 @@ KICK_UP_DUST = $97
SUPPRESS_WALK = $98
ENEMY_DATAL = $99
ENEMY_DATAH = $9A
DOOR_ACTIVATED = $9B
; done game puzzle state