mist: cabin: can now enter combination on the safe

This commit is contained in:
Vince Weaver 2020-07-14 11:15:40 -04:00
parent 2ef17c2948
commit 6704aa582e
6 changed files with 110 additions and 69 deletions

View File

@ -76,6 +76,13 @@ game_loop:
cmp #CABIN_TREE_BOOK_OPEN cmp #CABIN_TREE_BOOK_OPEN
beq animate_channel_book beq animate_channel_book
cmp #CABIN_SAFE
bne check_next
jsr draw_safe_combination
jmp nothing_special
check_next:
jmp nothing_special jmp nothing_special
animate_channel_book: animate_channel_book:

View File

@ -1,92 +1,114 @@
; this is a painful one ; this is a painful one
; mostly because the tree puzzle is sort of obscure in the original
;====================
; safe was clicked
;====================
goto_safe: goto_safe:
lda #CABIN_SAFE lda #CABIN_SAFE
sta LOCATION sta LOCATION
jmp change_location jmp change_location
;====================
; safe was touched
control_panel_pressed: ;====================
touch_safe:
lda CURSOR_Y lda CURSOR_Y
; check if buttons
cmp #26 ; blt cmp #26 ; blt
bcc panel_inc bcc safe_buttons
cmp #30 ; blt
bcc panel_dec
panel_latch: ; check if handle
cmp #34
bcs pull_handle ; bge
lda VIEWER_CHANNEL ; else do nothing
sta VIEWER_LATCHED ; latch value into pool state rts
lda #VIEWER_POOL
sta LOCATION
lda #DIRECTION_W pull_handle:
sta DIRECTION ; FIXME
jmp change_location rts
panel_inc: safe_buttons:
lda CURSOR_X lda CURSOR_X
cmp #18 cmp #13 ; not a button
bcs right_arrow_pressed 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 hundreds_inc:
and #$f0 sed
cmp #$90 lda SAFE_HUNDREDS
bcs done_panel_press ; bge
lda VIEWER_CHANNEL
clc clc
adc #$10 adc #$1
sta VIEWER_CHANNEL cld
rts
right_arrow_pressed:
; 13-17 right arrow
lda VIEWER_CHANNEL
and #$f and #$f
cmp #9 sta SAFE_HUNDREDS
bcs done_panel_press ; bge
inc VIEWER_CHANNEL
rts rts
panel_dec: tens_inc:
lda CURSOR_X sed
cmp #18 lda SAFE_TENS
bcs right_arrow_pressed_dec clc
adc #$1
; 19-23 left arrow cld
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
and #$f and #$f
beq done_panel_press sta SAFE_TENS
dec VIEWER_CHANNEL
rts
ones_inc:
sed
lda SAFE_ONES
clc
adc #$1
cld
and #$f
sta SAFE_ONES
done_panel_press:
rts 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 and #$f
asl asl
tay tay
@ -103,13 +125,11 @@ display_panel_code:
jsr put_sprite_crop jsr put_sprite_crop
; tens digit ; ones digit
lda VIEWER_CHANNEL lda SAFE_ONES
and #$f0 and #$f
lsr asl
lsr
lsr
tay tay
lda number_sprites,Y lda number_sprites,Y
@ -117,7 +137,7 @@ display_panel_code:
lda number_sprites+1,Y lda number_sprites+1,Y
sta INH sta INH
lda #15 lda #27
sta XPOS sta XPOS
lda #8 lda #8
sta YPOS sta YPOS

View File

@ -74,3 +74,7 @@
.byte $00 ; COMPARTMENT_OPEN = $C1 .byte $00 ; COMPARTMENT_OPEN = $C1
.byte $00 ; GAME_COMPLETED = $C2 .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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@ -105,7 +105,10 @@ location4:
.word $000 ; east bg .word $000 ; east bg
.word safe_w_lzsa ; west bg .word safe_w_lzsa ; west bg
.byte BG_WEST .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 ; CABIN_CLOCK_PATH -- path to clock
location5: location5:

View File

@ -189,7 +189,14 @@ COMPARTMENT_OPEN = $C1 ; dock marker switch compartment
GAME_COMPLETE = $C2 ; game has been completed 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 ; done game puzzle state