22 #ifndef MADS_PHANTOM_SOUND_ASOUND_H 23 #define MADS_PHANTOM_SOUND_ASOUND_H 25 #include "audio/fmopl.h" 26 #include "common/mutex.h" 27 #include "common/queue.h" 28 #include "common/util.h" 29 #include "mads/core/native_sound_timer.h" 30 #include "mads/core/sound_manager.h" 36 #define ADLIB_CHANNEL_COUNT 9 39 static bool _isDisabled;
40 uint8 _activeCount = 0;
42 uint8 _volumeFadeStep = 0;
43 uint8 _vibratoDepth = 0;
45 uint8 _sampleIndex = 0;
47 uint8 _noteOffset = 0;
48 uint8 _keyOnDelay = 0;
49 uint8 _fadePeriodCounter = 0;
50 uint8 _fadePeriodReload = 0;
51 uint8 _vibPeriodCounter = 0;
52 uint8 _vibPeriodReload = 0;
53 uint8 _patchAttenuation = 0;
54 byte *_loopStartPtr =
nullptr;
55 byte *_pSrc =
nullptr;
56 byte *_innerLoopPtr =
nullptr;
57 byte *_outerLoopPtr =
nullptr;
58 byte *_soundData =
nullptr;
59 byte *_branchTargetPtr =
nullptr;
60 uint16 _innerLoopCount = 0;
61 uint16 _outerLoopCount = 0;
62 uint16 _noiseFreqMask = 0;
63 uint16 _freqAccum = 0;
65 uint8 _freqSweepCounter = 0;
66 uint8 _savedFreqSweep = 0;
69 uint8 _opVolBytes = 0;
70 uint8 _opVolBytes2 = 0;
71 uint8 _octaveTranspose = 0;
72 uint8 _pendingStop = 0;
73 uint8 _durationOverride = 0;
85 void load(byte *soundData);
108 uint8 _attackRate = 0;
109 uint8 _decayRate = 0;
110 uint8 _sustainLevel = 0;
111 uint8 _releaseRate = 0;
114 uint8 _totalLevel = 0;
115 uint8 _scalingLevel = 0;
116 uint8 _waveformSelect = 0;
117 uint8 _freqMultiple = 0;
122 uint8 _freqSweepInit = 0;
124 uint16 _freqMask = 0;
125 uint16 _freqBase = 0;
126 uint16 _outerLoopPtr = 0;
137 bool _noiseEnabled =
false;
138 uint16 _callbackCounter = 0;
139 uint16 _callbackPeriod = 0;
141 uint8 _activeChannelNumber = 0;
142 uint16 _activeChannelReg = 0;
143 uint16 _currentOpBase = 0;
145 byte *pSrc =
nullptr;
146 int16 _pollResult = 0;
147 int16 _resultFlag = 0;
148 uint16 _randomSeed = 0x4D2;
149 uint8 _isDisabled = 0;
150 int _masterVolume = 255;
151 uint8 _findChannelMode = 0;
152 uint8 _ch5SweepLive = 0;
153 uint8 _ch5SweepSaved = 0;
154 uint8 _ch5PendingStop = 0;
155 uint8 _anySweepActive = 0;
156 int _frameNumber2 = 0;
157 uint8 _scriptVars[32];
158 uint16 _tickEnabled = 1;
159 uint16 _tickCounter = 0;
160 uint16 _tempoReload = 0;
161 uint16 _tempoTarget = 0;
162 uint16 _tempoShift = 0;
163 uint16 _tempoBase = 0xA0;
164 uint16 _tempoCurrent = 0x28;
165 uint16 _tempoScale = 0x0A;
175 void clearCallback();
176 void resetCallback() {
185 void adlib_channelOff(uint8 portIndex);
197 void refreshVolumes();
203 void writeFrequency();
209 void writePitchBend();
228 void writeSampleRegs();
247 void update1(
int channelIndex);
252 void setFrequency(uint8 voice, uint16 freq);
258 void noise_inner(
int channelIndex);
263 void updateAllChannels();
268 uint16 readWord_impl();
275 &_channel0, &_channel1, &_channel2, &_channel3, &_channel4,
276 &_channel5, &_channel6, &_channel7, &_channel8
279 uint8 _adlibPorts[0x100] = { 0 };
290 void write(uint8 reg, uint8 value);
295 uint16 getRandomNumber();
302 void adlib_channelOn(uint8 portIndex, uint8 vol);
307 void signalSoundPlaying();
312 void pollAllChannels();
336 void pollActiveChannel();
341 bool isSoundActive(byte *ptr)
const;
352 void findFreeChannel(byte *soundData);
358 void findFreeChannelFull(byte *soundData);
364 return &_soundData[offset];
371 void playSound(
int offset);
453 virtual void callFunction(uint16 offset,
AdlibChannel &channel);
459 static void validate(
bool isDemo);
469 int dataOffset,
int dataSize);
479 virtual int stop()
override;
490 void noise()
override;
492 void setVolume(
int volume)
override;
byte * loadData(int offset)
Definition: asound.h:363
void load(byte *soundData)
Definition: native_sound_timer.h:33
Definition: sound_manager.h:40
Definition: anim_timer.h:27
void processChannelFade()
virtual void tickGameCallback()
Definition: asound.h:323
virtual void resetGameState()
Definition: asound.h:317