.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 unusedName: 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)Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DecayScreenToBlack calls ProcessSound * DitherScreenBuffer calls ProcessSound * DrawLandscapeView (Part 2 of 3) calls ProcessSound * DrawTileAndObjects calls ProcessSound * GetRowVisibility (Part 1 of 2) calls ProcessSound * MainGameLoop calls ProcessSound * ProcessGameplay calls ProcessSound
[X]
Subroutine GetNextSeedNumber (category: Maths (Arithmetic))
Set A to a seed number
[X]
Subroutine MakeSound (category: Sound)
Make a sound
[X]
Entry point MakeSound-6 in subroutine MakeSound (category: Sound)
Make a two-part sound at the pitches defined in X and Y, where X is the pitch for sound data block #0 and Y is the pitch for sound data block #1
[X]
Subroutine ProcessMusic (category: Sound)
Play the configured music in the background
[X]
Variable gameOverSoundPitch in workspace Main variable workspace
A timer for the game over sound
[X]
Label psou1 is local to this routine
[X]
Label psou2 is local to this routine
[X]
Label psou3 is local to this routine
[X]
Variable soundCounter in workspace Main variable workspace
A counter for the sound currently being made, which counts down in the IRQHandler routine at a rate of 50 times a second
[X]
Variable soundData (category: Sound)
OSWORD blocks for making the various game sounds
[X]
Variable soundEffect in workspace Main variable workspace
Determines how the current sound is processed by the ProcessSound routine