dos33fsprogs/mist/clock_bridge_puzzle.s

478 lines
6.0 KiB
ArmAsm
Raw Normal View History

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 iside puzzle
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:
; 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
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 #30
sta location19,Y
ldy #LOCATION_NORTH_EXIT_DIR
lda #DIRECTION_E
sta location19,Y
ldy #LOCATION_NORTH_BG
lda #<gear_open_n_lzsa
sta location19,Y
lda #>gear_open_n_lzsa
sta location19+1,Y
ldy #LOCATION_SOUTH_BG
lda #<clock_inside_open_lzsa
sta location27,Y
lda #>clock_inside_open_lzsa
sta location27+1,Y
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 location19,Y
; ldy #LOCATION_NORTH_EXIT_DIR
; lda #DIRECTION_E
; sta location19,Y
ldy #LOCATION_NORTH_BG
lda #<gear_n_lzsa
sta location19,Y
lda #>gear_n_lzsa
sta location19+1,Y
ldy #LOCATION_SOUTH_BG
lda #<clock_inside_s_lzsa
sta location27,Y
lda #>clock_inside_s_lzsa
sta location27+1,Y
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 #26
sta location25,Y
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_S
sta location25,Y
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 location25,Y
lda #>clock_puzzle_bridge_lzsa
sta location25+1,Y
; draw it on other too
lda #<clock_bridge_lzsa
sta location15,Y
lda #>clock_bridge_lzsa
sta location15+1,Y
2020-03-07 20:21:16 +00:00
jmp done_clock_bridge
lower_bridge:
ldy #LOCATION_SOUTH_EXIT
lda #18
sta location25,Y
ldy #LOCATION_SOUTH_EXIT_DIR
lda #DIRECTION_N
sta location25,Y
ldy #LOCATION_SOUTH_BG
lda #<clock_puzzle_s_lzsa
sta location25,Y
lda #>clock_puzzle_s_lzsa
sta location25+1,Y
; lower on other too
lda #<clock_s_lzsa
sta location15,Y
lda #>clock_s_lzsa
sta location15+1,Y
2020-03-07 20:21:16 +00:00
done_clock_bridge:
2020-03-07 18:42:04 +00:00
jsr change_location
rts
2020-03-07 16:06:29 +00:00
;======================
; draw the clock face
draw_clock_face:
lda CLOCK_HOUR
asl
tay
lda clock_hour_sprites,Y
sta INL
lda clock_hour_sprites+1,Y
sta INH
lda #20
sta XPOS
lda #6
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 #20
sta XPOS
lda #6
sta YPOS
jsr put_sprite_crop
rts
2020-03-07 18:07:42 +00:00
;======================
; clock puzzle
clock_puzzle:
lda CURSOR_X
cmp #19
bcc clock_puzzle_hours ; blt
cmp #24
bcc clock_puzzle_minutes ; blt
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
bit $C030 ; click speaker
2020-03-07 18:42:04 +00:00
jsr raise_bridge
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 $ff,$ff,$ff,$ff
.byte $ff,$ff,$ff,$0f
; 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:
lda DIRECTION
cmp #DIRECTION_N
bne done_gear_delete
lda LOCATION
cmp #4
beq gear_look1
cmp #3
beq gear_look2
2020-03-07 23:24:46 +00:00
cmp #20
beq gear_look2
cmp #5
beq gear_look3
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