mist: cabin: can now ride tree to channelwood

This commit is contained in:
Vince Weaver 2020-07-16 01:56:26 -04:00
parent f827c36eba
commit 7563d411ad
10 changed files with 237 additions and 104 deletions

View File

@ -123,6 +123,8 @@ done_match_handler:
; handle special-case forground logic
;====================================
jsr update_boiler_state
jsr draw_marker_switch
lda LOCATION
@ -327,3 +329,4 @@ exit_to_mist:
; linking books
.include "link_book_channel.s"
.include "simple_sounds.s"

View File

@ -34,9 +34,121 @@
; button does nothing in basement
; dial in basement does same as one upstairs
; 0123456789012345678901234
; \ \ \ \ \ : / / / / /
; P S I
; \
; \
; BOILER_VALVE
; BOILER_LEVEL: high bit is if pilot lit, low bits are PSI
; BOILER_TOTAL:
; 0...128 warming up
; then if valve>12 inc level, when hit 15 inc tree
; if valve<12 dec level, when hit 0 dec tree
; rate of adding is (valve-12) 0..12 / 4 = 0..3
; 0 = FRAMEL&1f==0
; 1 = FRAMEL&f==0
; 2 = FRAMEL&7==0
; 3 = FRAMEL&3==0
; Make noise when change tree level
update_boiler_state:
; if pilot not lit, nothing to do
lda BOILER_LEVEL
bpl done_boiler_state
lda BOILER_VALVE
beq done_boiler_state
sec
sbc #12
bpl skip_abs
eor #$ff
clc
adc #$1
skip_abs:
; div by 4
lsr
lsr
lda FRAMEL
and #$1f
beq actually_adjust_boiler
rts
actually_adjust_boiler:
lda BOILER_VALVE
cmp #12
bcs valve_positive
bcc valve_negative
valve_positive:
jsr inc_boiler
jmp done_boiler_state
valve_negative:
jsr dec_boiler
done_boiler_state:
rts
inc_boiler:
lda BOILER_LEVEL
and #$7f
cmp #25
beq inc_boiler_overflow
inc BOILER_LEVEL
rts
inc_boiler_overflow:
lda TREE_LEVEL
cmp #6
beq tree_at_top
lda BOILER_LEVEL
and #$80
sta BOILER_LEVEL
inc TREE_LEVEL
jsr change_tree_level
tree_at_top:
rts
dec_boiler:
lda BOILER_LEVEL
and #$1f
cmp #0
beq dec_boiler_overflow
dec BOILER_LEVEL
rts
dec_boiler_overflow:
lda TREE_LEVEL
beq tree_at_bottom
lda #$80|24
sta BOILER_LEVEL
dec TREE_LEVEL
jsr change_tree_level
tree_at_bottom:
rts
change_tree_level:
jsr cabin_update_state
jsr change_direction
jsr beep
rts
tree_base_backgrounds:
@ -68,7 +180,7 @@ tree_elevator_backgrounds:
tree_basement_backgrounds:
.word tree_basement_n_lzsa ; 0 basement
.word tree_basement_n_lzsa ; 1 underground
.word tree_basement_noelev_n_lzsa ; 1 underground
.word tree_basement_noelev_n_lzsa ; 2 ground
.word tree_basement_noelev_n_lzsa ; 3 L6
.word tree_basement_noelev_n_lzsa ; 4 L8
@ -94,6 +206,8 @@ tree_entrance:
.byte CABIN_TREE_LOOK_UP ; 5 L10
.byte CABIN_TREE_LOOK_UP ; 6 TOP
; south if getting on elevator
; north if looking up
tree_entrance_dir:
.byte DIRECTION_N ; 0 basement
.byte DIRECTION_N ; 1 underground
@ -174,6 +288,17 @@ cabin_update_state:
rts
;==========================
; valve clicked in basement
valve_clicked_basement:
lda CURSOR_X
cmp #8
bcc valve_dec
bcs valve_inc
;==================================
; goto safe or valve (cabin boiler)
goto_safe_or_valve:
lda DIRECTION
@ -532,8 +657,42 @@ pilot_smc:
skip_pilot:
draw_psi:
bit TEXTGR ; bit of a hack
; adjust to correct page
lda DRAW_PAGE
clc
adc #$7
sta psi_smc+2
lda BOILER_LEVEL
and #$1f
tay
cpy #13
beq want_colon
bcc want_backslash
want_slash:
lda #'/'|$80
bne put_psi ; bra
want_backslash:
lda #'\'|$80
bne put_psi ; bra
want_colon:
lda #':'|$80
put_psi:
; 7,44 = $757
psi_smc:
sta $757,Y
lda #31
sta XPOS
lda #14
@ -580,11 +739,18 @@ press_elevator_button:
bcc button_ineffective
dec TREE_LEVEL ; drops you a floor
lda #$80
sta BOILER_LEVEL ; give some time before hitting again
jsr change_tree_level
button_ineffective:
rts
bump_up:
inc TREE_LEVEL ; if on ground floor it bumps you up
jsr change_tree_level
jmp button_ineffective

View File

@ -38,6 +38,7 @@ psc_smc2 =$19b7
; keyboard.s
handle_keypress =$1a38
change_direction =$1ae0
change_location =$1b19
; text_print.s

View File

@ -89,6 +89,7 @@ int main(int argc, char **argv) {
printf("; keyboard.s\n");
find_address("handle_keypress");
find_address("change_direction");
find_address("change_location");
printf("\n");

View File

@ -3,7 +3,14 @@
; initial state at start of game is for all vars to be 0
init_state:
.if 1
; global game state
lda #0
sta SOUND_DISABLED
sta JOYSTICK_ENABLED
; game state in saves init
lda #$0
ldy #WHICH_LOAD
init_state_loop:
@ -20,65 +27,3 @@ init_state_loop:
rts
.else
; book pages
sta RED_PAGES_TAKEN
sta BLUE_PAGES_TAKEN
sta HOLDING_PAGE
sta RED_PAGE_COUNT
sta BLUE_PAGE_COUNT
; init clock puzzles
sta CLOCK_MINUTE
sta CLOCK_HOUR
sta CLOCK_TOP
sta CLOCK_MIDDLE
sta CLOCK_BOTTOM
sta CLOCK_COUNT
sta CLOCK_LAST
; init gear
sta GEAR_OPEN
; init generator
sta BREAKER_TRIPPED
sta GENERATOR_VOLTS
sta ROCKET_VOLTS
sta GENERATOR_VOLTS_DISP
sta ROCKET_VOLTS_DISP
sta SWITCH_TOP_ROW
sta SWITCH_BOTTOM_ROW
sta ROCKET_HANDLE_STEP
; init rocket sliders
sta ROCKET_NOTE1
sta ROCKET_NOTE2
sta ROCKET_NOTE3
sta ROCKET_NOTE4
; meche elevator
sta MECHE_ELEVATOR
sta MECHE_ROTATION
sta MECHE_LOCK1
sta MECHE_LOCK2
sta MECHE_LOCK3
sta MECHE_LOCK4
sta VIEWER_CHANNEL
sta VIEWER_LATCHED
sta TOWER_ROTATION
sta SHIP_RAISED
sta PUMP_STATE
sta BATTERY_CHARGE
sta COMPASS_ANGLE
sta CRANK_ANGLE
sta CHANNEL_SWITCHES
lda #$ff ; for debugging
sta MARKER_SWITCHES
.endif
rts

View File

@ -172,7 +172,7 @@ location8:
.byte $ff ; east exit
.byte $ff ; west exit
.byte $ff ; north exit_dir
.byte DIRECTION_N ; south exit_dir
.byte DIRECTION_S ; south exit_dir
.byte $ff ; east exit_dir
.byte $ff ; west exit_dir
.word $0000 ; north bg
@ -201,7 +201,10 @@ location9:
.word $0000 ; east bg
.word $0000 ; west bg
.byte BG_SOUTH|BG_NORTH
.byte $ff
.byte DIRECTION_N ; special exit
.byte 3,10 ; special x
.byte 20,30 ; special y
.word valve_clicked_basement-1
; CABIN_TREE_BOOK -- tree basement book
location10:

View File

@ -361,5 +361,7 @@ flip_dock_switch:
.include "handle_pages.s"
.include "simple_sounds.s"
; level data
.include "leveldata_mist.inc"

View File

@ -282,43 +282,6 @@ move_the_ship:
rts
;===========================
; BEEP (inlined)
;===========================
beep:
ldy #235
sty tone_smc+1
; BEEP
; repeat 30 times
lda #30 ; 2
tone1_loop:
tone_smc:
ldy #24 ; 2
loopC: ldx #6 ; 2
loopD: dex ; 1
bne loopD ; 2
dey ; 1
bne loopC ; 2
bit SPEAKER ; 3 ; click speaker
sec ; 1
sbc #1 ; 2
bne tone1_loop ; 2
; Try X=6 Y=21 cycles=757
; Try X=6 Y=24 cycles=865
; Try X=7 Y=235 cycles=9636
rts
powersoftwo:
.byte $01,$02,$04,$08,$10,$20,$40,$80

47
mist/simple_sounds.s Normal file
View File

@ -0,0 +1,47 @@
click_speaker:
lda SOUND_DISABLED
bne done_click
bit $c030
done_click:
rts
;===========================
; BEEP (inlined)
;===========================
beep:
lda SOUND_DISABLED
bne done_beep
ldy #235
sty tone_smc+1
; BEEP
; repeat 30 times
lda #30 ; 2
tone1_loop:
tone_smc:
ldy #24 ; 2
loopC: ldx #6 ; 2
loopD: dex ; 1
bne loopD ; 2
dey ; 1
bne loopC ; 2
bit SPEAKER ; 3 ; click speaker
sec ; 1
sbc #1 ; 2
bne tone1_loop ; 2
; Try X=6 Y=21 cycles=757
; Try X=6 Y=24 cycles=865
; Try X=7 Y=235 cycles=9636
done_beep:
rts

View File

@ -217,6 +217,8 @@ END_OF_SAVE = $C9
; done game puzzle state
JOYSTICK_ENABLED= $DD
SOUND_DISABLED = $DE
GRID_PAGE = $DF
ANIMATE_FRAME = $E0
LEVEL_OVER = $E1