diff --git a/mist/cabin.s b/mist/cabin.s index 7ebecf22..fb313252 100644 --- a/mist/cabin.s +++ b/mist/cabin.s @@ -76,6 +76,13 @@ game_loop: cmp #CABIN_TREE_BOOK_OPEN beq animate_channel_book + cmp #CABIN_SAFE + bne check_next + jsr draw_safe_combination + jmp nothing_special + +check_next: + jmp nothing_special animate_channel_book: diff --git a/mist/cabin_boiler_puzzle.s b/mist/cabin_boiler_puzzle.s index 49894ae8..4a65b2c9 100644 --- a/mist/cabin_boiler_puzzle.s +++ b/mist/cabin_boiler_puzzle.s @@ -1,92 +1,114 @@ ; this is a painful one + ; mostly because the tree puzzle is sort of obscure in the original + + + ;==================== + ; safe was clicked + ;==================== goto_safe: lda #CABIN_SAFE sta LOCATION jmp change_location - - -control_panel_pressed: + ;==================== + ; safe was touched + ;==================== +touch_safe: lda CURSOR_Y + + ; check if buttons cmp #26 ; blt - bcc panel_inc - cmp #30 ; blt - bcc panel_dec + bcc safe_buttons -panel_latch: + ; check if handle + cmp #34 + bcs pull_handle ; bge - lda VIEWER_CHANNEL - sta VIEWER_LATCHED ; latch value into pool state + ; else do nothing + rts - lda #VIEWER_POOL - sta LOCATION - lda #DIRECTION_W - sta DIRECTION - jmp change_location +pull_handle: + ; FIXME + rts -panel_inc: +safe_buttons: lda CURSOR_X - cmp #18 - bcs right_arrow_pressed + cmp #13 ; not a button + bcc no_button + cmp #19 + bcc hundreds_inc + cmp #25 + bcc tens_inc + bcs ones_inc - ; 19-23 left arrow +no_button: + rts - lda VIEWER_CHANNEL - and #$f0 - cmp #$90 - bcs done_panel_press ; bge - lda VIEWER_CHANNEL +hundreds_inc: + sed + lda SAFE_HUNDREDS clc - adc #$10 - sta VIEWER_CHANNEL - rts - -right_arrow_pressed: - ; 13-17 right arrow - - lda VIEWER_CHANNEL + adc #$1 + cld and #$f - cmp #9 - bcs done_panel_press ; bge - inc VIEWER_CHANNEL + sta SAFE_HUNDREDS + rts -panel_dec: - lda CURSOR_X - cmp #18 - bcs right_arrow_pressed_dec - - ; 19-23 left arrow - - lda VIEWER_CHANNEL - and #$f0 - beq done_panel_press - lda VIEWER_CHANNEL - sec - sbc #$10 - sta VIEWER_CHANNEL - rts - -right_arrow_pressed_dec: - ; 13-17 right arrow - - lda VIEWER_CHANNEL +tens_inc: + sed + lda SAFE_TENS + clc + adc #$1 + cld and #$f - beq done_panel_press - dec VIEWER_CHANNEL + sta SAFE_TENS + + rts + +ones_inc: + sed + lda SAFE_ONES + clc + adc #$1 + cld + and #$f + sta SAFE_ONES -done_panel_press: rts -display_panel_code: - ; ones digit + ;============================== + ; draw the numbers on the safe + ;============================== +draw_safe_combination: - lda VIEWER_CHANNEL + ; hundreds digit + + lda SAFE_HUNDREDS + and #$f + asl + tay + + lda number_sprites,Y + sta INL + lda number_sprites+1,Y + sta INH + + lda #15 + sta XPOS + lda #8 + sta YPOS + + jsr put_sprite_crop + + ; tens digit + + lda SAFE_TENS and #$f asl tay @@ -103,13 +125,11 @@ display_panel_code: jsr put_sprite_crop - ; tens digit + ; ones digit - lda VIEWER_CHANNEL - and #$f0 - lsr - lsr - lsr + lda SAFE_ONES + and #$f + asl tay lda number_sprites,Y @@ -117,7 +137,7 @@ display_panel_code: lda number_sprites+1,Y sta INH - lda #15 + lda #27 sta XPOS lda #8 sta YPOS diff --git a/mist/default_save.s b/mist/default_save.s index 23abbade..7bcd6fa4 100644 --- a/mist/default_save.s +++ b/mist/default_save.s @@ -74,3 +74,7 @@ .byte $00 ; COMPARTMENT_OPEN = $C1 .byte $00 ; GAME_COMPLETED = $C2 +.byte $00 ; SAFE_HUNDREDS = $C3 +.byte $00 ; SAFE_TENS = $C4 +.byte $00 ; SAFE_ONES = $C5 +.byte $00 ; SAFE_OPEN = $C6 diff --git a/mist/graphics_cabin/safe_w.png b/mist/graphics_cabin/safe_w.png index 5e78f945..7d52efef 100644 Binary files a/mist/graphics_cabin/safe_w.png and b/mist/graphics_cabin/safe_w.png differ diff --git a/mist/leveldata_cabin.inc b/mist/leveldata_cabin.inc index cb562575..dcda0b2d 100644 --- a/mist/leveldata_cabin.inc +++ b/mist/leveldata_cabin.inc @@ -105,7 +105,10 @@ location4: .word $000 ; east bg .word safe_w_lzsa ; west bg .byte BG_WEST - .byte $ff + .byte DIRECTION_W ; special exit + .byte 3,31 ; special x + .byte 16,44 ; special y + .word touch_safe-1 ; CABIN_CLOCK_PATH -- path to clock location5: diff --git a/mist/zp.inc b/mist/zp.inc index 5066a36f..75cddd7c 100644 --- a/mist/zp.inc +++ b/mist/zp.inc @@ -189,7 +189,14 @@ COMPARTMENT_OPEN = $C1 ; dock marker switch compartment GAME_COMPLETE = $C2 ; game has been completed -END_OF_SAVE = $C3 +SAFE_HUNDREDS = $C3 ; safe combination, hundreds +SAFE_TENS = $C4 ; safe combination, tens +SAFE_ONES = $C5 ; safe combination, ones + +SAFE_OPEN = $C6 + + +END_OF_SAVE = $C7 ; done game puzzle state