1
0
Fork 0
mirror of https://github.com/halpz/re3.git synced 2024-12-26 18:15:27 +00:00

final processActiveQueues

This commit is contained in:
Roman Masanin 2020-10-02 00:11:51 +03:00
parent 311cffa901
commit e54b540bd4

View file

@ -750,49 +750,42 @@ cAudioManager::AddReleasingSounds()
void void
cAudioManager::ProcessActiveQueues() cAudioManager::ProcessActiveQueues()
{ {
char flag; // al CVector position;
int emittingVol_1; // ecx uint32 freqDivided;
bool missionState; // al uint32 loopCount;
uint32 freqDivided; // ebp uint8 emittingVol;
uint32 loopCount; // eax uint8 vol;
uint8 emittingVol_3; // dl uint8 offset;
unsigned int volume; // eax float x;
uint8 offset; // dl bool flag;
float x; // st4 bool missionState;
unsigned int emittingVol; // [esp+14h] [ebp-78h]
int emittingVolCmp; // [esp+28h] [ebp-64h]
int emittingVol_2; // [esp+28h] [ebp-64h]
int activeVolume_1; // [esp+40h] [ebp-4Ch]
CVector position; // [esp+70h] [ebp-1Ch]
CVector usedPosition;
for (int32 i = 0; i < m_nActiveSamples; i++) { for (int32 i = 0; i < m_nActiveSamples; i++) {
m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = false; m_asSamples[m_nActiveSampleQueue][i].m_bIsProcessed = false;
m_asActiveSamples[i].m_bIsProcessed = false; m_asActiveSamples[i].m_bIsProcessed = false;
} }
for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
for (int32 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { //??
tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
if (sample.m_nSampleIndex != NO_SAMPLE) { if (sample.m_nSampleIndex != NO_SAMPLE) {
for (int32 j = 0; j < m_nActiveSamples; j++) {//?? for (int32 j = 0; j < m_nActiveSamples; j++) {
if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex && if (sample.m_nEntityIndex == m_asActiveSamples[j].m_nEntityIndex &&
sample.m_nCounter == m_asActiveSamples[j].m_nCounter && sample.m_nCounter == m_asActiveSamples[j].m_nCounter &&
sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) { //!! sample.m_nSampleIndex == m_asActiveSamples[j].m_nSampleIndex) {
if (sample.m_nLoopCount) { //!! if (sample.m_nLoopCount) {
if (field_5554 & 1) { //!! if (field_5554 & 1) {
if (!(j & 1)) { //!! if (!(j & 1)) {
flag = 0; flag = false;
} else { } else {
flag = 1; flag = true;
} }
} else if (j & 1) { //!! } else if (j & 1) {
flag = 0; flag = false;
} else { } else {
flag = 1; flag = true;
} }
if (flag && !SampleManager.GetChannelUsedFlag(j)) { //!! if (flag && !SampleManager.GetChannelUsedFlag(j)) {
sample.m_bLoopEnded = true; sample.m_bLoopEnded = true;
m_asActiveSamples[j].m_bLoopEnded = true; m_asActiveSamples[j].m_bLoopEnded = true;
m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[j].m_nSampleIndex = NO_SAMPLE;
@ -805,9 +798,9 @@ cAudioManager::ProcessActiveQueues()
sample.m_bIsProcessed = true; sample.m_bIsProcessed = true;
m_asActiveSamples[j].m_bIsProcessed = true; m_asActiveSamples[j].m_bIsProcessed = true;
sample.m_nVolumeChange = -1; sample.m_nVolumeChange = -1;
if (!sample.m_bReleasingSoundFlag) { //!! if (!sample.m_bReleasingSoundFlag) {
if (sample.m_bIs2D) { //!! if (sample.m_bIs2D) {
if (field_4) { //!! if (field_4) {
emittingVol = 2 * Min(63, sample.m_nEmittingVolume); emittingVol = 2 * Min(63, sample.m_nEmittingVolume);
} else { } else {
emittingVol = sample.m_nEmittingVolume; emittingVol = sample.m_nEmittingVolume;
@ -822,35 +815,35 @@ cAudioManager::ProcessActiveQueues()
sample.m_fDistance, sample.m_fDistance,
sample.m_fSpeedMultiplier); sample.m_fSpeedMultiplier);
if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) { //!! if (sample.m_nFrequency != m_asActiveSamples[j].m_nFrequency) {
m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000); m_asActiveSamples[j].m_nFrequency = clamp2((int32)sample.m_nFrequency, (int32)m_asActiveSamples[j].m_nFrequency, 6000);
SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency); SampleManager.SetChannelFrequency(j, m_asActiveSamples[j].m_nFrequency);
} }
if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) { //!! if (sample.m_nEmittingVolume != m_asActiveSamples[j].m_nEmittingVolume) {
activeVolume_1 = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10); vol = clamp2((int8)sample.m_nEmittingVolume, (int8)m_asActiveSamples[j].m_nEmittingVolume, 10);
if (field_4) { //!! if (field_4) {
emittingVol_1 = 2 * Min(63, activeVolume_1); emittingVol = 2 * Min(63, vol);
} else { } else {
emittingVol_1 = activeVolume_1; emittingVol = vol;
} }
missionState = false; missionState = false;
for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) { //!! for (int32 k = 0; k < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); k++) {
if (m_sMissionAudio.m_bIsMobile[k]) { if (m_sMissionAudio.m_bIsMobile[k]) {
missionState = true; missionState = true;
break; break;
} }
} }
if (missionState) { //!! if (missionState) {
emittingVol_1 = (emittingVol_1 * field_5538) / 127; emittingVol = (emittingVol * field_5538) / 127;
} else { } else {
if (field_5538 < 127) if (field_5538 < 127)
emittingVol_1 = (emittingVol_1 * field_5538) / 127; emittingVol = (emittingVol * field_5538) / 127;
} }
SampleManager.SetChannelEmittingVolume(j, emittingVol_1); SampleManager.SetChannelEmittingVolume(j, emittingVol);
m_asActiveSamples[j].m_nEmittingVolume = activeVolume_1; m_asActiveSamples[j].m_nEmittingVolume = vol;
} }
TranslateEntity(&sample.m_vecPos, &position); TranslateEntity(&sample.m_vecPos, &position);
SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z); SampleManager.SetChannel3DPosition(j, position.x, position.y, position.z);
@ -866,67 +859,67 @@ cAudioManager::ProcessActiveQueues()
} }
} }
} }
for (int32 i = 0; i < m_nActiveSamples; i++) { //!! for (int32 i = 0; i < m_nActiveSamples; i++) {
if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) { if (m_asActiveSamples[i].m_nSampleIndex != NO_SAMPLE && !m_asActiveSamples[i].m_bIsProcessed) {
SampleManager.StopChannel(i); SampleManager.StopChannel(i);
m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE; m_asActiveSamples[i].m_nSampleIndex = NO_SAMPLE;
m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE; m_asActiveSamples[i].m_nEntityIndex = AEHANDLE_NONE;
} }
} }
for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) { //?? for (uint8 i = 0; i < m_SampleRequestQueuesStatus[m_nActiveSampleQueue]; i++) {
tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]]; tSound& sample = m_asSamples[m_nActiveSampleQueue][m_abSampleQueueIndexTable[m_nActiveSampleQueue][i]];
if (!sample.m_bIsProcessed && !sample.m_bLoopEnded && if (!sample.m_bIsProcessed && !sample.m_bLoopEnded &&
m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) { //!! m_asAudioEntities[sample.m_nEntityIndex].m_bIsUsed && sample.m_nSampleIndex < NO_SAMPLE) {
if (sample.m_nCounter > 255 && sample.m_nLoopCount && sample.m_nLoopsRemaining) { //!! if (sample.m_nCounter > 255 && sample.m_nLoopCount && sample.m_nLoopsRemaining) {
sample.m_nLoopsRemaining--; sample.m_nLoopsRemaining--;
sample.m_nReleasingVolumeDivider = 1; sample.m_nReleasingVolumeDivider = 1;
} else { } else {
for (uint8 j = 0; j < m_nActiveSamples; j++) { //?? for (uint8 j = 0; j < m_nActiveSamples; j++) {
uint8 k = (j + field_6) % m_nActiveSamples; uint8 k = (j + field_6) % m_nActiveSamples;
if (!m_asActiveSamples[k].m_bIsProcessed) { //!! if (!m_asActiveSamples[k].m_bIsProcessed) {
if (sample.m_nLoopCount != 0) { //!! if (sample.m_nLoopCount != 0) {
freqDivided = sample.m_nFrequency / m_nTimeSpent; freqDivided = sample.m_nFrequency / m_nTimeSpent;
loopCount = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex); loopCount = sample.m_nLoopCount * SampleManager.GetSampleLength(sample.m_nSampleIndex);
if (freqDivided == 0) //!! if (freqDivided == 0)
continue; continue;
sample.m_nReleasingVolumeDivider = loopCount / freqDivided + 1; sample.m_nReleasingVolumeDivider = loopCount / freqDivided + 1;
} }
memcpy(&m_asActiveSamples[k], &sample, sizeof(tSound)); memcpy(&m_asActiveSamples[k], &sample, sizeof(tSound));
if (!m_asActiveSamples[k].m_bIs2D) //!! if (!m_asActiveSamples[k].m_bIs2D)
TranslateEntity(&m_asActiveSamples[k].m_vecPos, &position); TranslateEntity(&m_asActiveSamples[k].m_vecPos, &position);
if (field_4) { //!! if (field_4) {
emittingVol_2 = 2 * Min(63, m_asActiveSamples[k].m_nEmittingVolume); emittingVol = 2 * Min(63, m_asActiveSamples[k].m_nEmittingVolume);
} else { } else {
emittingVol_2 = m_asActiveSamples[k].m_nEmittingVolume; emittingVol = m_asActiveSamples[k].m_nEmittingVolume;
} }
if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) { if (SampleManager.InitialiseChannel(k, m_asActiveSamples[k].m_nSampleIndex, m_asActiveSamples[k].m_nBankIndex)) {
SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency); SampleManager.SetChannelFrequency(k, m_asActiveSamples[k].m_nFrequency);
bool isMobile = false; bool isMobile = false;
for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) { //!! for (int32 l = 0; l < ARRAY_SIZE(m_sMissionAudio.m_bIsMobile); l++) {
if (m_sMissionAudio.m_bIsMobile[l]) { //!! if (m_sMissionAudio.m_bIsMobile[l]) {
isMobile = true; isMobile = true;
break; break;
} }
} }
if (!isMobile || m_asActiveSamples[k].m_bIs2D) { //!! if (!isMobile || m_asActiveSamples[k].m_bIs2D) {
if (field_5538 < 127) //!! if (field_5538 < 127)
emittingVol_2 *= field_5538 / 127; emittingVol *= field_5538 / 127;
volume = emittingVol_2; vol = emittingVol;
} else { } else {
volume = (emittingVol_2 * field_5538 / 127); vol = (emittingVol * field_5538 / 127);
} }
SampleManager.SetChannelEmittingVolume(k, volume); SampleManager.SetChannelEmittingVolume(k, vol);
SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd); SampleManager.SetChannelLoopPoints(k, m_asActiveSamples[k].m_nLoopStart, m_asActiveSamples[k].m_nLoopEnd);
SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount); SampleManager.SetChannelLoopCount(k, m_asActiveSamples[k].m_nLoopCount);
SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverbFlag); SampleManager.SetChannelReverbFlag(k, m_asActiveSamples[k].m_bReverbFlag);
if (m_asActiveSamples[k].m_bIs2D) { //!! if (m_asActiveSamples[k].m_bIs2D) {
offset = m_asActiveSamples[k].m_nOffset; offset = m_asActiveSamples[k].m_nOffset;
if (offset == 63) { //!! if (offset == 63) {
x = 0.0f; x = 0.0f;
} else if (offset >= 63) { //!! } else if (offset >= 63) {
x = (offset - 63) * 1000.0f / 63; x = (offset - 63) * 1000.0f / 63;
} else { } else {
x = -(63 - offset) * 1000.0f / 63; x = -(63 - offset) * 1000.0f / 63; //same like line below
} }
position = CVector(x, 0.0f, 0.0f); position = CVector(x, 0.0f, 0.0f);
m_asActiveSamples[k].m_fSoundIntensity = 100000.0f; m_asActiveSamples[k].m_fSoundIntensity = 100000.0f;
@ -944,7 +937,9 @@ cAudioManager::ProcessActiveQueues()
} }
} }
} }
field_6 %= m_nActiveSamples;
} }
void void
cAudioManager::ClearRequestedQueue() cAudioManager::ClearRequestedQueue()
{ {