mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #233 from delroth/dsphle-cleanups
DSPHLE Zelda cleanups
This commit is contained in:
commit
bad109402e
@ -14,42 +14,30 @@
|
||||
|
||||
|
||||
ZeldaUCode::ZeldaUCode(DSPHLE *dsphle, u32 crc)
|
||||
:
|
||||
UCodeInterface(dsphle, crc),
|
||||
|
||||
m_bSyncInProgress(false),
|
||||
m_MaxVoice(0),
|
||||
|
||||
m_NumSyncMail(0),
|
||||
|
||||
m_NumVoices(0),
|
||||
|
||||
m_bSyncCmdPending(false),
|
||||
m_CurVoice(0),
|
||||
m_CurBuffer(0),
|
||||
m_NumBuffers(0),
|
||||
|
||||
m_VoicePBsAddr(0),
|
||||
m_UnkTableAddr(0),
|
||||
m_ReverbPBsAddr(0),
|
||||
|
||||
m_RightBuffersAddr(0),
|
||||
m_LeftBuffersAddr(0),
|
||||
m_pos(0),
|
||||
|
||||
m_DMABaseAddr(0),
|
||||
|
||||
m_numSteps(0),
|
||||
m_bListInProgress(false),
|
||||
m_step(0),
|
||||
|
||||
m_readOffset(0),
|
||||
|
||||
m_MailState(WaitForMail),
|
||||
|
||||
m_NumPBs(0),
|
||||
m_PBAddress(0),
|
||||
m_PBAddress2(0)
|
||||
: UCodeInterface(dsphle, crc),
|
||||
m_sync_in_progress(false),
|
||||
m_max_voice(0),
|
||||
m_num_sync_mail(0),
|
||||
m_num_voices(0),
|
||||
m_sync_cmd_pending(false),
|
||||
m_current_voice(0),
|
||||
m_current_buffer(0),
|
||||
m_num_buffers(0),
|
||||
m_voice_pbs_addr(0),
|
||||
m_unk_table_addr(0),
|
||||
m_reverb_pbs_addr(0),
|
||||
m_right_buffers_addr(0),
|
||||
m_left_buffers_addr(0),
|
||||
m_pos(0),
|
||||
m_dma_base_addr(0),
|
||||
m_num_steps(0),
|
||||
m_list_in_progress(false),
|
||||
m_step(0),
|
||||
m_read_offset(0),
|
||||
m_mail_state(WaitForMail),
|
||||
m_num_pbs(0),
|
||||
m_pb_address(0),
|
||||
m_pb_address2(0)
|
||||
{
|
||||
DEBUG_LOG(DSPHLE, "UCode_Zelda - add boot mails for handshake");
|
||||
|
||||
@ -65,31 +53,31 @@ ZeldaUCode::ZeldaUCode(DSPHLE *dsphle, u32 crc)
|
||||
m_mail_handler.PushMail(0xF3551111); // handshake
|
||||
}
|
||||
|
||||
m_VoiceBuffer = new s32[256 * 1024];
|
||||
m_ResampleBuffer = new s16[256 * 1024];
|
||||
m_LeftBuffer = new s32[256 * 1024];
|
||||
m_RightBuffer = new s32[256 * 1024];
|
||||
m_voice_buffer = new s32[256 * 1024];
|
||||
m_resample_buffer = new s16[256 * 1024];
|
||||
m_left_buffer = new s32[256 * 1024];
|
||||
m_right_buffer = new s32[256 * 1024];
|
||||
|
||||
memset(m_Buffer, 0, sizeof(m_Buffer));
|
||||
memset(m_SyncFlags, 0, sizeof(m_SyncFlags));
|
||||
memset(m_AFCCoefTable, 0, sizeof(m_AFCCoefTable));
|
||||
memset(m_PBMask, 0, sizeof(m_PBMask));
|
||||
memset(m_buffer, 0, sizeof(m_buffer));
|
||||
memset(m_sync_flags, 0, sizeof(m_sync_flags));
|
||||
memset(m_afc_coef_table, 0, sizeof(m_afc_coef_table));
|
||||
memset(m_pb_mask, 0, sizeof(m_pb_mask));
|
||||
}
|
||||
|
||||
ZeldaUCode::~ZeldaUCode()
|
||||
{
|
||||
m_mail_handler.Clear();
|
||||
|
||||
delete [] m_VoiceBuffer;
|
||||
delete [] m_ResampleBuffer;
|
||||
delete [] m_LeftBuffer;
|
||||
delete [] m_RightBuffer;
|
||||
delete [] m_voice_buffer;
|
||||
delete [] m_resample_buffer;
|
||||
delete [] m_left_buffer;
|
||||
delete [] m_right_buffer;
|
||||
}
|
||||
|
||||
u8 *ZeldaUCode::GetARAMPointer(u32 address)
|
||||
{
|
||||
if (IsDMAVersion())
|
||||
return Memory::GetPointer(m_DMABaseAddr) + address;
|
||||
return Memory::GetPointer(m_dma_base_addr) + address;
|
||||
else
|
||||
return DSP::GetARAMPtr() + address;
|
||||
}
|
||||
@ -122,125 +110,125 @@ void ZeldaUCode::HandleMail(u32 mail)
|
||||
void ZeldaUCode::HandleMail_LightVersion(u32 mail)
|
||||
{
|
||||
//ERROR_LOG(DSPHLE, "Light version mail %08X, list in progress: %s, step: %i/%i",
|
||||
// mail, m_bListInProgress ? "yes":"no", m_step, m_numSteps);
|
||||
// mail, m_list_in_progress ? "yes":"no", m_step, m_num_steps);
|
||||
|
||||
if (m_bSyncCmdPending)
|
||||
if (m_sync_cmd_pending)
|
||||
{
|
||||
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
||||
|
||||
MixAudio();
|
||||
|
||||
m_CurBuffer++;
|
||||
m_current_buffer++;
|
||||
|
||||
if (m_CurBuffer == m_NumBuffers)
|
||||
if (m_current_buffer == m_num_buffers)
|
||||
{
|
||||
m_bSyncCmdPending = false;
|
||||
m_sync_cmd_pending = false;
|
||||
DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_bListInProgress)
|
||||
if (!m_list_in_progress)
|
||||
{
|
||||
switch ((mail >> 24) & 0x7F)
|
||||
{
|
||||
case 0x00: m_numSteps = 1; break; // dummy
|
||||
case 0x01: m_numSteps = 5; break; // DsetupTable
|
||||
case 0x02: m_numSteps = 3; break; // DsyncFrame
|
||||
case 0x00: m_num_steps = 1; break; // dummy
|
||||
case 0x01: m_num_steps = 5; break; // DsetupTable
|
||||
case 0x02: m_num_steps = 3; break; // DsyncFrame
|
||||
|
||||
default:
|
||||
{
|
||||
m_numSteps = 0;
|
||||
m_num_steps = 0;
|
||||
PanicAlert("Zelda uCode (light version): unknown/unsupported command %02X", (mail >> 24) & 0x7F);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
m_bListInProgress = true;
|
||||
m_list_in_progress = true;
|
||||
m_step = 0;
|
||||
}
|
||||
|
||||
if (m_step >= sizeof(m_Buffer) / 4)
|
||||
if (m_step >= sizeof(m_buffer) / 4)
|
||||
PanicAlert("m_step out of range");
|
||||
|
||||
((u32*)m_Buffer)[m_step] = mail;
|
||||
((u32*)m_buffer)[m_step] = mail;
|
||||
m_step++;
|
||||
|
||||
if (m_step >= m_numSteps)
|
||||
if (m_step >= m_num_steps)
|
||||
{
|
||||
ExecuteList();
|
||||
m_bListInProgress = false;
|
||||
m_list_in_progress = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ZeldaUCode::HandleMail_SMSVersion(u32 mail)
|
||||
{
|
||||
if (m_bSyncInProgress)
|
||||
if (m_sync_in_progress)
|
||||
{
|
||||
if (m_bSyncCmdPending)
|
||||
if (m_sync_cmd_pending)
|
||||
{
|
||||
m_SyncFlags[(m_NumSyncMail << 1) ] = mail >> 16;
|
||||
m_SyncFlags[(m_NumSyncMail << 1) + 1] = mail & 0xFFFF;
|
||||
m_sync_flags[(m_num_sync_mail << 1) ] = mail >> 16;
|
||||
m_sync_flags[(m_num_sync_mail << 1) + 1] = mail & 0xFFFF;
|
||||
|
||||
m_NumSyncMail++;
|
||||
if (m_NumSyncMail == 2)
|
||||
m_num_sync_mail++;
|
||||
if (m_num_sync_mail == 2)
|
||||
{
|
||||
m_NumSyncMail = 0;
|
||||
m_bSyncInProgress = false;
|
||||
m_num_sync_mail = 0;
|
||||
m_sync_in_progress = false;
|
||||
|
||||
MixAudio();
|
||||
|
||||
m_CurBuffer++;
|
||||
m_current_buffer++;
|
||||
|
||||
m_mail_handler.PushMail(DSP_SYNC);
|
||||
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
||||
m_mail_handler.PushMail(0xF355FF00 | m_CurBuffer);
|
||||
m_mail_handler.PushMail(0xF355FF00 | m_current_buffer);
|
||||
|
||||
if (m_CurBuffer == m_NumBuffers)
|
||||
if (m_current_buffer == m_num_buffers)
|
||||
{
|
||||
m_mail_handler.PushMail(DSP_FRAME_END);
|
||||
// DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
||||
|
||||
m_bSyncCmdPending = false;
|
||||
m_sync_cmd_pending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bSyncInProgress = false;
|
||||
m_sync_in_progress = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_bListInProgress)
|
||||
if (m_list_in_progress)
|
||||
{
|
||||
if (m_step >= sizeof(m_Buffer) / 4)
|
||||
if (m_step >= sizeof(m_buffer) / 4)
|
||||
PanicAlert("m_step out of range");
|
||||
|
||||
((u32*)m_Buffer)[m_step] = mail;
|
||||
((u32*)m_buffer)[m_step] = mail;
|
||||
m_step++;
|
||||
|
||||
if (m_step >= m_numSteps)
|
||||
if (m_step >= m_num_steps)
|
||||
{
|
||||
ExecuteList();
|
||||
m_bListInProgress = false;
|
||||
m_list_in_progress = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Here holds: m_bSyncInProgress == false && m_bListInProgress == false
|
||||
// Here holds: m_sync_in_progress == false && m_list_in_progress == false
|
||||
|
||||
if (mail == 0)
|
||||
{
|
||||
m_bSyncInProgress = true;
|
||||
m_NumSyncMail = 0;
|
||||
m_sync_in_progress = true;
|
||||
m_num_sync_mail = 0;
|
||||
}
|
||||
else if ((mail >> 16) == 0)
|
||||
{
|
||||
m_bListInProgress = true;
|
||||
m_numSteps = mail;
|
||||
m_list_in_progress = true;
|
||||
m_num_steps = mail;
|
||||
m_step = 0;
|
||||
}
|
||||
else if ((mail >> 16) == 0xCDD1) // A 0xCDD1000X mail should come right after we send a DSP_SYNCEND mail
|
||||
@ -280,65 +268,65 @@ void ZeldaUCode::HandleMail_NormalVersion(u32 mail)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_bSyncInProgress)
|
||||
if (m_sync_in_progress)
|
||||
{
|
||||
if (m_bSyncCmdPending)
|
||||
if (m_sync_cmd_pending)
|
||||
{
|
||||
u32 n = (mail >> 16) & 0xF;
|
||||
m_MaxVoice = (n + 1) << 4;
|
||||
m_SyncFlags[n] = mail & 0xFFFF;
|
||||
m_bSyncInProgress = false;
|
||||
m_max_voice = (n + 1) << 4;
|
||||
m_sync_flags[n] = mail & 0xFFFF;
|
||||
m_sync_in_progress = false;
|
||||
|
||||
m_CurVoice = m_MaxVoice;
|
||||
m_current_voice = m_max_voice;
|
||||
|
||||
if (m_CurVoice >= m_NumVoices)
|
||||
if (m_current_voice >= m_num_voices)
|
||||
{
|
||||
MixAudio();
|
||||
|
||||
m_CurBuffer++;
|
||||
m_current_buffer++;
|
||||
|
||||
m_mail_handler.PushMail(DSP_SYNC);
|
||||
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
||||
m_mail_handler.PushMail(0xF355FF00 | m_CurBuffer);
|
||||
m_mail_handler.PushMail(0xF355FF00 | m_current_buffer);
|
||||
|
||||
m_CurVoice = 0;
|
||||
m_current_voice = 0;
|
||||
|
||||
if (m_CurBuffer == m_NumBuffers)
|
||||
if (m_current_buffer == m_num_buffers)
|
||||
{
|
||||
if (!IsDMAVersion()) // this is a hack... without it Pikmin 1 Wii/ Zelda TP Wii mail-s stopped
|
||||
m_mail_handler.PushMail(DSP_FRAME_END);
|
||||
//g_dspInitialize.pGenerateDSPInterrupt();
|
||||
|
||||
m_bSyncCmdPending = false;
|
||||
m_sync_cmd_pending = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bSyncInProgress = false;
|
||||
m_sync_in_progress = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_bListInProgress)
|
||||
if (m_list_in_progress)
|
||||
{
|
||||
if (m_step >= sizeof(m_Buffer) / 4)
|
||||
if (m_step >= sizeof(m_buffer) / 4)
|
||||
PanicAlert("m_step out of range");
|
||||
|
||||
((u32*)m_Buffer)[m_step] = mail;
|
||||
((u32*)m_buffer)[m_step] = mail;
|
||||
m_step++;
|
||||
|
||||
if (m_step >= m_numSteps)
|
||||
if (m_step >= m_num_steps)
|
||||
{
|
||||
ExecuteList();
|
||||
m_bListInProgress = false;
|
||||
m_list_in_progress = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Here holds: m_bSyncInProgress == false && m_bListInProgress == false
|
||||
// Here holds: m_sync_in_progress == false && m_list_in_progress == false
|
||||
|
||||
// Zelda-only mails:
|
||||
// - 0000XXXX - Begin list
|
||||
@ -347,12 +335,12 @@ void ZeldaUCode::HandleMail_NormalVersion(u32 mail)
|
||||
|
||||
if (mail == 0)
|
||||
{
|
||||
m_bSyncInProgress = true;
|
||||
m_sync_in_progress = true;
|
||||
}
|
||||
else if ((mail >> 16) == 0)
|
||||
{
|
||||
m_bListInProgress = true;
|
||||
m_numSteps = mail;
|
||||
m_list_in_progress = true;
|
||||
m_num_steps = mail;
|
||||
m_step = 0;
|
||||
}
|
||||
else if ((mail >> 16) == 0xCDD1) // A 0xCDD1000X mail should come right after we send a DSP_FRAME_END mail
|
||||
@ -393,22 +381,22 @@ void ZeldaUCode::HandleMail_NormalVersion(u32 mail)
|
||||
void ZeldaUCode::ExecuteList()
|
||||
{
|
||||
// begin with the list
|
||||
m_readOffset = 0;
|
||||
m_read_offset = 0;
|
||||
|
||||
u32 CmdMail = Read32();
|
||||
u32 Command = (CmdMail >> 24) & 0x7f;
|
||||
u32 Sync;
|
||||
u32 ExtraData = CmdMail & 0xFFFF;
|
||||
u32 cmd_mail = Read32();
|
||||
u32 command = (cmd_mail >> 24) & 0x7f;
|
||||
u32 sync;
|
||||
u32 extra_data = cmd_mail & 0xFFFF;
|
||||
|
||||
if (IsLightVersion())
|
||||
Sync = 0x62 + (Command << 1); // seen in DSP_UC_Luigi.txt
|
||||
sync = 0x62 + (command << 1); // seen in DSP_UC_Luigi.txt
|
||||
else
|
||||
Sync = CmdMail >> 16;
|
||||
sync = cmd_mail >> 16;
|
||||
|
||||
DEBUG_LOG(DSPHLE, "==============================================================================");
|
||||
DEBUG_LOG(DSPHLE, "Zelda UCode - execute dlist (command: 0x%04x : sync: 0x%04x)", Command, Sync);
|
||||
DEBUG_LOG(DSPHLE, "Zelda UCode - execute dlist (command: 0x%04x : sync: 0x%04x)", command, sync);
|
||||
|
||||
switch (Command)
|
||||
switch (command)
|
||||
{
|
||||
// dummy
|
||||
case 0x00: break;
|
||||
@ -416,56 +404,56 @@ void ZeldaUCode::ExecuteList()
|
||||
// DsetupTable ... zelda ww jumps to 0x0095
|
||||
case 0x01:
|
||||
{
|
||||
m_NumVoices = ExtraData;
|
||||
m_VoicePBsAddr = Read32() & 0x7FFFFFFF;
|
||||
m_UnkTableAddr = Read32() & 0x7FFFFFFF;
|
||||
m_AFCCoefTableAddr = Read32() & 0x7FFFFFFF;
|
||||
m_ReverbPBsAddr = Read32() & 0x7FFFFFFF; // WARNING: reverb PBs are very different from voice PBs!
|
||||
m_num_voices = extra_data;
|
||||
m_voice_pbs_addr = Read32() & 0x7FFFFFFF;
|
||||
m_unk_table_addr = Read32() & 0x7FFFFFFF;
|
||||
m_afc_coef_table_addr = Read32() & 0x7FFFFFFF;
|
||||
m_reverb_pbs_addr = Read32() & 0x7FFFFFFF; // WARNING: reverb PBs are very different from voice PBs!
|
||||
|
||||
// Read the other table
|
||||
u16 *TempPtr = (u16*)Memory::GetPointer(m_UnkTableAddr);
|
||||
u16 *tmp_ptr = (u16*)Memory::GetPointer(m_unk_table_addr);
|
||||
for (int i = 0; i < 0x280; i++)
|
||||
m_MiscTable[i] = (s16)Common::swap16(TempPtr[i]);
|
||||
m_misc_table[i] = (s16)Common::swap16(tmp_ptr[i]);
|
||||
|
||||
// Read AFC coef table
|
||||
TempPtr = (u16*)Memory::GetPointer(m_AFCCoefTableAddr);
|
||||
tmp_ptr = (u16*)Memory::GetPointer(m_afc_coef_table_addr);
|
||||
for (int i = 0; i < 32; i++)
|
||||
m_AFCCoefTable[i] = (s16)Common::swap16(TempPtr[i]);
|
||||
m_afc_coef_table[i] = (s16)Common::swap16(tmp_ptr[i]);
|
||||
|
||||
DEBUG_LOG(DSPHLE, "DsetupTable");
|
||||
DEBUG_LOG(DSPHLE, "Num voice param blocks: %i", m_NumVoices);
|
||||
DEBUG_LOG(DSPHLE, "Voice param blocks address: 0x%08x", m_VoicePBsAddr);
|
||||
DEBUG_LOG(DSPHLE, "Num voice param blocks: %i", m_num_voices);
|
||||
DEBUG_LOG(DSPHLE, "Voice param blocks address: 0x%08x", m_voice_pbs_addr);
|
||||
|
||||
// This points to some strange data table. Don't know yet what it's for. Reverb coefs?
|
||||
DEBUG_LOG(DSPHLE, "DSPRES_FILTER (size: 0x40): 0x%08x", m_UnkTableAddr);
|
||||
DEBUG_LOG(DSPHLE, "DSPRES_FILTER (size: 0x40): 0x%08x", m_unk_table_addr);
|
||||
|
||||
// Zelda WW: This points to a 64-byte array of coefficients, which are EXACTLY the same
|
||||
// as the AFC ADPCM coef array in decode.c of the in_cube winamp plugin,
|
||||
// which can play Zelda audio. So, these should definitely be used when decoding AFC.
|
||||
DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x500): 0x%08x", m_AFCCoefTableAddr);
|
||||
DEBUG_LOG(DSPHLE, "Reverb param blocks address: 0x%08x", m_ReverbPBsAddr);
|
||||
DEBUG_LOG(DSPHLE, "DSPADPCM_FILTER (size: 0x500): 0x%08x", m_afc_coef_table_addr);
|
||||
DEBUG_LOG(DSPHLE, "Reverb param blocks address: 0x%08x", m_reverb_pbs_addr);
|
||||
}
|
||||
break;
|
||||
|
||||
// SyncFrame ... zelda ww jumps to 0x0243
|
||||
case 0x02:
|
||||
{
|
||||
m_bSyncCmdPending = true;
|
||||
m_sync_cmd_pending = true;
|
||||
|
||||
m_CurBuffer = 0;
|
||||
m_NumBuffers = (CmdMail >> 16) & 0xFF;
|
||||
m_current_buffer = 0;
|
||||
m_num_buffers = (cmd_mail >> 16) & 0xFF;
|
||||
|
||||
// Addresses for right & left buffers in main memory
|
||||
// Each buffer is 160 bytes long. The number of (both left & right) buffers
|
||||
// is set by the first mail of the list.
|
||||
m_LeftBuffersAddr = Read32() & 0x7FFFFFFF;
|
||||
m_RightBuffersAddr = Read32() & 0x7FFFFFFF;
|
||||
m_left_buffers_addr = Read32() & 0x7FFFFFFF;
|
||||
m_right_buffers_addr = Read32() & 0x7FFFFFFF;
|
||||
|
||||
DEBUG_LOG(DSPHLE, "DsyncFrame");
|
||||
// These alternate between three sets of mixing buffers. They are all three fairly near,
|
||||
// but not at, the ADMA read addresses.
|
||||
DEBUG_LOG(DSPHLE, "Right buffer address: 0x%08x", m_RightBuffersAddr);
|
||||
DEBUG_LOG(DSPHLE, "Left buffer address: 0x%08x", m_LeftBuffersAddr);
|
||||
DEBUG_LOG(DSPHLE, "Right buffer address: 0x%08x", m_right_buffers_addr);
|
||||
DEBUG_LOG(DSPHLE, "Left buffer address: 0x%08x", m_left_buffers_addr);
|
||||
|
||||
if (IsLightVersion())
|
||||
break;
|
||||
@ -498,31 +486,31 @@ void ZeldaUCode::ExecuteList()
|
||||
// In the Zelda ucode, it is dummy, because this ucode uses accelerator for audio data transfers.
|
||||
case 0x0e:
|
||||
{
|
||||
m_DMABaseAddr = Read32() & 0x7FFFFFFF;
|
||||
m_dma_base_addr = Read32() & 0x7FFFFFFF;
|
||||
DEBUG_LOG(DSPHLE, "DsetDMABaseAddr");
|
||||
DEBUG_LOG(DSPHLE, "DMA base address: 0x%08x", m_DMABaseAddr);
|
||||
DEBUG_LOG(DSPHLE, "DMA base address: 0x%08x", m_dma_base_addr);
|
||||
}
|
||||
break;
|
||||
|
||||
// default ... zelda ww jumps to 0x0043
|
||||
default:
|
||||
PanicAlert("Zelda UCode - unknown command: %x (size %i)", Command, m_numSteps);
|
||||
PanicAlert("Zelda UCode - unknown command: %x (size %i)", command, m_num_steps);
|
||||
break;
|
||||
}
|
||||
|
||||
// sync, we are ready
|
||||
if (IsLightVersion())
|
||||
{
|
||||
if (m_bSyncCmdPending)
|
||||
m_mail_handler.PushMail(0x80000000 | m_NumBuffers); // after CMD_2
|
||||
if (m_sync_cmd_pending)
|
||||
m_mail_handler.PushMail(0x80000000 | m_num_buffers); // after CMD_2
|
||||
else
|
||||
m_mail_handler.PushMail(0x80000000 | Sync); // after CMD_0, CMD_1
|
||||
m_mail_handler.PushMail(0x80000000 | sync); // after CMD_0, CMD_1
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mail_handler.PushMail(DSP_SYNC);
|
||||
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
|
||||
m_mail_handler.PushMail(0xF3550000 | Sync);
|
||||
m_mail_handler.PushMail(0xF3550000 | sync);
|
||||
}
|
||||
}
|
||||
|
||||
@ -533,46 +521,46 @@ u32 ZeldaUCode::GetUpdateMs()
|
||||
|
||||
void ZeldaUCode::DoState(PointerWrap &p)
|
||||
{
|
||||
p.Do(m_AFCCoefTable);
|
||||
p.Do(m_MiscTable);
|
||||
p.Do(m_afc_coef_table);
|
||||
p.Do(m_misc_table);
|
||||
|
||||
p.Do(m_bSyncInProgress);
|
||||
p.Do(m_MaxVoice);
|
||||
p.Do(m_SyncFlags);
|
||||
p.Do(m_sync_in_progress);
|
||||
p.Do(m_max_voice);
|
||||
p.Do(m_sync_flags);
|
||||
|
||||
p.Do(m_NumSyncMail);
|
||||
p.Do(m_num_sync_mail);
|
||||
|
||||
p.Do(m_NumVoices);
|
||||
p.Do(m_num_voices);
|
||||
|
||||
p.Do(m_bSyncCmdPending);
|
||||
p.Do(m_CurVoice);
|
||||
p.Do(m_CurBuffer);
|
||||
p.Do(m_NumBuffers);
|
||||
p.Do(m_sync_cmd_pending);
|
||||
p.Do(m_current_voice);
|
||||
p.Do(m_current_buffer);
|
||||
p.Do(m_num_buffers);
|
||||
|
||||
p.Do(m_VoicePBsAddr);
|
||||
p.Do(m_UnkTableAddr);
|
||||
p.Do(m_AFCCoefTableAddr);
|
||||
p.Do(m_ReverbPBsAddr);
|
||||
p.Do(m_voice_pbs_addr);
|
||||
p.Do(m_unk_table_addr);
|
||||
p.Do(m_afc_coef_table_addr);
|
||||
p.Do(m_reverb_pbs_addr);
|
||||
|
||||
p.Do(m_RightBuffersAddr);
|
||||
p.Do(m_LeftBuffersAddr);
|
||||
p.Do(m_right_buffers_addr);
|
||||
p.Do(m_left_buffers_addr);
|
||||
p.Do(m_pos);
|
||||
|
||||
p.Do(m_DMABaseAddr);
|
||||
p.Do(m_dma_base_addr);
|
||||
|
||||
p.Do(m_numSteps);
|
||||
p.Do(m_bListInProgress);
|
||||
p.Do(m_num_steps);
|
||||
p.Do(m_list_in_progress);
|
||||
p.Do(m_step);
|
||||
p.Do(m_Buffer);
|
||||
p.Do(m_buffer);
|
||||
|
||||
p.Do(m_readOffset);
|
||||
p.Do(m_read_offset);
|
||||
|
||||
p.Do(m_MailState);
|
||||
p.Do(m_PBMask);
|
||||
p.Do(m_mail_state);
|
||||
p.Do(m_pb_mask);
|
||||
|
||||
p.Do(m_NumPBs);
|
||||
p.Do(m_PBAddress);
|
||||
p.Do(m_PBAddress2);
|
||||
p.Do(m_num_pbs);
|
||||
p.Do(m_pb_address);
|
||||
p.Do(m_pb_address2);
|
||||
|
||||
DoStateShared(p);
|
||||
}
|
||||
|
@ -140,8 +140,8 @@ public:
|
||||
|
||||
u32 Read32()
|
||||
{
|
||||
u32 res = *(u32*)&m_Buffer[m_readOffset];
|
||||
m_readOffset += 4;
|
||||
u32 res = *(u32*)&m_buffer[m_read_offset];
|
||||
m_read_offset += 4;
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -198,52 +198,52 @@ private:
|
||||
}
|
||||
|
||||
// These are the only dynamically allocated things allowed in the ucode.
|
||||
s32* m_VoiceBuffer;
|
||||
s16* m_ResampleBuffer;
|
||||
s32* m_LeftBuffer;
|
||||
s32* m_RightBuffer;
|
||||
s32* m_voice_buffer;
|
||||
s16* m_resample_buffer;
|
||||
s32* m_left_buffer;
|
||||
s32* m_right_buffer;
|
||||
|
||||
// If you add variables, remember to keep DoState() and the constructor up to date.
|
||||
|
||||
s16 m_AFCCoefTable[32];
|
||||
s16 m_MiscTable[0x280];
|
||||
s16 m_afc_coef_table[32];
|
||||
s16 m_misc_table[0x280];
|
||||
|
||||
bool m_bSyncInProgress;
|
||||
u32 m_MaxVoice;
|
||||
u32 m_SyncFlags[16];
|
||||
bool m_sync_in_progress;
|
||||
u32 m_max_voice;
|
||||
u32 m_sync_flags[16];
|
||||
|
||||
// Used by SMS version
|
||||
u32 m_NumSyncMail;
|
||||
u32 m_num_sync_mail;
|
||||
|
||||
u32 m_NumVoices;
|
||||
u32 m_num_voices;
|
||||
|
||||
bool m_bSyncCmdPending;
|
||||
u32 m_CurVoice;
|
||||
u32 m_CurBuffer;
|
||||
u32 m_NumBuffers;
|
||||
bool m_sync_cmd_pending;
|
||||
u32 m_current_voice;
|
||||
u32 m_current_buffer;
|
||||
u32 m_num_buffers;
|
||||
|
||||
// Those are set by command 0x1 (DsetupTable)
|
||||
u32 m_VoicePBsAddr;
|
||||
u32 m_UnkTableAddr;
|
||||
u32 m_AFCCoefTableAddr;
|
||||
u32 m_ReverbPBsAddr;
|
||||
u32 m_voice_pbs_addr;
|
||||
u32 m_unk_table_addr;
|
||||
u32 m_afc_coef_table_addr;
|
||||
u32 m_reverb_pbs_addr;
|
||||
|
||||
u32 m_RightBuffersAddr;
|
||||
u32 m_LeftBuffersAddr;
|
||||
u32 m_right_buffers_addr;
|
||||
u32 m_left_buffers_addr;
|
||||
//u32 m_unkAddr;
|
||||
u32 m_pos;
|
||||
|
||||
// Only in SMG ucode
|
||||
// Set by command 0xE (DsetDMABaseAddr)
|
||||
u32 m_DMABaseAddr;
|
||||
u32 m_dma_base_addr;
|
||||
|
||||
// List, buffer management =====================
|
||||
u32 m_numSteps;
|
||||
bool m_bListInProgress;
|
||||
u32 m_num_steps;
|
||||
bool m_list_in_progress;
|
||||
u32 m_step;
|
||||
u8 m_Buffer[1024];
|
||||
u8 m_buffer[1024];
|
||||
|
||||
u32 m_readOffset;
|
||||
u32 m_read_offset;
|
||||
|
||||
enum EMailState
|
||||
{
|
||||
@ -253,12 +253,12 @@ private:
|
||||
ReadingSystemMsg
|
||||
};
|
||||
|
||||
EMailState m_MailState;
|
||||
u16 m_PBMask[0x10];
|
||||
EMailState m_mail_state;
|
||||
u16 m_pb_mask[0x10];
|
||||
|
||||
u32 m_NumPBs;
|
||||
u32 m_PBAddress; // The main param block array
|
||||
u32 m_PBAddress2; // 4 smaller param blocks
|
||||
u32 m_num_pbs;
|
||||
u32 m_pb_address; // The main param block array
|
||||
u32 m_pb_address2; // 4 smaller param blocks
|
||||
|
||||
void ExecuteList();
|
||||
|
||||
|
@ -1,180 +0,0 @@
|
||||
|
||||
#if 0
|
||||
void ZeldaUCode::UpdatePB(ZPB& _rPB, int *templbuffer, int *temprbuffer, u32 _Size)
|
||||
{
|
||||
u16* pTest = (u16*)&_rPB;
|
||||
|
||||
// Checks at 0293
|
||||
if (pTest[0x00] == 0)
|
||||
return;
|
||||
|
||||
if (pTest[0x01] != 0)
|
||||
return;
|
||||
|
||||
|
||||
if (pTest[0x06] != 0x00)
|
||||
{
|
||||
// probably pTest[0x06] == 0 -> AFC (and variants)
|
||||
// See 02a4
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (_rPB.type) // or Bytes per Sample
|
||||
{
|
||||
case 0x05:
|
||||
case 0x09:
|
||||
{
|
||||
// initialize "decoder" if the sample is played the first time
|
||||
if (pTest[0x04] != 0)
|
||||
{
|
||||
// This is 0717_ReadOutPBStuff
|
||||
|
||||
// increment 4fb
|
||||
|
||||
// zelda:
|
||||
// perhaps init or "has played before"
|
||||
pTest[0x32] = 0x00;
|
||||
pTest[0x66] = 0x00; // history1
|
||||
pTest[0x67] = 0x00; // history2
|
||||
|
||||
// samplerate? length? num of samples? i dunno...
|
||||
// Likely length...
|
||||
pTest[0x3a] = pTest[0x8a];
|
||||
pTest[0x3b] = pTest[0x8b];
|
||||
|
||||
// Copy ARAM addr from r to rw area.
|
||||
pTest[0x38] = pTest[0x8c];
|
||||
pTest[0x39] = pTest[0x8d];
|
||||
}
|
||||
|
||||
if (pTest[0x01] != 0) // 0747 early out... i dunno if this can happen because we filter it above
|
||||
return;
|
||||
|
||||
u32 ARAMAddr = (pTest[0x38] << 16) | pTest[0x39];
|
||||
u32 NumberOfSamples = (pTest[0x3a] << 16) | pTest[0x3b];
|
||||
|
||||
// round upwards how many samples we need to copy, 0759
|
||||
NumberOfSamples = (NumberOfSamples + 0xf) >> 4; // i think the lower 4 are the fraction
|
||||
u32 frac = NumberOfSamples & 0xF;
|
||||
|
||||
u8 inBuffer[9];
|
||||
short outbuf[16];
|
||||
u32 sampleCount = 0;
|
||||
|
||||
// It must be something like this:
|
||||
|
||||
// The PB contains a small sample buffer of 0x4D decoded samples.
|
||||
// If it's empty or "used", decode to it.
|
||||
// Then, resample from this buffer to the output as you go. When it needs
|
||||
// wrapping, decode more.
|
||||
|
||||
#define USE_RESAMPLE
|
||||
#if !defined(USE_RESAMPLE)
|
||||
for (int s = 0; s < _Size/16; s++)
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
inBuffer[i] = DSP::ReadARAM(ARAMAddr);
|
||||
ARAMAddr++;
|
||||
}
|
||||
|
||||
AFCdecodebuffer((char*)inBuffer, outbuf, (short*)&pTest[0x66], (short*)&pTest[0x67]);
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
templbuffer[sampleCount] += outbuf[i];
|
||||
temprbuffer[sampleCount] += outbuf[i];
|
||||
sampleCount++;
|
||||
}
|
||||
|
||||
NumberOfSamples--;
|
||||
|
||||
if (NumberOfSamples<=0)
|
||||
break;
|
||||
}
|
||||
#else
|
||||
while (NumberOfSamples > 0)
|
||||
{
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
inBuffer[i] = DSP::ReadARAM(ARAMAddr);
|
||||
ARAMAddr++;
|
||||
}
|
||||
|
||||
AFCdecodebuffer(m_AFCCoefTable, (char*)inBuffer, outbuf, (short*)&pTest[0x66], (short*)&pTest[0x67], 9);
|
||||
CResampler Sampler(outbuf, 16, 48000);
|
||||
|
||||
while (Sampler.m_queueSize > 0)
|
||||
{
|
||||
int sample = Sampler.sample_queue.front();
|
||||
Sampler.sample_queue.pop();
|
||||
Sampler.m_queueSize -= 1;
|
||||
|
||||
templbuffer[sampleCount] += sample;
|
||||
temprbuffer[sampleCount] += sample;
|
||||
sampleCount++;
|
||||
|
||||
if (sampleCount > _Size)
|
||||
break;
|
||||
}
|
||||
|
||||
if (sampleCount > _Size)
|
||||
break;
|
||||
|
||||
NumberOfSamples--;
|
||||
}
|
||||
#endif
|
||||
if (NumberOfSamples == 0)
|
||||
{
|
||||
pTest[0x01] = 1; // we are done ??
|
||||
}
|
||||
|
||||
// write back
|
||||
NumberOfSamples = (NumberOfSamples << 4); // missing fraction
|
||||
|
||||
pTest[0x38] = ARAMAddr >> 16;
|
||||
pTest[0x39] = ARAMAddr & 0xFFFF;
|
||||
pTest[0x3a] = NumberOfSamples >> 16;
|
||||
pTest[0x3b] = NumberOfSamples & 0xFFFF;
|
||||
|
||||
|
||||
#if 0
|
||||
NumberOfSamples = (NumberOfSamples + 0xf) >> 4;
|
||||
|
||||
static u8 Buffer[500000];
|
||||
for (int i =0; i<NumberOfSamples*9; i++)
|
||||
{
|
||||
Buffer[i] = DSP::ReadARAM(ARAMAddr+i);
|
||||
}
|
||||
|
||||
// yes, the dumps are really zelda sound ;)
|
||||
DumpAFC(Buffer, NumberOfSamples*9, 0x3d00);
|
||||
|
||||
DumpPB(_rPB);
|
||||
|
||||
// exit(1);
|
||||
#endif
|
||||
|
||||
// i think pTest[0x3a] and pTest[0x3b] got an update after you have decoded some samples...
|
||||
// just decrement them with the number of samples you have played
|
||||
// and incrrease the ARAM Offset in pTest[0x38], pTest[0x39]
|
||||
|
||||
|
||||
// end of block (Zelda 03b2)
|
||||
if (pTest[0x06] == 0)
|
||||
{
|
||||
// 02a4
|
||||
//
|
||||
|
||||
pTest[0x04] = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
ERROR_LOG(DSPHLE, "Zelda Ucode: Unknown PB type %i", _rPB.type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -158,7 +158,7 @@ void ZeldaUCode::RenderSynth_WaveTable(ZeldaVoicePB &PB, s32* _Buffer, int _Size
|
||||
|
||||
for (int i = 0; i < 0x50; i++)
|
||||
{
|
||||
_Buffer[i] = m_MiscTable[address];
|
||||
_Buffer[i] = m_misc_table[address];
|
||||
|
||||
ACC0 += PB.RatioInt << 5;
|
||||
address = AddValueToReg(address, ((ACC0 >> 16) & 0xffff));
|
||||
|
@ -277,7 +277,7 @@ void ZeldaUCode::RenderVoice_AFC(ZeldaVoicePB &PB, s16 *_Buffer, int _Size)
|
||||
u32 ram_mask = 1024 * 1024 * 16 - 1;
|
||||
if (IsDMAVersion())
|
||||
{
|
||||
source = Memory::GetPointer(m_DMABaseAddr);
|
||||
source = Memory::GetPointer(m_dma_base_addr);
|
||||
ram_mask = 1024 * 1024 * 64 - 1;
|
||||
}
|
||||
else
|
||||
@ -326,7 +326,7 @@ restart:
|
||||
u32 prev_addr = PB.CurAddr;
|
||||
|
||||
// Prefill the decode buffer.
|
||||
AFCdecodebuffer(m_AFCCoefTable, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, PB.Format);
|
||||
AFCdecodebuffer(m_afc_coef_table, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, PB.Format);
|
||||
PB.CurAddr += PB.Format; // 9 or 5
|
||||
|
||||
u32 SamplePosition = PB.Length - PB.RemLength;
|
||||
@ -350,7 +350,7 @@ restart:
|
||||
prev_yn2 = PB.YN2;
|
||||
prev_addr = PB.CurAddr;
|
||||
|
||||
AFCdecodebuffer(m_AFCCoefTable, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, PB.Format);
|
||||
AFCdecodebuffer(m_afc_coef_table, (char*)(source + (PB.CurAddr & ram_mask)), outbuf, (short*)&PB.YN2, (short*)&PB.YN1, PB.Format);
|
||||
PB.CurAddr += PB.Format; // 9 or 5
|
||||
}
|
||||
}
|
||||
@ -477,7 +477,7 @@ void ZeldaUCode::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightB
|
||||
{
|
||||
s32 sample = (s32)(s16)PB.FixedSample;
|
||||
for (int i = 0; i < _Size; i++)
|
||||
m_VoiceBuffer[i] = sample;
|
||||
m_voice_buffer[i] = sample;
|
||||
|
||||
goto ContinueWithBlock; // Yes, a goto. Yes, it's evil, but it makes the flow look much more like the DSP code.
|
||||
}
|
||||
@ -498,18 +498,18 @@ void ZeldaUCode::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightB
|
||||
{
|
||||
case 0x0005: // AFC with extra low bitrate (32:5 compression).
|
||||
case 0x0009: // AFC with normal bitrate (32:9 compression).
|
||||
RenderVoice_AFC(PB, m_ResampleBuffer + 4, _Size);
|
||||
Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true);
|
||||
RenderVoice_AFC(PB, m_resample_buffer + 4, _Size);
|
||||
Resample(PB, _Size, m_resample_buffer + 4, m_voice_buffer, true);
|
||||
break;
|
||||
|
||||
case 0x0008: // PCM8 - normal PCM 8-bit audio. Used in Mario Kart DD + very little in Zelda WW.
|
||||
RenderVoice_PCM8(PB, m_ResampleBuffer + 4, _Size);
|
||||
Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true);
|
||||
RenderVoice_PCM8(PB, m_resample_buffer + 4, _Size);
|
||||
Resample(PB, _Size, m_resample_buffer + 4, m_voice_buffer, true);
|
||||
break;
|
||||
|
||||
case 0x0010: // PCM16 - normal PCM 16-bit audio.
|
||||
RenderVoice_PCM16(PB, m_ResampleBuffer + 4, _Size);
|
||||
Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true);
|
||||
RenderVoice_PCM16(PB, m_resample_buffer + 4, _Size);
|
||||
Resample(PB, _Size, m_resample_buffer + 4, m_voice_buffer, true);
|
||||
break;
|
||||
|
||||
case 0x0020:
|
||||
@ -517,15 +517,15 @@ void ZeldaUCode::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightB
|
||||
// to the output buffer. However, (if we ever see this sound type), we'll
|
||||
// have to resample anyway since we're running at a different sample rate.
|
||||
|
||||
RenderVoice_Raw(PB, m_ResampleBuffer + 4, _Size);
|
||||
Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true);
|
||||
RenderVoice_Raw(PB, m_resample_buffer + 4, _Size);
|
||||
Resample(PB, _Size, m_resample_buffer + 4, m_voice_buffer, true);
|
||||
break;
|
||||
|
||||
case 0x0021:
|
||||
// Raw sound from RAM. Important for Zelda WW. Cutscenes use the music
|
||||
// to let the game know they ended
|
||||
RenderVoice_Raw(PB, m_ResampleBuffer + 4, _Size);
|
||||
Resample(PB, _Size, m_ResampleBuffer + 4, m_VoiceBuffer, true);
|
||||
RenderVoice_Raw(PB, m_resample_buffer + 4, _Size);
|
||||
Resample(PB, _Size, m_resample_buffer + 4, m_voice_buffer, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -540,16 +540,16 @@ void ZeldaUCode::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightB
|
||||
// Synthesized sounds
|
||||
case 0x0003: WARN_LOG(DSPHLE, "PB Format 0x03 used!");
|
||||
case 0x0000: // Example: Magic meter filling up in ZWW
|
||||
RenderSynth_RectWave(PB, m_VoiceBuffer, _Size);
|
||||
RenderSynth_RectWave(PB, m_voice_buffer, _Size);
|
||||
break;
|
||||
|
||||
case 0x0001: // Example: "Denied" sound when trying to pull out a sword indoors in ZWW
|
||||
RenderSynth_SawWave(PB, m_VoiceBuffer, _Size);
|
||||
RenderSynth_SawWave(PB, m_voice_buffer, _Size);
|
||||
break;
|
||||
|
||||
case 0x0006:
|
||||
WARN_LOG(DSPHLE, "Synthesizing 0x0006 (constant sound)");
|
||||
RenderSynth_Constant(PB, m_VoiceBuffer, _Size);
|
||||
RenderSynth_Constant(PB, m_voice_buffer, _Size);
|
||||
break;
|
||||
|
||||
// These are more "synth" formats - square wave, saw wave etc.
|
||||
@ -561,12 +561,12 @@ void ZeldaUCode::RenderAddVoice(ZeldaVoicePB &PB, s32* _LeftBuffer, s32* _RightB
|
||||
case 0x0007: // Example: "success" SFX in Pikmin 1, Pikmin 2 in a cave, not sure what sound it is.
|
||||
case 0x000b: // Example: SFX in area selection menu in Pikmin
|
||||
case 0x000c: // Example: beam of death/yellow force-field in Temple of the Gods, ZWW
|
||||
RenderSynth_WaveTable(PB, m_VoiceBuffer, _Size);
|
||||
RenderSynth_WaveTable(PB, m_voice_buffer, _Size);
|
||||
break;
|
||||
|
||||
default:
|
||||
// TODO: Implement general decoder here
|
||||
memset(m_VoiceBuffer, 0, _Size * sizeof(s32));
|
||||
memset(m_voice_buffer, 0, _Size * sizeof(s32));
|
||||
ERROR_LOG(DSPHLE, "Unknown MixAddVoice format in zelda %04x", PB.Format);
|
||||
break;
|
||||
}
|
||||
@ -602,10 +602,10 @@ ContinueWithBlock:
|
||||
short AX0H = PB.raw[0x28] & 0x7F;
|
||||
short AX1L = AX0L ^ 0x7F;
|
||||
short AX1H = AX0H ^ 0x7F;
|
||||
AX0L = m_MiscTable[0x200 + AX0L];
|
||||
AX0H = m_MiscTable[0x200 + AX0H];
|
||||
AX1L = m_MiscTable[0x200 + AX1L];
|
||||
AX1H = m_MiscTable[0x200 + AX1H];
|
||||
AX0L = m_misc_table[0x200 + AX0L];
|
||||
AX0H = m_misc_table[0x200 + AX0H];
|
||||
AX1L = m_misc_table[0x200 + AX1L];
|
||||
AX1H = m_misc_table[0x200 + AX1H];
|
||||
|
||||
short b00[20];
|
||||
b00[0] = AX1L * AX1H >> 16;
|
||||
@ -649,7 +649,7 @@ ContinueWithBlock:
|
||||
int ramp = value << 16;
|
||||
for (int i = 0; i < _Size; i++)
|
||||
{
|
||||
int unmixed_audio = m_VoiceBuffer[i];
|
||||
int unmixed_audio = m_voice_buffer[i];
|
||||
switch (count) {
|
||||
case 0: _LeftBuffer[i] += (u64)unmixed_audio * ramp >> 29; break;
|
||||
case 1: _RightBuffer[i] += (u64)unmixed_audio * ramp >> 29; break;
|
||||
@ -703,7 +703,7 @@ ContinueWithBlock:
|
||||
// 0ca9_RampedMultiplyAddBuffer
|
||||
for (int i = 0; i < _Size; i++)
|
||||
{
|
||||
int value = m_VoiceBuffer[i];
|
||||
int value = m_voice_buffer[i];
|
||||
|
||||
// TODO - add to buffer specified by dest_buffer_address
|
||||
switch (count)
|
||||
@ -740,40 +740,40 @@ void ZeldaUCode::MixAudio()
|
||||
const int BufferSamples = 5 * 16;
|
||||
|
||||
// Final mix buffers
|
||||
memset(m_LeftBuffer, 0, BufferSamples * sizeof(s32));
|
||||
memset(m_RightBuffer, 0, BufferSamples * sizeof(s32));
|
||||
memset(m_left_buffer, 0, BufferSamples * sizeof(s32));
|
||||
memset(m_right_buffer, 0, BufferSamples * sizeof(s32));
|
||||
|
||||
// For each PB...
|
||||
for (u32 i = 0; i < m_NumVoices; i++)
|
||||
for (u32 i = 0; i < m_num_voices; i++)
|
||||
{
|
||||
if (!IsLightVersion())
|
||||
{
|
||||
u32 flags = m_SyncFlags[(i >> 4) & 0xF];
|
||||
u32 flags = m_sync_flags[(i >> 4) & 0xF];
|
||||
if (!(flags & 1 << (15 - (i & 0xF))))
|
||||
continue;
|
||||
}
|
||||
|
||||
ZeldaVoicePB pb;
|
||||
ReadVoicePB(m_VoicePBsAddr + (i * 0x180), pb);
|
||||
ReadVoicePB(m_voice_pbs_addr + (i * 0x180), pb);
|
||||
|
||||
if (pb.Status == 0)
|
||||
continue;
|
||||
if (pb.KeyOff != 0)
|
||||
continue;
|
||||
|
||||
RenderAddVoice(pb, m_LeftBuffer, m_RightBuffer, BufferSamples);
|
||||
WritebackVoicePB(m_VoicePBsAddr + (i * 0x180), pb);
|
||||
RenderAddVoice(pb, m_left_buffer, m_right_buffer, BufferSamples);
|
||||
WritebackVoicePB(m_voice_pbs_addr + (i * 0x180), pb);
|
||||
}
|
||||
|
||||
// Post processing, final conversion.
|
||||
s16* left_buffer = (s16*)HLEMemory_Get_Pointer(m_LeftBuffersAddr);
|
||||
s16* right_buffer = (s16*)HLEMemory_Get_Pointer(m_RightBuffersAddr);
|
||||
left_buffer += m_CurBuffer * BufferSamples;
|
||||
right_buffer += m_CurBuffer * BufferSamples;
|
||||
s16* left_buffer = (s16*)HLEMemory_Get_Pointer(m_left_buffers_addr);
|
||||
s16* right_buffer = (s16*)HLEMemory_Get_Pointer(m_right_buffers_addr);
|
||||
left_buffer += m_current_buffer * BufferSamples;
|
||||
right_buffer += m_current_buffer * BufferSamples;
|
||||
for (int i = 0; i < BufferSamples; i++)
|
||||
{
|
||||
s32 left = m_LeftBuffer[i];
|
||||
s32 right = m_RightBuffer[i];
|
||||
s32 left = m_left_buffer[i];
|
||||
s32 right = m_right_buffer[i];
|
||||
|
||||
MathUtil::Clamp(&left, -32768, 32767);
|
||||
left_buffer[i] = Common::swap16((short)left);
|
||||
|
Loading…
Reference in New Issue
Block a user