AX: Use ArraySize over sizeof division
Also gets rid of magic numbers in volume ramp generation.
This commit is contained in:
parent
23f36b1824
commit
77d3bed058
|
@ -2,6 +2,7 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@ void AXUCode::LoadResamplingCoefficients()
|
||||||
|
|
||||||
size_t fidx;
|
size_t fidx;
|
||||||
std::string filename;
|
std::string filename;
|
||||||
for (fidx = 0; fidx < sizeof (filenames) / sizeof (filenames[0]); ++fidx)
|
for (fidx = 0; fidx < ArraySize(filenames); ++fidx)
|
||||||
{
|
{
|
||||||
filename = filenames[fidx];
|
filename = filenames[fidx];
|
||||||
if (!File::Exists(filename))
|
if (!File::Exists(filename))
|
||||||
|
@ -51,7 +52,7 @@ void AXUCode::LoadResamplingCoefficients()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fidx >= sizeof (filenames) / sizeof (filenames[0]))
|
if (fidx >= ArraySize(filenames))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WARN_LOG(DSPHLE, "Loading polyphase resampling coeffs from %s", filename.c_str());
|
WARN_LOG(DSPHLE, "Loading polyphase resampling coeffs from %s", filename.c_str());
|
||||||
|
@ -416,7 +417,7 @@ void AXUCode::ProcessPBList(u32 pb_addr)
|
||||||
m_coeffs_available ? m_coeffs : nullptr);
|
m_coeffs_available ? m_coeffs : nullptr);
|
||||||
|
|
||||||
// Forward the buffers
|
// Forward the buffers
|
||||||
for (u32 i = 0; i < sizeof (buffers.ptrs) / sizeof (buffers.ptrs[0]); ++i)
|
for (size_t i = 0; i < ArraySize(buffers.ptrs); ++i)
|
||||||
buffers.ptrs[i] += spms;
|
buffers.ptrs[i] += spms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,10 +587,10 @@ void AXUCode::SendAUXAndMix(u32 main_auxa_up, u32 auxb_s_up, u32 main_l_dl,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Download and mix
|
// Download and mix
|
||||||
for (u32 i = 0; i < sizeof (dl_buffers) / sizeof (dl_buffers[0]); ++i)
|
for (size_t i = 0; i < ArraySize(dl_buffers); ++i)
|
||||||
{
|
{
|
||||||
int* dl_src = (int*)HLEMemory_Get_Pointer(dl_addrs[i]);
|
int* dl_src = (int*)HLEMemory_Get_Pointer(dl_addrs[i]);
|
||||||
for (u32 j = 0; j < 32 * 5; ++j)
|
for (size_t j = 0; j < 32 * 5; ++j)
|
||||||
dl_buffers[i][j] += (int)Common::swap32(*dl_src++);
|
dl_buffers[i][j] += (int)Common::swap32(*dl_src++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -648,7 +649,7 @@ void AXUCode::HandleMail(u32 mail)
|
||||||
|
|
||||||
void AXUCode::CopyCmdList(u32 addr, u16 size)
|
void AXUCode::CopyCmdList(u32 addr, u16 size)
|
||||||
{
|
{
|
||||||
if (size >= (sizeof (m_cmdlist) / sizeof (u16)))
|
if (size >= ArraySize(m_cmdlist))
|
||||||
{
|
{
|
||||||
ERROR_LOG(DSPHLE, "Command list at %08x is too large: size=%d", addr, size);
|
ERROR_LOG(DSPHLE, "Command list at %08x is too large: size=%d", addr, size);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
#define AX_WII // Used in AXVoice.
|
#define AX_WII // Used in AXVoice.
|
||||||
|
|
||||||
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/MathUtil.h"
|
#include "Common/MathUtil.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
|
@ -470,7 +471,7 @@ void AXWiiUCode::ProcessPBList(u32 pb_addr)
|
||||||
m_coeffs_available ? m_coeffs : nullptr);
|
m_coeffs_available ? m_coeffs : nullptr);
|
||||||
|
|
||||||
// Forward the buffers
|
// Forward the buffers
|
||||||
for (u32 i = 0; i < sizeof (buffers.ptrs) / sizeof (buffers.ptrs[0]); ++i)
|
for (size_t i = 0; i < ArraySize(buffers.ptrs); ++i)
|
||||||
buffers.ptrs[i] += 32;
|
buffers.ptrs[i] += 32;
|
||||||
}
|
}
|
||||||
ReinjectUpdatesFields(pb, num_updates, updates_addr);
|
ReinjectUpdatesFields(pb, num_updates, updates_addr);
|
||||||
|
@ -490,7 +491,7 @@ void AXWiiUCode::ProcessPBList(u32 pb_addr)
|
||||||
void AXWiiUCode::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 volume)
|
void AXWiiUCode::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 volume)
|
||||||
{
|
{
|
||||||
u16 volume_ramp[96];
|
u16 volume_ramp[96];
|
||||||
GenerateVolumeRamp(volume_ramp, m_last_aux_volumes[aux_id], volume, 96);
|
GenerateVolumeRamp(volume_ramp, m_last_aux_volumes[aux_id], volume, ArraySize(volume_ramp));
|
||||||
m_last_aux_volumes[aux_id] = volume;
|
m_last_aux_volumes[aux_id] = volume;
|
||||||
|
|
||||||
int* buffers[3] = { nullptr };
|
int* buffers[3] = { nullptr };
|
||||||
|
@ -589,7 +590,7 @@ void AXWiiUCode::OutputSamples(u32 lr_addr, u32 surround_addr, u16 volume,
|
||||||
bool upload_auxc)
|
bool upload_auxc)
|
||||||
{
|
{
|
||||||
u16 volume_ramp[96];
|
u16 volume_ramp[96];
|
||||||
GenerateVolumeRamp(volume_ramp, m_last_main_volume, volume, 96);
|
GenerateVolumeRamp(volume_ramp, m_last_main_volume, volume, ArraySize(volume_ramp));
|
||||||
m_last_main_volume = volume;
|
m_last_main_volume = volume;
|
||||||
|
|
||||||
int upload_buffer[3 * 32] = { 0 };
|
int upload_buffer[3 * 32] = { 0 };
|
||||||
|
|
Loading…
Reference in New Issue