ootw: c4: generic doors now implemented

This commit is contained in:
Vince Weaver 2019-08-16 14:47:03 -04:00
parent f28c6c34ec
commit e9fbee8434
3 changed files with 48 additions and 29 deletions

View File

@ -37,7 +37,7 @@ recalc_walk_left:
dey
recalc_walk_left_loop:
cmp door_x,Y
cmp (DOOR_X),Y
bcc recalc_walk_left_continue ; bcs
lda (DOOR_STATUS),Y
@ -45,7 +45,7 @@ recalc_walk_left_loop:
bne recalc_walk_left_continue
; early exit
lda door_x,Y
lda (DOOR_X),Y
ora #$80
sta LEFT_WALK_LIMIT
jmp done_recalc_walk_left_collision
@ -61,7 +61,7 @@ done_recalc_walk_left_collision:
ldy #0
recalc_walk_right_loop:
cmp door_x,Y
cmp (DOOR_X),Y
bcs recalc_walk_right_continue ; bge
lda (DOOR_STATUS),Y
@ -69,7 +69,7 @@ recalc_walk_right_loop:
bne recalc_walk_right_continue
; early exit
lda door_x,Y
lda (DOOR_X),Y
sec
sbc #4
ora #$80
@ -125,7 +125,7 @@ calc_gun_right_door_loop:
lda PHYSICIST_X
cmp door_x,Y
cmp (DOOR_X),Y
bcs calc_gun_right_door_continue ; bge
lda (DOOR_STATUS),Y
@ -136,7 +136,7 @@ calc_gun_right_door_loop:
calc_gun_right_door_there:
; early exit
lda door_x,Y
lda (DOOR_X),Y
sta RIGHT_SHOOT_LIMIT
tya ; set target if hit
@ -233,7 +233,7 @@ calc_gun_left_doors:
calc_gun_left_door_loop:
lda PHYSICIST_X
cmp door_x,Y
cmp (DOOR_X),Y
bcc calc_gun_left_door_continue ; blt
lda (DOOR_STATUS),Y
@ -244,7 +244,7 @@ calc_gun_left_door_loop:
calc_gun_left_door_there:
; early exit
lda door_x,Y
lda (DOOR_X),Y
sta LEFT_SHOOT_LIMIT
tya ; set target if hit

View File

@ -35,10 +35,10 @@ draw_doors_loop:
sta INH
actually_draw_door:
lda door_x,Y
lda (DOOR_X),Y
sta XPOS
lda door_y,Y
lda (DOOR_Y),Y
sta YPOS
tya
@ -146,17 +146,17 @@ done_handle_doors:
handle_doors_open:
; only open/close if on same level
lda door_y,Y
lda (DOOR_Y),Y
clc
adc #4
cmp PHYSICIST_Y
bne close_door
lda PHYSICIST_X
cmp door_xmax,Y
cmp (DOOR_XMAX),Y
bcs close_door ; bge
cmp door_xmin,Y
cmp (DOOR_XMIN),Y
bcc close_door ; blt
; made it here, we are in bounds, stay open
@ -172,17 +172,17 @@ handle_doors_closed:
; only open if on same level
lda door_y,Y
lda (DOOR_Y),Y
clc
adc #4
cmp PHYSICIST_Y
bne handle_doors_continue
lda PHYSICIST_X
cmp door_xmax,Y
cmp (DOOR_XMAX),Y
bcs handle_doors_continue
cmp door_xmin,Y
cmp (DOOR_XMIN),Y
bcc handle_doors_continue
open_door:
@ -191,8 +191,21 @@ open_door:
jmp handle_doors_continue
;====================
;====================
; setup door table
;====================
;====================
setup_door_table:
ldx #9
setup_door_table_loop:
setup_door_table_loop_smc:
lda $1000,X
sta DOOR_STATUS,X
dex
bpl setup_door_table_loop
rts

View File

@ -118,10 +118,13 @@ room0:
lda #5
sta NUM_DOORS
lda #<door_status
sta DOOR_STATUS
lda #>door_status
sta DOOR_STATUS_H
lda #<door_c4_r0
sta setup_door_table_loop_smc+1
lda #>door_c4_r0
sta setup_door_table_loop_smc+2
jsr setup_door_table
; set up room limits
lda #(6+128)
sta LEFT_LIMIT
@ -976,39 +979,42 @@ pit_door_cover:
; bne clear1
; rts
door_c4_r0:
.word door_c4_r0_status
.word door_c4_r0_x
.word door_c4_r0_y
.word door_c4_r0_xmin
.word door_c4_r0_xmax
door_status:
door_c4_r0_status:
c4_r0_door0_status: .byte DOOR_STATUS_CLOSED
c4_r0_door1_status: .byte DOOR_STATUS_CLOSED
c4_r0_door2_status: .byte DOOR_STATUS_LOCKED
c4_r0_door3_status: .byte DOOR_STATUS_LOCKED
c4_r0_door4_status: .byte DOOR_STATUS_LOCKED
door_x:
door_c4_r0_x:
c4_r0_door0_x: .byte 7
c4_r0_door1_x: .byte 18
c4_r0_door2_x: .byte 29
c4_r0_door3_x: .byte 31
c4_r0_door4_x: .byte 33
door_y:
door_c4_r0_y:
c4_r0_door0_y: .byte 24
c4_r0_door1_y: .byte 24
c4_r0_door2_y: .byte 24
c4_r0_door3_y: .byte 24
c4_r0_door4_y: .byte 24
door_xmin:
door_c4_r0_xmin:
c4_r0_door0_xmin: .byte 0 ; 7-4-5
c4_r0_door1_xmin: .byte 11 ; 18-4-5
c4_r0_door2_xmin: .byte 20 ; 29-4-5
c4_r0_door3_xmin: .byte 22 ; 31-4-5
c4_r0_door4_xmin: .byte 24 ; 33-4-5
door_xmax:
door_c4_r0_xmax:
c4_r0_door0_xmax: .byte 11 ; 7+4
c4_r0_door1_xmax: .byte 21 ; 18+4
c4_r0_door2_xmax: .byte 33 ; don't care