Prev: B92D Up: Map Next: B94B
B934: Tick Wave Table
Actor handler for type A1. Plays one note of a sound whose pitches are held in a table, so the sound moves on by one note each time the main loop reaches the slot.
The slot is filled by InitialiseExplosion_Copy from a template such as Explosion_Template_2, and holds:
Byte Holds
*IX+00 The actor type, A1.
*IX+01 Counter. Starts at the number of notes plus one.
*IX+02 Address of the pitch table minus one (low byte).
*IX+03 Address of the pitch table minus one (high byte).
*IX+04 Repeat count, i.e. how many times each note is played.
The counter is also the index into the pitch table, and it counts down, so the table is played backwards: the last pitch is the first one heard. The pitch is the half-wave delay used by PlaySquareWave, so the larger the value the lower the note. When the counter reaches zero the sound ends and the slot is freed by EndSound.
Input
IX Explosion slot (Explosion_Slot)
Count down, and end the sound when the table has been played.
TickWaveTable B934 DEC (IX+$01) Decrease the counter in *IX+01 by one.
B937 JR Z,EndSound Jump to EndSound if the counter is now zero.
Use the counter as an index into the pitch table to find this note. The table address is stored minus one, so that an index of 01 picks the first byte.
Call Counter Address Pitch
01 07 B971 48
02 06 B970 50
03 05 B96F 58
04 04 B96E 60
05 03 B96D 68
06 02 B96C 70
07 01 B96B 78
08 00 - The sound ends.
The example above is the template at Explosion_Template_2, which starts with a counter of 08 and a table address of B96A.
B939 LD C,(IX+$01) Set BC to the counter, to use as the index.
B93C LD B,$00
B93E LD L,(IX+$02) Fetch the pitch table address from *IX+02 into HL.
B941 LD H,(IX+$03)
B944 ADD HL,BC Add the index to find the pitch for this note.
B945 LD C,(HL) Fetch the pitch into C.
Play the note, repeated for the number of times held in the slot.
B946 LD D,(IX+$04) Fetch the repeat count from *IX+04 into D.
B949 JR PlayWaveSequence Jump to PlayWaveSequence to play the note D times.
Prev: B92D Up: Map Next: B94B