2020-07-08 18:43:54 +00:00
|
|
|
;====================================
|
|
|
|
; Routines for the generator puzzles
|
|
|
|
;====================================
|
|
|
|
|
2020-07-08 17:53:46 +00:00
|
|
|
leave_tower1:
|
|
|
|
lda #GEN_TOWER1_TOP
|
|
|
|
sta LOCATION
|
|
|
|
|
|
|
|
lda #DIRECTION_E
|
|
|
|
sta DIRECTION
|
|
|
|
|
|
|
|
jsr change_location
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
2020-07-08 18:43:54 +00:00
|
|
|
back_to_mist:
|
|
|
|
lda #MIST_TREE_CORRIDOR_4
|
|
|
|
sta LOCATION
|
|
|
|
|
|
|
|
lda #DIRECTION_E
|
|
|
|
sta DIRECTION
|
|
|
|
|
|
|
|
lda #LOAD_MIST
|
|
|
|
sta WHICH_LOAD
|
|
|
|
|
|
|
|
lda #$ff
|
|
|
|
sta LEVEL_OVER
|
2020-07-08 17:53:46 +00:00
|
|
|
|
2020-07-08 18:43:54 +00:00
|
|
|
rts
|
2020-07-08 17:53:46 +00:00
|
|
|
|
|
|
|
|
2020-03-18 05:48:15 +00:00
|
|
|
;=======================
|
|
|
|
; flip circuit breaker
|
|
|
|
|
2020-03-19 21:25:20 +00:00
|
|
|
; if room==MIST_TOWER2_TOP, and with #$fe
|
2020-07-08 17:53:46 +00:00
|
|
|
; if room==GEN_TOWER1_TOP, and with #$fd
|
2020-03-18 05:48:15 +00:00
|
|
|
|
|
|
|
circuit_breaker:
|
|
|
|
|
2020-07-17 13:39:27 +00:00
|
|
|
jsr click_speaker ; click speaker
|
2020-03-19 05:59:09 +00:00
|
|
|
|
2020-03-18 05:48:15 +00:00
|
|
|
lda LOCATION
|
2020-03-19 21:25:20 +00:00
|
|
|
cmp #MIST_TOWER2_TOP
|
2020-03-18 05:48:15 +00:00
|
|
|
bne other_circuit_breaker
|
|
|
|
|
|
|
|
lda BREAKER_TRIPPED
|
|
|
|
and #$fe
|
|
|
|
jmp done_circuit_breaker
|
|
|
|
|
|
|
|
other_circuit_breaker:
|
|
|
|
lda BREAKER_TRIPPED
|
|
|
|
and #$fd
|
|
|
|
|
|
|
|
done_circuit_breaker:
|
|
|
|
sta BREAKER_TRIPPED
|
2020-03-19 15:43:59 +00:00
|
|
|
|
|
|
|
bne done_turn_on_breaker
|
|
|
|
|
|
|
|
turn_on_breaker:
|
|
|
|
|
|
|
|
lda GENERATOR_VOLTS
|
|
|
|
cmp #$60
|
|
|
|
bcs done_turn_on_breaker
|
|
|
|
|
|
|
|
sta ROCKET_VOLTS
|
|
|
|
sta ROCKET_VOLTS_DISP
|
|
|
|
|
|
|
|
|
|
|
|
done_turn_on_breaker:
|
|
|
|
|
2020-03-18 05:48:15 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2020-03-10 20:12:56 +00:00
|
|
|
;======================
|
|
|
|
; open the generator_door
|
|
|
|
|
|
|
|
open_gen_door:
|
|
|
|
|
|
|
|
ldy #LOCATION_NORTH_EXIT
|
2020-07-08 17:53:46 +00:00
|
|
|
lda #GEN_GENERATOR_ROOM
|
|
|
|
sta location3,Y ; GEN_GENERATOR_DOOR
|
2020-03-10 20:12:56 +00:00
|
|
|
|
|
|
|
ldy #LOCATION_NORTH_EXIT_DIR
|
2020-03-11 13:46:53 +00:00
|
|
|
lda #(DIRECTION_N | DIRECTION_SPLIT | DIRECTION_ONLY_POINT)
|
2020-07-08 17:53:46 +00:00
|
|
|
sta location3,Y ; GEN_GENERATOR_DOOR
|
2020-03-10 20:12:56 +00:00
|
|
|
|
|
|
|
ldy #LOCATION_NORTH_BG
|
|
|
|
lda #<gen_door_open_n_lzsa
|
2020-07-08 17:53:46 +00:00
|
|
|
sta location3,Y ; GEN_GENERATOR_DOOR
|
2020-03-10 20:12:56 +00:00
|
|
|
lda #>gen_door_open_n_lzsa
|
2020-07-08 17:53:46 +00:00
|
|
|
sta location3+1,Y ; GEN_GENERATOR_DOOR
|
2020-03-10 20:12:56 +00:00
|
|
|
|
|
|
|
jsr change_location
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2020-03-11 13:46:53 +00:00
|
|
|
button_lookup:
|
|
|
|
.byte $10,$8,$4,$2,$1
|
|
|
|
|
2020-03-11 15:57:01 +00:00
|
|
|
button_values_top:
|
|
|
|
.byte $01,$02,$22,$19,$09 ; BCD
|
|
|
|
button_values_bottom:
|
|
|
|
.byte $10,$07,$08,$16,$05 ; BCD
|
|
|
|
|
|
|
|
needle_strings:
|
|
|
|
.byte '\'|$80,' '|$80,' '|$80,' '|$80
|
|
|
|
.byte ' '|$80,':'|$80,' '|$80,' '|$80
|
|
|
|
.byte ' '|$80,' '|$80,':'|$80,' '|$80
|
|
|
|
.byte ' '|$80,' '|$80,' '|$80,'/'|$80
|
|
|
|
|
|
|
|
;============================
|
|
|
|
; handle button presses
|
|
|
|
;============================
|
|
|
|
|
2020-03-11 13:46:53 +00:00
|
|
|
generator_button_press:
|
|
|
|
|
2020-03-19 21:25:20 +00:00
|
|
|
lda CURSOR_Y
|
2020-03-11 15:57:01 +00:00
|
|
|
cmp #38
|
|
|
|
bcs button_bottom_row ; bge
|
|
|
|
|
|
|
|
button_top_row:
|
|
|
|
|
2020-03-15 19:06:36 +00:00
|
|
|
lda CURSOR_X
|
2020-03-11 15:57:01 +00:00
|
|
|
sec
|
2020-03-11 16:07:15 +00:00
|
|
|
sbc #24
|
2020-03-11 15:57:01 +00:00
|
|
|
lsr
|
|
|
|
bmi done_press
|
|
|
|
cmp #5
|
|
|
|
bcs done_press ; bge
|
|
|
|
|
|
|
|
tax
|
2020-03-11 13:46:53 +00:00
|
|
|
lda SWITCH_TOP_ROW
|
2020-03-11 15:57:01 +00:00
|
|
|
eor button_lookup,X ; toggle switch
|
2020-03-11 13:46:53 +00:00
|
|
|
sta SWITCH_TOP_ROW
|
|
|
|
|
2020-03-11 15:57:01 +00:00
|
|
|
jmp done_press
|
|
|
|
|
|
|
|
button_bottom_row:
|
|
|
|
|
2020-03-15 19:06:36 +00:00
|
|
|
lda CURSOR_X
|
2020-03-11 15:57:01 +00:00
|
|
|
sec
|
2020-03-11 16:07:15 +00:00
|
|
|
sbc #25
|
2020-03-11 15:57:01 +00:00
|
|
|
lsr
|
|
|
|
bmi done_press
|
|
|
|
cmp #5
|
|
|
|
bcs done_press ; bge
|
|
|
|
|
|
|
|
tax
|
|
|
|
lda SWITCH_BOTTOM_ROW
|
|
|
|
eor button_lookup,X ; toggle switch
|
|
|
|
sta SWITCH_BOTTOM_ROW
|
|
|
|
no_bottom_press:
|
|
|
|
|
|
|
|
done_press:
|
|
|
|
|
|
|
|
|
|
|
|
calculate_button_totals:
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta ROCKET_VOLTS
|
|
|
|
sta GENERATOR_VOLTS
|
|
|
|
tax
|
|
|
|
|
|
|
|
calc_buttons_loop:
|
|
|
|
|
|
|
|
; top button
|
|
|
|
|
|
|
|
lda SWITCH_TOP_ROW
|
|
|
|
and button_lookup,X
|
|
|
|
beq ctop_button_off
|
|
|
|
|
|
|
|
ctop_button_on:
|
|
|
|
sed
|
|
|
|
clc
|
|
|
|
lda GENERATOR_VOLTS
|
|
|
|
adc button_values_top,X
|
|
|
|
sta GENERATOR_VOLTS
|
|
|
|
cld
|
|
|
|
|
|
|
|
ctop_button_off:
|
|
|
|
|
|
|
|
lda SWITCH_BOTTOM_ROW
|
|
|
|
and button_lookup,X
|
|
|
|
beq cbottom_button_off
|
|
|
|
|
|
|
|
cbottom_button_on:
|
|
|
|
sed
|
|
|
|
clc
|
|
|
|
lda GENERATOR_VOLTS
|
|
|
|
adc button_values_bottom,X
|
|
|
|
sta GENERATOR_VOLTS
|
|
|
|
cld
|
|
|
|
|
|
|
|
cbottom_button_off:
|
|
|
|
|
|
|
|
inx
|
|
|
|
cpx #5
|
|
|
|
bne calc_buttons_loop
|
|
|
|
|
|
|
|
; calculate rocket volts
|
|
|
|
lda BREAKER_TRIPPED
|
|
|
|
bne done_rocket_volts
|
|
|
|
|
|
|
|
lda GENERATOR_VOLTS
|
2020-03-15 19:06:36 +00:00
|
|
|
cmp #$60
|
|
|
|
bcs oops_flipped ; bge
|
2020-03-11 15:57:01 +00:00
|
|
|
|
|
|
|
sta ROCKET_VOLTS
|
|
|
|
jmp done_rocket_volts
|
|
|
|
|
|
|
|
oops_flipped:
|
|
|
|
lda #$3
|
|
|
|
sta BREAKER_TRIPPED
|
|
|
|
|
|
|
|
done_rocket_volts:
|
2020-03-11 13:46:53 +00:00
|
|
|
|
|
|
|
rts
|
|
|
|
|
2020-03-11 15:57:01 +00:00
|
|
|
;===========================
|
|
|
|
; draw the voltage displays
|
|
|
|
;===========================
|
2020-03-11 13:46:53 +00:00
|
|
|
|
|
|
|
generator_update_volts:
|
|
|
|
|
2020-03-11 18:17:58 +00:00
|
|
|
; gradually adjust generator voltage
|
|
|
|
sed
|
|
|
|
lda GENERATOR_VOLTS_DISP
|
|
|
|
cmp GENERATOR_VOLTS
|
|
|
|
beq no_adjust_gen_volts
|
|
|
|
bcs gen_volts_dec
|
|
|
|
|
|
|
|
clc
|
|
|
|
adc #1
|
|
|
|
jmp done_adjust_gen_volts
|
|
|
|
gen_volts_dec:
|
|
|
|
sec
|
|
|
|
sbc #1
|
|
|
|
done_adjust_gen_volts:
|
|
|
|
sta GENERATOR_VOLTS_DISP
|
|
|
|
|
|
|
|
no_adjust_gen_volts:
|
|
|
|
|
|
|
|
|
|
|
|
; gradually adjust rocket voltage
|
|
|
|
lda ROCKET_VOLTS_DISP
|
|
|
|
cmp ROCKET_VOLTS
|
|
|
|
beq no_adjust_rocket_volts
|
|
|
|
bcs rocket_volts_dec
|
|
|
|
|
|
|
|
clc
|
|
|
|
adc #1
|
|
|
|
jmp done_adjust_rocket_volts
|
|
|
|
rocket_volts_dec:
|
|
|
|
sec
|
|
|
|
sbc #1
|
|
|
|
done_adjust_rocket_volts:
|
|
|
|
sta ROCKET_VOLTS_DISP
|
|
|
|
|
|
|
|
no_adjust_rocket_volts:
|
|
|
|
cld
|
|
|
|
|
|
|
|
|
2020-03-11 13:46:53 +00:00
|
|
|
lda DRAW_PAGE
|
|
|
|
clc
|
|
|
|
adc #$6
|
2020-03-11 15:57:01 +00:00
|
|
|
sta gen_volt_ones_smc+2
|
|
|
|
sta gen_volt_tens_smc+2
|
|
|
|
sta rocket_volt_ones_smc+2
|
|
|
|
sta rocket_volt_tens_smc+2
|
|
|
|
sta gen_put_needle_smc+2
|
|
|
|
sta rocket_put_needle_smc+2
|
2020-03-11 13:46:53 +00:00
|
|
|
|
2020-03-11 18:17:58 +00:00
|
|
|
lda GENERATOR_VOLTS_DISP
|
2020-03-11 13:46:53 +00:00
|
|
|
and #$f
|
|
|
|
clc
|
|
|
|
adc #$b0
|
2020-03-11 15:57:01 +00:00
|
|
|
gen_volt_ones_smc:
|
2020-03-11 13:46:53 +00:00
|
|
|
sta $6d0+14 ; 14,21
|
|
|
|
|
2020-03-11 18:17:58 +00:00
|
|
|
lda GENERATOR_VOLTS_DISP
|
2020-03-11 13:46:53 +00:00
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
and #$f
|
|
|
|
clc
|
|
|
|
adc #$b0
|
2020-03-11 15:57:01 +00:00
|
|
|
gen_volt_tens_smc:
|
2020-03-11 13:46:53 +00:00
|
|
|
sta $6d0+13 ; 13,21
|
|
|
|
|
2020-03-11 15:57:01 +00:00
|
|
|
; draw gen needle
|
2020-03-11 18:17:58 +00:00
|
|
|
lda GENERATOR_VOLTS_DISP
|
2020-03-11 15:57:01 +00:00
|
|
|
ldx #0
|
|
|
|
cmp #$25
|
|
|
|
bcc gen_put_needle
|
|
|
|
inx
|
|
|
|
cmp #$50
|
|
|
|
bcc gen_put_needle
|
|
|
|
inx
|
|
|
|
cmp #$75
|
|
|
|
bcc gen_put_needle
|
|
|
|
inx
|
|
|
|
gen_put_needle:
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
ldy #0
|
|
|
|
gen_put_needle_loop:
|
|
|
|
|
|
|
|
lda needle_strings,X
|
|
|
|
gen_put_needle_smc:
|
|
|
|
sta $650+12,Y
|
|
|
|
iny
|
|
|
|
inx
|
|
|
|
cpy #4
|
|
|
|
bne gen_put_needle_loop
|
|
|
|
|
2020-03-11 13:46:53 +00:00
|
|
|
|
2020-03-11 18:17:58 +00:00
|
|
|
lda ROCKET_VOLTS_DISP
|
2020-03-11 15:57:01 +00:00
|
|
|
and #$f
|
|
|
|
clc
|
|
|
|
adc #$b0
|
|
|
|
rocket_volt_ones_smc:
|
|
|
|
sta $6d0+21 ; 21,21
|
|
|
|
|
2020-03-11 18:17:58 +00:00
|
|
|
lda ROCKET_VOLTS_DISP
|
2020-03-11 15:57:01 +00:00
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
lsr
|
|
|
|
and #$f
|
|
|
|
clc
|
|
|
|
adc #$b0
|
|
|
|
rocket_volt_tens_smc:
|
|
|
|
sta $6d0+20 ; 20,21
|
|
|
|
|
|
|
|
|
|
|
|
; draw rocket needle
|
2020-03-11 18:17:58 +00:00
|
|
|
lda ROCKET_VOLTS_DISP
|
2020-03-11 15:57:01 +00:00
|
|
|
ldx #0
|
|
|
|
cmp #$25
|
|
|
|
bcc rocket_put_needle
|
|
|
|
inx
|
|
|
|
cmp #$50
|
|
|
|
bcc rocket_put_needle
|
|
|
|
inx
|
|
|
|
cmp #$75
|
|
|
|
bcc rocket_put_needle
|
|
|
|
inx
|
|
|
|
rocket_put_needle:
|
|
|
|
txa
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
ldy #0
|
|
|
|
rocket_put_needle_loop:
|
|
|
|
|
|
|
|
lda needle_strings,X
|
|
|
|
rocket_put_needle_smc:
|
|
|
|
sta $650+19,Y
|
|
|
|
iny
|
|
|
|
inx
|
|
|
|
cpy #4
|
|
|
|
bne rocket_put_needle_loop
|
2020-03-11 13:46:53 +00:00
|
|
|
|
|
|
|
rts
|
|
|
|
|
2020-03-11 15:57:01 +00:00
|
|
|
;=========================
|
|
|
|
; draw the buttons
|
|
|
|
;=========================
|
2020-03-11 13:46:53 +00:00
|
|
|
|
|
|
|
generator_draw_buttons:
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
clc
|
|
|
|
lda DRAW_PAGE
|
|
|
|
adc #$4
|
|
|
|
sta top_button_draw_smc+2
|
|
|
|
adc #$1
|
|
|
|
sta bottom_button_draw_smc+2
|
|
|
|
lda #$d0+25
|
|
|
|
sta top_button_draw_smc+1
|
|
|
|
adc #$1
|
|
|
|
sta bottom_button_draw_smc+1
|
|
|
|
|
|
|
|
draw_buttons_loop:
|
|
|
|
|
|
|
|
; top button
|
|
|
|
|
|
|
|
lda SWITCH_TOP_ROW
|
|
|
|
and button_lookup,X
|
|
|
|
beq top_button_off
|
|
|
|
|
|
|
|
top_button_on:
|
|
|
|
ldy #$95
|
|
|
|
bne top_button_draw_smc
|
|
|
|
|
|
|
|
top_button_off:
|
|
|
|
ldy #$35
|
|
|
|
|
|
|
|
top_button_draw_smc:
|
|
|
|
sty $4d0+25
|
|
|
|
|
|
|
|
inc top_button_draw_smc+1
|
|
|
|
inc top_button_draw_smc+1
|
|
|
|
|
|
|
|
; bottom button
|
|
|
|
|
|
|
|
lda SWITCH_BOTTOM_ROW
|
|
|
|
and button_lookup,X
|
|
|
|
beq bottom_button_off
|
|
|
|
|
|
|
|
bottom_button_on:
|
2020-03-11 15:57:01 +00:00
|
|
|
ldy #$19
|
2020-03-11 13:46:53 +00:00
|
|
|
bne bottom_button_draw_smc
|
|
|
|
|
|
|
|
bottom_button_off:
|
|
|
|
ldy #$13
|
|
|
|
|
|
|
|
bottom_button_draw_smc:
|
|
|
|
sty $5d0+26
|
|
|
|
|
|
|
|
inc bottom_button_draw_smc+1
|
|
|
|
inc bottom_button_draw_smc+1
|
|
|
|
|
|
|
|
inx
|
|
|
|
cpx #5
|
|
|
|
bne draw_buttons_loop
|
|
|
|
|
|
|
|
rts
|
|
|
|
|