duke: can exit level2 now

This commit is contained in:
Vince Weaver 2020-12-17 17:24:00 -05:00
parent 2ff04fa97f
commit dd5cf3dc3d
6 changed files with 107 additions and 82 deletions

View File

@ -27,94 +27,89 @@ up_action:
; $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
bne open_the_wall
no_red_key:
jsr buzzer_noise
jmp done_up_action
;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
; bne open_the_wall
;
;no_red_key:
; jsr buzzer_noise
; jmp done_up_action
;
; open the red wall
; there has to be a more efficient way of doing this
open_the_wall:
; reset smc
lda #>BIG_TILEMAP
sta rwr_smc1+2
sta rwr_smc2+2
;open_the_wall:
; ; reset smc
; lda #>BIG_TILEMAP
; sta rwr_smc1+2
; sta rwr_smc2+2
;
;remove_red_wall_outer:
; ldx #0
;remove_red_wall_loop:
;rwr_smc1:
; lda BIG_TILEMAP,X
; cmp #49 ; red key tile
; bne not_red_tile
; lda #2 ; lblue bg tile
;rwr_smc2:
; sta BIG_TILEMAP,X
;not_red_tile:
; inx
; bne remove_red_wall_loop
;
; inc rwr_smc1+2
; inc rwr_smc2+2
;
; lda rwr_smc1+2
; cmp #(>BIG_TILEMAP)+40
; bne remove_red_wall_outer
;
; ; refresh local tilemap
;
; jsr copy_tilemap_subset
;
; jsr rumble_noise
remove_red_wall_outer:
ldx #0
remove_red_wall_loop:
rwr_smc1:
lda BIG_TILEMAP,X
cmp #49 ; red key tile
bne not_red_tile
lda #2 ; lblue bg tile
rwr_smc2:
sta BIG_TILEMAP,X
not_red_tile:
inx
bne remove_red_wall_loop
inc rwr_smc1+2
inc rwr_smc2+2
lda rwr_smc1+2
cmp #(>BIG_TILEMAP)+40
bne remove_red_wall_outer
; refresh local tilemap
jsr copy_tilemap_subset
jsr rumble_noise
jmp done_up_action
; 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
; exit is 924,84
; 924,84 (-80,-12) -> 844,72 -> (/4,/4) -> 211,18
lda XPOS
cmp #54
cmp #211
beq exit_x
cmp #55
cmp #212
bne done_up_action
exit_x:
lda YPOS
cmp #34
cmp #18
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
@ -140,11 +135,11 @@ check_open_door:
sta INH
; need to find actual door location
; it's at 54,34
; it's at 211,18
; Y is going to be at 20 unless something weird is going on
; X is going to be ((54-TILE_X)+2)*2
; X is going to be ((211-TILE_X)+2)*2
lda #56
lda #213 ; +2, edge of screen
sec
sbc TILEMAP_X
asl

View File

@ -192,6 +192,10 @@ do_duke_loop:
done_with_duke:
bit KEYRESET ; clear keypress
lda #LOAD_DUKE2
sta WHICH_LOAD
rts ; exit back

View File

@ -173,6 +173,10 @@ do_duke_loop:
done_with_duke:
bit KEYRESET ; clear keypress
; FIXME: point to next level
lda #LOAD_TITLE
sta WHICH_LOAD
rts ; exit back

View File

@ -333,7 +333,7 @@ enemy4:
.byte 0 ; exploding
.byte ENEMY_TERP ; type
.byte $ff ; direction
.byte 114,19 ; tilex,tiley
.byte 113,19 ; tilex,tiley
.byte 0,0 ; x,y
enemy5:

View File

@ -56,10 +56,6 @@ really_end_level:
lda #NEXT_LEVEL
sta LEVEL_OVER
; FIXME: point to next level
lda #LOAD_TITLE
sta WHICH_LOAD
jsr clear_all
rts

View File

@ -208,8 +208,8 @@ check_left_collide:
lda DUKE_FOOT_OFFSET
sec
sbc #1 ; left is one to left
sbc #2 ; left is one to left
; +1 fudge factor
tax
lda TILEMAP,X
@ -265,6 +265,15 @@ done_handle_jumping:
; xx 6
; xx 7
;-----------------------
; YY = block
;========================
; YYYY YYYY
; -XX- -XX-
; -XX- -XX-
; left, foot = (X+1)/2
; right, foot = (X+2)/2
duke_get_feet_location:
; + 1 is because sprite is 4 pixels wide?
@ -302,10 +311,27 @@ duke_get_feet_location:
sta DUKE_FOOT_OFFSET
sec
; lda DUKE_DIRECTION
; bmi foot_left
foot_right:
lda DUKE_X
sbc #3
lsr ; (x-3)/2
clc
adc #2
; jmp foot_done
;foot_left:
; lda DUKE_X
; sec
; sbc #1
foot_done:
lsr
; offset by two block at edge of screen
sec
sbc #2
clc
adc DUKE_FOOT_OFFSET