Skip to content

Commit

Permalink
Fix EarTrans assignment (#2057)
Browse files Browse the repository at this point in the history
and some slight cleaning
  • Loading branch information
Ziemas committed Dec 22, 2022
1 parent 1b2db09 commit 4edec27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion game/overlord/srpc.cpp
Expand Up @@ -634,7 +634,7 @@ void* RPC_Player2(unsigned int /*fno*/, void* data, int size) {
// TODO reverb
} break;
case Jak2SoundCommand::set_ear_trans: {
SetEarTrans(&cmd->ear_trans_j2.ear_trans1, &cmd->ear_trans_j2.ear_trans2,
SetEarTrans(&cmd->ear_trans_j2.ear_trans0, &cmd->ear_trans_j2.ear_trans1,
&cmd->ear_trans_j2.cam_trans, cmd->ear_trans_j2.cam_angle);
} break;
case Jak2SoundCommand::shutdown: {
Expand Down
2 changes: 1 addition & 1 deletion game/overlord/srpc.h
Expand Up @@ -152,7 +152,7 @@ struct SoundRpcSetEarTrans {

struct SoundRpc2SetEarTrans {
Vec3w ear_trans1;
Vec3w ear_trans2;
Vec3w ear_trans0;
Vec3w cam_trans;
s32 cam_angle;
};
Expand Down
26 changes: 9 additions & 17 deletions game/overlord/ssound.cpp
Expand Up @@ -13,7 +13,7 @@
using namespace iop;

Sound gSounds[64];
Curve gCurve[12]; // TODO verify count
Curve gCurve[16];
VolumePair gPanTable[361];

Vec3w gEarTrans[2];
Expand Down Expand Up @@ -285,15 +285,7 @@ s32 CalculateFallofVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
s32 min = fo_min << 8;
s32 max = fo_max << 8;

if (max < xdiff) {
return 0;
}

if (max < ydiff) {
return 0;
}

if (max < zdiff) {
if (max < xdiff || max < ydiff || max < zdiff) {
return 0;
}

Expand Down Expand Up @@ -494,13 +486,13 @@ void UpdateVolume(Sound* sound) {
}
}

void SetEarTrans(Vec3w* ear_trans1, Vec3w* ear_trans2, Vec3w* cam_trans, s32 cam_angle) {
void SetEarTrans(Vec3w* ear_trans0, Vec3w* ear_trans1, Vec3w* cam_trans, s32 cam_angle) {
s32 tick = snd_GetTick();
u32 delta = tick - sLastTick;
sLastTick = tick;

gEarTrans[0] = *ear_trans1;
gEarTrans[1] = *ear_trans2;
gEarTrans[0] = *ear_trans0;
gEarTrans[1] = *ear_trans1;
gCamTrans = *cam_trans;
gCamAngle = cam_angle;

Expand Down Expand Up @@ -543,10 +535,10 @@ void PrintActiveSounds() {
}
}

void SetCurve(s32 curve, s32 fallof, s32 ease) {
gCurve[curve].unk1 = ease << 1;
gCurve[curve].unk2 = fallof + ease * -3;
gCurve[curve].unk3 = (ease - fallof) + -0x1000;
void SetCurve(s32 curve, s32 falloff, s32 ease) {
gCurve[curve].unk1 = ease * 2;
gCurve[curve].unk2 = falloff - 3 * ease;
gCurve[curve].unk3 = ease - falloff - 0x1000;
gCurve[curve].unk4 = 0x1000;
}

Expand Down

0 comments on commit 4edec27

Please sign in to comment.