CheckSound effectively matching

This commit is contained in:
Dethrace Labs 2025-12-03 12:35:36 +13:00 committed by Dethrace Engineering Department
parent 21e2063cce
commit 8844a43f5d
3 changed files with 28 additions and 2 deletions

View File

@ -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@<EAX>(tU32 pTime@<EAX>)

View File

@ -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;

View File

@ -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);