![]() |
Routines |
| Prev: 6106 | Up: Map | Next: 614B |
|
Used by the routine at HandlerPlayer.
Plays the next step of the sound made when a cup is collected or the car is refuelled. This is called every frame but only makes a sound on every other frame. The step counter is held at SoundCounter. For the refuel sound it counts down from 07 and bit 7 is clear; each step has a higher pitch than the one before. For the cup sound it starts at 87 (bit 7 set) and each step has a lower pitch than the one before. Each step plays 20 square waves using PlaySquareWave, and there are six of them. The cup sound: The refuel sound:
|
||||
| SoundsCupRefuel | 611B | LD A,($5E29) | Fetch the game timer from GameTimer. | |
| 611E | AND %00000001 | Keep only bit 0. | ||
| 6120 | RET NZ | Return on every other frame. | ||
| 6121 | LD HL,$5E46 | Point HL at the step counter (SoundCounter). | ||
| 6124 | LD A,(HL) | Fetch the step counter. | ||
| 6125 | BIT 7,A | Jump to SoundsCup if bit 7 is set, as that is the cup sound. | ||
| 6127 | JR NZ,SoundsCup | |||
| 6129 | AND A | Return if the step counter is zero, as there is no sound to play. | ||
| 612A | RET Z | |||
| 612B | DEC A | Decrease the step counter by one. | ||
| 612C | LD (HL),A | Write the new step counter back to SoundCounter. | ||
| 612D | RET Z | Return if the step counter has reached zero, as the sound is over. | ||
|
Work out the period of the waves from the step counter.
|
||||
| SoundsRefuel | 612E | RLCA | Multiply the step counter by 04 by rotating it left twice. | |
| 612F | RLCA | |||
| 6130 | AND %00011100 | Keep only bits 2-4. | ||
| 6132 | OR %00100000 | Set bit 5. | ||
| 6134 | LD D,A | Set the period of the waves. | ||
| 6135 | LD C,$20 | Set the wave counter to 20. | ||
| SoundsCupRefuel_Loop | 6137 | CALL PlaySquareWave | Play a square wave using PlaySquareWave. | |
| 613A | DEC C | Decrease the wave counter by one and loop back to SoundsCupRefuel_Loop until all 20 waves have been played. | ||
| 613B | JR NZ,SoundsCupRefuel_Loop | |||
| 613D | RET | Return. | ||
|
The cup sound keeps bit 7 set in the step counter, and inverts the step so that the pitch falls rather than rises.
|
||||
| SoundsCup | 613E | AND %01111111 | Keep only the step counter (bits 0-6). | |
| 6140 | RET Z | Return if the step counter is zero, as the sound is over. | ||
| 6141 | DEC A | Decrease the step counter by one. | ||
| 6142 | OR %10000000 | Set bit 7 so that the sound stays the cup sound. | ||
| 6144 | LD (HL),A | Write the new step counter back to SoundCounter. | ||
| 6145 | AND %01111111 | Keep only the step counter (bits 0-6). | ||
| 6147 | RET Z | Return if the step counter has reached zero. | ||
| 6148 | CPL | Flip the bits, so that the pitch falls with each step. | ||
| 6149 | JR SoundsRefuel | Jump to SoundsRefuel. | ||
| Prev: 6106 | Up: Map | Next: 614B |