dos33fsprogs/monkey/monkey.s

358 lines
5.7 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
2020-09-18 00:26:18 +00:00
sta GUYBRUSH_DIRECTION
2020-09-18 03:39:02 +00:00
sta DISPLAY_MESSAGE
sta BAR_DOOR_OPEN
sta VALID_NOUN
2020-09-13 03:33:28 +00:00
; init cursor
lda #20
sta CURSOR_X
sta CURSOR_Y
; set up initial location
2020-10-01 19:07:02 +00:00
lda #MONKEY_BAR
; lda #MONKEY_LOOKOUT
2020-09-13 03:33:28 +00:00
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-18 02:53:00 +00:00
cmp #MONKEY_BAR
beq do_draw_bar_door
2020-09-28 02:03:50 +00:00
cmp #MONKEY_ZIPLINE
beq do_draw_sign
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
2020-09-18 02:53:00 +00:00
do_draw_bar_door:
jsr draw_bar_door
jmp nothing_special
2020-09-13 03:33:28 +00:00
2020-09-28 02:03:50 +00:00
do_draw_sign:
jsr draw_sign
jmp nothing_special
2020-09-13 03:33:28 +00:00
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:
2020-09-18 00:34:27 +00:00
lda #DIR_LEFT
sta GUYBRUSH_DIRECTION
2020-09-17 02:57:51 +00:00
dec GUYBRUSH_X
jmp move_guybrush_y
move_guybrush_right:
2020-09-18 00:34:27 +00:00
lda #DIR_RIGHT
sta GUYBRUSH_DIRECTION
2020-09-17 02:57:51 +00:00
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
2020-09-18 00:34:27 +00:00
bcs move_guybrush_down
move_guybrush_up:
lda #DIR_UP
sta GUYBRUSH_DIRECTION
2020-09-17 02:57:51 +00:00
dec GUYBRUSH_Y
dec GUYBRUSH_Y
jmp done_move_guybrush
2020-09-18 00:34:27 +00:00
move_guybrush_down:
lda #DIR_DOWN
sta GUYBRUSH_DIRECTION
2020-09-17 02:57:51 +00:00
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 LOCATION
cmp #MONKEY_MAP
bne big_guybrush
map_guybrush:
lda #<guybrush_map_sprite
sta INL
lda #>guybrush_map_sprite
sta INH
jmp really_draw_guybrush
big_guybrush:
2020-09-18 00:26:18 +00:00
lda GUYBRUSH_Y ; always even
lsr
eor GUYBRUSH_X
and #$1 ; 0 or 1
ora GUYBRUSH_DIRECTION ; 00/01 or 02/03 or 04/05 or 06/07
asl
tay
lda guybrush_sprites,Y
2020-09-13 04:32:52 +00:00
sta INL
2020-09-18 00:26:18 +00:00
lda guybrush_sprites+1,Y
2020-09-13 04:32:52 +00:00
sta INH
really_draw_guybrush:
2020-09-13 04:32:52 +00:00
jsr put_sprite_crop
;====================================
; draw foreground sprites
;====================================
lda LOCATION
cmp #MONKEY_LOOKOUT
beq do_draw_wall
2020-09-18 02:53:00 +00:00
cmp #MONKEY_POSTER
beq do_draw_house
cmp #MONKEY_BAR
beq do_draw_building
jmp nothing_foreground
do_draw_wall:
jsr draw_wall
jmp nothing_foreground
2020-09-18 02:53:00 +00:00
do_draw_house:
jsr draw_house
jmp nothing_foreground
do_draw_building:
jsr draw_bar_fg_building
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
;====================================
; keep in bounds
;====================================
keep_in_bounds_smc:
jsr $0000
2020-09-18 01:26:01 +00:00
;====================================
; check if exiting room
;====================================
2020-09-25 03:33:59 +00:00
check_exit_smc:
jsr $0000
2020-09-13 03:33:28 +00:00
;====================================
; 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"
2020-09-25 03:33:59 +00:00
; Locations
.include "monkey_lookout.s"
2020-09-18 01:26:01 +00:00
.include "monkey_poster.s"
2020-09-18 01:37:50 +00:00
.include "monkey_dock.s"
.include "monkey_bar.s"
2020-09-19 05:36:48 +00:00
.include "monkey_town.s"
.include "monkey_map.s"
2020-09-25 03:33:59 +00:00
.include "monkey_church.s"
.include "monkey_zipline.s"
.include "monkey_mansion.s"
.include "monkey_mansion_path.s"
.include "monkey_bar_inside1.s"
.include "monkey_bar_inside2.s"
2020-10-01 19:07:02 +00:00
.include "monkey_voodoo1.s"
.include "monkey_voodoo2.s"
; cutscenes
.include "chapter1.s"
.include "cutscene_lechuck.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"