12 #ifndef MADS_PHANTOM_SOUND_PSOUND_H 13 #define MADS_PHANTOM_SOUND_PSOUND_H 15 #include "mads/core/native_sound_timer.h" 16 #include "mads/core/sound_manager.h" 37 int initializedDataSize;
39 uint16 randomSeedOffset;
40 uint16 nullSequenceOffset;
41 uint16 patchTableOffset;
51 kMusicChannelCount = 6,
54 kOpcodeBudgetPerTick = 256
61 kBothBanks = kFirstBank | kSecondBank
75 byte volumeFadeCounter;
76 byte volumeFadeReload;
77 byte panningFadeCounter;
78 byte panningFadeReload;
82 byte operatorTotalLevel[4];
85 uint16 innerLoopStart;
86 uint16 outerLoopStart;
87 uint16 innerLoopCount;
88 uint16 outerLoopCount;
89 uint16 originalSequence;
99 int8 patchAttenuation;
100 byte durationOverride;
103 void load(uint16 sequenceOffset);
107 byte _registerCache[2][256];
109 Channel _channels[kChannelCount];
110 byte _scriptVars[kScriptVarCount];
113 uint16 _frameCounter;
116 uint16 _nullSequenceOffset;
117 uint16 _patchTableOffset;
120 bool _updatesEnabled;
121 bool _noiseServiceEnabled;
131 uint16 _tempoCurrent;
138 bool isDataRangeValid(uint32 offset, uint32 length)
const;
139 const byte *getDataPointer(uint32 offset, uint32 length,
140 const char *operation)
const;
141 byte *getDataPointer(uint32 offset, uint32 length,
const char *operation);
142 byte readDataByte(uint32 offset)
const;
143 uint16 readDataUint16(uint32 offset)
const;
144 void writeDataByte(uint32 offset, byte value);
145 void writeDataUint16(uint32 offset, uint16 value);
147 byte getBankMask(uint channel)
const;
148 byte getOplChannel(uint channel)
const;
149 byte getOperatorOffset(uint channel, uint operatorIndex)
const;
150 const byte *getPatch(uint patchIndex)
const;
151 byte getPanningAttenuation(byte panning)
const;
152 uint16 getFrequencyNumber(byte semitone)
const;
153 void writeRegister(byte banks, byte reg, byte value);
154 byte getCachedRegister(byte banks, byte reg)
const;
156 void initializePas16();
157 void shutdownPas16();
169 void requestStop(uint firstChannel, uint endChannel);
170 void setCurrentSequence(uint firstChannel, uint endChannel,
171 uint16 sequenceOffset);
172 void loadChannel(uint channel, uint16 sequenceOffset);
173 void playSound(uint16 sequenceOffset);
174 void playMusicAny(uint16 sequenceOffset);
175 bool isSoundActive(uint16 sequenceOffset)
const;
181 void updateChannel(uint channelIndex);
182 bool isOpcodeDataValid(uint16 position, uint32 length)
const;
183 byte readOpcodeByte(uint16 position, uint16 delta)
const;
184 uint16 readOpcodeWord(uint16 position, uint16 delta)
const;
185 bool isScriptVariableValid(byte index)
const;
186 bool transferOpcode(
Channel &channel, uint16 position,
bool take,
188 bool executeOpcode(uint channelIndex, byte opcode,
bool &levelsDirty);
189 void finishChannel(uint channelIndex);
190 void checkPendingStops();
192 void loadPatch(uint channelIndex, byte patchIndex);
193 void programOperator(byte banks, uint channelIndex, uint operatorIndex,
194 const byte *operatorData);
195 void updatePanning(uint channelIndex);
196 void updateChannelLevels(uint channelIndex);
197 void updateChannelFrequency(uint channelIndex,
bool keyOn);
198 void updatePitchBend(uint channelIndex);
199 void keyOff(uint channelIndex);
200 void setNoiseFrequency(uint channelIndex,
int frequency);
206 virtual bool callFunction(uint16 targetOffset,
Channel &channel) = 0;
211 bool isReady()
const {
return _opl !=
nullptr; }
215 void noise()
override;
216 void setVolume(
int volume)
override;
223 #endif // MADS_PHANTOM_SOUND_PSOUND_H
Definition: native_sound_timer.h:33
Definition: sound_manager.h:40
Definition: anim_timer.h:27