mist: you can play the organ now

This commit is contained in:
Vince Weaver 2020-03-14 11:57:09 -04:00
parent 7059d6e683
commit 8dbb04d591
7 changed files with 547 additions and 10 deletions

View File

@ -88,6 +88,8 @@ selena.o: selena.s zp.inc hardware.inc \
link_book_selena.s \
keyboard.s \
draw_pointer.s \
speaker_beeps.s \
organ_puzzle.s \
gr_copy.s audio.s text_print.s decompress_fast_v2.s
ca65 -o selena.o selena.s -l selena.lst

View File

@ -77,8 +77,8 @@ MIST island:
MECHE age:
+ Everything in age
SPACESHIP age:
+ Keyboard/music
SELENA age:
+ optional mockingboard sound for keyboard?
+ Linking book
+ Complicated age with sounds
+ That whole rediculous underground cart sequence

View File

@ -19,7 +19,10 @@ draw_pointer:
lda (LOCATION_STRUCT_L),Y
cmp #$ff
beq finger_not_special ; if $ff not special
cmp DIRECTION
lda DIRECTION
and #$f
cmp (LOCATION_STRUCT_L),Y
bne finger_not_special ; only special if facing right way
; see if X1 < X < X2

View File

@ -45,7 +45,8 @@ location0:
.byte $ff ; north exit_dir
.byte $ff ; south exit_dir
.byte DIRECTION_E ; east exit_dir
.byte DIRECTION_W ; west exit_dir
; .byte DIRECTION_W
.byte (DIRECTION_W|DIRECTION_ONLY_POINT) ; west exit_dir
.word spaceship_inside_mist_n_lzsa ; north bg
.word $0000 ; south bg
.word spaceship_inside_e_lzsa ; east bg
@ -86,11 +87,10 @@ location2:
.word $0000 ; east bg
.word organ_w_lzsa ; west bg
.byte BG_WEST
.byte $ff
;DIRECTION_E ; special exit
; .byte 21,31 ; special x
; .byte 10,24 ; special y
; .word meche_link_book-1 ; special function
.byte DIRECTION_W ; special exit
.byte 7,31 ; special x
.byte 24,34 ; special y
.word organ_pressed-1 ; special function

463
mist/organ_puzzle.s Normal file
View File

@ -0,0 +1,463 @@
organ_pressed:
ldy #0
lda YPOS
cmp #27
bcs organ_regular ; bge
organ_sharps:
; urgh nonsymmetric, this is way cheating
; FIXME: if actually on a white key, then jump and check regular?
lda XPOS
cmp #11-1
bcc done_organ_sharps
iny
cmp #13-1
bcc done_organ_sharps
iny
cmp #18-1
bcc done_organ_sharps
iny
cmp #20-1
bcc done_organ_sharps
iny
cmp #22-1
bcc done_organ_sharps
iny
cmp #27-1
bcc done_organ_sharps
iny
done_organ_sharps:
lda sharp_notes,Y
jmp done_organ_freq
organ_regular:
; urgh nonsymmetric, this is way cheating
lda XPOS
cmp #10-1
bcc done_organ_regular
iny
cmp #12-1
bcc done_organ_regular
iny
cmp #14-1
bcc done_organ_regular
iny
cmp #17-1
bcc done_organ_regular
iny
cmp #20-1
bcc done_organ_regular
iny
cmp #22-1
bcc done_organ_regular
iny
cmp #24-1
bcc done_organ_regular
iny
cmp #27-1
bcc done_organ_regular
iny
cmp #30-1
bcc done_organ_regular
iny
done_organ_regular:
lda regular_notes,Y
done_organ_freq:
sta speaker_frequency
organ_tone:
lda #25
sta speaker_duration
jsr speaker_tone
rts
regular_notes:
.byte NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4
.byte NOTE_C5,NOTE_D5,NOTE_E5
sharp_notes:
.byte NOTE_CSHARP4,NOTE_DSHARP4,NOTE_FSHARP4,NOTE_GSHARP4,NOTE_ASHARP4
.byte NOTE_CSHARP5,NOTE_DSHARP5
.if 0
open_gen_door:
ldy #LOCATION_NORTH_EXIT
lda #36
sta location35,Y
ldy #LOCATION_NORTH_EXIT_DIR
lda #(DIRECTION_N | DIRECTION_SPLIT | DIRECTION_ONLY_POINT)
sta location35,Y
ldy #LOCATION_NORTH_BG
lda #<gen_door_open_n_lzsa
sta location35,Y
lda #>gen_door_open_n_lzsa
sta location35+1,Y
jsr change_location
rts
button_lookup:
.byte $10,$8,$4,$2,$1
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
;============================
generator_button_press:
lda YPOS
cmp #38
bcs button_bottom_row ; bge
button_top_row:
lda XPOS
sec
sbc #24
lsr
bmi done_press
cmp #5
bcs done_press ; bge
tax
lda SWITCH_TOP_ROW
eor button_lookup,X ; toggle switch
sta SWITCH_TOP_ROW
jmp done_press
button_bottom_row:
lda XPOS
sec
sbc #25
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
cmp #$59
bcs oops_flipped
sta ROCKET_VOLTS
jmp done_rocket_volts
oops_flipped:
lda #$3
sta BREAKER_TRIPPED
done_rocket_volts:
rts
;===========================
; draw the voltage displays
;===========================
generator_update_volts:
; 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
lda DRAW_PAGE
clc
adc #$6
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
lda GENERATOR_VOLTS_DISP
and #$f
clc
adc #$b0
gen_volt_ones_smc:
sta $6d0+14 ; 14,21
lda GENERATOR_VOLTS_DISP
lsr
lsr
lsr
lsr
and #$f
clc
adc #$b0
gen_volt_tens_smc:
sta $6d0+13 ; 13,21
; draw gen needle
lda GENERATOR_VOLTS_DISP
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
lda ROCKET_VOLTS_DISP
and #$f
clc
adc #$b0
rocket_volt_ones_smc:
sta $6d0+21 ; 21,21
lda ROCKET_VOLTS_DISP
lsr
lsr
lsr
lsr
and #$f
clc
adc #$b0
rocket_volt_tens_smc:
sta $6d0+20 ; 20,21
; draw rocket needle
lda ROCKET_VOLTS_DISP
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
rts
;=========================
; draw the buttons
;=========================
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:
ldy #$19
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
.endif

View File

@ -163,6 +163,8 @@ room_frame_no_oflo:
; puzzles
.include "organ_puzzle.s"
; linking books
@ -172,7 +174,7 @@ room_frame_no_oflo:
.include "leveldata_selena.inc"
.include "speaker_beeps.s"

67
mist/speaker_beeps.s Normal file
View File

@ -0,0 +1,67 @@
; based on code from here
; http://eightbitsoundandfury.ld8.org/programming.html
; A,X,Y trashed
; duration also trashed
NOTE_C3 = 255
NOTE_CSHARP3 = 241
NOTE_D3 = 227
NOTE_DSHARP3 = 214
NOTE_E3 = 202
NOTE_F3 = 191
NOTE_FSHARP3 = 180
NOTE_G3 = 170
NOTE_GSHARP3 = 161
NOTE_A3 = 152
NOTE_ASHARP3 = 143
NOTE_B3 = 135
NOTE_C4 = 128
NOTE_CSHARP4 = 121
NOTE_D4 = 114
NOTE_DSHARP4 = 108
NOTE_E4 = 102
NOTE_F4 = 96
NOTE_FSHARP4 = 91
NOTE_G4 = 85
NOTE_GSHARP4 = 81
NOTE_A4 = 76
NOTE_ASHARP4 = 72
NOTE_B4 = 68
NOTE_C5 = 64
NOTE_CSHARP5 = 60
NOTE_D5 = 57
NOTE_DSHARP5 = 54
NOTE_E5 = 51
NOTE_F5 = 48
NOTE_FSHARP5 = 45
NOTE_G5 = 43
NOTE_GSHARP5 = 40
NOTE_A5 = 38
NOTE_ASHARP5 = 36
NOTE_B5 = 34
speaker_tone:
lda $C030 ; click speaker
speaker_loop:
dey ; y never set?
bne slabel1 ; duration roughly 256*?
dec speaker_duration ; (Duration)
beq done_tone
slabel1:
dex
bne speaker_loop
ldx speaker_frequency ; (Frequency)
jmp speaker_tone
done_tone:
rts
speaker_duration:
.byte $00
speaker_frequency:
.byte $00