Prev: 47405 Up: Map Next: 47435
47412: Tick Wave Table
Actor handler for type 161. 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+0 The actor type, 161.
*IX+1 Counter. Starts at the number of notes plus one.
*IX+2 Address of the pitch table minus one (low byte).
*IX+3 Address of the pitch table minus one (high byte).
*IX+4 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 47412 DEC (IX+1) Decrease the counter in *IX+1 by one.
47415 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 1 picks the first byte.
Call Counter Address Pitch
1 7 47473 72
2 6 47472 80
3 5 47471 88
4 4 47470 96
5 3 47469 104
6 2 47468 112
7 1 47467 120
8 0 - The sound ends.
The example above is the template at Explosion_Template_2, which starts with a counter of 8 and a table address of 47466.
47417 LD C,(IX+1) Set BC to the counter, to use as the index.
47420 LD B,0
47422 LD L,(IX+2) Fetch the pitch table address from *IX+2 into HL.
47425 LD H,(IX+3)
47428 ADD HL,BC Add the index to find the pitch for this note.
47429 LD C,(HL) Fetch the pitch into C.
Play the note, repeated for the number of times held in the slot.
47430 LD D,(IX+4) Fetch the repeat count from *IX+4 into D.
47433 JR PlayWaveSequence Jump to PlayWaveSequence to play the note D times.
Prev: 47405 Up: Map Next: 47435