dos33fsprogs/monkey/monkey.s

271 lines
4.1 KiB
ArmAsm
Raw Normal View History

2020-09-13 03:33:28 +00:00
; Monkey Monkey
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page
.include "zp.inc"
.include "hardware.inc"
.include "common_defines.inc"
monkey_start:
;===================
; init screen
jsr TEXT
jsr HOME
bit KEYRESET
bit SET_GR
bit PAGE0
bit LORES
bit TEXTGR
;=================
; set up location
;=================
lda #<locations
sta LOCATIONS_L
lda #>locations
sta LOCATIONS_H
2020-09-13 04:32:52 +00:00
lda #29
sta GUYBRUSH_X
lda #18
sta GUYBRUSH_Y
2020-09-13 03:33:28 +00:00
lda #0
sta DRAW_PAGE
sta LEVEL_OVER
; init cursor
lda #20
sta CURSOR_X
sta CURSOR_Y
; set up initial location
lda #MONKEY_LOOKOUT
sta LOCATION
jsr change_location
lda #1
sta CURSOR_VISIBLE ; visible at first
lda #0
sta ANIMATE_FRAME
2020-09-16 03:45:02 +00:00
lda #VERB_WALK
sta CURRENT_VERB
2020-09-17 02:57:51 +00:00
lda #$ff
sta DESTINATION_X
sta DESTINATION_Y
2020-09-13 03:33:28 +00:00
game_loop:
;=================
; reset things
;=================
lda #0
sta IN_SPECIAL
sta IN_RIGHT
sta IN_LEFT
;====================================
; copy background to current page
;====================================
jsr gr_copy_to_current
;====================================
2020-09-13 04:32:52 +00:00
; draw background sprites
2020-09-13 03:33:28 +00:00
;====================================
lda LOCATION
cmp #MONKEY_LOOKOUT
beq animate_flame
2020-09-13 03:33:28 +00:00
jmp nothing_special
animate_flame:
jsr draw_fire
2020-09-13 03:33:28 +00:00
jmp nothing_special
nothing_special:
2020-09-17 02:57:51 +00:00
;====================================
; move guybrush
;====================================
; only do it every 4th frame
lda FRAMEL
and #$3
bne done_move_guybrush
move_guybrush_x:
lda DESTINATION_X
bmi move_guybrush_y
cmp GUYBRUSH_X
beq guybrush_lr_done
bcs move_guybrush_right
move_guybrush_left:
dec GUYBRUSH_X
jmp move_guybrush_y
move_guybrush_right:
inc GUYBRUSH_X
jmp move_guybrush_y
guybrush_lr_done:
lda #$ff
sta DESTINATION_X
move_guybrush_y:
lda DESTINATION_Y
bmi done_move_guybrush
cmp GUYBRUSH_Y
beq guybrush_ud_done
bcs move_guybrush_up
move_guybrush_down:
dec GUYBRUSH_Y
dec GUYBRUSH_Y
jmp done_move_guybrush
move_guybrush_up:
inc GUYBRUSH_Y
inc GUYBRUSH_Y
jmp done_move_guybrush
guybrush_ud_done:
lda #$ff
sta DESTINATION_Y
done_move_guybrush:
2020-09-13 04:32:52 +00:00
;====================================
; draw guybrush
;====================================
lda GUYBRUSH_X
sta XPOS
lda GUYBRUSH_Y
sta YPOS
lda #<guybrush_back_sprite
sta INL
lda #>guybrush_back_sprite
sta INH
jsr put_sprite_crop
;====================================
; draw foreground sprites
;====================================
lda LOCATION
cmp #MONKEY_LOOKOUT
beq do_draw_wall
jmp nothing_foreground
do_draw_wall:
jsr draw_wall
jmp nothing_foreground
nothing_foreground:
2020-09-13 04:32:52 +00:00
;====================================
; what are we pointing too
;====================================
jsr where_do_we_point
2020-09-13 04:32:52 +00:00
;====================================
; update bottom bar
;====================================
jsr update_bottom
2020-09-13 03:33:28 +00:00
;====================================
; draw pointer
;====================================
jsr draw_pointer
;====================================
; page flip
;====================================
jsr page_flip
;====================================
; handle keypress/joystick
;====================================
jsr handle_keypress
;====================================
; inc frame count
;====================================
inc FRAMEL
bne room_frame_no_oflo
inc FRAMEH
room_frame_no_oflo:
;====================================
; check level over
;====================================
lda LEVEL_OVER
bne really_exit
jmp game_loop
really_exit:
jmp end_level
2020-09-13 04:32:52 +00:00
2020-09-13 03:33:28 +00:00
;==========================
; includes
;==========================
; level graphics
.include "graphics/graphics.inc"
; level data
.include "leveldata_monkey.inc"
.include "end_level.s"
.include "text_print.s"
.include "gr_offsets.s"
.include "gr_fast_clear.s"
.include "keyboard.s"
.include "gr_copy.s"
.include "gr_putsprite_crop.s"
.include "joystick.s"
.include "gr_pageflip.s"
.include "decompress_fast_v2.s"
.include "draw_pointer.s"
.include "common_sprites.inc"
2020-09-13 04:32:52 +00:00
.include "guy.brush"
.include "monkey_lookout.s"
2020-09-13 04:32:52 +00:00
.include "monkey_actions.s"
2020-09-16 03:45:02 +00:00
.include "update_bottom.s"