mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 00:57:44 -04:00
[jak2] fully implement PLAYER set-param
for VAG streams + fix regression (#3314)
At last...
This commit is contained in:
parent
ba7b0397b1
commit
13f1aa1785
|
@ -172,7 +172,7 @@ s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
|
||||||
} else {
|
} else {
|
||||||
if (fo_curve == 1) {
|
if (fo_curve == 1) {
|
||||||
return volume;
|
return volume;
|
||||||
} else if (fo_curve == 9) {
|
} else if (fo_curve == 9 || fo_curve == 11) {
|
||||||
xdiff = gEarTrans[1].x - pos->x;
|
xdiff = gEarTrans[1].x - pos->x;
|
||||||
ydiff = gEarTrans[1].y - pos->y;
|
ydiff = gEarTrans[1].y - pos->y;
|
||||||
zdiff = gEarTrans[1].z - pos->z;
|
zdiff = gEarTrans[1].z - pos->z;
|
||||||
|
@ -180,10 +180,6 @@ s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
|
||||||
xdiff = 0;
|
xdiff = 0;
|
||||||
ydiff = gEarTrans[0].y - pos->y;
|
ydiff = gEarTrans[0].y - pos->y;
|
||||||
zdiff = 0;
|
zdiff = 0;
|
||||||
} else if (fo_curve == 11) {
|
|
||||||
xdiff = gEarTrans[1].x - pos->x;
|
|
||||||
ydiff = gEarTrans[1].y - pos->y;
|
|
||||||
zdiff = gEarTrans[1].z - pos->z;
|
|
||||||
} else {
|
} else {
|
||||||
xdiff = gEarTrans[0].x - pos->x;
|
xdiff = gEarTrans[0].x - pos->x;
|
||||||
ydiff = gEarTrans[0].y - pos->y;
|
ydiff = gEarTrans[0].y - pos->y;
|
||||||
|
@ -213,38 +209,36 @@ s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
|
||||||
ydiff >>= 1;
|
ydiff >>= 1;
|
||||||
zdiff >>= 1;
|
zdiff >>= 1;
|
||||||
}
|
}
|
||||||
s32 dist_squared = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
|
u32 dist_squared = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
|
||||||
s32 dist_steps = 0;
|
s32 dist_steps = 0;
|
||||||
if (dist_squared != 0) {
|
if (dist_squared != 0) {
|
||||||
while ((dist_squared & 0xc0000000) == 0) {
|
while ((dist_squared & 0xc0000000) == 0) {
|
||||||
dist_steps = dist_steps + 1;
|
++dist_steps;
|
||||||
dist_squared <<= 2;
|
dist_squared <<= 2;
|
||||||
}
|
}
|
||||||
dist_steps = sqrt_table[dist_squared >> 24] >> (dist_steps & 0x1f);
|
dist_steps = sqrt_table[dist_squared >> 24] >> (dist_steps & 0x1f);
|
||||||
}
|
}
|
||||||
new_vol = volume;
|
new_vol = volume;
|
||||||
if (min < dist_steps) {
|
if (min < dist_steps) {
|
||||||
s32 voldiff = dist_steps - min;
|
u32 voldiff = dist_steps - min;
|
||||||
if (dist_steps < max) {
|
if (dist_steps < max) {
|
||||||
dist_steps = max - min;
|
dist_steps = max - min;
|
||||||
while (0xffff < voldiff) {
|
while (voldiff > 0xffff) {
|
||||||
dist_steps >>= 1;
|
dist_steps >>= 1;
|
||||||
voldiff >>= 1;
|
voldiff >>= 1;
|
||||||
}
|
}
|
||||||
voldiff = (voldiff << 0x10) / dist_steps;
|
voldiff = (voldiff << 0x10) / dist_steps;
|
||||||
if (voldiff != 0x10000) {
|
if (voldiff != 0x10000) {
|
||||||
new_vol = voldiff * voldiff >> 0x10;
|
new_vol = (voldiff * voldiff) >> 0x10;
|
||||||
new_vol = gCurves[fo_curve].unk4 * 0x10000 + gCurves[fo_curve].unk3 * voldiff +
|
new_vol = (gCurves[fo_curve].unk4 * 0x10000 + gCurves[fo_curve].unk3 * voldiff +
|
||||||
gCurves[fo_curve].unk2 * new_vol +
|
gCurves[fo_curve].unk2 * new_vol +
|
||||||
gCurves[fo_curve].unk1 * ((new_vol * voldiff) >> 0x10) >>
|
gCurves[fo_curve].unk1 * ((new_vol * voldiff) >> 0x10)) >>
|
||||||
0xc;
|
0xc;
|
||||||
if (new_vol < 0) {
|
if (new_vol < 0) {
|
||||||
new_vol = 0;
|
new_vol = 0;
|
||||||
} else {
|
} else if (0x10000 < new_vol) {
|
||||||
if (0x10000 < new_vol) {
|
|
||||||
new_vol = 0x10000;
|
new_vol = 0x10000;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
new_vol = (new_vol * volume) >> 0x10;
|
new_vol = (new_vol * volume) >> 0x10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -176,7 +176,6 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) {
|
||||||
PauseVAG(vs, 1);
|
PauseVAG(vs, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO vag
|
|
||||||
} break;
|
} break;
|
||||||
case Jak2SoundCommand::stop_sound: {
|
case Jak2SoundCommand::stop_sound: {
|
||||||
Sound* sound = LookupSound(cmd->sound_id.sound_id);
|
Sound* sound = LookupSound(cmd->sound_id.sound_id);
|
||||||
|
@ -188,7 +187,6 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) {
|
||||||
StopVagStream(vs, 1);
|
StopVagStream(vs, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO vag
|
|
||||||
} break;
|
} break;
|
||||||
case Jak2SoundCommand::continue_sound: {
|
case Jak2SoundCommand::continue_sound: {
|
||||||
Sound* sound = LookupSound(cmd->sound_id.sound_id);
|
Sound* sound = LookupSound(cmd->sound_id.sound_id);
|
||||||
|
@ -200,7 +198,6 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) {
|
||||||
UnPauseVAG(vs, 1);
|
UnPauseVAG(vs, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO vag
|
|
||||||
} break;
|
} break;
|
||||||
case Jak2SoundCommand::set_param: {
|
case Jak2SoundCommand::set_param: {
|
||||||
Sound* sound = LookupSound(cmd->sound_id.sound_id);
|
Sound* sound = LookupSound(cmd->sound_id.sound_id);
|
||||||
|
@ -271,9 +268,24 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) {
|
||||||
if (mask & 0x2) {
|
if (mask & 0x2) {
|
||||||
SetVAGStreamPitch(cmd->param.sound_id, cmd->param.parms.pitch_mod);
|
SetVAGStreamPitch(cmd->param.sound_id, cmd->param.parms.pitch_mod);
|
||||||
}
|
}
|
||||||
|
if (mask & 0x20) {
|
||||||
|
vs->vec3 = cmd->param.parms.trans;
|
||||||
|
vs->unk_296 = 1;
|
||||||
|
}
|
||||||
|
if (mask & 0x40) {
|
||||||
|
vs->fo_min = cmd->param.parms.fo_min;
|
||||||
|
}
|
||||||
|
if (mask & 0x80) {
|
||||||
|
vs->fo_max = cmd->param.parms.fo_max;
|
||||||
|
}
|
||||||
|
if (mask & 0x100) {
|
||||||
|
vs->fo_curve = cmd->param.parms.fo_curve;
|
||||||
|
}
|
||||||
|
if (mask & 0x1) {
|
||||||
|
vs->vol_multiplier = cmd->param.parms.volume;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO vag
|
|
||||||
} break;
|
} break;
|
||||||
case Jak2SoundCommand::set_master_volume: {
|
case Jak2SoundCommand::set_master_volume: {
|
||||||
u32 group = cmd->master_volume.group.group;
|
u32 group = cmd->master_volume.group.group;
|
||||||
|
|
Loading…
Reference in a new issue