dos33fsprogs/ootw/ootw_mesa.s

346 lines
6.0 KiB
ArmAsm
Raw Normal View History

2019-01-20 06:45:51 +00:00
; Ootw mesa at far right
ootw_mesa:
2019-03-24 05:14:23 +00:00
2019-01-20 06:45:51 +00:00
;===========================
; 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-03-19 19:31:37 +00:00
2019-01-20 06:45:51 +00:00
;===========================
; Setup right/left exit paramaters
lda BEAST_OUT ; if beast out, we can go full right
beq beast_not_out_yet
lda #(128+39) ; aliens trigger
sta RIGHT_LIMIT
jmp mesa_left
beast_not_out_yet:
lda #(128+20) ; beast trigger
2019-01-20 06:45:51 +00:00
sta RIGHT_LIMIT
mesa_left:
lda #(128-3)
2019-01-20 06:45:51 +00:00
sta LEFT_LIMIT
;=============================
; Load background to $c00
lda #>(cavern3_rle)
sta GBASH
lda #<(cavern3_rle)
sta GBASL
lda #$c ; load image off-screen $c00
2019-01-20 06:45:51 +00:00
jsr load_rle_gr
;=================================
; copy to screen
2019-01-20 06:45:51 +00:00
jsr gr_copy_to_current
jsr page_flip
;=================================
; setup vars
lda #0
sta GAIT
sta GAME_OVER
2019-03-20 15:14:55 +00:00
sta LEVELEND_PROGRESS
2019-01-20 06:45:51 +00:00
2019-03-27 03:12:44 +00:00
jsr setup_beast
2019-01-20 06:45:51 +00:00
;============================
2019-03-20 15:14:55 +00:00
;============================
;============================
; Mesa main Loop
;============================
;============================
2019-01-20 06:45:51 +00:00
;============================
mesa_loop:
2019-03-19 19:31:37 +00:00
;===================================
; Check if in end-of-level animation
;===================================
lda LEVELEND_PROGRESS
beq no_levelend
2019-03-20 15:14:55 +00:00
;=== load special background on first frame and frame 19
cmp #(MAX_PROGRESSION-36) ; on frame 19?
bne check_if_first
lda #<deadbeast_rle
sta GBASL
lda #>deadbeast_rle
jmp finish_first
check_if_first:
cmp #MAX_PROGRESSION ; only load background on first frame
2019-03-19 19:31:37 +00:00
bne levelend_not_first
lda #<cavern3_rle
sta GBASL
lda #>cavern3_rle
2019-03-20 15:14:55 +00:00
finish_first:
2019-03-19 19:31:37 +00:00
sta GBASH
lda #$C ; load image off-screen $C00
jsr load_rle_gr
levelend_not_first:
dec LEVELEND_PROGRESS
dec LEVELEND_PROGRESS
bne not_beginning_of_end
beginning_of_end:
lda #5
sta GAME_OVER
jmp l1_game_over_check
not_beginning_of_end:
2019-03-19 19:31:37 +00:00
ldx LEVELEND_PROGRESS
lda endl1_progression,X
sta GBASL
lda endl1_progression+1,X
sta GBASH
lda #$10 ; load image off-screen $1000
jsr load_rle_gr
jsr gr_overlay_40x40
;====================
; pause
lda LEVELEND_PROGRESS
lsr
tax
lda endl_pauses,X
tax
jsr long_wait
2019-03-19 19:31:37 +00:00
jmp beyond_mesa_normal
no_levelend:
2019-01-20 06:45:51 +00:00
;================================
; copy background to current page
jsr gr_copy_to_current
2019-03-19 19:31:37 +00:00
beyond_mesa_normal:
2019-01-20 06:45:51 +00:00
lda LEVELEND_PROGRESS ; only draw if not in end animation
bne level1_ending
2019-01-20 06:45:51 +00:00
;===============================
; check keyboard
jsr handle_keypress
;===============================
; Move physicist
jsr move_physicist
;===============================
; check limits
jsr check_screen_limit
2019-01-20 06:45:51 +00:00
;===============
; draw physicist
2019-03-19 19:31:37 +00:00
jsr draw_physicist
2019-03-24 05:14:23 +00:00
;================
; handle beast
lda BEAST_OUT
beq mesa_no_beast
;================
2019-03-25 04:12:09 +00:00
; move beast
2019-03-24 05:14:23 +00:00
jsr move_beast
;================
; draw beast
jsr draw_beast
mesa_no_beast:
2019-03-19 19:31:37 +00:00
level1_ending:
2019-01-20 06:45:51 +00:00
;===============
; page flip
jsr page_flip
;================
; inc frame count
inc FRAMEL
bne mesa_frame_no_oflo
inc FRAMEH
mesa_frame_no_oflo:
;========================================
;========================================
; check if at edge of screen or game over
;========================================
;========================================
l1_game_over_check:
lda GAME_OVER ; if not game over, skip ahead
2019-01-20 06:45:51 +00:00
beq not_done_mesa
cmp #$ff ; check if died, if so exit
beq done_mesa
cmp #$5 ; check if defeated, if so exit
2019-01-20 06:45:51 +00:00
beq done_mesa
;====================
; check if leaving room
2019-01-25 02:41:01 +00:00
mesa_check_right:
cmp #$2
bne mesa_check_left
2019-01-20 06:45:51 +00:00
;=====================
; off screen to right
lda BEAST_OUT ; if beast out trigger end
beq trigger_beast ; otherwise trigger beast
;=====================
; trigger ending
lda #MAX_PROGRESSION
sta LEVELEND_PROGRESS
lda #0
sta GAME_OVER
lda #30
sta PHYSICIST_X ; debugging
jmp not_done_mesa
2019-01-25 02:41:01 +00:00
trigger_beast:
;=======================
; trigger beast emerging
2019-01-25 02:41:01 +00:00
lda #1
sta BEAST_OUT
lda #0
2019-03-24 05:14:23 +00:00
sta BEAST_DIRECTION
sta BEAST_GAIT
sta BEAST_STATE ; B_STANDING
sta GAME_OVER
2019-03-24 05:14:23 +00:00
sta PHYSICIST_STATE ; stop in tracks
2019-03-25 04:12:09 +00:00
lda #50
sta BEAST_COUNT
2019-03-24 05:14:23 +00:00
lda #30
sta BEAST_X
lda #(39+128) ; update right side of screen
sta RIGHT_LIMIT ; this is mostly for testing
2019-01-25 02:41:01 +00:00
jsr beast_cutscene
jmp not_done_mesa
mesa_check_left:
cmp #$1
bne not_done_mesa
2019-01-20 06:45:51 +00:00
;============================
2019-01-20 06:45:51 +00:00
; off screen to left
mesa_off_left:
lda #37
sta PHYSICIST_X
lda #1
sta WHICH_CAVE ; go left one screen
2019-01-20 06:45:51 +00:00
jmp ootw_cavern
not_done_mesa:
; loop forever
jmp mesa_loop
done_mesa:
rts
;=====================
; long(er) wait
; waits approximately 10ms * X
long_wait:
lda #64
jsr WAIT ; delay 1/2(26+27A+5A^2) us, 11,117
dex
bne long_wait
rts
MAX_PROGRESSION = 106
endl1_progression:
.word black_rle,black_rle
.word l1end51_rle,l1end50_rle,l1end49_rle,l1end48_rle,l1end47_rle
.word l1end46_rle,l1end45_rle,l1end44_rle,l1end43_rle,l1end42_rle
.word l1end41_rle,l1end40_rle,l1end39_rle,l1end38_rle,l1end37_rle
.word l1end36_rle
.word gunguy_rle,peace_rle
.word l1end33_rle,l1end32_rle,l1end31_rle,l1end30_rle
.word l1end29_rle,l1end28_rle,l1end27_rle,l1end26_rle,l1end25_rle
.word l1end24_rle,l1end23_rle,l1end22_rle,l1end21_rle,l1end20_rle
.word l1end19_rle,l1end18_rle,l1end17_rle,l1end16_rle,l1end15_rle
.word l1end14_rle,l1end13_rle,l1end12_rle,l1end11_rle,l1end10_rle
.word l1end09_rle,l1end08_rle,l1end07_rle,l1end06_rle,l1end05_rle
.word l1end04_rle,l1end03_rle,l1end02_rle,l1end01_rle
; pause is *before* image indicated
endl_pauses:
2019-03-20 15:14:55 +00:00
; fading out
.byte 10,10 ; black,black
.byte 10,10,10,10,220 ; 51,50,49,48,47
2019-03-20 15:14:55 +00:00
; getting shot
.byte 3,3,3,3,3 ; 46,45,44,43,42
.byte 3,3,3,3,3 ; 41,40,39,38,37
.byte 250 ; 36
.byte 230,80 ; gun, peace
2019-03-20 15:14:55 +00:00
; raising hand
.byte 20,150,20,20 ; 33,32,31,30
; getting up
.byte 20,20,150,10,10 ; 29,28,27,26,25
.byte 10,10,10,10,10 ; 24,23,22,21,20
2019-03-20 15:14:55 +00:00
; shooting of beast
.byte 3,3,3,3,3 ; 19,18,17,16,15
.byte 3,3,3,3,3 ; 14,13,12,11,10
.byte 3,3,3,3,3 ; 09,08,07,06,05
.byte 3,3,3,3 ; 04,03,02,01