Use PS2-y global names on SampMan

This commit is contained in:
erorcun 2021-06-27 17:53:14 +03:00
parent a923728877
commit 091a65996e
6 changed files with 273 additions and 273 deletions

View File

@ -58,69 +58,69 @@ enum LOADING_STATUS { LOADING_STATUS_NOT_LOADED = 0, LOADING_STATUS_LOADED, LOAD
void void
cAudioManager::PreInitialiseGameSpecificSetup() const cAudioManager::PreInitialiseGameSpecificSetup() const
{ {
BankStartOffset[SFX_BANK_0] = SAMPLEBANK_START; gBankStartOffset[SFX_BANK_0] = SAMPLEBANK_START;
#ifdef GTA_PS2 #ifdef GTA_PS2
BankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1; gBankStartOffset[SFX_BANK_PACARD] = SFX_CAR_ACCEL_1;
BankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2; gBankStartOffset[SFX_BANK_PATHFINDER] = SFX_CAR_ACCEL_2;
BankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3; gBankStartOffset[SFX_BANK_PORSCHE] = SFX_CAR_ACCEL_3;
BankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4; gBankStartOffset[SFX_BANK_SPIDER] = SFX_CAR_ACCEL_4;
BankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5; gBankStartOffset[SFX_BANK_MERC] = SFX_CAR_ACCEL_5;
BankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6; gBankStartOffset[SFX_BANK_TRUCK] = SFX_CAR_ACCEL_6;
BankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7; gBankStartOffset[SFX_BANK_HOTROD] = SFX_CAR_ACCEL_7;
BankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8; gBankStartOffset[SFX_BANK_COBRA] = SFX_CAR_ACCEL_8;
BankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9; gBankStartOffset[SFX_BANK_NONE] = SFX_CAR_ACCEL_9;
BankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT; gBankStartOffset[SFX_BANK_FRONT_END_MENU] = SFX_PAGE_CHANGE_AND_BACK_LEFT;
BankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP; gBankStartOffset[SFX_BANK_TRAIN] = SFX_TRAIN_STATION_AMBIENCE_LOOP;
BankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1; gBankStartOffset[SFX_BANK_BUILDING_CLUB_1] = SFX_CLUB_1;
BankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2; gBankStartOffset[SFX_BANK_BUILDING_CLUB_2] = SFX_CLUB_2;
BankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3; gBankStartOffset[SFX_BANK_BUILDING_CLUB_3] = SFX_CLUB_3;
BankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4; gBankStartOffset[SFX_BANK_BUILDING_CLUB_4] = SFX_CLUB_4;
BankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5; gBankStartOffset[SFX_BANK_BUILDING_CLUB_5] = SFX_CLUB_5;
BankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6; gBankStartOffset[SFX_BANK_BUILDING_CLUB_6] = SFX_CLUB_6;
BankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7; gBankStartOffset[SFX_BANK_BUILDING_CLUB_7] = SFX_CLUB_7;
BankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8; gBankStartOffset[SFX_BANK_BUILDING_CLUB_8] = SFX_CLUB_8;
BankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9; gBankStartOffset[SFX_BANK_BUILDING_CLUB_9] = SFX_CLUB_9;
BankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10; gBankStartOffset[SFX_BANK_BUILDING_CLUB_10] = SFX_CLUB_10;
BankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11; gBankStartOffset[SFX_BANK_BUILDING_CLUB_11] = SFX_CLUB_11;
BankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12; gBankStartOffset[SFX_BANK_BUILDING_CLUB_12] = SFX_CLUB_12;
BankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA; gBankStartOffset[SFX_BANK_BUILDING_CLUB_RAGGA] = SFX_CLUB_RAGGA;
BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1; gBankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_1] = SFX_STRIP_CLUB_1;
BankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2; gBankStartOffset[SFX_BANK_BUILDING_STRIP_CLUB_2] = SFX_STRIP_CLUB_2;
BankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1; gBankStartOffset[SFX_BANK_BUILDING_WORKSHOP] = SFX_WORKSHOP_1;
BankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1; gBankStartOffset[SFX_BANK_BUILDING_PIANO_BAR] = SFX_PIANO_BAR_1;
BankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP; gBankStartOffset[SFX_BANK_BUILDING_SAWMILL] = SFX_SAWMILL_LOOP;
BankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY; gBankStartOffset[SFX_BANK_BUILDING_DOG_FOOD_FACTORY] = SFX_DOG_FOOD_FACTORY;
BankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP; gBankStartOffset[SFX_BANK_BUILDING_LAUNDERETTE] = SFX_LAUNDERETTE_LOOP;
BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN; gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_CHINATOWN] = SFX_RESTAURANT_CHINATOWN;
BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY; gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_ITALY] = SFX_RESTAURANT_ITALY;
BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1; gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_1] = SFX_RESTAURANT_GENERIC_1;
BankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2; gBankStartOffset[SFX_BANK_BUILDING_RESTAURANT_GENERIC_2] = SFX_RESTAURANT_GENERIC_2;
BankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1; gBankStartOffset[SFX_BANK_BUILDING_AIRPORT] = SFX_AIRPORT_ANNOUNCEMENT_1;
BankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP; gBankStartOffset[SFX_BANK_BUILDING_SHOP] = SFX_SHOP_LOOP;
BankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1; gBankStartOffset[SFX_BANK_BUILDING_CINEMA] = SFX_CINEMA_BASS_1;
BankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN; gBankStartOffset[SFX_BANK_BUILDING_DOCKS] = SFX_DOCKS_FOGHORN;
BankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1; gBankStartOffset[SFX_BANK_BUILDING_HOME] = SFX_HOME_1;
BankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP; gBankStartOffset[SFX_BANK_BUILDING_PORN_1] = SFX_PORN_1_LOOP;
BankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP; gBankStartOffset[SFX_BANK_BUILDING_PORN_2] = SFX_PORN_2_LOOP;
BankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP; gBankStartOffset[SFX_BANK_BUILDING_PORN_3] = SFX_PORN_3_LOOP;
BankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1; gBankStartOffset[SFX_BANK_BUILDING_POLICE_BALL] = SFX_POLICE_BALL_1;
BankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1; gBankStartOffset[SFX_BANK_BUILDING_BANK_ALARM] = SFX_BANK_ALARM_1;
BankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL; gBankStartOffset[SFX_BANK_BUILDING_RAVE_INDUSTRIAL] = SFX_RAVE_INDUSTRIAL;
BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL; gBankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL] = SFX_RAVE_COMMERCIAL;
BankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN; gBankStartOffset[SFX_BANK_BUILDING_RAVE_SUBURBAN] = SFX_RAVE_SUBURBAN;
BankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2; gBankStartOffset[SFX_BANK_BUILDING_RAVE_COMMERCIAL_2] = SFX_RAVE_COMMERCIAL_2;
BankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1; gBankStartOffset[SFX_BANK_BUILDING_39] = SFX_CLUB_1_1;
BankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2; gBankStartOffset[SFX_BANK_BUILDING_40] = SFX_CLUB_1_2;
BankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3; gBankStartOffset[SFX_BANK_BUILDING_41] = SFX_CLUB_1_3;
BankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4; gBankStartOffset[SFX_BANK_BUILDING_42] = SFX_CLUB_1_4;
BankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5; gBankStartOffset[SFX_BANK_BUILDING_43] = SFX_CLUB_1_5;
BankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6; gBankStartOffset[SFX_BANK_BUILDING_44] = SFX_CLUB_1_6;
BankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7; gBankStartOffset[SFX_BANK_BUILDING_45] = SFX_CLUB_1_7;
BankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8; gBankStartOffset[SFX_BANK_BUILDING_46] = SFX_CLUB_1_8;
BankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9; gBankStartOffset[SFX_BANK_BUILDING_47] = SFX_CLUB_1_9;
BankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1; gBankStartOffset[SFX_BANK_GENERIC_EXTRA] = SFX_EXPLOSION_1;
#endif // GTA_PS2 #endif // GTA_PS2
BankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START; gBankStartOffset[SFX_BANK_PED_COMMENTS] = SAMPLEBANK_PED_START;
} }
void void

View File

@ -17,7 +17,7 @@ bool bChannelsCreated = false;
int32 CChannel::channelsThatNeedService = 0; int32 CChannel::channelsThatNeedService = 0;
uint8 tempStereoBuffer[PED_BLOCKSIZE * 2]; uint8 tempStereoBuffer[PED_BUFFERSIZE * 2];
void void
CChannel::InitChannels() CChannel::InitChannels()

View File

@ -96,7 +96,7 @@ enum
}; };
#define MAX_PEDSFX 7 #define MAX_PEDSFX 7
#define PED_BLOCKSIZE 79000 #define PED_BUFFERSIZE 79000
#define MAXPROVIDERS 64 #define MAXPROVIDERS 64
@ -130,7 +130,7 @@ class cSampleManager
bool8 m_bInitialised; bool8 m_bInitialised;
uint8 m_nNumberOfProviders; uint8 m_nNumberOfProviders;
char *m_aAudioProviders[MAXPROVIDERS]; char *m_aAudioProviders[MAXPROVIDERS];
tSample m_aSamples[TOTAL_AUDIO_SAMPLES]; tSample m_aSampleDataTable[TOTAL_AUDIO_SAMPLES];
public: public:
@ -217,7 +217,7 @@ public:
}; };
extern cSampleManager SampleManager; extern cSampleManager SampleManager;
extern uint32 BankStartOffset[MAX_SFX_BANKS]; extern uint32 gBankStartOffset[MAX_SFX_BANKS];
#ifdef AUDIO_OAL #ifdef AUDIO_OAL
extern int defaultProvider; extern int defaultProvider;

View File

@ -20,27 +20,27 @@
#pragma comment( lib, "mss32.lib" ) #pragma comment( lib, "mss32.lib" )
cSampleManager SampleManager; cSampleManager SampleManager;
uint32 BankStartOffset[MAX_SFX_BANKS]; uint32 gBankStartOffset[MAX_SFX_BANKS];
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
char SampleBankDescFilename[] = "AUDIO\\SFX.SDT"; char SampleBankDescFilename[] = "AUDIO\\SFX.SDT";
char SampleBankDataFilename[] = "AUDIO\\SFX.RAW"; char SampleBankDataFilename[] = "AUDIO\\SFX.RAW";
FILE *fpSampleDescHandle; FILE *gFileHandleSampleDesc;
FILE *fpSampleDataHandle; FILE *gFileHandleSampleData;
bool8 bSampleBankLoaded [MAX_SFX_BANKS]; bool8 gBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; int32 gSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS]; int32 gSampleBankSize [MAX_SFX_BANKS];
int32 nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; int32 gSampleBankMemoryStartAddress[MAX_SFX_BANKS];
int32 _nSampleDataEndOffset; int32 _nSampleDataEndOffset;
int32 nPedSlotSfx [MAX_PEDSFX]; int32 gPedSfx [MAX_PEDSFX];
int32 nPedSlotSfxAddr[MAX_PEDSFX]; int32 gPedSfxAddr[MAX_PEDSFX];
uint8 nCurrentPedSlot; uint8 gCurPedIndex;
uint8 nChannelVolume[MAXCHANNELS+MAX2DCHANNELS]; uint8 gChannelVolume[MAXCHANNELS+MAX2DCHANNELS];
uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; uint32 gStreamLength[TOTAL_STREAMED_SOUNDS];
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
struct tMP3Entry struct tMP3Entry
@ -851,11 +851,11 @@ cSampleManager::Initialise(void)
{ {
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
{ {
m_aSamples[i].nOffset = 0; m_aSampleDataTable[i].nOffset = 0;
m_aSamples[i].nSize = 0; m_aSampleDataTable[i].nSize = 0;
m_aSamples[i].nFrequency = 22050; m_aSampleDataTable[i].nFrequency = 22050;
m_aSamples[i].nLoopStart = 0; m_aSampleDataTable[i].nLoopStart = 0;
m_aSamples[i].nLoopEnd = -1; m_aSampleDataTable[i].nLoopEnd = -1;
} }
m_nEffectsVolume = MAX_VOLUME; m_nEffectsVolume = MAX_VOLUME;
@ -890,17 +890,17 @@ cSampleManager::Initialise(void)
// banks // banks
TRACE("banks"); TRACE("banks");
{ {
fpSampleDescHandle = NULL; gFileHandleSampleDesc = NULL;
fpSampleDataHandle = NULL; gFileHandleSampleData = NULL;
_nSampleDataEndOffset = 0; _nSampleDataEndOffset = 0;
for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) for ( int32 i = 0; i < MAX_SFX_BANKS; i++ )
{ {
bSampleBankLoaded[i] = FALSE; gBankLoaded[i] = FALSE;
nSampleBankDiscStartOffset[i] = 0; gSampleBankDiscStartOffset[i] = 0;
nSampleBankSize[i] = 0; gSampleBankSize[i] = 0;
nSampleBankMemoryStartAddress[i] = 0; gSampleBankMemoryStartAddress[i] = 0;
} }
} }
@ -909,18 +909,18 @@ cSampleManager::Initialise(void)
{ {
for ( int32 i = 0; i < MAX_PEDSFX; i++ ) for ( int32 i = 0; i < MAX_PEDSFX; i++ )
{ {
nPedSlotSfx[i] = NO_SAMPLE; gPedSfx[i] = NO_SAMPLE;
nPedSlotSfxAddr[i] = 0; gPedSfxAddr[i] = 0;
} }
nCurrentPedSlot = 0; gCurPedIndex = 0;
} }
// channel volume // channel volume
TRACE("vol"); TRACE("vol");
{ {
for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ ) for ( int32 i = 0; i < MAXCHANNELS+MAX2DCHANNELS; i++ )
nChannelVolume[i] = 0; gChannelVolume[i] = 0;
} }
TRACE("mss"); TRACE("mss");
@ -947,14 +947,14 @@ cSampleManager::Initialise(void)
return FALSE; return FALSE;
} }
nSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(nSampleBankSize[SFX_BANK_0]); gSampleBankMemoryStartAddress[SFX_BANK_0] = (int32)AIL_mem_alloc_lock(gSampleBankSize[SFX_BANK_0]);
if ( !nSampleBankMemoryStartAddress[SFX_BANK_0] ) if ( !gSampleBankMemoryStartAddress[SFX_BANK_0] )
{ {
Terminate(); Terminate();
return FALSE; return FALSE;
} }
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BLOCKSIZE*MAX_PEDSFX); gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (int32)AIL_mem_alloc_lock(PED_BUFFERSIZE*MAX_PEDSFX);
} }
@ -962,7 +962,7 @@ cSampleManager::Initialise(void)
TRACE("cache"); TRACE("cache");
FILE *cacheFile = fopen("audio\\sound.cache", "rb"); FILE *cacheFile = fopen("audio\\sound.cache", "rb");
if (cacheFile) { if (cacheFile) {
fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fread(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile); fclose(cacheFile);
m_bInitialised = TRUE; m_bInitialised = TRUE;
}else { }else {
@ -1016,7 +1016,7 @@ cSampleManager::Initialise(void)
AIL_close_stream(mp3Stream[0]); AIL_close_stream(mp3Stream[0]);
mp3Stream[0] = NULL; mp3Stream[0] = NULL;
nStreamLength[i] = tatalms; gStreamLength[i] = tatalms;
} }
else else
{ {
@ -1115,7 +1115,7 @@ cSampleManager::Initialise(void)
strcpy(m_szCDRomRootPath, rootpath); strcpy(m_szCDRomRootPath, rootpath);
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
nStreamLength[i] = streamLength[i]; gStreamLength[i] = streamLength[i];
_bUseHDDAudio = TRUE; _bUseHDDAudio = TRUE;
} }
@ -1125,7 +1125,7 @@ cSampleManager::Initialise(void)
#endif #endif
#ifdef AUDIO_CACHE #ifdef AUDIO_CACHE
cacheFile = fopen("audio\\sound.cache", "wb"); cacheFile = fopen("audio\\sound.cache", "wb");
fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fwrite(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile); fclose(cacheFile);
} }
#endif #endif
@ -1188,12 +1188,12 @@ cSampleManager::Initialise(void)
if ( nNumMP3s != 0 ) if ( nNumMP3s != 0 )
{ {
nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0;
for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext )
{ {
e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; e->nTrackStreamPos = gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER];
nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength;
} }
time_t t = time(NULL); time_t t = time(NULL);
@ -1270,16 +1270,16 @@ cSampleManager::Terminate(void)
_DeleteMP3Entries(); _DeleteMP3Entries();
if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) if ( gSampleBankMemoryStartAddress[SFX_BANK_0] != 0 )
{ {
AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); AIL_mem_free_lock((void *)gSampleBankMemoryStartAddress[SFX_BANK_0]);
nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; gSampleBankMemoryStartAddress[SFX_BANK_0] = 0;
} }
if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) if ( gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 )
{ {
AIL_mem_free_lock((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); AIL_mem_free_lock((void *)gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]);
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
} }
if ( DIG ) if ( DIG )
@ -1363,10 +1363,10 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff
{ {
if ( opened_samples[i] && GetChannelUsedFlag(i) ) if ( opened_samples[i] && GetChannelUsedFlag(i) )
{ {
if ( nChannelVolume[i] ) if ( gChannelVolume[i] )
{ {
AIL_set_3D_sample_volume(opened_samples[i], AIL_set_3D_sample_volume(opened_samples[i],
m_nEffectsFadeVolume * nChannelVolume[i] * m_nEffectsVolume >> 14); m_nEffectsFadeVolume * gChannelVolume[i] * m_nEffectsVolume >> 14);
} }
} }
} }
@ -1376,10 +1376,10 @@ cSampleManager::UpdateEffectsVolume(void) //[Y], cSampleManager::UpdateSoundBuff
{ {
if ( GetChannelUsedFlag(i - MAXCHANNELS) ) if ( GetChannelUsedFlag(i - MAXCHANNELS) )
{ {
if ( nChannelVolume[i - MAXCHANNELS] ) if ( gChannelVolume[i - MAXCHANNELS] )
{ {
AIL_set_sample_volume(opened_2dsamples[i - MAXCHANNELS], AIL_set_sample_volume(opened_2dsamples[i - MAXCHANNELS],
m_nEffectsFadeVolume * nChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14); m_nEffectsFadeVolume * gChannelVolume[i - MAXCHANNELS] * m_nEffectsVolume >> 14);
} }
} }
} }
@ -1433,13 +1433,13 @@ cSampleManager::LoadSampleBank(uint8 nBank)
return FALSE; return FALSE;
} }
if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) if ( fseek(gFileHandleSampleData, gSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 )
return FALSE; return FALSE;
if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank],fpSampleDataHandle) != nSampleBankSize[nBank] ) if ( fread((void *)gSampleBankMemoryStartAddress[nBank], 1, gSampleBankSize[nBank],gFileHandleSampleData) != gSampleBankSize[nBank] )
return FALSE; return FALSE;
bSampleBankLoaded[nBank] = TRUE; gBankLoaded[nBank] = TRUE;
return TRUE; return TRUE;
} }
@ -1447,13 +1447,13 @@ cSampleManager::LoadSampleBank(uint8 nBank)
void void
cSampleManager::UnloadSampleBank(uint8 nBank) cSampleManager::UnloadSampleBank(uint8 nBank)
{ {
bSampleBankLoaded[nBank] = FALSE; gBankLoaded[nBank] = FALSE;
} }
bool8 bool8
cSampleManager::IsSampleBankLoaded(uint8 nBank) cSampleManager::IsSampleBankLoaded(uint8 nBank)
{ {
return bSampleBankLoaded[nBank]; return gBankLoaded[nBank];
} }
bool8 bool8
@ -1463,12 +1463,12 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
slot = nCurrentPedSlot - i - 1; slot = gCurPedIndex - i - 1;
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (slot < 0) if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx); slot += ARRAY_SIZE(gPedSfx);
#endif #endif
if ( nComment == nPedSlotSfx[slot] ) if ( nComment == gPedSfx[slot] )
return TRUE; return TRUE;
} }
@ -1482,12 +1482,12 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment)
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
slot = nCurrentPedSlot - i - 1; slot = gCurPedIndex - i - 1;
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (slot < 0) if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx); slot += ARRAY_SIZE(gPedSfx);
#endif #endif
if ( nComment == nPedSlotSfx[slot] ) if ( nComment == gPedSfx[slot] )
return slot; return slot;
} }
@ -1522,17 +1522,17 @@ cSampleManager::LoadPedComment(uint32 nComment)
} }
} }
if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) if ( fseek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset, SEEK_SET) != 0 )
return FALSE; return FALSE;
if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) if ( fread((void *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex), 1, m_aSampleDataTable[nComment].nSize, gFileHandleSampleData) != m_aSampleDataTable[nComment].nSize )
return FALSE; return FALSE;
nPedSlotSfxAddr[nCurrentPedSlot] = nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot; gPedSfxAddr[gCurPedIndex] = gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex;
nPedSlotSfx [nCurrentPedSlot] = nComment; gPedSfx [gCurPedIndex] = nComment;
if ( ++nCurrentPedSlot >= MAX_PEDSFX ) if ( ++gCurPedIndex >= MAX_PEDSFX )
nCurrentPedSlot = 0; gCurPedIndex = 0;
return TRUE; return TRUE;
} }
@ -1540,10 +1540,10 @@ cSampleManager::LoadPedComment(uint32 nComment)
int32 int32
cSampleManager::GetBankContainingSound(uint32 offset) cSampleManager::GetBankContainingSound(uint32 offset)
{ {
if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) if ( offset >= gBankStartOffset[SFX_BANK_PED_COMMENTS] )
return SFX_BANK_PED_COMMENTS; return SFX_BANK_PED_COMMENTS;
if ( offset >= BankStartOffset[SFX_BANK_0] ) if ( offset >= gBankStartOffset[SFX_BANK_0] )
return SFX_BANK_0; return SFX_BANK_0;
return INVALID_SFX_BANK; return INVALID_SFX_BANK;
@ -1552,25 +1552,25 @@ cSampleManager::GetBankContainingSound(uint32 offset)
int32 int32
cSampleManager::GetSampleBaseFrequency(uint32 nSample) cSampleManager::GetSampleBaseFrequency(uint32 nSample)
{ {
return m_aSamples[nSample].nFrequency; return m_aSampleDataTable[nSample].nFrequency;
} }
int32 int32
cSampleManager::GetSampleLoopStartOffset(uint32 nSample) cSampleManager::GetSampleLoopStartOffset(uint32 nSample)
{ {
return m_aSamples[nSample].nLoopStart; return m_aSampleDataTable[nSample].nLoopStart;
} }
int32 int32
cSampleManager::GetSampleLoopEndOffset(uint32 nSample) cSampleManager::GetSampleLoopEndOffset(uint32 nSample)
{ {
return m_aSamples[nSample].nLoopEnd; return m_aSampleDataTable[nSample].nLoopEnd;
} }
uint32 uint32
cSampleManager::GetSampleLength(uint32 nSample) cSampleManager::GetSampleLength(uint32 nSample)
{ {
return m_aSamples[nSample].nSize >> 1; return m_aSampleDataTable[nSample].nSize >> 1;
} }
bool8 bool8
@ -1700,7 +1700,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
if ( !IsSampleBankLoaded(nBank) ) if ( !IsSampleBankLoaded(nBank) )
return FALSE; return FALSE;
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; addr = gSampleBankMemoryStartAddress[nBank] + m_aSampleDataTable[nSfx].nOffset - m_aSampleDataTable[gBankStartOffset[nBank]].nOffset;
} }
else else
{ {
@ -1709,14 +1709,14 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
int32 slot = _GetPedCommentSlot(nSfx); int32 slot = _GetPedCommentSlot(nSfx);
addr = nPedSlotSfxAddr[slot]; addr = gPedSfxAddr[slot];
} }
if ( b2d ) if ( b2d )
{ {
if ( opened_2dsamples[nChannel - MAXCHANNELS] ) if ( opened_2dsamples[nChannel - MAXCHANNELS] )
{ {
AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSamples[nSfx].nSize); AIL_set_sample_address(opened_2dsamples[nChannel - MAXCHANNELS], (void *)addr, m_aSampleDataTable[nSfx].nSize);
return TRUE; return TRUE;
} }
else else
@ -1729,8 +1729,8 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
info.format = WAVE_FORMAT_PCM; info.format = WAVE_FORMAT_PCM;
info.data_ptr = (void *)addr; info.data_ptr = (void *)addr;
info.channels = 1; info.channels = 1;
info.data_len = m_aSamples[nSfx].nSize; info.data_len = m_aSampleDataTable[nSfx].nSize;
info.rate = m_aSamples[nSfx].nFrequency; info.rate = m_aSampleDataTable[nSfx].nFrequency;
info.bits = 16; info.bits = 16;
if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 ) if ( AIL_set_3D_sample_info(opened_samples[nChannel], &info) == 0 )
@ -1749,18 +1749,18 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
uint32 vol = nVolume; uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
nChannelVolume[nChannel] = vol; gChannelVolume[nChannel] = vol;
// increase the volume for JB.MP3 and S4_BDBD.MP3 // increase the volume for JB.MP3 and S4_BDBD.MP3
if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE
&& MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO
&& MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD )
{ {
nChannelVolume[nChannel] >>= 2; gChannelVolume[nChannel] >>= 2;
} }
if ( opened_samples[nChannel] ) if ( opened_samples[nChannel] )
AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); AIL_set_3D_sample_volume(opened_samples[nChannel], m_nEffectsFadeVolume*gChannelVolume[nChannel]*m_nEffectsVolume >> 14);
} }
@ -1788,14 +1788,14 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
{ {
case CHANNEL_POLICE_RADIO: case CHANNEL_POLICE_RADIO:
{ {
nChannelVolume[nChannel] = vol; gChannelVolume[nChannel] = vol;
// increase the volume for JB.MP3 and S4_BDBD.MP3 // increase the volume for JB.MP3 and S4_BDBD.MP3
if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE
&& MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO
&& MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD )
{ {
nChannelVolume[nChannel] >>= 2; gChannelVolume[nChannel] >>= 2;
} }
if ( opened_2dsamples[nChannel - MAXCHANNELS] ) if ( opened_2dsamples[nChannel - MAXCHANNELS] )
@ -2065,7 +2065,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
// Just switched to MP3 player // Just switched to MP3 player
if ( !_bIsMp3Active && i == 0 ) if ( !_bIsMp3Active && i == 0 )
{ {
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) if ( nPos > gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0; position = 0;
tMP3Entry *e = _pMP3List; tMP3Entry *e = _pMP3List;
@ -2253,7 +2253,7 @@ int32
cSampleManager::GetStreamedFileLength(uint8 nStream) cSampleManager::GetStreamedFileLength(uint8 nStream)
{ {
if ( m_bInitialised ) if ( m_bInitialised )
return nStreamLength[nStream]; return gStreamLength[nStream];
return 0; return 0;
} }
@ -2280,42 +2280,42 @@ cSampleManager::InitialiseSampleBanks(void)
{ {
int32 nBank = SFX_BANK_0; int32 nBank = SFX_BANK_0;
fpSampleDescHandle = fopen(SampleBankDescFilename, "rb"); gFileHandleSampleDesc = fopen(SampleBankDescFilename, "rb");
if ( fpSampleDescHandle == NULL ) if ( gFileHandleSampleDesc == NULL )
return FALSE; return FALSE;
fpSampleDataHandle = fopen(SampleBankDataFilename, "rb"); gFileHandleSampleData = fopen(SampleBankDataFilename, "rb");
if ( fpSampleDataHandle == NULL ) if ( gFileHandleSampleData == NULL )
{ {
fclose(fpSampleDescHandle); fclose(gFileHandleSampleDesc);
fpSampleDescHandle = NULL; gFileHandleSampleDesc = NULL;
return FALSE; return FALSE;
} }
fseek(fpSampleDataHandle, 0, SEEK_END); fseek(gFileHandleSampleData, 0, SEEK_END);
_nSampleDataEndOffset = ftell(fpSampleDataHandle); _nSampleDataEndOffset = ftell(gFileHandleSampleData);
rewind(fpSampleDataHandle); rewind(gFileHandleSampleData);
fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); fread(m_aSampleDataTable, sizeof(tSample), TOTAL_AUDIO_SAMPLES, gFileHandleSampleDesc);
fclose(fpSampleDescHandle); fclose(gFileHandleSampleDesc);
fpSampleDescHandle = NULL; gFileHandleSampleDesc = NULL;
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
{ {
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (nBank >= MAX_SFX_BANKS) break; if (nBank >= MAX_SFX_BANKS) break;
#endif #endif
if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) if ( gBankStartOffset[nBank] == gBankStartOffset[SFX_BANK_0] + i )
{ {
nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; gSampleBankDiscStartOffset[nBank] = m_aSampleDataTable[i].nOffset;
nBank++; nBank++;
} }
} }
nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; gSampleBankSize[SFX_BANK_0] = gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - gSampleBankDiscStartOffset[SFX_BANK_0];
nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; gSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS];
return TRUE; return TRUE;
} }

View File

@ -6,7 +6,7 @@
cSampleManager SampleManager; cSampleManager SampleManager;
bool8 _bSampmanInitialised = FALSE; bool8 _bSampmanInitialised = FALSE;
uint32 BankStartOffset[MAX_SFX_BANKS]; uint32 gBankStartOffset[MAX_SFX_BANKS];
uint32 nNumMP3s; uint32 nNumMP3s;
cSampleManager::cSampleManager(void) cSampleManager::cSampleManager(void)

View File

@ -47,9 +47,9 @@
//TODO: fix eax3 reverb //TODO: fix eax3 reverb
cSampleManager SampleManager; cSampleManager SampleManager;
bool8 _bSampmanInitialised = FALSE; bool8 gInitialised = FALSE;
uint32 BankStartOffset[MAX_SFX_BANKS]; uint32 gBankStartOffset[MAX_SFX_BANKS];
int prevprovider=-1; int prevprovider=-1;
int curprovider=-1; int curprovider=-1;
@ -79,26 +79,26 @@ int defaultProvider;
char SampleBankDescFilename[] = "audio/sfx.SDT"; char SampleBankDescFilename[] = "audio/sfx.SDT";
char SampleBankDataFilename[] = "audio/sfx.RAW"; char SampleBankDataFilename[] = "audio/sfx.RAW";
FILE *fpSampleDescHandle; FILE *gFileHandleSampleDesc;
#ifdef OPUS_SFX #ifdef OPUS_SFX
OggOpusFile *fpSampleDataHandle; OggOpusFile *gFileHandleSampleData;
#else #else
FILE *fpSampleDataHandle; FILE *gFileHandleSampleData;
#endif #endif
bool8 bSampleBankLoaded [MAX_SFX_BANKS]; bool8 gBankLoaded [MAX_SFX_BANKS];
int32 nSampleBankDiscStartOffset [MAX_SFX_BANKS]; int32 gSampleBankDiscStartOffset [MAX_SFX_BANKS];
int32 nSampleBankSize [MAX_SFX_BANKS]; int32 gSampleBankSize [MAX_SFX_BANKS];
uintptr nSampleBankMemoryStartAddress[MAX_SFX_BANKS]; uintptr gSampleBankMemoryStartAddress[MAX_SFX_BANKS];
int32 _nSampleDataEndOffset; int32 _nSampleDataEndOffset;
int32 nPedSlotSfx [MAX_PEDSFX]; int32 gPedSfx [MAX_PEDSFX];
int32 nPedSlotSfxAddr[MAX_PEDSFX]; int32 gPedSfxAddr[MAX_PEDSFX];
uint8 nCurrentPedSlot; uint8 gCurPedIndex;
CChannel aChannel[NUM_CHANNELS]; CChannel aChannel[NUM_CHANNELS];
uint8 nChannelVolume[NUM_CHANNELS]; uint8 gChannelVolume[NUM_CHANNELS];
uint32 nStreamLength[TOTAL_STREAMED_SOUNDS]; uint32 gStreamLength[TOTAL_STREAMED_SOUNDS];
ALuint ALStreamSources[MAX_STREAMS][2]; ALuint ALStreamSources[MAX_STREAMS][2];
ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS]; ALuint ALStreamBuffers[MAX_STREAMS][NUM_STREAMBUFFERS];
@ -779,7 +779,7 @@ void cSampleManager::ReacquireDigitalHandle(void)
bool8 bool8
cSampleManager::Initialise(void) cSampleManager::Initialise(void)
{ {
if ( _bSampmanInitialised ) if ( gInitialised )
return TRUE; return TRUE;
EFXInit(); EFXInit();
@ -788,11 +788,11 @@ cSampleManager::Initialise(void)
{ {
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
{ {
m_aSamples[i].nOffset = 0; m_aSampleDataTable[i].nOffset = 0;
m_aSamples[i].nSize = 0; m_aSampleDataTable[i].nSize = 0;
m_aSamples[i].nFrequency = 22050; m_aSampleDataTable[i].nFrequency = 22050;
m_aSamples[i].nLoopStart = 0; m_aSampleDataTable[i].nLoopStart = 0;
m_aSamples[i].nLoopEnd = -1; m_aSampleDataTable[i].nLoopEnd = -1;
} }
m_nEffectsVolume = MAX_VOLUME; m_nEffectsVolume = MAX_VOLUME;
@ -820,31 +820,31 @@ cSampleManager::Initialise(void)
} }
{ {
fpSampleDescHandle = NULL; gFileHandleSampleDesc = NULL;
fpSampleDataHandle = NULL; gFileHandleSampleData = NULL;
for ( int32 i = 0; i < MAX_SFX_BANKS; i++ ) for ( int32 i = 0; i < MAX_SFX_BANKS; i++ )
{ {
bSampleBankLoaded[i] = FALSE; gBankLoaded[i] = FALSE;
nSampleBankDiscStartOffset[i] = 0; gSampleBankDiscStartOffset[i] = 0;
nSampleBankSize[i] = 0; gSampleBankSize[i] = 0;
nSampleBankMemoryStartAddress[i] = 0; gSampleBankMemoryStartAddress[i] = 0;
} }
} }
{ {
for ( int32 i = 0; i < MAX_PEDSFX; i++ ) for ( int32 i = 0; i < MAX_PEDSFX; i++ )
{ {
nPedSlotSfx[i] = NO_SAMPLE; gPedSfx[i] = NO_SAMPLE;
nPedSlotSfxAddr[i] = 0; gPedSfxAddr[i] = 0;
} }
nCurrentPedSlot = 0; gCurPedIndex = 0;
} }
{ {
for ( int32 i = 0; i < NUM_CHANNELS; i++ ) for ( int32 i = 0; i < NUM_CHANNELS; i++ )
nChannelVolume[i] = 0; gChannelVolume[i] = 0;
} }
add_providers(); add_providers();
@ -922,14 +922,14 @@ cSampleManager::Initialise(void)
{ {
for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ ) for ( int32 i = 0; i < TOTAL_STREAMED_SOUNDS; i++ )
nStreamLength[i] = 0; gStreamLength[i] = 0;
} }
#ifdef AUDIO_CACHE #ifdef AUDIO_CACHE
FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb"); FILE *cacheFile = fcaseopen("audio\\sound.cache", "rb");
if (cacheFile) { if (cacheFile) {
debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n"); debug("Loadind audio cache (If game crashes around here, then your cache is corrupted, remove audio/sound.cache)\n");
fread(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fread(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile); fclose(cacheFile);
} else } else
{ {
@ -944,7 +944,7 @@ cSampleManager::Initialise(void)
delete aStream[0]; delete aStream[0];
aStream[0] = NULL; aStream[0] = NULL;
nStreamLength[i] = tatalms; gStreamLength[i] = tatalms;
} else } else
USERERROR("Can't open '%s'\n", StreamedNameTable[i]); USERERROR("Can't open '%s'\n", StreamedNameTable[i]);
} }
@ -952,7 +952,7 @@ cSampleManager::Initialise(void)
cacheFile = fcaseopen("audio\\sound.cache", "wb"); cacheFile = fcaseopen("audio\\sound.cache", "wb");
if(cacheFile) { if(cacheFile) {
debug("Saving audio cache\n"); debug("Saving audio cache\n");
fwrite(nStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile); fwrite(gStreamLength, sizeof(uint32), TOTAL_STREAMED_SOUNDS, cacheFile);
fclose(cacheFile); fclose(cacheFile);
} else { } else {
debug("Cannot save audio cache\n"); debug("Cannot save audio cache\n");
@ -967,17 +967,17 @@ cSampleManager::Initialise(void)
return FALSE; return FALSE;
} }
nSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(nSampleBankSize[SFX_BANK_0]); gSampleBankMemoryStartAddress[SFX_BANK_0] = (uintptr)malloc(gSampleBankSize[SFX_BANK_0]);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_0] != 0); ASSERT(gSampleBankMemoryStartAddress[SFX_BANK_0] != 0);
if ( nSampleBankMemoryStartAddress[SFX_BANK_0] == 0 ) if ( gSampleBankMemoryStartAddress[SFX_BANK_0] == 0 )
{ {
Terminate(); Terminate();
return FALSE; return FALSE;
} }
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BLOCKSIZE*MAX_PEDSFX); gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = (uintptr)malloc(PED_BUFFERSIZE*MAX_PEDSFX);
ASSERT(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0); ASSERT(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0);
LoadSampleBank(SFX_BANK_0); LoadSampleBank(SFX_BANK_0);
} }
@ -992,7 +992,7 @@ cSampleManager::Initialise(void)
} }
{ {
_bSampmanInitialised = TRUE; gInitialised = TRUE;
if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders ) if ( defaultProvider >= 0 && defaultProvider < m_nNumberOfProviders )
{ {
@ -1014,12 +1014,12 @@ cSampleManager::Initialise(void)
if ( nNumMP3s != 0 ) if ( nNumMP3s != 0 )
{ {
nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0; gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] = 0;
for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext ) for ( tMP3Entry *e = _pMP3List; e != NULL; e = e->pNext )
{ {
e->nTrackStreamPos = nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER]; e->nTrackStreamPos = gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER];
nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength; gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] += e->nTrackLength;
} }
time_t t = time(NULL); time_t t = time(NULL);
@ -1130,19 +1130,19 @@ cSampleManager::Terminate(void)
CStream::Terminate(); CStream::Terminate();
if ( nSampleBankMemoryStartAddress[SFX_BANK_0] != 0 ) if ( gSampleBankMemoryStartAddress[SFX_BANK_0] != 0 )
{ {
free((void *)nSampleBankMemoryStartAddress[SFX_BANK_0]); free((void *)gSampleBankMemoryStartAddress[SFX_BANK_0]);
nSampleBankMemoryStartAddress[SFX_BANK_0] = 0; gSampleBankMemoryStartAddress[SFX_BANK_0] = 0;
} }
if ( nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 ) if ( gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] != 0 )
{ {
free((void *)nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]); free((void *)gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS]);
nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0; gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] = 0;
} }
_bSampmanInitialised = FALSE; gInitialised = FALSE;
} }
bool8 cSampleManager::CheckForAnAudioFileOnCD(void) bool8 cSampleManager::CheckForAnAudioFileOnCD(void)
@ -1158,14 +1158,14 @@ char cSampleManager::GetCDAudioDriveLetter(void)
void void
cSampleManager::UpdateEffectsVolume(void) cSampleManager::UpdateEffectsVolume(void)
{ {
if ( _bSampmanInitialised ) if ( gInitialised )
{ {
for ( int32 i = 0; i < NUM_CHANNELS; i++ ) for ( int32 i = 0; i < NUM_CHANNELS; i++ )
{ {
if ( GetChannelUsedFlag(i) ) if ( GetChannelUsedFlag(i) )
{ {
if ( nChannelVolume[i] != 0 ) if ( gChannelVolume[i] != 0 )
aChannel[i].SetVolume(m_nEffectsFadeVolume*nChannelVolume[i]*m_nEffectsVolume >> 14); aChannel[i].SetVolume(m_nEffectsFadeVolume*gChannelVolume[i]*m_nEffectsVolume >> 14);
} }
} }
} }
@ -1220,10 +1220,10 @@ cSampleManager::LoadSampleBank(uint8 nBank)
#ifdef OPUS_SFX #ifdef OPUS_SFX
int samplesRead = 0; int samplesRead = 0;
int samplesSize = nSampleBankSize[nBank] / 2; int samplesSize = gSampleBankSize[nBank] / 2;
op_pcm_seek(fpSampleDataHandle, 0); op_pcm_seek(gFileHandleSampleData, 0);
while (samplesSize > 0) { while (samplesSize > 0) {
int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL); int size = op_read(gFileHandleSampleData, (opus_int16 *)(gSampleBankMemoryStartAddress[nBank] + samplesRead), samplesSize, NULL);
if (size <= 0) { if (size <= 0) {
// huh? // huh?
//assert(0); //assert(0);
@ -1233,13 +1233,13 @@ cSampleManager::LoadSampleBank(uint8 nBank)
samplesSize -= size; samplesSize -= size;
} }
#else #else
if ( fseek(fpSampleDataHandle, nSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 ) if ( fseek(gFileHandleSampleData, gSampleBankDiscStartOffset[nBank], SEEK_SET) != 0 )
return FALSE; return FALSE;
if ( fread((void *)nSampleBankMemoryStartAddress[nBank], 1, nSampleBankSize[nBank], fpSampleDataHandle) != nSampleBankSize[nBank] ) if ( fread((void *)gSampleBankMemoryStartAddress[nBank], 1, gSampleBankSize[nBank], gFileHandleSampleData) != gSampleBankSize[nBank] )
return FALSE; return FALSE;
#endif #endif
bSampleBankLoaded[nBank] = TRUE; gBankLoaded[nBank] = TRUE;
return TRUE; return TRUE;
} }
@ -1249,7 +1249,7 @@ cSampleManager::UnloadSampleBank(uint8 nBank)
{ {
ASSERT( nBank < MAX_SFX_BANKS); ASSERT( nBank < MAX_SFX_BANKS);
bSampleBankLoaded[nBank] = FALSE; gBankLoaded[nBank] = FALSE;
} }
bool8 bool8
@ -1257,7 +1257,7 @@ cSampleManager::IsSampleBankLoaded(uint8 nBank)
{ {
ASSERT( nBank < MAX_SFX_BANKS); ASSERT( nBank < MAX_SFX_BANKS);
return bSampleBankLoaded[nBank]; return gBankLoaded[nBank];
} }
bool8 bool8
@ -1269,12 +1269,12 @@ cSampleManager::IsPedCommentLoaded(uint32 nComment)
for ( int32 i = 0; i < _TODOCONST(3); i++ ) for ( int32 i = 0; i < _TODOCONST(3); i++ )
{ {
slot = nCurrentPedSlot - i - 1; slot = gCurPedIndex - i - 1;
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (slot < 0) if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx); slot += ARRAY_SIZE(gPedSfx);
#endif #endif
if ( nComment == nPedSlotSfx[slot] ) if ( nComment == gPedSfx[slot] )
return TRUE; return TRUE;
} }
@ -1289,12 +1289,12 @@ cSampleManager::_GetPedCommentSlot(uint32 nComment)
for (int32 i = 0; i < _TODOCONST(3); i++) for (int32 i = 0; i < _TODOCONST(3); i++)
{ {
slot = nCurrentPedSlot - i - 1; slot = gCurPedIndex - i - 1;
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (slot < 0) if (slot < 0)
slot += ARRAY_SIZE(nPedSlotSfx); slot += ARRAY_SIZE(gPedSfx);
#endif #endif
if (nComment == nPedSlotSfx[slot]) if (nComment == gPedSfx[slot])
return slot; return slot;
} }
@ -1333,10 +1333,10 @@ cSampleManager::LoadPedComment(uint32 nComment)
#ifdef OPUS_SFX #ifdef OPUS_SFX
int samplesRead = 0; int samplesRead = 0;
int samplesSize = m_aSamples[nComment].nSize / 2; int samplesSize = m_aSampleDataTable[nComment].nSize / 2;
op_pcm_seek(fpSampleDataHandle, m_aSamples[nComment].nOffset / 2); op_pcm_seek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset / 2);
while (samplesSize > 0) { while (samplesSize > 0) {
int size = op_read(fpSampleDataHandle, (opus_int16 *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * nCurrentPedSlot + samplesRead), int size = op_read(gFileHandleSampleData, (opus_int16 *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE * gCurPedIndex + samplesRead),
samplesSize, NULL); samplesSize, NULL);
if (size <= 0) { if (size <= 0) {
return FALSE; return FALSE;
@ -1345,17 +1345,17 @@ cSampleManager::LoadPedComment(uint32 nComment)
samplesSize -= size; samplesSize -= size;
} }
#else #else
if ( fseek(fpSampleDataHandle, m_aSamples[nComment].nOffset, SEEK_SET) != 0 ) if ( fseek(gFileHandleSampleData, m_aSampleDataTable[nComment].nOffset, SEEK_SET) != 0 )
return FALSE; return FALSE;
if ( fread((void *)(nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE*nCurrentPedSlot), 1, m_aSamples[nComment].nSize, fpSampleDataHandle) != m_aSamples[nComment].nSize ) if ( fread((void *)(gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE*gCurPedIndex), 1, m_aSampleDataTable[nComment].nSize, gFileHandleSampleData) != m_aSampleDataTable[nComment].nSize )
return FALSE; return FALSE;
#endif #endif
nPedSlotSfx[nCurrentPedSlot] = nComment; gPedSfx[gCurPedIndex] = nComment;
if ( ++nCurrentPedSlot >= MAX_PEDSFX ) if ( ++gCurPedIndex >= MAX_PEDSFX )
nCurrentPedSlot = 0; gCurPedIndex = 0;
return TRUE; return TRUE;
} }
@ -1363,10 +1363,10 @@ cSampleManager::LoadPedComment(uint32 nComment)
int32 int32
cSampleManager::GetBankContainingSound(uint32 offset) cSampleManager::GetBankContainingSound(uint32 offset)
{ {
if ( offset >= BankStartOffset[SFX_BANK_PED_COMMENTS] ) if ( offset >= gBankStartOffset[SFX_BANK_PED_COMMENTS] )
return SFX_BANK_PED_COMMENTS; return SFX_BANK_PED_COMMENTS;
if ( offset >= BankStartOffset[SFX_BANK_0] ) if ( offset >= gBankStartOffset[SFX_BANK_0] )
return SFX_BANK_0; return SFX_BANK_0;
return INVALID_SFX_BANK; return INVALID_SFX_BANK;
@ -1376,28 +1376,28 @@ int32
cSampleManager::GetSampleBaseFrequency(uint32 nSample) cSampleManager::GetSampleBaseFrequency(uint32 nSample)
{ {
ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return m_aSamples[nSample].nFrequency; return m_aSampleDataTable[nSample].nFrequency;
} }
int32 int32
cSampleManager::GetSampleLoopStartOffset(uint32 nSample) cSampleManager::GetSampleLoopStartOffset(uint32 nSample)
{ {
ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return m_aSamples[nSample].nLoopStart; return m_aSampleDataTable[nSample].nLoopStart;
} }
int32 int32
cSampleManager::GetSampleLoopEndOffset(uint32 nSample) cSampleManager::GetSampleLoopEndOffset(uint32 nSample)
{ {
ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return m_aSamples[nSample].nLoopEnd; return m_aSampleDataTable[nSample].nLoopEnd;
} }
uint32 uint32
cSampleManager::GetSampleLength(uint32 nSample) cSampleManager::GetSampleLength(uint32 nSample)
{ {
ASSERT( nSample < TOTAL_AUDIO_SAMPLES ); ASSERT( nSample < TOTAL_AUDIO_SAMPLES );
return m_aSamples[nSample].nSize / sizeof(uint16); return m_aSampleDataTable[nSample].nSize / sizeof(uint16);
} }
bool8 cSampleManager::UpdateReverb(void) bool8 cSampleManager::UpdateReverb(void)
@ -1496,7 +1496,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
if ( !IsSampleBankLoaded(nBank) ) if ( !IsSampleBankLoaded(nBank) )
return FALSE; return FALSE;
addr = nSampleBankMemoryStartAddress[nBank] + m_aSamples[nSfx].nOffset - m_aSamples[BankStartOffset[nBank]].nOffset; addr = gSampleBankMemoryStartAddress[nBank] + m_aSampleDataTable[nSfx].nOffset - m_aSampleDataTable[gBankStartOffset[nBank]].nOffset;
} }
else else
{ {
@ -1504,7 +1504,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
return FALSE; return FALSE;
int32 slot = _GetPedCommentSlot(nSfx); int32 slot = _GetPedCommentSlot(nSfx);
addr = (nSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BLOCKSIZE * slot); addr = (gSampleBankMemoryStartAddress[SFX_BANK_PED_COMMENTS] + PED_BUFFERSIZE * slot);
} }
if ( GetChannelUsedFlag(nChannel) ) if ( GetChannelUsedFlag(nChannel) )
@ -1516,7 +1516,7 @@ cSampleManager::InitialiseChannel(uint32 nChannel, uint32 nSfx, uint8 nBank)
aChannel[nChannel].Reset(); aChannel[nChannel].Reset();
if ( aChannel[nChannel].HasSource() ) if ( aChannel[nChannel].HasSource() )
{ {
aChannel[nChannel].SetSampleData ((void*)addr, m_aSamples[nSfx].nSize, m_aSamples[nSfx].nFrequency); aChannel[nChannel].SetSampleData ((void*)addr, m_aSampleDataTable[nSfx].nSize, m_aSampleDataTable[nSfx].nFrequency);
aChannel[nChannel].SetLoopPoints (0, -1); aChannel[nChannel].SetLoopPoints (0, -1);
aChannel[nChannel].SetPitch (1.0f); aChannel[nChannel].SetPitch (1.0f);
return TRUE; return TRUE;
@ -1533,18 +1533,18 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume)
uint32 vol = nVolume; uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
nChannelVolume[nChannel] = vol; gChannelVolume[nChannel] = vol;
// reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing // reduce channel volume when JB.MP3 or S4_BDBD.MP3 playing
if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE
&& MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO
&& MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD )
{ {
nChannelVolume[nChannel] = vol / 4; gChannelVolume[nChannel] = vol / 4;
} }
// no idea, does this one looks like a bug or it's SetChannelVolume ? // no idea, does this one looks like a bug or it's SetChannelVolume ?
aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*nChannelVolume[nChannel]*m_nEffectsVolume >> 14); aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*gChannelVolume[nChannel]*m_nEffectsVolume >> 14);
} }
void void
@ -1573,14 +1573,14 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume)
uint32 vol = nVolume; uint32 vol = nVolume;
if ( vol > MAX_VOLUME ) vol = MAX_VOLUME; if ( vol > MAX_VOLUME ) vol = MAX_VOLUME;
nChannelVolume[nChannel] = vol; gChannelVolume[nChannel] = vol;
// reduce the volume for JB.MP3 and S4_BDBD.MP3 // reduce the volume for JB.MP3 and S4_BDBD.MP3
if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE
&& MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO && MusicManager.GetNextTrack() != STREAMED_SOUND_NEWS_INTRO
&& MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) && MusicManager.GetNextTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD )
{ {
nChannelVolume[nChannel] = vol / 4; gChannelVolume[nChannel] = vol / 4;
} }
aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14); aChannel[nChannel].SetVolume(m_nEffectsFadeVolume*vol*m_nEffectsVolume >> 14);
@ -1727,7 +1727,7 @@ cSampleManager::StartStreamedFile(uint8 nFile, uint32 nPos, uint8 nStream)
// Switched to MP3 player just now // Switched to MP3 player just now
if ( !_bIsMp3Active && i == 0 ) if ( !_bIsMp3Active && i == 0 )
{ {
if ( nPos > nStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] ) if ( nPos > gStreamLength[STREAMED_SOUND_RADIO_MP3_PLAYER] )
position = 0; position = 0;
tMP3Entry *e = _pMP3List; tMP3Entry *e = _pMP3List;
@ -1935,7 +1935,7 @@ cSampleManager::GetStreamedFileLength(uint8 nStream)
{ {
ASSERT( nStream < TOTAL_STREAMED_SOUNDS ); ASSERT( nStream < TOTAL_STREAMED_SOUNDS );
return nStreamLength[nStream]; return gStreamLength[nStream];
} }
bool8 bool8
@ -1977,47 +1977,47 @@ cSampleManager::InitialiseSampleBanks(void)
{ {
int32 nBank = SFX_BANK_0; int32 nBank = SFX_BANK_0;
fpSampleDescHandle = fcaseopen(SampleBankDescFilename, "rb"); gFileHandleSampleDesc = fcaseopen(SampleBankDescFilename, "rb");
if ( fpSampleDescHandle == NULL ) if ( gFileHandleSampleDesc == NULL )
return FALSE; return FALSE;
#ifndef OPUS_SFX #ifndef OPUS_SFX
fpSampleDataHandle = fcaseopen(SampleBankDataFilename, "rb"); gFileHandleSampleData = fcaseopen(SampleBankDataFilename, "rb");
if ( fpSampleDataHandle == NULL ) if ( gFileHandleSampleData == NULL )
{ {
fclose(fpSampleDescHandle); fclose(gFileHandleSampleDesc);
fpSampleDescHandle = NULL; gFileHandleSampleDesc = NULL;
return FALSE; return FALSE;
} }
fseek(fpSampleDataHandle, 0, SEEK_END); fseek(gFileHandleSampleData, 0, SEEK_END);
int32 _nSampleDataEndOffset = ftell(fpSampleDataHandle); int32 _nSampleDataEndOffset = ftell(gFileHandleSampleData);
rewind(fpSampleDataHandle); rewind(gFileHandleSampleData);
#else #else
int e; int e;
fpSampleDataHandle = op_open_file(SampleBankDataFilename, &e); gFileHandleSampleData = op_open_file(SampleBankDataFilename, &e);
#endif #endif
fread(m_aSamples, sizeof(tSample), TOTAL_AUDIO_SAMPLES, fpSampleDescHandle); fread(m_aSampleDataTable, sizeof(tSample), TOTAL_AUDIO_SAMPLES, gFileHandleSampleDesc);
#ifdef OPUS_SFX #ifdef OPUS_SFX
int32 _nSampleDataEndOffset = m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSamples[TOTAL_AUDIO_SAMPLES - 1].nSize; int32 _nSampleDataEndOffset = m_aSampleDataTable[TOTAL_AUDIO_SAMPLES - 1].nOffset + m_aSampleDataTable[TOTAL_AUDIO_SAMPLES - 1].nSize;
#endif #endif
fclose(fpSampleDescHandle); fclose(gFileHandleSampleDesc);
fpSampleDescHandle = NULL; gFileHandleSampleDesc = NULL;
for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ ) for ( int32 i = 0; i < TOTAL_AUDIO_SAMPLES; i++ )
{ {
#ifdef FIX_BUGS #ifdef FIX_BUGS
if (nBank >= MAX_SFX_BANKS) break; if (nBank >= MAX_SFX_BANKS) break;
#endif #endif
if ( BankStartOffset[nBank] == BankStartOffset[SFX_BANK_0] + i ) if ( gBankStartOffset[nBank] == gBankStartOffset[SFX_BANK_0] + i )
{ {
nSampleBankDiscStartOffset[nBank] = m_aSamples[i].nOffset; gSampleBankDiscStartOffset[nBank] = m_aSampleDataTable[i].nOffset;
nBank++; nBank++;
} }
} }
nSampleBankSize[SFX_BANK_0] = nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - nSampleBankDiscStartOffset[SFX_BANK_0]; gSampleBankSize[SFX_BANK_0] = gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS] - gSampleBankDiscStartOffset[SFX_BANK_0];
nSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - nSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS]; gSampleBankSize[SFX_BANK_PED_COMMENTS] = _nSampleDataEndOffset - gSampleBankDiscStartOffset[SFX_BANK_PED_COMMENTS];
return TRUE; return TRUE;
} }