mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-30 12:34:36 +00:00
ootw: c4: start making doors generic
This commit is contained in:
parent
e1d57cbef8
commit
f28c6c34ec
@ -281,10 +281,10 @@ blast_door_left:
|
||||
|
||||
txa
|
||||
and #$f
|
||||
tax
|
||||
tay
|
||||
|
||||
lda #DOOR_STATUS_EXPLODING1
|
||||
sta door_status,X
|
||||
sta (DOOR_STATUS),Y
|
||||
|
||||
jsr recalc_walk_collision
|
||||
|
||||
@ -331,10 +331,10 @@ blast_alien_right:
|
||||
blast_door_right:
|
||||
txa
|
||||
and #$f
|
||||
tax
|
||||
tay
|
||||
|
||||
lda #DOOR_STATUS_EXPLODING1
|
||||
sta door_status,X
|
||||
sta (DOOR_STATUS),Y
|
||||
|
||||
jsr recalc_walk_collision
|
||||
|
||||
|
@ -33,43 +33,43 @@ recalc_walk_left:
|
||||
|
||||
lda PHYSICIST_X
|
||||
|
||||
ldx NUM_DOORS
|
||||
dex
|
||||
ldy NUM_DOORS
|
||||
dey
|
||||
recalc_walk_left_loop:
|
||||
|
||||
cmp door_x,X
|
||||
cmp door_x,Y
|
||||
bcc recalc_walk_left_continue ; bcs
|
||||
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
cmp #DOOR_STATUS_LOCKED
|
||||
bne recalc_walk_left_continue
|
||||
|
||||
; early exit
|
||||
lda door_x,X
|
||||
lda door_x,Y
|
||||
ora #$80
|
||||
sta LEFT_WALK_LIMIT
|
||||
jmp done_recalc_walk_left_collision
|
||||
|
||||
recalc_walk_left_continue:
|
||||
dex
|
||||
dey
|
||||
bpl recalc_walk_left_loop
|
||||
|
||||
done_recalc_walk_left_collision:
|
||||
|
||||
lda PHYSICIST_X
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
recalc_walk_right_loop:
|
||||
|
||||
cmp door_x,X
|
||||
cmp door_x,Y
|
||||
bcs recalc_walk_right_continue ; bge
|
||||
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
cmp #DOOR_STATUS_LOCKED
|
||||
bne recalc_walk_right_continue
|
||||
|
||||
; early exit
|
||||
lda door_x,X
|
||||
lda door_x,Y
|
||||
sec
|
||||
sbc #4
|
||||
ora #$80
|
||||
@ -77,8 +77,8 @@ recalc_walk_right_loop:
|
||||
jmp done_recalc_walk_right_collision
|
||||
|
||||
recalc_walk_right_continue:
|
||||
inx
|
||||
cpx NUM_DOORS
|
||||
iny
|
||||
cpy NUM_DOORS
|
||||
bne recalc_walk_right_loop
|
||||
|
||||
done_recalc_walk_right_collision:
|
||||
@ -120,15 +120,15 @@ calc_gun_right_door:
|
||||
calc_gun_right_doors:
|
||||
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
calc_gun_right_door_loop:
|
||||
|
||||
lda PHYSICIST_X
|
||||
|
||||
cmp door_x,X
|
||||
cmp door_x,Y
|
||||
bcs calc_gun_right_door_continue ; bge
|
||||
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
cmp #DOOR_STATUS_LOCKED
|
||||
beq calc_gun_right_door_there
|
||||
cmp #DOOR_STATUS_CLOSED
|
||||
@ -136,18 +136,18 @@ calc_gun_right_door_loop:
|
||||
|
||||
calc_gun_right_door_there:
|
||||
; early exit
|
||||
lda door_x,X
|
||||
lda door_x,Y
|
||||
sta RIGHT_SHOOT_LIMIT
|
||||
|
||||
txa ; set target if hit
|
||||
tya ; set target if hit
|
||||
ora #TARGET_DOOR
|
||||
sta RIGHT_SHOOT_TARGET
|
||||
|
||||
jmp done_calc_gun_right_door_collision
|
||||
|
||||
calc_gun_right_door_continue:
|
||||
inx
|
||||
cpx NUM_DOORS
|
||||
iny
|
||||
cpy NUM_DOORS
|
||||
bne calc_gun_right_door_loop
|
||||
|
||||
done_calc_gun_right_door_collision:
|
||||
@ -228,15 +228,15 @@ left_limit_ok:
|
||||
calc_gun_left_doors:
|
||||
|
||||
|
||||
ldx NUM_DOORS
|
||||
dex
|
||||
ldy NUM_DOORS
|
||||
dey
|
||||
calc_gun_left_door_loop:
|
||||
lda PHYSICIST_X
|
||||
|
||||
cmp door_x,X
|
||||
cmp door_x,Y
|
||||
bcc calc_gun_left_door_continue ; blt
|
||||
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
cmp #DOOR_STATUS_LOCKED
|
||||
beq calc_gun_left_door_there
|
||||
cmp #DOOR_STATUS_CLOSED
|
||||
@ -244,17 +244,17 @@ calc_gun_left_door_loop:
|
||||
|
||||
calc_gun_left_door_there:
|
||||
; early exit
|
||||
lda door_x,X
|
||||
lda door_x,Y
|
||||
sta LEFT_SHOOT_LIMIT
|
||||
|
||||
txa ; set target if hit
|
||||
tya ; set target if hit
|
||||
ora #TARGET_DOOR
|
||||
sta LEFT_SHOOT_TARGET
|
||||
|
||||
jmp done_calc_gun_left_door_collision
|
||||
|
||||
calc_gun_left_door_continue:
|
||||
dex
|
||||
dey
|
||||
bpl calc_gun_left_door_loop
|
||||
|
||||
done_calc_gun_left_door_collision:
|
||||
|
77
ootw/door.s
77
ootw/door.s
@ -23,27 +23,28 @@ draw_doors:
|
||||
lda NUM_DOORS
|
||||
beq done_draw_doors
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
draw_doors_loop:
|
||||
|
||||
ldy door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
tax
|
||||
|
||||
lda door_sprite_lookup_lo,Y
|
||||
lda door_sprite_lookup_lo,X
|
||||
sta INL
|
||||
lda door_sprite_lookup_hi,Y
|
||||
lda door_sprite_lookup_hi,X
|
||||
sta INH
|
||||
|
||||
actually_draw_door:
|
||||
lda door_x,X
|
||||
lda door_x,Y
|
||||
sta XPOS
|
||||
|
||||
lda door_y,X
|
||||
lda door_y,Y
|
||||
sta YPOS
|
||||
|
||||
txa
|
||||
tya
|
||||
pha
|
||||
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
cmp #DOOR_STATUS_EXPLODING1
|
||||
bcs draw_exploding_door
|
||||
|
||||
@ -52,11 +53,11 @@ actually_draw_door:
|
||||
after_door_put_sprite:
|
||||
|
||||
pla
|
||||
tax
|
||||
tay
|
||||
|
||||
draw_doors_continue:
|
||||
inx
|
||||
cpx NUM_DOORS
|
||||
iny
|
||||
cpy NUM_DOORS
|
||||
bne draw_doors_loop
|
||||
|
||||
done_draw_doors:
|
||||
@ -69,13 +70,16 @@ draw_exploding_door:
|
||||
and #$7
|
||||
bne not_done_exploding_door
|
||||
|
||||
inc door_status,X
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
clc
|
||||
adc #1
|
||||
sta (DOOR_STATUS),Y
|
||||
|
||||
cmp #DOOR_STATUS_EXPLODING6
|
||||
bcc not_done_exploding_door
|
||||
|
||||
lda #DOOR_STATUS_EXPLODED
|
||||
sta door_status,X
|
||||
sta (DOOR_STATUS),Y
|
||||
|
||||
not_done_exploding_door:
|
||||
dec XPOS
|
||||
@ -96,11 +100,11 @@ handle_doors:
|
||||
lda NUM_DOORS
|
||||
beq done_handle_doors
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
handle_doors_loop:
|
||||
|
||||
; state machine
|
||||
lda door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
|
||||
; if locked->do nothing
|
||||
cmp #DOOR_STATUS_LOCKED
|
||||
@ -126,11 +130,14 @@ handle_doors_loop:
|
||||
; if opening, continue to open
|
||||
; if closing, continue to close
|
||||
handle_door_inc_state:
|
||||
inc door_status,X
|
||||
lda (DOOR_STATUS),Y
|
||||
clc
|
||||
adc #1
|
||||
sta (DOOR_STATUS),Y
|
||||
|
||||
handle_doors_continue:
|
||||
inx
|
||||
cpx NUM_DOORS
|
||||
iny
|
||||
cpy NUM_DOORS
|
||||
bne handle_doors_loop
|
||||
|
||||
done_handle_doors:
|
||||
@ -139,19 +146,17 @@ done_handle_doors:
|
||||
handle_doors_open:
|
||||
|
||||
; only open/close if on same level
|
||||
ldy door_y,X
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
cpy PHYSICIST_Y
|
||||
lda door_y,Y
|
||||
clc
|
||||
adc #4
|
||||
cmp PHYSICIST_Y
|
||||
bne close_door
|
||||
|
||||
lda PHYSICIST_X
|
||||
cmp door_xmax,X
|
||||
cmp door_xmax,Y
|
||||
bcs close_door ; bge
|
||||
|
||||
cmp door_xmin,X
|
||||
cmp door_xmin,Y
|
||||
bcc close_door ; blt
|
||||
|
||||
; made it here, we are in bounds, stay open
|
||||
@ -160,31 +165,29 @@ handle_doors_open:
|
||||
|
||||
close_door:
|
||||
lda #DOOR_STATUS_CLOSING1
|
||||
sta door_status,X
|
||||
sta (DOOR_STATUS),Y
|
||||
jmp handle_doors_continue
|
||||
|
||||
handle_doors_closed:
|
||||
|
||||
; only open if on same level
|
||||
|
||||
ldy door_y,X
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
iny
|
||||
cpy PHYSICIST_Y
|
||||
lda door_y,Y
|
||||
clc
|
||||
adc #4
|
||||
cmp PHYSICIST_Y
|
||||
bne handle_doors_continue
|
||||
|
||||
lda PHYSICIST_X
|
||||
cmp door_xmax,X
|
||||
cmp door_xmax,Y
|
||||
bcs handle_doors_continue
|
||||
|
||||
cmp door_xmin,X
|
||||
cmp door_xmin,Y
|
||||
bcc handle_doors_continue
|
||||
|
||||
open_door:
|
||||
lda #DOOR_STATUS_OPENING1
|
||||
sta door_status,X
|
||||
sta (DOOR_STATUS),Y
|
||||
jmp handle_doors_continue
|
||||
|
||||
|
||||
|
@ -118,6 +118,11 @@ room0:
|
||||
lda #5
|
||||
sta NUM_DOORS
|
||||
|
||||
lda #<door_status
|
||||
sta DOOR_STATUS
|
||||
lda #>door_status
|
||||
sta DOOR_STATUS_H
|
||||
|
||||
lda #(6+128)
|
||||
sta LEFT_LIMIT
|
||||
lda #(39+128)
|
||||
@ -974,12 +979,6 @@ pit_door_cover:
|
||||
|
||||
|
||||
|
||||
door_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_status:
|
||||
c4_r0_door0_status: .byte DOOR_STATUS_CLOSED
|
||||
@ -995,6 +994,13 @@ door_x:
|
||||
c4_r0_door3_x: .byte 31
|
||||
c4_r0_door4_x: .byte 33
|
||||
|
||||
door_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:
|
||||
c4_r0_door0_xmin: .byte 0 ; 7-4-5
|
||||
c4_r0_door1_xmin: .byte 11 ; 18-4-5
|
||||
|
12
ootw/zp.inc
12
ootw/zp.inc
@ -118,6 +118,18 @@ LZ4_DONE = $96
|
||||
; More zero-page addresses
|
||||
; we try not to conflict with anything DOS, MONITOR or BASIC related
|
||||
|
||||
|
||||
DOOR_STATUS = $C0
|
||||
DOOR_STATUS_H = $C1
|
||||
DOOR_X = $C2
|
||||
DOOR_X_H = $C3
|
||||
DOOR_Y = $C4
|
||||
DOOR_Y_H = $C5
|
||||
DOOR_XMIN = $C6
|
||||
DOOR_XMIN_H = $C7
|
||||
DOOR_XMAX = $C8
|
||||
DOOR_XMAX_H = $C9
|
||||
|
||||
LEFT_SHOOT_TARGET = $CF ; ALL
|
||||
RIGHT_SHOOT_TARGET = $D0 ; ALL
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user