diff options
author | Filip Gawin <filip.gawin@zoho.com> | 2019-07-05 21:15:32 +0200 |
---|---|---|
committer | Filip Gawin <filip.gawin@zoho.com> | 2019-07-07 17:48:32 +0200 |
commit | d6944ec570d10f23867a925e5438192b314eb936 (patch) | |
tree | 3945beafd65493024405e50a5729a10a57aba755 | |
parent | cleanup AudioManager (diff) | |
download | re3-d6944ec570d10f23867a925e5438192b314eb936.tar re3-d6944ec570d10f23867a925e5438192b314eb936.tar.gz re3-d6944ec570d10f23867a925e5438192b314eb936.tar.bz2 re3-d6944ec570d10f23867a925e5438192b314eb936.tar.lz re3-d6944ec570d10f23867a925e5438192b314eb936.tar.xz re3-d6944ec570d10f23867a925e5438192b314eb936.tar.zst re3-d6944ec570d10f23867a925e5438192b314eb936.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/AudioManager.cpp | 108 | ||||
-rw-r--r-- | src/audio/AudioManager.h | 13 | ||||
-rw-r--r-- | src/audio/MusicManager.cpp | 14 | ||||
-rw-r--r-- | src/audio/MusicManager.h | 3 | ||||
-rw-r--r-- | src/audio/SampleManager.cpp | 28 | ||||
-rw-r--r-- | src/audio/SampleManager.h | 7 |
6 files changed, 167 insertions, 6 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp index a48a3838..6df4c052 100644 --- a/src/audio/AudioManager.cpp +++ b/src/audio/AudioManager.cpp @@ -94,6 +94,102 @@ constexpr int totalAudioEntitiesSlots = 200; char &g_nMissionAudioPlayingStatus = *(char *)0x60ED88; +void +cAudioManager::Initialise() +{ + if(!m_bIsInitialised) { + PreInitialiseGameSpecificSetup(); + m_bIsInitialised = cSampleManager.Initialise(); + if(m_bIsInitialised) { + m_bActiveSamples = cSampleManager.GetActiveSamples(); + if(m_bActiveSamples <= 1u) { + Terminate(); + } else { + --m_bActiveSamples; + PostInitialiseGameSpecificSetup(); + InitialisePoliceRadioZones(); + InitialisePoliceRadio(); + MusicManager.Initialise(); + } + } + } +} + +void +cAudioManager::PostInitialiseGameSpecificSetup() +{ + m_nFireAudioEntity = CreateEntity( + AUDIOTYPE_FIRE, (CPhysical *)0x8F31D0); // last is addr of firemanager @todo change + if(m_nFireAudioEntity >= 0) cAudioManager::SetEntityStatus(m_nFireAudioEntity, 1); + + m_nCollisionEntity = CreateEntity(AUDIOTYPE_COLLISION, (CPhysical *)1); + if(m_nCollisionEntity >= 0) cAudioManager::SetEntityStatus(m_nCollisionEntity, 1); + + m_nFrontEndEntity = CreateEntity(AUDIOTYPE_FRONTEND, (CPhysical *)1); + if(m_nFrontEndEntity >= 0) cAudioManager::SetEntityStatus(m_nFrontEndEntity, 1); + + m_nProjectileEntity = CreateEntity(AUDIOTYPE_PROJECTILE, (CPhysical *)1); + if(m_nProjectileEntity >= 0) cAudioManager::SetEntityStatus(m_nProjectileEntity, 1); + + m_nWaterCannonEntity = CreateEntity(AUDIOTYPE_WATER_CANNON, (CPhysical *)1); + if(m_nWaterCannonEntity >= 0) cAudioManager::SetEntityStatus(m_nWaterCannonEntity, 1); + + m_nPoliceChannelEntity = CreateEntity(AUDIOTYPE_D, (CPhysical *)1); + if(m_nPoliceChannelEntity >= 0) cAudioManager::SetEntityStatus(m_nPoliceChannelEntity, 1); + + m_nBridgeEntity = CreateEntity(AUDIOTYPE_BRIDGE, (CPhysical *)1); + if(m_nBridgeEntity >= 0) cAudioManager::SetEntityStatus(m_nBridgeEntity, 1); + + m_sMissionAudio.m_nSampleIndex = NO_SAMPLE; + m_sMissionAudio.m_bLoadingStatus = 0; + m_sMissionAudio.m_bPlayStatus = 0; + m_sMissionAudio.field_22 = 0; + m_sMissionAudio.m_bIsPlayed = 0; + m_sMissionAudio.field_12 = 1; + m_sMissionAudio.field_24 = 0; + ResetAudioLogicTimers((int32)CTimer::GetTimeInMilliseconds); +} + +WRAPPER +void +cAudioManager::InitialisePoliceRadioZones() +{ + EAXJMP(0x57EAC0); +} + +WRAPPER +void +cAudioManager::ResetAudioLogicTimers(int32 timer) +{ + EAXJMP(0x569650); +} + +void +cAudioManager::Terminate() +{ + if(m_bIsInitialised) { + MusicManager.Terminate(); + + for(uint32 i = 0; i < totalAudioEntitiesSlots; i++) { + m_asAudioEntities[i].m_bIsUsed = 0; + m_anAudioEntityIndices[i] = 200; + } + + m_nAudioEntitiesTotal = 0; + m_nScriptObjectEntityTotal = 0; + PreTerminateGameSpecificShutdown(); + + for(uint32 i = 0; i < 2; i++) { + if(cSampleManager.IsSampleBankLoaded(i)) cSampleManager.UnloadSampleBank(i); + } + + cSampleManager.Terminate(); + + m_bIsInitialised = 0; + PostTerminateGameSpecificShutdown(); + } +} + char cAudioManager::GetMissionScriptPoliceAudioPlayingStatus() { @@ -469,17 +565,17 @@ cAudioManager::IsAudioInitialised() const } int32 -cAudioManager::CreateEntity(int32 type, CPhysical *memory) +cAudioManager::CreateEntity(int32 type, CPhysical *entity) { if(!m_bIsInitialised) return -4; - if(!memory) return -2; + if(!entity) return -2; if(type >= TOTAL_AUDIO_TYPES) return -1; for(uint32 i = 0; i < 200; i++) { if(!m_asAudioEntities[i].m_bIsUsed) { m_asAudioEntities[i].m_bIsUsed = true; m_asAudioEntities[i].m_bStatus = 0; m_asAudioEntities[i].m_nType = (eAudioType)type; - m_asAudioEntities[i].m_pEntity = memory; + m_asAudioEntities[i].m_pEntity = entity; m_asAudioEntities[i].m_awAudioEvent[0] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[1] = SOUND_TOTAL_PED_SOUNDS; m_asAudioEntities[i].m_awAudioEvent[2] = SOUND_TOTAL_PED_SOUNDS; @@ -2720,6 +2816,12 @@ cAudioManager::Service() } STARTPATCHES +InjectHook(0x57A0E0, &cAudioManager::Initialise, PATCH_JUMP); +InjectHook(0x569420, &cAudioManager::PostInitialiseGameSpecificSetup, PATCH_JUMP); +//InjectHook(0x57EAC0, &cAudioManager::InitialisePoliceRadioZones, PATCH_JUMP); +//InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); +InjectHook(0x57A150, &cAudioManager::Terminate, PATCH_JUMP); + InjectHook(0x57F050, &cAudioManager::GetMissionScriptPoliceAudioPlayingStatus, PATCH_JUMP); InjectHook(0x5795D0, &cAudioManager::GetMissionAudioLoadingStatus, PATCH_JUMP); diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h index 24dae2ce..9796c1c8 100644 --- a/src/audio/AudioManager.h +++ b/src/audio/AudioManager.h @@ -218,6 +218,15 @@ public: char field_19195; int m_nTimeOfRecentCrime; + void Initialise(); + void PostInitialiseGameSpecificSetup(); + void InitialisePoliceRadioZones(); // @todo + void ResetAudioLogicTimers(int32 timer); // @todo + + void Terminate(); + + // done + char GetMissionScriptPoliceAudioPlayingStatus(); bool GetMissionAudioLoadingStatus(); @@ -282,8 +291,6 @@ public: void InitialisePoliceRadio(); - // done - int32 RandomDisplacement(uint32 seed); void ReleaseDigitalHandle(); @@ -292,7 +299,7 @@ public: bool IsAudioInitialised() const; - int32 CreateEntity(int32 type, CPhysical *memory); + int32 CreateEntity(int32 type, CPhysical *entity); void DestroyEntity(int32 id); void SetEntityStatus(int32 id, bool status); diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp index 7b7c1182..dcd4ae93 100644 --- a/src/audio/MusicManager.cpp +++ b/src/audio/MusicManager.cpp @@ -174,3 +174,17 @@ void cMusicManager::DisplayRadioStationName() } } #endif + +WRAPPER +void +cMusicManager::Initialise() +{ + EAXJMP(0x57CF70); +} + +WRAPPER +void +cMusicManager::Terminate() +{ + EAXJMP(0x57D140); +} diff --git a/src/audio/MusicManager.h b/src/audio/MusicManager.h index dcb34daf..944fd16e 100644 --- a/src/audio/MusicManager.h +++ b/src/audio/MusicManager.h @@ -264,6 +264,9 @@ public: uint8 field_2395; public: + void Initialise(); + void Terminate(); + char *Get3DProviderName(char); bool PlayerInCar(); void DisplayRadioStationName(); diff --git a/src/audio/SampleManager.cpp b/src/audio/SampleManager.cpp index 7af3446b..fbeb49ed 100644 --- a/src/audio/SampleManager.cpp +++ b/src/audio/SampleManager.cpp @@ -12,6 +12,33 @@ bool CSampleManager::IsMP3RadioChannelAvailable() { return nNumOfMp3Files != 0; } +WRAPPER +bool CSampleManager::IsSampleBankLoaded(uint8) { EAXJMP(0x567130); } + +WRAPPER +void CSampleManager::UnloadSampleBank(uint8) { EAXJMP(0x567110); } + +WRAPPER +void +CSampleManager::Terminate() +{ + EAXJMP(0x566DC0); +} + +WRAPPER +bool +CSampleManager::Initialise() +{ + EAXJMP(0x566530); +} + +WRAPPER +int32 +CSampleManager::GetActiveSamples() +{ + EAXJMP(0x565970); +} + WRAPPER void CSampleManager::ReleaseDigitalHandle() { @@ -87,6 +114,7 @@ CSampleManager::StopChannel(int32 id) { EAXJMP(0x567BE0); } + STARTPATCHES InjectHook(0x566490, CSampleManager::IsMP3RadioChannelAvailable, PATCH_JUMP); ENDPATCHES
\ No newline at end of file diff --git a/src/audio/SampleManager.h b/src/audio/SampleManager.h index 1bee1775..f0245d4e 100644 --- a/src/audio/SampleManager.h +++ b/src/audio/SampleManager.h @@ -11,6 +11,13 @@ struct tSample { class CSampleManager { public: + bool IsSampleBankLoaded(uint8); + void UnloadSampleBank(uint8); + void Terminate(); + + bool Initialise(); + int32 GetActiveSamples(); + void ReleaseDigitalHandle(); void RequireDigitalHandle(); |