◆ ASound()
Constructor
- Parameters
-
| mixer | Mixer |
| filename | Specifies the adlib sound player file to use |
| dataOffset | Offset in the file of the data segment |
◆ ~ASound()
| MADS::Phantom::ASound::~ASound |
( |
| ) |
|
|
inlineoverride |
◆ write()
| void MADS::Phantom::ASound::write |
( |
uint8 |
reg, |
|
|
uint8 |
value |
|
) |
| |
|
protected |
write(register, value)
Updates the local port-shadow array so that subsequent reads from _adlibPorts[reg] return the last-written value, then sends the byte pair to the real hardware (or whatever back-end is wired in).
◆ getRandomNumber()
| uint16 MADS::Phantom::ASound::getRandomNumber |
( |
| ) |
|
|
protected |
Updates and returns _asound_randomSeed.
◆ adlib_channelOn()
| void MADS::Phantom::ASound::adlib_channelOn |
( |
uint8 |
portIndex, |
|
|
uint8 |
vol |
|
) |
| |
|
protected |
Restores one output operator: clears the forced-max bits (0x3F) and writes the caller-supplied volume nibble (bh in the asm). 'portIndex' is the operator register index; 'vol' is the volume nibble.
◆ signalSoundPlaying()
| void MADS::Phantom::ASound::signalSoundPlaying |
( |
| ) |
|
|
protected |
Sets the poll-result flags to indicate that sound is playing.
◆ pollAllChannels()
| void MADS::Phantom::ASound::pollAllChannels |
( |
| ) |
|
|
protected |
◆ pollActiveChannel()
| void MADS::Phantom::ASound::pollActiveChannel |
( |
| ) |
|
|
protected |
Per-channel update, called once per frame by pollAllChannels. Implements a bytecode interpreter : the sound data stream is a sequence of (note, duration) pairs plus command bytes(0x80-0xFF). Commands with high bit clear are notes; high bit set triggers the switch below.
The interpreter loop re-enters the top of the dispatch after each command that does not consume a duration tick. Note bytes consume one tick per call (activeCount counts down).
◆ isSoundActive()
| bool MADS::Phantom::ASound::isSoundActive |
( |
byte * |
ptr | ) |
const |
|
protected |
Returns true if a given sound data is already active.
◆ findFreeChannel()
| void MADS::Phantom::ASound::findFreeChannel |
( |
byte * |
soundData | ) |
|
|
protected |
Channel finder helpers Scan channels in priority order and call AdlibChannel_load on the first inactive (or pending-stop) one found.
Searches channels 0-5 for an empty slot, falling through to asound_findFreeChannelFull (channels 6-8) if none found. _findChannelMode == 1 means "only search 0-5".
◆ findFreeChannelFull()
| void MADS::Phantom::ASound::findFreeChannelFull |
( |
byte * |
soundData | ) |
|
|
protected |
Extends the search to channels 6-8 and then checks for pending-stop channels (which can be pre-empted), in reverse priority order.
◆ loadData()
| byte* MADS::Phantom::ASound::loadData |
( |
int |
offset | ) |
|
|
inlineprotected |
Returns data for the specified offset.
◆ playSound()
| void MADS::Phantom::ASound::playSound |
( |
int |
offset | ) |
|
|
protected |
Plays the sound data at a given offset
◆ command0()
| int MADS::Phantom::ASound::command0 |
( |
| ) |
|
|
protected |
Silences every voice and mutes the hardware:
- Reset all 9 channels.
- Mute all operator total-level registers (0x40-0x55) to max attenuation.
- Zero remaining operator registers (0x60-0xFF and 0x01-0x3F).
- Write Waveform Select Enable (register 0x01 = 0x20).
- Reset the tick callback.
◆ command2()
| int MADS::Phantom::ASound::command2 |
( |
| ) |
|
|
protected |
Fade out music channels 0-5.
◆ command3()
| int MADS::Phantom::ASound::command3 |
( |
| ) |
|
|
protected |
◆ command4()
| int MADS::Phantom::ASound::command4 |
( |
| ) |
|
|
protected |
Fade out SFX channels 6-8.
◆ command6()
| int MADS::Phantom::ASound::command6 |
( |
| ) |
|
|
protected |
Saves each channel's current freqSweepCounter into savedFreqSweep, zeroes freqSweepCounter on all channels, then mutes the output operators for voices 3-5 (the secondary operator set at 0x43-0x55).
◆ command7()
| int MADS::Phantom::ASound::command7 |
( |
| ) |
|
|
protected |
Resume playback after a pause. Restores operator volumes for channels 0-5, re-saves sweep counters from the live values (which were frozen to 0 by command6), then re-enables the audio engine.
The OPL2 voice-to-operator mapping used here: voice 0 -> operator index 67 (0x43) voice 1 -> operator index 68 (0x44) voice 2 -> operator index 69 (0x45) voice 3 -> operator index 75 (0x4B) voice 4 -> operator index 76 (0x4C) voice 5 -> operator index 77 (0x4D)
◆ command8()
| int MADS::Phantom::ASound::command8 |
( |
| ) |
|
|
protected |
Returns non-zero if any of the 9 Adlib channels has a non-zero _activeCount (i.e. sound is currently playing).
◆ callFunction()
| virtual void MADS::Phantom::ASound::callFunction |
( |
uint16 |
offset | ) |
|
|
protectedvirtual |
Calls a function at a fixed offset within the sound driver.
- Parameters
-
| offset | Offset of the function |
◆ validate()
| static void MADS::Phantom::ASound::validate |
( |
bool |
isDemo | ) |
|
|
static |
Validates the presence of the sound driver files.
◆ stop()
| virtual int MADS::Phantom::ASound::stop |
( |
| ) |
|
|
overridevirtual |
◆ poll()
| int MADS::Phantom::ASound::poll |
( |
| ) |
|
|
overridevirtual |
◆ noise()
| void MADS::Phantom::ASound::noise |
( |
| ) |
|
|
overridevirtual |
Noise channel : each tick picks a random frequency offset masked by noiseFreqMask, adds freqAccum, and writes the result.
Implements MADS::SoundDriver.
◆ setVolume()
| void MADS::Phantom::ASound::setVolume |
( |
int |
volume | ) |
|
|
inlineoverridevirtual |
◆ _channels
Initial value:= {
&_channel0, &_channel1, &_channel2, &_channel3, &_channel4,
&_channel5, &_channel6, &_channel7, &_channel8
}
The documentation for this class was generated from the following file: