dos33fsprogs/ootw/door.s

402 lines
6.9 KiB
ArmAsm
Raw Normal View History

2019-08-15 16:30:00 +00:00
DOOR_STATUS_OPENING1 = $00
DOOR_STATUS_OPENING2 = $01
DOOR_STATUS_OPEN = $02
2019-08-15 15:36:53 +00:00
DOOR_STATUS_CLOSING1 = $03
DOOR_STATUS_CLOSING2 = $04
DOOR_STATUS_CLOSED = $05
DOOR_STATUS_EXPLODED = $06
DOOR_STATUS_LOCKED = $07
2019-08-15 19:12:34 +00:00
DOOR_STATUS_EXPLODING1 = $08
DOOR_STATUS_EXPLODING2 = $09
DOOR_STATUS_EXPLODING3 = $0A
DOOR_STATUS_EXPLODING4 = $0B
DOOR_STATUS_EXPLODING5 = $0C
DOOR_STATUS_EXPLODING6 = $0D
2019-08-08 04:38:55 +00:00
;==================================
; draw_doors
;==================================
; be sure to smc to point to right place
2019-08-08 04:38:55 +00:00
draw_doors:
lda NUM_DOORS
beq done_draw_doors
2019-08-08 04:38:55 +00:00
2019-08-16 18:34:16 +00:00
ldy #0
draw_doors_loop:
2019-08-08 04:38:55 +00:00
2019-08-16 18:34:16 +00:00
lda (DOOR_STATUS),Y
tax
2019-08-08 04:38:55 +00:00
2019-08-16 18:34:16 +00:00
lda door_sprite_lookup_lo,X
2019-08-15 15:36:53 +00:00
sta INL
2019-08-16 18:34:16 +00:00
lda door_sprite_lookup_hi,X
2019-08-15 15:36:53 +00:00
sta INH
2019-08-08 04:38:55 +00:00
actually_draw_door:
lda (DOOR_X),Y
2019-08-08 04:38:55 +00:00
sta XPOS
2019-08-15 19:12:34 +00:00
lda (DOOR_Y),Y
2019-08-08 04:38:55 +00:00
sta YPOS
2019-08-16 18:34:16 +00:00
tya
pha
2019-08-16 18:34:16 +00:00
lda (DOOR_STATUS),Y
2019-08-15 19:12:34 +00:00
cmp #DOOR_STATUS_EXPLODING1
bcs draw_exploding_door
2019-08-08 04:38:55 +00:00
jsr put_sprite
2019-08-15 19:12:34 +00:00
after_door_put_sprite:
pla
2019-08-16 18:34:16 +00:00
tay
draw_doors_continue:
2019-08-16 18:34:16 +00:00
iny
cpy NUM_DOORS
bne draw_doors_loop
2019-08-08 04:38:55 +00:00
done_draw_doors:
rts
2019-08-15 19:12:34 +00:00
draw_exploding_door:
lda FRAMEL
and #$7
bne not_done_exploding_door
2019-08-16 18:34:16 +00:00
lda (DOOR_STATUS),Y
clc
adc #1
sta (DOOR_STATUS),Y
2019-08-15 19:12:34 +00:00
cmp #DOOR_STATUS_EXPLODING6
bcc not_done_exploding_door
lda #DOOR_STATUS_EXPLODED
2019-08-16 18:34:16 +00:00
sta (DOOR_STATUS),Y
2019-08-15 19:12:34 +00:00
not_done_exploding_door:
dec XPOS
jsr put_sprite
jmp after_door_put_sprite
2019-08-08 04:38:55 +00:00
2019-08-15 16:30:00 +00:00
;==========================
2019-08-08 04:38:55 +00:00
;==========================
; handle doors
2019-08-15 16:30:00 +00:00
;==========================
;==========================
2019-08-08 04:38:55 +00:00
handle_doors:
2019-08-15 16:30:00 +00:00
lda NUM_DOORS
beq done_handle_doors
2019-08-16 18:34:16 +00:00
ldy #0
2019-08-15 16:30:00 +00:00
handle_doors_loop:
; state machine
2019-08-16 18:34:16 +00:00
lda (DOOR_STATUS),Y
2019-08-08 04:38:55 +00:00
2019-08-15 16:30:00 +00:00
; if locked->do nothing
cmp #DOOR_STATUS_LOCKED
beq handle_doors_continue
2019-08-08 04:38:55 +00:00
2019-08-15 16:30:00 +00:00
; if exploded->do nothing
cmp #DOOR_STATUS_EXPLODED
beq handle_doors_continue
2019-08-08 04:38:55 +00:00
2019-08-15 16:30:00 +00:00
; if closed and xpos/ypos in range: open
; if open and xpos/ypos not ni range: close
cmp #DOOR_STATUS_OPEN
beq handle_doors_open
cmp #DOOR_STATUS_CLOSED
beq handle_doors_closed
2019-08-08 04:38:55 +00:00
2019-08-15 16:30:00 +00:00
; if exploding: continue exploding
2019-08-15 19:12:34 +00:00
; we handle the increment elsewhere
cmp #DOOR_STATUS_EXPLODING1
bcs handle_doors_continue ; bge
2019-08-15 16:30:00 +00:00
; if opening, continue to open
; if closing, continue to close
handle_door_inc_state:
2019-08-16 18:34:16 +00:00
lda (DOOR_STATUS),Y
clc
adc #1
sta (DOOR_STATUS),Y
2019-08-08 04:38:55 +00:00
2019-08-15 16:30:00 +00:00
handle_doors_continue:
2019-08-16 18:34:16 +00:00
iny
cpy NUM_DOORS
2019-08-15 16:30:00 +00:00
bne handle_doors_loop
done_handle_doors:
2019-08-08 04:38:55 +00:00
rts
2019-08-15 16:30:00 +00:00
handle_doors_open:
; only open/close if on same level
lda (DOOR_Y),Y
2019-08-16 18:34:16 +00:00
clc
adc #4
cmp PHYSICIST_Y
2019-08-15 16:30:00 +00:00
bne close_door
lda PHYSICIST_X
cmp (DOOR_XMAX),Y
2019-08-15 16:30:00 +00:00
bcs close_door ; bge
cmp (DOOR_XMIN),Y
2019-08-15 16:30:00 +00:00
bcc close_door ; blt
; made it here, we are in bounds, stay open
jmp handle_doors_continue
close_door:
lda #DOOR_STATUS_CLOSING1
2019-08-16 18:34:16 +00:00
sta (DOOR_STATUS),Y
2019-08-15 16:30:00 +00:00
jmp handle_doors_continue
handle_doors_closed:
; only open if on same level
lda (DOOR_Y),Y
2019-08-16 18:34:16 +00:00
clc
adc #4
cmp PHYSICIST_Y
2019-08-15 16:30:00 +00:00
bne handle_doors_continue
lda PHYSICIST_X
cmp (DOOR_XMAX),Y
2019-08-15 16:30:00 +00:00
bcs handle_doors_continue
cmp (DOOR_XMIN),Y
2019-08-15 16:30:00 +00:00
bcc handle_doors_continue
open_door:
lda #DOOR_STATUS_OPENING1
2019-08-16 18:34:16 +00:00
sta (DOOR_STATUS),Y
2019-08-15 16:30:00 +00:00
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
2019-08-15 16:30:00 +00:00
2019-08-08 04:38:55 +00:00
;======================================
;======================================
; door sprites
;======================================
;======================================
2019-08-15 15:36:53 +00:00
door_sprite_lookup_lo:
.byte <door_opening_sprite1 ; DOOR_STATUS_OPENING1
.byte <door_opening_sprite2 ; DOOR_STATUS_OPENING2
2019-08-15 16:30:00 +00:00
.byte <door_open_sprite ; DOOR_STATUS_OPEN
2019-08-15 15:36:53 +00:00
.byte <door_closing_sprite1 ; DOOR_STATUS_CLOSING1
.byte <door_closing_sprite2 ; DOOR_STATUS_CLOSING2
.byte <door_closed_sprite ; DOOR_STATUS_CLOSED
.byte <door_exploded_sprite ; DOOR_STATUS_EXPLODED
.byte <door_closed_sprite ; DOOR_STATUS_LOCKED
2019-08-15 19:12:34 +00:00
.byte <door_exploding_sprite1 ; DOOR_STATUS_EXPLODING1
.byte <door_exploding_sprite2 ; DOOR_STATUS_EXPLODING2
.byte <door_exploding_sprite3 ; DOOR_STATUS_EXPLODING3
.byte <door_exploding_sprite4 ; DOOR_STATUS_EXPLODING4
.byte <door_exploding_sprite5 ; DOOR_STATUS_EXPLODING5
.byte <door_exploding_sprite6 ; DOOR_STATUS_EXPLODING6
2019-08-15 15:36:53 +00:00
door_sprite_lookup_hi:
.byte >door_opening_sprite1 ; DOOR_STATUS_OPENING1
.byte >door_opening_sprite2 ; DOOR_STATUS_OPENING2
2019-08-15 16:30:00 +00:00
.byte >door_open_sprite ; DOOR_STATUS_OPEN
2019-08-15 15:36:53 +00:00
.byte >door_closing_sprite1 ; DOOR_STATUS_CLOSING1
.byte >door_closing_sprite2 ; DOOR_STATUS_CLOSING2
.byte >door_closed_sprite ; DOOR_STATUS_CLOSED
.byte >door_exploded_sprite ; DOOR_STATUS_EXPLODED
.byte >door_closed_sprite ; DOOR_STATUS_LOCKED
2019-08-15 19:12:34 +00:00
.byte >door_exploding_sprite1 ; DOOR_STATUS_EXPLODING1
.byte >door_exploding_sprite2 ; DOOR_STATUS_EXPLODING2
.byte >door_exploding_sprite3 ; DOOR_STATUS_EXPLODING3
.byte >door_exploding_sprite4 ; DOOR_STATUS_EXPLODING4
.byte >door_exploding_sprite5 ; DOOR_STATUS_EXPLODING5
.byte >door_exploding_sprite6 ; DOOR_STATUS_EXPLODING6
2019-08-15 15:36:53 +00:00
2019-08-08 04:38:55 +00:00
door_closed_sprite:
.byte 1,10
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
.byte $00
door_open_sprite:
.byte 1,10
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
2019-08-15 15:36:53 +00:00
door_opening_sprite2:
2019-08-08 04:38:55 +00:00
door_closing_sprite1:
.byte 1,10
.byte $00
.byte $A0
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $0A
.byte $00
2019-08-15 15:36:53 +00:00
door_opening_sprite1:
2019-08-08 04:38:55 +00:00
door_closing_sprite2:
.byte 1,10
.byte $00
.byte $00
.byte $00
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $00
.byte $00
.byte $00
door_exploded_sprite:
.byte 1,10
.byte $00
.byte $A5
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $AA
.byte $A5
2019-08-15 15:36:53 +00:00
door_exploding_sprite1:
2019-08-15 19:12:34 +00:00
.byte 3,10
.byte $AA,$FF,$66
.byte $AA,$FF,$66
.byte $AA,$FF,$AA
.byte $AA,$FF,$AA
.byte $AA,$FF,$AA
.byte $AA,$FF,$AA
.byte $AA,$FF,$AA
.byte $AA,$FF,$AA
.byte $AA,$FF,$66
.byte $AA,$FF,$66
door_exploding_sprite2:
.byte 3,10
.byte $AA,$FF,$EE
.byte $AA,$FF,$EE
.byte $EE,$FF,$EE
.byte $FF,$FF,$EE
.byte $FF,$FF,$EE
.byte $FF,$FF,$EE
.byte $EE,$FF,$EE
.byte $AA,$FF,$EE
.byte $AA,$FF,$EE
.byte $AA,$FF,$EE
door_exploding_sprite3:
.byte 3,10
.byte $AA,$00,$AA
.byte $AA,$A5,$AA
.byte $FF,$AA,$AA
.byte $FF,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $FF,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$A5,$AA
door_exploding_sprite4:
.byte 3,10
.byte $AA,$00,$AA
.byte $AA,$A5,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $FF,$AA,$AA
.byte $FF,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $FF,$AA,$AA
.byte $AA,$A5,$AA
door_exploding_sprite5:
.byte 3,10
.byte $AA,$00,$AA
.byte $AA,$A5,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $FA,$AA,$AA
.byte $AF,$A5,$AA
door_exploding_sprite6:
.byte 3,10
.byte $AA,$00,$AA
.byte $AA,$A5,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $AA,$AA,$AA
.byte $FA,$AA,$AA
.byte $AF,$A5,$AA