diff options
Diffstat (limited to '')
-rw-r--r-- | src/audio/sampman_oal.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp index 0f0cc8c8..4122e9ff 100644 --- a/src/audio/sampman_oal.cpp +++ b/src/audio/sampman_oal.cpp @@ -102,6 +102,11 @@ int32 nPedSlotSfx [MAX_PEDSFX]; int32 nPedSlotSfxAddr[MAX_PEDSFX]; uint8 nCurrentPedSlot; +#ifdef FIX_BUGS +uint32 gPlayerTalkSfx = UINT32_MAX; +void *gPlayerTalkData = 0; +#endif + CChannel aChannel[NUM_CHANNELS]; uint8 nChannelVolume[NUM_CHANNELS]; @@ -1047,7 +1052,17 @@ cSampleManager::Initialise(void) nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); - + +#ifdef FIX_BUGS + // Find biggest player comment + uint32 nMaxPedSize = 0; + for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++) + nMaxPedSize = Max(nMaxPedSize, m_aSamples[i].nSize); + + gPlayerTalkData = malloc(nMaxPedSize); + ASSERT(gPlayerTalkData != 0); +#endif + LoadSampleBank(SFX_BANK_0); } @@ -1207,6 +1222,14 @@ cSampleManager::Terminate(void) free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; } + +#ifdef FIX_BUGS + if ( gPlayerTalkData != 0 ) + { + free(gPlayerTalkData); + gPlayerTalkData = 0; + } +#endif _bSampmanInitialised = FALSE; } @@ -1332,6 +1355,33 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank) return bSampleBankLoaded[nBank]; } +#ifdef FIX_BUGS +bool8 +cSampleManager::IsMissionAudioLoaded(uint8 nSlot, uint32 nSample) +{ + ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC + + return nSample == gPlayerTalkSfx; +} + +bool8 +cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample) +{ + ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC + ASSERT(nSample < TOTAL_AUDIO_SAMPLES); + + if (fseek(fpSampleDataHandle, m_aSamples[nSample].nOffset, SEEK_SET) != 0) + return FALSE; + + if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize) + return FALSE; + + gPlayerTalkSfx = nSample; + + return TRUE; +} +#endif + bool8 cSampleManager::IsPedCommentLoaded(uint32 nComment) { @@ -1566,6 +1616,15 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank) addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; } +#ifdef FIX_BUGS + else if ( nSfx >= PLAYER_COMMENTS_START && nSfx <= PLAYER_COMMENTS_END ) + { + if ( !IsMissionAudioLoaded(MISSION_AUDIO_PLAYER_COMMENT, nSfx) ) + return FALSE; + + addr = (uintptr)gPlayerTalkData; + } +#endif else { if ( !IsPedCommentLoaded(nSfx) ) @@ -2087,7 +2146,7 @@ cSampleManager::InitialiseSampleBanks(void) fclose(fpSampleDescHandle); fpSampleDescHandle = NULL; - for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) + for ( uint32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) { #ifdef FIX_BUGS if (nBank >= MAX_SFX_BANKS) break; |