diff --git a/src/DETHRACE/common/piping.c b/src/DETHRACE/common/piping.c index bdb5df6d..f50db0a9 100644 --- a/src/DETHRACE/common/piping.c +++ b/src/DETHRACE/common/piping.c @@ -2229,8 +2229,19 @@ int CheckSound(tPipe_chunk* pChunk_ptr, int pChunk_count, tU32 pTime) { int sound_length; tPipe_chunk* temp_ptr; - STUB_ONCE(); - return 1; + temp_ptr = pChunk_ptr; + for (i = 0; i < pChunk_count; i++) { + sound_length = S3GetSampleLength(temp_ptr->subject_index); + if (temp_ptr->chunk_data.sound_data.pitch > 1) { + sound_length = (double)sound_length / ((double)temp_ptr->chunk_data.sound_data.pitch / 65536.0); + } + if (pTime + sound_length >= gYoungest_time && pTime + sound_length < gOldest_time) { + ApplySound(&temp_ptr); + } else { + AdvanceChunkPtr(&temp_ptr, ePipe_chunk_sound); + } + } + return 0; } // IDA: int __usercall SoundTimeout@(tU32 pTime@) diff --git a/src/S3/s3sound.c b/src/S3/s3sound.c index 07b3c58a..6c771caf 100644 --- a/src/S3/s3sound.c +++ b/src/S3/s3sound.c @@ -286,6 +286,20 @@ int S3ExecuteSampleFilterFuncs(tS3_channel* chan) { return 0; } +// FUNCTION: CARM95 0x004C9577 +int S3GetSampleLength(tS3_sound_tag tag) { + tS3_descriptor* descriptor; + tS3_sample* sound_data; + + descriptor = S3GetDescriptorByID(tag); + if (descriptor) { + sound_data = (tS3_sample*)descriptor->sound_data; + return 1000 * sound_data->size / sound_data->rate; + } else { + return 0; + } +} + int S3PlaySample(tS3_channel* chan) { tS3_sample* sound_data; diff --git a/src/S3/s3sound.h b/src/S3/s3sound.h index 02c63fd8..c2836627 100644 --- a/src/S3/s3sound.h +++ b/src/S3/s3sound.h @@ -15,6 +15,7 @@ int S3CreateTypeStructs(tS3_channel* chan); int S3ReleaseTypeStructs(tS3_channel* chan); int S3StopSample(tS3_channel* chan); int S3ExecuteSampleFilterFuncs(tS3_channel* chan); +int S3GetSampleLength(tS3_sound_tag tag); int S3SyncSampleVolumeAndPan(tS3_channel* chan); int S3SyncSampleRate(tS3_channel* chan);