monkey: you can walk around

This commit is contained in:
Vince Weaver 2020-09-16 22:57:51 -04:00
parent da7b9745fc
commit 532bf7d3af
3 changed files with 173 additions and 50 deletions

View File

@ -1,3 +1,6 @@
; G = Give P=Pick up U=use M=walk
; O = Open L=Look at H=push
; C = Close T=Talk to N=pull
;============================== ;==============================
; Handle Keypress ; Handle Keypress
@ -87,28 +90,99 @@ check_sound:
; can't be ^J as that's the same as down ; can't be ^J as that's the same as down
check_joystick: check_joystick:
; cmp #$10 ; control-P cmp #'J' ; J
cmp #'J' bne check_give
bne check_load
lda JOYSTICK_ENABLED lda JOYSTICK_ENABLED
eor #1 eor #1
sta JOYSTICK_ENABLED sta JOYSTICK_ENABLED
jmp done_keypress jmp done_keypress
check_load: check_give:
cmp #$C ; control-L cmp #'G'
bne check_save bne check_open
lda #VERB_GIVE
sta CURRENT_VERB
jmp done_keypress
check_open:
cmp #'O'
bne check_close
lda #VERB_OPEN
sta CURRENT_VERB
jmp done_keypress
check_close:
cmp #'C'
bne check_pick_up
lda #VERB_CLOSE
sta CURRENT_VERB
jmp done_keypress
check_pick_up:
cmp #'P'
bne check_look_at
lda #VERB_PICK_UP
sta CURRENT_VERB
jmp done_keypress
check_look_at:
cmp #'L'
bne check_talk_to
lda #VERB_LOOK_AT
sta CURRENT_VERB
jmp done_keypress
check_talk_to:
cmp #'T'
bne check_use
lda #VERB_TALK_TO
sta CURRENT_VERB
jmp done_keypress
check_use:
cmp #'U'
bne check_push
lda #VERB_USE
sta CURRENT_VERB
jmp done_keypress
check_push:
cmp #'H'
bne check_pull
lda #VERB_PUSH
sta CURRENT_VERB
jmp done_keypress
check_pull:
cmp #'N'
bne check_walk
lda #VERB_PULL
sta CURRENT_VERB
jmp done_keypress
check_walk:
cmp #'M'
bne check_left
lda #VERB_WALK
sta CURRENT_VERB
jmp done_keypress
;check_load:
; cmp #$C ; control-L
; bne check_save
; jsr load_game ; jsr load_game
jmp done_keypress ; jmp done_keypress
check_save: ;check_save:
cmp #$13 ; control-S ; cmp #$13 ; control-S
bne check_left ; bne check_left
; jsr save_game ; jsr save_game
jmp done_keypress ; jmp done_keypress
check_left: check_left:
cmp #'A' cmp #'A'
@ -185,7 +259,7 @@ check_return:
return_pressed: return_pressed:
special_return: special_return:
jsr handle_special jsr handle_return
; special case, don't make cursor visible ; special case, don't make cursor visible
jmp no_keypress jmp no_keypress
@ -198,6 +272,21 @@ no_keypress:
bit KEYRESET bit KEYRESET
rts rts
;============================
; handle_return
;============================
handle_return:
lda CURSOR_X
sta DESTINATION_X
lda CURSOR_Y
and #$FE ; has to be even
sta DESTINATION_Y
rts
;============================ ;============================
; handle_special ; handle_special
;=========================== ;===========================
@ -213,40 +302,7 @@ handle_special:
rts rts
;=============================
; change direction
;=============================
change_direction:
; split text/graphics
; bit TEXTGR
; also change sprite cutoff
; ldx #40
; stx psc_smc1+1
; stx psc_smc2+1
jmp done_split
;no_split:
; bit FULLGR
; also change sprite cutoff
; ldx #48
; stx psc_smc1+1
; stx psc_smc2+1
done_split:
ldy #0
lda (LOCATION_STRUCT_L),Y
sta LZSA_SRC_LO
iny
lda (LOCATION_STRUCT_L),Y
sta LZSA_SRC_HI
lda #$c ; load to page $c00
jsr decompress_lzsa2_fast
rts
;============================= ;=============================
@ -274,13 +330,21 @@ change_location:
lda (LOCATIONS_L),Y lda (LOCATIONS_L),Y
sta LOCATION_STRUCT_H sta LOCATION_STRUCT_H
jsr change_direction
rts ;=============================
; change direction
;=============================
change_direction:
done_split:
ldy #0
lda (LOCATION_STRUCT_L),Y
sta LZSA_SRC_LO
iny
lda (LOCATION_STRUCT_L),Y
sta LZSA_SRC_HI
lda #$c ; load to page $c00
jsr decompress_lzsa2_fast
log2_table:
; 0 1 2 3 4 5 6 7 8
; .byte 0,0,1,1,2,2,2,2,3

View File

@ -60,6 +60,10 @@ monkey_start:
lda #VERB_WALK lda #VERB_WALK
sta CURRENT_VERB sta CURRENT_VERB
lda #$ff
sta DESTINATION_X
sta DESTINATION_Y
game_loop: game_loop:
;================= ;=================
; reset things ; reset things
@ -95,6 +99,58 @@ animate_gate_n:
nothing_special: nothing_special:
;====================================
; 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:
;==================================== ;====================================
; draw guybrush ; draw guybrush
;==================================== ;====================================

View File

@ -84,6 +84,9 @@ NOUN_H = $87
NOUN_VECTOR_L = $88 ; pointer to callback for clicking noun NOUN_VECTOR_L = $88 ; pointer to callback for clicking noun
NOUN_VECTOR_H = $89 NOUN_VECTOR_H = $89
DESTINATION_X = $8A ; where to walk
DESTINATION_Y = $8B
; done game puzzle state ; done game puzzle state