22 #ifndef MADS_PHANTOM_ASOUND_H 23 #define MADS_PHANTOM_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/sound_manager.h" 34 #define ADLIB_CHANNEL_COUNT 9 37 static bool _isDisabled;
38 uint8 _activeCount = 0;
40 uint8 _volumeFadeStep = 0;
41 uint8 _vibratoDepth = 0;
43 uint8 _sampleIndex = 0;
45 uint8 _noteOffset = 0;
46 uint8 _keyOnDelay = 0;
47 uint8 _fadePeriodCounter = 0;
48 uint8 _fadePeriodReload = 0;
49 uint8 _vibPeriodCounter = 0;
50 uint8 _vibPeriodReload = 0;
51 uint8 _patchAttenuation = 0;
52 byte *_loopStartPtr =
nullptr;
53 byte *_pSrc =
nullptr;
54 byte *_innerLoopPtr =
nullptr;
55 byte *_outerLoopPtr =
nullptr;
56 byte *_soundData =
nullptr;
57 byte *_branchTargetPtr =
nullptr;
58 uint16 _innerLoopCount = 0;
59 uint16 _outerLoopCount = 0;
60 uint16 _noiseFreqMask = 0;
61 uint16 _freqAccum = 0;
63 uint8 _freqSweepCounter = 0;
64 uint8 _savedFreqSweep = 0;
67 uint8 _opVolBytes = 0;
68 uint8 _opVolBytes2 = 0;
69 uint8 _octaveTranspose = 0;
70 uint8 _pendingStop = 0;
71 uint8 _durationOverride = 0;
83 void load(byte *soundData);
106 uint8 _attackRate = 0;
107 uint8 _decayRate = 0;
108 uint8 _sustainLevel = 0;
109 uint8 _releaseRate = 0;
112 uint8 _totalLevel = 0;
113 uint8 _scalingLevel = 0;
114 uint8 _waveformSelect = 0;
115 uint8 _freqMultiple = 0;
120 uint8 _freqSweepInit = 0;
122 uint16 _freqMask = 0;
123 uint16 _freqBase = 0;
124 uint16 _outerLoopPtr = 0;
134 uint16 _callbackCounter = 0;
135 uint16 _callbackPeriod = 0;
137 uint8 _activeChannelNumber = 0;
138 uint16 _activeChannelReg = 0;
139 uint16 _currentOpBase = 0;
141 byte *pSrc =
nullptr;
142 int16 _pollResult = 0;
143 int16 _resultFlag = 0;
144 uint16 _randomSeed = 0x4D2;
145 uint8 _isDisabled = 0;
146 uint8 _findChannelMode = 0;
147 uint8 _ch5SweepLive = 0;
148 uint8 _ch5SweepSaved = 0;
149 uint8 _ch5PendingStop = 0;
150 uint8 _anySweepActive = 0;
151 int _frameNumber2 = 0;
152 uint8 _scriptVars[32];
153 uint16 _tickEnabled = 1;
154 uint16 _tickCounter = 0;
155 uint16 _tempoReload = 0;
156 uint16 _tempoTarget = 0;
157 uint16 _tempoShift = 0;
158 uint16 _tempoBase = 0xA0;
159 uint16 _tempoCurrent = 0x28;
160 uint16 _tempoScale = 0x0A;
170 void clearCallback();
171 void resetCallback() {
180 void adlib_channelOff(uint8 portIndex);
197 void writeFrequency();
203 void writePitchBend();
222 void writeSampleRegs();
241 void update1(
int channelIndex);
246 void setFrequency(uint8 voice, uint16 freq);
252 void noise_inner(
int channelIndex);
257 void updateAllChannels();
262 uint16 readWord_impl();
269 &_channel0, &_channel1, &_channel2, &_channel3, &_channel4,
270 &_channel5, &_channel6, &_channel7, &_channel8
273 uint8 _adlibPorts[0x100] = { 0 };
284 void write(uint8 reg, uint8 value);
289 uint16 getRandomNumber();
296 void adlib_channelOn(uint8 portIndex, uint8 vol);
301 void signalSoundPlaying();
306 void pollAllChannels();
318 void pollActiveChannel();
323 bool isSoundActive(byte *ptr)
const;
334 void findFreeChannel(byte *soundData);
340 void findFreeChannelFull(byte *soundData);
346 return &_soundData[offset];
353 void playSound(
int offset);
434 virtual void callFunction(uint16 offset);
440 static void validate(
bool isDemo);
450 int dataOffset,
int dataSize);
462 virtual int stop()
override;
473 void noise()
override;
~ASound() override
Definition: asound.h:455
void processChannelFade()
static OPL * create(DriverId driver, OplType type)
Definition: sound_manager.h:38
Definition: anim_timer.h:27
void setVolume(int volume) override
Definition: asound.h:475
void load(byte *soundData)
byte * loadData(int offset)
Definition: asound.h:345