dos33fsprogs/ootw/ootw.s

331 lines
3.8 KiB
ArmAsm
Raw Normal View History

2019-01-13 06:10:44 +00:00
; Ootw
.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
lda #>(planet_rle)
sta GBASH
lda #<(planet_rle)
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-14 04:37:49 +00:00
game_loop:
; check keyboard
jsr handle_keypress
; 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
; draw pool ripples
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-13 06:10:44 +00:00
2019-01-16 03:44:57 +00:00
; draw slugs
jsr draw_slugs
2019-01-13 06:10:44 +00:00
2019-01-14 04:37:49 +00:00
; draw foreground
2019-01-14 05:18:37 +00:00
lda #>foreground_plant
sta INH
lda #<foreground_plant
sta INL
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
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
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
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
wait_loop:
lda KEYPRESS
bpl wait_loop
lda KEYRESET ; clear strobe
jmp ootw
.byte "PRESS RETURN TO CONTINUE"
.byte "ACCESS CODE: IH8S"
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-13 06:10:44 +00:00
.include "ootw_backgrounds.inc"
2019-01-14 04:37:49 +00:00
.include "ootw_sprites.inc"