diff options
author | Sergeanur <s.anureev@yandex.ua> | 2020-05-27 02:29:54 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2020-05-27 02:29:54 +0200 |
commit | 408faf8a663672030682d15c5c85cd17dba85cf1 (patch) | |
tree | 0f565542461fe3b6185a3a0632c03b5109c0693d /src/audio/sampman_miles.cpp | |
parent | Merge pull request #553 from Sergeanur/VC/audio (diff) | |
download | re3-408faf8a663672030682d15c5c85cd17dba85cf1.tar re3-408faf8a663672030682d15c5c85cd17dba85cf1.tar.gz re3-408faf8a663672030682d15c5c85cd17dba85cf1.tar.bz2 re3-408faf8a663672030682d15c5c85cd17dba85cf1.tar.lz re3-408faf8a663672030682d15c5c85cd17dba85cf1.tar.xz re3-408faf8a663672030682d15c5c85cd17dba85cf1.tar.zst re3-408faf8a663672030682d15c5c85cd17dba85cf1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/sampman_miles.cpp | 61 |
1 files changed, 56 insertions, 5 deletions
diff --git a/src/audio/sampman_miles.cpp b/src/audio/sampman_miles.cpp index d625ac35..63e89cac 100644 --- a/src/audio/sampman_miles.cpp +++ b/src/audio/sampman_miles.cpp @@ -264,10 +264,63 @@ set_new_provider(S32 index) return false; } +U32 RadioHandlers[9]; + +U32 WINAPI vfs_open_callback(char const* Filename, U32* FileHandle) +{ + *FileHandle = (U32)fopen(Filename, "rb"); + + // couldn't they just use stricmp once? and strlen? this is very inefficient + if ((strcmp(Filename + strlen(Filename) - 4, ".adf") == 0) || (strcmp(Filename + strlen(Filename) - 4, ".ADF") == 0)) { + for (int i = 0; i < ARRAY_SIZE(RadioHandlers); i++) { + if (RadioHandlers[i] == NULL) { + RadioHandlers[i] = *FileHandle; + break; + } + } + strcpy((char*)Filename + strlen(Filename) - 4, ".mp3"); + } + return *FileHandle; +} + +void WINAPI vfs_close_callback(U32 FileHandle) +{ + for (int i = 0; i < ARRAY_SIZE(RadioHandlers); i++) { + if (RadioHandlers[i] == FileHandle) { + RadioHandlers[i] = NULL; + break; + } + } + fclose((FILE*)FileHandle); +} + +S32 WINAPI vfs_seek_callback(U32 FileHandle, S32 Offset, U32 Type) +{ + fseek((FILE*)FileHandle, Offset, Type); + return ftell((FILE*)FileHandle); +} + +U32 WINAPI vfs_read_callback(U32 FileHandle, void* Buffer, U32 Bytes) +{ + fread(Buffer, Bytes, 1, (FILE*)FileHandle); + uint8* _Buffer = (uint8*)Buffer; + + for (int i = 0; i < ARRAY_SIZE(RadioHandlers); i++) { + if (FileHandle == RadioHandlers[i]) { + for (U32 k = 0; k < Bytes; k++) + _Buffer[k] ^= 0x22; + break; + } + } + return Bytes; +} + cSampleManager::cSampleManager(void) : m_nNumberOfProviders(0) { ; + + AIL_set_file_callbacks(vfs_open_callback, vfs_close_callback, vfs_seek_callback, vfs_read_callback); } cSampleManager::~cSampleManager(void) @@ -1500,7 +1553,7 @@ cSampleManager::LoadPedComment(uint32 nComment) case MUSICMODE_FRONTEND: { - if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_GAME_COMPLETED ) + if ( MusicManager.GetCurrentTrack() == STREAMED_SOUND_CUTSCENE_FINALE ) return false; break; @@ -1739,8 +1792,7 @@ cSampleManager::SetChannelEmittingVolume(uint32 nChannel, uint32 nVolume) // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_FINALE ) { nChannelVolume[nChannel] >>= 2; } @@ -1778,8 +1830,7 @@ cSampleManager::SetChannelVolume(uint32 nChannel, uint32 nVolume) // increase the volume for JB.MP3 and S4_BDBD.MP3 if ( MusicManager.GetMusicMode() == MUSICMODE_CUTSCENE - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_NEWS_INTRO - && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_SAL4_BDBD ) + && MusicManager.GetCurrentTrack() != STREAMED_SOUND_CUTSCENE_FINALE ) { nChannelVolume[nChannel] >>= 2; } |