From dcec7fa124825934389c6d0f42301521af01306d Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 6 Aug 2020 23:18:37 -0400 Subject: [PATCH] mist: stoney: only draw underwater lamp if on --- mist/default_save.s | 4 +-- mist/stoney.s | 6 ++++ mist/stoney_puzzles.s | 73 +++++++++++++++++++++++++++++++++++++++++++ mist/zp.inc | 4 ++- 4 files changed, 84 insertions(+), 3 deletions(-) diff --git a/mist/default_save.s b/mist/default_save.s index 9053be42..2a3a74e9 100644 --- a/mist/default_save.s +++ b/mist/default_save.s @@ -109,8 +109,8 @@ .byte $00 ; SHIP_RAISED = $AF ; stoneship .byte $00 ; PUMP_STATE = $B0 -.byte $00 ; BATTERY_CHARGE = $B1 -.byte $00 ; COMPASS_ANGLE = $B2 +.byte $07 ; BATTERY_CHARGE = $B1 +.byte $00 ; COMPASS_STATE = $B2 .byte $00 ; CRANK_ANGLE = $B3 .byte $00 ; WHITE_PAGE_TAKEN = $B4 .byte $00 ; CHANNEL_SWITCHES = $B5 diff --git a/mist/stoney.s b/mist/stoney.s index 734f55f3..594e4592 100644 --- a/mist/stoney.s +++ b/mist/stoney.s @@ -48,6 +48,9 @@ stoney_start: jsr change_location + ; make sure book access set up right + jsr update_compass_state + lda #1 sta CURSOR_VISIBLE ; visible at first @@ -92,6 +95,9 @@ dont_touch_lights: ; handle special-case forground logic ;==================================== + ; check to see if draw compass light + jsr compass_draw_light + lda LOCATION cmp #STONEY_BOOK_TABLE_OPEN diff --git a/mist/stoney_puzzles.s b/mist/stoney_puzzles.s index 5f35a954..ee50fe0b 100644 --- a/mist/stoney_puzzles.s +++ b/mist/stoney_puzzles.s @@ -64,6 +64,79 @@ compass_puzzle: rts + ;================================== + ; draw compass light + ;================================== + ; underwater light comes on if compass successful + + ; if in room STONEY_COMPASS_ROOM_RIGHT (facing N) or + ; STONEY_COMPASS_ROOM_LEFT (facing W) + ; and COMPASS_STATE is not 0 then draw the sprite + +compass_draw_light: + lda COMPASS_STATE + beq done_compass_draw_light + + lda LOCATION + cmp #STONEY_COMPASS_ROOM_RIGHT + beq light_room_right + cmp #STONEY_COMPASS_ROOM_LEFT + beq light_room_left + + rts + +light_room_right: + lda DIRECTION + cmp #DIRECTION_N + beq actually_draw_light + rts + +light_room_left: + lda DIRECTION + cmp #DIRECTION_W + bne done_compass_draw_light + +actually_draw_light: + lda #17 + sta XPOS + lda #14 + sta YPOS + lda #compass_light_sprite + sta INH + jsr put_sprite_crop + +done_compass_draw_light: + rts + +compass_light_sprite: + .byte 6,4 + .byte $44,$94,$94,$94,$94,$44 + .byte $44,$99,$ff,$ff,$99,$44 + .byte $44,$99,$9f,$9f,$99,$44 + .byte $24,$24,$24,$24,$24,$24 + + ;================================== + ; update compass state + ;================================== + ; if COMPASS_STATE is 0: + ; disable access to linking book + ; if COMPASS_STATE is 1: + ; enable access to linking book +update_compass_state: + ldy #LOCATION_NORTH_EXIT + lda COMPASS_STATE + bne enable_book_access +disable_book_access: + lda #$ff + bne update_book_access ; bra +enable_book_access: + lda #STONEY_BOOK_TABLE +update_book_access: + sta location16,Y ; STONEY_BOOK_ROOM + rts + ;=================================== ; crawlways ;=================================== diff --git a/mist/zp.inc b/mist/zp.inc index 515bd990..b59a14d1 100644 --- a/mist/zp.inc +++ b/mist/zp.inc @@ -172,7 +172,9 @@ SHIP_RAISED = $AF ; ship raised or not PUMP_STATE = $B0 ; stoneship pump state BATTERY_CHARGE = $B1 ; stoneship battery charge -COMPASS_ANGLE = $B2 ; stoneship compass angle +COMPASS_STATE = $B2 ; stoneship compass state + COMPASS_DEFAULT = 0 ; cabin lights off + COMPASS_LIGHT_ON= 1 ; proper angle selected CRANK_ANGLE = $B3 ; stoneship crank angle WHITE_PAGE_TAKEN= $B4 ; white page taken