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 ; $39,$22 = 57,34
; check if it's a key slot ; check if it's a key slot
check_red_keyhole: ;check_red_keyhole:
;
;
; key slot is 280,148 ; ; key slot is 280,148
; 280,148 (-80,-12) -> 200,136 -> (/4,/4) -> 50,34 ; ; 280,148 (-80,-12) -> 200,136 -> (/4,/4) -> 50,34
;
lda XPOS ; lda XPOS
cmp #50 ; cmp #50
beq redkey_x ; beq redkey_x
cmp #51 ; cmp #51
bne check_if_exit ; 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
;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 ; open the red wall
; there has to be a more efficient way of doing this ; there has to be a more efficient way of doing this
open_the_wall: ;open_the_wall:
; reset smc ; ; reset smc
lda #>BIG_TILEMAP ; lda #>BIG_TILEMAP
sta rwr_smc1+2 ; sta rwr_smc1+2
sta rwr_smc2+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: ; jmp done_up_action
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
; check if it's the exit ; check if it's the exit
check_if_exit: check_if_exit:
; exit is 296,148 ; exit is 924,84
; 296,148 (-80,-12) -> 216,136 -> (/4,/4) -> 54,34 ; 924,84 (-80,-12) -> 844,72 -> (/4,/4) -> 211,18
lda XPOS lda XPOS
cmp #54 cmp #211
beq exit_x beq exit_x
cmp #55 cmp #212
bne done_up_action bne done_up_action
exit_x: exit_x:
lda YPOS lda YPOS
cmp #34 cmp #18
bne done_up_action bne done_up_action
; check that we have the key
lda INVENTORY
and #INV_RED_KEY
beq done_up_action
lda #1 lda #1
sta DOOR_ACTIVATED sta DOOR_ACTIVATED
@ -140,11 +135,11 @@ check_open_door:
sta INH sta INH
; need to find actual door location ; 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 ; 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 sec
sbc TILEMAP_X sbc TILEMAP_X
asl asl

View File

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

View File

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

View File

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

View File

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

View File

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