22 #ifndef MADS_NEBULAR_SOUND_PSOUND_H 23 #define MADS_NEBULAR_SOUND_PSOUND_H 25 #include "mads/core/native_sound_timer.h" 26 #include "mads/core/sound_manager.h" 33 namespace RexNebular {
49 int initializedDataSize;
51 uint16 nullSequenceOffset;
52 uint16 patchTableOffset;
54 byte musicChannelCount;
63 kMusicChannelCount = 6,
65 kOpcodeBudgetPerTick = 256
71 kBothBanks = kFirstBank | kSecondBank
86 byte volumeFadeCounter;
87 byte volumeFadeReload;
88 byte panningFadeCounter;
89 byte panningFadeReload;
93 byte operatorTotalLevel[4];
96 uint16 innerLoopStart;
97 uint16 outerLoopStart;
98 uint16 innerLoopCount;
99 uint16 outerLoopCount;
100 uint16 originalSequence;
104 int8 patchAttenuation;
107 void load(uint16 sequenceOffset);
112 uint16 frequencyMask;
113 uint16 frequencyBase;
120 byte _registerCache[2][256];
122 Channel _channels[kChannelCount];
127 uint16 _frameCounter;
130 uint16 _nullSequenceOffset;
131 uint16 _patchTableOffset;
134 byte _musicChannelCount;
136 bool _updatesEnabled;
138 bool _noiseServiceEnabled;
141 byte _savedNoiseTicks[2];
142 byte _noiseChannel[2];
143 uint16 _noiseMask[2];
151 bool isDataRangeValid(uint32 offset, uint32 length)
const;
152 void requireDataRange(uint32 offset, uint32 length,
const char *operation)
const;
153 const byte *getDataPointer(uint32 offset, uint32 length,
154 const char *operation)
const;
155 byte *getDataPointer(uint32 offset, uint32 length,
const char *operation);
158 byte readDataByte(uint32 offset)
const;
159 uint16 readDataUint16(uint32 offset)
const;
160 void writeDataByte(uint32 offset, byte value);
161 void writeDataUint16(uint32 offset, uint16 value);
163 byte getBankMask(uint channel)
const;
164 byte getOplChannel(uint channel)
const;
165 byte getOperatorOffset(uint channel, uint operatorIndex)
const;
166 const byte *getPatch(uint patchIndex)
const;
167 byte getPanningAttenuation(byte panning)
const;
168 uint16 getFrequencyNumber(byte semitone)
const;
170 void writeRegister(byte banks, byte reg, byte value);
171 byte getCachedRegister(byte banks, byte reg)
const;
173 virtual int command0();
186 void loadChannel(uint channel, uint16 sequenceOffset);
187 void playSound(uint16 sequenceOffset);
188 void playSoundAny(uint16 sequenceOffset);
189 bool isSoundActive(uint16 sequenceOffset)
const;
190 void requestStop(uint firstChannel, uint endChannel);
191 void setCurrentSequence(uint firstChannel, uint endChannel,
192 uint16 sequenceOffset);
198 virtual void tickCallback() {
200 virtual byte getStopFadeReload()
const {
203 void updateChannel(uint channelIndex);
204 bool executeOpcode(uint channelIndex, byte opcode,
bool &levelsDirty);
205 void checkPendingStops();
206 void finishChannel(uint channelIndex);
208 void loadPatch(uint channelIndex, byte patchIndex);
209 void programOperator(byte banks, uint channelIndex, uint operatorIndex,
210 const byte *operatorData);
211 void updatePanning(uint channelIndex);
212 void updateChannelLevels(uint channelIndex);
213 void updateChannelFrequency(uint channelIndex,
bool keyOn);
214 void updatePitchBend(uint channelIndex);
215 void keyOff(uint channelIndex);
216 void startNoise(uint channelIndex);
218 void setNoiseFrequency(uint channelIndex,
int frequency);
222 byte scaledCommandParameter(
int param)
const;
225 static void validate(
bool isDemo);
226 bool isReady()
const {
return _opl !=
nullptr; }
230 void noise()
override;
231 void setVolume(
int volume)
override;
238 #endif // MADS_NEBULAR_SOUND_PSOUND_H
Definition: native_sound_timer.h:33
Definition: sound_manager.h:40
Definition: anim_timer.h:27