mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-18 07:39:08 +00:00
TSAGE: Bugfixes for sound channel updates
This commit is contained in:
parent
57bae5ecd6
commit
8ed74c61f6
@ -48,7 +48,9 @@ bool EventsClass::pollEvent() {
|
||||
_priorFrameTime = milli;
|
||||
++_frameNumber;
|
||||
|
||||
// Update screen and allow the sound manager to process pending sounds
|
||||
g_system->updateScreen();
|
||||
SoundManager::_sfSoundServer();
|
||||
}
|
||||
|
||||
if (!g_system->getEventManager()->pollEvent(_event)) return false;
|
||||
@ -297,6 +299,9 @@ void EventsClass::delay(int numFrames) {
|
||||
|
||||
++_frameNumber;
|
||||
_priorFrameTime = g_system->getMillis();
|
||||
|
||||
// Allow pending sounds to be processed
|
||||
SoundManager::_sfSoundServer();
|
||||
}
|
||||
|
||||
g_system->updateScreen();
|
||||
|
@ -460,6 +460,8 @@ void SoundManager::_sfUpdateVoiceStructs() {
|
||||
void SoundManager::_sfUpdateVoiceStructs2() {
|
||||
for (int voiceIndex = 0; voiceIndex < SOUND_ARR_SIZE; ++voiceIndex) {
|
||||
VoiceTypeStruct *vtStruct = sfManager()._voiceTypeStructPtrs[voiceIndex];
|
||||
if (!vtStruct)
|
||||
continue;
|
||||
|
||||
for (uint idx = 0; idx < vtStruct->_entries.size(); ++idx) {
|
||||
|
||||
@ -716,8 +718,7 @@ void SoundManager::_sfRethinkVoiceTypes() {
|
||||
continue;
|
||||
|
||||
_sfUpdateVoiceStructs();
|
||||
for (int idx = 0; idx < SOUND_ARR_SIZE; ++idx)
|
||||
sound->_chWork[idx] = 0;
|
||||
Common::set_to(sound->_chWork, sound->_chWork + SOUND_ARR_SIZE, false);
|
||||
|
||||
for (;;) {
|
||||
// Scan for sub priority
|
||||
@ -743,7 +744,7 @@ void SoundManager::_sfRethinkVoiceTypes() {
|
||||
break;
|
||||
|
||||
int chNumVoices = sound->_chNumVoices[foundIndex];
|
||||
sound->_chWork[foundIndex] = 1;
|
||||
sound->_chWork[foundIndex] = true;
|
||||
|
||||
VoiceTypeStruct *vtStruct = sfManager()._voiceTypeStructPtrs[sound->_chVoiceType[foundIndex]];
|
||||
if (!vtStruct) {
|
||||
@ -770,7 +771,7 @@ void SoundManager::_sfRethinkVoiceTypes() {
|
||||
++idx;
|
||||
}
|
||||
|
||||
vtStruct->_numVoices = numVoices;
|
||||
vtStruct->_numVoices -= chNumVoices;
|
||||
continue;
|
||||
} else if (!foundPriority) {
|
||||
do {
|
||||
@ -1133,7 +1134,7 @@ void SoundManager::_sfRethinkVoiceTypes() {
|
||||
|
||||
for (uint entryIndex = 0; entryIndex < vs->_entries.size(); ++entryIndex) {
|
||||
VoiceStructEntryType1 &vse2 = vs->_entries[entryIndex]._type1;
|
||||
if (!vse2._sound && (vse._sound3 == sound) && (vse._channelNum3 == channelNum)) {
|
||||
if (!vse2._sound && (vse2._sound3 == sound) && (vse2._channelNum3 == channelNum)) {
|
||||
vse2._sound = sound;
|
||||
vse2._channelNum = channelNum;
|
||||
vse._channelNum = vse2._channelNum2;
|
||||
@ -1170,7 +1171,7 @@ void SoundManager::_sfRethinkVoiceTypes() {
|
||||
driver->proc38(vs->_entries[idx2]._voiceNum, 7,
|
||||
vse2._sound->_chVolume[vse2._channelNum] * vse2._sound->_volume / 127);
|
||||
driver->proc38(vs->_entries[idx2]._voiceNum, 10, vse2._sound->_chPan[vse2._channelNum]);
|
||||
driver->proc40(vs->_entries[idx2]._voiceNum, vse2._sound->_chPitchBlend[vse2._channelNum]);
|
||||
driver->setPitch(vs->_entries[idx2]._voiceNum, vse2._sound->_chPitchBlend[vse2._channelNum]);
|
||||
}
|
||||
|
||||
for (uint idx = 0; idx < vs->_entries.size(); ++idx) {
|
||||
@ -1411,7 +1412,7 @@ Sound::Sound() {
|
||||
memset(_chNumVoices, 0, SOUND_ARR_SIZE * sizeof(int));
|
||||
memset(_chSubPriority, 0, SOUND_ARR_SIZE * sizeof(int));
|
||||
memset(_chFlags, 0, SOUND_ARR_SIZE * sizeof(int));
|
||||
memset(_chWork, 0, SOUND_ARR_SIZE * sizeof(int));
|
||||
Common::set_to(_chWork, _chWork + SOUND_ARR_SIZE, false);
|
||||
memset(_channelData, 0, SOUND_ARR_SIZE * sizeof(byte *));
|
||||
memset(_trkChannel, 0, SOUND_ARR_SIZE * sizeof(int));
|
||||
memset(_trkState, 0, SOUND_ARR_SIZE * sizeof(int));
|
||||
@ -1733,6 +1734,7 @@ bool Sound::_soServiceTracks() {
|
||||
flag = false;
|
||||
}
|
||||
|
||||
++_timer;
|
||||
if (!flag)
|
||||
return false;
|
||||
else if ((_loop > 0) && (--_loop == 0))
|
||||
@ -1841,7 +1843,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) {
|
||||
voiceType = VOICETYPE_0;
|
||||
} else {
|
||||
chVoiceType = (VoiceType)_chVoiceType[channelNum];
|
||||
vtStruct = _soundManager->_voiceTypeStructPtrs[channelNum];
|
||||
vtStruct = _soundManager->_voiceTypeStructPtrs[(int)chVoiceType];
|
||||
|
||||
if (vtStruct) {
|
||||
voiceType = vtStruct->_voiceType;
|
||||
@ -1912,7 +1914,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) {
|
||||
trkRest = (trkRest << 5) | (b & 0x1f);
|
||||
}
|
||||
|
||||
_trkRest[trackIndex] = trkRest;
|
||||
_trkRest[trackIndex] = trkRest - 1;
|
||||
_trkIndex[trackIndex] = pData - channelData;
|
||||
return;
|
||||
} else if (!(v & 0x10)) {
|
||||
@ -1935,6 +1937,9 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) {
|
||||
_soDoTrackCommand(_trkChannel[trackIndex], cmdVal, b);
|
||||
|
||||
if (!_soundManager->_soTimeIndexFlag) {
|
||||
if (cmdVal == 7)
|
||||
b = static_cast<byte>(_volume * (int)b / 127);
|
||||
|
||||
if (voiceType != VOICETYPE_0) {
|
||||
_soProc38(vtStruct, channelNum, chVoiceType, cmdVal, v);
|
||||
} else if (voiceNum != -1) {
|
||||
@ -1979,7 +1984,7 @@ void Sound::_soServiceTrackType0(int trackIndex, const byte *channelData) {
|
||||
} else if (!(v & 0x2)) {
|
||||
// Area #7
|
||||
if (!_soundManager->_soTimeIndexFlag) {
|
||||
int pitchBlend = READ_LE_UINT16(pData);
|
||||
int pitchBlend = READ_BE_UINT16(pData);
|
||||
pData += 2;
|
||||
|
||||
if (channelNum != -1) {
|
||||
@ -2132,7 +2137,7 @@ void Sound::_soProc40(VoiceTypeStruct *vtStruct, int channelNum, int pitchBlend)
|
||||
SoundDriver *driver = vtStruct->_entries[entryIndex]._driver;
|
||||
assert(driver);
|
||||
|
||||
driver->proc40(vtStruct->_entries[entryIndex]._voiceNum, pitchBlend);
|
||||
driver->setPitch(vtStruct->_entries[entryIndex]._voiceNum, pitchBlend);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2384,7 +2389,7 @@ AdlibSoundDriver::AdlibSoundDriver(): SoundDriver() {
|
||||
memset(_v44079, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
|
||||
memset(_v44082, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
|
||||
_v44082[ADLIB_CHANNEL_COUNT] = 0x90;
|
||||
Common::set_to(_v4408C, _v4408C + ADLIB_CHANNEL_COUNT, 0x2000);
|
||||
Common::set_to(_pitchBlend, _pitchBlend + ADLIB_CHANNEL_COUNT, 0x2000);
|
||||
memset(_v4409E, 0, ADLIB_CHANNEL_COUNT * sizeof(int));
|
||||
}
|
||||
|
||||
@ -2491,8 +2496,8 @@ void AdlibSoundDriver::proc38(int channel, int cmd, int value) {
|
||||
}
|
||||
}
|
||||
|
||||
void AdlibSoundDriver::proc40(int channel, int pitchBlend) {
|
||||
_v4408C[channel] = pitchBlend;
|
||||
void AdlibSoundDriver::setPitch(int channel, int pitchBlend) {
|
||||
_pitchBlend[channel] = pitchBlend;
|
||||
setFrequency(channel);
|
||||
}
|
||||
|
||||
@ -2579,7 +2584,7 @@ void AdlibSoundDriver::updateChannel(int channel) {
|
||||
void AdlibSoundDriver::setFrequency(int channel) {
|
||||
int offset, ch;
|
||||
|
||||
int v = _v4408C[channel];
|
||||
int v = _pitchBlend[channel];
|
||||
if (v == 0x2000) {
|
||||
offset = 0;
|
||||
ch = _v44067[channel];
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
virtual void updateVoice(int channel) {} // Method #17
|
||||
virtual void proc36() {} // Method #18
|
||||
virtual void proc38(int channel, int cmd, int value) {} // Method #19
|
||||
virtual void proc40(int channel, int pitchBlend) {} // Method #20
|
||||
virtual void setPitch(int channel, int pitchBlend) {} // Method #20
|
||||
virtual void proc42(int channel, int v0, int v1) {} // Method #21
|
||||
};
|
||||
|
||||
@ -282,7 +282,7 @@ public:
|
||||
int _chNumVoices[SOUND_ARR_SIZE];
|
||||
int _chSubPriority[SOUND_ARR_SIZE];
|
||||
int _chFlags[SOUND_ARR_SIZE];
|
||||
int _chWork[SOUND_ARR_SIZE];
|
||||
bool _chWork[SOUND_ARR_SIZE];
|
||||
trackInfoStruct _trackInfo;
|
||||
byte *_channelData[SOUND_ARR_SIZE];
|
||||
int _trkChannel[SOUND_ARR_SIZE];
|
||||
@ -404,7 +404,7 @@ private:
|
||||
int _v44070[ADLIB_CHANNEL_COUNT];
|
||||
int _v44079[ADLIB_CHANNEL_COUNT];
|
||||
int _v44082[ADLIB_CHANNEL_COUNT + 1];
|
||||
int _v4408C[ADLIB_CHANNEL_COUNT];
|
||||
int _pitchBlend[ADLIB_CHANNEL_COUNT];
|
||||
int _v4409E[ADLIB_CHANNEL_COUNT];
|
||||
|
||||
|
||||
@ -427,7 +427,7 @@ public:
|
||||
virtual void proc32(int channel, int program, int v0, int v1);
|
||||
virtual void updateVoice(int channel);
|
||||
virtual void proc38(int channel, int cmd, int value);
|
||||
void proc40(int channel, int pitchBlend);
|
||||
virtual void setPitch(int channel, int pitchBlend);
|
||||
};
|
||||
|
||||
} // End of namespace tSage
|
||||
|
Loading…
Reference in New Issue
Block a user