From 2317067e98da1bbd56de74ac2ea74f0d4e00b3db Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 17 Sep 2020 21:26:01 -0400 Subject: [PATCH] monkey: can walk to other room now --- monkey/Makefile | 2 +- monkey/keyboard.s | 29 ++++++++++++++- monkey/monkey.s | 31 ++++++++++++++++ monkey/monkey_lookout.s | 64 ++++++++++++++++++++++++++++++++ monkey/monkey_poster.s | 81 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 205 insertions(+), 2 deletions(-) create mode 100644 monkey/monkey_poster.s diff --git a/monkey/Makefile b/monkey/Makefile index 2bdfefe6..109220d7 100644 --- a/monkey/Makefile +++ b/monkey/Makefile @@ -56,7 +56,7 @@ monkey.o: monkey.s zp.inc hardware.inc common_defines.inc \ leveldata_monkey.inc \ monkey_actions.s update_bottom.s \ guy.brush \ - monkey_lookout.s + monkey_lookout.s monkey_poster.s ca65 -o monkey.o monkey.s -l monkey.lst graphics/graphics.inc: diff --git a/monkey/keyboard.s b/monkey/keyboard.s index 09a52ec0..f601277d 100644 --- a/monkey/keyboard.s +++ b/monkey/keyboard.s @@ -292,11 +292,38 @@ set_destination: lda CURSOR_X sta DESTINATION_X lda CURSOR_Y + sec + sbc #7 and #$FE ; has to be even sta DESTINATION_Y - ; FIXME: adjust for bounds + ; FIXME: this should be a jump table + lda LOCATION + cmp #MONKEY_LOOKOUT + beq set_destination_lookout + cmp #MONKEY_POSTER + beq set_destination_poster + cmp #MONKEY_DOCK + beq set_destination_dock + cmp #MONKEY_BAR + beq set_destination_bar + +set_destination_lookout: + jsr lookout_adjust_destination + jmp done_set_destination +set_destination_poster: + jsr poster_adjust_destination + jmp done_set_destination +set_destination_dock: +; jsr dock_adjust_destination + jmp done_set_destination +set_destination_bar: +; jsr bar_adjust_destination + jmp done_set_destination + + +done_set_destination: rts diff --git a/monkey/monkey.s b/monkey/monkey.s index 2590c39e..0291db04 100644 --- a/monkey/monkey.s +++ b/monkey/monkey.s @@ -233,6 +233,36 @@ nothing_foreground: jsr handle_keypress + ;==================================== + ; check if exiting room + ;==================================== + + ; FIXME: this should be a jump table + + lda LOCATION + cmp #MONKEY_LOOKOUT + beq check_exit_lookout + cmp #MONKEY_POSTER + beq check_exit_poster + cmp #MONKEY_DOCK + beq check_exit_dock + cmp #MONKEY_BAR + beq check_exit_bar + +check_exit_lookout: + jsr lookout_check_exit + jmp done_check_exit +check_exit_poster: + jsr poster_check_exit + jmp done_check_exit +check_exit_dock: +; jsr dock_check_exit + jmp done_check_exit +check_exit_bar: +; jsr bar_check_exit + jmp done_check_exit + +done_check_exit: ;==================================== ; inc frame count ;==================================== @@ -281,6 +311,7 @@ really_exit: .include "guy.brush" .include "monkey_lookout.s" + .include "monkey_poster.s" .include "monkey_actions.s" .include "update_bottom.s" diff --git a/monkey/monkey_lookout.s b/monkey/monkey_lookout.s index 15d3d196..124b0662 100644 --- a/monkey/monkey_lookout.s +++ b/monkey/monkey_lookout.s @@ -1,4 +1,68 @@ + ; if 2828 + ; goto MONKEY_POSTER + ; at location 2,22 +lookout_check_exit: + lda DESTINATION_Y + cmp #28 + bcc lookout_no_exit + + lda DESTINATION_X + cmp #28 + bcc lookout_no_exit + cmp #35 + bcs lookout_no_exit + + lda #MONKEY_POSTER + sta LOCATION + lda #2 + sta GUYBRUSH_X + lda #22 + sta GUYBRUSH_Y + jsr change_location + +lookout_no_exit: + rts + +lookout_adjust_destination: + +ld_check_x: + lda DESTINATION_X + cmp #19 + bcc ld_x_too_small + cmp #35 + bcs ld_x_too_big + jmp ld_check_y + +ld_x_too_big: + lda #35 + sta DESTINATION_X + bne ld_check_y + +ld_x_too_small: + lda #18 + sta DESTINATION_X + +ld_check_y: + ; if x < 28, Y must be between 16 and 18 + ; if x < 35, Y must be between 8 and 28 + + lda DESTINATION_Y + cmp #16 + bcc ld_y_too_small + + rts + +ld_y_too_small: + lda #16 + sta DESTINATION_Y + +done_ld_adjust: + rts + + + + draw_fire: lda FRAMEL and #$18 diff --git a/monkey/monkey_poster.s b/monkey/monkey_poster.s new file mode 100644 index 00000000..314b969c --- /dev/null +++ b/monkey/monkey_poster.s @@ -0,0 +1,81 @@ + + +poster_check_exit: +; lda DESTINATION_Y +; cmp #28 +; bcc lookout_no_exit + +; lda DESTINATION_X +; cmp #28 +; bcc lookout_no_exit +; cmp #35 +; bcs lookout_no_exit + +; lda #MONKEY_POSTER +; sta LOCATION +; lda #2 +; sta GUYBRUSH_X +; lda #22 +; sta GUYBRUSH_Y +; jsr change_location + +poster_no_exit: + rts + +poster_adjust_destination: + +ps_check_x: +; lda DESTINATION_X +; cmp #19 +; bcc ld_x_too_small +; cmp #35 +; bcs ld_x_too_big +; jmp ld_check_y + +ps_x_too_big: +; lda #35 +; sta DESTINATION_X +; bne ld_check_y + +ps_x_too_small: +; lda #18 +; sta DESTINATION_X + +ps_check_y: + ; if x < 28, Y must be between 16 and 18 + ; if x < 35, Y must be between 8 and 28 + +; lda DESTINATION_Y +; cmp #16 +; bcc ld_y_too_small + + rts + +ps_y_too_small: +; lda #16 +; sta DESTINATION_Y + +done_ps_adjust: + rts + + + + +draw_house: + +; lda #wall_sprite +; sta INH + +; lda #18 +; sta XPOS +; lda #22 +; sta YPOS + +; jsr put_sprite_crop + +; rts + +house_sprite: +