Fixes for review

This commit is contained in:
Filip Gawin 2020-03-21 14:51:30 +01:00
parent 337924c794
commit a097f225bc
5 changed files with 53 additions and 38 deletions

View File

@ -53,6 +53,21 @@ uint8 &gJumboVolOffsetPercentage = *(uint8 *)0x6508ED;
bool &bPlayerJustEnteredCar = *(bool *)0x6508C4; bool &bPlayerJustEnteredCar = *(bool *)0x6508C4;
bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E;
const int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
const int policeChannel = channels + 1;
const int allChannels = channels + 2;
const int maxVolume = 127;
const int scriptObjectIntensityS = 30;
const int scriptObjectIntensityL = 80;
const int bridgeIntensity = 400;
const int rocketLauncherIntensity = 90;
const int molotovIntensity = 30;
const int molotovVolume = 50;
const int rainOnVehicleIntensity = 22;
const int reverseGearIntensity = 30;
constexpr bool hornPatternsArray[8][44] = { constexpr bool hornPatternsArray[8][44] = {
{false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, {false, false, true, true, true, true, true, true, true, true, true, true, true, true, true,
true, true, false, false, false, false, false, false, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, true, true, true, true, true, true, true,
@ -165,8 +180,8 @@ cPedComments::Add(tPedComment *com)
{ {
uint8 index; uint8 index;
if(nrOfCommentsInBank[activeBank] >= pedCommentsSlots) { if(nrOfCommentsInBank[activeBank] >= NUM_PED_COMMENTS_SLOTS) {
index = indexMap[activeBank][pedCommentsSlots - 1]; index = indexMap[activeBank][NUM_PED_COMMENTS_SLOTS - 1];
if(m_asPedComments[activeBank][index].m_bVolume > com->m_bVolume) return; if(m_asPedComments[activeBank][index].m_bVolume > com->m_bVolume) return;
} else { } else {
index = nrOfCommentsInBank[activeBank]++; index = nrOfCommentsInBank[activeBank]++;
@ -187,7 +202,7 @@ cPedComments::Add(tPedComment *com)
} }
} }
if(i < index) memmove(&indexMap[activeBank][i + 1], &indexMap[activeBank][i], pedCommentsSlots -1 - i); if(i < index) memmove(&indexMap[activeBank][i + 1], &indexMap[activeBank][i], NUM_PED_COMMENTS_SLOTS -1 - i);
} }
indexMap[activeBank][i] = index; indexMap[activeBank][i] = index;
@ -221,7 +236,7 @@ cPedComments::Process()
AudioManager.m_sQueueSample.m_nLoopCount = 1; AudioManager.m_sQueueSample.m_nLoopCount = 1;
AudioManager.m_sQueueSample.m_nLoopStart = 0; AudioManager.m_sQueueSample.m_nLoopStart = 0;
AudioManager.m_sQueueSample.m_nLoopEnd = -1; AudioManager.m_sQueueSample.m_nLoopEnd = -1;
AudioManager.m_sQueueSample.m_bEmittingVolume = AudioManager.maxVolume; AudioManager.m_sQueueSample.m_bEmittingVolume = maxVolume;
AudioManager.m_sQueueSample.field_48 = 3.0f; AudioManager.m_sQueueSample.field_48 = 3.0f;
switch(sampleIndex) { switch(sampleIndex) {
case SFX_POLICE_HELI_1: case SFX_POLICE_HELI_1:
@ -268,7 +283,7 @@ cPedComments::Process()
} }
} }
for(uint32 i = 0; i < pedCommentsSlots; i++) { indexMap[actualUsedBank][i] = pedCommentsSlots; } for(uint32 i = 0; i < NUM_PED_COMMENTS_SLOTS; i++) { indexMap[actualUsedBank][i] = NUM_PED_COMMENTS_SLOTS; }
nrOfCommentsInBank[actualUsedBank] = 0; nrOfCommentsInBank[actualUsedBank] = 0;
} }
} }

View File

@ -2,6 +2,7 @@
#include "DMAudio.h" #include "DMAudio.h"
#include "common.h" #include "common.h"
#include "core/config.h"
#include "AudioCollision.h" #include "AudioCollision.h"
#include "PoliceRadio.h" #include "PoliceRadio.h"
@ -194,9 +195,9 @@ public:
void *m_pEntity; void *m_pEntity;
bool m_bIsUsed; bool m_bIsUsed;
uint8 m_bStatus; uint8 m_bStatus;
int16 m_awAudioEvent[4]; int16 m_awAudioEvent[NUM_AUDIOENTITY_EVENTS];
uint8 gap_18[2]; uint8 gap_18[2];
float m_afVolume[4]; float m_afVolume[NUM_AUDIOENTITY_EVENTS];
uint8 m_AudioEvents; uint8 m_AudioEvents;
uint8 field_25[3]; uint8 field_25[3];
@ -224,11 +225,9 @@ static_assert(sizeof(tPedComment) == 28, "tPedComment: error");
class cPedComments class cPedComments
{ {
public: public:
static constexpr int pedCommentsBanks = 2; tPedComment m_asPedComments[NUM_PED_COMMENTS_BANKS][NUM_PED_COMMENTS_SLOTS];
static constexpr int pedCommentsSlots = 20; uint8 indexMap[NUM_PED_COMMENTS_BANKS][NUM_PED_COMMENTS_SLOTS];
tPedComment m_asPedComments[pedCommentsBanks][pedCommentsSlots]; uint8 nrOfCommentsInBank[NUM_PED_COMMENTS_BANKS];
uint8 indexMap[pedCommentsBanks][pedCommentsSlots];
uint8 nrOfCommentsInBank[pedCommentsBanks];
uint8 activeBank; uint8 activeBank;
uint8 gap_1163[1]; uint8 gap_1163[1];
@ -306,16 +305,16 @@ public:
tSound m_sQueueSample; tSound m_sQueueSample;
bool m_bActiveSampleQueue; bool m_bActiveSampleQueue;
uint8 gap_109[3]; uint8 gap_109[3];
tSound m_asSamples[2][27]; tSound m_asSamples[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS];
uint8 m_abSampleQueueIndexTable[2][27]; uint8 m_abSampleQueueIndexTable[NUM_SOUNDS_SAMPLES_BANKS][NUM_SOUNDS_SAMPLES_SLOTS];
uint8 m_bSampleRequestQueuesStatus[2]; uint8 m_bSampleRequestQueuesStatus[NUM_SOUNDS_SAMPLES_BANKS];
tSound m_asActiveSamples[27]; tSound m_asActiveSamples[NUM_SOUNDS_SAMPLES_SLOTS];
tAudioEntity m_asAudioEntities[200]; tAudioEntity m_asAudioEntities[NUM_AUDIOENTITIES];
int32 m_anAudioEntityIndices[200]; int32 m_anAudioEntityIndices[NUM_AUDIOENTITIES];
int32 m_nAudioEntitiesTotal; int32 m_nAudioEntitiesTotal;
CVector m_avecReflectionsPos[5]; CVector m_avecReflectionsPos[NUM_AUDIO_REFLECTIONS];
float m_afReflectionsDistances[5]; float m_afReflectionsDistances[NUM_AUDIO_REFLECTIONS];
int32 m_anScriptObjectEntityIndices[40]; int32 m_anScriptObjectEntityIndices[NUM_SCRIPT_MAX_ENTITIES];
int32 m_nScriptObjectEntityTotal; int32 m_nScriptObjectEntityTotal;
cPedComments m_sPedComments; cPedComments m_sPedComments;
int32 m_nFireAudioEntity; int32 m_nFireAudioEntity;
@ -608,21 +607,6 @@ public:
void AdjustSamplesVolume(); /// ok void AdjustSamplesVolume(); /// ok
uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity, uint8 ComputeEmittingVolume(uint8 emittingVolume, float intensity,
float dist); /// ok float dist); /// ok
public:
static constexpr int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
static constexpr int policeChannel = channels + 1;
static constexpr int allChannels = channels + 2;
static constexpr int maxVolume = 127;
static constexpr int scriptObjectIntensityS = 30;
static constexpr int scriptObjectIntensityL = 80;
static constexpr int bridgeIntensity = 400;
static constexpr int rocketLauncherIntensity = 90;
static constexpr int molotovIntensity = 30;
static constexpr int molotovVolume = 50;
static constexpr int rainOnVehicleIntensity = 22;
static constexpr int reverseGearIntensity = 30;
}; };
static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error"); static_assert(sizeof(cAudioManager) == 19220, "cAudioManager: error");

View File

@ -21,6 +21,8 @@ uint8 &cDisplay = *(uint8 *)0x650BA1;
int32 &gRetuneCounter = *(int32*)0x650B84; int32 &gRetuneCounter = *(int32*)0x650B84;
bool& bHasStarted = *(bool*)0x650B7C; bool& bHasStarted = *(bool*)0x650B7C;
constexpr int maxVolume = 127;
cMusicManager::cMusicManager() cMusicManager::cMusicManager()
{ {
m_bIsInitialised = false; m_bIsInitialised = false;
@ -365,7 +367,7 @@ cMusicManager::Service()
if (!m_bIsInitialised || m_bDisabled) return; if (!m_bIsInitialised || m_bDisabled) return;
if (m_nMusicMode == MUSICMODE_CUTSCENE) { if (m_nMusicMode == MUSICMODE_CUTSCENE) {
SampleManager.SetStreamedVolumeAndPan(AudioManager.maxVolume, 63, 1, 0); SampleManager.SetStreamedVolumeAndPan(maxVolume, 63, 1, 0);
return; return;
} }
@ -666,7 +668,7 @@ cMusicManager::PreloadCutSceneMusic(uint8 track)
while (SampleManager.IsStreamPlaying(0)) while (SampleManager.IsStreamPlaying(0))
SampleManager.StopStreamedFile(0); SampleManager.StopStreamedFile(0);
SampleManager.PreloadStreamedFile(track, 0); SampleManager.PreloadStreamedFile(track, 0);
SampleManager.SetStreamedVolumeAndPan(AudioManager.maxVolume, 63, 1, 0); SampleManager.SetStreamedVolumeAndPan(maxVolume, 63, 1, 0);
m_nCurrentStreamedSound = track; m_nCurrentStreamedSound = track;
} }
} }

View File

@ -11,6 +11,9 @@
#include "Vehicle.h" #include "Vehicle.h"
#include "World.h" #include "World.h"
constexpr int maxVolume = 127;
constexpr int channels = ARRAY_SIZE(cAudioManager::m_asActiveSamples);
constexpr int policeChannel = channels + 1;
struct tPoliceRadioZone { struct tPoliceRadioZone {
char m_aName[8]; char m_aName[8];

View File

@ -101,6 +101,17 @@ enum Config {
NUMVISIBLEENTITIES = 2000, NUMVISIBLEENTITIES = 2000,
NUMINVISIBLEENTITIES = 150, NUMINVISIBLEENTITIES = 150,
NUM_AUDIOENTITY_EVENTS = 4,
NUM_PED_COMMENTS_BANKS = 2,
NUM_PED_COMMENTS_SLOTS = 20,
NUM_SOUNDS_SAMPLES_BANKS = 2,
NUM_SOUNDS_SAMPLES_SLOTS = 27,
NUM_AUDIOENTITIES = 200,
NUM_AUDIO_REFLECTIONS = 5,
NUM_SCRIPT_MAX_ENTITIES = 40,
}; };
// We'll use this once we're ready to become independent of the game // We'll use this once we're ready to become independent of the game