dos33fsprogs/mist/clock_bridge_puzzle.s

525 lines
7.3 KiB
ArmAsm
Raw Normal View History

2020-07-11 23:43:09 +00:00
; note, the clock is a bit different in the real game
; can't see face when pressing buttons
; and the way the hands move is a bit more complex (or is it?)
2020-07-11 23:43:09 +00:00
2020-03-07 20:21:16 +00:00
;======================
; reset the puzzle inside the clock
clock_inside_reset:
lda #0
sta CLOCK_TOP
sta CLOCK_MIDDLE
sta CLOCK_BOTTOM
sta CLOCK_COUNT
sta CLOCK_LAST
2020-03-07 20:21:16 +00:00
rts
;======================
; handle the clock inside puzzle
2020-03-07 20:21:16 +00:00
clock_inside_puzzle:
lda XPOS
cmp #25
bcc inside_not_reset
inside_reset:
jsr clock_inside_reset
rts
inside_not_reset:
lda CLOCK_COUNT
cmp #9
beq inside_done
lda XPOS
cmp #18
bcc inside_left
bcs inside_right
inside_left:
inc CLOCK_MIDDLE
lda CLOCK_LAST
cmp #1
bne left_spin_bottom
lda YPOS
cmp #24
bcs left_nospin_bottom
left_spin_bottom:
2020-03-07 20:21:16 +00:00
inc CLOCK_BOTTOM
left_nospin_bottom:
lda #1
2020-03-07 20:21:16 +00:00
jmp wrap_wheels
inside_right:
inc CLOCK_MIDDLE
lda CLOCK_LAST
cmp #2
bne right_spin_top
lda YPOS
cmp #24
bcs right_nospin_top
right_spin_top:
2020-03-07 20:21:16 +00:00
inc CLOCK_TOP
right_nospin_top:
lda #2
2020-03-07 20:21:16 +00:00
wrap_wheels:
sta CLOCK_LAST
inc CLOCK_COUNT
2020-03-07 20:21:16 +00:00
ldx #0
wrap_wheels_loop:
lda CLOCK_TOP,X
cmp #3
bne no_wrap
lda #0
sta CLOCK_TOP,X
no_wrap:
inx
cpx #3
bne wrap_wheels_loop
2020-03-07 23:24:46 +00:00
; see if done!
; note 0->3, 1->1, 2->2 so want 2/2/1 -> 2/2/1
lda CLOCK_TOP
cmp #2
bne no_open_gear
lda CLOCK_MIDDLE
cmp #2
bne no_open_gear
lda CLOCK_BOTTOM
cmp #1
bne no_open_gear
lda #1
change_gear:
sta GEAR_OPEN
jsr open_the_gear
jmp inside_done
no_open_gear:
lda GEAR_OPEN
beq inside_done
; change if it was open
lda #0
jmp change_gear
2020-03-07 20:21:16 +00:00
inside_done:
rts
;======================
; draw the clock inside
draw_clock_inside:
lda DIRECTION
cmp #DIRECTION_S
bne done_draw_clock_puzzle
2020-03-07 20:21:16 +00:00
; draw weight
lda #<clock_weight_sprite
sta INL
lda #>clock_weight_sprite
sta INH
lda #9
sta XPOS
lda CLOCK_COUNT
asl
asl
clc
adc #4
2020-03-07 20:21:16 +00:00
sta YPOS
jsr put_sprite_crop
lda CLOCK_TOP
asl
tay
lda clock_gear_sprites,Y
sta INL
lda clock_gear_sprites+1,Y
sta INH
lda #17
sta XPOS
lda #8
sta YPOS
jsr put_sprite_crop
lda CLOCK_MIDDLE
asl
tay
lda clock_gear_sprites,Y
sta INL
lda clock_gear_sprites+1,Y
sta INH
lda #17
sta XPOS
lda #12
sta YPOS
jsr put_sprite_crop
lda CLOCK_BOTTOM
asl
tay
lda clock_gear_sprites,Y
sta INL
lda clock_gear_sprites+1,Y
sta INH
lda #17
sta XPOS
lda #16
sta YPOS
jsr put_sprite_crop
done_draw_clock_puzzle:
2020-03-07 20:21:16 +00:00
rts
;======================
; open the gear
open_the_gear:
2020-03-07 23:24:46 +00:00
lda GEAR_OPEN
beq no_gear_open
yes_gear_open:
ldy #LOCATION_NORTH_EXIT
lda #MIST_OPEN_GEAR
sta location15,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
ldy #LOCATION_NORTH_EXIT_DIR
lda #DIRECTION_E
sta location15,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
ldy #LOCATION_NORTH_BG
lda #<gear_open_n_lzsa
sta location15,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
lda #>gear_open_n_lzsa
sta location15+1,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
ldy #LOCATION_SOUTH_BG
lda #<clock_inside_open_lzsa
sta location23,Y ; MIST_CLOCK_INSIDE
2020-03-07 23:24:46 +00:00
lda #>clock_inside_open_lzsa
sta location23+1,Y ; MIST_CLOCK_INSIDE
2020-03-07 23:24:46 +00:00
jmp done_open_the_gear
2020-03-07 20:21:16 +00:00
2020-03-07 23:24:46 +00:00
no_gear_open:
ldy #LOCATION_NORTH_EXIT
lda #$FF
sta location15,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
; ldy #LOCATION_NORTH_EXIT_DIR
; lda #DIRECTION_E
; sta location15,Y
2020-03-07 23:24:46 +00:00
ldy #LOCATION_NORTH_BG
lda #<gear_n_lzsa
sta location15,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
lda #>gear_n_lzsa
sta location15+1,Y ; MIST_GEAR
2020-03-07 23:24:46 +00:00
ldy #LOCATION_SOUTH_BG
lda #<clock_inside_s_lzsa ; MIST_CLOCK_INSIDE
sta location23,Y
2020-03-07 23:24:46 +00:00
lda #>clock_inside_s_lzsa
sta location23+1,Y
2020-03-07 23:24:46 +00:00
done_open_the_gear:
jsr change_location
2020-03-07 20:21:16 +00:00
rts
2020-03-07 18:42:04 +00:00
;======================
; raise bridge
raise_bridge:
2020-03-07 20:21:16 +00:00
lda CLOCK_BRIDGE
beq lower_bridge
2020-03-07 18:42:04 +00:00
ldy #LOCATION_SOUTH_EXIT
lda #MIST_CLOCK_ISLAND
sta location21,Y ; MIST_CLOCK_PUZZLE
2020-03-07 18:42:04 +00:00
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_S
sta location21,Y ; MIST_CLOCK_PUZZLE
2020-03-07 16:06:29 +00:00
2020-03-07 18:42:04 +00:00
ldy #LOCATION_SOUTH_BG
lda #<clock_puzzle_bridge_lzsa
sta location21,Y ; MIST_CLOCK_PUZZLE
2020-03-07 18:42:04 +00:00
lda #>clock_puzzle_bridge_lzsa
sta location21+1,Y ; MIST_CLOCK_PUZZLE
2020-03-07 18:42:04 +00:00
; draw it on other too
lda #<clock_bridge_lzsa
sta location11,Y ; MIST_CLOCK
lda #>clock_bridge_lzsa
sta location11+1,Y ; MIST_CLOCK
2020-03-07 20:21:16 +00:00
jmp done_clock_bridge
lower_bridge:
ldy #LOCATION_SOUTH_EXIT
; lda #MIST_TREE_CORRIDOR_5
lda #$ff
sta location21,Y ; MIST_CLOCK_PUZZLE
2020-03-07 20:21:16 +00:00
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_N
sta location21,Y ; MIST_CLOCK_PUZZLE
2020-03-07 20:21:16 +00:00
ldy #LOCATION_SOUTH_BG
lda #<clock_puzzle_s_lzsa
sta location21,Y ; MIST_CLOCK_PUZZLE
2020-03-07 20:21:16 +00:00
lda #>clock_puzzle_s_lzsa
sta location21+1,Y ; MIST_CLOCK_PUZZLE
2020-03-07 20:21:16 +00:00
; lower on other too
lda #<clock_s_lzsa
sta location11,Y ; MIST_CLOCK
lda #>clock_s_lzsa
sta location11+1,Y ; MIST_CLOCK
2020-03-07 20:21:16 +00:00
done_clock_bridge:
2020-03-07 18:42:04 +00:00
rts
2020-03-07 16:06:29 +00:00
;======================
; draw the clock face
draw_clock_face:
2020-04-15 18:04:40 +00:00
lda DIRECTION
cmp #DIRECTION_S
bne done_draw_clock_face
2020-03-07 16:06:29 +00:00
lda CLOCK_HOUR
asl
tay
lda clock_hour_sprites,Y
sta INL
lda clock_hour_sprites+1,Y
sta INH
lda LOCATION
cmp #MIST_CLOCK
bne old_clock_face
new_clock_face:
lda #24
sta XPOS
lda #8
bne done_clock_face ; bra
old_clock_face:
2020-03-07 16:06:29 +00:00
lda #20
sta XPOS
lda #6
done_clock_face:
2020-03-07 16:06:29 +00:00
sta YPOS
jsr put_sprite_crop
lda CLOCK_MINUTE
asl
tay
lda clock_minute_sprites,Y
sta INL
lda clock_minute_sprites+1,Y
sta INH
lda LOCATION
cmp #MIST_CLOCK
bne old_clock_face2
new_clock_face2:
lda #24
sta XPOS
lda #8
bne done_clock_face2 ; bra
old_clock_face2:
2020-03-07 16:06:29 +00:00
lda #20
sta XPOS
lda #6
done_clock_face2:
2020-03-07 16:06:29 +00:00
sta YPOS
jsr put_sprite_crop
2020-04-15 18:04:40 +00:00
done_draw_clock_face:
2020-03-07 16:06:29 +00:00
rts
2020-03-07 18:07:42 +00:00
;======================
; clock puzzle
clock_puzzle:
lda CURSOR_X
cmp #19
bcc clock_puzzle_minutes ; blt
2020-03-07 18:07:42 +00:00
cmp #24
bcc clock_puzzle_hours ; blt
2020-03-07 18:07:42 +00:00
bcs clock_puzzle_button ; bge
clock_puzzle_hours:
inc CLOCK_HOUR
lda CLOCK_HOUR
cmp #12
bne clock_puzzle_done
lda #0
sta CLOCK_HOUR
beq clock_puzzle_done
clock_puzzle_minutes:
inc CLOCK_MINUTE
lda CLOCK_MINUTE
cmp #12
bne clock_puzzle_done
lda #0
sta CLOCK_MINUTE
beq clock_puzzle_done
clock_puzzle_button:
lda CLOCK_MINUTE
cmp #8
bne bridge_down
lda CLOCK_HOUR
cmp #2
bne bridge_down
lda #1
jmp bridge_adjust
2020-03-07 16:06:29 +00:00
2020-03-07 18:07:42 +00:00
bridge_down:
lda #0
bridge_adjust:
sta CLOCK_BRIDGE
jsr click_speaker ; click speaker
2020-03-07 18:07:42 +00:00
2020-03-07 18:42:04 +00:00
jsr raise_bridge
; update the background
jsr change_location
2020-03-07 18:07:42 +00:00
clock_puzzle_done:
rts
2020-03-07 16:06:29 +00:00
.include "clock_sprites.inc"
2020-03-07 23:24:46 +00:00
; put at 12,6 on screen 4 N
gear_block_sprite1:
.byte 4,3
.byte $ff,$ff,$ff,$ff
.byte $df,$df,$df,$df
.byte $ff,$dd,$ff,$0f
2020-03-07 23:24:46 +00:00
; put at 9,6 on screen 20 N
gear_block_sprite2:
.byte 7,4
.byte $ff,$ff,$ff,$ff,$ff,$ff,$ff
.byte $ff,$ff,$ff,$ff,$ff,$ff,$ff
.byte $fd,$fd,$dd,$ff,$dd,$fd,$df
.byte $ff,$ff,$dd,$ff,$dd,$ff,$0f
; put at 21,4 on screen 5 N
gear_block_sprite3:
.byte 2,2
.byte $ff,$ff
.byte $ff,$ff
check_gear_delete:
; all views of gear are when looking north?
2020-03-07 23:24:46 +00:00
lda DIRECTION
cmp #DIRECTION_N
bne done_gear_delete
lda LOCATION
cmp #MIST_ABOVE_DOCK
2020-03-07 23:24:46 +00:00
beq gear_look1
cmp #MIST_DOCK_STEPS
beq gear_look2
cmp #MIST_GEAR_BASE
2020-03-07 23:24:46 +00:00
beq gear_look2
cmp #MIST_BASE_STEPS
2020-03-07 23:24:46 +00:00
beq gear_look3
cmp #MIST_STEPS_1ST_LANDING
beq gear_look3
2020-03-07 23:24:46 +00:00
bne done_gear_delete
gear_look1:
lda #<gear_block_sprite1
sta INL
lda #>gear_block_sprite1
sta INH
lda #12
sta XPOS
lda #6
jmp draw_gear_delete
gear_look2:
lda #<gear_block_sprite2
sta INL
lda #>gear_block_sprite2
sta INH
lda #9
sta XPOS
lda #6
jmp draw_gear_delete
gear_look3:
lda #<gear_block_sprite3
sta INL
lda #>gear_block_sprite3
sta INH
lda #21
sta XPOS
lda #4
draw_gear_delete:
sta YPOS
jsr put_sprite_crop
done_gear_delete:
rts