Skip to navigation

Sound: ProcessSound

Name: ProcessSound [Show more] Type: Subroutine Category: Sound Summary: Process any sound effects that have been configured so they play in the background (this is called regularly throughout gameplay)
.ProcessSound LDA soundCounter \ If soundCounter is non-zero then a sound is already BNE psou1 \ being made, so jump to psou1 to return from the \ subroutine LDA soundEffect \ Set A to the type of sound effect we need to apply, \ which is specified in the soundEffect variable when \ the sound is made CMP #4 \ If A = 4 then this is the scanner sound, so jump to BEQ psou3 \ psou3 to process the scanner sound CMP #3 \ If A = 3 then this is music, so jump to ProcessMusic BEQ psou2 \ via psou2 to process the music being played CMP #6 \ If A <> 6 then there is no sound effect to apply, so BNE psou1 \ jump to psou1 to return from the subroutine \ If we get here then soundEffect = 6, so this is the \ game over sound LDX #7 \ Set X = 7 to pass to MakeSound-6 as the pitch of the \ first part of the game over sound LDY gameOverSoundPitch \ Set Y to the pitch for the second part of the game \ over sound, which starts in the ShowGameOverScreen \ routine at 250 and counts down towards 80 CPY #80 \ If Y < 80 then the game over sound has finished, so BCC psou1 \ jump to psou1 to return from the subroutine without \ making a sound LDA #6 \ Make sound #6 (game over) with the pitches in X and Y JSR MakeSound-6 JSR GetNextSeedNumber \ Set A to the next number from the landscape's sequence \ of seed numbers, which by this point in the game is \ effectively a random number AND #3 \ Convert the random number in A into a random number in CLC \ the range 1 to 4 ADC #1 STA soundCounter \ Set soundCounter to a random number between 1 and 4 to \ control the length of the noise we just made DEC gameOverSoundPitch \ Decrement the pitch of the game over sound so the \ overall effect is of a slowly decaying sound effect .psou1 RTS \ Return from the subroutine .psou2 \ If we get here then soundEffect = 3, so the sound \ effect is music JMP ProcessMusic \ Jump to ProcessMusic to play the music .psou3 \ If we get here then soundEffect = 4, so this is the \ scanner sound LDA #50 \ Set soundCounter = 50 to count down while the next STA soundCounter \ sound is made LDA #34 \ Set the third parameter of sound data block #2 to 34, STA soundData+20 \ to set the pitch LDA #3 \ Set the second parameter of sound data block #2 to 3, STA soundData+18 \ to set the amplitude LDA #4 \ Make sound #4 (scanner) JSR MakeSound RTS \ Return from the subroutine EQUB &B9 \ This byte appears to be unused