dos33fsprogs/ootw/ootw.s

500 lines
5.7 KiB
ArmAsm
Raw Normal View History

2019-01-17 20:56:43 +00:00
; Ootw
2019-01-13 06:10:44 +00:00
.include "zp.inc"
.include "hardware.inc"
2019-01-16 03:44:57 +00:00
ootw:
2019-01-13 06:10:44 +00:00
;===========================
; Enable graphics
bit LORES
bit SET_GR
bit FULLGR
;===========================
; Clear both bottoms
lda #$4
sta DRAW_PAGE
jsr clear_bottom
lda #$0
sta DRAW_PAGE
jsr clear_bottom
lda #0
sta DRAW_PAGE
lda #1
sta DISP_PAGE
;=============================
2019-01-14 04:37:49 +00:00
; Load background to $c00
2019-01-13 06:10:44 +00:00
lda #$0c
sta BASH
lda #$00
2019-01-14 04:37:49 +00:00
sta BASL ; load image off-screen $c00
2019-01-13 06:10:44 +00:00
2019-01-17 20:56:43 +00:00
lda #>(pool_rle)
2019-01-13 06:10:44 +00:00
sta GBASH
2019-01-17 20:56:43 +00:00
lda #<(pool_rle)
2019-01-13 06:10:44 +00:00
sta GBASL
jsr load_rle_gr
;=================================
2019-01-14 04:37:49 +00:00
; copy to both pages $400/$800
2019-01-13 06:10:44 +00:00
jsr gr_copy_to_current
jsr page_flip
jsr gr_copy_to_current
;=================================
2019-01-14 04:37:49 +00:00
; setup vars
lda #22
2019-01-14 17:44:26 +00:00
sta PHYSICIST_Y
2019-01-14 04:37:49 +00:00
lda #20
2019-01-14 17:44:26 +00:00
sta PHYSICIST_X
2019-01-14 04:37:49 +00:00
2019-01-14 05:34:45 +00:00
lda #1
sta DIRECTION
2019-01-14 17:44:26 +00:00
lda #0
sta GAIT
2019-01-17 05:22:51 +00:00
lda #30
sta TENTACLE_PROGRESS
;============================
; Main Loop
;============================
2019-01-14 04:37:49 +00:00
game_loop:
; check keyboard
jsr handle_keypress
;================================
2019-01-14 04:37:49 +00:00
; copy background to current page
2019-01-14 04:58:48 +00:00
jsr gr_copy_to_current
2019-01-16 03:44:57 +00:00
;=======================
2019-01-16 03:44:57 +00:00
; draw pool ripples
lda FRAMEL
and #$30 ; 0110 1100
lsr
lsr
lsr
tax
lda pool_ripples,X
sta INL
lda pool_ripples+1,X
sta INH
lda #9
sta XPOS
lda #30
sta YPOS
jsr put_sprite
lda FRAMEL
and #$30 ; 0110 1100
lsr
lsr
lsr
clc
adc #2
and #$6
tax
lda pool_ripples,X
sta INL
lda pool_ripples+1,X
sta INH
lda #27
sta XPOS
lda #30
sta YPOS
jsr put_sprite
lda FRAMEL
and #$30 ; 0110 1100
lsr
lsr
lsr
clc
adc #4
and #$6
tax
lda #18
sta XPOS
lda #28
sta YPOS
jsr put_sprite
2019-01-17 05:22:51 +00:00
;===============
; move/draw tentacle monster
lda FRAMEH
and #3
bne tentacle_move
lda FRAMEL
cmp #$ff
bne tentacle_move
tentacle_init:
sec
lda PHYSICIST_X
sbc #2
sta TENTACLE_X
lda #0
sta TENTACLE_PROGRESS
tentacle_move:
lda TENTACLE_PROGRESS
cmp #26
bpl no_tentacle
; lda FRAMEL
; and #$30 ; 0110 1100
; lsr
; lsr
; lsr
tax
lda tentacle_progression,X
sta INL
lda tentacle_progression+1,X
sta INH
lda TENTACLE_X
sta XPOS
lda #22
sta YPOS
lda FRAMEL
and #$3f
bne no_tentacle_progress
inc TENTACLE_PROGRESS
inc TENTACLE_PROGRESS
no_tentacle_progress:
jsr put_sprite
no_tentacle:
;===============
2019-01-14 17:44:26 +00:00
; draw physicist
2019-01-14 04:37:49 +00:00
2019-01-14 17:44:26 +00:00
jsr draw_physicist
2019-01-14 04:37:49 +00:00
;===============
2019-01-16 03:44:57 +00:00
; draw slugs
jsr draw_slugs
2019-01-13 06:10:44 +00:00
;======================
; draw foreground plant
2019-01-14 04:37:49 +00:00
lda FRAMEL
and #$c0 ; 0110 1100
lsr
lsr
lsr
lsr
lsr
tax
lda plant_wind,X
2019-01-14 05:18:37 +00:00
sta INL
lda plant_wind+1,X
sta INH
2019-01-14 05:18:37 +00:00
lda #4
sta XPOS
lda #30
sta YPOS
jsr put_sprite
2019-01-14 04:37:49 +00:00
; page flip
2019-01-13 06:10:44 +00:00
jsr page_flip
; inc frame count
inc FRAMEL
bne frame_no_oflo
inc FRAMEH
frame_no_oflo:
2019-01-14 04:37:49 +00:00
; pause?
; loop forever
jmp game_loop
;======================================
; handle keypress
;======================================
handle_keypress:
lda KEYPRESS ; 4
bpl no_keypress ; 3
; -1
2019-01-13 06:10:44 +00:00
2019-01-14 04:58:48 +00:00
and #$7f ; clear high bit
2019-01-16 03:44:57 +00:00
check_quit:
cmp #'Q'
beq quit
cmp #27
bne check_left
quit:
jmp quit_level
2019-01-14 04:58:48 +00:00
check_left:
cmp #'A'
beq left
cmp #$8 ; left arrow
bne check_right
left:
2019-01-14 05:34:45 +00:00
lda DIRECTION
bne face_left
2019-01-14 17:44:26 +00:00
dec PHYSICIST_X
bpl just_fine_left
too_far_left:
inc PHYSICIST_X
just_fine_left:
2019-01-14 17:44:26 +00:00
inc GAIT
inc GAIT
2019-01-14 04:58:48 +00:00
jmp done_keypress
2019-01-14 05:34:45 +00:00
face_left:
lda #0
sta DIRECTION
2019-01-14 17:44:26 +00:00
sta GAIT
2019-01-14 05:34:45 +00:00
jmp done_keypress
2019-01-14 04:58:48 +00:00
check_right:
cmp #'D'
beq right
cmp #$15
bne unknown
right:
2019-01-14 05:34:45 +00:00
lda DIRECTION
beq face_right
2019-01-14 17:44:26 +00:00
inc PHYSICIST_X
2019-01-17 04:30:18 +00:00
lda PHYSICIST_X
cmp #37
bne just_fine_right
too_far_right:
dec PHYSICIST_X
just_fine_right:
2019-01-14 17:44:26 +00:00
inc GAIT
inc GAIT
2019-01-14 04:58:48 +00:00
jmp done_keypress
2019-01-14 05:34:45 +00:00
face_right:
2019-01-14 17:44:26 +00:00
lda #0
sta GAIT
2019-01-14 05:34:45 +00:00
lda #1
sta DIRECTION
jmp done_keypress
2019-01-14 04:58:48 +00:00
unknown:
done_keypress:
2019-01-14 04:37:49 +00:00
bit KEYRESET ; clear the keyboard strobe ; 4
no_keypress:
rts ; 6
2019-01-14 17:44:26 +00:00
;======================================
; draw physicist
;======================================
draw_physicist:
lda GAIT
and #$f
sta GAIT
tax
lda phys_walk_progression,X
2019-01-14 17:44:26 +00:00
sta INL
lda phys_walk_progression+1,X
2019-01-14 17:44:26 +00:00
sta INH
lda PHYSICIST_X
sta XPOS
lda PHYSICIST_Y
sta YPOS
2019-01-14 17:44:26 +00:00
lda DIRECTION
bne facing_right
2019-01-14 17:44:26 +00:00
facing_left:
2019-01-15 05:21:25 +00:00
jmp put_sprite
facing_right:
2019-01-15 05:21:25 +00:00
jmp put_sprite_flipped
2019-01-14 17:44:26 +00:00
2019-01-16 03:44:57 +00:00
;==================================
; draw slugs
;==================================
slugg0_out: .byte $1
slugg0_x: .byte $01
slugg0_dir: .byte $1
slugg0_gait: .byte $0
; ___ _-_
draw_slugs:
lda slugg0_out
beq slug_done ; don't draw if not there
inc slugg0_gait
lda slugg0_gait
and #$1f
cmp #$00
bne slug_no_move
slug_move:
lda slugg0_x
clc
adc slugg0_dir
sta slugg0_x
cmp #37
beq remove_slug
slug_no_move:
lda slugg0_gait
and #$10
beq slug_squinched
slug_flat:
lda #<slug1
sta INL
lda #>slug1
sta INH
bne slug_selected
slug_squinched:
lda #<slug2
sta INL
lda #>slug2
sta INH
slug_selected:
lda slugg0_x
sta XPOS
lda #34
sta YPOS
lda DIRECTION
bmi slug_right
slug_left:
jsr put_sprite
jmp slug_done
slug_right:
jsr put_sprite_flipped
slug_done:
rts
remove_slug:
lda #0
sta slugg0_out
rts
;===========================
; quit_level
;===========================
quit_level:
jsr TEXT
jsr HOME
lda KEYRESET ; clear strobe
2019-01-16 05:28:23 +00:00
lda #0
sta DRAW_PAGE
lda #<end_message
sta OUTL
lda #>end_message
sta OUTH
jsr move_and_print
jsr move_and_print
2019-01-16 03:44:57 +00:00
wait_loop:
lda KEYPRESS
bpl wait_loop
lda KEYRESET ; clear strobe
jmp ootw
2019-01-16 05:28:23 +00:00
end_message:
.byte 8,10,"PRESS RETURN TO CONTINUE",0
.byte 11,20,"ACCESS CODE: IH8S",0
2019-01-16 03:44:57 +00:00
2019-01-16 05:28:23 +00:00
.include "text_print.s"
2019-01-13 06:10:44 +00:00
.include "gr_pageflip.s"
.include "gr_unrle.s"
.include "gr_fast_clear.s"
.include "gr_copy.s"
2019-01-14 04:37:49 +00:00
.include "gr_putsprite.s"
.include "gr_offsets.s"
2019-01-17 20:56:43 +00:00
.include "ootw_pool.inc"
.include "ootw_cavern.inc"
2019-01-14 04:37:49 +00:00
.include "ootw_sprites.inc"