Prev: BFCD Up: Map Next: BFF4
BFDA: 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
00 04 The action key is used (AC96).
01 05 A program packet is sent (9E45).
02 07 A sector is activated (A440).
03 04 A program is destroyed (A3F4).
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 00, 01, 02 or 03. At the start of play A' is 50, 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 00 and 03 both ask for four tones, so they sound the same.
PlaySoundStep BFDA LD HL,$9688 Point at the tone counter.
BFDD LD A,(HL) Return if no sound effect is playing.
BFDE AND A
BFDF RET Z
BFE0 DEC (HL) Count it down.
BFE1 EX AF,AF' Keep the old counter in A'.
BFE2 INC HL Point at the effect number, which is not loaded.
BFE3 LD BC,$BFF4 Point at the table of pitch lists.
BFE6 CALL GetTableEntry Choose a pitch list with GetTableEntry, using A' as the index.
BFE9 EX AF,AF' Fetch the old counter.
BFEA LD C,A Use the old counter as the offset...
BFEB LD B,$00
BFED ADD HL,BC ...and add it to the address.
BFEE LD B,(HL) Fetch the pitch.
BFEF LD C,$0C The tone is made of 0C cycles.
BFF1 JP PlayWaveSequence Make the tone using PlayWaveSequence.
View the equivalent code in;
Prev: BFCD Up: Map Next: BFF4