The Sound Manager


&BCA7SOUND RESET
ActionResets the sound manager by clearing the sound queues and abandoning any current sounds
EntryNo entry conditions
ExitAF, BC, DE and HL are corrupt, and all others are preserved
&BCAASOUND QUEUE
ActionAdds a sound to the sound queue of a channel
EntryHL contains the address of a series of bytes which define the sound and are stored in the central 32K of RAM
ExitIf the sound was successfully added to the queue, then Carry is true and HL is corrupt; if one of the sound queues was full, then Carry is false and HL is preserved; in either case, A, BC, DE, IX and the other flags are corrupt, and all others are preserved
NotesThe bytes required to define the sound are as follows
byte 0 - channel status byte
byte 1 - volume envelope to use
byte 2 - tone envelope to use
bytes 3&4 - tone period
byte 5 - noise period
byte 6 - start volume
bytes 7&8 - duration of the sound, or envelope repeat count
&BCADSOUND CHECK
ActionGets the status of a sound channel
EntryA contains the channel to test - for channel A, bit 0 set; for channel B, bit 1 set; for channel C, bit 2 set
ExitA contains the channel status, BC, DE, HL and flags are corrupt, and all others are preserved
NotesThe channel status returned is bit significant, as follows
bits 0 to 2 - the number of free spaces in the sound queue
bit 3 - trying to rendezvous with channel A
bit 4 - trying to rendezvous with channel B
bit 5 - trying to rendezvous with channel C
bit 6 - holding the channel
bit 7 - producing a sound
&BCB0SOUND ARM EVENT
ActionSets up an event which will be activated when a space occurs in a sound queue
EntryA contains the channel to set the event up for (see SOUND CHECK for the bit values this can take), and HL holds the address of the event block
ExitAF, BC, DE and HL are corrupt, and all other registers are preserved
NotesThe event block must be initialised by KL INIT EVENT and is disarmed when the event itself is run
&BCB3SOUND RELEASE
ActionAllows the playing of sounds on specific channels that had been stopped by SOUND HOLD
EntryA contains the sound channels to be released (see SOUND CHECK for the bit values this can take)
ExitAF, BC, DE, HL and IX are corrupt, and all others are preserved
&BCB6SOUND HOLD
ActionImmediately stops all sound output (on all channels)
EntryNo entry conditions
ExitIf a sound was being made, then Carry is true; if no sound was being made, then Carry is false; in all cases, A, BC, HL and other flags are corrupt, and all others are preserved
NotesWhen the sounds are restarted, they will begin from exactly the same place that they were stopped
&BCB9SOUND CONTINUE
ActionRestarts all sound output (on all channels)
EntryNo entry conditions
ExitAF, BC, DE and IX are corrupt, and all others are preserved
&BCBCSOUND AMPL ENVELOPE
ActionSets up avolume envelope
EntryA holds an envelope number (from 1 to 15), HL holds the address of a block of data for the envelope
ExitIf it was set up properly, Carry is true, HL holds the data block address + 16, A and BC are corrupt; if the envelope number is invalid, then Carry is false, and A, B and HL are preserved; in either case, DE and the other flags are corrupt, and all other registers are preserved
NotesAll the rules of enevelopes in BASIC also apply; the block of the data for the envelope is set up as follows
byte 0 - number of sections in the envelope
bytes 1 to 3 - first section of the envelope
bytes 4 to 6 - second section of the envelope
bytes 7 to 9 - third section of the envelope
bytes 10 to 12 - fourth section of the envelope
bytes 13 to 15 - fifth section of the envelope
Each section of the envelope has three bytes set out as follows
byte 0 - step count (with bit 7 set)
byte 1 - step size
byte 2 - pause time or if it is a hardware envelope, then each section takes the following form
byte 0 - envelope shape (with bit 7 not set)
bytes 1 and 2 - envelope period
See also SOUND TONE ENVELOPE below
&BCBFSOUND TONE ENVELOPE
ActionSets up a tone envelope
EntryA holds an envelope number (from 1 to 15), HL holds the address of a block of data for the envelope
ExitIf it was set up properly, Carry is true, HL holds the data block address + 16, A and BC are corrupt; ¡ if the envelope number is invalid, then Carry is false, and A, B and HL are preserved; in either case, DE and the other flags are corrupt, and all other registers are preserved
NotesAll the rules of envelopes in BASIC also apply; the block of the data for the envelope is set up as follows
byte 0 - number of sections in the envelope
bytes 1 to 3 - first section of the envelope
bytes 4 to 6 - second section of the envelope
bytes 7 to 9 - third section of the envelope
bytes 10 to 12 - fourth section of the envelope
bytes 13 to 15 - fifth section of the envelope
Each section of the envelope has three bytes set out as follows
byte 0 - step count
byte 1 - step size
byte 2 - pause time
See also SOUND AMPL ENVELOPE above
&BCC2SOUND A ADDRESS
ActionGets the address of the data block associated with a volume envelope
EntryA contains an envelope number (from 1 to 15)
ExitIf it was found, then Carry is true, HL holds the data block's address, and BC holds its length; if the envelope number is invalid, then Carry is false, HL is corrupt and BC is preserved; in both cases, A and the other flags are corrupt, and all others are preserved
&BCC5SOUND T ADDRESS
ActionGets the address of the data block associated with a tone envelope
EntryA contains an envelope number (from 1 to 15)
ExitIf it was found, then Carry is true, HL holds the data block's address, and BC holds its length; if the envelope number is invalid, then Carry is false, HL is corrupt and BC is preserved; in both cases, A and the other flags are corrupt, and all others are preserved


David Cantrell, March 1996