diff --git a/monkey/keyboard.s b/monkey/keyboard.s index ab1aa920..8ca2a2ae 100644 --- a/monkey/keyboard.s +++ b/monkey/keyboard.s @@ -290,8 +290,16 @@ handle_return: ;============================== set_destination: lda CURSOR_X + bpl destination_x_is_positive + ; we are off edge of screen, just say 0 + lda #0 +destination_x_is_positive: sta DESTINATION_X + lda CURSOR_Y + bpl destination_y_is_positive + lda #0 +destination_y_is_positive: sec sbc #7 and #$FE ; has to be even @@ -356,9 +364,9 @@ change_location: lda #0 sta ANIMATE_FRAME sta CURSOR_VISIBLE - lda #20 - sta CURSOR_X - sta CURSOR_Y +; lda #20 +; sta CURSOR_X +; sta CURSOR_Y lda LOCATION asl diff --git a/monkey/monkey.s b/monkey/monkey.s index cc766719..fd139473 100644 --- a/monkey/monkey.s +++ b/monkey/monkey.s @@ -88,15 +88,18 @@ game_loop: lda LOCATION cmp #MONKEY_LOOKOUT beq animate_flame + cmp #MONKEY_BAR + beq do_draw_bar_door jmp nothing_special - - animate_flame: jsr draw_fire jmp nothing_special +do_draw_bar_door: + jsr draw_bar_door + jmp nothing_special nothing_special: @@ -192,6 +195,8 @@ done_move_guybrush: lda LOCATION cmp #MONKEY_LOOKOUT beq do_draw_wall + cmp #MONKEY_POSTER + beq do_draw_house jmp nothing_foreground @@ -199,6 +204,9 @@ do_draw_wall: jsr draw_wall jmp nothing_foreground +do_draw_house: + jsr draw_house + jmp nothing_foreground nothing_foreground: diff --git a/monkey/monkey_bar.s b/monkey/monkey_bar.s index 24420b11..5a8a9ec6 100644 --- a/monkey/monkey_bar.s +++ b/monkey/monkey_bar.s @@ -1,59 +1,55 @@ - + ; if x<5 goto DOCK at 34,20 bar_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 GUYBRUSH_X + cmp #5 + bcc bar_to_dock + bcs bar_no_exit -; lda #MONKEY_POSTER -; sta LOCATION -; lda #2 -; sta GUYBRUSH_X -; lda #22 -; sta GUYBRUSH_Y -; jsr change_location +bar_to_dock: + lda #MONKEY_DOCK + sta LOCATION + lda #34 + sta GUYBRUSH_X + sta DESTINATION_X + lda #20 + sta GUYBRUSH_Y + sta DESTINATION_Y + jsr change_location bar_no_exit: rts bar_adjust_destination: + ; if x<21, y=20 + ; if x<25, y=18 + ; x can't go past 25 + br_check_x: -; lda DESTINATION_X -; cmp #19 -; bcc ld_x_too_small -; cmp #35 -; bcs ld_x_too_big -; jmp ld_check_y + lda DESTINATION_X + cmp #25 + bcs br_x_too_big + cmp #21 + bcc br_x_small + bcs br_x_medium br_x_too_big: -; lda #35 -; sta DESTINATION_X -; bne ld_check_y + lda #25 + sta DESTINATION_X + lda #18 + sta DESTINATION_Y + bne done_br_adjust -br_x_too_small: -; lda #18 -; sta DESTINATION_X +br_x_medium: + lda #18 + sta DESTINATION_Y + bne done_br_adjust -br_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 - -br_y_too_small: -; lda #16 -; sta DESTINATION_Y +br_x_small: + lda #20 + sta DESTINATION_Y done_br_adjust: rts @@ -61,21 +57,32 @@ done_br_adjust: -;draw_house: +draw_bar_door: -; lda #wall_sprite -; sta INH + lda BAR_DOOR_OPEN + beq done_draw_bar_door -; lda #18 -; sta XPOS -; lda #22 -; sta YPOS + lda #door_sprite + sta INH -; jsr put_sprite_crop + lda #11 + sta XPOS + lda #22 + sta YPOS + + jsr put_sprite_crop +done_draw_bar_door: + rts + +door_sprite: + .byte 2,5 + .byte $d2,$d2 + .byte $88,$DD + .byte $88,$DD + .byte $88,$DD + .byte $5d,$5D -; rts -;house_sprite: diff --git a/monkey/monkey_dock.s b/monkey/monkey_dock.s index 806b51f4..e4363f28 100644 --- a/monkey/monkey_dock.s +++ b/monkey/monkey_dock.s @@ -1,60 +1,55 @@ ; stuff regarding the dock ; guybrush is a friend without pier + ; if x<4 goto MONKEY_POSTER at 28,20 + ; if x>35 goto MONKEY_BAR at 5,20 + dock_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 GUYBRUSH_X + cmp #4 + bcc dock_to_poster + cmp #35 + bcs dock_to_bar + bcc dock_no_exit -; lda #MONKEY_POSTER -; sta LOCATION -; lda #2 -; sta GUYBRUSH_X -; lda #22 -; sta GUYBRUSH_Y -; jsr change_location +dock_to_poster: + lda #MONKEY_POSTER + sta LOCATION + lda #34 + sta GUYBRUSH_X + sta DESTINATION_X + lda #20 + sta GUYBRUSH_Y + sta DESTINATION_Y + jsr change_location + jmp dock_no_exit + +dock_to_bar: + lda #MONKEY_BAR + sta LOCATION + lda #5 + sta GUYBRUSH_X + sta DESTINATION_X + lda #20 + sta GUYBRUSH_Y + sta DESTINATION_Y + jsr change_location + jmp dock_no_exit dock_no_exit: rts dock_adjust_destination: - -dk_check_x: -; lda DESTINATION_X -; cmp #19 -; bcc ld_x_too_small -; cmp #35 -; bcs ld_x_too_big -; jmp ld_check_y - -dk_x_too_big: -; lda #35 -; sta DESTINATION_X -; bne ld_check_y - -dk_x_too_small: -; lda #18 -; sta DESTINATION_X + ; just make Y always 20 dk_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 - dk_y_too_small: -; lda #16 -; sta DESTINATION_Y + lda #20 + sta DESTINATION_Y done_dk_adjust: rts diff --git a/monkey/monkey_lookout.s b/monkey/monkey_lookout.s index 124b0662..816d5182 100644 --- a/monkey/monkey_lookout.s +++ b/monkey/monkey_lookout.s @@ -1,13 +1,16 @@ - ; if 2828 + ; if 28=28 and direction==down ; goto MONKEY_POSTER - ; at location 2,22 + ; at location 4,20 lookout_check_exit: - lda DESTINATION_Y - cmp #28 + lda GUYBRUSH_Y + cmp #24 bcc lookout_no_exit + lda GUYBRUSH_DIRECTION + cmp #DIR_DOWN + bne lookout_no_exit - lda DESTINATION_X + lda GUYBRUSH_X cmp #28 bcc lookout_no_exit cmp #35 @@ -15,10 +18,12 @@ lookout_check_exit: lda #MONKEY_POSTER sta LOCATION - lda #2 + lda #4 sta GUYBRUSH_X - lda #22 + sta DESTINATION_X + lda #20 sta GUYBRUSH_Y + sta DESTINATION_Y jsr change_location lookout_no_exit: diff --git a/monkey/monkey_poster.s b/monkey/monkey_poster.s index 314b969c..728724b2 100644 --- a/monkey/monkey_poster.s +++ b/monkey/monkey_poster.s @@ -1,23 +1,40 @@ - + ; if x<3 goto MONKEY_POSTER at 28,30 with destination 28,24 + ; if x>35 goto MONKEY_DOCK at 5,20 poster_check_exit: -; lda DESTINATION_Y -; cmp #28 -; bcc lookout_no_exit + lda GUYBRUSH_X + cmp #3 + bcc poster_to_lookout + cmp #35 + bcs poster_to_dock + bcc poster_no_exit -; lda DESTINATION_X -; cmp #28 -; bcc lookout_no_exit -; cmp #35 -; bcs lookout_no_exit +poster_to_lookout: + lda #MONKEY_LOOKOUT + sta LOCATION + lda #28 + sta GUYBRUSH_X + lda #26 + sta GUYBRUSH_Y + lda #28 + sta DESTINATION_X + lda #18 + sta DESTINATION_Y + lda #DIR_UP + sta GUYBRUSH_DIRECTION + jsr change_location + jmp poster_no_exit -; lda #MONKEY_POSTER -; sta LOCATION -; lda #2 -; sta GUYBRUSH_X -; lda #22 -; sta GUYBRUSH_Y -; jsr change_location +poster_to_dock: + lda #MONKEY_DOCK + sta LOCATION + lda #5 + sta DESTINATION_X + sta GUYBRUSH_X + lda #20 + sta GUYBRUSH_Y + sta DESTINATION_Y + jsr change_location poster_no_exit: rts @@ -25,35 +42,13 @@ poster_no_exit: 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 + ; can be any X ps_check_y: - ; if x < 28, Y must be between 16 and 18 - ; if x < 35, Y must be between 8 and 28 + ; if x>5 Y should be 20 -; lda DESTINATION_Y -; cmp #16 -; bcc ld_y_too_small - - rts - -ps_y_too_small: -; lda #16 -; sta DESTINATION_Y + lda #20 + sta DESTINATION_Y done_ps_adjust: rts @@ -63,19 +58,42 @@ done_ps_adjust: draw_house: -; lda #wall_sprite -; sta INH + lda #house_sprite + sta INH -; lda #18 -; sta XPOS -; lda #22 -; sta YPOS + lda #9 + sta XPOS + lda #20 + sta YPOS -; jsr put_sprite_crop + jsr put_sprite_crop -; rts + rts house_sprite: + .byte 18,7 + ;line 1 + .byte $AA,$5A,$55,$55,$55,$55,$55,$55,$55,$55 + .byte $55,$55,$55,$57,$7A,$7A,$AA,$AA + + .byte $00,$00,$00,$00,$00,$00,$00,$05,$05,$05 + .byte $05,$05,$05,$05,$05,$05,$07,$7A + + .byte $22,$22,$22,$22,$20,$80,$80,$00,$80,$80 + .byte $22,$72,$A7,$AA,$AA,$AA,$77,$AA + + .byte $22,$22,$22,$22,$22,$88,$d8,$00,$d8,$88 + .byte $22,$77,$AA,$AA,$AA,$77,$AA,$AA + + .byte $22,$22,$22,$22,$22,$08,$0d,$00,$0d,$22 + .byte $22,$77,$AA,$AA,$AA,$77,$AA,$AA + + .byte $22,$22,$22,$22,$22,$88,$dd,$00,$dd,$22 + .byte $22,$77,$7A,$7A,$7A,$77,$AA,$AA + + .byte $22,$22,$22,$22,$22,$28,$20,$2d,$28,$22 + .byte $77,$AA,$77,$AA,$77,$AA,$AA,$AA + diff --git a/monkey/zp.inc b/monkey/zp.inc index dd445716..28075c32 100644 --- a/monkey/zp.inc +++ b/monkey/zp.inc @@ -105,6 +105,8 @@ GUYBRUSH_DIRECTION = $93 DIR_UP = 4 DIR_RIGHT= 6 +BAR_DOOR_OPEN = $94 + ; done game puzzle state