summaryrefslogtreecommitdiffstats
path: root/src/audio/sampman_oal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/sampman_oal.cpp')
-rw-r--r--src/audio/sampman_oal.cpp71
1 files changed, 52 insertions, 19 deletions
diff --git a/src/audio/sampman_oal.cpp b/src/audio/sampman_oal.cpp
index 4122e9ff..5b05269b 100644
--- a/src/audio/sampman_oal.cpp
+++ b/src/audio/sampman_oal.cpp
@@ -92,7 +92,7 @@ OggOpusFile *fpSampleDataHandle;
#else
FILE *fpSampleDataHandle;
#endif
-bool8 bSampleBankLoaded [MAX_SFX_BANKS];
+bool8 bSampleBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS];
uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS];
@@ -102,10 +102,11 @@ int32 nPedSlotSfx [MAX_PEDSFX];
int32 nPedSlotSfxAddr[MAX_PEDSFX];
uint8 nCurrentPedSlot;
-#ifdef FIX_BUGS
+uint32 nMissionSlotSfx[MISSION_AUDIO_SLOTS] = { UINT32_MAX, UINT32_MAX };
+uintptr nMissionSlotSfxStartAddress;
+
uint32 gPlayerTalkSfx = UINT32_MAX;
void *gPlayerTalkData = 0;
-#endif
CChannel aChannel[NUM_CHANNELS];
uint8 nChannelVolume[NUM_CHANNELS];
@@ -1053,7 +1054,9 @@ cSampleManager::Initialise(void)
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
-#ifdef FIX_BUGS
+ nMissionSlotSfxStartAddress = (uintptr)malloc(MISSION_AUDIO_BLOCKSIZE*MISSION_AUDIO_SLOTS);
+ ASSERT(nMissionSlotSfxStartAddress != 0);
+
// Find biggest player comment
uint32 nMaxPedSize = 0;
for (uint32 i = PLAYER_COMMENTS_START; i <= PLAYER_COMMENTS_END; i++)
@@ -1061,7 +1064,6 @@ cSampleManager::Initialise(void)
gPlayerTalkData = malloc(nMaxPedSize);
ASSERT(gPlayerTalkData != 0);
-#endif
LoadSampleBank(SFX_BANK_0);
}
@@ -1223,13 +1225,20 @@ cSampleManager::Terminate(void)
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
}
-#ifdef FIX_BUGS
+ if ( nMissionSlotSfxStartAddress != 0 )
+ {
+ free((void*)nMissionSlotSfxStartAddress);
+ nMissionSlotSfxStartAddress = 0;
+
+ for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ )
+ nMissionSlotSfx[i] = UINT32_MAX;
+ }
+
if ( gPlayerTalkData != 0 )
{
free(gPlayerTalkData);
gPlayerTalkData = 0;
}
-#endif
_bSampmanInitialised = FALSE;
}
@@ -1355,32 +1364,50 @@ 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;
+ ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
+
+ switch (nSlot)
+ {
+ case MISSION_AUDIO_SLOT_1:
+ case MISSION_AUDIO_SLOT_2:
+ return nMissionSlotSfx[nSlot] == nSample;
+ case MISSION_AUDIO_PLAYER_COMMENT:
+ return nSample == gPlayerTalkSfx;
+ }
+ return FALSE;
}
bool8
cSampleManager::LoadMissionAudio(uint8 nSlot, uint32 nSample)
{
- ASSERT(nSlot == MISSION_AUDIO_PLAYER_COMMENT); // only MISSION_AUDIO_PLAYER_COMMENT is supported on PC
+ ASSERT(nSlot != MISSION_AUDIO_POLRADIO_CRIME_OR_COLOR && nSlot != MISSION_AUDIO_POLRADIO_AREA_OR_CAR); // these are not used in LCS
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;
+ switch (nSlot)
+ {
+ case MISSION_AUDIO_SLOT_1:
+ case MISSION_AUDIO_SLOT_2:
+ if (fread((void*)(nMissionSlotSfxStartAddress + nSlot*MISSION_AUDIO_BLOCKSIZE), 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
+ return FALSE;
+
+ nMissionSlotSfx[nSlot] = nSample;
+ break;
+ case MISSION_AUDIO_PLAYER_COMMENT:
+ if (fread(gPlayerTalkData, 1, m_aSamples[nSample].nSize, fpSampleDataHandle) != m_aSamples[nSample].nSize)
+ return FALSE;
- gPlayerTalkSfx = nSample;
+ gPlayerTalkSfx = nSample;
+ break;
+ }
return TRUE;
}
-#endif
bool8
cSampleManager::IsPedCommentLoaded(uint32 nComment)
@@ -1616,7 +1643,6 @@ 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) )
@@ -1624,16 +1650,23 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
addr = (uintptr)gPlayerTalkData;
}
-#endif
else
{
+ for ( uint32 i = 0; i < MISSION_AUDIO_SLOTS; i++ ) {
+ if ( IsMissionAudioLoaded(i, nSfx) ) {
+ addr = nMissionSlotSfxStartAddress + i * MISSION_AUDIO_BLOCKSIZE;
+ goto MissionAudioFound;
+ }
+ }
+
if ( !IsPedCommentLoaded(nSfx) )
return FALSE;
int32 slot = _GetPedCommentSlot(nSfx);
addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot);
}
-
+
+MissionAudioFound:
if ( GetChannelUsedFlag(nChannel) )
{
TRACE("Stopping channel %d - really!!!", nChannel);