dos33fsprogs/ootw/ootw_c2_jail.s

866 lines
11 KiB
ArmAsm
Raw Normal View History

2019-03-21 02:46:18 +00:00
; Ootw Checkpoint2 -- Running around the Jail
2019-07-19 17:13:23 +00:00
; call once before entering jail for first time
ootw_jail_init:
lda #0
2019-07-19 16:12:10 +00:00
sta CITY_MOVIE_SEEN
sta CART_OUT
sta DUDE_OUT
2019-07-19 17:13:23 +00:00
sta PHYSICIST_STATE
sta WHICH_JAIL
2019-07-19 16:12:10 +00:00
lda #1
sta JAIL_POWER_ON
sta GUN_OUT
sta friend_out
sta friend_direction
2019-07-19 16:12:10 +00:00
2019-07-19 21:19:34 +00:00
lda #F_RUNNING
sta friend_state
2019-07-19 16:12:10 +00:00
lda #39
sta DUDE_X
lda #$FA
sta CART_X
lda #25
sta friend_x
lda #30
sta friend_y
lda #29
2019-07-19 17:13:23 +00:00
sta PHYSICIST_X
lda #30
sta PHYSICIST_Y
lda #1
sta DIRECTION
rts
;===========================
; enter new room in jail
;===========================
ootw_jail:
;==============================
; each room init
lda #0
sta ON_ELEVATOR
sta TELEPORTING
2019-03-21 02:46:18 +00:00
;==============================
; setup per-room variables
lda WHICH_JAIL
bne jail1
jail0:
2019-07-19 17:13:23 +00:00
lda #(24+128)
2019-03-21 02:46:18 +00:00
sta LEFT_LIMIT
lda #(39+128)
2019-03-21 02:46:18 +00:00
sta RIGHT_LIMIT
; set right exit
lda #1
sta jer_smc+1
; set left exit
lda #0
sta jel_smc+1
2019-07-19 17:13:23 +00:00
lda #30
sta PHYSICIST_Y
; load background
lda #>(cage_fell_rle)
sta GBASH
lda #<(cage_fell_rle)
2019-03-21 02:46:18 +00:00
jmp jail_setup_done
jail1:
cmp #1
bne jail2
lda #(-4+128)
sta LEFT_LIMIT
lda #(39+128)
sta RIGHT_LIMIT
; set right exit
lda #2
sta jer_smc+1
; set left exit
lda #0
sta jel_smc+1
lda #30
sta PHYSICIST_Y
; load background
lda #>(jail2_rle)
sta GBASH
lda #<(jail2_rle)
jmp jail_setup_done
jail2:
cmp #2
bne jail3
lda #(-4+128)
sta LEFT_LIMIT
lda #(39+128)
sta RIGHT_LIMIT
; set right exit
lda #3
sta jer_smc+1
; set left exit
lda #1
sta jel_smc+1
; load background
lda #>(jail3_rle)
sta GBASH
lda #<(jail3_rle)
jmp jail_setup_done
jail3:
cmp #3
bne jail4
lda #(-4+128)
2019-03-21 02:46:18 +00:00
sta LEFT_LIMIT
lda #(39+128)
2019-03-21 02:46:18 +00:00
sta RIGHT_LIMIT
; set right exit
lda #7
sta jer_smc+1
; set left exit
lda #2
sta jel_smc+1
lda #30
sta PHYSICIST_Y
; load background
lda #>(jail4_rle)
sta GBASH
lda #<(jail4_rle)
jmp jail_setup_done
jail4:
cmp #4
bne jail5
2019-07-12 20:15:51 +00:00
lda PHYSICIST_Y
cmp #30 ; see if coming in on bottom
bne jail4_top
jail4_bottom:
lda #(-4+128)
sta LEFT_LIMIT
lda #(28+128)
sta RIGHT_LIMIT
jmp jail4_ok
jail4_top:
2019-07-12 16:24:37 +00:00
lda #(10+128)
sta LEFT_LIMIT
lda #(39+128)
sta RIGHT_LIMIT
2019-07-12 20:15:51 +00:00
lda #8
sta PHYSICIST_Y
jail4_ok:
; set right exit
lda #8
sta jer_smc+1
; set left exit
lda #5
sta jel_smc+1
2019-07-12 20:15:51 +00:00
; setup teleporter
lda #(-4+128)
sta td_left_smc1+1
lda #(28+128)
sta td_right_smc1+1
lda #(10+128)
sta tu_left_smc1+1
lda #(39+128)
sta tu_right_smc1+1
; load background
lda #>(room_b4_rle)
sta GBASH
lda #<(room_b4_rle)
jmp jail_setup_done
jail5:
cmp #5
bne jail6
2019-07-12 19:58:56 +00:00
lda #(30+128)
sta LEFT_LIMIT
lda #(39+128)
sta RIGHT_LIMIT
; set right exit
lda #4
sta jer_smc+1
lda #30
sta PHYSICIST_Y
2019-07-12 20:15:51 +00:00
; set up teleporter
lda #(30+128)
sta td_left_smc1+1
lda #(39+128)
sta td_right_smc1+1
lda #(6+128)
sta tu_left_smc1+1
lda #(32+128)
sta tu_right_smc1+1
; load background
lda #>(room_b3_rle)
sta GBASH
lda #<(room_b3_rle)
jmp jail_setup_done
jail6:
lda #(17+128)
sta LEFT_LIMIT
lda #(39+128)
sta RIGHT_LIMIT
; set right exit
lda #9
sta jer_smc+1
lda #20
sta PHYSICIST_Y
; load background
lda #>(room_b2_rle)
sta GBASH
lda #<(room_b2_rle)
jmp jail_setup_done
jail_setup_done:
sta GBASL
lda #$c ; load to page $c00
jsr load_rle_gr ; tail call
ootw_jail_already_set:
;===========================
; 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-21 02:46:18 +00:00
;=================================
; copy to screen
2019-07-19 17:13:23 +00:00
; jsr gr_copy_to_current
; jsr page_flip
2019-03-21 02:46:18 +00:00
;=================================
; setup vars
lda #0
sta GAIT
sta GAME_OVER
2019-07-19 17:13:23 +00:00
;============================
2019-03-21 02:46:18 +00:00
;============================
2019-07-12 19:58:56 +00:00
; Jail Loop
2019-03-21 02:46:18 +00:00
;============================
2019-07-19 17:13:23 +00:00
;============================
2019-03-21 02:46:18 +00:00
jail_loop:
;================================
; copy background to current page
jsr gr_copy_to_current
;==================================
; draw background action
2019-03-21 02:46:18 +00:00
lda WHICH_JAIL
2019-07-19 17:13:23 +00:00
bg_jail0:
2019-07-19 17:35:39 +00:00
; Jail #0, draw miners, gun
2019-07-19 17:13:23 +00:00
cmp #0
bne bg_jail6
jsr ootw_draw_miners
2019-07-19 17:35:39 +00:00
lda GUN_OUT
beq c2_no_bg_action
lda #34
2019-07-19 17:35:39 +00:00
sta XPOS
lda #44
sta YPOS
jsr draw_gun
jmp c2_no_bg_action
2019-07-19 17:13:23 +00:00
bg_jail6:
; Jail #6, draw power animation
cmp #6
bne c2_no_bg_action
; draw power
lda JAIL_POWER_ON
beq c2_no_bg_action ; skip if power off already
lda #20
sta XPOS
lda #0
sta YPOS
lda FRAMEL
lsr
lsr
lsr
and #$6
tay
lda power_line_sprites,Y
sta INL
lda power_line_sprites+1,Y
sta INH
jsr put_sprite_crop
c2_no_bg_action:
2019-03-21 02:46:18 +00:00
;===============================
; check keyboard
jsr handle_keypress
;===============================
; move physicist
;===============================
jsr move_physicist
;===============================
; move friend
;===============================
jsr move_friend
2019-03-21 02:46:18 +00:00
;===============
; check room limits
jsr check_screen_limit
;===============
; draw physicist
2019-07-12 20:40:21 +00:00
lda TELEPORTING
bne actively_teleporting
2019-03-21 02:46:18 +00:00
jsr draw_physicist
2019-07-12 20:40:21 +00:00
jmp c2_done_draw_physicist
actively_teleporting:
lda PHYSICIST_X
sta XPOS
lda #24
sta YPOS
lda #<teleport_sprite
sta INL
lda #>teleport_sprite
sta INH
jsr put_sprite_crop
dec TELEPORTING
c2_done_draw_physicist:
2019-03-21 02:46:18 +00:00
;===============
; draw friend
jsr draw_friend
c2_done_draw_friend:
;========================
; draw foreground action
2019-07-12 18:34:34 +00:00
lda WHICH_JAIL
cmp #1
2019-07-12 19:35:26 +00:00
bne c2_no_cart_action
2019-07-12 18:34:34 +00:00
c2_draw_cart:
lda CART_X
sta XPOS
lda #36
sta YPOS
lda #<cart_sprite
sta INL
lda #>cart_sprite
sta INH
jsr put_sprite_crop
jmp c2_no_fg_action
2019-07-12 19:35:26 +00:00
c2_no_cart_action:
lda WHICH_JAIL
cmp #2
bne c2_no_fg_action
c2_draw_dude:
lda DUDE_X
sta XPOS
lda #36
sta YPOS
lda DUDE_X
and #3
asl
tay
lda walking_dude_sprites,Y
sta INL
lda walking_dude_sprites+1,Y
sta INH
jsr put_sprite_crop
jmp c2_no_fg_action
2019-07-12 18:34:34 +00:00
c2_no_fg_action:
2019-07-12 19:35:26 +00:00
2019-07-12 18:34:34 +00:00
;====================
; activate fg objects
;====================
2019-07-12 19:35:26 +00:00
c2_fg_check_jail1:
2019-07-12 18:34:34 +00:00
lda WHICH_JAIL
cmp #1
2019-07-12 19:35:26 +00:00
bne c2_fg_check_jail2
2019-07-12 18:34:34 +00:00
lda CART_OUT
2019-07-12 19:35:26 +00:00
bne c2_fg_check_jail2
2019-07-12 18:34:34 +00:00
inc CART_OUT
2019-07-12 19:35:26 +00:00
c2_fg_check_jail2:
lda WHICH_JAIL
cmp #2
bne c2_move_fg_objects
lda DUDE_OUT
bne c2_move_fg_objects
inc DUDE_OUT
2019-07-12 18:34:34 +00:00
;================
; move fg objects
;================
c2_move_fg_objects:
2019-07-12 19:35:26 +00:00
2019-07-12 18:34:34 +00:00
lda CART_OUT
cmp #1
bne cart_not_out
; move cart
lda FRAMEL
and #$3
bne cart_not_out
inc CART_X
lda CART_X
cmp #39
bne cart_not_out
inc CART_OUT
cart_not_out:
2019-07-12 19:35:26 +00:00
lda DUDE_OUT
cmp #1
bne dude_not_out
; move dude
lda FRAMEL
and #$7
bne dude_not_out
dec DUDE_X
lda DUDE_X
cmp #$fa
bne dude_not_out
inc DUDE_OUT
dude_not_out:
2019-03-21 02:46:18 +00:00
;===============
; page flip
jsr page_flip
;================
; inc frame count
inc FRAMEL
bne jail_frame_no_oflo
inc FRAMEH
jail_frame_no_oflo:
2019-07-12 19:58:56 +00:00
;====================
; handle teleporters
lda WHICH_JAIL
cmp #4
2019-07-12 20:15:51 +00:00
beq handle_teleporter1
cmp #5
beq handle_teleporter2
2019-07-12 19:58:56 +00:00
bne no_teleporters
2019-07-12 20:15:51 +00:00
handle_teleporter1:
2019-07-12 19:58:56 +00:00
lda PHYSICIST_X
cmp #14
bcs no_teleporters ; bge
cmp #11
bcc no_teleporters ; blt
lda #1
bne save_teleporters ; bra
2019-07-12 20:15:51 +00:00
handle_teleporter2:
lda PHYSICIST_X
cmp #32
bcs no_teleporters ; bge
cmp #29
bcc no_teleporters ; blt
lda #1
bne save_teleporters ; bra
2019-07-12 19:58:56 +00:00
no_teleporters:
lda #0
save_teleporters:
sta ON_ELEVATOR
;==========================
; handle teleporting
;==========================
lda PHYSICIST_STATE
teleporter_check_up:
cmp #P_ELEVATING_UP
bne teleporter_check_down
teleporting_up:
2019-07-12 20:40:21 +00:00
lda #3
sta TELEPORTING
lda #0
sta PHYSICIST_STATE
2019-07-12 19:58:56 +00:00
lda #8
sta PHYSICIST_Y
2019-07-12 20:15:51 +00:00
tu_left_smc1:
2019-07-12 19:58:56 +00:00
lda #(10+128)
sta LEFT_LIMIT
2019-07-12 20:15:51 +00:00
tu_right_smc1:
2019-07-12 19:58:56 +00:00
lda #(39+128)
sta RIGHT_LIMIT
jmp done_teleport
teleporter_check_down:
cmp #P_ELEVATING_DOWN
bne not_teleporting_today
teleporting_down:
2019-07-12 20:40:21 +00:00
lda #3
sta TELEPORTING
lda #0
sta PHYSICIST_STATE
2019-07-12 19:58:56 +00:00
lda #30
sta PHYSICIST_Y
2019-07-12 20:15:51 +00:00
td_left_smc1:
2019-07-12 19:58:56 +00:00
lda #(-4+128)
sta LEFT_LIMIT
2019-07-12 20:15:51 +00:00
td_right_smc1:
2019-07-12 19:58:56 +00:00
lda #(28+128)
sta RIGHT_LIMIT
done_teleport:
not_teleporting_today:
;==========================
2019-03-21 02:46:18 +00:00
; check if done this level
;==========================
2019-03-21 02:46:18 +00:00
lda GAME_OVER
beq still_in_jail
cmp #$ff ; if $ff, we died
beq done_jail
;===============================
; check if exited room to right
cmp #1
beq jail_exit_left
;=================
2019-03-21 02:46:18 +00:00
; exit to right
jail_right_yes_exit:
2019-03-21 02:46:18 +00:00
lda #0
sta PHYSICIST_X
jer_smc:
lda #$0 ; smc+1 = exit location
2019-03-21 02:46:18 +00:00
sta WHICH_CAVE
jmp done_jail
;=====================
; exit to left
2019-03-21 02:46:18 +00:00
jail_exit_left:
2019-03-21 02:46:18 +00:00
lda #37
sta PHYSICIST_X
jel_smc:
lda #0 ; smc+1
2019-03-21 02:46:18 +00:00
sta WHICH_CAVE
jmp done_jail
2019-03-21 02:46:18 +00:00
; loop forever
still_in_jail:
lda #0
sta GAME_OVER
2019-03-21 02:46:18 +00:00
jmp jail_loop
done_jail:
rts
power_line_sprites:
.word power_line_sprite0
.word power_line_sprite1
.word power_line_sprite2
.word power_line_sprite3
power_line_sprite0:
.byte 1,8
; XXXoXXXoXXXoXXXo
.byte $77,$67,$77,$67,$77,$67,$77,$07
power_line_sprite1:
.byte 1,8
; XXoXXXoXXXoXXXoX
.byte $77,$76,$77,$76,$77,$76,$77,$06
2019-03-21 02:46:18 +00:00
power_line_sprite2:
.byte 1,8
; XoXXXoXXXoXXXoXX
.byte $67,$77,$67,$77,$67,$77,$67,$07
2019-03-21 02:46:18 +00:00
power_line_sprite3:
.byte 1,8
; oXXXoXXXoXXXoXXX
.byte $76,$77,$76,$77,$76,$77,$76,$07
2019-07-12 18:34:34 +00:00
cart_sprite:
.byte 7,6
.byte $00,$aa,$00,$aa,$00,$aa,$00
.byte $00,$aa,$00,$aa,$00,$aa,$00
.byte $00,$0a,$00,$0a,$00,$0a,$00
.byte $00,$aa,$00,$aa,$00,$aa,$00
.byte $00,$0a,$00,$0a,$00,$0a,$00
.byte $00,$aa,$00,$aa,$00,$aa,$00
2019-07-12 19:35:26 +00:00
walking_dude_sprites:
.word walking_dude0
.word walking_dude1
.word walking_dude2
.word walking_dude1
walking_dude0: .byte 6,6
.byte $AA,$AA,$AA,$AA,$AA,$AA
.byte $7A,$77,$f7,$f7,$7A,$AA
.byte $77,$7f,$77,$77,$77,$AA
.byte $A7,$77,$77,$07,$07,$AA
.byte $AA,$07,$70,$f7,$70,$00
.byte $AA,$00,$77,$7f,$77,$00
walking_dude1: .byte 6,6
.byte $AA,$AA,$7A,$7A,$7A,$AA
.byte $77,$f7,$7f,$7f,$77,$AA
.byte $77,$77,$77,$77,$77,$AA
.byte $AA,$77,$07,$70,$00,$0A
.byte $AA,$00,$77,$ff,$77,$00
.byte $AA,$00,$77,$77,$77,$00
walking_dude2: .byte 6,6
.byte $7A,$77,$f7,$f7,$7A,$AA
.byte $77,$7f,$77,$77,$77,$AA
.byte $A7,$77,$77,$07,$07,$AA
.byte $AA,$07,$70,$f7,$70,$00
.byte $AA,$00,$77,$7f,$77,$00
.byte $AA,$00,$77,$77,$77,$00
2019-07-12 20:40:21 +00:00
teleport_sprite:
.byte 3,8
.byte $BB,$AA,$BA
.byte $BB,$44,$BB
.byte $BB,$44,$BB
.byte $BB,$44,$BB
.byte $BB,$44,$BA
.byte $BB,$99,$BB
.byte $AB,$59,$BB
.byte $AA,$45,$AB
2019-07-19 17:35:39 +00:00
gun_sprite:
.byte 3,1
.byte $0a,$0a,$00
;====================
; draw gun
;====================
; xpos/ypos already set
draw_gun:
lda #<gun_sprite
sta INL
lda #>gun_sprite
sta INH
jmp put_sprite_crop
2019-07-20 01:30:23 +00:00
; blank screen
; off (1)
; 8 until green on (2)
; 25 until gren off (1)
; 25 until green on (2)
; 24 until hand grab (3)
; 8 until next (4)
; 8 until next (5)
; 8 until next (6)
; 8 until next (7)
; 8 until next (8)
; 40 of blank
laser_movie:
.word laserg_01_rle
.word laserg_02_rle
.word laserg_02_rle
.word laserg_02_rle
.word laserg_01_rle
.word laserg_01_rle
.word laserg_01_rle
.word laserg_02_rle
.word laserg_02_rle
.word laserg_02_rle
.word laserg_03_rle
.word laserg_04_rle
.word laserg_05_rle
.word laserg_06_rle
.word laserg_07_rle
.word laserg_08_rle
.word laserg_blank_rle
.word laserg_blank_rle
.word laserg_blank_rle
.word laserg_blank_rle
.word laserg_blank_rle