mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 15:28:58 -04:00
j2-overlord: Clean up some VAG functions (#3287)
Some cleanup of vag related functions in overlord.
This commit is contained in:
@@ -11,7 +11,7 @@ Sound gSounds[64];
|
||||
Vec3w gEarTrans[2];
|
||||
Vec3w gCamTrans;
|
||||
s32 gMusicFadeDir = 0;
|
||||
Curve gCurve[16];
|
||||
Curve gCurves[16];
|
||||
s32 gCamAngle;
|
||||
u8 gMirrorMode = 0;
|
||||
u32 sLastTick = 0;
|
||||
@@ -154,7 +154,7 @@ s32 GetPan(Sound* sound) {
|
||||
return CalculateAngle(&sound->params.trans);
|
||||
}
|
||||
|
||||
s32 CalculateFallofVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32 fo_max) {
|
||||
s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32 fo_max) {
|
||||
s32 xdiff = 0;
|
||||
s32 ydiff = 0;
|
||||
s32 zdiff = 0;
|
||||
@@ -256,9 +256,9 @@ s32 CalculateFallofVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
|
||||
return volume;
|
||||
}
|
||||
|
||||
s32 factor = ((gCurve[fo_curve].unk4 << 16) + gCurve[fo_curve].unk3 * v13 +
|
||||
gCurve[fo_curve].unk2 * ((v13 * v13) >> 16) +
|
||||
gCurve[fo_curve].unk1 * (((((v13 * v13) >> 16) * v13) >> 16) >> 16)) >>
|
||||
s32 factor = ((gCurves[fo_curve].unk4 << 16) + gCurves[fo_curve].unk3 * v13 +
|
||||
gCurves[fo_curve].unk2 * ((v13 * v13) >> 16) +
|
||||
gCurves[fo_curve].unk1 * (((((v13 * v13) >> 16) * v13) >> 16) >> 16)) >>
|
||||
12;
|
||||
|
||||
if (factor > 0x10000) {
|
||||
@@ -274,8 +274,8 @@ s32 CalculateFallofVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
|
||||
}
|
||||
|
||||
s32 GetVolume(Sound* sound) {
|
||||
return CalculateFallofVolume(&sound->params.trans, sound->params.volume, sound->params.fo_curve,
|
||||
sound->params.fo_min, sound->params.fo_max);
|
||||
return CalculateFalloffVolume(&sound->params.trans, sound->params.volume, sound->params.fo_curve,
|
||||
sound->params.fo_min, sound->params.fo_max);
|
||||
}
|
||||
|
||||
void UpdateVolume(Sound* sound) {
|
||||
@@ -322,32 +322,6 @@ void KillSoundsInGroup(u8 group) {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateLocation(Sound* sound) {
|
||||
if (sound->id == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_game_version == GameVersion::Jak1) {
|
||||
if ((sound->bank_entry->fallof_params >> 28) == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
s32 id = snd_SoundIsStillPlaying(sound->sound_handle);
|
||||
if (id == 0) {
|
||||
sound->id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
s32 volume = GetVolume(sound);
|
||||
if (volume == 0) {
|
||||
snd_StopSound(sound->sound_handle);
|
||||
} else {
|
||||
s32 pan = GetPan(sound);
|
||||
snd_SetSoundVolPan(id, volume, pan);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateAutoVol(Sound* sound, s32 ticks) {
|
||||
if (ticks < sound->auto_time) {
|
||||
s32 nvol = sound->new_volume;
|
||||
@@ -417,8 +391,8 @@ void PrintActiveSounds() {
|
||||
}
|
||||
|
||||
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;
|
||||
gCurves[curve].unk1 = ease * 2;
|
||||
gCurves[curve].unk2 = falloff - 3 * ease;
|
||||
gCurves[curve].unk3 = ease - falloff - 0x1000;
|
||||
gCurves[curve].unk4 = 0x1000;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ struct Curve {
|
||||
|
||||
extern Sound gSounds[64];
|
||||
extern Vec3w gEarTrans[2];
|
||||
extern Curve gCurve[16];
|
||||
extern Curve gCurves[16];
|
||||
extern Vec3w gCamTrans;
|
||||
extern u8 gMirrorMode;
|
||||
extern s32 gCamAngle;
|
||||
@@ -64,11 +64,10 @@ Sound* LookupSound(s32 id);
|
||||
Sound* AllocateSound();
|
||||
s32 GetVolume(Sound* sound);
|
||||
void UpdateVolume(Sound* sound);
|
||||
s32 CalculateFallofVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32 fo_max);
|
||||
s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32 fo_max);
|
||||
s32 GetPan(Sound* sound);
|
||||
s32 CalculateAngle(Vec3w* trans);
|
||||
void KillSoundsInGroup(u8 group);
|
||||
void UpdateLocation(Sound* sound);
|
||||
void UpdateAutoVol(Sound* sound, s32 ticks);
|
||||
void PrintActiveSounds();
|
||||
void SetCurve(s32 curve, s32 fallof, s32 ease);
|
||||
|
||||
@@ -1368,7 +1368,7 @@ static void PauseVAG(VagCommand* vag) {
|
||||
|
||||
static void CalculateVAGVolumes(s32 volume, s32 positioned, Vec3w* trans, s32* left, s32* right) {
|
||||
if (positioned) {
|
||||
volume = CalculateFallofVolume(trans, (volume * gDialogVolume) >> 10, 1, 10, 50);
|
||||
volume = CalculateFalloffVolume(trans, (volume * gDialogVolume) >> 10, 1, 10, 50);
|
||||
auto* pan = &gPanTable[(630 - CalculateAngle(trans)) % 360];
|
||||
*left = (pan->left * volume) >> 10;
|
||||
*right = (pan->right * volume) >> 10;
|
||||
|
||||
@@ -54,13 +54,13 @@ void InitSound_Overlord() {
|
||||
snd_StartSoundSystem();
|
||||
snd_RegisterIOPMemAllocator(SndMemAlloc, SndMemFree);
|
||||
snd_LockVoiceAllocator(1);
|
||||
u32 voice = snd_ExternVoiceAlloc(2, 0x7f);
|
||||
s32 voice = snd_ExternVoiceAlloc(2, 0x7f);
|
||||
snd_UnlockVoiceAllocator();
|
||||
|
||||
// The voice allocator returns a number in the range 0-47 where voices
|
||||
// 0-23 are on SPU Core 0 and 24-47 are on core 2.
|
||||
// For some reason we convert it to this format where 0-47 alternate core every step.
|
||||
voice = voice / 24 + ((voice % 24) * 2);
|
||||
gVoice = voice / 24 + ((voice % 24) * 2);
|
||||
|
||||
// Allocate SPU RAM for our streams.
|
||||
// (Which we don't need on PC)
|
||||
@@ -115,6 +115,30 @@ void InitSound_Overlord() {
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateLocation(Sound* sound) {
|
||||
if (sound->id == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((sound->bank_entry->fallof_params >> 28) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
s32 id = snd_SoundIsStillPlaying(sound->sound_handle);
|
||||
if (id == 0) {
|
||||
sound->id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
s32 volume = GetVolume(sound);
|
||||
if (volume == 0) {
|
||||
snd_StopSound(sound->sound_handle);
|
||||
} else {
|
||||
s32 pan = GetPan(sound);
|
||||
snd_SetSoundVolPan(id, volume, pan);
|
||||
}
|
||||
}
|
||||
|
||||
void SetEarTrans(Vec3w* ear_trans0, Vec3w* ear_trans1, Vec3w* cam_trans, s32 cam_angle) {
|
||||
s32 tick = snd_GetTick();
|
||||
u32 delta = tick - sLastTick;
|
||||
@@ -150,4 +174,4 @@ static void* SndMemAlloc() {
|
||||
return nullptr;
|
||||
}
|
||||
static void SndMemFree(void* /*ptr*/) {}
|
||||
} // namespace jak1
|
||||
} // namespace jak1
|
||||
|
||||
@@ -13,6 +13,7 @@ extern u32 gTrapSRAM;
|
||||
extern s32 gMusicVol;
|
||||
|
||||
void InitSound_Overlord();
|
||||
void UpdateLocation(Sound* sound);
|
||||
void SetEarTrans(Vec3w* ear_trans1, Vec3w* ear_trans2, Vec3w* cam_trans, s32 cam_angle);
|
||||
void SetMusicVol();
|
||||
} // namespace jak1
|
||||
} // namespace jak1
|
||||
|
||||
+22
-22
@@ -1,5 +1,6 @@
|
||||
#include "dma.h"
|
||||
|
||||
#include "game/overlord/jak2/ssound.h"
|
||||
#include "game/overlord/jak2/vag.h"
|
||||
#include "game/sound/sdshim.h"
|
||||
#include "game/sound/sndshim.h"
|
||||
@@ -90,30 +91,29 @@ int SpuDmaIntr(int, void*) {
|
||||
int pitch = CalculateVAGPitch(DmaVagCmd->pitch1, DmaVagCmd->unk_256_pitch2);
|
||||
if (!DmaStereoVagCmd) {
|
||||
DmaVagCmd->spu_addr_to_start_playing = 0;
|
||||
sceSdSetAddr(((s16)DmaVagCmd->voice) | 0x2040, DmaVagCmd->spu_stream_dma_mem_addr + 0x30);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x300, 0xf);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x400, 0x1fc0);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x200, pitch);
|
||||
sceSdSetAddr(SD_VA_SSA | DmaVagCmd->voice, DmaVagCmd->spu_stream_dma_mem_addr + 0x30);
|
||||
sceSdSetParam(SD_VP_ADSR1 | DmaVagCmd->voice, 0xf);
|
||||
sceSdSetParam(SD_VP_ADSR2 | DmaVagCmd->voice, 0x1fc0);
|
||||
sceSdSetParam(SD_VP_PITCH | DmaVagCmd->voice, pitch);
|
||||
|
||||
// start playback!
|
||||
sceSdkey_on_jak2_voice(DmaVagCmd->voice);
|
||||
sceSdSetSwitch(SD_S_KON | (DmaVagCmd->voice & 1), VOICE_BIT(DmaVagCmd->voice));
|
||||
} else {
|
||||
// same for stereo, but we start both voices.
|
||||
DmaVagCmd->spu_addr_to_start_playing = 0;
|
||||
DmaStereoVagCmd->spu_addr_to_start_playing = 0;
|
||||
|
||||
sceSdSetAddr((u16)DmaVagCmd->voice | 0x2040, DmaVagCmd->spu_stream_dma_mem_addr + 0x30);
|
||||
sceSdSetAddr((u16)DmaStereoVagCmd->voice | 0x2040,
|
||||
sceSdSetAddr(SD_VA_SSA | DmaVagCmd->voice, DmaVagCmd->spu_stream_dma_mem_addr + 0x30);
|
||||
sceSdSetAddr(SD_VA_SSA | DmaStereoVagCmd->voice,
|
||||
DmaStereoVagCmd->spu_stream_dma_mem_addr + 0x30);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x300, 0xf);
|
||||
sceSdSetParam((u16)DmaStereoVagCmd->voice | 0x300, 0xf);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x400, 0x1fc0);
|
||||
sceSdSetParam((u16)DmaStereoVagCmd->voice | 0x400, 0x1fc0);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x200, pitch);
|
||||
sceSdSetParam((u16)DmaStereoVagCmd->voice | 0x200, pitch);
|
||||
sceSdSetParam(SD_VP_ADSR1 | DmaVagCmd->voice, 0xf);
|
||||
sceSdSetParam(SD_VP_ADSR1 | DmaStereoVagCmd->voice, 0xf);
|
||||
sceSdSetParam(SD_VP_ADSR2 | DmaVagCmd->voice, 0x1fc0);
|
||||
sceSdSetParam(SD_VP_ADSR2 | DmaStereoVagCmd->voice, 0x1fc0);
|
||||
sceSdSetParam(SD_VP_PITCH | DmaVagCmd->voice, pitch);
|
||||
sceSdSetParam(SD_VP_PITCH | DmaStereoVagCmd->voice, pitch);
|
||||
|
||||
sceSdkey_on_jak2_voice(DmaVagCmd->voice);
|
||||
sceSdkey_on_jak2_voice(DmaStereoVagCmd->voice);
|
||||
sceSdSetSwitch(SD_S_KON | (DmaVagCmd->voice & 1),
|
||||
VOICE_BIT(DmaVagCmd->voice) | VOICE_BIT(DmaStereoVagCmd->voice));
|
||||
}
|
||||
} else if (DmaVagCmd->num_processed_chunks == 2) {
|
||||
// on the second chunk's DMA finish, start playing by unpausing.
|
||||
@@ -127,13 +127,13 @@ int SpuDmaIntr(int, void*) {
|
||||
// if we paused since the first, kill the voice.
|
||||
if (DmaVagCmd->sb_paused) {
|
||||
if (!DmaStereoVagCmd) {
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x200, 0);
|
||||
sceSdSetParam(SD_VP_PITCH | DmaVagCmd->voice, 0);
|
||||
} else {
|
||||
sceSdSetParam((u16)DmaStereoVagCmd->voice | 0x200, 0);
|
||||
sceSdSetParam((u16)DmaVagCmd->voice | 0x200, 0);
|
||||
sceSdkey_off_jak2_voice(DmaStereoVagCmd->voice);
|
||||
sceSdSetParam(SD_VP_PITCH | DmaStereoVagCmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_PITCH | DmaVagCmd->voice, 0);
|
||||
sceSdSetSwitch(SD_S_KOFF | (DmaVagCmd->voice & 1), VOICE_BIT(DmaStereoVagCmd->voice));
|
||||
}
|
||||
sceSdkey_off_jak2_voice(DmaVagCmd->voice);
|
||||
sceSdSetSwitch(SD_S_KOFF | (DmaVagCmd->voice & 1), VOICE_BIT(DmaVagCmd->voice));
|
||||
goto hack;
|
||||
}
|
||||
|
||||
@@ -231,4 +231,4 @@ void DmaCancelThisVagCmd(VagCmd* param_1) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace jak2
|
||||
} // namespace jak2
|
||||
|
||||
@@ -241,7 +241,7 @@ void IsoQueueVagStream(VagCmd* cmd, int param_2) {
|
||||
new_cmd->id = cmd->id;
|
||||
|
||||
new_cmd->plugin_id = cmd->plugin_id;
|
||||
new_cmd->unk_136 = cmd->unk_136;
|
||||
new_cmd->sound_handler = cmd->sound_handler;
|
||||
new_cmd->unk_176 = cmd->unk_176;
|
||||
new_cmd->unk_288 = cmd->unk_288;
|
||||
new_cmd->unk_292 = cmd->unk_292;
|
||||
@@ -689,7 +689,7 @@ u32 ISOThread() {
|
||||
do {
|
||||
if ((((cmd_iter->byte11 == false) && (cmd_iter->sb_scanned == false)) &&
|
||||
(cmd_iter->id != 0)) ||
|
||||
((StopPluginStreams == 1 && (cmd_iter->unk_136) != 0))) {
|
||||
((StopPluginStreams == 1 && (cmd_iter->sound_handler) != 0))) {
|
||||
// CpuSuspendIntr(&local_2c);
|
||||
bVar1 = false;
|
||||
if (cmd_iter->id == 0) {
|
||||
|
||||
@@ -64,7 +64,7 @@ void QueueVAGStream(VagStrListNode* param_1) {
|
||||
cmd.header.cmd_kind = 0x400;
|
||||
cmd.header.mbx_to_reply = 0;
|
||||
cmd.header.thread_id = 0;
|
||||
if (param_1->unk_72 == 0) {
|
||||
if (param_1->sound_handler == 0) {
|
||||
EEVagAndVagwad(param_1->name, &cmd);
|
||||
cmd.vol_multiplier = 0x400;
|
||||
} else {
|
||||
@@ -96,7 +96,7 @@ void QueueVAGStream(VagStrListNode* param_1) {
|
||||
cmd.unk_176 = param_1->unk_100;
|
||||
}
|
||||
strncpy(cmd.name, param_1->name, 0x30);
|
||||
cmd.unk_136 = param_1->unk_72;
|
||||
cmd.sound_handler = param_1->sound_handler;
|
||||
cmd.id = param_1->id;
|
||||
cmd.plugin_id = param_1->unk_68;
|
||||
cmd.priority = param_1->prio;
|
||||
|
||||
@@ -842,7 +842,7 @@ void StopVagStream(VagCmd* param_1, int param_2) {
|
||||
if (cmd != 0x0) {
|
||||
cmd->sb_playing = '\0';
|
||||
}
|
||||
if (param_1->unk_136 == 0) {
|
||||
if (param_1->sound_handler == 0) {
|
||||
PauseVAG(param_1, 0);
|
||||
param_1->byte9 = '\x01';
|
||||
if (cmd != 0x0) {
|
||||
@@ -892,7 +892,7 @@ u32 GetSpuRamAddress(VagCmd* param_1) {
|
||||
// if the overlord thread isn't keeping up.
|
||||
// as far as I can tell, it's totally fine to discard these checks because our sceSdGetAddr
|
||||
// works perfectly.
|
||||
return sceSdGetAddr((param_1->voice & 0xffffU) | 0x2240);
|
||||
return sceSdGetAddr(SD_VA_NAX | param_1->voice);
|
||||
}
|
||||
|
||||
u32 bswap(u32 param_1) {
|
||||
|
||||
@@ -312,7 +312,7 @@ void* RPC_Player(unsigned int /*fno*/, void* data, int size) {
|
||||
local_178.header.thread_id = 0;
|
||||
local_178.vag_dir_entry = nullptr;
|
||||
local_178.name[0] = '\0';
|
||||
local_178.unk_136 = 0;
|
||||
local_178.sound_handler = 0;
|
||||
local_178.id = 0;
|
||||
local_178.priority = 0;
|
||||
StopVagStream(&local_178, 1);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "game/overlord/jak2/streamlist.h"
|
||||
#include "game/overlord/jak2/vag.h"
|
||||
#include "game/sce/iop.h"
|
||||
#include "game/sound/sdshim.h"
|
||||
#include "game/sound/sndshim.h"
|
||||
|
||||
using namespace iop;
|
||||
@@ -42,11 +43,10 @@ void InitSound_overlord() {
|
||||
// need this one for PC sound to start up
|
||||
snd_StartSoundSystem();
|
||||
|
||||
// there's a bunch of stuff that we don't use.
|
||||
StreamVoice[0] = 0;
|
||||
StreamVoice[1] = 1;
|
||||
StreamVoice[2] = 2;
|
||||
StreamVoice[3] = 3; // TODO idk what im doing.
|
||||
StreamVoice[0] = SD_VOICE(0, 0);
|
||||
StreamVoice[1] = SD_VOICE(0, 1);
|
||||
StreamVoice[2] = SD_VOICE(0, 2);
|
||||
StreamVoice[3] = SD_VOICE(0, 3);
|
||||
|
||||
for (int i = 0; i < 91; i++) {
|
||||
s16 opposing_front = static_cast<s16>(((i * 0x33ff) / 0x5a) + 0xc00);
|
||||
@@ -110,6 +110,32 @@ void SetMusicVol() {
|
||||
snd_SetMasterVolume(2, vol);
|
||||
}
|
||||
|
||||
void UpdateLocation(Sound* sound) {
|
||||
if (sound->id == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
s32 id = snd_SoundIsStillPlaying(sound->sound_handle);
|
||||
if (id == 0) {
|
||||
sound->id = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
s32 volume = GetVolume(sound);
|
||||
if (volume == 0) {
|
||||
snd_StopSound(sound->sound_handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sound->params.fo_curve == 1 || sound->params.fo_curve == 10) {
|
||||
snd_SetSoundVolPan(id, volume, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
s32 pan = GetPan(sound);
|
||||
snd_SetSoundVolPan(id, volume, pan);
|
||||
}
|
||||
|
||||
void SetEarTrans(Vec3w* ear_trans0, Vec3w* ear_trans1, Vec3w* cam_trans, s32 cam_angle) {
|
||||
// some assuming that this is the same in jak2...
|
||||
s32 tick = snd_GetTick();
|
||||
@@ -136,7 +162,7 @@ void SetEarTrans(Vec3w* ear_trans0, Vec3w* ear_trans1, Vec3w* cam_trans, s32 cam
|
||||
auto* cmd = VagCmds;
|
||||
// piVar6 = &VagCmds[0].vol_multiplier;
|
||||
do {
|
||||
if (cmd->unk_136 == 0x0) {
|
||||
if (cmd->sound_handler == 0x0) {
|
||||
LAB_0000c388:
|
||||
SetVAGVol(cmd, 1);
|
||||
} else if ((cmd->sb_scanned == '\0') || (cmd->byte8 != '\0')) {
|
||||
@@ -172,4 +198,4 @@ void SetEarTrans(Vec3w* ear_trans0, Vec3w* ear_trans1, Vec3w* cam_trans, s32 cam
|
||||
} while (true);
|
||||
}
|
||||
|
||||
} // namespace jak2
|
||||
} // namespace jak2
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
#include "game/overlord/common/ssound.h"
|
||||
|
||||
namespace jak2 {
|
||||
#define VOICE_BIT(voice) (1 << ((voice) >> 1))
|
||||
#define CORE_BIT(voice) ((voice)&1)
|
||||
void ssound_init_globals();
|
||||
void SetBufferMem(void*, int);
|
||||
void ReleaseBufferMem();
|
||||
void SetMusicVol();
|
||||
void UpdateLocation(Sound* sound);
|
||||
void SetEarTrans(Vec3w* ear_trans0, Vec3w* ear_trans1, Vec3w* cam_trans, s32 cam_angle);
|
||||
void InitSound_overlord();
|
||||
extern s32 StreamThread;
|
||||
extern VolumePair gPanTable[361];
|
||||
} // namespace jak2
|
||||
} // namespace jak2
|
||||
|
||||
@@ -178,7 +178,7 @@ void* RPC_PLAY([[maybe_unused]] unsigned int fno, void* _cmd, int size) {
|
||||
strncpy(list_node.name, cmd_iter->names[s].chars, 0x30);
|
||||
list_node.id = cmd_iter->id[s];
|
||||
list_node.unk_76 = cmd_iter->address & 1 << (s & 0x1f) & 0xf;
|
||||
list_node.unk_72 = 0;
|
||||
list_node.sound_handler = 0;
|
||||
list_node.unk_80 = cmd_iter->address & 0x10 << (s & 0x1f) & 0xf0;
|
||||
list_node.prio = iVar5;
|
||||
pRVar2 = FindThisVagStream(list_node.name, list_node.id);
|
||||
@@ -247,7 +247,7 @@ void* RPC_PLAY([[maybe_unused]] unsigned int fno, void* _cmd, int size) {
|
||||
strncpy(list_node.name, cmd_iter->names[s].chars, 0x30);
|
||||
list_node.id = cmd_iter->id[s];
|
||||
list_node.unk_68 = 0;
|
||||
list_node.unk_72 = 0;
|
||||
list_node.sound_handler = 0;
|
||||
list_node.prio = iVar5;
|
||||
pRVar2 = FindThisVagStream(cmd_iter->names[s].chars, cmd_iter->id[s]);
|
||||
if ((pRVar2 == 0x0) || (pRVar2->byte4 == '\0')) {
|
||||
@@ -260,7 +260,7 @@ void* RPC_PLAY([[maybe_unused]] unsigned int fno, void* _cmd, int size) {
|
||||
|
||||
iVar4->id = list_node.id;
|
||||
iVar4->prio = list_node.prio;
|
||||
iVar4->unk_72 = list_node.unk_72;
|
||||
iVar4->sound_handler = list_node.sound_handler;
|
||||
iVar4->unk_76 = 0;
|
||||
iVar4->unk_80 = 0;
|
||||
iVar4->unk_92 = 0;
|
||||
|
||||
@@ -74,9 +74,9 @@ VagStrListNode* InsertVagStreamInList(VagStrListNode* param_1, List* param_2) {
|
||||
pVVar5->unk_76 = param_1->unk_76;
|
||||
pVVar5->unk_80 = param_1->unk_80;
|
||||
pVVar5->prio = param_1->prio;
|
||||
iVar1 = param_1->unk_72;
|
||||
iVar1 = param_1->sound_handler;
|
||||
pVVar5->unk_92 = 0;
|
||||
pVVar5->unk_72 = iVar1;
|
||||
pVVar5->sound_handler = iVar1;
|
||||
pVVar5->vol_multiplier = param_1->vol_multiplier;
|
||||
pVVar5->unk_100 = param_1->unk_100;
|
||||
if (pVVar6 == (VagStrListNode*)0x0) {
|
||||
@@ -132,7 +132,7 @@ void QueueNewStreamsFromList(List* list) {
|
||||
// puVar4[0xe] = 0;
|
||||
pvVar6->id = 0;
|
||||
// puVar4[0x10] = 0;
|
||||
pvVar6->unk_72 = 0;
|
||||
pvVar6->sound_handler = 0;
|
||||
// puVar4[0x13] = 0;
|
||||
pvVar6->prio = 0;
|
||||
// puVar4[0x11] = 0;
|
||||
@@ -264,7 +264,7 @@ code_r0x0000f058:
|
||||
(pVVar4->list).in_use = 0;
|
||||
strncpy(pVVar4->name, "free", 0x30);
|
||||
pVVar4->id = 0;
|
||||
pVVar4->unk_72 = 0;
|
||||
pVVar4->sound_handler = 0;
|
||||
pVVar4->prio = 0;
|
||||
pVVar4->unk_76 = 0;
|
||||
pVVar4->unk_80 = 0;
|
||||
@@ -306,7 +306,7 @@ u32 StreamListThread() {
|
||||
// puVar4[0xe] = 0;
|
||||
pvVar6->id = 0;
|
||||
// puVar4[0x10] = 0;
|
||||
pvVar6->unk_72 = 0;
|
||||
pvVar6->sound_handler = 0;
|
||||
// puVar4[0x13] = 0;
|
||||
pvVar6->prio = 0;
|
||||
// puVar4[0x11] = 0;
|
||||
@@ -438,7 +438,7 @@ bool InitVagStreamList(List* param_1, u32 param_2, const char* param_3) {
|
||||
// *(undefined4*)(piVar1 + -0x24) = 0;
|
||||
pLVar3->id = 0;
|
||||
// *(undefined4*)(piVar1 + -0x1c) = 0;
|
||||
pLVar3->unk_72 = 0;
|
||||
pLVar3->sound_handler = 0;
|
||||
// *(undefined4*)(piVar1 + -0x10) = 0;
|
||||
pLVar3->prio = 0;
|
||||
// *(undefined4*)(piVar1 + -0x18) = 0;
|
||||
@@ -525,7 +525,7 @@ void RemoveVagStreamFromList(VagStrListNode* param_1, List* param_2) {
|
||||
(pVVar2->list).in_use = 0;
|
||||
strncpy(pVVar2->name, "free", 0x30);
|
||||
pVVar2->id = 0;
|
||||
pVVar2->unk_72 = 0;
|
||||
pVVar2->sound_handler = 0;
|
||||
pVVar2->prio = 0;
|
||||
pVVar2->unk_76 = 0;
|
||||
pVVar2->unk_80 = 0;
|
||||
@@ -563,7 +563,7 @@ void EmptyVagStreamList(List* param_1) {
|
||||
// puVar1 = puVar1 + 0x1a;
|
||||
|
||||
pvVar2->id = 0;
|
||||
pvVar2->unk_72 = 0;
|
||||
pvVar2->sound_handler = 0;
|
||||
pvVar2->prio = 0;
|
||||
pvVar2->unk_76 = 0;
|
||||
pvVar2->unk_80 = 0;
|
||||
|
||||
@@ -10,7 +10,7 @@ struct VagStrListNode {
|
||||
int unk_60;
|
||||
int id;
|
||||
int unk_68;
|
||||
int unk_72;
|
||||
int sound_handler; // 989snd handler that owns this stream
|
||||
int unk_76;
|
||||
int unk_80;
|
||||
int prio;
|
||||
|
||||
+148
-424
@@ -24,7 +24,8 @@ VagCmdPriListEntry VagCmdsPriList[11];
|
||||
int VagCmdsPriCounter[11];
|
||||
int ActiveVagStreams;
|
||||
|
||||
void CalculateVAGVolumes(VagCmd* cmd, int* l_out, int* r_out);
|
||||
void CalculateVAGVolumes(VagCmd* cmd, u32* l_out, u32* r_out);
|
||||
void StopVAG(VagCmd* cmd, int /*param_2*/);
|
||||
|
||||
enum VolumeCategory {
|
||||
DIALOGUE = 2, // VAG streams. Copied "dialogue" name from jak 1.
|
||||
@@ -101,7 +102,7 @@ void InitVagCmds() {
|
||||
cmd.unk_256_pitch2 = 0; // puVar5[-9] = 0;
|
||||
cmd.id = 0; // puVar5[-4] = 0;
|
||||
cmd.plugin_id = 0; // puVar5[-3] = 0;
|
||||
cmd.unk_136 = 0; // puVar5[-0x27] = 0;
|
||||
cmd.sound_handler = 0; // puVar5[-0x27] = 0;
|
||||
cmd.unk_176 = 0; // puVar5[-0x1d] = 0;
|
||||
cmd.priority = 0; // puVar5[-2] = 0;
|
||||
cmd.unk_288 = 0; // puVar5[-1] = 0;
|
||||
@@ -189,189 +190,34 @@ VagCmd* SmartAllocVagCmd(VagCmd* cmd) {
|
||||
}
|
||||
|
||||
void TerminateVAG(VagCmd* cmd, int param_2) {
|
||||
[[maybe_unused]] int* piVar1;
|
||||
int iVar2;
|
||||
u32 uVar3;
|
||||
VagCmd* pRVar4;
|
||||
VagCmd* pRVar5;
|
||||
VagStrListNode vag_node;
|
||||
LfoListNode lfo_node;
|
||||
// undefined4 auStack32 [2];
|
||||
|
||||
if (param_2 == 1) {
|
||||
// CpuSuspendIntr(auStack32);
|
||||
}
|
||||
pRVar4 = cmd->stereo_sibling;
|
||||
// if (param_2 == 1) {
|
||||
// CpuSuspendIntr(auStack32);
|
||||
//}
|
||||
|
||||
auto* sibling = cmd->stereo_sibling;
|
||||
strncpy(vag_node.name, cmd->name, 0x30);
|
||||
vag_node.id = cmd->id;
|
||||
cmd->sb_scanned = '\0';
|
||||
|
||||
if (cmd->status_bytes[BYTE5] != '\0') {
|
||||
pRVar5 = cmd->stereo_sibling;
|
||||
PauseVAG(cmd, 0);
|
||||
if (cmd->status_bytes[BYTE5] != '\0') {
|
||||
uVar3 = 1 << (cmd->voice >> 1 & 0x1fU);
|
||||
if (pRVar5 != 0x0) {
|
||||
uVar3 = uVar3 | 1 << (pRVar5->voice >> 1 & 0x1fU);
|
||||
}
|
||||
// sceSdSetSwitch(*(u16*)&cmd->voice & 1 | 0x1600, uVar3);
|
||||
sceSdkey_off_jak2_voice(cmd->voice);
|
||||
if (cmd->stereo_sibling) {
|
||||
sceSdkey_off_jak2_voice(cmd->stereo_sibling->voice);
|
||||
}
|
||||
}
|
||||
// iVar2 = 0x18;
|
||||
// piVar1 = &(cmd->header).unk_24;
|
||||
// do {
|
||||
// *(undefined *)(piVar1 + 0x34) = 0;
|
||||
// iVar2 = iVar2 + -1;
|
||||
// piVar1 = (int *)((int)piVar1 + -1);
|
||||
// } while (-1 < iVar2);
|
||||
for (auto& x : cmd->status_bytes) {
|
||||
x = 0;
|
||||
}
|
||||
cmd->vol_multiplier = 0;
|
||||
cmd->unk_256_pitch2 = 0;
|
||||
cmd->id = 0;
|
||||
cmd->plugin_id = 0;
|
||||
(cmd->header).ready_for_data = 0;
|
||||
cmd->unk_136 = 0;
|
||||
cmd->unk_140 = 0;
|
||||
cmd->pitch1 = 0;
|
||||
(cmd->header).callback = NullCallback;
|
||||
cmd->unk_180 = 0;
|
||||
cmd->unk_184 = 0;
|
||||
cmd->unk_188 = 0;
|
||||
cmd->unk_192 = 0;
|
||||
StopVAG(cmd, 0);
|
||||
}
|
||||
|
||||
ReleaseMessage(&cmd->header, 0);
|
||||
VagCmdsPriList[cmd->priority].cmds[cmd->idx_in_cmd_arr] = 0x0;
|
||||
if (VagCmdsPriCounter[cmd->priority] < 1) {
|
||||
printf("IOP: ======================================================================\n");
|
||||
printf("IOP: vag RemoveVagCmd: VagCmdsPriCounter[%d] is zero\n", cmd->priority);
|
||||
printf("IOP: ======================================================================\n");
|
||||
} else {
|
||||
VagCmdsPriCounter[cmd->priority] = VagCmdsPriCounter[cmd->priority] + -1;
|
||||
RemoveVagCmd(cmd, 0);
|
||||
FreeVagCmd(cmd, 0);
|
||||
|
||||
if (sibling != nullptr) {
|
||||
sibling->sb_scanned = '\0';
|
||||
RemoveVagCmd(sibling, 0);
|
||||
FreeVagCmd(sibling, 0);
|
||||
}
|
||||
// iVar2 = 0x18;
|
||||
// piVar1 = &(cmd->header).unk_24;
|
||||
VagCmdsPriCounter[0] = VagCmdsPriCounter[0] + 1;
|
||||
for (auto& x : cmd->status_bytes) {
|
||||
x = 0;
|
||||
}
|
||||
// do {
|
||||
// *(undefined*)(piVar1 + 0x34) = 0;
|
||||
// iVar2 = iVar2 + -1;
|
||||
// piVar1 = (int*)((int)piVar1 + -1);
|
||||
// } while (-1 < iVar2);
|
||||
cmd->sb_playing = '\0';
|
||||
cmd->sb_paused = '\x01';
|
||||
cmd->sb_scanned = '\0';
|
||||
cmd->unk_180 = 0;
|
||||
cmd->unk_184 = 0;
|
||||
cmd->unk_188 = 0;
|
||||
cmd->unk_192 = 0;
|
||||
SetVagStreamName(cmd, 0, 0);
|
||||
cmd->name[0] = '\0';
|
||||
iVar2 = ActiveVagStreams;
|
||||
cmd->safe_to_change_dma_fields = 1;
|
||||
cmd->unk_264 = 0x4000;
|
||||
(cmd->header).callback = NullCallback;
|
||||
cmd->unk_140 = 0;
|
||||
cmd->pitch1 = 0;
|
||||
cmd->file_record = nullptr;
|
||||
cmd->vag_dir_entry = nullptr;
|
||||
cmd->unk_196 = 0;
|
||||
cmd->unk_200 = 0;
|
||||
cmd->unk_204 = 0;
|
||||
cmd->num_processed_chunks = 0;
|
||||
cmd->xfer_size = 0;
|
||||
cmd->sample_rate = 0;
|
||||
cmd->unk_260 = 0;
|
||||
cmd->unk_268 = 0;
|
||||
cmd->vol_multiplier = 0;
|
||||
cmd->unk_256_pitch2 = 0;
|
||||
cmd->id = 0;
|
||||
cmd->plugin_id = 0;
|
||||
cmd->unk_136 = 0;
|
||||
cmd->priority = 0;
|
||||
cmd->unk_288 = 0;
|
||||
cmd->unk_292 = 0;
|
||||
cmd->unk_296 = 0;
|
||||
(cmd->header).callback_buffer = (Buffer*)0x0;
|
||||
(cmd->header).ready_for_data = 0;
|
||||
(cmd->header).lse = (LoadStackEntry*)0x0;
|
||||
cmd->dma_iop_mem_ptr = (uint8_t*)0x0;
|
||||
cmd->dma_chan = -1;
|
||||
cmd->unk_236 = 0;
|
||||
if (0 < iVar2) {
|
||||
ActiveVagStreams = iVar2 + -1;
|
||||
}
|
||||
if (pRVar4 != 0x0) {
|
||||
pRVar4->sb_scanned = '\0';
|
||||
VagCmdsPriList[pRVar4->priority].cmds[pRVar4->idx_in_cmd_arr] = 0x0;
|
||||
if (VagCmdsPriCounter[pRVar4->priority] < 1) {
|
||||
printf("IOP: ======================================================================\n");
|
||||
printf("IOP: vag RemoveVagCmd: VagCmdsPriCounter[%d] is zero\n", pRVar4->priority);
|
||||
printf("IOP: ======================================================================\n");
|
||||
} else {
|
||||
VagCmdsPriCounter[pRVar4->priority] = VagCmdsPriCounter[pRVar4->priority] + -1;
|
||||
}
|
||||
iVar2 = 0x18;
|
||||
piVar1 = &(pRVar4->header).ready_for_data;
|
||||
VagCmdsPriCounter[0] = VagCmdsPriCounter[0] + 1;
|
||||
for (auto& x : cmd->status_bytes) {
|
||||
x = 0;
|
||||
}
|
||||
// do {
|
||||
// *(undefined*)(piVar1 + 0x34) = 0;
|
||||
// iVar2 = iVar2 + -1;
|
||||
// piVar1 = (int*)((int)piVar1 + -1);
|
||||
// } while (-1 < iVar2);
|
||||
pRVar4->sb_playing = '\0';
|
||||
pRVar4->sb_paused = '\x01';
|
||||
pRVar4->sb_scanned = '\0';
|
||||
pRVar4->unk_180 = 0;
|
||||
pRVar4->unk_184 = 0;
|
||||
pRVar4->unk_188 = 0;
|
||||
pRVar4->unk_192 = 0;
|
||||
SetVagStreamName(pRVar4, 0, 0);
|
||||
pRVar4->name[0] = '\0';
|
||||
iVar2 = ActiveVagStreams;
|
||||
pRVar4->safe_to_change_dma_fields = 1;
|
||||
pRVar4->unk_264 = 0x4000;
|
||||
(pRVar4->header).callback = NullCallback;
|
||||
pRVar4->unk_140 = 0;
|
||||
pRVar4->pitch1 = 0;
|
||||
pRVar4->file_record = nullptr;
|
||||
pRVar4->vag_dir_entry = nullptr;
|
||||
pRVar4->unk_196 = 0;
|
||||
pRVar4->unk_200 = 0;
|
||||
pRVar4->unk_204 = 0;
|
||||
pRVar4->num_processed_chunks = 0;
|
||||
pRVar4->xfer_size = 0;
|
||||
pRVar4->sample_rate = 0;
|
||||
pRVar4->unk_260 = 0;
|
||||
pRVar4->unk_268 = 0;
|
||||
pRVar4->vol_multiplier = 0;
|
||||
pRVar4->unk_256_pitch2 = 0;
|
||||
pRVar4->id = 0;
|
||||
pRVar4->plugin_id = 0;
|
||||
pRVar4->unk_136 = 0;
|
||||
pRVar4->priority = 0;
|
||||
pRVar4->unk_288 = 0;
|
||||
pRVar4->unk_292 = 0;
|
||||
pRVar4->unk_296 = 0;
|
||||
(pRVar4->header).callback_buffer = (Buffer*)0x0;
|
||||
(pRVar4->header).ready_for_data = 0;
|
||||
(pRVar4->header).lse = (LoadStackEntry*)0x0;
|
||||
pRVar4->dma_iop_mem_ptr = (uint8_t*)0x0;
|
||||
pRVar4->dma_chan = -1;
|
||||
pRVar4->unk_236 = 0;
|
||||
if (0 < iVar2) {
|
||||
ActiveVagStreams = iVar2 + -1;
|
||||
}
|
||||
}
|
||||
if (cmd->unk_136) {
|
||||
|
||||
if (cmd->sound_handler) {
|
||||
RemoveVagStreamFromList(&vag_node, &PluginStreamsList);
|
||||
lfo_node.id = cmd->id;
|
||||
lfo_node.plugin_id = cmd->plugin_id;
|
||||
@@ -380,10 +226,9 @@ void TerminateVAG(VagCmd* cmd, int param_2) {
|
||||
// printf("termina removing %s (2)\n", vag_node.name);
|
||||
|
||||
RemoveVagStreamFromList(&vag_node, &EEPlayList);
|
||||
if (param_2 == 1) {
|
||||
// CpuResumeIntr(auStack32[0]);
|
||||
}
|
||||
// return;
|
||||
// if (param_2 == 1) {
|
||||
// CpuResumeIntr(auStack32[0]);
|
||||
//}
|
||||
}
|
||||
|
||||
void PauseVAG(VagCmd* cmd, int /*param_2*/) {
|
||||
@@ -395,13 +240,11 @@ void PauseVAG(VagCmd* cmd, int /*param_2*/) {
|
||||
auto* stereo_cmd = cmd->stereo_sibling;
|
||||
if (!stereo_cmd) {
|
||||
if (cmd->sb_playing != '\0') {
|
||||
sceSdSetParam((u16)cmd->voice | SD_VP_VOLL, 0);
|
||||
sceSdSetParam(((u16)cmd->voice) | SD_VP_VOLR, 0);
|
||||
sceSdSetParam(SD_VP_VOLL | cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | cmd->voice, 0);
|
||||
}
|
||||
sceSdSetParam(((u16)cmd->voice) | SD_VP_PITCH, 0);
|
||||
// TODO: ignored, whatever this is
|
||||
// sceSdSetSwitch((((s16)cmd->voice) & 1) | 0x1600, 1 << (cmd->voice >> 1 & 0x1fU));
|
||||
sceSdkey_off_jak2_voice(cmd->voice);
|
||||
sceSdSetParam(SD_VP_PITCH | cmd->voice, 0);
|
||||
sceSdSetSwitch(SD_S_KOFF | CORE_BIT(cmd->voice), VOICE_BIT(cmd->voice));
|
||||
if (cmd->status_bytes[BYTE5] == '\0') {
|
||||
cmd->spu_addr_to_start_playing = 0;
|
||||
} else {
|
||||
@@ -410,23 +253,21 @@ void PauseVAG(VagCmd* cmd, int /*param_2*/) {
|
||||
cmd->sb_paused = 1;
|
||||
} else {
|
||||
if (cmd->sb_playing != '\0') {
|
||||
sceSdSetParam(((u16)cmd->voice) | SD_VP_VOLL, 0);
|
||||
sceSdSetParam(((u16)cmd->voice) | SD_VP_VOLR, 0);
|
||||
sceSdSetParam(((u16)stereo_cmd->voice) | SD_VP_VOLL, 0);
|
||||
sceSdSetParam(((u16)stereo_cmd->voice) | SD_VP_VOLR, 0);
|
||||
sceSdSetParam(SD_VP_VOLL | cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLL | stereo_cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | stereo_cmd->voice, 0);
|
||||
}
|
||||
sceSdSetParam(((u16)stereo_cmd->voice) | SD_VP_PITCH, 0);
|
||||
sceSdSetParam(((u16)cmd->voice) | SD_VP_PITCH, 0);
|
||||
// sceSdSetSwitch(((u16)cmd->voice & 1) | 0x1600,
|
||||
// 1 << (cmd->voice >> 1 & 0x1fU) | 1 << (stereo_cmd->voice >> 1 & 0x1fU));
|
||||
sceSdkey_off_jak2_voice(cmd->voice);
|
||||
sceSdkey_off_jak2_voice(stereo_cmd->voice);
|
||||
sceSdSetParam(SD_VP_PITCH | stereo_cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_PITCH | cmd->voice, 0);
|
||||
sceSdSetSwitch(SD_S_KOFF | CORE_BIT(cmd->voice),
|
||||
VOICE_BIT(cmd->voice) | VOICE_BIT(stereo_cmd->voice));
|
||||
|
||||
if (cmd->status_bytes[BYTE5] == '\0') {
|
||||
cmd->spu_addr_to_start_playing = 0;
|
||||
stereo_cmd->spu_addr_to_start_playing = 0;
|
||||
} else {
|
||||
int ram_addr = GetSpuRamAddress(cmd);
|
||||
u32 ram_addr = GetSpuRamAddress(cmd);
|
||||
cmd->spu_addr_to_start_playing = ram_addr & 0xfffffff8;
|
||||
stereo_cmd->spu_addr_to_start_playing =
|
||||
((ram_addr & 0xfffffff8) - cmd->spu_stream_dma_mem_addr) +
|
||||
@@ -449,38 +290,35 @@ void UnPauseVAG(VagCmd* param_1, int /*param_2*/) {
|
||||
//}
|
||||
if (param_1->status_bytes[BYTE11] == '\0') {
|
||||
auto* stereo_cmd = param_1->stereo_sibling;
|
||||
int pitch_reuslt = CalculateVAGPitch(param_1->pitch1, param_1->unk_256_pitch2);
|
||||
int vol_l, vol_r;
|
||||
int pitch = CalculateVAGPitch(param_1->pitch1, param_1->unk_256_pitch2);
|
||||
u32 vol_l, vol_r;
|
||||
CalculateVAGVolumes(param_1, &vol_l, &vol_r);
|
||||
if (!stereo_cmd) {
|
||||
if (param_1->sb_playing != '\0') {
|
||||
sceSdSetParam(((u16)param_1->voice) | 0x200, pitch_reuslt);
|
||||
sceSdSetParam(SD_VP_PITCH | param_1->voice, pitch);
|
||||
if (param_1->spu_addr_to_start_playing != 0) {
|
||||
sceSdSetAddr(((u16)param_1->voice) | 0x2040, param_1->spu_addr_to_start_playing);
|
||||
sceSdSetAddr(SD_VA_SSA | param_1->voice, param_1->spu_addr_to_start_playing);
|
||||
}
|
||||
// sceSdSetSwitch(((u16)param_1->voice & 1) | 0x1500, 1 << (voice >> 1 & 0x1fU));
|
||||
sceSdkey_on_jak2_voice(param_1->voice);
|
||||
sceSdSetParam(((u16)param_1->voice), vol_l);
|
||||
sceSdSetParam(((u16)param_1->voice) | 0x100, vol_r);
|
||||
sceSdSetSwitch(SD_S_KON | CORE_BIT(param_1->voice), VOICE_BIT(param_1->voice));
|
||||
sceSdSetParam(SD_VP_VOLL | param_1->voice, vol_l);
|
||||
sceSdSetParam(SD_VP_VOLR | param_1->voice, vol_r);
|
||||
}
|
||||
param_1->sb_paused = 0;
|
||||
} else {
|
||||
if (param_1->sb_playing != '\0') {
|
||||
sceSdSetParam(((u16)param_1->voice) | 0x200, pitch_reuslt);
|
||||
sceSdSetParam(((u16)stereo_cmd->voice) | 0x200, pitch_reuslt);
|
||||
sceSdSetParam(SD_VP_PITCH | param_1->voice, pitch);
|
||||
sceSdSetParam(SD_VP_PITCH | stereo_cmd->voice, pitch);
|
||||
if (param_1->spu_addr_to_start_playing != 0) {
|
||||
sceSdSetAddr(((u16)param_1->voice) | 0x2040, param_1->spu_addr_to_start_playing);
|
||||
sceSdSetAddr(((u16)stereo_cmd->voice) | 0x2040, stereo_cmd->spu_addr_to_start_playing);
|
||||
sceSdSetAddr(SD_VA_SSA | param_1->voice, param_1->spu_addr_to_start_playing);
|
||||
sceSdSetAddr(SD_VA_SSA | stereo_cmd->voice, stereo_cmd->spu_addr_to_start_playing);
|
||||
}
|
||||
sceSdkey_on_jak2_voice(param_1->voice);
|
||||
sceSdkey_on_jak2_voice(stereo_cmd->voice);
|
||||
|
||||
// sceSdSetSwitch(((u16)param_1->voice & 1) | 0x1500,
|
||||
// 1 << (voice >> 1 & 0x1fU) | 1 << (stereo_voice >> 1 & 0x1fU));
|
||||
sceSdSetParam(((u16)param_1->voice), vol_l);
|
||||
sceSdSetParam(((u16)stereo_cmd->voice), 0);
|
||||
sceSdSetParam(((u16)param_1->voice) | 0x100, 0);
|
||||
sceSdSetParam(((u16)stereo_cmd->voice) | 0x100, vol_r);
|
||||
sceSdSetSwitch(SD_S_KON | CORE_BIT(param_1->voice),
|
||||
VOICE_BIT(param_1->voice) | VOICE_BIT(stereo_cmd->voice));
|
||||
sceSdSetParam(SD_VP_VOLL | param_1->voice, vol_l);
|
||||
sceSdSetParam(SD_VP_VOLL | stereo_cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | param_1->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | stereo_cmd->voice, vol_r);
|
||||
}
|
||||
param_1->sb_paused = 0;
|
||||
stereo_cmd->sb_paused = 0;
|
||||
@@ -505,82 +343,54 @@ void RestartVag(VagCmd* param_1, int param_2, int /*param_3*/) {
|
||||
// if (param_3 == 1) {
|
||||
// CpuSuspendIntr(&local_30);
|
||||
//}
|
||||
int vol_l, vol_r;
|
||||
u32 vol_l, vol_r;
|
||||
CalculateVAGVolumes(param_1, &vol_l, &vol_r);
|
||||
if (param_1->status_bytes[BYTE11] == '\0') {
|
||||
int voice = 1 << (param_1->voice >> 1 & 0x1fU);
|
||||
auto* stereo_sibling = param_1->stereo_sibling;
|
||||
int sram_offset = param_2 ? 0x2000 : 0;
|
||||
if (stereo_sibling) {
|
||||
voice = voice | 1 << (stereo_sibling->voice >> 1 & 0x1fU);
|
||||
}
|
||||
// sceSdSetSwitch(((u16)param_1->voice & 1) | 0x1600, voice);
|
||||
sceSdkey_off_jak2_voice(param_1->voice);
|
||||
if (stereo_sibling) {
|
||||
sceSdkey_off_jak2_voice(stereo_sibling->voice);
|
||||
}
|
||||
sceSdSetParam(((u16)param_1->voice), 0);
|
||||
sceSdSetParam(((u16)param_1->voice) | 0x100, 0);
|
||||
|
||||
int other_voice;
|
||||
int sram_addr;
|
||||
if (!stereo_sibling) {
|
||||
other_voice = *(u16*)¶m_1->voice;
|
||||
sram_addr = param_1->spu_stream_dma_mem_addr;
|
||||
} else {
|
||||
sceSdSetParam(((u16)stereo_sibling->voice), 0);
|
||||
sceSdSetParam(((u16)stereo_sibling->voice) | 0x100, 0);
|
||||
sceSdSetAddr(((u16)param_1->voice) | 0x2040, param_1->spu_stream_dma_mem_addr + sram_offset);
|
||||
other_voice = ((u16)stereo_sibling->voice);
|
||||
sram_addr = stereo_sibling->spu_stream_dma_mem_addr;
|
||||
}
|
||||
sceSdSetAddr(other_voice | 0x2040, sram_addr + sram_offset);
|
||||
// sceSdSetSwitch(((u16)param_1->voice & 1) | 0x1500, voice);
|
||||
sceSdkey_on_jak2_voice(param_1->voice);
|
||||
int voices = VOICE_BIT(param_1->voice);
|
||||
if (stereo_sibling) {
|
||||
sceSdkey_on_jak2_voice(stereo_sibling->voice);
|
||||
voices |= VOICE_BIT(stereo_sibling->voice);
|
||||
}
|
||||
|
||||
if (!stereo_sibling) {
|
||||
sceSdSetParam(((u16)param_1->voice), vol_l);
|
||||
other_voice = ((u16)param_1->voice);
|
||||
} else {
|
||||
sceSdSetParam(((u16)param_1->voice), vol_l);
|
||||
sceSdSetParam(((u16)stereo_sibling->voice), 0);
|
||||
sceSdSetParam(((u16)param_1->voice) | 0x100, 0);
|
||||
other_voice = ((u16)stereo_sibling->voice);
|
||||
sceSdSetSwitch(SD_S_KOFF | CORE_BIT(param_1->voice), voices);
|
||||
|
||||
sceSdSetParam(SD_VP_VOLL | param_1->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | param_1->voice, 0);
|
||||
if (stereo_sibling) {
|
||||
sceSdSetParam(SD_VP_VOLL | stereo_sibling->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | stereo_sibling->voice, 0);
|
||||
}
|
||||
|
||||
sceSdSetAddr(SD_VA_SSA | param_1->voice, param_1->spu_stream_dma_mem_addr + sram_offset);
|
||||
if (stereo_sibling) {
|
||||
sceSdSetAddr(SD_VA_SSA | stereo_sibling->voice,
|
||||
stereo_sibling->spu_stream_dma_mem_addr + sram_offset);
|
||||
}
|
||||
|
||||
sceSdSetSwitch(SD_S_KON | CORE_BIT(param_1->voice), voices);
|
||||
|
||||
if (!stereo_sibling) {
|
||||
sceSdSetParam(SD_VP_VOLL | param_1->voice, vol_l);
|
||||
sceSdSetParam(SD_VP_VOLR | param_1->voice, vol_r);
|
||||
} else {
|
||||
sceSdSetParam(SD_VP_VOLL | param_1->voice, vol_l);
|
||||
sceSdSetParam(SD_VP_VOLL | stereo_sibling->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | param_1->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | stereo_sibling->voice, vol_r);
|
||||
}
|
||||
sceSdSetParam(other_voice | 0x100, vol_r);
|
||||
}
|
||||
// if (param_3 == 1) {
|
||||
// CpuResumeIntr(local_30);
|
||||
//}
|
||||
}
|
||||
|
||||
struct sceSdBatch {
|
||||
u32 entry;
|
||||
u32 value;
|
||||
u32 func;
|
||||
};
|
||||
|
||||
void sceSdProcBatch(sceSdBatch* b, int, int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
sceSdSetParam(b[i].entry, b[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
void SetVAGVol(VagCmd* cmd, int param_2) {
|
||||
u32 uVar1;
|
||||
u32 uVar3;
|
||||
int iVar4;
|
||||
int iVar5;
|
||||
VagCmd* stereo_cmd;
|
||||
sceSdBatch batch[6];
|
||||
u32 local_28;
|
||||
u32 local_24;
|
||||
// undefined4 local_20 [2];
|
||||
u32 lvol, rvol;
|
||||
|
||||
if (cmd == 0x0) {
|
||||
if (cmd == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (cmd->byte4 == '\0') {
|
||||
@@ -592,105 +402,43 @@ void SetVAGVol(VagCmd* cmd, int param_2) {
|
||||
if (cmd->byte11 != '\0') {
|
||||
return;
|
||||
}
|
||||
auto pvVar2 = cmd->unk_136;
|
||||
stereo_cmd = cmd->stereo_sibling;
|
||||
if (pvVar2 == 0) {
|
||||
if (cmd->unk_296 == 0) {
|
||||
local_28 = (u32)(cmd->vol_multiplier * MasterVolume[2]) >> 6;
|
||||
local_24 = local_28;
|
||||
if (0x3fff < local_28) {
|
||||
local_28 = 0x3fff;
|
||||
local_24 = local_28;
|
||||
}
|
||||
goto LAB_0000a258;
|
||||
}
|
||||
iVar4 = CalculateFallofVolume(&cmd->vec3, (u32)(cmd->vol_multiplier * MasterVolume[2]) >> 10,
|
||||
cmd->fo_curve, cmd->fo_min, cmd->fo_max);
|
||||
iVar5 = CalculateAngle(&cmd->vec3);
|
||||
uVar3 = 0x276 - iVar5;
|
||||
uVar1 = (uVar3 >> 3) / 0x2d;
|
||||
local_28 = ((s16*)gPanTable)[uVar1 * -0x2d0 + uVar3 * 2] * iVar4;
|
||||
local_24 = ((s16*)gPanTable)[uVar1 * -0x2d0 + uVar3 * 2 + 1] * iVar4;
|
||||
|
||||
if (!cmd->sound_handler) {
|
||||
CalculateVAGVolumes(cmd, &lvol, &rvol);
|
||||
} else {
|
||||
ASSERT_NOT_REACHED();
|
||||
// uVar3 = cmd->unk_176 + 0x5a;
|
||||
// uVar1 = (uVar3 >> 3) / 0x2d;
|
||||
// local_24 = (((u32)(cmd->vol_multiplier * MasterVolume[*(char *)((int)pvVar2 + 0x17)]) >>
|
||||
// 10) *
|
||||
// (int)*(short *)((int)pvVar2 + 0x10) >> 10) * 0x3fff >> 10;
|
||||
// local_28 = (int)gPanTable[uVar1 * -0x2d0 + uVar3 * 2] * local_24;
|
||||
// local_24 = (int)gPanTable[uVar1 * -0x2d0 + uVar3 * 2 + 1] * local_24;
|
||||
// TODO vag 989snd plugin
|
||||
// SoundHandler* hnd = cmd->sound_handler;
|
||||
// u32 vol =
|
||||
// 0x3fff *
|
||||
// ((((cmd->vol_multiplier * MasterVolume[hnd->VolGroup]) >> 10) * hnd->Current_Vol) >> 10)
|
||||
// >> 10;
|
||||
// lvol = (vol * gPanTable[(cmd->unk_176 + 90) % 360].left) >> 10;
|
||||
// lvol = (vol * gPanTable[(cmd->unk_176 + 90) % 360].right) >> 10;
|
||||
// if (lvol >= 0x4000) {
|
||||
// lvol = 0x3fff;
|
||||
//}
|
||||
// if (rvol >= 0x4000) {
|
||||
// rvol = 0x3fff;
|
||||
//}
|
||||
}
|
||||
local_28 = local_28 >> 10;
|
||||
local_24 = local_24 >> 10;
|
||||
if (0x3fff < local_28) {
|
||||
local_28 = 0x3fff;
|
||||
}
|
||||
if (0x3fff < local_24) {
|
||||
local_24 = 0x3fff;
|
||||
}
|
||||
LAB_0000a258:
|
||||
if (stereo_cmd == (VagCmd*)0x0) {
|
||||
batch[0].entry = *(uint16_t*)&cmd->voice;
|
||||
iVar4 = 2;
|
||||
batch[1].entry = *(u16*)&cmd->voice | 0x100;
|
||||
batch[2].entry = *(u16*)&cmd->voice | 0x200;
|
||||
iVar5 = cmd->unk_256_pitch2;
|
||||
uVar1 = cmd->pitch1;
|
||||
// printf("cmd's pitch is %d, %d\n", cmd->pitch1, cmd->unk_256_pitch2);
|
||||
batch[1].value = local_24;
|
||||
|
||||
// Originally used ProcBatch, buts this is easier to read.
|
||||
stereo_cmd = cmd->stereo_sibling;
|
||||
if (stereo_cmd) {
|
||||
sceSdSetParam(SD_VP_VOLL | cmd->voice, lvol);
|
||||
sceSdSetParam(SD_VP_VOLR | cmd->voice, 0);
|
||||
|
||||
sceSdSetParam(SD_VP_VOLL | stereo_cmd->voice, 0);
|
||||
sceSdSetParam(SD_VP_VOLR | stereo_cmd->voice, rvol);
|
||||
|
||||
sceSdSetParam(SD_VP_PITCH | cmd->voice, CalculateVAGPitch(cmd->pitch1, cmd->unk_256_pitch2));
|
||||
sceSdSetParam(SD_VP_PITCH | stereo_cmd->voice,
|
||||
CalculateVAGPitch(cmd->pitch1, cmd->unk_256_pitch2));
|
||||
} else {
|
||||
batch[0].entry = *(uint16_t*)&cmd->voice;
|
||||
batch[1].entry = *(uint16_t*)&stereo_cmd->voice;
|
||||
batch[1].value = 0;
|
||||
batch[2].value = 0;
|
||||
batch[2].entry = *(u16*)&cmd->voice | 0x100;
|
||||
batch[3].func = 1;
|
||||
batch[3].entry = *(u16*)&stereo_cmd->voice | 0x100;
|
||||
batch[4].func = 1;
|
||||
batch[4].entry = *(u16*)&cmd->voice | 0x200;
|
||||
iVar4 = cmd->unk_256_pitch2;
|
||||
batch[4].value = cmd->pitch1;
|
||||
if (iVar4 != 0) {
|
||||
if (iVar4 < 1) {
|
||||
batch[4].value = (u32)(batch[4].value * 0x5f4) / (0x5f4U - iVar4);
|
||||
if (0x5f4U - iVar4 == 0) {
|
||||
ASSERT_NOT_REACHED();
|
||||
// trap(0x1c00);
|
||||
}
|
||||
} else {
|
||||
batch[4].value = (u32)(batch[4].value * (iVar4 + 0x5f4)) / 0x5f4;
|
||||
}
|
||||
}
|
||||
iVar4 = 5;
|
||||
batch[5].func = 1;
|
||||
batch[5].entry = *(u16*)&stereo_cmd->voice | 0x200;
|
||||
iVar5 = cmd->unk_256_pitch2;
|
||||
uVar1 = cmd->pitch1;
|
||||
batch[3].value = local_24;
|
||||
}
|
||||
if (iVar5 != 0) {
|
||||
if (iVar5 < 1) {
|
||||
uVar1 = (uVar1 * 0x5f4) / (0x5f4U - iVar5);
|
||||
if (0x5f4U - iVar5 == 0) {
|
||||
ASSERT_NOT_REACHED();
|
||||
// trap(0x1c00);
|
||||
}
|
||||
} else {
|
||||
uVar1 = (uVar1 * (iVar5 + 0x5f4)) / 0x5f4;
|
||||
}
|
||||
}
|
||||
batch[2].func = 1;
|
||||
batch[1].func = 1;
|
||||
batch[0].value = local_28;
|
||||
batch[0].func = 1;
|
||||
batch[iVar4].value = uVar1;
|
||||
if (param_2 == 1) {
|
||||
// CpuSuspendIntr(local_20);
|
||||
sceSdProcBatch(batch, 0, iVar4 + 1);
|
||||
// CpuResumeIntr(local_20[0]);
|
||||
} else {
|
||||
sceSdProcBatch(batch, 0, iVar4 + 1);
|
||||
sceSdSetParam(SD_VP_VOLL | cmd->voice, lvol);
|
||||
sceSdSetParam(SD_VP_VOLR | cmd->voice, rvol);
|
||||
sceSdSetParam(SD_VP_PITCH | cmd->voice, CalculateVAGPitch(cmd->pitch1, cmd->unk_256_pitch2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -866,6 +614,7 @@ void FreeVagCmd(VagCmd* cmd, int /*param_2*/) {
|
||||
cmd->unk_188 = 0;
|
||||
cmd->unk_192 = 0;
|
||||
SetVagStreamName(cmd, 0, 0);
|
||||
|
||||
cmd->name[0] = '\0';
|
||||
cmd->unk_264 = 0x4000;
|
||||
(cmd->header).callback = NullCallback;
|
||||
@@ -886,7 +635,7 @@ void FreeVagCmd(VagCmd* cmd, int /*param_2*/) {
|
||||
cmd->unk_256_pitch2 = 0;
|
||||
cmd->id = 0;
|
||||
cmd->plugin_id = 0;
|
||||
cmd->unk_136 = 0;
|
||||
cmd->sound_handler = 0;
|
||||
cmd->priority = 0;
|
||||
cmd->unk_288 = 0;
|
||||
cmd->unk_292 = 0;
|
||||
@@ -948,15 +697,11 @@ void StopVAG(VagCmd* cmd, int /*param_2*/) {
|
||||
auto& sibling = cmd->stereo_sibling;
|
||||
PauseVAG(cmd, 0);
|
||||
if (cmd->status_bytes[BYTE5] != '\0') {
|
||||
int val = 1 << (cmd->voice >> 1 & 0x1fU);
|
||||
int val = VOICE_BIT(cmd->voice);
|
||||
if (sibling) {
|
||||
val = val | 1 << (sibling->voice >> 1 & 0x1fU);
|
||||
}
|
||||
// sceSdSetSwitch(u16(cmd->voice) & 1 | 0x1600, val);
|
||||
sceSdkey_off_jak2_voice(cmd->voice);
|
||||
if (sibling) {
|
||||
sceSdkey_off_jak2_voice(sibling->voice);
|
||||
val = val | VOICE_BIT(sibling->voice);
|
||||
}
|
||||
sceSdSetSwitch(SD_S_KOFF | CORE_BIT(cmd->voice), val);
|
||||
}
|
||||
for (auto& x : cmd->status_bytes) {
|
||||
x = 0;
|
||||
@@ -967,7 +712,7 @@ void StopVAG(VagCmd* cmd, int /*param_2*/) {
|
||||
cmd->id = 0;
|
||||
cmd->plugin_id = 0;
|
||||
(cmd->header).ready_for_data = 0;
|
||||
cmd->unk_136 = 0;
|
||||
cmd->sound_handler = 0;
|
||||
cmd->unk_140 = 0;
|
||||
cmd->pitch1 = 0;
|
||||
cmd->unk_180 = 0;
|
||||
@@ -989,16 +734,14 @@ void VAG_MarkLoopStart(int8_t* param_1) {
|
||||
}
|
||||
|
||||
int CalculateVAGPitch(int param_1, int param_2) {
|
||||
if (param_2 != 0) {
|
||||
if (param_2 < 1) {
|
||||
param_1 = (param_1 * 0x5f4) / (0x5f4U - param_2);
|
||||
if (0x5f4U - param_2 == 0) {
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
if (param_2) {
|
||||
if (param_2 <= 0) {
|
||||
return 0x5f4 * param_1 / (0x5f4 - param_2);
|
||||
} else {
|
||||
param_1 = (param_1 * (param_2 + 0x5f4)) / 0x5f4;
|
||||
return param_1 * (param_2 + 0x5f4) / 0x5f4;
|
||||
}
|
||||
}
|
||||
|
||||
return param_1;
|
||||
}
|
||||
|
||||
@@ -1018,61 +761,42 @@ void UnPauseVagStreams() {
|
||||
}
|
||||
}
|
||||
|
||||
void SetAllVagsVol(int param_1)
|
||||
|
||||
{
|
||||
int iVar1;
|
||||
VagCmd* cmd;
|
||||
|
||||
cmd = VagCmds;
|
||||
if (param_1 < 0) {
|
||||
iVar1 = 0;
|
||||
do {
|
||||
SetVAGVol(cmd, 1);
|
||||
iVar1 = iVar1 + 1;
|
||||
cmd = cmd + 1;
|
||||
} while (iVar1 < 4);
|
||||
} else {
|
||||
iVar1 = 0;
|
||||
do {
|
||||
if (cmd->unk_136) {
|
||||
void SetAllVagsVol(int param_1) {
|
||||
if (param_1 >= 0) {
|
||||
for (auto& VagCmd : VagCmds) {
|
||||
if (VagCmd.sound_handler /* && VagCmd.sound_handler->VolGroup == param_1 */) {
|
||||
ASSERT_NOT_REACHED();
|
||||
// if (*(char *)((int)cmd->unk_136 + 0x17) == param_1) {
|
||||
// SetVAGVol(cmd,1);
|
||||
// }
|
||||
cmd = cmd + 1;
|
||||
SetVAGVol(&VagCmd, 1);
|
||||
}
|
||||
iVar1 = iVar1 + 1;
|
||||
} while (iVar1 < 4);
|
||||
}
|
||||
} else {
|
||||
for (auto& VagCmd : VagCmds) {
|
||||
SetVAGVol(&VagCmd, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CalculateVAGVolumes(VagCmd* cmd, int* l_out, int* r_out) {
|
||||
// int iVar1;
|
||||
// int iVar2;
|
||||
// u32 uVar3;
|
||||
|
||||
void CalculateVAGVolumes(VagCmd* cmd, u32* l_out, u32* r_out) {
|
||||
if (cmd->unk_296 == 0) {
|
||||
u32 vol = (u32)(cmd->vol_multiplier * MasterVolume[VolumeCategory::DIALOGUE]) >> 6;
|
||||
if (0x3fff < vol) {
|
||||
if (vol >= 0x4000) {
|
||||
vol = 0x3fff;
|
||||
}
|
||||
*l_out = vol;
|
||||
*r_out = vol;
|
||||
} else {
|
||||
int fo_vol =
|
||||
CalculateFallofVolume(&cmd->vec3, (u32)(cmd->vol_multiplier * MasterVolume[2]) >> 10,
|
||||
cmd->fo_curve, cmd->fo_min, cmd->fo_max);
|
||||
int angle = CalculateAngle(&cmd->vec3);
|
||||
int uVar4 = 0x276 - angle;
|
||||
int uVar3 = (uVar4 >> 3) / 0x2d;
|
||||
auto* pan = (s16*)gPanTable;
|
||||
*l_out = (u32)(pan[uVar3 * -0x2d0 + uVar4 * 2] * fo_vol) >> 10;
|
||||
*r_out = (u32)(pan[uVar3 * -0x2d0 + uVar4 * 2 + 1] * fo_vol) >> 10;
|
||||
if (0x3fff < *l_out) {
|
||||
CalculateFalloffVolume(&cmd->vec3, (u32)(cmd->vol_multiplier * MasterVolume[2]) >> 10,
|
||||
cmd->fo_curve, cmd->fo_min, cmd->fo_max);
|
||||
|
||||
auto* pan = &gPanTable[(630 - CalculateAngle(&cmd->vec3)) % 360];
|
||||
*l_out = (pan->left * fo_vol) >> 10;
|
||||
*r_out = (pan->right * fo_vol) >> 10;
|
||||
|
||||
if (*l_out >= 0x4000) {
|
||||
*l_out = 0x3fff;
|
||||
}
|
||||
if (0x3fff < *r_out) {
|
||||
if (*r_out >= 0x4000) {
|
||||
*r_out = 0x3fff;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ struct VagCmd {
|
||||
int spu_trap_mem_addr; // 124
|
||||
int voice; // 128
|
||||
int idx_in_cmd_arr; // 132 (index in VagCmds)
|
||||
int unk_136; // 136
|
||||
int sound_handler; // 136 (989snd sound that played this stream)
|
||||
int unk_140; // 140
|
||||
int unk_176; // 176
|
||||
int unk_180; // 180
|
||||
@@ -95,7 +95,7 @@ struct VagCmd {
|
||||
int priority; // 284
|
||||
int unk_288; // 288
|
||||
int unk_292; // 292
|
||||
int unk_296; // 296
|
||||
int unk_296; // 296 (audio has world positioning)
|
||||
Vec3w vec3; // 300
|
||||
int fo_min; // 312 (init to 5)
|
||||
int fo_max; // 316 (init to 316)
|
||||
@@ -142,4 +142,4 @@ VagCmd* FindVagStreamId(int id);
|
||||
void SetVAGVol(VagCmd* cmd, int param_2);
|
||||
void SetAllVagsVol(int vol);
|
||||
void SetVagStreamsNotScanned();
|
||||
} // namespace jak2
|
||||
} // namespace jak2
|
||||
|
||||
+30
-25
@@ -26,7 +26,10 @@ snd::Voice* voice_from_entry(u32 entry) {
|
||||
}
|
||||
|
||||
u32 sceSdGetAddr(u32 entry) {
|
||||
auto* voice = voice_from_entry(entry);
|
||||
[[maybe_unused]] u32 core = entry & 1;
|
||||
[[maybe_unused]] u32 voice_id = (entry >> 1) & 0x1f;
|
||||
|
||||
auto* voice = voice_from_entry(voice_id);
|
||||
if (!voice) {
|
||||
return 0;
|
||||
}
|
||||
@@ -38,35 +41,36 @@ u32 sceSdGetAddr(u32 entry) {
|
||||
return voice->GetNax() << 1;
|
||||
}
|
||||
|
||||
void sceSdSetSwitch(u32 entry, u32 /*value*/) {
|
||||
// we can ignore this, only used for vmix
|
||||
void sceSdSetSwitch(u32 entry, u32 value) {
|
||||
u32 reg = entry & ~0x3f;
|
||||
switch (reg) {
|
||||
case 0x1500:
|
||||
voice_from_entry(entry)->KeyOn();
|
||||
voice_from_entry(entry + 1)->KeyOn();
|
||||
break;
|
||||
case 0x1600:
|
||||
voice_from_entry(entry)->KeyOff();
|
||||
break;
|
||||
u8 voice = 0;
|
||||
while (value) {
|
||||
u8 bit = value & 1;
|
||||
|
||||
if (bit) {
|
||||
switch (reg) {
|
||||
case SD_S_KON:
|
||||
voice_from_entry(voice)->KeyOn();
|
||||
break;
|
||||
case SD_S_KOFF:
|
||||
voice_from_entry(voice)->KeyOff();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
voice++;
|
||||
value >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void sceSdkey_on_jak2_voice(int id) {
|
||||
voice_from_entry(id)->KeyOn();
|
||||
}
|
||||
|
||||
void sceSdkey_off_jak2_voice(int id) {
|
||||
voice_from_entry(id)->KeyOff();
|
||||
}
|
||||
|
||||
void sceSdSetAddr(u32 entry, u32 value) {
|
||||
auto* voice = voice_from_entry(entry);
|
||||
[[maybe_unused]] u32 core = entry & 1;
|
||||
[[maybe_unused]] u32 voice_id = (entry >> 1) & 0x1f;
|
||||
|
||||
auto* voice = voice_from_entry(voice_id);
|
||||
if (!voice) {
|
||||
return;
|
||||
}
|
||||
[[maybe_unused]] u32 core = entry & 1;
|
||||
[[maybe_unused]] u32 voice_id = (entry >> 1) & 0x1f;
|
||||
u32 reg = entry & ~0x3f;
|
||||
|
||||
switch (reg) {
|
||||
@@ -84,12 +88,13 @@ void sceSdSetAddr(u32 entry, u32 value) {
|
||||
}
|
||||
|
||||
void sceSdSetParam(u32 entry, u32 value) {
|
||||
auto* voice = voice_from_entry(entry);
|
||||
[[maybe_unused]] u32 core = entry & 1;
|
||||
[[maybe_unused]] u32 voice_id = (entry >> 1) & 0x1f;
|
||||
|
||||
auto* voice = voice_from_entry(voice_id);
|
||||
if (!voice) {
|
||||
return;
|
||||
}
|
||||
[[maybe_unused]] u32 core = entry & 1;
|
||||
[[maybe_unused]] u32 voice_id = (entry >> 1) & 0x1f;
|
||||
u32 reg = entry & ~0x3f;
|
||||
|
||||
switch (reg) {
|
||||
|
||||
+3
-2
@@ -15,6 +15,9 @@
|
||||
#define SD_VP_ADSR1 (0x03 << 8)
|
||||
#define SD_VP_ADSR2 (0x04 << 8)
|
||||
#define SD_VA_NAX ((0x22 << 8) + (0x01 << 6))
|
||||
#define SD_S_KON (0x15 << 8)
|
||||
#define SD_S_KOFF (0x16 << 8)
|
||||
#define SD_VOICE(_core, _v) ((_core) | ((_v) << 1))
|
||||
|
||||
extern std::shared_ptr<snd::Voice> voices[4];
|
||||
extern u8 spu_memory[0x15160 * 10];
|
||||
@@ -28,5 +31,3 @@ void sceSdSetAddr(u32 entry, u32 value);
|
||||
void sceSdSetParam(u32 entry, u32 value);
|
||||
void sceSdSetTransIntrHandler(s32 channel, sceSdTransIntrHandler, void* data);
|
||||
u32 sceSdVoiceTrans(s32 channel, s32 mode, void* iop_addr, u32 spu_addr, u32 size);
|
||||
void sceSdkey_on_jak2_voice(int id);
|
||||
void sceSdkey_off_jak2_voice(int id);
|
||||
|
||||
Reference in New Issue
Block a user