Prev: 49101 Up: Map Next: 49140
49114: Play Sound Effect Step
Used by the routine at MainLoop.
Called once a frame. If a sound effect is playing, one tone of it is made and the counter is counted down. An effect is started by storing a length and an effect number at SoundEffect.
Effect Tones Started when
0 4 The action key is used (44182).
1 5 A program packet is sent (40517).
2 7 A sector is activated (42048).
3 4 A program is destroyed (41972).
The effect number is stored and never loaded. GetTableEntry takes its index from A', which is whatever the frame left there. The lists at SoundEffectTable are used only when A' is 0, 1, 2 or 3. At the start of play A' is 80, so the first tone is read from outside those lists. The samples are the four effects as they sound then, one tone a frame. Effects 0 and 3 both ask for four tones, so they sound the same.
PlaySoundStep 49114 LD HL,38536 Point at the tone counter.
49117 LD A,(HL) Return if no sound effect is playing.
49118 AND A
49119 RET Z
49120 DEC (HL) Count it down.
49121 EX AF,AF' Keep the old counter in A'.
49122 INC HL Point at the effect number, which is not loaded.
49123 LD BC,49140 Point at the table of pitch lists.
49126 CALL GetTableEntry Choose a pitch list with GetTableEntry, using A' as the index.
49129 EX AF,AF' Fetch the old counter.
49130 LD C,A Use the old counter as the offset...
49131 LD B,0
49133 ADD HL,BC ...and add it to the address.
49134 LD B,(HL) Fetch the pitch.
49135 LD C,12 The tone is made of 12 cycles.
49137 JP PlayWaveSequence Make the tone using PlayWaveSequence.
View the equivalent code in;
Prev: 49101 Up: Map Next: 49140