From 37516b2298fa4882e4783b6f01071c773e944884 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 18 Sep 2020 00:42:07 -0400 Subject: [PATCH] monkey: can click on bottom menu now also fixes an unrelated off-by-one error in the noun code that somehow these changes activated, which was a *huge* pan to track down --- monkey/keyboard.s | 74 +++++++++++++++++++++++++++++++++++++++-- monkey/monkey.s | 1 + monkey/monkey_actions.s | 6 ++-- monkey/update_bottom.s | 2 +- 4 files changed, 77 insertions(+), 6 deletions(-) diff --git a/monkey/keyboard.s b/monkey/keyboard.s index 6a1e4a49..5a1b5383 100644 --- a/monkey/keyboard.s +++ b/monkey/keyboard.s @@ -280,14 +280,84 @@ no_keypress: ;============================ handle_return: + ; if Y>38 then clicking on verb + lda CURSOR_Y + cmp #38 + bcc check_walking ; blt + + lda CURSOR_X + clc + adc #3 ; get onto screen + + cmp #7 + bcc menu_col1 + cmp #16 + bcc menu_col2 + cmp #22 + bcc menu_col3 + bcs done_click_nochange + +menu_col1: + lda CURSOR_Y + cmp #40 + beq menu_col1_row2 + bcs menu_col1_row3 +menu_col1_row1: + lda #VERB_GIVE + jmp done_click_menu +menu_col1_row2: + lda #VERB_OPEN + jmp done_click_menu +menu_col1_row3: + lda #VERB_CLOSE + jmp done_click_menu + +menu_col2: + lda CURSOR_Y + cmp #40 + beq menu_col2_row2 + bcs menu_col2_row3 +menu_col2_row1: + lda #VERB_PICK_UP + jmp done_click_menu +menu_col2_row2: + lda #VERB_LOOK_AT + jmp done_click_menu +menu_col2_row3: + lda #VERB_TALK_TO + jmp done_click_menu + +menu_col3: + lda CURSOR_Y + cmp #40 + beq menu_col3_row2 + bcs menu_col3_row3 +menu_col3_row1: + lda #VERB_USE + jmp done_click_menu +menu_col3_row2: + lda #VERB_PUSH + jmp done_click_menu +menu_col3_row3: + lda #VERB_PULL + jmp done_click_menu + + +done_click_menu: + sta CURRENT_VERB +done_click_nochange: + rts + + +check_walking: ; check if walking verb lda CURRENT_VERB cmp #VERB_WALK beq action_walk_to ; otherwise see if there's a noun - lda VALID_NOUN ; 0 means yes for some reason - beq activate_noun + lda VALID_NOUN + bne activate_noun ; wasn't valid, switch to walk lda #VERB_WALK diff --git a/monkey/monkey.s b/monkey/monkey.s index 16654dd8..3db28d88 100644 --- a/monkey/monkey.s +++ b/monkey/monkey.s @@ -40,6 +40,7 @@ monkey_start: sta GUYBRUSH_DIRECTION sta DISPLAY_MESSAGE sta BAR_DOOR_OPEN + sta VALID_NOUN ; init cursor diff --git a/monkey/monkey_actions.s b/monkey/monkey_actions.s index 58971a3e..448dcbc2 100644 --- a/monkey/monkey_actions.s +++ b/monkey/monkey_actions.s @@ -48,7 +48,7 @@ where_loop: lda (LOCATION_STRUCT_L),Y sta NOUN_VECTOR_H - lda #0 + lda #1 sta VALID_NOUN rts @@ -69,12 +69,12 @@ where_notyhigh: iny dex - bpl where_loop + bne where_loop point_nowhere: - lda #$ff + lda #0 sta VALID_NOUN rts diff --git a/monkey/update_bottom.s b/monkey/update_bottom.s index 8c8397ab..318ecd85 100644 --- a/monkey/update_bottom.s +++ b/monkey/update_bottom.s @@ -47,7 +47,7 @@ no_message: lda VALID_NOUN - bmi no_noun + beq no_noun lda NOUN_L sta OUTL