dos33fsprogs/games/ootw/ootw_c1/ootw_c1_rope.s

427 lines
6.0 KiB
ArmAsm
Raw Normal View History

2019-01-19 04:23:18 +00:00
; Ootw Rope course
ootw_rope:
;===========================
; Enable graphics
bit LORES
bit SET_GR
bit FULLGR
;===========================
; Setup pages (is this necessary?)
lda #0
sta DRAW_PAGE
lda #1
sta DISP_PAGE
;=================================
2019-01-19 04:23:18 +00:00
; Setup right/left exit paramaters
lda #(39+128)
2019-01-19 04:23:18 +00:00
sta RIGHT_LIMIT
sta RIGHT_WALK_LIMIT
lda #(11+128)
2019-01-19 04:23:18 +00:00
sta LEFT_LIMIT
sta LEFT_WALK_LIMIT
2019-01-19 04:23:18 +00:00
2019-03-17 05:28:42 +00:00
lda #0
sta SWING_PROGRESS
2019-01-21 05:30:17 +00:00
2019-01-19 04:23:18 +00:00
;=============================
; Load background to $c00
lda BEFORE_SWING
beq after_swing_bg
before_swing_bg:
2021-03-23 13:21:30 +00:00
lda #<(rope_lzsa)
sta getsrc_smc+1 ; LZSA_SRC_LO
lda #>(rope_lzsa)
sta getsrc_smc+2 ; LZSA_SRC_HI
jmp load_swing_bg
after_swing_bg:
2021-03-23 13:21:30 +00:00
lda #<(broke_rope_lzsa)
sta getsrc_smc+1 ; LZSA_SRC_LO
lda #>(broke_rope_lzsa)
sta getsrc_smc+2 ; LZSA_SRC_HI
load_swing_bg:
lda #$c ; load image off-screen $c00
2021-03-23 13:21:30 +00:00
jsr decompress_lzsa2_fast
2019-01-19 04:23:18 +00:00
;================================
; Load quake background to $BC00
jsr gr_make_quake
2019-01-19 04:23:18 +00:00
;=================================
; copy $c00 to both pages $400/$800
2019-01-19 04:23:18 +00:00
; jsr gr_copy_to_current
; jsr page_flip
2019-01-19 04:23:18 +00:00
;=================================
; setup vars
lda #0
sta GAIT
sta GAME_OVER
lda #3
sta WHICH_CAVE
2019-03-25 04:12:09 +00:00
jsr setup_beast
;============================
2019-01-19 04:23:18 +00:00
;============================
; Rope Loop
;============================
2019-03-25 04:12:09 +00:00
;============================
2019-01-19 04:23:18 +00:00
rope_loop:
2019-03-17 05:28:42 +00:00
;============================
; Check if swinging
;============================
lda SWING_PROGRESS
beq no_swing
2019-03-19 04:31:18 +00:00
cmp #80 ; only load background on first frame
bne swing_not_first
2021-03-23 13:21:30 +00:00
lda #<no_rope_lzsa
sta getsrc_smc+1 ; LZSA_SRC_LO
lda #>no_rope_lzsa
sta getsrc_smc+2 ; LZSA_SRC_HI
2019-03-19 04:31:18 +00:00
lda #$C ; load image off-screen $C00
2021-03-23 13:21:30 +00:00
jsr decompress_lzsa2_fast
2019-03-19 04:31:18 +00:00
swing_not_first:
2019-03-17 05:28:42 +00:00
dec SWING_PROGRESS
dec SWING_PROGRESS
ldx SWING_PROGRESS
lda swing_progression,X
2021-03-23 13:21:30 +00:00
sta getsrc_smc+1 ; LZSA_SRC_LO
2019-03-17 05:28:42 +00:00
lda swing_progression+1,X
2021-03-23 13:21:30 +00:00
sta getsrc_smc+2 ; LZSA_SRC_HI
2019-03-19 04:31:18 +00:00
lda #$10 ; load image off-screen $1000
2021-03-23 13:21:30 +00:00
jsr decompress_lzsa2_fast
2019-03-17 05:28:42 +00:00
2019-03-19 04:31:18 +00:00
jsr gr_overlay_40x40
; FIXME
; jsr gr_make_quake ; make quake
2019-03-17 05:28:42 +00:00
2019-03-19 04:31:18 +00:00
jmp beyond_quake
2019-03-17 05:28:42 +00:00
no_swing:
2019-01-19 04:23:18 +00:00
;================================
; handle earthquakes
2019-01-19 04:23:18 +00:00
jsr earthquake_handler
2019-01-19 04:23:18 +00:00
2019-03-19 04:31:18 +00:00
beyond_quake:
2019-01-19 04:23:18 +00:00
;===============================
; check keyboard
jsr handle_keypress
;===============================
; move physicist
jsr move_physicist
;===============================
; check screen limits
jsr check_screen_limit
2019-03-25 04:12:09 +00:00
;================
; handle beast
lda BEAST_OUT
beq rope_no_beast
;================
; move beast
jsr move_beast
;================
; draw beast
; adjust y for slope
; shift by 2 from physicist as beast is 9 wide (vs 5)
lda BEAST_X
cmp #24
bcs beast_no_adjust_y ; bge
cmp #15
bcc beast_on_platform ; blt
clc
adc #1
and #$fe ; our sprite code only draws even y
jmp beast_done_adjust_y
; 16 maps to -> 16
; 24 maps to -> 24
beast_on_platform:
lda #16
bne beast_done_adjust_y
beast_no_adjust_y:
lda #24
beast_done_adjust_y:
sta BEAST_Y
2019-03-25 04:12:09 +00:00
jsr draw_beast
rope_no_beast:
2019-03-17 05:28:42 +00:00
;===============================
; check if swinging off
lda PHYSICIST_STATE
cmp #P_SWINGING
bne done_swing_check
lda SWING_PROGRESS
bne done_swing_check
2019-01-19 04:23:18 +00:00
2019-03-17 05:28:42 +00:00
; swung off screen!
lda #5
sta GAME_OVER
2019-03-19 04:31:18 +00:00
2019-03-17 05:28:42 +00:00
done_swing_check:
2019-01-19 04:23:18 +00:00
;===============
; draw physicist
2019-01-21 05:30:17 +00:00
; adjust y for slope
lda PHYSICIST_X
cmp #26
bcs phys_no_adjust_y ; bge
2019-01-21 05:30:17 +00:00
cmp #17
bcc phys_on_platform
sec
sbc #3
and #$fe ; our sprite code only draws even y
jmp phys_done_adjust_y
; slope is 15 - 26 ( 28 - 36)
; 26 -> 22
phys_on_platform:
lda #14
bne phys_done_adjust_y
phys_no_adjust_y:
lda #22
phys_done_adjust_y:
sta PHYSICIST_Y
2019-01-19 04:23:18 +00:00
2019-03-17 05:28:42 +00:00
lda PHYSICIST_STATE
cmp #P_SWINGING
beq hes_swinging
jsr draw_physicist
hes_swinging:
2019-01-19 04:23:18 +00:00
;======================
; draw foreground plant
lda #<foreground_spikes
sta INL
lda #>foreground_spikes
sta INH
lda #30
sta XPOS
lda #30
sec
sbc EARTH_OFFSET
2019-01-19 04:23:18 +00:00
sta YPOS
jsr put_sprite
;================
; draw falling boulder
jsr draw_boulder
2019-01-19 04:23:18 +00:00
;===============
; page flip
jsr page_flip
;================
; inc frame count
inc FRAMEL
bne rope_frame_no_oflo
inc FRAMEH
rope_frame_no_oflo:
;===================
; check cliff's edge
lda PHYSICIST_X
cmp #11
bcs already_swung
lda BEFORE_SWING
beq already_swung
lda #0
sta BEFORE_SWING
; FIXME: check for jump
lda #80
sta SWING_PROGRESS
lda #11
sta PHYSICIST_X
lda #P_SWINGING
sta PHYSICIST_STATE
jmp not_done_rope
already_swung:
2019-03-17 05:28:42 +00:00
;=========================
; check if done this room
;=========================
2019-01-19 04:23:18 +00:00
2019-03-17 05:28:42 +00:00
; handle game over
2019-01-19 04:23:18 +00:00
lda GAME_OVER
cmp #$ff
beq done_rope
2019-03-17 05:28:42 +00:00
; if 2 then exiting right, to pool
2019-01-19 04:23:18 +00:00
cmp #$2
bne check_cliff_edge
2019-01-19 04:23:18 +00:00
lda #0
sta PHYSICIST_X
sta EARTH_OFFSET
2019-01-19 04:23:18 +00:00
jmp ootw_pool
2019-03-17 05:28:42 +00:00
; if 1 then at edge of cliff
check_cliff_edge:
cmp #$1
2019-03-17 05:28:42 +00:00
bne check_swung_off
lda #0
sta GAME_OVER
2019-03-17 05:28:42 +00:00
check_swung_off:
cmp #$5
bne not_done_rope
2019-03-27 03:12:44 +00:00
;==========================
; swung off screen to right
2019-03-17 05:28:42 +00:00
lda #1
sta PHYSICIST_X
sta EARTH_OFFSET
sta DIRECTION ; face right
2019-03-27 03:12:44 +00:00
sta BEAST_DIRECTION
2019-03-17 05:28:42 +00:00
lda #10
sta PHYSICIST_Y
lda #P_FALLING_SIDEWAYS
2019-03-17 05:28:42 +00:00
sta PHYSICIST_STATE
jmp ootw_pool
not_done_rope:
2019-01-19 04:23:18 +00:00
; loop forever
jmp rope_loop
done_rope:
rts
2019-03-17 05:28:42 +00:00
swing_progression:
2021-03-23 13:21:30 +00:00
.word swing25_lzsa
.word swing24_lzsa
.word swing23_lzsa
.word swing22_lzsa
.word swing21_lzsa
.word swing20_lzsa
.word swing19_lzsa
.word swing18_lzsa
.word swing17_lzsa
.word swing16_lzsa
.word swing15_lzsa
.word swing14_lzsa
.word swing13_lzsa
.word swing12_lzsa
.word swing11_lzsa
.word swing10_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing08_lzsa
.word swing06_lzsa
.word swing05_lzsa
.word swing04_lzsa
.word swing03_lzsa
.word swing02_lzsa
.word swing01_lzsa
2019-03-17 05:28:42 +00:00