add sound toggle

This commit is contained in:
4am 2020-05-04 21:46:19 -04:00
parent 1753d00ab7
commit da2591e756
3 changed files with 59 additions and 23 deletions

View File

@ -3,21 +3,33 @@
;
; Public functions:
; - InitSound
; - ReinitSoundAfterPrefChange
; - LoopSound
; - PlaySound
; - SoftBell
;
gMockingboardSlot
!byte $00
!byte 0
gSoundPref
!byte 1 ; 0 = no sound, 1 = sound
ReinitSoundAfterPrefChange
ldx gMockingboardSlot
InitSound
stx gMockingboardSlot
lda gSoundPref
beq @theSoundOfSilence
cpx #0
beq @playThroughSpeaker
+LDADDR MockingDuet
bne + ; always branches
@playThroughSpeaker
+LDADDR ElectricDuet
bne + ; always branches
@theSoundOfSilence
+LDADDR Silence
+
+ST16 SoundLibraryDispatch
rts
@ -32,7 +44,6 @@ PlaySound
php
+ST16 $1E
+ST16 $FE
bit CLEARKBD
SoundLibraryDispatch=*+1
jsr $FDFD ; SMC
plp
@ -40,4 +51,24 @@ SoundLibraryDispatch=*+1
lda KBD
bpl -
+ lda KBD
rts
Silence rts
;------------------------------------------------------------------------------
; SoftBell
;
; in: none
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
SoftBell
lda gSoundPref
beq +
ldx #32
- lda #2
jsr ROM_WAIT
bit SPEAKER
lda #33
jsr ROM_WAIT
bit SPEAKER
dex
bne -
+ rts

View File

@ -120,24 +120,6 @@ LogicalColumnToPhysicalColumn
tay
rts
;------------------------------------------------------------------------------
; SoftBell
;
; in: none
; out: all registers and flags clobbered
;------------------------------------------------------------------------------
SoftBell
ldx #32
- lda #2
jsr ROM_WAIT
bit SPEAKER
lda #33
jsr ROM_WAIT
bit SPEAKER
dex
bne -
rts
nonZeroDigits = $EE
paddingCharacter = $EF
ToASCIIString

View File

@ -20,6 +20,7 @@ MainMenu
jsr @drawMenuTitle
+ jsr @drawMenuText
@menuloop
bit CLEARKBD
+LDADDR MainMenuMusic
jsr LoopSound
bit CLEARKBD
@ -28,6 +29,8 @@ MainMenu
beq @eventReturn
cmp #$01 ; Ctrl-A
beq @eventCtrlA
cmp #$13 ; Ctrl-S
beq @eventCtrlS
cmp #$1B ; Esc
bne @menuloop
;@eventEsc
@ -41,6 +44,13 @@ MainMenu
jsr AboutPage
sec
bcs MainMenu
@eventCtrlS
lda gSoundPref
eor #$01
sta gSoundPref
jsr ReinitSoundAfterPrefChange
clc
bcc MainMenu
@drawMenuTitle
jsr Home
lda #1
@ -64,6 +74,13 @@ MainMenu
+PRINT_AT version, 11, 26
+PRINT_AT menuline_play, 15, 10
+PRINT_AT menuline_sound, 16, 10
lda gSoundPref
beq @theSoundOfSilence
+LDADDR menuline_sound_on
bne + ; always branches
@theSoundOfSilence
+LDADDR menuline_sound_off
+ jsr DrawHeavySilkString
+PRINT_AT menuline_about, 17, 10
+PRINT_AT menuline_quit, 18, 10
+PRINT_AT disclaimer, 23, 0
@ -243,8 +260,14 @@ menuline_play
!byte 20
!raw "RETURN.....PLAY GAME"
menuline_sound
!byte 21
!raw "CTRL-S.....SOUND (ON) "
!byte 18
!raw "CTRL-S.....SOUND ("
menuline_sound_on
!byte 4
!raw "ON) "
menuline_sound_off
!byte 4
!raw "OFF)"
menuline_about
!byte 16
!raw "CTRL-A.....ABOUT"