dos33fsprogs/games/ootw/ootw_c2_elevator.s

841 lines
14 KiB
ArmAsm
Raw Normal View History

2019-07-09 15:23:48 +00:00
; Ootw Checkpoint2 -- Using the elevator
ootw_elevator:
2019-07-12 17:12:06 +00:00
;===========================
; load dome for later
lda #>(dome_rle)
sta GBASH
lda #<(dome_rle)
sta GBASL
lda #$10 ; load to page $1000
jsr load_rle_gr
2019-07-10 18:25:04 +00:00
;==============================
; setup physicist
lda #16
sta PHYSICIST_Y
2019-07-09 15:23:48 +00:00
;==============================
; setup per-room variables
check_elevator7:
2019-07-09 15:23:48 +00:00
lda WHICH_JAIL
cmp #7
bne check_elevator8
2019-07-09 15:23:48 +00:00
elevator7:
2019-07-10 12:19:28 +00:00
lda #(-4+128)
2019-07-09 15:23:48 +00:00
sta LEFT_LIMIT
2019-07-11 15:28:30 +00:00
lda #(21+128)
2019-07-09 15:23:48 +00:00
sta RIGHT_LIMIT
2019-07-11 15:28:30 +00:00
; set left exit
2019-07-10 12:19:28 +00:00
lda #3
sta eel_smc+1
2019-07-09 15:23:48 +00:00
2019-07-11 16:30:34 +00:00
; set up exit
lda #10
2019-07-11 16:30:34 +00:00
sta going_up_smc+1
; set down exit
lda #8
2019-07-11 16:30:34 +00:00
sta going_down_smc+1
lda #48
sta ELEVATOR_OFFSET
2019-07-11 16:30:34 +00:00
2019-07-10 12:19:28 +00:00
jmp elevator_setup_done
2019-07-09 15:23:48 +00:00
check_elevator8:
cmp #8
bne check_elevator9
elevator8:
2019-07-09 15:23:48 +00:00
lda #(-4+128)
sta LEFT_LIMIT
2019-07-11 16:30:34 +00:00
lda #(21+128)
2019-07-09 15:23:48 +00:00
sta RIGHT_LIMIT
2019-07-11 16:30:34 +00:00
; set left exit
lda #4
2019-07-11 16:30:34 +00:00
sta eel_smc+1
; set up exit
lda #7
2019-07-11 16:30:34 +00:00
sta going_up_smc+1
; set down exit
lda #9
2019-07-11 16:30:34 +00:00
sta going_down_smc+1
lda #96
sta ELEVATOR_OFFSET
2019-07-11 16:30:34 +00:00
jmp elevator_setup_done
check_elevator9:
cmp #9
bne elevator10
2019-07-11 16:30:34 +00:00
elevator9:
2019-07-11 16:30:34 +00:00
lda #(-4+128)
sta LEFT_LIMIT
lda #(21+128)
sta RIGHT_LIMIT
; set left exit
lda #6
2019-07-11 16:30:34 +00:00
sta eel_smc+1
; set up exit
lda #8
2019-07-11 16:30:34 +00:00
sta going_up_smc+1
; no down exit
lda #144
sta ELEVATOR_OFFSET
2019-07-11 16:30:34 +00:00
jmp elevator_setup_done
; The dome
elevator10:
2019-07-11 16:30:34 +00:00
lda #(4+128)
2019-07-11 16:30:34 +00:00
sta LEFT_LIMIT
lda #(30+128)
sta RIGHT_LIMIT
; set up exit
; no up exit
; set down exit
lda #7
2019-07-11 16:30:34 +00:00
sta going_down_smc+1
lda #0
sta ELEVATOR_OFFSET
2019-07-11 16:30:34 +00:00
; fallthrough
2019-07-10 12:19:28 +00:00
2019-07-09 15:23:48 +00:00
elevator_setup_done:
;=============================
; load background image
jsr elevator_load_background
2019-07-09 15:23:48 +00:00
;=================================
; copy to screen
jsr gr_copy_to_current
2019-07-12 16:24:37 +00:00
; jsr page_flip
2019-07-09 15:23:48 +00:00
;============================
; init shields
jsr init_shields
;=====================
; setup walk collision
jsr recalc_walk_collision
2019-07-09 15:23:48 +00:00
;=================================
; setup vars
lda #0
sta GAIT
;============================
; Elevator Loop
;============================
elevator_loop:
2019-07-11 15:28:30 +00:00
lda #0
sta GAME_OVER
2019-07-09 15:23:48 +00:00
;================================
; copy background to current page
jsr gr_copy_to_current
2019-07-10 18:25:04 +00:00
;================================
; draw elevator
2019-07-11 15:28:30 +00:00
lda #16
2019-07-10 18:25:04 +00:00
sta XPOS
lda #32
sta YPOS
2019-07-11 15:28:30 +00:00
lda FRAMEL
and #$10
bne elevator_anim2
lda #<elevator_sprite1
2019-07-10 18:25:04 +00:00
sta INL
2019-07-11 15:28:30 +00:00
lda #>elevator_sprite1
2019-07-10 18:25:04 +00:00
sta INH
2019-07-11 15:28:30 +00:00
jmp draw_elevator
2019-07-10 18:25:04 +00:00
2019-07-11 15:28:30 +00:00
elevator_anim2:
lda #<elevator_sprite2
sta INL
lda #>elevator_sprite2
sta INH
draw_elevator:
2019-07-10 18:25:04 +00:00
jsr put_sprite_crop
2019-07-09 15:23:48 +00:00
;===============================
; check keyboard
jsr handle_keypress
;===============================
; move physicist
jsr move_physicist
;===============
; check room limits
jsr check_screen_limit
;===============
; draw physicist
jsr draw_physicist
;================
; handle gun
;================
jsr handle_gun
2019-07-09 15:23:48 +00:00
;===============
; page flip
jsr page_flip
;================
; inc frame count
inc FRAMEL
bne elevator_frame_no_oflo
inc FRAMEH
elevator_frame_no_oflo:
2019-07-11 16:30:34 +00:00
;==========================
; handle elevator
;==========================
lda PHYSICIST_X
cmp #16
2019-07-11 16:30:34 +00:00
bcc not_on_elevator ; blt
cmp #23
bcs not_on_elevator ; bge
2019-07-11 16:30:34 +00:00
lda #1
bne update_elevator ; bra
2019-07-11 16:30:34 +00:00
not_on_elevator:
lda #0
update_elevator:
sta ON_ELEVATOR
;==========================
; handle elevating
;==========================
lda PHYSICIST_STATE
elevator_check_up:
cmp #P_ELEVATING_UP
bne elevator_check_down
going_up:
2019-07-12 16:24:37 +00:00
jsr move_elevator
2019-07-11 16:30:34 +00:00
going_up_smc:
lda #7
sta WHICH_JAIL
2019-07-12 16:24:37 +00:00
2019-07-11 16:30:34 +00:00
jmp done_elevator
elevator_check_down:
cmp #P_ELEVATING_DOWN
bne going_nowhere
going_down:
2019-07-12 16:24:37 +00:00
jsr move_elevator
2019-07-11 16:30:34 +00:00
going_down_smc:
lda #4
sta WHICH_JAIL
2019-07-12 16:24:37 +00:00
jmp done_elevator
2019-07-11 16:30:34 +00:00
going_nowhere:
2019-07-12 04:43:23 +00:00
;==================================
; see if we should play city movie
;==================================
2019-07-11 16:30:34 +00:00
2019-07-12 04:43:23 +00:00
lda WHICH_JAIL
cmp #10
bne no_city_movie
lda PHYSICIST_X
cmp #28
bne no_city_movie
lda CITY_MOVIE_SEEN
bne no_city_movie
jsr play_city_movie
lda #1
sta CITY_MOVIE_SEEN
lda #0
sta PHYSICIST_STATE
2019-07-11 16:30:34 +00:00
2019-07-12 04:43:23 +00:00
no_city_movie:
2019-07-11 16:30:34 +00:00
;==========================
; check if done this room
;==========================
2019-07-09 15:23:48 +00:00
lda GAME_OVER
beq still_in_elevator
cmp #$ff ; if $ff, we died
beq done_elevator
;===============================
; check if exited room to right
cmp #1
beq elevator_exit_left
2019-07-11 15:28:30 +00:00
; exit to right ???
; it's never possible to exit right from an elevator screen
2019-07-09 15:23:48 +00:00
elevator_exit_right:
2019-07-11 15:28:30 +00:00
jmp still_in_elevator
2019-07-09 15:23:48 +00:00
elevator_exit_left:
lda #37
sta PHYSICIST_X
eel_smc:
lda #0
sta WHICH_CAVE
2019-07-10 12:19:28 +00:00
jmp done_elevator
2019-07-09 15:23:48 +00:00
; loop forever
still_in_elevator:
jmp elevator_loop
done_elevator:
rts
;===============================
; load proper background to $c00
;===============================
elevator_load_background:
lda ELEVATOR_OFFSET
cmp #24
2019-07-12 16:52:39 +00:00
bcs elevator_bg_no_dome ; bge
; dome, dome on the range
2019-07-12 17:12:06 +00:00
; loaded the dome at entry to level, rather than every cycle
2019-07-12 16:52:39 +00:00
lda ELEVATOR_OFFSET
tay
jsr gr_copy_to_offset
rts
elevator_bg_no_dome:
2019-07-10 12:19:28 +00:00
ldy #0
elevator_background_loop:
; self modify line we're on
2019-07-10 18:25:04 +00:00
lda gr_offsets_l,Y
2019-07-10 12:19:28 +00:00
sta line0_left_loop+1
sta line0_center_loop+1
2019-07-10 18:25:04 +00:00
sta line0_right_loop+1
2019-07-10 12:19:28 +00:00
2019-07-10 18:25:04 +00:00
lda gr_offsets_h,Y
2019-07-10 12:19:28 +00:00
clc
adc #$8
sta line0_left_loop+2
sta line0_center_loop+2
2019-07-10 18:25:04 +00:00
sta line0_right_loop+2
2019-07-10 12:19:28 +00:00
sty TEMP
; calculate framebuffer offset
tya
clc
adc ELEVATOR_OFFSET
sec
sbc #24
tay
; draw left part
lda elevator_fb,Y
and #$f0
beq elevator_right_none
lda #$88
elevator_right_none:
ldx #0
line0_left_loop:
sta $c00,X
inx
2019-07-10 18:25:04 +00:00
cpx #17
bne line0_left_loop
; draw center part
lda elevator_fb,Y
and #$0f
beq line0_center_loop
lda #$88
line0_center_loop:
sta $c00,X
inx
cpx #25
bne line0_center_loop
lda #$88
line0_right_loop:
sta $c00,X
inx
2019-07-10 18:25:04 +00:00
cpx #40
bne line0_right_loop
ldy TEMP
2019-07-10 12:19:28 +00:00
iny
2019-07-10 18:25:04 +00:00
cpy #24
2019-07-10 12:19:28 +00:00
bne elevator_background_loop
2019-07-10 12:19:28 +00:00
rts
elevator_fb:
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
; /----------------\
.byte $80 ; ######## ######## 0 (24)
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ;+######## ########
.byte $80 ; ######## ######## ; 24 (48) (Room4)
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ;+######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ;+######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ;+######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ;+######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $80 ; ######## ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $00 ; ########
.byte $80 ; ######## ########
.byte $88 ; ####################
.byte $88 ; ####################
.byte $88 ; ####################
.byte $88 ; ####################
.byte $88 ; ####################
.byte $88 ; ####################
.byte $88 ;+####################
2019-07-10 18:25:04 +00:00
2019-07-11 15:28:30 +00:00
2019-07-10 18:25:04 +00:00
2019-07-12 04:43:23 +00:00
;===================================
; play city movie
;===================================
play_city_movie:
ldy #0
city_loop:
; load background
lda city_frames+1,Y
sta GBASH
lda city_frames,Y
sta GBASL
tya
pha
lda #$c
jsr load_rle_gr
jsr gr_copy_to_current
jsr page_flip
ldx #2
city_long_delay:
lda #250
jsr WAIT
dex
bne city_long_delay
pla
tay
iny
iny
cpy #36
bne city_loop
city_end:
jsr elevator_load_background
rts
city_frames:
.word city01_rle ; 0
.word city02_rle ; 1
.word city03_rle ; 2
.word city04_rle ; 3
.word city05_rle ; 4
.word city06_rle ; 5
.word city07_rle ; 6
.word city08_rle ; 7
.word city09_rle ; 8
.word city10_rle ; 9
.word city11_rle ; 10
.word city12_rle ; 11
.word city13_rle ; 12
.word city14_rle ; 13
.word city14_rle ; 14
.word city14_rle ; 15
.word city14_rle ; 16
.word city14_rle ; 17
2019-07-12 16:24:37 +00:00
;====================================
; run the elevator ride
;====================================
move_elevator:
lda PHYSICIST_STATE
cmp #P_ELEVATING_UP
bne move_elevator_down
move_elevator_up:
lda WHICH_JAIL
cmp #10 ; if top floor, no up
beq elevator_all_done
lda ELEVATOR_OFFSET
sec
sbc #48
sta elevator_end_smc+1
lda #$C6 ; dec
sta elevator_direction_smc
jmp move_elevator_loop
move_elevator_down:
lda WHICH_JAIL
cmp #9 ; if bottom floor, no down
beq elevator_all_done
lda ELEVATOR_OFFSET
clc
adc #48
sta elevator_end_smc+1
lda #$E6 ; inc
sta elevator_direction_smc
move_elevator_loop:
lda #0
sta PHYSICIST_STATE
elevator_direction_smc:
inc ELEVATOR_OFFSET ; E6=inc, C6=DEC
jsr elevator_load_background
jsr gr_copy_to_current
;===============
; draw physicist
jsr draw_physicist
2019-07-12 17:12:06 +00:00
;===============
; increment frame count
inc FRAMEL
bne elevator_moving_frame_no_oflo
inc FRAMEH
elevator_moving_frame_no_oflo:
2019-07-12 16:24:37 +00:00
;================================
; draw elevator moving
lda #16
sta XPOS
lda #32
sta YPOS
lda FRAMEL
2019-07-12 17:12:06 +00:00
lsr
; lsr
and #$6
tay
2019-07-12 16:24:37 +00:00
2019-07-12 17:12:06 +00:00
lda elevator_moving_sprites,Y
2019-07-12 16:24:37 +00:00
sta INL
2019-07-12 17:12:06 +00:00
lda elevator_moving_sprites+1,Y
2019-07-12 16:24:37 +00:00
sta INH
jsr put_sprite_crop
2019-07-12 17:12:06 +00:00
;========================
; flip pages
2019-07-12 16:24:37 +00:00
jsr page_flip
lda ELEVATOR_OFFSET
elevator_end_smc:
cmp #$ff
bne move_elevator_loop
elevator_all_done:
lda #0
sta PHYSICIST_STATE
rts
2019-07-12 17:12:06 +00:00
elevator_sprite1:
.byte 10,1
.byte $5A,$25,$25,$25,$25,$25,$25,$25,$25,$A5
elevator_sprite2:
.byte 10,1
.byte $A5,$25,$25,$25,$25,$25,$25,$25,$25,$5A
; low/high nothing
; high/low xBxxxxxx
; low/high xxBBBxxx
; high low xxxxxxBx
elevator_moving_sprites:
.word elevator_moving_sprite0
.word elevator_moving_sprite1
.word elevator_moving_sprite2
.word elevator_moving_sprite3
elevator_moving_sprite0:
.byte 10,1
.byte $5A,$25,$25,$25,$25,$25,$25,$25,$25,$A5
elevator_moving_sprite1:
.byte 10,1
.byte $A5,$25,$75,$25,$25,$25,$25,$25,$25,$5A
elevator_moving_sprite2:
.byte 10,1
.byte $5A,$25,$25,$75,$75,$75,$25,$25,$25,$A5
elevator_moving_sprite3:
.byte 10,1
.byte $A5,$25,$25,$25,$25,$25,$25,$75,$25,$5A