diff --git a/include/sound_ids.h b/include/sound_ids.h index f946e90a..20cd036c 100644 --- a/include/sound_ids.h +++ b/include/sound_ids.h @@ -6,6 +6,9 @@ #define SOUND_VOICE_CHARACTER_POSITIVE SOUND_VOICE_KRUNCH_POSITIVE1 #define SOUND_VOICE_CHARACTER_NEGATIVE SOUND_VOICE_KRUNCH_NEGATIVE1 +/// Cannot stress enough that these names are very temporary, preliminary, expendable and other words that imply that they are not final. +// Also might be worth thinking of a better way of laying this out, because scrolling through hundreds of sound ID's isn't particularly pleasant. + // Anything I've labelled as UNK, without a comment, is something I didn't get an audible sound from. enum SoundID { SOUND_UNK0, diff --git a/src/racer.c b/src/racer.c index dee43107..832c998d 100644 --- a/src/racer.c +++ b/src/racer.c @@ -1635,29 +1635,35 @@ void func_800570A4(Object *obj, s32 arg1, s32 arg2) { temp->unk210 = arg2; } -void func_800570B8(Object *obj, s32 soundID, s32 arg2, s32 arg3) { - s32 temp_v1; - Object_64 *temp_s2; +/** + * Play a random character voice clip from the given offset. + * It uses SOUND_VOICE_CHARACTER_POSITIVE and SOUND_VOICE_CHARACTER_NEGATIVE for + * acceptable offsets. Range will always be 8, because that's how many ID's for each + * there are. + */ +void func_800570B8(Object *obj, s32 soundID, s32 range, s32 arg3) { + s32 soundIndex; + Object_64 *tempRacer; - temp_s2 = obj->unk64; - if ((temp_s2->racer.unk108 == 0) && ((!(arg3 & 0x80)) || (D_8011D55C != -1))) { + tempRacer = obj->unk64; + if (tempRacer->racer.unk108 == 0 && ((!(arg3 & 0x80)) || D_8011D55C != -1)) { if (arg3 == 2) { - if ((temp_s2->racer.unk24 != 0) && (soundID != temp_s2->racer.unk2A)) { - func_800096F8(temp_s2->racer.unk24); - temp_s2->racer.unk24 = 0; + if ((tempRacer->racer.unk24 != 0) && (soundID != tempRacer->racer.unk2A)) { + func_800096F8(tempRacer->racer.unk24); + tempRacer->racer.unk24 = 0; } } - if ((temp_s2->racer.unk24 == 0) && ((arg3 != 3) || (get_random_number_from_range(0, 1) != 0))) { - temp_s2->racer.unk2A = soundID; - soundID += temp_s2->racer.characterId; - temp_v1 = (get_random_number_from_range(0, arg2 - 1) * 12) + soundID; - if (arg2 - 1 > 0) { - while (temp_v1 == temp_s2->racer.unk28) { - temp_v1 = (get_random_number_from_range(0, arg2 - 1) * 12) + soundID; + if (tempRacer->racer.unk24 == 0 && (arg3 != 3 || get_random_number_from_range(0, 1))) { + tempRacer->racer.unk2A = soundID; + soundID += tempRacer->racer.characterId; + soundIndex = (get_random_number_from_range(0, range - 1) * 12) + soundID; + if (range - 1 > 0) { + while (soundIndex == tempRacer->racer.unk28) { + soundIndex = (get_random_number_from_range(0, range - 1) * 12) + soundID; } } - func_80009558(temp_v1, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, &temp_s2->racer.unk24); - temp_s2->racer.unk28 = temp_v1; + func_80009558(soundIndex, obj->segment.trans.x_position, obj->segment.trans.y_position, obj->segment.trans.z_position, 4, &tempRacer->racer.unk24); + tempRacer->racer.unk28 = soundIndex; } } } diff --git a/src/racer.h b/src/racer.h index 008c657e..ffe17f06 100644 --- a/src/racer.h +++ b/src/racer.h @@ -224,7 +224,7 @@ s32 func_80052388(Object *obj1, Object_Racer *racer, Object *obj2, f32 distance) void func_80055A84(Object *obj, Object_Racer *racer, s32 arg2); void func_8005C270(Object_Racer *racer); f32 handle_racer_top_speed(Object *obj, Object_Racer *racer); -void func_800570B8(Object *obj, s32 soundID, s32 arg2, s32 arg3); +void func_800570B8(Object *obj, s32 soundID, s32 range, s32 arg3); void apply_vehicle_rotation_offset(Object_Racer *obj, s32 max, s16 yRotation, s16 xRotation, s16 zRotation); void func_80059080(Object *obj, Object_Racer *racer, f32 *velX, f32 *velY, f32 *velZ); void func_80054110(Object *obj, Object_Racer *racer, s32 updateRate, f32 arg3);