mirror of
https://github.com/a2-4am/million-perfect-letters.git
synced 2024-06-02 22:41:33 +00:00
143 lines
2.9 KiB
Plaintext
143 lines
2.9 KiB
Plaintext
;
|
|
; convenience functions for playing sounds through different libraries
|
|
;
|
|
; Public functions:
|
|
; - InitSound
|
|
; - ReinitSoundAfterPrefChange
|
|
; - LoopSound
|
|
; - PlaySound
|
|
; - ErrorSound
|
|
;
|
|
|
|
gMockingboardSlot
|
|
!byte 0
|
|
|
|
gSoundPref
|
|
!byte 1 ; 0 = no sound, 1 = sound
|
|
|
|
progressionIndex ; [byte][private]
|
|
!byte 0
|
|
|
|
kProgressionsByWorld ; chord progression to use on each world (index=world)
|
|
!word k251Progression
|
|
!word k251Progression
|
|
!word k251Progression
|
|
!word k251Progression
|
|
!word k6251Progression
|
|
!word k6251Progression
|
|
!word k6251Progression
|
|
!word k6251Progression
|
|
!word k16251Progression
|
|
!word k16251Progression
|
|
!word k16251Progression
|
|
!word k16251Progression
|
|
k251Progression
|
|
!byte 2
|
|
!word M_ii
|
|
!word M_V
|
|
k6251Progression
|
|
!byte 3
|
|
!word M_vi6
|
|
!word M_ii
|
|
!word M_V
|
|
k16251Progression
|
|
!byte 4
|
|
!word M_I
|
|
!word M_vi6
|
|
!word M_ii
|
|
!word M_V
|
|
kFinalChord
|
|
!word M_I_LONG
|
|
kErrorSound
|
|
!word M_ERROR
|
|
|
|
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
|
|
|
|
-
|
|
+LD16 $FE
|
|
LoopSound
|
|
sec
|
|
+HIDE_NEXT_BYTE
|
|
PlaySound
|
|
clc
|
|
php
|
|
+ST16 $1E
|
|
+ST16 $FE
|
|
SoundLibraryDispatch=*+1
|
|
jsr $FDFD ; SMC
|
|
plp
|
|
bcc +
|
|
lda KBD
|
|
bpl -
|
|
+ lda KBD
|
|
Silence rts
|
|
|
|
InitPuzzleSound
|
|
lda #$FF
|
|
sta progressionIndex
|
|
rts
|
|
|
|
PlayNextChord
|
|
; out: preserves X
|
|
txa
|
|
pha
|
|
lda gWorldID
|
|
asl
|
|
tax
|
|
lda kProgressionsByWorld, x
|
|
sta $FE
|
|
inx
|
|
lda kProgressionsByWorld, x
|
|
sta $FF
|
|
inc progressionIndex
|
|
ldy #0
|
|
lda ($FE), y
|
|
cmp progressionIndex
|
|
bne +
|
|
dec progressionIndex
|
|
+ lda progressionIndex
|
|
asl
|
|
tay
|
|
iny
|
|
lda ($FE), y
|
|
pha
|
|
iny
|
|
lda ($FE), y
|
|
tay
|
|
pla
|
|
jsr PlaySound
|
|
pla
|
|
tax
|
|
rts
|
|
|
|
PlayFinalChord
|
|
; out: preserves X
|
|
txa
|
|
pha
|
|
+LD16 kFinalChord
|
|
jsr PlaySound
|
|
pla
|
|
tax
|
|
rts
|
|
|
|
ErrorSound
|
|
+LD16 kErrorSound
|
|
jmp PlaySound
|