Replace C-style casts with static_cast - Core & UnitTests
This commit is contained in:
parent
f8bf35e6f0
commit
4b3f674f6b
|
@ -147,7 +147,7 @@ OpenALStream::~OpenALStream()
|
|||
|
||||
void OpenALStream::SetVolume(int volume)
|
||||
{
|
||||
m_volume = (float)volume / 100.0f;
|
||||
m_volume = static_cast<float>(volume) / 100.0f;
|
||||
|
||||
if (m_source)
|
||||
palSourcef(m_source, AL_GAIN, m_volume);
|
||||
|
|
|
@ -149,8 +149,8 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count,
|
|||
for (u32 i = 0; i < count; i++)
|
||||
{
|
||||
// Flip the audio channels from RL to LR
|
||||
conv_buffer[2 * i] = Common::swap16((u16)sample_data[2 * i + 1]);
|
||||
conv_buffer[2 * i + 1] = Common::swap16((u16)sample_data[2 * i]);
|
||||
conv_buffer[2 * i] = Common::swap16(static_cast<u16>(sample_data[2 * i + 1]));
|
||||
conv_buffer[2 * i + 1] = Common::swap16(static_cast<u16>(sample_data[2 * i]));
|
||||
|
||||
// Apply volume (volume ranges from 0 to 256)
|
||||
conv_buffer[2 * i] = conv_buffer[2 * i] * l_volume / 256;
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
template <typename K, class V>
|
||||
void Do(std::map<K, V>& x)
|
||||
{
|
||||
u32 count = (u32)x.size();
|
||||
u32 count = static_cast<u32>(x.size());
|
||||
Do(count);
|
||||
|
||||
switch (m_mode)
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
template <typename V>
|
||||
void Do(std::set<V>& x)
|
||||
{
|
||||
u32 count = (u32)x.size();
|
||||
u32 count = static_cast<u32>(x.size());
|
||||
Do(count);
|
||||
|
||||
switch (m_mode)
|
||||
|
|
|
@ -377,7 +377,7 @@ void GekkoDisassembler::ill(u32 in)
|
|||
// Type 3: A register is ignored (li)
|
||||
std::string GekkoDisassembler::imm(u32 in, int uimm, int type, bool hex)
|
||||
{
|
||||
int i = (int)(in & 0xffff);
|
||||
int i = static_cast<int>(in & 0xffff);
|
||||
|
||||
if (uimm == 0)
|
||||
{
|
||||
|
@ -461,13 +461,13 @@ void GekkoDisassembler::trapi(u32 in, unsigned char dmode)
|
|||
|
||||
void GekkoDisassembler::cmpi(u32 in, int uimm)
|
||||
{
|
||||
int i = (int)PPCGETL(in);
|
||||
int i = static_cast<int>(PPCGETL(in));
|
||||
|
||||
if (i < 2)
|
||||
{
|
||||
m_opcode = fmt::format("{}i", cmpname[uimm * 2 + i]);
|
||||
|
||||
i = (int)PPCGETCRD(in);
|
||||
i = static_cast<int>(PPCGETCRD(in));
|
||||
if (i != 0)
|
||||
{
|
||||
m_operands += fmt::format("cr{}, ", i);
|
||||
|
@ -507,10 +507,10 @@ void GekkoDisassembler::addi(u32 in, std::string_view ext)
|
|||
// Build a branch instr. and return number of chars written to operand.
|
||||
size_t GekkoDisassembler::branch(u32 in, std::string_view bname, int aform, int bdisp)
|
||||
{
|
||||
int bo = (int)PPCGETD(in);
|
||||
int bi = (int)PPCGETA(in);
|
||||
char y = (char)(bo & 1);
|
||||
const char* ext = b_ext[aform * 2 + (int)(in & 1)];
|
||||
int bo = static_cast<int>(PPCGETD(in));
|
||||
int bi = static_cast<int>(PPCGETA(in));
|
||||
char y = static_cast<char>(bo & 1);
|
||||
const char* ext = b_ext[aform * 2 + static_cast<int>(in & 1)];
|
||||
|
||||
if (bdisp < 0)
|
||||
y ^= 1;
|
||||
|
@ -558,7 +558,7 @@ size_t GekkoDisassembler::branch(u32 in, std::string_view bname, int aform, int
|
|||
|
||||
void GekkoDisassembler::bc(u32 in)
|
||||
{
|
||||
unsigned int d = (int)(in & 0xfffc);
|
||||
unsigned int d = static_cast<int>(in & 0xfffc);
|
||||
|
||||
if (d & 0x8000)
|
||||
d |= 0xffff0000;
|
||||
|
@ -601,9 +601,9 @@ void GekkoDisassembler::mcrf(u32 in, std::string_view suffix)
|
|||
|
||||
void GekkoDisassembler::crop(u32 in, std::string_view n1, std::string_view n2)
|
||||
{
|
||||
int crd = (int)PPCGETD(in);
|
||||
int cra = (int)PPCGETA(in);
|
||||
int crb = (int)PPCGETB(in);
|
||||
int crd = static_cast<int>(PPCGETD(in));
|
||||
int cra = static_cast<int>(PPCGETA(in));
|
||||
int crb = static_cast<int>(PPCGETB(in));
|
||||
|
||||
if ((in & 1) == 0)
|
||||
{
|
||||
|
@ -633,11 +633,11 @@ void GekkoDisassembler::nooper(u32 in, std::string_view name)
|
|||
|
||||
void GekkoDisassembler::rlw(u32 in, std::string_view name, int i)
|
||||
{
|
||||
int s = (int)PPCGETD(in);
|
||||
int a = (int)PPCGETA(in);
|
||||
int bsh = (int)PPCGETB(in);
|
||||
int mb = (int)PPCGETC(in);
|
||||
int me = (int)PPCGETM(in);
|
||||
int s = static_cast<int>(PPCGETD(in));
|
||||
int a = static_cast<int>(PPCGETA(in));
|
||||
int bsh = static_cast<int>(PPCGETB(in));
|
||||
int mb = static_cast<int>(PPCGETC(in));
|
||||
int me = static_cast<int>(PPCGETM(in));
|
||||
|
||||
m_opcode = fmt::format("rlw{}{}", name, (in & 1) ? "." : "");
|
||||
m_operands = fmt::format("{}, {}, {}{}, {}, {} ({:08x})", regnames[a], regnames[s], regsel[i],
|
||||
|
@ -652,10 +652,10 @@ void GekkoDisassembler::ori(u32 in, std::string_view name)
|
|||
|
||||
void GekkoDisassembler::rld(u32 in, std::string_view name, int i)
|
||||
{
|
||||
int s = (int)PPCGETD(in);
|
||||
int a = (int)PPCGETA(in);
|
||||
int bsh = i ? (int)PPCGETB(in) : (int)(((in & 2) << 4) + PPCGETB(in));
|
||||
int m = (int)(in & 0x7e0) >> 5;
|
||||
int s = static_cast<int>(PPCGETD(in));
|
||||
int a = static_cast<int>(PPCGETA(in));
|
||||
int bsh = i ? static_cast<int>(PPCGETB(in)) : static_cast<int>(((in & 2) << 4) + PPCGETB(in));
|
||||
int m = static_cast<int>(in & 0x7e0) >> 5;
|
||||
|
||||
m_opcode = fmt::format("rld{}{}", name, (in & 1) ? "." : "");
|
||||
m_operands = fmt::format("{}, {}, {}{}, {}", regnames[a], regnames[s], regsel[i], bsh, m);
|
||||
|
@ -663,13 +663,13 @@ void GekkoDisassembler::rld(u32 in, std::string_view name, int i)
|
|||
|
||||
void GekkoDisassembler::cmp(u32 in)
|
||||
{
|
||||
int i = (int)PPCGETL(in);
|
||||
int i = static_cast<int>(PPCGETL(in));
|
||||
|
||||
if (i < 2)
|
||||
{
|
||||
m_opcode = cmpname[((in & PPCIDX2MASK) ? 2 : 0) + i];
|
||||
|
||||
i = (int)PPCGETCRD(in);
|
||||
i = static_cast<int>(PPCGETCRD(in));
|
||||
if (i != 0)
|
||||
m_operands += fmt::format("cr{},", i);
|
||||
|
||||
|
@ -683,7 +683,7 @@ void GekkoDisassembler::cmp(u32 in)
|
|||
|
||||
void GekkoDisassembler::trap(u32 in, unsigned char dmode)
|
||||
{
|
||||
int to = (int)PPCGETD(in);
|
||||
int to = static_cast<int>(PPCGETD(in));
|
||||
const char* cnd = trap_condition[to];
|
||||
|
||||
if (cnd != nullptr)
|
||||
|
@ -716,7 +716,7 @@ void GekkoDisassembler::trap(u32 in, unsigned char dmode)
|
|||
void GekkoDisassembler::dab(u32 in, std::string_view name, int mask, int smode, int chkoe,
|
||||
int chkrc)
|
||||
{
|
||||
if (chkrc >= 0 && ((in & 1) != (unsigned int)chkrc))
|
||||
if (chkrc >= 0 && ((in & 1) != static_cast<unsigned int>(chkrc)))
|
||||
{
|
||||
ill(in);
|
||||
}
|
||||
|
@ -735,7 +735,7 @@ void GekkoDisassembler::dab(u32 in, std::string_view name, int mask, int smode,
|
|||
// Last operand is no register: xxxx rD,rA,NB
|
||||
void GekkoDisassembler::rrn(u32 in, std::string_view name, int smode, int chkoe, int chkrc)
|
||||
{
|
||||
if (chkrc >= 0 && ((in & 1) != (unsigned int)chkrc))
|
||||
if (chkrc >= 0 && ((in & 1) != static_cast<unsigned int>(chkrc)))
|
||||
{
|
||||
ill(in);
|
||||
}
|
||||
|
@ -754,8 +754,8 @@ void GekkoDisassembler::rrn(u32 in, std::string_view name, int smode, int chkoe,
|
|||
|
||||
void GekkoDisassembler::mtcr(u32 in)
|
||||
{
|
||||
int s = (int)PPCGETD(in);
|
||||
int crm = (int)(in & 0x000ff000) >> 12;
|
||||
int s = static_cast<int>(PPCGETD(in));
|
||||
int crm = static_cast<int>(in & 0x000ff000) >> 12;
|
||||
|
||||
if (in & 0x00100801)
|
||||
{
|
||||
|
@ -774,8 +774,8 @@ void GekkoDisassembler::mtcr(u32 in)
|
|||
|
||||
void GekkoDisassembler::msr(u32 in, int smode)
|
||||
{
|
||||
int s = (int)PPCGETD(in);
|
||||
int sr = (int)(in & 0x000f0000) >> 16;
|
||||
int s = static_cast<int>(PPCGETD(in));
|
||||
int sr = static_cast<int>(in & 0x000f0000) >> 16;
|
||||
|
||||
if (in & 0x0010f801)
|
||||
{
|
||||
|
@ -794,8 +794,8 @@ void GekkoDisassembler::msr(u32 in, int smode)
|
|||
|
||||
void GekkoDisassembler::mspr(u32 in, int smode)
|
||||
{
|
||||
int d = (int)PPCGETD(in);
|
||||
int spr = (int)((PPCGETB(in) << 5) + PPCGETA(in));
|
||||
int d = static_cast<int>(PPCGETD(in));
|
||||
int spr = static_cast<int>((PPCGETB(in) << 5) + PPCGETA(in));
|
||||
int fmt = 0;
|
||||
|
||||
if (in & 1)
|
||||
|
@ -843,8 +843,8 @@ void GekkoDisassembler::mspr(u32 in, int smode)
|
|||
|
||||
void GekkoDisassembler::mtb(u32 in)
|
||||
{
|
||||
int d = (int)PPCGETD(in);
|
||||
int tbr = (int)((PPCGETB(in) << 5) + PPCGETA(in));
|
||||
int d = static_cast<int>(PPCGETD(in));
|
||||
int tbr = static_cast<int>((PPCGETB(in) << 5) + PPCGETA(in));
|
||||
|
||||
if (in & 1)
|
||||
{
|
||||
|
@ -876,9 +876,9 @@ void GekkoDisassembler::mtb(u32 in)
|
|||
|
||||
void GekkoDisassembler::sradi(u32 in)
|
||||
{
|
||||
int s = (int)PPCGETD(in);
|
||||
int a = (int)PPCGETA(in);
|
||||
int bsh = (int)(((in & 2) << 4) + PPCGETB(in));
|
||||
int s = static_cast<int>(PPCGETD(in));
|
||||
int a = static_cast<int>(PPCGETA(in));
|
||||
int bsh = static_cast<int>(((in & 2) << 4) + PPCGETB(in));
|
||||
|
||||
m_opcode = fmt::format("sradi{}", (in & 1) ? "." : "");
|
||||
m_operands = fmt::format("{}, {}, {}", regnames[a], regnames[s], bsh);
|
||||
|
@ -886,8 +886,8 @@ void GekkoDisassembler::sradi(u32 in)
|
|||
|
||||
void GekkoDisassembler::ldst(u32 in, std::string_view name, char reg)
|
||||
{
|
||||
int s = (int)PPCGETD(in);
|
||||
int a = (int)PPCGETA(in);
|
||||
int s = static_cast<int>(PPCGETD(in));
|
||||
int a = static_cast<int>(PPCGETA(in));
|
||||
int d = (u32)(in & 0xffff);
|
||||
|
||||
m_opcode = name;
|
||||
|
@ -913,17 +913,17 @@ void GekkoDisassembler::fdabc(u32 in, std::string_view name, int mask)
|
|||
if (mask & 4)
|
||||
m_operands += fmt::format(", f{}", PPCGETA(in));
|
||||
else if ((mask & 8) == 0)
|
||||
err |= (int)PPCGETA(in);
|
||||
err |= static_cast<int>(PPCGETA(in));
|
||||
|
||||
if (mask & 2)
|
||||
m_operands += fmt::format(", f{}", PPCGETC(in));
|
||||
else if (PPCGETC(in) && (mask & 8) == 0)
|
||||
err |= (int)PPCGETC(in);
|
||||
err |= static_cast<int>(PPCGETC(in));
|
||||
|
||||
if (mask & 1)
|
||||
m_operands += fmt::format(", f{}", PPCGETB(in));
|
||||
else if (!(mask & 8))
|
||||
err |= (int)PPCGETB(in);
|
||||
err |= static_cast<int>(PPCGETB(in));
|
||||
|
||||
if (err)
|
||||
ill(in);
|
||||
|
@ -1149,7 +1149,7 @@ void GekkoDisassembler::ps(u32 inst)
|
|||
{
|
||||
m_opcode = ps_cmpname[(inst >> 6) & 0x3];
|
||||
|
||||
int i = (int)PPCGETCRD(inst);
|
||||
int i = static_cast<int>(PPCGETCRD(inst));
|
||||
if (i != 0)
|
||||
m_operands += fmt::format("cr{}, ", i);
|
||||
m_operands += fmt::format("p{}, p{}", FA, FB);
|
||||
|
|
|
@ -137,36 +137,36 @@ static u64 GetMurmurHash3(const u8* src, u32 len, u32 samples)
|
|||
switch (len & 15)
|
||||
{
|
||||
case 15:
|
||||
k2 ^= u64(tail[14]) << 48;
|
||||
k2 ^= static_cast<u64>(tail[14]) << 48;
|
||||
case 14:
|
||||
k2 ^= u64(tail[13]) << 40;
|
||||
k2 ^= static_cast<u64>(tail[13]) << 40;
|
||||
case 13:
|
||||
k2 ^= u64(tail[12]) << 32;
|
||||
k2 ^= static_cast<u64>(tail[12]) << 32;
|
||||
case 12:
|
||||
k2 ^= u64(tail[11]) << 24;
|
||||
k2 ^= static_cast<u64>(tail[11]) << 24;
|
||||
case 11:
|
||||
k2 ^= u64(tail[10]) << 16;
|
||||
k2 ^= static_cast<u64>(tail[10]) << 16;
|
||||
case 10:
|
||||
k2 ^= u64(tail[9]) << 8;
|
||||
k2 ^= static_cast<u64>(tail[9]) << 8;
|
||||
case 9:
|
||||
k2 ^= u64(tail[8]) << 0;
|
||||
k2 ^= static_cast<u64>(tail[8]) << 0;
|
||||
|
||||
case 8:
|
||||
k1 ^= u64(tail[7]) << 56;
|
||||
k1 ^= static_cast<u64>(tail[7]) << 56;
|
||||
case 7:
|
||||
k1 ^= u64(tail[6]) << 48;
|
||||
k1 ^= static_cast<u64>(tail[6]) << 48;
|
||||
case 6:
|
||||
k1 ^= u64(tail[5]) << 40;
|
||||
k1 ^= static_cast<u64>(tail[5]) << 40;
|
||||
case 5:
|
||||
k1 ^= u64(tail[4]) << 32;
|
||||
k1 ^= static_cast<u64>(tail[4]) << 32;
|
||||
case 4:
|
||||
k1 ^= u64(tail[3]) << 24;
|
||||
k1 ^= static_cast<u64>(tail[3]) << 24;
|
||||
case 3:
|
||||
k1 ^= u64(tail[2]) << 16;
|
||||
k1 ^= static_cast<u64>(tail[2]) << 16;
|
||||
case 2:
|
||||
k1 ^= u64(tail[1]) << 8;
|
||||
k1 ^= static_cast<u64>(tail[1]) << 8;
|
||||
case 1:
|
||||
k1 ^= u64(tail[0]) << 0;
|
||||
k1 ^= static_cast<u64>(tail[0]) << 0;
|
||||
bmix64(h1, h2, k1, k2, c1, c2);
|
||||
};
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ template <typename... Args>
|
|||
inline void Register(const void* start, const void* end, fmt::format_string<Args...> format,
|
||||
Args&&... args)
|
||||
{
|
||||
u32 code_size = (u32)((const char*)end - (const char*)start);
|
||||
u32 code_size = static_cast<u32>(static_cast<const char*>(end) - static_cast<const char*>(start));
|
||||
Register(start, code_size, fmt::format(format, std::forward<Args>(args)...));
|
||||
}
|
||||
} // namespace Common::JitRegister
|
||||
|
|
|
@ -346,7 +346,8 @@ void* MemArena::MapInMemoryRegion(s64 offset, size_t size, void* base)
|
|||
return rv;
|
||||
}
|
||||
|
||||
return MapViewOfFileEx(m_memory_handle, FILE_MAP_ALL_ACCESS, 0, (DWORD)((u64)offset), size, base);
|
||||
return MapViewOfFileEx(m_memory_handle, FILE_MAP_ALL_ACCESS, 0,
|
||||
static_cast<DWORD>(static_cast<u64>(offset)), size, base);
|
||||
}
|
||||
|
||||
bool MemArena::JoinRegionsAfterUnmap(void* start_address, size_t size)
|
||||
|
|
|
@ -267,7 +267,7 @@ void DHCPPacket::AddOption(u8 fnc, const std::vector<u8>& params)
|
|||
{
|
||||
if (params.size() > 255)
|
||||
return;
|
||||
std::vector<u8> opt = {fnc, u8(params.size())};
|
||||
std::vector<u8> opt = {fnc, static_cast<u8>(params.size())};
|
||||
opt.insert(opt.end(), params.begin(), params.end());
|
||||
options.emplace_back(std::move(opt));
|
||||
}
|
||||
|
@ -386,11 +386,11 @@ std::vector<u8> TCPPacket::Build() const
|
|||
|
||||
auto ip_checksum_bitcast_ptr =
|
||||
Common::BitCastPtr<u16>(ip_ptr + offsetof(IPv4Header, header_checksum));
|
||||
ip_checksum_bitcast_ptr = u16(0);
|
||||
ip_checksum_bitcast_ptr = static_cast<u16>(0);
|
||||
ip_checksum_bitcast_ptr = htons(Common::ComputeNetworkChecksum(ip_ptr, ip_header_size));
|
||||
|
||||
auto checksum_bitcast_ptr = Common::BitCastPtr<u16>(tcp_ptr + offsetof(TCPHeader, checksum));
|
||||
checksum_bitcast_ptr = u16(0);
|
||||
checksum_bitcast_ptr = static_cast<u16>(0);
|
||||
checksum_bitcast_ptr = ComputeTCPNetworkChecksum(
|
||||
ip_header.source_addr, ip_header.destination_addr, tcp_ptr, tcp_length, IPPROTO_TCP);
|
||||
|
||||
|
@ -436,11 +436,11 @@ std::vector<u8> UDPPacket::Build() const
|
|||
|
||||
auto ip_checksum_bitcast_ptr =
|
||||
Common::BitCastPtr<u16>(ip_ptr + offsetof(IPv4Header, header_checksum));
|
||||
ip_checksum_bitcast_ptr = u16(0);
|
||||
ip_checksum_bitcast_ptr = static_cast<u16>(0);
|
||||
ip_checksum_bitcast_ptr = htons(Common::ComputeNetworkChecksum(ip_ptr, ip_header_size));
|
||||
|
||||
auto checksum_bitcast_ptr = Common::BitCastPtr<u16>(udp_ptr + offsetof(UDPHeader, checksum));
|
||||
checksum_bitcast_ptr = u16(0);
|
||||
checksum_bitcast_ptr = static_cast<u16>(0);
|
||||
checksum_bitcast_ptr = ComputeTCPNetworkChecksum(
|
||||
ip_header.source_addr, ip_header.destination_addr, udp_ptr, udp_length, IPPROTO_UDP);
|
||||
|
||||
|
|
|
@ -55,9 +55,10 @@ void PCAP::AddPacket(const u8* bytes, size_t size)
|
|||
std::chrono::system_clock::time_point now(std::chrono::system_clock::now());
|
||||
auto ts = now.time_since_epoch();
|
||||
PCAPRecordHeader rec_hdr = {
|
||||
(u32)std::chrono::duration_cast<std::chrono::seconds>(ts).count(),
|
||||
(u32)(std::chrono::duration_cast<std::chrono::microseconds>(ts).count() % 1000000), (u32)size,
|
||||
(u32)size};
|
||||
static_cast<u32>(std::chrono::duration_cast<std::chrono::seconds>(ts).count()),
|
||||
static_cast<u32>(std::chrono::duration_cast<std::chrono::microseconds>(ts).count() % 1000000),
|
||||
static_cast<u32>(size),
|
||||
static_cast<u32>(size)};
|
||||
m_fp->WriteBytes(&rec_hdr, sizeof(rec_hdr));
|
||||
m_fp->WriteBytes(bytes, size);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ Profiler::Profiler(const std::string& name)
|
|||
m_calls(0), m_depth(0)
|
||||
{
|
||||
m_time = Common::Timer::NowUs();
|
||||
s_max_length = std::max<u32>(s_max_length, u32(m_name.length()));
|
||||
s_max_length = std::max<u32>(s_max_length, static_cast<u32>(m_name.length()));
|
||||
|
||||
std::lock_guard<std::mutex> lk(s_mutex);
|
||||
s_all_profilers.push_back(this);
|
||||
|
@ -128,8 +128,8 @@ std::string Profiler::Read()
|
|||
double time_rel = 0;
|
||||
if (m_calls)
|
||||
{
|
||||
avg = double(m_usecs) / m_calls;
|
||||
stdev = std::sqrt(double(m_usecs_quad) / m_calls - avg * avg);
|
||||
avg = static_cast<double>(m_usecs) / m_calls;
|
||||
stdev = std::sqrt(static_cast<double>(m_usecs_quad) / m_calls - avg * avg);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ std::string Profiler::Read()
|
|||
}
|
||||
if (s_usecs_frame)
|
||||
{
|
||||
time_rel = double(m_usecs) * 100 / s_usecs_frame;
|
||||
time_rel = static_cast<double>(m_usecs) * 100 / s_usecs_frame;
|
||||
}
|
||||
|
||||
std::ostringstream buffer;
|
||||
|
|
|
@ -66,7 +66,7 @@ SettingsReader::SettingsReader(const SettingsBuffer& buffer) : m_decoded{""}
|
|||
u32 key = INITIAL_SEED;
|
||||
for (u32 position = 0; position < buffer.size(); ++position)
|
||||
{
|
||||
m_decoded.push_back((u8)(buffer[position] ^ key));
|
||||
m_decoded.push_back(static_cast<u8>(buffer[position] ^ key));
|
||||
key = (key >> 31) | (key << 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ void TraversalClient::HandleResends()
|
|||
const u32 now = enet_time_get();
|
||||
for (auto& tpi : m_OutgoingTraversalPackets)
|
||||
{
|
||||
if (now - tpi.sendTime >= (u32)(300 * tpi.tries))
|
||||
if (now - tpi.sendTime >= static_cast<u32>(300 * tpi.tries))
|
||||
{
|
||||
if (tpi.tries >= 5)
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ void TraversalClient::HandleTraversalTest()
|
|||
waitCondition = 0;
|
||||
break;
|
||||
}
|
||||
else if (rv < int(sizeof(packet)) || raddr.host != m_ServerAddress.host ||
|
||||
else if (rv < static_cast<int>(sizeof(packet)) || raddr.host != m_ServerAddress.host ||
|
||||
raddr.host != m_portAlt || packet.requestId != m_TestRequestId)
|
||||
{
|
||||
// irrelevant packet, ignore
|
||||
|
|
|
@ -55,14 +55,17 @@ size_t XEmitter::ABI_PushRegistersAndAdjustStack(BitSet32 mask, size_t rsp_align
|
|||
MOV(64, R(RBP), R(RSP));
|
||||
}
|
||||
for (int r : (mask & ABI_ALL_GPRS & ~BitSet32{RBP}))
|
||||
PUSH((X64Reg)r);
|
||||
PUSH(static_cast<X64Reg>(r));
|
||||
|
||||
if (subtraction)
|
||||
SUB(64, R(RSP), subtraction >= 0x80 ? Imm32((u32)subtraction) : Imm8((u8)subtraction));
|
||||
SUB(64, R(RSP),
|
||||
subtraction >= 0x80 ?
|
||||
Imm32(static_cast<u32>(subtraction)) :
|
||||
Imm8(static_cast<u8>(subtraction)));
|
||||
|
||||
for (int x : (mask & ABI_ALL_FPRS))
|
||||
{
|
||||
MOVAPD(MDisp(RSP, (int)xmm_offset), (X64Reg)(x - 16));
|
||||
MOVAPD(MDisp(RSP, static_cast<int>(xmm_offset)), static_cast<X64Reg>(x - 16));
|
||||
xmm_offset += 16;
|
||||
}
|
||||
|
||||
|
@ -79,17 +82,19 @@ void XEmitter::ABI_PopRegistersAndAdjustStack(BitSet32 mask, size_t rsp_alignmen
|
|||
|
||||
for (int x : (mask & ABI_ALL_FPRS))
|
||||
{
|
||||
MOVAPD((X64Reg)(x - 16), MDisp(RSP, (int)xmm_offset));
|
||||
MOVAPD(static_cast<X64Reg>(x - 16), MDisp(RSP, static_cast<int>(xmm_offset)));
|
||||
xmm_offset += 16;
|
||||
}
|
||||
|
||||
if (subtraction)
|
||||
ADD(64, R(RSP), subtraction >= 0x80 ? Imm32((u32)subtraction) : Imm8((u8)subtraction));
|
||||
ADD(64, R(RSP),
|
||||
subtraction >= 0x80 ? Imm32(static_cast<u32>(subtraction)) :
|
||||
Imm8(static_cast<u8>(subtraction)));
|
||||
|
||||
for (int r = 15; r >= 0; r--)
|
||||
{
|
||||
if (r != RBP && mask[r])
|
||||
POP((X64Reg)r);
|
||||
POP(static_cast<X64Reg>(r));
|
||||
}
|
||||
// RSP is pushed first and popped last to make debuggers/profilers happy
|
||||
if (mask[RBP])
|
||||
|
|
|
@ -206,12 +206,12 @@ void XEmitter::CheckFlags()
|
|||
|
||||
void XEmitter::WriteModRM(int mod, int reg, int rm)
|
||||
{
|
||||
Write8((u8)((mod << 6) | ((reg & 7) << 3) | (rm & 7)));
|
||||
Write8(static_cast<u8>((mod << 6) | ((reg & 7) << 3) | (rm & 7)));
|
||||
}
|
||||
|
||||
void XEmitter::WriteSIB(int scale, int index, int base)
|
||||
{
|
||||
Write8((u8)((scale << 6) | ((index & 7) << 3) | (base & 7)));
|
||||
Write8(static_cast<u8>((scale << 6) | ((index & 7) << 3) | (base & 7)));
|
||||
}
|
||||
|
||||
void OpArg::WriteREX(XEmitter* emit, int opBits, int bits, int customOp) const
|
||||
|
@ -273,7 +273,7 @@ void OpArg::WriteRest(XEmitter* emit, int extraBytes, X64Reg _operandReg,
|
|||
bool warn_64bit_offset) const
|
||||
{
|
||||
if (_operandReg == INVALID_REG)
|
||||
_operandReg = (X64Reg)this->operandReg;
|
||||
_operandReg = static_cast<X64Reg>(this->operandReg);
|
||||
int mod = 0;
|
||||
int ireg = indexReg;
|
||||
bool SIB = false;
|
||||
|
@ -286,12 +286,12 @@ void OpArg::WriteRest(XEmitter* emit, int extraBytes, X64Reg _operandReg,
|
|||
emit->WriteModRM(0, _operandReg, _offsetOrBaseReg);
|
||||
// TODO : add some checks
|
||||
u64 ripAddr = (u64)emit->GetCodePtr() + 4 + extraBytes;
|
||||
s64 distance = (s64)offset - (s64)ripAddr;
|
||||
s64 distance = static_cast<s64>(offset) - static_cast<s64>(ripAddr);
|
||||
ASSERT_MSG(DYNA_REC,
|
||||
(distance < 0x80000000LL && distance >= -0x80000000LL) || !warn_64bit_offset,
|
||||
"WriteRest: op out of range ({:#x} uses {:#x})", ripAddr, offset);
|
||||
s32 offs = (s32)distance;
|
||||
emit->Write32((u32)offs);
|
||||
s32 offs = static_cast<s32>(distance);
|
||||
emit->Write32(static_cast<u32>(offs));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ void OpArg::WriteRest(XEmitter* emit, int extraBytes, X64Reg _operandReg,
|
|||
|
||||
// Okay, we're fine. Just disp encoding.
|
||||
// We need displacement. Which size?
|
||||
int ioff = (int)(s64)offset;
|
||||
int ioff = static_cast<int>(static_cast<s64>(offset));
|
||||
if (ioff == 0 && (_offsetOrBaseReg & 7) != 5)
|
||||
{
|
||||
mod = 0; // No displacement
|
||||
|
@ -384,16 +384,16 @@ void OpArg::WriteRest(XEmitter* emit, int extraBytes, X64Reg _operandReg,
|
|||
ss = 0;
|
||||
break;
|
||||
}
|
||||
emit->Write8((u8)((ss << 6) | ((ireg & 7) << 3) | (_offsetOrBaseReg & 7)));
|
||||
emit->Write8(static_cast<u8>((ss << 6) | ((ireg & 7) << 3) | (_offsetOrBaseReg & 7)));
|
||||
}
|
||||
|
||||
if (mod == 1) // 8-bit disp
|
||||
{
|
||||
emit->Write8((u8)(s8)(s32)offset);
|
||||
emit->Write8(static_cast<u8>(static_cast<s8>((s32)offset)));
|
||||
}
|
||||
else if (mod == 2 || (scale >= SCALE_NOBASE_2 && scale <= SCALE_NOBASE_8)) // 32-bit disp
|
||||
{
|
||||
emit->Write32((u32)offset);
|
||||
emit->Write32(static_cast<u32>(offset));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ void XEmitter::Rex(int w, int r, int x, int b)
|
|||
r = r ? 1 : 0;
|
||||
x = x ? 1 : 0;
|
||||
b = b ? 1 : 0;
|
||||
u8 rx = (u8)(0x40 | (w << 3) | (r << 2) | (x << 1) | (b));
|
||||
u8 rx = static_cast<u8>(0x40 | (w << 3) | (r << 2) | (x << 1) | (b));
|
||||
if (rx != 0x40)
|
||||
Write8(rx);
|
||||
}
|
||||
|
@ -417,21 +417,21 @@ void XEmitter::JMP(const u8* addr, const Jump jump)
|
|||
u64 fn = (u64)addr;
|
||||
if (jump == Jump::Short)
|
||||
{
|
||||
s64 distance = (s64)(fn - ((u64)code + 2));
|
||||
s64 distance = static_cast<s64>(fn - ((u64)code + 2));
|
||||
ASSERT_MSG(DYNA_REC, distance >= -0x80 && distance < 0x80,
|
||||
"Jump::Short target too far away ({}), needs Jump::Near", distance);
|
||||
// 8 bits will do
|
||||
Write8(0xEB);
|
||||
Write8((u8)(s8)distance);
|
||||
Write8(static_cast<u8>(static_cast<s8>(distance)));
|
||||
}
|
||||
else
|
||||
{
|
||||
s64 distance = (s64)(fn - ((u64)code + 5));
|
||||
s64 distance = static_cast<s64>(fn - ((u64)code + 5));
|
||||
|
||||
ASSERT_MSG(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL,
|
||||
"Jump::Near target too far away ({}), needs indirect register", distance);
|
||||
Write8(0xE9);
|
||||
Write32((u32)(s32)distance);
|
||||
Write32(static_cast<u32>(static_cast<s32>(distance)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +470,7 @@ void XEmitter::CALL(const void* fnptr)
|
|||
ASSERT_MSG(DYNA_REC, distance < 0x0000000080000000ULL || distance >= 0xFFFFFFFF80000000ULL,
|
||||
"CALL out of range ({} calls {})", fmt::ptr(code), fmt::ptr(fnptr));
|
||||
Write8(0xE8);
|
||||
Write32(u32(distance));
|
||||
Write32(static_cast<u32>(distance));
|
||||
}
|
||||
|
||||
FixupBranch XEmitter::CALL()
|
||||
|
@ -548,20 +548,20 @@ FixupBranch XEmitter::J_CC(CCFlags conditionCode, const Jump jump)
|
|||
void XEmitter::J_CC(CCFlags conditionCode, const u8* addr)
|
||||
{
|
||||
u64 fn = (u64)addr;
|
||||
s64 distance = (s64)(fn - ((u64)code + 2));
|
||||
s64 distance = static_cast<s64>(fn - ((u64)code + 2));
|
||||
if (distance < -0x80 || distance >= 0x80)
|
||||
{
|
||||
distance = (s64)(fn - ((u64)code + 6));
|
||||
distance = static_cast<s64>(fn - ((u64)code + 6));
|
||||
ASSERT_MSG(DYNA_REC, distance >= -0x80000000LL && distance < 0x80000000LL,
|
||||
"Jump target too far away ({}), needs indirect register", distance);
|
||||
Write8(0x0F);
|
||||
Write8(0x80 + conditionCode);
|
||||
Write32((u32)(s32)distance);
|
||||
Write32(static_cast<u32>(static_cast<s32>(distance)));
|
||||
}
|
||||
else
|
||||
{
|
||||
Write8(0x70 + conditionCode);
|
||||
Write8((u8)(s8)distance);
|
||||
Write8(static_cast<u8>(static_cast<s8>(distance)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -575,7 +575,7 @@ void XEmitter::SetJumpTarget(const FixupBranch& branch)
|
|||
s64 distance = (s64)(code - branch.ptr);
|
||||
ASSERT_MSG(DYNA_REC, distance >= -0x80 && distance < 0x80,
|
||||
"Jump::Short target too far away ({}), needs Jump::Near", distance);
|
||||
branch.ptr[-1] = (u8)(s8)distance;
|
||||
branch.ptr[-1] = static_cast<u8>(static_cast<s8>(distance));
|
||||
}
|
||||
else if (branch.type == FixupBranch::Type::Branch32Bit)
|
||||
{
|
||||
|
@ -608,7 +608,7 @@ void XEmitter::RET_FAST()
|
|||
// The first sign of decadence: optimized NOPs.
|
||||
void XEmitter::NOP(size_t size)
|
||||
{
|
||||
DEBUG_ASSERT((int)size > 0);
|
||||
DEBUG_ASSERT(static_cast<int>(size) > 0);
|
||||
while (true)
|
||||
{
|
||||
switch (size)
|
||||
|
@ -784,17 +784,17 @@ void XEmitter::WriteSimple1Byte(int bits, u8 byte, X64Reg reg)
|
|||
{
|
||||
if (bits == 16)
|
||||
Write8(0x66);
|
||||
Rex(bits == 64, 0, 0, (int)reg >> 3);
|
||||
Write8(byte + ((int)reg & 7));
|
||||
Rex(bits == 64, 0, 0, static_cast<int>(reg) >> 3);
|
||||
Write8(byte + (static_cast<int>(reg) & 7));
|
||||
}
|
||||
|
||||
void XEmitter::WriteSimple2Byte(int bits, u8 byte1, u8 byte2, X64Reg reg)
|
||||
{
|
||||
if (bits == 16)
|
||||
Write8(0x66);
|
||||
Rex(bits == 64, 0, 0, (int)reg >> 3);
|
||||
Rex(bits == 64, 0, 0, static_cast<int>(reg) >> 3);
|
||||
Write8(byte1);
|
||||
Write8(byte2 + ((int)reg & 7));
|
||||
Write8(byte2 + (static_cast<int>(reg) & 7));
|
||||
}
|
||||
|
||||
void XEmitter::CWD(int bits)
|
||||
|
@ -835,16 +835,16 @@ void XEmitter::PUSH(int bits, const OpArg& reg)
|
|||
{
|
||||
case 8:
|
||||
Write8(0x6A);
|
||||
Write8((u8)(s8)reg.offset);
|
||||
Write8(static_cast<u8>(static_cast<s8>(reg.offset)));
|
||||
break;
|
||||
case 16:
|
||||
Write8(0x66);
|
||||
Write8(0x68);
|
||||
Write16((u16)(s16)(s32)reg.offset);
|
||||
Write16(static_cast<u16>(static_cast<s16>((s32)reg.offset)));
|
||||
break;
|
||||
case 32:
|
||||
Write8(0x68);
|
||||
Write32((u32)reg.offset);
|
||||
Write32(static_cast<u32>(reg.offset));
|
||||
break;
|
||||
default:
|
||||
ASSERT_MSG(DYNA_REC, 0, "PUSH - Bad imm bits");
|
||||
|
@ -857,7 +857,7 @@ void XEmitter::PUSH(int bits, const OpArg& reg)
|
|||
Write8(0x66);
|
||||
reg.WriteREX(this, bits, bits);
|
||||
Write8(0xFF);
|
||||
reg.WriteRest(this, 0, (X64Reg)6);
|
||||
reg.WriteRest(this, 0, static_cast<X64Reg>(6));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -913,7 +913,7 @@ void XEmitter::SETcc(CCFlags flag, OpArg dest)
|
|||
dest.operandReg = 0;
|
||||
dest.WriteREX(this, 0, 8);
|
||||
Write8(0x0F);
|
||||
Write8(0x90 + (u8)flag);
|
||||
Write8(0x90 + static_cast<u8>(flag));
|
||||
dest.WriteRest(this);
|
||||
}
|
||||
|
||||
|
@ -926,7 +926,7 @@ void XEmitter::CMOVcc(int bits, X64Reg dest, OpArg src, CCFlags flag)
|
|||
src.operandReg = dest;
|
||||
src.WriteREX(this, bits, bits);
|
||||
Write8(0x0F);
|
||||
Write8(0x40 + (u8)flag);
|
||||
Write8(0x40 + static_cast<u8>(flag));
|
||||
src.WriteRest(this);
|
||||
}
|
||||
|
||||
|
@ -978,7 +978,7 @@ void XEmitter::WriteBitSearchType(int bits, X64Reg dest, OpArg src, u8 byte2, bo
|
|||
{
|
||||
ASSERT_MSG(DYNA_REC, !src.IsImm(), "WriteBitSearchType - Imm argument");
|
||||
CheckFlags();
|
||||
src.operandReg = (u8)dest;
|
||||
src.operandReg = static_cast<u8>(dest);
|
||||
if (bits == 16)
|
||||
Write8(0x66);
|
||||
if (rep)
|
||||
|
@ -1028,7 +1028,7 @@ void XEmitter::MOVSX(int dbits, int sbits, X64Reg dest, OpArg src)
|
|||
MOV(dbits, R(dest), src);
|
||||
return;
|
||||
}
|
||||
src.operandReg = (u8)dest;
|
||||
src.operandReg = static_cast<u8>(dest);
|
||||
if (dbits == 16)
|
||||
Write8(0x66);
|
||||
src.WriteREX(this, dbits, sbits);
|
||||
|
@ -1061,7 +1061,7 @@ void XEmitter::MOVZX(int dbits, int sbits, X64Reg dest, OpArg src)
|
|||
MOV(dbits, R(dest), src);
|
||||
return;
|
||||
}
|
||||
src.operandReg = (u8)dest;
|
||||
src.operandReg = static_cast<u8>(dest);
|
||||
if (dbits == 16)
|
||||
Write8(0x66);
|
||||
// the 32bit result is automatically zero extended to 64bit
|
||||
|
@ -1183,7 +1183,7 @@ void XEmitter::SwapAndStore(int size, const OpArg& dst, X64Reg src, MovInfo* inf
|
|||
void XEmitter::LEA(int bits, X64Reg dest, OpArg src)
|
||||
{
|
||||
ASSERT_MSG(DYNA_REC, !src.IsImm(), "LEA - Imm argument");
|
||||
src.operandReg = (u8)dest;
|
||||
src.operandReg = static_cast<u8>(dest);
|
||||
if (bits == 16)
|
||||
Write8(0x66); // TODO: performance warning
|
||||
src.WriteREX(this, bits, bits);
|
||||
|
@ -1212,7 +1212,7 @@ void XEmitter::WriteShift(int bits, OpArg dest, const OpArg& shift, int ext)
|
|||
if (shift.GetImmBits() == 8)
|
||||
{
|
||||
// ok an imm
|
||||
u8 imm = (u8)shift.offset;
|
||||
u8 imm = static_cast<u8>(shift.offset);
|
||||
if (imm == 1)
|
||||
{
|
||||
Write8(bits == 8 ? 0xD0 : 0xD1);
|
||||
|
@ -1229,7 +1229,7 @@ void XEmitter::WriteShift(int bits, OpArg dest, const OpArg& shift, int ext)
|
|||
}
|
||||
dest.WriteRest(this, writeImm ? 1 : 0);
|
||||
if (writeImm)
|
||||
Write8((u8)shift.offset);
|
||||
Write8(static_cast<u8>(shift.offset));
|
||||
}
|
||||
|
||||
// large rotates and shift are slower on Intel than AMD
|
||||
|
@ -1282,8 +1282,8 @@ void XEmitter::WriteBitTest(int bits, const OpArg& dest, const OpArg& index, int
|
|||
dest.WriteREX(this, bits, bits);
|
||||
Write8(0x0F);
|
||||
Write8(0xBA);
|
||||
dest.WriteRest(this, 1, (X64Reg)ext);
|
||||
Write8((u8)index.offset);
|
||||
dest.WriteRest(this, 1, static_cast<X64Reg>(ext));
|
||||
Write8(static_cast<u8>(index.offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1338,7 +1338,7 @@ void XEmitter::SHRD(int bits, const OpArg& dest, const OpArg& src, const OpArg&
|
|||
Write8(0x0F);
|
||||
Write8(0xAC);
|
||||
dest.WriteRest(this, 1, operand);
|
||||
Write8((u8)shift.offset);
|
||||
Write8(static_cast<u8>(shift.offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1373,7 +1373,7 @@ void XEmitter::SHLD(int bits, const OpArg& dest, const OpArg& src, const OpArg&
|
|||
Write8(0x0F);
|
||||
Write8(0xA4);
|
||||
dest.WriteRest(this, 1, operand);
|
||||
Write8((u8)shift.offset);
|
||||
Write8(static_cast<u8>(shift.offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1388,7 +1388,7 @@ void OpArg::WriteSingleByteOp(XEmitter* emit, u8 op, X64Reg _operandReg, int bit
|
|||
if (bits == 16)
|
||||
emit->Write8(0x66);
|
||||
|
||||
this->operandReg = (u8)_operandReg;
|
||||
this->operandReg = static_cast<u8>(_operandReg);
|
||||
WriteREX(emit, bits, bits);
|
||||
emit->Write8(op);
|
||||
WriteRest(emit);
|
||||
|
@ -1425,14 +1425,14 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
|
|||
if (!scale && offsetOrBaseReg == AL && op_def.eaximm8 != 0xCC)
|
||||
{
|
||||
emit->Write8(op_def.eaximm8);
|
||||
emit->Write8((u8)operand.offset);
|
||||
emit->Write8(static_cast<u8>(operand.offset));
|
||||
return;
|
||||
}
|
||||
// mov reg, imm8
|
||||
if (!scale && op == NormalOp::MOV)
|
||||
{
|
||||
emit->Write8(0xB0 + (offsetOrBaseReg & 7));
|
||||
emit->Write8((u8)operand.offset);
|
||||
emit->Write8(static_cast<u8>(operand.offset));
|
||||
return;
|
||||
}
|
||||
// op r/m8, imm8
|
||||
|
@ -1447,8 +1447,10 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
|
|||
// if the instruction supports simm8.
|
||||
// op r/m, imm8
|
||||
if (op_def.simm8 != 0xCC &&
|
||||
((operand.scale == SCALE_IMM16 && (s16)operand.offset == (s8)operand.offset) ||
|
||||
(operand.scale == SCALE_IMM32 && (s32)operand.offset == (s8)operand.offset)))
|
||||
((operand.scale == SCALE_IMM16 &&
|
||||
static_cast<s16>(operand.offset) == static_cast<s8>(operand.offset)) ||
|
||||
(operand.scale == SCALE_IMM32 &&
|
||||
static_cast<s32>(operand.offset) == static_cast<s8>(operand.offset))))
|
||||
{
|
||||
emit->Write8(op_def.simm8);
|
||||
immToWrite = 8;
|
||||
|
@ -1460,9 +1462,9 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
|
|||
{
|
||||
emit->Write8(0xB8 + (offsetOrBaseReg & 7));
|
||||
if (bits == 16)
|
||||
emit->Write16((u16)operand.offset);
|
||||
emit->Write16(static_cast<u16>(operand.offset));
|
||||
else
|
||||
emit->Write32((u32)operand.offset);
|
||||
emit->Write32(static_cast<u32>(operand.offset));
|
||||
return;
|
||||
}
|
||||
// op eax, imm
|
||||
|
@ -1470,9 +1472,9 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
|
|||
{
|
||||
emit->Write8(op_def.eaximm32);
|
||||
if (bits == 16)
|
||||
emit->Write16((u16)operand.offset);
|
||||
emit->Write16(static_cast<u16>(operand.offset));
|
||||
else
|
||||
emit->Write32((u32)operand.offset);
|
||||
emit->Write32(static_cast<u32>(operand.offset));
|
||||
return;
|
||||
}
|
||||
// op r/m, imm
|
||||
|
@ -1524,7 +1526,7 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
|
|||
}
|
||||
else
|
||||
{
|
||||
_operandReg = (X64Reg)operand.offsetOrBaseReg;
|
||||
_operandReg = static_cast<X64Reg>(operand.offsetOrBaseReg);
|
||||
WriteREX(emit, bits, bits, _operandReg);
|
||||
// op r/m, reg
|
||||
if (toRM)
|
||||
|
@ -1543,13 +1545,13 @@ void OpArg::WriteNormalOp(XEmitter* emit, bool toRM, NormalOp op, const OpArg& o
|
|||
case 0:
|
||||
break;
|
||||
case 8:
|
||||
emit->Write8((u8)operand.offset);
|
||||
emit->Write8(static_cast<u8>(operand.offset));
|
||||
break;
|
||||
case 16:
|
||||
emit->Write16((u16)operand.offset);
|
||||
emit->Write16(static_cast<u16>(operand.offset));
|
||||
break;
|
||||
case 32:
|
||||
emit->Write32((u32)operand.offset);
|
||||
emit->Write32(static_cast<u32>(operand.offset));
|
||||
break;
|
||||
default:
|
||||
ASSERT_MSG(DYNA_REC, 0, "WriteNormalOp - Unhandled case");
|
||||
|
@ -1753,12 +1755,13 @@ void XEmitter::IMUL(int bits, X64Reg regOp, const OpArg& a1, const OpArg& a2)
|
|||
Write8(0x66);
|
||||
a1.WriteREX(this, bits, bits, regOp);
|
||||
|
||||
if (a2.GetImmBits() == 8 || (a2.GetImmBits() == 16 && (s8)a2.offset == (s16)a2.offset) ||
|
||||
(a2.GetImmBits() == 32 && (s8)a2.offset == (s32)a2.offset))
|
||||
if (a2.GetImmBits() == 8 ||
|
||||
(a2.GetImmBits() == 16 && static_cast<s8>(a2.offset) == static_cast<s16>(a2.offset)) ||
|
||||
(a2.GetImmBits() == 32 && static_cast<s8>(a2.offset) == static_cast<s32>(a2.offset)))
|
||||
{
|
||||
Write8(0x6B);
|
||||
a1.WriteRest(this, 1, regOp);
|
||||
Write8((u8)a2.offset);
|
||||
Write8(static_cast<u8>(a2.offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1766,12 +1769,12 @@ void XEmitter::IMUL(int bits, X64Reg regOp, const OpArg& a1, const OpArg& a2)
|
|||
if (a2.GetImmBits() == 16 && bits == 16)
|
||||
{
|
||||
a1.WriteRest(this, 2, regOp);
|
||||
Write16((u16)a2.offset);
|
||||
Write16(static_cast<u16>(a2.offset));
|
||||
}
|
||||
else if (a2.GetImmBits() == 32 && (bits == 32 || bits == 64))
|
||||
{
|
||||
a1.WriteRest(this, 4, regOp);
|
||||
Write32((u32)a2.offset);
|
||||
Write32(static_cast<u32>(a2.offset));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1854,7 +1857,7 @@ void XEmitter::WriteVEXOp4(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, co
|
|||
X64Reg regOp3, int W)
|
||||
{
|
||||
WriteVEXOp(opPrefix, op, regOp1, regOp2, arg, W, 1);
|
||||
Write8((u8)regOp3 << 4);
|
||||
Write8(static_cast<u8>(regOp3) << 4);
|
||||
}
|
||||
|
||||
void XEmitter::WriteAVXOp(u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, const OpArg& arg,
|
||||
|
@ -2512,19 +2515,19 @@ void XEmitter::PUNPCKLQDQ(X64Reg dest, const OpArg& arg)
|
|||
|
||||
void XEmitter::PSRLW(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x71, (X64Reg)2, R(reg));
|
||||
WriteSSEOp(0x66, 0x71, static_cast<X64Reg>(2), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
void XEmitter::PSRLD(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x72, (X64Reg)2, R(reg));
|
||||
WriteSSEOp(0x66, 0x72, static_cast<X64Reg>(2), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
void XEmitter::PSRLQ(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x73, (X64Reg)2, R(reg));
|
||||
WriteSSEOp(0x66, 0x73, static_cast<X64Reg>(2), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
|
@ -2535,31 +2538,31 @@ void XEmitter::PSRLQ(X64Reg reg, const OpArg& arg)
|
|||
|
||||
void XEmitter::PSRLDQ(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x73, (X64Reg)3, R(reg));
|
||||
WriteSSEOp(0x66, 0x73, static_cast<X64Reg>(3), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
void XEmitter::PSLLW(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x71, (X64Reg)6, R(reg));
|
||||
WriteSSEOp(0x66, 0x71, static_cast<X64Reg>(6), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
void XEmitter::PSLLD(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x72, (X64Reg)6, R(reg));
|
||||
WriteSSEOp(0x66, 0x72, static_cast<X64Reg>(6), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
void XEmitter::PSLLQ(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x73, (X64Reg)6, R(reg));
|
||||
WriteSSEOp(0x66, 0x73, static_cast<X64Reg>(6), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
void XEmitter::PSLLDQ(X64Reg reg, int shift)
|
||||
{
|
||||
WriteSSEOp(0x66, 0x73, (X64Reg)7, R(reg));
|
||||
WriteSSEOp(0x66, 0x73, static_cast<X64Reg>(7), R(reg));
|
||||
Write8(shift);
|
||||
}
|
||||
|
||||
|
@ -3338,15 +3341,15 @@ void XEmitter::BZHI(int bits, X64Reg regOp1, const OpArg& arg, X64Reg regOp2)
|
|||
}
|
||||
void XEmitter::BLSR(int bits, X64Reg regOp, const OpArg& arg)
|
||||
{
|
||||
WriteBMI1Op(bits, 0x00, 0x38F3, (X64Reg)0x1, regOp, arg);
|
||||
WriteBMI1Op(bits, 0x00, 0x38F3, static_cast<X64Reg>(0x1), regOp, arg);
|
||||
}
|
||||
void XEmitter::BLSMSK(int bits, X64Reg regOp, const OpArg& arg)
|
||||
{
|
||||
WriteBMI1Op(bits, 0x00, 0x38F3, (X64Reg)0x2, regOp, arg);
|
||||
WriteBMI1Op(bits, 0x00, 0x38F3, static_cast<X64Reg>(0x2), regOp, arg);
|
||||
}
|
||||
void XEmitter::BLSI(int bits, X64Reg regOp, const OpArg& arg)
|
||||
{
|
||||
WriteBMI1Op(bits, 0x00, 0x38F3, (X64Reg)0x3, regOp, arg);
|
||||
WriteBMI1Op(bits, 0x00, 0x38F3, static_cast<X64Reg>(0x3), regOp, arg);
|
||||
}
|
||||
void XEmitter::BEXTR(int bits, X64Reg regOp1, const OpArg& arg, X64Reg regOp2)
|
||||
{
|
||||
|
|
|
@ -130,38 +130,38 @@ struct OpArg
|
|||
u32 Imm32() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM32);
|
||||
return (u32)offset;
|
||||
return static_cast<u32>(offset);
|
||||
}
|
||||
u16 Imm16() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM16);
|
||||
return (u16)offset;
|
||||
return static_cast<u16>(offset);
|
||||
}
|
||||
u8 Imm8() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM8);
|
||||
return (u8)offset;
|
||||
return static_cast<u8>(offset);
|
||||
}
|
||||
|
||||
s64 SImm64() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM64);
|
||||
return (s64)offset;
|
||||
return static_cast<s64>(offset);
|
||||
}
|
||||
s32 SImm32() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM32);
|
||||
return (s32)offset;
|
||||
return static_cast<s32>(offset);
|
||||
}
|
||||
s16 SImm16() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM16);
|
||||
return (s16)offset;
|
||||
return static_cast<s16>(offset);
|
||||
}
|
||||
s8 SImm8() const
|
||||
{
|
||||
DEBUG_ASSERT(scale == SCALE_IMM8);
|
||||
return (s8)offset;
|
||||
return static_cast<s8>(offset);
|
||||
}
|
||||
|
||||
OpArg AsImm64() const
|
||||
|
@ -172,17 +172,17 @@ struct OpArg
|
|||
OpArg AsImm32() const
|
||||
{
|
||||
DEBUG_ASSERT(IsImm());
|
||||
return OpArg((u32)offset, SCALE_IMM32);
|
||||
return OpArg(static_cast<u32>(offset), SCALE_IMM32);
|
||||
}
|
||||
OpArg AsImm16() const
|
||||
{
|
||||
DEBUG_ASSERT(IsImm());
|
||||
return OpArg((u16)offset, SCALE_IMM16);
|
||||
return OpArg(static_cast<u16>(offset), SCALE_IMM16);
|
||||
}
|
||||
OpArg AsImm8() const
|
||||
{
|
||||
DEBUG_ASSERT(IsImm());
|
||||
return OpArg((u8)offset, SCALE_IMM8);
|
||||
return OpArg(static_cast<u8>(offset), SCALE_IMM8);
|
||||
}
|
||||
|
||||
constexpr bool IsImm() const
|
||||
|
@ -244,7 +244,7 @@ private:
|
|||
template <typename T>
|
||||
inline OpArg M(const T* ptr)
|
||||
{
|
||||
return OpArg((u64)(const void*)ptr, (int)SCALE_RIP);
|
||||
return OpArg((u64) static_cast<const void*>(ptr), (int)SCALE_RIP);
|
||||
}
|
||||
constexpr OpArg R(X64Reg value)
|
||||
{
|
||||
|
@ -308,7 +308,7 @@ inline u32 PtrOffset(const void* ptr, const void* base = nullptr)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return (u32)distance;
|
||||
return static_cast<u32>(distance);
|
||||
}
|
||||
|
||||
struct FixupBranch
|
||||
|
|
|
@ -150,8 +150,8 @@ constexpr Seeds genseeds = [] {
|
|||
|
||||
for (size_t i = 0; i < array0.size(); ++i)
|
||||
{
|
||||
const auto tmp = u8(gentable0[i] - 1);
|
||||
array0[i] = (u32(0 - (gensubtable[tmp >> 3] & gentable1[tmp & 7])) >> 31);
|
||||
const auto tmp = static_cast<u8>(gentable0[i] - 1);
|
||||
array0[i] = (static_cast<u32>(0 - (gensubtable[tmp >> 3] & gentable1[tmp & 7])) >> 31);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0x10; ++i)
|
||||
|
@ -163,7 +163,7 @@ constexpr Seeds genseeds = [] {
|
|||
|
||||
for (u32 j = 0; j < 0x38; j++)
|
||||
{
|
||||
auto tmp = u8(tmp2 + j);
|
||||
auto tmp = static_cast<u8>(tmp2 + j);
|
||||
|
||||
if (j > 0x1B)
|
||||
{
|
||||
|
@ -394,7 +394,7 @@ static bool batchdecrypt(u32* codes, u16 size)
|
|||
|
||||
static int GetVal(const char* flt, char chr)
|
||||
{
|
||||
int ret = (int)(strchr(flt, chr) - flt);
|
||||
int ret = static_cast<int>(strchr(flt, chr) - flt);
|
||||
switch (ret)
|
||||
{
|
||||
case 32: // 'I'
|
||||
|
@ -466,7 +466,7 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
|
|||
Common::ToUpper(&s);
|
||||
}
|
||||
|
||||
const u32 ret = alphatobin(uCodes.data(), vCodes, (int)vCodes.size());
|
||||
const u32 ret = alphatobin(uCodes.data(), vCodes, static_cast<int>(vCodes.size()));
|
||||
if (ret)
|
||||
{
|
||||
// Return value is index + 1, 0 being the success flag value.
|
||||
|
@ -474,7 +474,7 @@ void DecryptARCode(std::vector<std::string> vCodes, std::vector<AREntry>* ops)
|
|||
"Action Replay Code Decryption Error:\nParity Check Failed\n\nCulprit Code:\n{0}",
|
||||
vCodes[ret - 1]);
|
||||
}
|
||||
else if (!batchdecrypt(uCodes.data(), (u16)vCodes.size() << 1))
|
||||
else if (!batchdecrypt(uCodes.data(), static_cast<u16>(vCodes.size()) << 1))
|
||||
{
|
||||
// Commented out since we just send the code anyways and hope for the best XD
|
||||
// PanicAlertFmt("Action Replay Code Decryption Error:\nCRC Check Failed\n\n"
|
||||
|
|
|
@ -640,7 +640,7 @@ void AchievementManager::DoState(PointerWrap& p)
|
|||
return;
|
||||
}
|
||||
}
|
||||
p.DoArray(buffer.get(), (u32)size);
|
||||
p.DoArray(buffer.get(), static_cast<u32>(size));
|
||||
if (p.IsReadMode())
|
||||
{
|
||||
int result = rc_client_deserialize_progress_sized(m_client, buffer.get(), size);
|
||||
|
|
|
@ -86,7 +86,7 @@ bool DolReader::Initialize(const std::vector<u8>& buffer)
|
|||
std::vector<u8> data(section_size);
|
||||
const u8* data_start = &buffer[section_offset];
|
||||
std::memcpy(&data[0], data_start,
|
||||
std::min((size_t)section_size, buffer.size() - section_offset));
|
||||
std::min(static_cast<size_t>(section_size), buffer.size() - section_offset));
|
||||
m_data_sections.emplace_back(data);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -31,8 +31,8 @@ public:
|
|||
~ElfReader();
|
||||
u32 Read32(int off) const { return base32[off >> 2]; }
|
||||
// Quick accessors
|
||||
ElfType GetType() const { return (ElfType)(header->e_type); }
|
||||
ElfMachine GetMachine() const { return (ElfMachine)(header->e_machine); }
|
||||
ElfType GetType() const { return static_cast<ElfType>(header->e_type); }
|
||||
ElfMachine GetMachine() const { return static_cast<ElfMachine>(header->e_machine); }
|
||||
u32 GetEntryPoint() const override { return entryPoint; }
|
||||
u32 GetFlags() const { return (u32)(header->e_flags); }
|
||||
bool LoadIntoMemory(Core::System& system, bool only_in_mem1 = false) const override;
|
||||
|
|
|
@ -924,11 +924,11 @@ int AddOnStateChangedCallback(StateChangedCallbackFunc callback)
|
|||
if (!s_on_state_changed_callbacks[i])
|
||||
{
|
||||
s_on_state_changed_callbacks[i] = std::move(callback);
|
||||
return int(i);
|
||||
return static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
s_on_state_changed_callbacks.emplace_back(std::move(callback));
|
||||
return int(s_on_state_changed_callbacks.size()) - 1;
|
||||
return static_cast<int>(s_on_state_changed_callbacks.size()) - 1;
|
||||
}
|
||||
|
||||
bool RemoveOnStateChangedCallback(int* handle)
|
||||
|
|
|
@ -273,7 +273,7 @@ s32 DSPAssembler::ParseValue(const char* str)
|
|||
//
|
||||
char* DSPAssembler::FindBrackets(char* src, char* dst)
|
||||
{
|
||||
s32 len = (s32)strlen(src);
|
||||
s32 len = static_cast<s32>(strlen(src));
|
||||
s32 first = -1;
|
||||
s32 count = 0;
|
||||
s32 i, j;
|
||||
|
@ -323,8 +323,8 @@ u32 DSPAssembler::ParseExpression(const char* ptr)
|
|||
char* pbuf;
|
||||
s32 val = 0;
|
||||
|
||||
char* d_buffer = (char*)malloc(1024);
|
||||
char* s_buffer = (char*)malloc(1024);
|
||||
char* d_buffer = static_cast<char*>(malloc(1024));
|
||||
char* s_buffer = static_cast<char*>(malloc(1024));
|
||||
strcpy(s_buffer, ptr);
|
||||
|
||||
while ((pbuf = FindBrackets(s_buffer, d_buffer)) != nullptr)
|
||||
|
@ -335,14 +335,14 @@ u32 DSPAssembler::ParseExpression(const char* ptr)
|
|||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < ((s32)strlen(s_buffer) + 1); i++)
|
||||
for (int i = 0; i < (static_cast<s32>(strlen(s_buffer)) + 1); i++)
|
||||
{
|
||||
char c = s_buffer[i];
|
||||
if (c != ' ')
|
||||
d_buffer[j++] = c;
|
||||
}
|
||||
|
||||
for (int i = 0; i < ((s32)strlen(d_buffer) + 1); i++)
|
||||
for (int i = 0; i < (static_cast<s32>(strlen(d_buffer)) + 1); i++)
|
||||
{
|
||||
char c = d_buffer[i];
|
||||
if (c == '-')
|
||||
|
@ -537,21 +537,23 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
case P_REG1C:
|
||||
{
|
||||
int value = (opc->params[i].type >> 8) & 0x1f;
|
||||
if ((int)par[i].val < value ||
|
||||
(int)par[i].val > value + get_mask_shifted_down(opc->params[i].mask))
|
||||
if (static_cast<int>(par[i].val) < value ||
|
||||
static_cast<int>(par[i].val) > value + get_mask_shifted_down(opc->params[i].mask))
|
||||
{
|
||||
ShowError(AssemblerError::InvalidRegister);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case P_PRG:
|
||||
if ((int)par[i].val < DSP_REG_AR0 || (int)par[i].val > DSP_REG_AR3)
|
||||
if (static_cast<int>(par[i].val) < DSP_REG_AR0 ||
|
||||
static_cast<int>(par[i].val) > DSP_REG_AR3)
|
||||
{
|
||||
ShowError(AssemblerError::InvalidRegister);
|
||||
}
|
||||
break;
|
||||
case P_ACC:
|
||||
if ((int)par[i].val < DSP_REG_ACC0_FULL || (int)par[i].val > DSP_REG_ACC1_FULL)
|
||||
if (static_cast<int>(par[i].val) < DSP_REG_ACC0_FULL ||
|
||||
static_cast<int>(par[i].val) > DSP_REG_ACC1_FULL)
|
||||
{
|
||||
if (par[i].val >= DSP_REG_ACM0 && par[i].val <= DSP_REG_ACM1)
|
||||
{
|
||||
|
@ -568,7 +570,8 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
}
|
||||
break;
|
||||
case P_ACCM:
|
||||
if ((int)par[i].val < DSP_REG_ACM0 || (int)par[i].val > DSP_REG_ACM1)
|
||||
if (static_cast<int>(par[i].val) < DSP_REG_ACM0 ||
|
||||
static_cast<int>(par[i].val) > DSP_REG_ACM1)
|
||||
{
|
||||
if (par[i].val >= DSP_REG_ACL0 && par[i].val <= DSP_REG_ACL1)
|
||||
{
|
||||
|
@ -585,7 +588,8 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
}
|
||||
break;
|
||||
case P_ACCL:
|
||||
if ((int)par[i].val < DSP_REG_ACL0 || (int)par[i].val > DSP_REG_ACL1)
|
||||
if (static_cast<int>(par[i].val) < DSP_REG_ACL0 ||
|
||||
static_cast<int>(par[i].val) > DSP_REG_ACL1)
|
||||
{
|
||||
if (par[i].val >= DSP_REG_ACM0 && par[i].val <= DSP_REG_ACM1)
|
||||
{
|
||||
|
@ -630,12 +634,12 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
// modified by Hermes: test NUMBER range
|
||||
int value = get_mask_shifted_down(opc->params[i].mask);
|
||||
unsigned int valueu = 0xffff & ~(value >> 1);
|
||||
if ((int)par[i].val < 0)
|
||||
if (static_cast<int>(par[i].val) < 0)
|
||||
{
|
||||
if (value == 7) // value 7 for sbclr/sbset
|
||||
{
|
||||
ShowError(AssemblerError::NumberOutOfRange, "Value must be from 0x0 to {:#x}, was {:#x}",
|
||||
value, (int)par[i].val);
|
||||
value, static_cast<int>(par[i].val));
|
||||
}
|
||||
else if (opc->params[i].type == P_MEM)
|
||||
{
|
||||
|
@ -643,27 +647,28 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
{
|
||||
ShowError(AssemblerError::NumberOutOfRange,
|
||||
"Address value must be from {:#x} to {:#x}, was {:#x}", valueu, (value >> 1),
|
||||
(int)par[i].val);
|
||||
static_cast<int>(par[i].val));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowError(AssemblerError::NumberOutOfRange,
|
||||
"Address value must be from 0x0 to {:#x}, was {:#x}", value, (int)par[i].val);
|
||||
"Address value must be from 0x0 to {:#x}, was {:#x}", value,
|
||||
static_cast<int>(par[i].val));
|
||||
}
|
||||
}
|
||||
else if ((int)par[i].val < -((value >> 1) + 1))
|
||||
else if (static_cast<int>(par[i].val) < -((value >> 1) + 1))
|
||||
{
|
||||
if (value < 128)
|
||||
{
|
||||
ShowError(AssemblerError::NumberOutOfRange,
|
||||
"Value must be from {:#x} to {:#x}, was {:#x}", -((value >> 1) + 1),
|
||||
value >> 1, (int)par[i].val);
|
||||
value >> 1, static_cast<int>(par[i].val));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowError(AssemblerError::NumberOutOfRange,
|
||||
"Value must be from {:#x} to {:#x} or 0x0 to {:#x}, was {:#x}",
|
||||
-((value >> 1) + 1), value >> 1, value, (int)par[i].val);
|
||||
-((value >> 1) + 1), value >> 1, value, static_cast<int>(par[i].val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -671,7 +676,7 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
{
|
||||
if (value == 7) // value 7 for sbclr/sbset
|
||||
{
|
||||
if (par[i].val > (unsigned)value)
|
||||
if (par[i].val > static_cast<unsigned>(value))
|
||||
{
|
||||
ShowError(AssemblerError::NumberOutOfRange,
|
||||
"Value must be from {:#x} to {:#x}, was {:#x}\n", valueu, value, par[i].val);
|
||||
|
@ -681,8 +686,8 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
{
|
||||
if (value < 256)
|
||||
value >>= 1; // addressing 8 bit with sign
|
||||
if (par[i].val > (unsigned)value &&
|
||||
(par[i].val < valueu || par[i].val > (unsigned)0xffff))
|
||||
if (par[i].val > static_cast<unsigned>(value) &&
|
||||
(par[i].val < valueu || par[i].val > static_cast<unsigned>(0xffff)))
|
||||
{
|
||||
if (value < 256)
|
||||
{
|
||||
|
@ -702,7 +707,7 @@ bool DSPAssembler::VerifyParams(const DSPOPCTemplate* opc, param_t* par, size_t
|
|||
{
|
||||
if (value < 128)
|
||||
value >>= 1; // special case ASL/ASR/LSL/LSR
|
||||
if (par[i].val > (unsigned)value)
|
||||
if (par[i].val > static_cast<unsigned>(value))
|
||||
{
|
||||
if (value < 64)
|
||||
{
|
||||
|
@ -818,7 +823,7 @@ bool DSPAssembler::AssemblePass(const std::string& text, int pass)
|
|||
}
|
||||
|
||||
// turn text into spaces if disable_text is on (in a comment).
|
||||
if (disable_text && ((unsigned char)c) > ' ')
|
||||
if (disable_text && static_cast<unsigned char>(c) > ' ')
|
||||
c = ' ';
|
||||
|
||||
if (c == '\r' || c == '\n' || c == ';')
|
||||
|
@ -842,7 +847,7 @@ bool DSPAssembler::AssemblePass(const std::string& text, int pass)
|
|||
{
|
||||
bool valid = true;
|
||||
|
||||
for (int j = 0; j < (int)col_pos; j++)
|
||||
for (int j = 0; j < static_cast<int>(col_pos); j++)
|
||||
{
|
||||
if (j == 0)
|
||||
if (!((ptr[j] >= 'A' && ptr[j] <= 'Z') || (ptr[j] == '_')))
|
||||
|
|
|
@ -141,7 +141,8 @@ std::vector<u16> BinaryStringBEToCode(const std::string& str)
|
|||
|
||||
for (size_t i = 0; i < code.size(); i++)
|
||||
{
|
||||
code[i] = ((u16)(u8)str[i * 2 + 0] << 8) | ((u16)(u8)str[i * 2 + 1]);
|
||||
code[i] = (static_cast<u16>(static_cast<u8>(str[i * 2 + 0])) << 8) |
|
||||
static_cast<u16>(static_cast<u8>(str[i * 2 + 1]));
|
||||
}
|
||||
|
||||
return code;
|
||||
|
|
|
@ -109,7 +109,8 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
|
|||
{
|
||||
// Left and right shifts function essentially as a single shift by a 7-bit signed value,
|
||||
// but are split into two intructions for clarity.
|
||||
buf += fmt::format("#{}", (val & 0x20) != 0 ? (int(val) - 64) : int(val));
|
||||
buf += fmt::format("#{}", (val & 0x20) != 0 ? (static_cast<int>(val) - 64) :
|
||||
static_cast<int>(val));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -124,7 +125,7 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
|
|||
|
||||
case P_MEM:
|
||||
if (opc.params[j].size != 2)
|
||||
val = (u16)(s16)(s8)val;
|
||||
val = static_cast<u16>(static_cast<s16>((s8)val));
|
||||
|
||||
if (settings_.decode_names)
|
||||
buf += fmt::format("@{}", pdname(val));
|
||||
|
|
|
@ -1226,7 +1226,7 @@ void DSPEmitter::lsl(const UDSPInstruction opc)
|
|||
get_long_acc(rreg);
|
||||
|
||||
// acc <<= shift;
|
||||
SHL(64, R(RAX), Imm8((u8)shift));
|
||||
SHL(64, R(RAX), Imm8(static_cast<u8>(shift)));
|
||||
|
||||
// dsp_set_long_acc(rreg, acc);
|
||||
set_long_acc(rreg);
|
||||
|
@ -1285,7 +1285,7 @@ void DSPEmitter::asl(const UDSPInstruction opc)
|
|||
// u64 acc = dsp_get_long_acc(rreg);
|
||||
get_long_acc(rreg);
|
||||
// acc <<= shift;
|
||||
SHL(64, R(RAX), Imm8((u8)shift));
|
||||
SHL(64, R(RAX), Imm8(static_cast<u8>(shift)));
|
||||
// dsp_set_long_acc(rreg, acc);
|
||||
set_long_acc(rreg);
|
||||
// Update_SR_Register64(dsp_get_long_acc(rreg));
|
||||
|
@ -1315,7 +1315,7 @@ void DSPEmitter::asr(const UDSPInstruction opc)
|
|||
// s64 acc = dsp_get_long_acc(dreg);
|
||||
get_long_acc(dreg);
|
||||
// acc >>= shift;
|
||||
SAR(64, R(RAX), Imm8((u8)shift));
|
||||
SAR(64, R(RAX), Imm8(static_cast<u8>(shift)));
|
||||
|
||||
// dsp_set_long_acc(dreg, acc);
|
||||
set_long_acc(dreg);
|
||||
|
|
|
@ -47,7 +47,7 @@ void DSPEmitter::lri(const UDSPInstruction opc)
|
|||
void DSPEmitter::lris(const UDSPInstruction opc)
|
||||
{
|
||||
u8 reg = ((opc >> 8) & 0x7) + DSP_REG_AXL0;
|
||||
u16 imm = (s8)opc;
|
||||
u16 imm = static_cast<s8>(opc);
|
||||
dsp_op_write_reg_imm(reg, imm);
|
||||
dsp_conditional_extend_accum_imm(reg, imm);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ CDump::~CDump()
|
|||
|
||||
int CDump::GetNumberOfSteps()
|
||||
{
|
||||
return (int)(m_size / STRUCTUR_SIZE);
|
||||
return static_cast<int>(m_size / STRUCTUR_SIZE);
|
||||
}
|
||||
|
||||
u32 CDump::GetGPR(int _step, int _gpr)
|
||||
|
|
|
@ -19,23 +19,23 @@ namespace Core::Debug
|
|||
void OSContext::Read(const Core::CPUThreadGuard& guard, u32 addr)
|
||||
{
|
||||
for (std::size_t i = 0; i < gpr.size(); i++)
|
||||
gpr[i] = PowerPC::MMU::HostRead_U32(guard, addr + u32(i * sizeof(int)));
|
||||
gpr[i] = PowerPC::MMU::HostRead_U32(guard, addr + static_cast<u32>(i * sizeof(int)));
|
||||
cr = PowerPC::MMU::HostRead_U32(guard, addr + 0x80);
|
||||
lr = PowerPC::MMU::HostRead_U32(guard, addr + 0x84);
|
||||
ctr = PowerPC::MMU::HostRead_U32(guard, addr + 0x88);
|
||||
xer = PowerPC::MMU::HostRead_U32(guard, addr + 0x8C);
|
||||
for (std::size_t i = 0; i < fpr.size(); i++)
|
||||
fpr[i] = PowerPC::MMU::HostRead_F64(guard, addr + 0x90 + u32(i * sizeof(double)));
|
||||
fpr[i] = PowerPC::MMU::HostRead_F64(guard, addr + 0x90 + static_cast<u32>(i * sizeof(double)));
|
||||
fpscr = PowerPC::MMU::HostRead_U64(guard, addr + 0x190);
|
||||
srr0 = PowerPC::MMU::HostRead_U32(guard, addr + 0x198);
|
||||
srr1 = PowerPC::MMU::HostRead_U32(guard, addr + 0x19c);
|
||||
dummy = PowerPC::MMU::HostRead_U16(guard, addr + 0x1a0);
|
||||
state = static_cast<OSContext::State>(PowerPC::MMU::HostRead_U16(guard, addr + 0x1a2));
|
||||
for (std::size_t i = 0; i < gqr.size(); i++)
|
||||
gqr[i] = PowerPC::MMU::HostRead_U32(guard, addr + 0x1a4 + u32(i * sizeof(int)));
|
||||
gqr[i] = PowerPC::MMU::HostRead_U32(guard, addr + 0x1a4 + static_cast<u32>(i * sizeof(int)));
|
||||
psf_padding = 0;
|
||||
for (std::size_t i = 0; i < psf.size(); i++)
|
||||
psf[i] = PowerPC::MMU::HostRead_F64(guard, addr + 0x1c8 + u32(i * sizeof(double)));
|
||||
psf[i] = PowerPC::MMU::HostRead_F64(guard, addr + 0x1c8 + static_cast<u32>(i * sizeof(double)));
|
||||
}
|
||||
|
||||
// Mutex offsets based on the following functions:
|
||||
|
|
|
@ -458,8 +458,8 @@ PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instructio
|
|||
// match[1]: negative sign for offset or no match.
|
||||
// match[2]: 0xNNNN, 0, or rNN. Check next for 'r' to see if a gpr needs to be loaded.
|
||||
// match[3]: will either be p, toc, or NN. Always a gpr.
|
||||
const std::string_view offset_match{&*match[2].first, size_t(match[2].length())};
|
||||
const std::string_view register_match{&*match[3].first, size_t(match[3].length())};
|
||||
const std::string_view offset_match{&*match[2].first, static_cast<size_t>(match[2].length())};
|
||||
const std::string_view register_match{&*match[3].first, static_cast<size_t>(match[3].length())};
|
||||
constexpr char is_reg = 'r';
|
||||
u32 offset = 0;
|
||||
|
||||
|
@ -488,7 +488,8 @@ PPCDebugInterface::GetMemoryAddressFromInstruction(const std::string& instructio
|
|||
|
||||
const u32 base_address = m_system.GetPPCState().gpr[i];
|
||||
|
||||
if (std::string_view sign{&*match[1].first, size_t(match[1].length())}; !sign.empty())
|
||||
if (std::string_view sign{&*match[1].first, static_cast<size_t>(match[1].length())};
|
||||
!sign.empty())
|
||||
return base_address - offset;
|
||||
|
||||
return base_address + offset;
|
||||
|
|
|
@ -158,7 +158,7 @@ bool FifoDataFile::Save(const std::string& filename)
|
|||
header.texMemSize = TEX_MEM_SIZE;
|
||||
|
||||
header.frameListOffset = frameListOffset;
|
||||
header.frameCount = (u32)m_Frames.size();
|
||||
header.frameCount = static_cast<u32>(m_Frames.size());
|
||||
|
||||
header.flags = m_Flags;
|
||||
|
||||
|
|
|
@ -92,8 +92,8 @@ void FifoPlaybackAnalyzer::AnalyzeFrames(FifoDataFile* file,
|
|||
|
||||
while (offset < frame.fifoData.size())
|
||||
{
|
||||
const u32 cmd_size = OpcodeDecoder::RunCommand(&frame.fifoData[offset],
|
||||
u32(frame.fifoData.size()) - offset, analyzer);
|
||||
const u32 cmd_size = OpcodeDecoder::RunCommand(
|
||||
&frame.fifoData[offset], static_cast<u32>(frame.fifoData.size()) - offset, analyzer);
|
||||
|
||||
if (analyzer.m_start_of_primitives)
|
||||
{
|
||||
|
@ -414,7 +414,7 @@ void FifoPlayer::WriteFrame(const FifoFrameInfo& frame, const AnalyzedFrameInfo&
|
|||
// Skip all memory updates if early memory updates are enabled, as we already wrote them
|
||||
if (m_EarlyMemoryUpdates)
|
||||
{
|
||||
memory_update = (u32)(frame.memoryUpdates.size());
|
||||
memory_update = static_cast<u32>(frame.memoryUpdates.size());
|
||||
}
|
||||
|
||||
for (const FramePart& part : info.parts)
|
||||
|
@ -533,7 +533,7 @@ void FifoPlayer::WriteFifo(const u8* data, u32 start, u32 end)
|
|||
gpfifo.Write8(data[written++]);
|
||||
|
||||
// Advance core timing
|
||||
u32 elapsedCycles = u32(((u64)written * m_CyclesPerFrame) / m_FrameFifoSize);
|
||||
u32 elapsedCycles = static_cast<u32>((static_cast<u64>(written) * m_CyclesPerFrame) / m_FrameFifoSize);
|
||||
u32 cyclesUsed = elapsedCycles - m_ElapsedCycles;
|
||||
m_ElapsedCycles = elapsedCycles;
|
||||
|
||||
|
|
|
@ -379,7 +379,7 @@ void FifoRecorder::UseMemory(u32 address, u32 size, MemoryUpdate::Type type, boo
|
|||
// Record memory update
|
||||
MemoryUpdate memUpdate;
|
||||
memUpdate.address = address;
|
||||
memUpdate.fifoPosition = (u32)(m_FifoData.size());
|
||||
memUpdate.fifoPosition = static_cast<u32>(m_FifoData.size());
|
||||
memUpdate.type = type;
|
||||
memUpdate.data.resize(size);
|
||||
std::copy_n(newData, size, memUpdate.data.begin());
|
||||
|
@ -447,7 +447,7 @@ void FifoRecorder::SetVideoMemory(const u32* bpMem, const u32* cpMem, const u32*
|
|||
memcpy(m_File->GetCPMem(), cpMem, FifoDataFile::CP_MEM_SIZE * 4);
|
||||
memcpy(m_File->GetXFMem(), xfMem, FifoDataFile::XF_MEM_SIZE * 4);
|
||||
|
||||
u32 xfRegsCopySize = std::min((u32)FifoDataFile::XF_REGS_SIZE, xfRegsSize);
|
||||
u32 xfRegsCopySize = std::min(static_cast<u32>(FifoDataFile::XF_REGS_SIZE), xfRegsSize);
|
||||
memcpy(m_File->GetXFRegs(), xfRegs, xfRegsCopySize * 4);
|
||||
|
||||
memcpy(m_File->GetTexMem(), texMem_ptr, FifoDataFile::TEX_MEM_SIZE);
|
||||
|
|
|
@ -118,7 +118,7 @@ FreeLookController::FreeLookController(const unsigned int index) : m_index(index
|
|||
|
||||
std::string FreeLookController::GetName() const
|
||||
{
|
||||
return std::string("FreeLook") + char('1' + m_index);
|
||||
return std::string("FreeLook") + static_cast<char>('1' + m_index);
|
||||
}
|
||||
|
||||
InputConfig* FreeLookController::GetConfig() const
|
||||
|
|
|
@ -43,7 +43,7 @@ u16 CMailHandler::ReadDSPMailboxHigh()
|
|||
{
|
||||
m_last_mail = m_pending_mails.front().first;
|
||||
}
|
||||
return u16(m_last_mail >> 0x10);
|
||||
return static_cast<u16>(m_last_mail >> 0x10);
|
||||
}
|
||||
|
||||
u16 CMailHandler::ReadDSPMailboxLow()
|
||||
|
@ -66,7 +66,7 @@ u16 CMailHandler::ReadDSPMailboxLow()
|
|||
// (The CPU reads the high word first, and then the low word; since this function returns the low
|
||||
// word, this means that the next read of the high word will have the top bit cleared.)
|
||||
m_last_mail &= ~0x8000'0000;
|
||||
return u16(m_last_mail & 0xffff);
|
||||
return static_cast<u16>(m_last_mail & 0xffff);
|
||||
}
|
||||
|
||||
void CMailHandler::ClearPending()
|
||||
|
|
|
@ -360,7 +360,7 @@ AXMixControl AXUCode::ConvertMixerControl(u32 mixer_control)
|
|||
// This will only matter once we have ITD support.
|
||||
}
|
||||
|
||||
return (AXMixControl)ret;
|
||||
return static_cast<AXMixControl>(ret);
|
||||
}
|
||||
|
||||
void AXUCode::SetupProcessing(u32 init_addr)
|
||||
|
@ -390,16 +390,16 @@ void AXUCode::DownloadAndMixWithVolume(u32 addr, u16 vol_main, u16 vol_auxa, u16
|
|||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
for (u32 i = 0; i < 3; ++i)
|
||||
{
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, addr));
|
||||
u16 volume = volumes[i];
|
||||
for (u32 j = 0; j < 3; ++j)
|
||||
{
|
||||
int* buffer = buffers[i][j];
|
||||
for (u32 k = 0; k < 5 * 32; ++k)
|
||||
{
|
||||
s64 sample = (s64)(s32)Common::swap32(*ptr++);
|
||||
s64 sample = (s64) static_cast<s32>(Common::swap32(*ptr++));
|
||||
sample *= volume;
|
||||
buffer[k] += (s32)(sample >> 15);
|
||||
buffer[k] += static_cast<s32>(sample >> 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ void AXUCode::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr)
|
|||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
if (write_addr)
|
||||
{
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, write_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, write_addr));
|
||||
for (auto& buffer : buffers)
|
||||
for (u32 j = 0; j < 5 * 32; ++j)
|
||||
*ptr++ = Common::swap32(buffer[j]);
|
||||
|
@ -523,13 +523,13 @@ void AXUCode::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr)
|
|||
|
||||
// Then, we read the new temp from the CPU and add to our current
|
||||
// temp.
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, read_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, read_addr));
|
||||
for (auto& sample : m_samples_main_left)
|
||||
sample += (int)Common::swap32(*ptr++);
|
||||
sample += static_cast<int>(Common::swap32(*ptr++));
|
||||
for (auto& sample : m_samples_main_right)
|
||||
sample += (int)Common::swap32(*ptr++);
|
||||
sample += static_cast<int>(Common::swap32(*ptr++));
|
||||
for (auto& sample : m_samples_main_surround)
|
||||
sample += (int)Common::swap32(*ptr++);
|
||||
sample += static_cast<int>(Common::swap32(*ptr++));
|
||||
}
|
||||
|
||||
void AXUCode::UploadLRS(u32 dst_addr)
|
||||
|
@ -548,10 +548,10 @@ void AXUCode::UploadLRS(u32 dst_addr)
|
|||
|
||||
void AXUCode::SetMainLR(u32 src_addr)
|
||||
{
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(m_dsphle->GetSystem().GetMemory(), src_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(m_dsphle->GetSystem().GetMemory(), src_addr));
|
||||
for (u32 i = 0; i < 5 * 32; ++i)
|
||||
{
|
||||
int samp = (int)Common::swap32(*ptr++);
|
||||
int samp = static_cast<int>(Common::swap32(*ptr++));
|
||||
m_samples_main_left[i] = samp;
|
||||
m_samples_main_right[i] = samp;
|
||||
m_samples_main_surround[i] = 0;
|
||||
|
@ -564,8 +564,8 @@ void AXUCode::RunCompressor(u16 threshold, u16 release_frames, u32 table_addr, u
|
|||
bool triggered = false;
|
||||
for (u32 i = 0; i < 32 * millis; ++i)
|
||||
{
|
||||
if (std::abs(m_samples_main_left[i]) > int(threshold) ||
|
||||
std::abs(m_samples_main_right[i]) > int(threshold))
|
||||
if (std::abs(m_samples_main_left[i]) > static_cast<int>(threshold) ||
|
||||
std::abs(m_samples_main_right[i]) > static_cast<int>(threshold))
|
||||
{
|
||||
triggered = true;
|
||||
break;
|
||||
|
@ -596,12 +596,12 @@ void AXUCode::RunCompressor(u16 threshold, u16 release_frames, u32 table_addr, u
|
|||
|
||||
// apply the selected ramp
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
u16* ramp = (u16*)HLEMemory_Get_Pointer(memory, table_addr + table_offset);
|
||||
u16* ramp = static_cast<u16*>(HLEMemory_Get_Pointer(memory, table_addr + table_offset));
|
||||
for (u32 i = 0; i < 32 * millis; ++i)
|
||||
{
|
||||
u16 coef = Common::swap16(*ramp++);
|
||||
m_samples_main_left[i] = (s64(m_samples_main_left[i]) * coef) >> 15;
|
||||
m_samples_main_right[i] = (s64(m_samples_main_right[i]) * coef) >> 15;
|
||||
m_samples_main_left[i] = (static_cast<s64>(m_samples_main_left[i]) * coef) >> 15;
|
||||
m_samples_main_right[i] = (static_cast<s64>(m_samples_main_right[i]) * coef) >> 15;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -634,14 +634,14 @@ void AXUCode::MixAUXBLR(u32 ul_addr, u32 dl_addr)
|
|||
{
|
||||
// Upload AUXB L/R
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, ul_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, ul_addr));
|
||||
for (auto& sample : m_samples_auxB_left)
|
||||
*ptr++ = Common::swap32(sample);
|
||||
for (auto& sample : m_samples_auxB_right)
|
||||
*ptr++ = Common::swap32(sample);
|
||||
|
||||
// Mix AUXB L/R to MAIN L/R, and replace AUXB L/R
|
||||
ptr = (int*)HLEMemory_Get_Pointer(memory, dl_addr);
|
||||
ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, dl_addr));
|
||||
for (u32 i = 0; i < 5 * 32; ++i)
|
||||
{
|
||||
int samp = Common::swap32(*ptr++);
|
||||
|
@ -659,7 +659,7 @@ void AXUCode::MixAUXBLR(u32 ul_addr, u32 dl_addr)
|
|||
void AXUCode::SetOppositeLR(u32 src_addr)
|
||||
{
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, src_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, src_addr));
|
||||
for (u32 i = 0; i < 5 * 32; ++i)
|
||||
{
|
||||
int inp = Common::swap32(*ptr++);
|
||||
|
@ -681,7 +681,7 @@ void AXUCode::SendAUXAndMix(u32 auxa_lrs_up, u32 auxb_s_up, u32 main_l_dl, u32 m
|
|||
|
||||
// Upload AUXA LRS
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, auxa_lrs_up);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, auxa_lrs_up));
|
||||
for (const auto& up_buffer : up_buffers)
|
||||
{
|
||||
for (u32 j = 0; j < 32 * 5; ++j)
|
||||
|
@ -689,7 +689,7 @@ void AXUCode::SendAUXAndMix(u32 auxa_lrs_up, u32 auxb_s_up, u32 main_l_dl, u32 m
|
|||
}
|
||||
|
||||
// Upload AUXB S
|
||||
ptr = (int*)HLEMemory_Get_Pointer(memory, auxb_s_up);
|
||||
ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, auxb_s_up));
|
||||
for (auto& sample : m_samples_auxB_surround)
|
||||
*ptr++ = Common::swap32(sample);
|
||||
|
||||
|
@ -710,9 +710,9 @@ void AXUCode::SendAUXAndMix(u32 auxa_lrs_up, u32 auxb_s_up, u32 main_l_dl, u32 m
|
|||
// Download and mix
|
||||
for (size_t i = 0; i < dl_buffers.size(); ++i)
|
||||
{
|
||||
const int* dl_src = (int*)HLEMemory_Get_Pointer(memory, dl_addrs[i]);
|
||||
const int* dl_src = static_cast<int*>(HLEMemory_Get_Pointer(memory, dl_addrs[i]));
|
||||
for (size_t j = 0; j < 32 * 5; ++j)
|
||||
dl_buffers[i][j] += (int)Common::swap32(*dl_src++);
|
||||
dl_buffers[i][j] += static_cast<int>(Common::swap32(*dl_src++));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,8 @@ protected:
|
|||
for (size_t i = 0; i < BufCount; ++i)
|
||||
{
|
||||
const BufferDesc& buf = buffers[i];
|
||||
s32 value = s32((u32(init_array[3 * i]) << 16) | init_array[3 * i + 1]);
|
||||
s32 value =
|
||||
static_cast<s32>((static_cast<u32>(init_array[3 * i]) << 16) | init_array[3 * i + 1]);
|
||||
s16 delta = init_array[3 * i + 2];
|
||||
if (value == 0)
|
||||
{
|
||||
|
|
|
@ -368,7 +368,7 @@ void MixAdd(int* out, const s16* input, u32 count, VolumeData* vd, s16* dpop, bo
|
|||
s64 sample = input[i];
|
||||
sample *= volume;
|
||||
sample >>= 15;
|
||||
s16 sample16 = ClampS16((s32)sample);
|
||||
s16 sample16 = ClampS16(static_cast<s32>(sample));
|
||||
|
||||
out[i] += sample16;
|
||||
volume += volume_delta;
|
||||
|
@ -381,7 +381,8 @@ void MixAdd(int* out, const s16* input, u32 count, VolumeData* vd, s16* dpop, bo
|
|||
static void LowPassFilter(s16* samples, u32 count, PBLowPassFilter& f)
|
||||
{
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
f.yn1 = samples[i] = ClampS16((f.a0 * (s32)samples[i] + f.b0 * (s32)f.yn1) >> 15);
|
||||
f.yn1 = samples[i] =
|
||||
ClampS16((f.a0 * static_cast<s32>(samples[i]) + f.b0 * static_cast<s32>(f.yn1)) >> 15);
|
||||
}
|
||||
|
||||
#ifdef AX_WII
|
||||
|
@ -436,7 +437,7 @@ void ProcessVoice(HLEAccelerator* accelerator, PB_TYPE& pb, const AXBuffers& buf
|
|||
// unsigned on Wii
|
||||
const s32 volume = (u16)pb.vol_env.cur_volume;
|
||||
#endif
|
||||
const s32 sample = ((s32)samples[i] * volume) >> 15;
|
||||
const s32 sample = (static_cast<s32>(samples[i]) * volume) >> 15;
|
||||
samples[i] = ClampS16(sample);
|
||||
pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta;
|
||||
}
|
||||
|
|
|
@ -106,12 +106,12 @@ void AXWiiUCode::HandleCommandList()
|
|||
{
|
||||
volume = m_cmdlist[curr_idx++];
|
||||
u32 addresses[6] = {
|
||||
(u32)(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
(u32)(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
(u32)(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
(u32)(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
(u32)(m_cmdlist[curr_idx + 8] << 16) | m_cmdlist[curr_idx + 9],
|
||||
(u32)(m_cmdlist[curr_idx + 10] << 16) | m_cmdlist[curr_idx + 11],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 8] << 16) | m_cmdlist[curr_idx + 9],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 10] << 16) | m_cmdlist[curr_idx + 11],
|
||||
};
|
||||
curr_idx += 12;
|
||||
UploadAUXMixLRSC(cmd == CMD_UPL_AUXB_MIX_LRSC_OLD, addresses, volume);
|
||||
|
@ -140,10 +140,10 @@ void AXWiiUCode::HandleCommandList()
|
|||
case CMD_WM_OUTPUT_OLD:
|
||||
{
|
||||
u32 addresses[4] = {
|
||||
(u32)(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
(u32)(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
(u32)(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
(u32)(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
};
|
||||
curr_idx += 8;
|
||||
OutputWMSamples(addresses);
|
||||
|
@ -203,12 +203,12 @@ void AXWiiUCode::HandleCommandList()
|
|||
{
|
||||
volume = m_cmdlist[curr_idx++];
|
||||
u32 addresses[6] = {
|
||||
(u32)(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
(u32)(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
(u32)(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
(u32)(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
(u32)(m_cmdlist[curr_idx + 8] << 16) | m_cmdlist[curr_idx + 9],
|
||||
(u32)(m_cmdlist[curr_idx + 10] << 16) | m_cmdlist[curr_idx + 11],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 8] << 16) | m_cmdlist[curr_idx + 9],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 10] << 16) | m_cmdlist[curr_idx + 11],
|
||||
};
|
||||
curr_idx += 12;
|
||||
UploadAUXMixLRSC(cmd == CMD_UPL_AUXB_MIX_LRSC, addresses, volume);
|
||||
|
@ -238,10 +238,10 @@ void AXWiiUCode::HandleCommandList()
|
|||
case CMD_WM_OUTPUT:
|
||||
{
|
||||
u32 addresses[4] = {
|
||||
(u32)(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
(u32)(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
(u32)(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
(u32)(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 0] << 16) | m_cmdlist[curr_idx + 1],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 2] << 16) | m_cmdlist[curr_idx + 3],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 4] << 16) | m_cmdlist[curr_idx + 5],
|
||||
static_cast<u32>(m_cmdlist[curr_idx + 6] << 16) | m_cmdlist[curr_idx + 7],
|
||||
};
|
||||
curr_idx += 8;
|
||||
OutputWMSamples(addresses);
|
||||
|
@ -274,10 +274,10 @@ void AXWiiUCode::SetupProcessing(u32 init_addr)
|
|||
void AXWiiUCode::AddToLR(u32 val_addr, bool neg)
|
||||
{
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, val_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, val_addr));
|
||||
for (int i = 0; i < 32 * 3; ++i)
|
||||
{
|
||||
int val = (int)Common::swap32(*ptr++);
|
||||
int val = static_cast<int>(Common::swap32(*ptr++));
|
||||
if (neg)
|
||||
val = -val;
|
||||
|
||||
|
@ -289,15 +289,15 @@ void AXWiiUCode::AddToLR(u32 val_addr, bool neg)
|
|||
void AXWiiUCode::AddSubToLR(u32 val_addr)
|
||||
{
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, val_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, val_addr));
|
||||
for (int i = 0; i < 32 * 3; ++i)
|
||||
{
|
||||
int val = (int)Common::swap32(*ptr++);
|
||||
int val = static_cast<int>(Common::swap32(*ptr++));
|
||||
m_samples_main_left[i] += val;
|
||||
}
|
||||
for (int i = 0; i < 32 * 3; ++i)
|
||||
{
|
||||
int val = (int)Common::swap32(*ptr++);
|
||||
int val = static_cast<int>(Common::swap32(*ptr++));
|
||||
m_samples_main_right[i] -= val;
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ AXMixControl AXWiiUCode::ConvertMixerControl(u32 mixer_control)
|
|||
if (mixer_control & 0x40000000)
|
||||
ret |= MIX_AUXC_S | MIX_AUXC_S_RAMP;
|
||||
|
||||
return (AXMixControl)ret;
|
||||
return static_cast<AXMixControl>(ret);
|
||||
}
|
||||
|
||||
void AXWiiUCode::GenerateVolumeRamp(u16* output, u16 vol1, u16 vol2, size_t nvals)
|
||||
|
@ -355,8 +355,8 @@ void AXWiiUCode::GenerateVolumeRamp(u16* output, u16 vol1, u16 vol2, size_t nval
|
|||
float curr = vol1;
|
||||
for (size_t i = 0; i < nvals; ++i)
|
||||
{
|
||||
curr += (vol2 - vol1) / (float)nvals;
|
||||
output[i] = (u16)curr;
|
||||
curr += (vol2 - vol1) / static_cast<float>(nvals);
|
||||
output[i] = static_cast<u16>(curr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,7 +526,7 @@ void AXWiiUCode::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 vo
|
|||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
if (write_addr)
|
||||
{
|
||||
int* ptr = (int*)HLEMemory_Get_Pointer(memory, write_addr);
|
||||
int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, write_addr));
|
||||
for (const auto& buffer : buffers)
|
||||
{
|
||||
for (u32 j = 0; j < 3 * 32; ++j)
|
||||
|
@ -535,14 +535,14 @@ void AXWiiUCode::MixAUXSamples(int aux_id, u32 write_addr, u32 read_addr, u16 vo
|
|||
}
|
||||
|
||||
// Then read the buffers from the CPU and add to our main buffers.
|
||||
const int* ptr = (int*)HLEMemory_Get_Pointer(memory, read_addr);
|
||||
const int* ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, read_addr));
|
||||
for (auto& main_buffer : main_buffers)
|
||||
{
|
||||
for (u32 j = 0; j < 3 * 32; ++j)
|
||||
{
|
||||
s64 sample = (s64)(s32)Common::swap32(*ptr++);
|
||||
s64 sample = (s64) static_cast<s32>(Common::swap32(*ptr++));
|
||||
sample *= volume_ramp[j];
|
||||
main_buffer[j] += (s32)(sample >> 15);
|
||||
main_buffer[j] += static_cast<s32>(sample >> 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ void AXWiiUCode::UploadAUXMixLRSC(int aux_id, u32* addresses, u16 volume)
|
|||
int* auxc_buffer = aux_id ? m_samples_auxC_surround : m_samples_auxC_right;
|
||||
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
int* upload_ptr = (int*)HLEMemory_Get_Pointer(memory, addresses[0]);
|
||||
int* upload_ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, addresses[0]));
|
||||
for (u32 i = 0; i < 96; ++i)
|
||||
*upload_ptr++ = Common::swap32(aux_left[i]);
|
||||
for (u32 i = 0; i < 96; ++i)
|
||||
|
@ -563,7 +563,7 @@ void AXWiiUCode::UploadAUXMixLRSC(int aux_id, u32* addresses, u16 volume)
|
|||
for (u32 i = 0; i < 96; ++i)
|
||||
*upload_ptr++ = Common::swap32(aux_surround[i]);
|
||||
|
||||
upload_ptr = (int*)HLEMemory_Get_Pointer(memory, addresses[1]);
|
||||
upload_ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, addresses[1]));
|
||||
for (u32 i = 0; i < 96; ++i)
|
||||
*upload_ptr++ = Common::swap32(auxc_buffer[i]);
|
||||
|
||||
|
@ -575,7 +575,7 @@ void AXWiiUCode::UploadAUXMixLRSC(int aux_id, u32* addresses, u16 volume)
|
|||
m_samples_auxC_left};
|
||||
for (u32 mix_i = 0; mix_i < 4; ++mix_i)
|
||||
{
|
||||
int* dl_ptr = (int*)HLEMemory_Get_Pointer(memory, addresses[2 + mix_i]);
|
||||
int* dl_ptr = static_cast<int*>(HLEMemory_Get_Pointer(memory, addresses[2 + mix_i]));
|
||||
for (u32 i = 0; i < 96; ++i)
|
||||
aux_left[i] = Common::swap32(dl_ptr[i]);
|
||||
|
||||
|
@ -583,7 +583,7 @@ void AXWiiUCode::UploadAUXMixLRSC(int aux_id, u32* addresses, u16 volume)
|
|||
{
|
||||
s64 sample = (s64)(s32)aux_left[i];
|
||||
sample *= volume_ramp[i];
|
||||
mix_dest[mix_i][i] += (s32)(sample >> 15);
|
||||
mix_dest[mix_i][i] += static_cast<s32>(sample >> 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -644,11 +644,11 @@ void AXWiiUCode::OutputWMSamples(u32* addresses)
|
|||
for (u32 i = 0; i < 4; ++i)
|
||||
{
|
||||
int* in = buffers[i];
|
||||
u16* out = (u16*)HLEMemory_Get_Pointer(memory, addresses[i]);
|
||||
u16* out = static_cast<u16*>(HLEMemory_Get_Pointer(memory, addresses[i]));
|
||||
for (u32 j = 0; j < 3 * 6; ++j)
|
||||
{
|
||||
s16 sample = ClampS16(in[j]);
|
||||
out[j] = Common::swap16((u16)sample);
|
||||
out[j] = Common::swap16(static_cast<u16>(sample));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -470,7 +470,7 @@ void ZeldaUCode::RunPendingCommands()
|
|||
m_renderer.SetVPBBaseAddress(Read32());
|
||||
|
||||
auto& memory = m_dsphle->GetSystem().GetMemory();
|
||||
u16* data_ptr = (u16*)HLEMemory_Get_Pointer(memory, Read32());
|
||||
u16* data_ptr = static_cast<u16*>(HLEMemory_Get_Pointer(memory, Read32()));
|
||||
|
||||
std::array<s16, 0x100> resampling_coeffs;
|
||||
for (size_t i = 0; i < 0x100; ++i)
|
||||
|
@ -492,7 +492,7 @@ void ZeldaUCode::RunPendingCommands()
|
|||
m_renderer.SetSineTable(std::move(sine_table));
|
||||
}
|
||||
|
||||
u16* afc_coeffs_ptr = (u16*)HLEMemory_Get_Pointer(memory, Read32());
|
||||
u16* afc_coeffs_ptr = static_cast<u16*>(HLEMemory_Get_Pointer(memory, Read32()));
|
||||
std::array<s16, 0x20> afc_coeffs;
|
||||
for (size_t i = 0; i < 0x20; ++i)
|
||||
afc_coeffs[i] = Common::swap16(afc_coeffs_ptr[i]);
|
||||
|
@ -1084,7 +1084,7 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)
|
|||
};
|
||||
|
||||
auto& memory = m_system.GetMemory();
|
||||
u16* rpb_base_ptr = (u16*)HLEMemory_Get_Pointer(memory, m_reverb_pb_base_addr);
|
||||
u16* rpb_base_ptr = static_cast<u16*>(HLEMemory_Get_Pointer(memory, m_reverb_pb_base_addr));
|
||||
for (u16 rpb_idx = 0; rpb_idx < 4; ++rpb_idx)
|
||||
{
|
||||
ReverbPB rpb;
|
||||
|
@ -1098,7 +1098,7 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)
|
|||
u16 mram_buffer_idx = m_reverb_pb_frames_count[rpb_idx];
|
||||
|
||||
u32 mram_addr = rpb.GetCircularBufferBase() + mram_buffer_idx * 0x50 * sizeof(s16);
|
||||
s16* mram_ptr = (s16*)HLEMemory_Get_Pointer(memory, mram_addr);
|
||||
s16* mram_ptr = static_cast<s16*>(HLEMemory_Get_Pointer(memory, mram_addr));
|
||||
|
||||
if (!post_rendering)
|
||||
{
|
||||
|
@ -1120,7 +1120,7 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)
|
|||
{
|
||||
s32 sample = 0;
|
||||
for (u16 j = 0; j < 8; ++j)
|
||||
sample += (s32)buffer[i + j] * rpb.filter_coeffs[j];
|
||||
sample += static_cast<s32>(buffer[i + j]) * rpb.filter_coeffs[j];
|
||||
sample >>= 15;
|
||||
buffer[i] = std::clamp(sample, -0x8000, 0x7FFF);
|
||||
}
|
||||
|
@ -1305,10 +1305,10 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
|
|||
// Compute volume for each quadrant.
|
||||
u16 shift_factor = (m_flags & MAKE_DOLBY_LOUDER) ? 15 : 16;
|
||||
s16 quadrant_volumes[4] = {
|
||||
(s16)((left_volume * front_volume) >> shift_factor),
|
||||
(s16)((left_volume * back_volume) >> shift_factor),
|
||||
(s16)((right_volume * front_volume) >> shift_factor),
|
||||
(s16)((right_volume * back_volume) >> shift_factor),
|
||||
static_cast<s16>((left_volume * front_volume) >> shift_factor),
|
||||
static_cast<s16>((left_volume * back_volume) >> shift_factor),
|
||||
static_cast<s16>((right_volume * front_volume) >> shift_factor),
|
||||
static_cast<s16>((right_volume * back_volume) >> shift_factor),
|
||||
};
|
||||
|
||||
// Compute the volume delta for each sample to match the difference
|
||||
|
@ -1316,7 +1316,7 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
|
|||
s16 delta = vpb.dolby_volume_target - vpb.dolby_volume_current;
|
||||
s16 volume_deltas[4];
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
volume_deltas[i] = ((u16)quadrant_volumes[i] * delta) >> shift_factor;
|
||||
volume_deltas[i] = (static_cast<u16>(quadrant_volumes[i]) * delta) >> shift_factor;
|
||||
|
||||
// Apply master volume to each quadrant.
|
||||
for (s16& quadrant_volume : quadrant_volumes)
|
||||
|
@ -1349,7 +1349,8 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
|
|||
for (const auto& buffer : buffers)
|
||||
{
|
||||
AddBuffersWithVolumeRamp(buffer.buffer, input_samples, buffer.volume << 16,
|
||||
(buffer.volume_delta << 16) / (s32)buffer.buffer->size());
|
||||
(buffer.volume_delta << 16) /
|
||||
static_cast<s32>(buffer.buffer->size()));
|
||||
}
|
||||
|
||||
vpb.dolby_volume_current = vpb.dolby_volume_target;
|
||||
|
@ -1384,7 +1385,8 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
|
|||
else
|
||||
volume_delta = vpb.channels[i].target_volume - vpb.channels[i].current_volume;
|
||||
|
||||
s32 volume_step = (volume_delta << 16) / (s32)input_samples.size(); // In 1.31 format.
|
||||
s32 volume_step =
|
||||
(volume_delta << 16) / static_cast<s32>(input_samples.size()); // In 1.31 format.
|
||||
|
||||
// TODO: The last value of each channel structure is used to
|
||||
// determine whether a channel should be skipped or not. Not
|
||||
|
@ -1424,15 +1426,15 @@ void ZeldaAudioRenderer::FinalizeFrame()
|
|||
ApplyVolumeInPlace_4_12(&m_buf_front_right, m_output_volume);
|
||||
|
||||
auto& memory = m_system.GetMemory();
|
||||
u16* ram_left_buffer = (u16*)HLEMemory_Get_Pointer(memory, m_output_lbuf_addr);
|
||||
u16* ram_right_buffer = (u16*)HLEMemory_Get_Pointer(memory, m_output_rbuf_addr);
|
||||
u16* ram_left_buffer = static_cast<u16*>(HLEMemory_Get_Pointer(memory, m_output_lbuf_addr));
|
||||
u16* ram_right_buffer = static_cast<u16*>(HLEMemory_Get_Pointer(memory, m_output_rbuf_addr));
|
||||
for (size_t i = 0; i < m_buf_front_left.size(); ++i)
|
||||
{
|
||||
ram_left_buffer[i] = Common::swap16(m_buf_front_left[i]);
|
||||
ram_right_buffer[i] = Common::swap16(m_buf_front_right[i]);
|
||||
}
|
||||
m_output_lbuf_addr += sizeof(u16) * (u32)m_buf_front_left.size();
|
||||
m_output_rbuf_addr += sizeof(u16) * (u32)m_buf_front_right.size();
|
||||
m_output_lbuf_addr += sizeof(u16) * static_cast<u32>(m_buf_front_left.size());
|
||||
m_output_rbuf_addr += sizeof(u16) * static_cast<u32>(m_buf_front_right.size());
|
||||
|
||||
// TODO: Some more Dolby mixing.
|
||||
|
||||
|
@ -1445,7 +1447,7 @@ void ZeldaAudioRenderer::FetchVPB(u16 voice_id, VPB* vpb)
|
|||
{
|
||||
auto& memory = m_system.GetMemory();
|
||||
u16* vpb_words = (u16*)vpb;
|
||||
u16* ram_vpbs = (u16*)HLEMemory_Get_Pointer(memory, m_vpb_base_addr);
|
||||
u16* ram_vpbs = static_cast<u16*>(HLEMemory_Get_Pointer(memory, m_vpb_base_addr));
|
||||
|
||||
// A few versions of the UCode have VPB of size 0x80 (vs. the standard
|
||||
// 0xC0). The whole 0x40-0x80 part is gone. Handle that by moving things
|
||||
|
@ -1464,7 +1466,7 @@ void ZeldaAudioRenderer::StoreVPB(u16 voice_id, VPB* vpb)
|
|||
{
|
||||
auto& memory = m_system.GetMemory();
|
||||
u16* vpb_words = (u16*)vpb;
|
||||
u16* ram_vpbs = (u16*)HLEMemory_Get_Pointer(memory, m_vpb_base_addr);
|
||||
u16* ram_vpbs = static_cast<u16*>(HLEMemory_Get_Pointer(memory, m_vpb_base_addr));
|
||||
|
||||
size_t vpb_size = (m_flags & TINY_VPB) ? 0x80 : 0xC0;
|
||||
size_t base_idx = voice_id * vpb_size;
|
||||
|
@ -1631,10 +1633,10 @@ void ZeldaAudioRenderer::Resample(VPB* vpb, const s16* src, MixingBuffer* dst)
|
|||
|
||||
s64 dst_sample_unclamped = 0;
|
||||
for (size_t i = 0; i < 4; ++i)
|
||||
dst_sample_unclamped += (s64)2 * coeffs[i] * input[i];
|
||||
dst_sample_unclamped += static_cast<s64>(2) * coeffs[i] * input[i];
|
||||
dst_sample_unclamped >>= 16;
|
||||
|
||||
dst_sample = (s16)std::clamp<s64>(dst_sample_unclamped, -0x8000, 0x7FFF);
|
||||
dst_sample = static_cast<s16>(std::clamp<s64>(dst_sample_unclamped, -0x8000, 0x7FFF));
|
||||
|
||||
pos += ratio;
|
||||
}
|
||||
|
@ -1688,8 +1690,9 @@ void ZeldaAudioRenderer::DownloadPCMSamplesFromARAM(s16* dst, VPB* vpb, u16 requ
|
|||
vpb->SetCurrentARAMAddr(vpb->GetBaseAddress() + vpb->GetCurrentPosition() * sizeof(T));
|
||||
}
|
||||
|
||||
T* src_ptr = (T*)GetARAMPtr(vpb->GetCurrentARAMAddr());
|
||||
u16 samples_to_download = std::min(vpb->GetRemainingLength(), (u32)requested_samples_count);
|
||||
T* src_ptr = static_cast<T*>(GetARAMPtr(vpb->GetCurrentARAMAddr()));
|
||||
u16 samples_to_download =
|
||||
std::min(vpb->GetRemainingLength(), static_cast<u32>(requested_samples_count));
|
||||
|
||||
for (u16 i = 0; i < samples_to_download; ++i)
|
||||
*dst++ = Common::FromBigEndian<T>(*src_ptr++) << (16 - 8 * sizeof(T));
|
||||
|
@ -1823,8 +1826,8 @@ void ZeldaAudioRenderer::DownloadAFCSamplesFromARAM(s16* dst, VPB* vpb, u16 requ
|
|||
void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
|
||||
{
|
||||
u32 addr = vpb->GetCurrentARAMAddr();
|
||||
u8* src = (u8*)GetARAMPtr(addr);
|
||||
vpb->SetCurrentARAMAddr(addr + (u32)block_count * vpb->samples_source_type);
|
||||
u8* src = static_cast<u8*>(GetARAMPtr(addr));
|
||||
vpb->SetCurrentARAMAddr(addr + static_cast<u32>(block_count) * vpb->samples_source_type);
|
||||
|
||||
for (size_t b = 0; b < block_count; ++b)
|
||||
{
|
||||
|
@ -1843,7 +1846,7 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
|
|||
src++;
|
||||
}
|
||||
for (auto& nibble : nibbles)
|
||||
nibble = s16(nibble << 12) >> 1;
|
||||
nibble = static_cast<s16>(nibble << 12) >> 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1857,7 +1860,7 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
|
|||
src++;
|
||||
}
|
||||
for (auto& nibble : nibbles)
|
||||
nibble = s16(nibble << 14) >> 1;
|
||||
nibble = static_cast<s16>(nibble << 14) >> 1;
|
||||
}
|
||||
|
||||
s32 yn1 = *vpb->AFCYN1(), yn2 = *vpb->AFCYN2();
|
||||
|
@ -1866,7 +1869,7 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
|
|||
s32 sample = delta * nibble + yn1 * m_afc_coeffs[idx * 2] + yn2 * m_afc_coeffs[idx * 2 + 1];
|
||||
sample >>= 11;
|
||||
sample = std::clamp(sample, -0x8000, 0x7fff);
|
||||
*dst++ = (s16)sample;
|
||||
*dst++ = static_cast<s16>(sample);
|
||||
yn2 = yn1;
|
||||
yn1 = sample;
|
||||
}
|
||||
|
@ -1880,7 +1883,7 @@ void ZeldaAudioRenderer::DownloadRawSamplesFromMRAM(s16* dst, VPB* vpb, u16 requ
|
|||
{
|
||||
auto& memory = m_system.GetMemory();
|
||||
u32 addr = vpb->GetBaseAddress() + vpb->current_position_h * sizeof(u16);
|
||||
s16* src_ptr = (s16*)HLEMemory_Get_Pointer(memory, addr);
|
||||
s16* src_ptr = static_cast<s16*>(HLEMemory_Get_Pointer(memory, addr));
|
||||
|
||||
if (requested_samples_count > vpb->GetRemainingLength())
|
||||
{
|
||||
|
@ -1909,7 +1912,7 @@ void ZeldaAudioRenderer::DownloadRawSamplesFromMRAM(s16* dst, VPB* vpb, u16 requ
|
|||
for (u16 i = 0; i < vpb->samples_before_loop; ++i)
|
||||
*dst++ = Common::swap16(*src_ptr++);
|
||||
vpb->SetBaseAddress(vpb->GetLoopAddress());
|
||||
src_ptr = (s16*)HLEMemory_Get_Pointer(memory, vpb->GetLoopAddress());
|
||||
src_ptr = static_cast<s16*>(HLEMemory_Get_Pointer(memory, vpb->GetLoopAddress()));
|
||||
for (u16 i = vpb->samples_before_loop; i < requested_samples_count; ++i)
|
||||
*dst++ = Common::swap16(*src_ptr++);
|
||||
vpb->current_position_h = requested_samples_count - vpb->samples_before_loop;
|
||||
|
|
|
@ -60,10 +60,10 @@ private:
|
|||
{
|
||||
for (size_t i = 0; i < N; ++i)
|
||||
{
|
||||
s32 tmp = (u32)(*buf)[i] * (u32)vol;
|
||||
s32 tmp = static_cast<u32>((*buf)[i]) * static_cast<u32>(vol);
|
||||
tmp >>= 16 - B;
|
||||
|
||||
(*buf)[i] = (s16)std::clamp(tmp, -0x8000, 0x7FFF);
|
||||
(*buf)[i] = static_cast<s16>(std::clamp(tmp, -0x8000, 0x7FFF));
|
||||
}
|
||||
}
|
||||
template <size_t N>
|
||||
|
@ -104,7 +104,7 @@ private:
|
|||
{
|
||||
while (count--)
|
||||
{
|
||||
s32 vol_src = ((s32)*src++ * (s32)vol) >> 15;
|
||||
s32 vol_src = (static_cast<s32>(*src++) * static_cast<s32>(vol)) >> 15;
|
||||
*dst++ += std::clamp(vol_src, -0x8000, 0x7FFF);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ int Line2Addr(int line) // -1 for not found
|
|||
|
||||
const char* GetLineText(int line)
|
||||
{
|
||||
if (line >= 0 && line < (int)lines.size())
|
||||
if (line >= 0 && line < static_cast<int>(lines.size()))
|
||||
{
|
||||
return lines[line].c_str();
|
||||
}
|
||||
|
|
|
@ -235,9 +235,10 @@ void DVDInterface::DTKStreamingCallback(DIInterruptType interrupt_type,
|
|||
}
|
||||
|
||||
// Read the next chunk of audio data asynchronously.
|
||||
s64 ticks_to_dtk = m_system.GetSystemTimers().GetTicksPerSecond() * s64(m_pending_blocks) *
|
||||
StreamADPCM::SAMPLES_PER_BLOCK * sample_rate_divisor /
|
||||
Mixer::FIXED_SAMPLE_RATE_DIVIDEND;
|
||||
s64 ticks_to_dtk = m_system.GetSystemTimers().GetTicksPerSecond() *
|
||||
static_cast<s64>(m_pending_blocks) *
|
||||
StreamADPCM::SAMPLES_PER_BLOCK *
|
||||
sample_rate_divisor / Mixer::FIXED_SAMPLE_RATE_DIVIDEND;
|
||||
ticks_to_dtk -= cycles_late;
|
||||
if (read_length > 0)
|
||||
{
|
||||
|
|
|
@ -65,7 +65,7 @@ void SetIPIdentification(u8* ptr, std::size_t size, u16 value)
|
|||
|
||||
u8* const ip_checksum_ptr = ip_ptr + offsetof(Common::IPv4Header, header_checksum);
|
||||
auto checksum_bitcast_ptr = Common::BitCastPtr<u16>(ip_checksum_ptr);
|
||||
checksum_bitcast_ptr = u16(0);
|
||||
checksum_bitcast_ptr = static_cast<u16>(0);
|
||||
checksum_bitcast_ptr = htons(Common::ComputeNetworkChecksum(ip_ptr, ip_header_size));
|
||||
}
|
||||
} // namespace
|
||||
|
|
|
@ -205,7 +205,7 @@ bool TAPServerConnection::SendAndRemoveAllHDLCFrames(std::string* send_buf)
|
|||
}
|
||||
const int written_bytes =
|
||||
send(m_fd, send_buf->data() + start_offset, static_cast<int>(size), SEND_FLAGS);
|
||||
if (u32(written_bytes) != size)
|
||||
if (static_cast<u32>(written_bytes) != size)
|
||||
{
|
||||
ERROR_LOG_FMT(SP1,
|
||||
"SendAndRemoveAllHDLCFrames(): expected to write {} bytes, instead wrote {}",
|
||||
|
@ -232,7 +232,7 @@ bool TAPServerConnection::SendFrame(const u8* frame, u32 size)
|
|||
}
|
||||
const int written_bytes =
|
||||
send(m_fd, reinterpret_cast<const char*>(frame), static_cast<ws_ssize_t>(size), SEND_FLAGS);
|
||||
if (u32(written_bytes) != size)
|
||||
if (static_cast<u32>(written_bytes) != size)
|
||||
{
|
||||
ERROR_LOG_FMT(SP1, "SendFrame(): expected to write {} bytes, instead wrote {}", size,
|
||||
written_bytes);
|
||||
|
|
|
@ -42,7 +42,7 @@ bool CEXIETHERNET::XLinkNetworkInterface::Activate()
|
|||
std::string cmd =
|
||||
"connect;" + m_client_identifier + ";dolphin;000000000000000000000000000000000000000000";
|
||||
|
||||
const auto size = u32(cmd.length());
|
||||
const auto size = static_cast<u32>(cmd.length());
|
||||
memmove(buffer, cmd.c_str(), size);
|
||||
|
||||
DEBUG_LOG_FMT(SP1, "SendCommandPayload {:x}\n{}", size, ArrayToString(buffer, size, 0x10));
|
||||
|
@ -67,7 +67,7 @@ void CEXIETHERNET::XLinkNetworkInterface::Deactivate()
|
|||
// disconnect;optional_locally_unique_name;optional_padding
|
||||
std::string cmd =
|
||||
"disconnect;" + m_client_identifier + ";0000000000000000000000000000000000000000000";
|
||||
const auto size = u32(cmd.length());
|
||||
const auto size = static_cast<u32>(cmd.length());
|
||||
u8 buffer[255] = {};
|
||||
memmove(buffer, cmd.c_str(), size);
|
||||
|
||||
|
@ -188,7 +188,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
|
|||
// Only uncomment for debugging, the performance hit is too big otherwise
|
||||
// DEBUG_LOG_FMT(SP1, "Read data: {}", ArrayToString(self->m_eth_ref->mRecvBuffer.get(),
|
||||
// u32(bytes_read - 4), 0x10));
|
||||
self->m_eth_ref->mRecvBufferLength = u32(bytes_read - 4);
|
||||
self->m_eth_ref->mRecvBufferLength = static_cast<u32>(bytes_read - 4);
|
||||
self->m_eth_ref->RecvHandlePacket();
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
|
|||
if (self->m_chat_osd_enabled)
|
||||
{
|
||||
constexpr std::string_view cmd = "setting;chat;true;";
|
||||
const auto size = u32(cmd.length());
|
||||
const auto size = static_cast<u32>(cmd.length());
|
||||
u8 buffer[255] = {};
|
||||
memmove(buffer, cmd.data(), size);
|
||||
|
||||
|
|
|
@ -193,9 +193,9 @@ void ExpansionInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||
void ExpansionInterfaceManager::ChangeDeviceCallback(Core::System& system, u64 userdata,
|
||||
s64 cycles_late)
|
||||
{
|
||||
u8 channel = (u8)(userdata >> 32);
|
||||
u8 type = (u8)(userdata >> 16);
|
||||
u8 num = (u8)userdata;
|
||||
u8 channel = static_cast<u8>(userdata >> 32);
|
||||
u8 type = static_cast<u8>(userdata >> 16);
|
||||
u8 num = static_cast<u8>(userdata);
|
||||
|
||||
system.GetExpansionInterface().m_channels.at(channel)->AddDevice(static_cast<EXIDeviceType>(type),
|
||||
num);
|
||||
|
@ -213,11 +213,13 @@ void ExpansionInterfaceManager::ChangeDevice(u8 channel, u8 device_num, EXIDevic
|
|||
// Let the hardware see no device for 1 second
|
||||
auto& core_timing = m_system.GetCoreTiming();
|
||||
core_timing.ScheduleEvent(0, m_event_type_change_device,
|
||||
((u64)channel << 32) | ((u64)EXIDeviceType::None << 16) | device_num,
|
||||
(static_cast<u64>(channel) << 32) |
|
||||
(static_cast<u64>(EXIDeviceType::None) << 16) | device_num,
|
||||
from_thread);
|
||||
core_timing.ScheduleEvent(
|
||||
m_system.GetSystemTimers().GetTicksPerSecond(), m_event_type_change_device,
|
||||
((u64)channel << 32) | ((u64)device_type << 16) | device_num, from_thread);
|
||||
(static_cast<u64>(channel) << 32) | (static_cast<u64>(device_type) << 16) | device_num,
|
||||
from_thread);
|
||||
}
|
||||
|
||||
CEXIChannel* ExpansionInterfaceManager::GetChannel(u32 index)
|
||||
|
|
|
@ -292,7 +292,7 @@ private:
|
|||
|
||||
inline u16 page_ptr(int const index) const
|
||||
{
|
||||
return ((u16)mBbaMem[index + 1] << 8) | mBbaMem[index];
|
||||
return (static_cast<u16>(mBbaMem[index + 1]) << 8) | mBbaMem[index];
|
||||
}
|
||||
|
||||
bool IsMXCommand(u32 const data);
|
||||
|
|
|
@ -84,7 +84,7 @@ GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index)
|
|||
|
||||
std::string GCKeyboard::GetName() const
|
||||
{
|
||||
return std::string("GCKeyboard") + char('1' + m_index);
|
||||
return std::string("GCKeyboard") + static_cast<char>('1' + m_index);
|
||||
}
|
||||
|
||||
InputConfig* GCKeyboard::GetConfig() const
|
||||
|
|
|
@ -435,7 +435,7 @@ u16 GCMemcard::DEntry_FirstBlock(u8 index) const
|
|||
return 0xFFFF;
|
||||
|
||||
u16 block = GetActiveDirectory().m_dir_entries[index].m_first_block;
|
||||
if (block > (u16)m_size_blocks)
|
||||
if (block > static_cast<u16>(m_size_blocks))
|
||||
return 0xFFFF;
|
||||
return block;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ u16 GCMemcard::DEntry_BlockCount(u8 index) const
|
|||
return 0xFFFF;
|
||||
|
||||
u16 blocks = GetActiveDirectory().m_dir_entries[index].m_block_count;
|
||||
if (blocks > (u16)m_size_blocks)
|
||||
if (blocks > static_cast<u16>(m_size_blocks))
|
||||
return 0xFFFF;
|
||||
return blocks;
|
||||
}
|
||||
|
@ -1043,7 +1043,7 @@ bool GCMemcard::Format(const CardFlashId& flash_id, u16 size_mbits, bool shift_j
|
|||
m_bat_blocks[0] = m_bat_blocks[1] = BlockAlloc(size_mbits);
|
||||
|
||||
m_size_mb = size_mbits;
|
||||
m_size_blocks = (u32)m_size_mb * MBIT_TO_BLOCKS;
|
||||
m_size_blocks = static_cast<u32>(m_size_mb) * MBIT_TO_BLOCKS;
|
||||
m_data_blocks.clear();
|
||||
m_data_blocks.resize(m_size_blocks - MC_FST_BLOCKS);
|
||||
|
||||
|
@ -1083,10 +1083,14 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry&
|
|||
const auto [serial1, serial2] = cardheader.CalculateSerial();
|
||||
|
||||
// set new serial numbers
|
||||
*(u16*)&FileBuffer[1].m_block[0x0066] = Common::swap16(u16(Common::swap32(serial1) >> 16));
|
||||
*(u16*)&FileBuffer[3].m_block[0x1580] = Common::swap16(u16(Common::swap32(serial2) >> 16));
|
||||
*(u16*)&FileBuffer[1].m_block[0x0060] = Common::swap16(u16(Common::swap32(serial1) & 0xFFFF));
|
||||
*(u16*)&FileBuffer[1].m_block[0x0200] = Common::swap16(u16(Common::swap32(serial2) & 0xFFFF));
|
||||
*(u16*)&FileBuffer[1].m_block[0x0066] =
|
||||
Common::swap16(static_cast<u16>(Common::swap32(serial1) >> 16));
|
||||
*(u16*)&FileBuffer[3].m_block[0x1580] =
|
||||
Common::swap16(static_cast<u16>(Common::swap32(serial2) >> 16));
|
||||
*(u16*)&FileBuffer[1].m_block[0x0060] =
|
||||
Common::swap16(static_cast<u16>(Common::swap32(serial1) & 0xFFFF));
|
||||
*(u16*)&FileBuffer[1].m_block[0x0200] =
|
||||
Common::swap16(static_cast<u16>(Common::swap32(serial2) & 0xFFFF));
|
||||
|
||||
// calc 16-bit checksum
|
||||
for (i = 0x02; i < 0x8000; i++)
|
||||
|
@ -1104,7 +1108,7 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry&
|
|||
}
|
||||
|
||||
// set new checksum
|
||||
*(u16*)&FileBuffer[0].m_block[0x00] = Common::swap16(u16(~chksum));
|
||||
*(u16*)&FileBuffer[0].m_block[0x00] = Common::swap16(static_cast<u16>(~chksum));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1210,7 +1214,7 @@ void InitializeHeaderData(HeaderData* data, const CardFlashId& flash_id, u16 siz
|
|||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
||||
data->m_serial[i] = (u8)(flash_id[i] + (u32)rand);
|
||||
data->m_serial[i] = static_cast<u8>(flash_id[i] + static_cast<u32>(rand));
|
||||
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
||||
rand &= (u64)0x0000000000007fffULL;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ bool GCMemcardDirectory::LoadGCI(Memcard::GCIFile gci)
|
|||
}
|
||||
|
||||
// actually load save file into memory card
|
||||
int idx = (int)m_saves.size();
|
||||
int idx = static_cast<int>(m_saves.size());
|
||||
m_dir1.Replace(gci.m_gci_header, idx);
|
||||
m_saves.push_back(std::move(gci));
|
||||
SetUsedBlocks(idx);
|
||||
|
|
|
@ -43,7 +43,7 @@ MemoryCard::MemoryCard(const std::string& filename, ExpansionInterface::Slot car
|
|||
if (file)
|
||||
{
|
||||
// Measure size of the existing memcard file.
|
||||
m_memory_card_size = (u32)file.GetSize();
|
||||
m_memory_card_size = static_cast<u32>(file.GetSize());
|
||||
m_nintendo_card_id = m_memory_card_size / SIZE_TO_Mb;
|
||||
m_memcard_data = std::make_unique<u8[]>(m_memory_card_size);
|
||||
memset(&m_memcard_data[0], 0xFF, m_memory_card_size);
|
||||
|
|
|
@ -91,7 +91,7 @@ GCPad::GCPad(const unsigned int index) : m_index(index)
|
|||
|
||||
std::string GCPad::GetName() const
|
||||
{
|
||||
return std::string("GCPad") + char('1' + m_index);
|
||||
return std::string("GCPad") + static_cast<char>('1' + m_index);
|
||||
}
|
||||
|
||||
InputConfig* GCPad::GetConfig() const
|
||||
|
|
|
@ -230,7 +230,7 @@ ReadHandlingMethod<T>* ReadToSmaller(Mapping* mmio, u32 high_part_addr, u32 low_
|
|||
|
||||
// TODO(delroth): optimize
|
||||
return ComplexRead<T>([=](Core::System& system, u32 addr) {
|
||||
return ((T)high_part->Read(system, high_part_addr) << (8 * sizeof(ST))) |
|
||||
return (static_cast<T>(high_part->Read(system, high_part_addr)) << (8 * sizeof(ST))) |
|
||||
low_part->Read(system, low_part_addr);
|
||||
});
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ WriteHandlingMethod<T>* WriteToSmaller(Mapping* mmio, u32 high_part_addr, u32 lo
|
|||
// TODO(delroth): optimize
|
||||
return ComplexWrite<T>([=](Core::System& system, u32 addr, T val) {
|
||||
high_part->Write(system, high_part_addr, val >> (8 * sizeof(ST)));
|
||||
low_part->Write(system, low_part_addr, (ST)val);
|
||||
low_part->Write(system, low_part_addr, static_cast<ST>(val));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ void MemoryManager::Init()
|
|||
if (!region.active)
|
||||
continue;
|
||||
|
||||
*region.out_pointer = (u8*)m_arena.CreateView(region.shm_position, region.size);
|
||||
*region.out_pointer = static_cast<u8*>(m_arena.CreateView(region.shm_position, region.size));
|
||||
|
||||
if (!*region.out_pointer)
|
||||
{
|
||||
|
@ -217,7 +217,7 @@ bool MemoryManager::InitFastmemArena()
|
|||
continue;
|
||||
|
||||
u8* base = m_physical_base + region.physical_address;
|
||||
u8* view = (u8*)m_arena.MapInMemoryRegion(region.shm_position, region.size, base);
|
||||
u8* view = static_cast<u8*>(m_arena.MapInMemoryRegion(region.shm_position, region.size, base));
|
||||
|
||||
if (base != view)
|
||||
{
|
||||
|
|
|
@ -162,7 +162,7 @@ void SerialInterfaceManager::RunSIBuffer(u64 user_data, s64 cycles_late)
|
|||
std::ostringstream ss;
|
||||
for (u8 b : request_copy)
|
||||
{
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << (int)b << ' ';
|
||||
ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(b) << ' ';
|
||||
}
|
||||
DEBUG_LOG_FMT(
|
||||
SERIALINTERFACE,
|
||||
|
@ -360,7 +360,7 @@ void SerialInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||
}
|
||||
|
||||
// In and out for the 4 SI channels.
|
||||
for (u32 i = 0; i < u32(MAX_SI_CHANNELS); ++i)
|
||||
for (u32 i = 0; i < static_cast<u32>(MAX_SI_CHANNELS); ++i)
|
||||
{
|
||||
// We need to clear the RDST bit for the SI channel when reading.
|
||||
const u32 clear_rdst = ~GetRDSTBit(i);
|
||||
|
|
|
@ -57,7 +57,7 @@ u32 CSIDevice_DanceMat::MapPadStatus(const GCPadStatus& pad_status)
|
|||
if (pad_status.button & PAD_BUTTON_START)
|
||||
map |= 0x1000;
|
||||
|
||||
return (u32)(map << 16) | 0x8080;
|
||||
return static_cast<u32>(map << 16) | 0x8080;
|
||||
}
|
||||
|
||||
bool CSIDevice_DanceMat::GetData(u32& hi, u32& low)
|
||||
|
|
|
@ -158,10 +158,11 @@ void GBASockServer::ClockSync(Core::System& system)
|
|||
}
|
||||
else
|
||||
{
|
||||
time_slice = (u32)(core_timing.GetTicks() - m_last_time_slice);
|
||||
time_slice = static_cast<u32>(core_timing.GetTicks() - m_last_time_slice);
|
||||
}
|
||||
|
||||
time_slice = (u32)((u64)time_slice * 16777216 / system.GetSystemTimers().GetTicksPerSecond());
|
||||
time_slice = static_cast<u32>(static_cast<u64>(time_slice) * 16777216 /
|
||||
system.GetSystemTimers().GetTicksPerSecond());
|
||||
m_last_time_slice = core_timing.GetTicks();
|
||||
char bytes[4] = {0, 0, 0, 0};
|
||||
bytes[0] = (time_slice >> 24) & 0xff;
|
||||
|
|
|
@ -80,7 +80,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
|||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Get Origin");
|
||||
|
||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||
for (int i = 0; i < static_cast<int>(sizeof(SOrigin)); i++)
|
||||
{
|
||||
buffer[i] = *calibration++;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
|
|||
INFO_LOG_FMT(SERIALINTERFACE, "PAD - Recalibrate");
|
||||
|
||||
u8* calibration = reinterpret_cast<u8*>(&m_origin);
|
||||
for (int i = 0; i < (int)sizeof(SOrigin); i++)
|
||||
for (int i = 0; i < static_cast<int>(sizeof(SOrigin)); i++)
|
||||
{
|
||||
buffer[i] = *calibration++;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ CSIDevice_GCController::HandleButtonCombos(const GCPadStatus& pad_status)
|
|||
{
|
||||
const u64 current_time = m_system.GetCoreTiming().GetTicks();
|
||||
const u32 ticks_per_second = m_system.GetSystemTimers().GetTicksPerSecond();
|
||||
if (u32(current_time - m_timer_button_combo_start) > ticks_per_second * 3)
|
||||
if (static_cast<u32>(current_time - m_timer_button_combo_start) > ticks_per_second * 3)
|
||||
{
|
||||
if (m_last_button_combo == COMBO_RESET)
|
||||
{
|
||||
|
|
|
@ -49,12 +49,12 @@ bool CSIDevice_GCSteeringWheel::GetData(u32& hi, u32& low)
|
|||
{
|
||||
GCPadStatus pad_status = GetPadStatus();
|
||||
|
||||
hi = (u32)((u8)pad_status.stickX); // Steering
|
||||
hi |= 0x800; // Pedal connected flag
|
||||
hi |= (u32)((u16)(pad_status.button | PAD_USE_ORIGIN) << 16);
|
||||
hi = static_cast<u32>((u8)pad_status.stickX); // Steering
|
||||
hi |= 0x800; // Pedal connected flag
|
||||
hi |= static_cast<u32>(static_cast<u16>(pad_status.button | PAD_USE_ORIGIN) << 16);
|
||||
|
||||
low = (u8)pad_status.triggerRight; // All 8 bits
|
||||
low |= (u32)((u8)pad_status.triggerLeft << 8); // All 8 bits
|
||||
low = (u8)pad_status.triggerRight; // All 8 bits
|
||||
low |= static_cast<u32>((u8)pad_status.triggerLeft << 8); // All 8 bits
|
||||
|
||||
// The GC Steering Wheel has 8 bit values for both the accelerator/brake.
|
||||
// Our mapping UI and GCPadEmu class weren't really designed to provide
|
||||
|
@ -83,10 +83,10 @@ bool CSIDevice_GCSteeringWheel::GetData(u32& hi, u32& low)
|
|||
// but we'll have to redesign our GameCube controller input to fix that.
|
||||
|
||||
// All 8 bits (Accelerate)
|
||||
low |= u32(std::clamp(accel_value * 2, 0, 0xff)) << 24;
|
||||
low |= static_cast<u32>(std::clamp(accel_value * 2, 0, 0xff)) << 24;
|
||||
|
||||
// All 8 bits (Brake)
|
||||
low |= u32(std::clamp(brake_value * 2, 0, 0xff)) << 16;
|
||||
low |= static_cast<u32>(std::clamp(brake_value * 2, 0, 0xff)) << 16;
|
||||
|
||||
HandleButtonCombos(pad_status);
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 command, u8 poll)
|
|||
if (pad_num < 4)
|
||||
{
|
||||
// Lowest bit is the high bit of the strength field.
|
||||
const auto type = ForceCommandType(wheel_command.parameter2 >> 1);
|
||||
const auto type = static_cast<ForceCommandType>(wheel_command.parameter2 >> 1);
|
||||
|
||||
// Strength is a 9 bit value from 0 to 256.
|
||||
// 0 = left strong, 256 = right strong
|
||||
|
@ -129,7 +129,7 @@ void CSIDevice_GCSteeringWheel::SendCommand(u32 command, u8 poll)
|
|||
Pad::Rumble(pad_num, 0);
|
||||
break;
|
||||
default:
|
||||
WARN_LOG_FMT(SERIALINTERFACE, "Unknown CMD_FORCE type {}", int(type));
|
||||
WARN_LOG_FMT(SERIALINTERFACE, "Unknown CMD_FORCE type {}", static_cast<int>(type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ void SetCardFlashID(Sram* sram, const u8* buffer, ExpansionInterface::Slot card_
|
|||
for (int i = 0; i < 12; i++)
|
||||
{
|
||||
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
||||
csum += sram->settings_ex.flash_id[card_index][i] = buffer[i] - ((u8)rand & 0xff);
|
||||
csum += sram->settings_ex.flash_id[card_index][i] = buffer[i] - (static_cast<u8>(rand) & 0xff);
|
||||
rand = (((rand * (u64)0x0000000041c64e6dULL) + (u64)0x0000000000003039ULL) >> 16);
|
||||
rand &= (u64)0x0000000000007fffULL;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ static s16 ADPDecodeSample(s32 bits, s32 q, s32& hist1, s32& hist2)
|
|||
}
|
||||
hist = std::clamp((hist + 0x20) >> 6, -0x200000, 0x1fffff);
|
||||
|
||||
s32 cur = (((s16)(bits << 12) >> (q & 0xf)) << 6) + hist;
|
||||
s32 cur = ((static_cast<s16>(bits << 12) >> (q & 0xf)) << 6) + hist;
|
||||
|
||||
hist2 = hist1;
|
||||
hist1 = cur;
|
||||
|
@ -40,7 +40,7 @@ static s16 ADPDecodeSample(s32 bits, s32 q, s32& hist1, s32& hist2)
|
|||
cur >>= 6;
|
||||
cur = std::clamp(cur, -0x8000, 0x7fff);
|
||||
|
||||
return (s16)cur;
|
||||
return static_cast<s16>(cur);
|
||||
}
|
||||
|
||||
void ADPCMDecoder::ResetFilter()
|
||||
|
|
|
@ -194,7 +194,8 @@ u32 SystemTimersManager::GetFakeDecrementer() const
|
|||
{
|
||||
const auto& core_timing = m_system.GetCoreTiming();
|
||||
return (core_timing.GetFakeDecStartValue() -
|
||||
(u32)((core_timing.GetTicks() - core_timing.GetFakeDecStartTicks()) / TIMER_RATIO));
|
||||
static_cast<u32>((core_timing.GetTicks() - core_timing.GetFakeDecStartTicks()) /
|
||||
TIMER_RATIO));
|
||||
}
|
||||
|
||||
void SystemTimersManager::TimeBaseSet()
|
||||
|
|
|
@ -355,7 +355,7 @@ void VideoInterfaceManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||
MMIO::ComplexWrite<u16>([](Core::System& system, u32, u16 val) {
|
||||
auto& vi = system.GetVideoInterface();
|
||||
vi.m_unknown_aa_register =
|
||||
(vi.m_unknown_aa_register & 0x0000FFFF) | ((u32)val << 16);
|
||||
(vi.m_unknown_aa_register & 0x0000FFFF) | (static_cast<u32>(val) << 16);
|
||||
WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (hi)");
|
||||
}));
|
||||
mmio->Register(base | VI_UNK_AA_REG_LO, MMIO::ComplexRead<u16>([](Core::System& system, u32) {
|
||||
|
|
|
@ -244,12 +244,14 @@ private:
|
|||
|
||||
static constexpr FS::Modes GetFsMode(u8 bin_mode)
|
||||
{
|
||||
return {FS::Mode(bin_mode >> 4 & 3), FS::Mode(bin_mode >> 2 & 3), FS::Mode(bin_mode >> 0 & 3)};
|
||||
return {static_cast<FS::Mode>(bin_mode >> 4 & 3), static_cast<FS::Mode>(bin_mode >> 2 & 3),
|
||||
static_cast<FS::Mode>(bin_mode >> 0 & 3)};
|
||||
}
|
||||
|
||||
static constexpr u8 GetBinMode(const FS::Modes& modes)
|
||||
{
|
||||
return u8(modes.owner) << 4 | u8(modes.group) << 2 | u8(modes.other) << 0;
|
||||
return static_cast<u8>(modes.owner) << 4 | static_cast<u8>(modes.group) << 2 |
|
||||
static_cast<u8>(modes.other) << 0;
|
||||
}
|
||||
|
||||
u8 GetBinMode(const std::string& path) const
|
||||
|
|
|
@ -231,10 +231,10 @@ void DoState(PointerWrap& p)
|
|||
for (int i = 0; i < MAX_BBMOTES; ++i)
|
||||
{
|
||||
const WiimoteSource source = GetSource(i);
|
||||
auto state_wiimote_source = u8(source);
|
||||
auto state_wiimote_source = static_cast<u8>(source);
|
||||
p.Do(state_wiimote_source);
|
||||
|
||||
if (WiimoteSource(state_wiimote_source) == WiimoteSource::Emulated)
|
||||
if (static_cast<WiimoteSource>(state_wiimote_source) == WiimoteSource::Emulated)
|
||||
{
|
||||
// Sync complete state of emulated wiimotes.
|
||||
static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(i))->DoState(p);
|
||||
|
@ -244,7 +244,8 @@ void DoState(PointerWrap& p)
|
|||
{
|
||||
// If using a real wiimote or the save-state source does not match the current source,
|
||||
// then force a reconnection on load.
|
||||
if (source == WiimoteSource::Real || source != WiimoteSource(state_wiimote_source))
|
||||
if (source == WiimoteSource::Real ||
|
||||
source != static_cast<WiimoteSource>(state_wiimote_source))
|
||||
WiimoteCommon::UpdateSource(i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,7 +209,8 @@ struct InputReportStatus
|
|||
}
|
||||
void SetEstimatedCharge(float charge)
|
||||
{
|
||||
battery = u8(std::lround((charge - BATTERY_LEVEL_B) / BATTERY_LEVEL_M * BATTERY_MAX));
|
||||
battery =
|
||||
static_cast<u8>(std::lround((charge - BATTERY_LEVEL_B) / BATTERY_LEVEL_M * BATTERY_MAX));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -66,7 +66,7 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
|
|||
|
||||
const auto camera_view =
|
||||
Matrix44::Perspective(field_of_view.y, field_of_view.x / field_of_view.y, 0.001f, 1000) *
|
||||
Matrix44::FromMatrix33(Matrix33::RotateX(float(MathUtil::TAU / 4))) * transform;
|
||||
Matrix44::FromMatrix33(Matrix33::RotateX(static_cast<float>(MathUtil::TAU / 4))) * transform;
|
||||
|
||||
std::array<CameraPoint, CameraLogic::NUM_POINTS> camera_points;
|
||||
|
||||
|
@ -78,8 +78,8 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
|
|||
return CameraPoint();
|
||||
|
||||
// FYI: truncating vs. rounding seems to produce more symmetrical cursor positioning.
|
||||
const auto x = s32((1 - point.x / point.w) * CAMERA_RES_X / 2);
|
||||
const auto y = s32((1 - point.y / point.w) * CAMERA_RES_Y / 2);
|
||||
const auto x = static_cast<s32>((1 - point.x / point.w) * CAMERA_RES_X / 2);
|
||||
const auto y = static_cast<s32>((1 - point.y / point.w) * CAMERA_RES_Y / 2);
|
||||
|
||||
// Check if LED is outside of view.
|
||||
if (x < 0 || y < 0 || x >= CAMERA_RES_X || y >= CAMERA_RES_Y)
|
||||
|
@ -91,7 +91,8 @@ CameraLogic::GetCameraPoints(const Common::Matrix44& transform, Common::Vec2 fie
|
|||
|
||||
const auto clamped_point_size = std::clamp<s32>(std::lround(point_size), 1, MAX_POINT_SIZE);
|
||||
|
||||
return CameraPoint({u16(x), u16(y)}, u8(clamped_point_size));
|
||||
return CameraPoint({static_cast<u16>(x), static_cast<u16>(y)},
|
||||
static_cast<u8>(clamped_point_size));
|
||||
});
|
||||
|
||||
return camera_points;
|
||||
|
@ -166,7 +167,7 @@ void CameraLogic::Update(const std::array<CameraPoint, NUM_POINTS>& camera_point
|
|||
std::lround((irdata.xmax - irdata.xmin) * (irdata.ymax - irdata.ymin) /
|
||||
SUBPIXEL_RESOLUTION / SUBPIXEL_RESOLUTION * MathUtil::TAU / 8);
|
||||
|
||||
irdata.intensity = u8(std::min(MAX_INTENSITY, intensity));
|
||||
irdata.intensity = static_cast<u8>(std::min(MAX_INTENSITY, intensity));
|
||||
|
||||
Common::BitCastPtr<IRFull>(&data[i * sizeof(IRFull)]) = irdata;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
// Jordan: I calculate the FOV at 42 degrees horizontally and having a 4:3 aspect ratio.
|
||||
// This is 31.5 degrees vertically.
|
||||
static constexpr float CAMERA_AR = 4.f / 3;
|
||||
static constexpr float CAMERA_FOV_X = 42 * float(MathUtil::TAU) / 360;
|
||||
static constexpr float CAMERA_FOV_X = 42 * static_cast<float>(MathUtil::TAU) / 360;
|
||||
static constexpr float CAMERA_FOV_Y = CAMERA_FOV_X / CAMERA_AR;
|
||||
|
||||
enum : u8
|
||||
|
|
|
@ -29,20 +29,21 @@ SerializedWiimoteState SerializeDesiredState(const DesiredWiimoteState& state)
|
|||
// encoding so that typical extensions (None, Nunchuk, Classic Controller) still fit into the
|
||||
// initial 4 bits.
|
||||
static_assert(std::variant_size_v<DesiredExtensionState::ExtensionData> <= (1 << 4));
|
||||
const u8 extension = u8(state.extension.data.index());
|
||||
const u8 extension = static_cast<u8>(state.extension.data.index());
|
||||
|
||||
SerializedWiimoteState s;
|
||||
s.length = 0;
|
||||
s.data[s.length++] = u8(has_buttons | (has_accel << 1) | (has_camera << 2) |
|
||||
(has_motion_plus << 3) | (extension << 4));
|
||||
s.data[s.length++] = static_cast<u8>(has_buttons | (has_accel << 1) | (has_camera << 2) |
|
||||
(has_motion_plus << 3) | (extension << 4));
|
||||
|
||||
if (has_buttons)
|
||||
{
|
||||
const u8 buttons = u8((state.buttons.a) | (state.buttons.b << 1) | (state.buttons.plus << 2) |
|
||||
(state.buttons.minus << 3) | (state.buttons.one << 4) |
|
||||
(state.buttons.two << 5) | (state.buttons.home << 6));
|
||||
const u8 dpad = u8((state.buttons.up) | (state.buttons.down << 1) | (state.buttons.left << 2) |
|
||||
(state.buttons.right << 3));
|
||||
const u8 buttons =
|
||||
static_cast<u8>((state.buttons.a) | (state.buttons.b << 1) | (state.buttons.plus << 2)
|
||||
(state.buttons.minus << 3) | (state.buttons.one << 4)
|
||||
(state.buttons.two << 5) | (state.buttons.home << 6));
|
||||
const u8 dpad = static_cast<u8>((state.buttons.up) | (state.buttons.down << 1)
|
||||
(state.buttons.left << 2) | (state.buttons.right << 3));
|
||||
s.data[s.length++] = buttons;
|
||||
s.data[s.length++] = dpad;
|
||||
}
|
||||
|
@ -52,20 +53,20 @@ SerializedWiimoteState SerializeDesiredState(const DesiredWiimoteState& state)
|
|||
const u16 accel_x = state.acceleration.value.x; // 10 bits
|
||||
const u16 accel_y = state.acceleration.value.y; // 9 bits (ignore lowest bit)
|
||||
const u16 accel_z = state.acceleration.value.z; // 9 bits (ignore lowest bit)
|
||||
const u8 accel_x_high = u8(accel_x >> 2);
|
||||
const u8 accel_y_high = u8(accel_y >> 2);
|
||||
const u8 accel_z_high = u8(accel_z >> 2);
|
||||
const u8 accel_low = u8((accel_x & 0b11) | (Common::ExtractBit<1>(accel_y) << 2) |
|
||||
(Common::ExtractBit<1>(accel_z) << 3));
|
||||
const u8 accel_x_high = static_cast<u8>(accel_x >> 2);
|
||||
const u8 accel_y_high = static_cast<u8>(accel_y >> 2);
|
||||
const u8 accel_z_high = static_cast<u8>(accel_z >> 2);
|
||||
const u8 accel_low = static_cast<u8>((accel_x & 0b11) | (Common::ExtractBit<1>(accel_y) << 2) |
|
||||
(Common::ExtractBit<1>(accel_z) << 3));
|
||||
|
||||
if (has_buttons)
|
||||
{
|
||||
// can use the high bits of the dpad field from buttons
|
||||
s.data[s.length - 1] |= u8(accel_low << 4);
|
||||
s.data[s.length - 1] |= static_cast<u8>(accel_low << 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.data[s.length++] = u8(accel_low << 4);
|
||||
s.data[s.length++] = static_cast<u8>(accel_low << 4);
|
||||
}
|
||||
|
||||
s.data[s.length++] = accel_x_high;
|
||||
|
@ -93,12 +94,12 @@ SerializedWiimoteState SerializeDesiredState(const DesiredWiimoteState& state)
|
|||
const u16 pitch_value = state.motion_plus->gyro.value.x; // 14 bits
|
||||
const u16 roll_value = state.motion_plus->gyro.value.y; // 14 bits
|
||||
const u16 yaw_value = state.motion_plus->gyro.value.z; // 14 bits
|
||||
s.data[s.length++] = u8(pitch_value);
|
||||
s.data[s.length++] = u8(((pitch_value >> 8) & 0x3f) | (pitch_slow << 7));
|
||||
s.data[s.length++] = u8(roll_value);
|
||||
s.data[s.length++] = u8(((roll_value >> 8) & 0x3f) | (roll_slow << 7));
|
||||
s.data[s.length++] = u8(yaw_value);
|
||||
s.data[s.length++] = u8(((yaw_value >> 8) & 0x3f) | (yaw_slow << 7));
|
||||
s.data[s.length++] = static_cast<u8>(pitch_value);
|
||||
s.data[s.length++] = static_cast<u8>(((pitch_value >> 8) & 0x3f) | (pitch_slow << 7));
|
||||
s.data[s.length++] = static_cast<u8>(roll_value);
|
||||
s.data[s.length++] = static_cast<u8>(((roll_value >> 8) & 0x3f) | (roll_slow << 7));
|
||||
s.data[s.length++] = static_cast<u8>(yaw_value);
|
||||
s.data[s.length++] = static_cast<u8>(((yaw_value >> 8) & 0x3f) | (yaw_slow << 7));
|
||||
}
|
||||
|
||||
if (extension)
|
||||
|
|
|
@ -83,7 +83,8 @@ Common::Quaternion ComplementaryFilter(const Common::Quaternion& gyroscope,
|
|||
void EmulateShake(PositionalState* state, ControllerEmu::Shake* const shake_group,
|
||||
float time_elapsed)
|
||||
{
|
||||
auto target_position = shake_group->GetState() * float(shake_group->GetIntensity() / 2);
|
||||
auto target_position =
|
||||
shake_group->GetState() * static_cast<float>(shake_group->GetIntensity() / 2);
|
||||
for (std::size_t i = 0; i != target_position.data.size(); ++i)
|
||||
{
|
||||
if (state->velocity.data[i] * std::copysign(1.f, target_position.data[i]) < 0 ||
|
||||
|
@ -122,7 +123,7 @@ void EmulateTilt(RotationalState* state, ControllerEmu::Tilt* const tilt_group,
|
|||
for (std::size_t i = 0; i != target_angle.data.size(); ++i)
|
||||
{
|
||||
auto& angle = state->angle.data[i];
|
||||
if (std::abs(angle - target_angle.data[i]) > float(MathUtil::PI))
|
||||
if (std::abs(angle - target_angle.data[i]) > static_cast<float>(MathUtil::PI))
|
||||
angle -= std::copysign(MathUtil::TAU, angle);
|
||||
}
|
||||
|
||||
|
@ -146,9 +147,10 @@ void EmulateSwing(MotionState* state, ControllerEmu::Force* swing_group, float t
|
|||
const auto xz_target_dist = Common::Vec2{target_position.x, target_position.z}.Length();
|
||||
const auto y_target_dist = std::abs(target_position.y);
|
||||
const auto target_dist = Common::Vec3{xz_target_dist, y_target_dist, xz_target_dist};
|
||||
const auto speed = MathUtil::Lerp(Common::Vec3{1, 1, 1} * float(swing_group->GetReturnSpeed()),
|
||||
Common::Vec3{1, 1, 1} * float(swing_group->GetSpeed()),
|
||||
target_dist / max_distance);
|
||||
const auto speed =
|
||||
MathUtil::Lerp(Common::Vec3{1, 1, 1} * static_cast<float>(swing_group->GetReturnSpeed()),
|
||||
Common::Vec3{1, 1, 1} * static_cast<float>(swing_group->GetSpeed()),
|
||||
target_dist / max_distance);
|
||||
|
||||
// Convert our m/s "speed" to the jerk required to reach this speed when traveling 1 meter.
|
||||
const auto max_jerk = speed * speed * speed * 4;
|
||||
|
@ -211,15 +213,15 @@ void EmulateSwing(MotionState* state, ControllerEmu::Force* swing_group, float t
|
|||
|
||||
WiimoteCommon::AccelData ConvertAccelData(const Common::Vec3& accel, u16 zero_g, u16 one_g)
|
||||
{
|
||||
const auto scaled_accel = accel * (one_g - zero_g) / float(GRAVITY_ACCELERATION);
|
||||
const auto scaled_accel = accel * (one_g - zero_g) / static_cast<float>(GRAVITY_ACCELERATION);
|
||||
|
||||
// 10-bit integers.
|
||||
constexpr long MAX_VALUE = (1 << 10) - 1;
|
||||
|
||||
return WiimoteCommon::AccelData(
|
||||
{u16(std::clamp(std::lround(scaled_accel.x + zero_g), 0l, MAX_VALUE)),
|
||||
u16(std::clamp(std::lround(scaled_accel.y + zero_g), 0l, MAX_VALUE)),
|
||||
u16(std::clamp(std::lround(scaled_accel.z + zero_g), 0l, MAX_VALUE))});
|
||||
{static_cast<u16>(std::clamp(std::lround(scaled_accel.x + zero_g), 0l, MAX_VALUE)),
|
||||
static_cast<u16>(std::clamp(std::lround(scaled_accel.y + zero_g), 0l, MAX_VALUE)),
|
||||
static_cast<u16>(std::clamp(std::lround(scaled_accel.z + zero_g), 0l, MAX_VALUE))});
|
||||
}
|
||||
|
||||
void EmulatePoint(MotionState* state, ControllerEmu::Cursor* ir_group,
|
||||
|
@ -266,7 +268,7 @@ void EmulatePoint(MotionState* state, ControllerEmu::Cursor* ir_group,
|
|||
// Higher values will be more responsive but increase rate of M+ "desync".
|
||||
// I'd rather not expose this value in the UI if not needed.
|
||||
// At this value, sync is very good and responsiveness still appears instant.
|
||||
constexpr auto MAX_ACCEL = float(MathUtil::TAU * 8);
|
||||
constexpr auto MAX_ACCEL = static_cast<float>(MathUtil::TAU * 8);
|
||||
|
||||
ApproachAngleWithAccel(state, target_angle, MAX_ACCEL, time_elapsed);
|
||||
}
|
||||
|
@ -329,7 +331,7 @@ void EmulateIMUCursor(IMUCursorState* state, ControllerEmu::IMUCursor* imu_ir_gr
|
|||
|
||||
// Clamp yaw within configured bounds.
|
||||
const auto yaw = GetYaw(state->rotation);
|
||||
const auto max_yaw = float(imu_ir_group->GetTotalYaw() / 2);
|
||||
const auto max_yaw = static_cast<float>(imu_ir_group->GetTotalYaw() / 2);
|
||||
auto target_yaw = std::clamp(yaw, -max_yaw, max_yaw);
|
||||
|
||||
// Handle the "Recenter" button being pressed.
|
||||
|
|
|
@ -302,7 +302,8 @@ void Wiimote::HandleWriteData(const OutputReportWriteData& wd)
|
|||
}
|
||||
|
||||
// Top byte of address is ignored on the bus.
|
||||
auto const bytes_written = m_i2c_bus.BusWrite(wd.slave_address, (u8)address, wd.size, wd.data);
|
||||
auto const bytes_written =
|
||||
m_i2c_bus.BusWrite(wd.slave_address, static_cast<u8>(address), wd.size, wd.data);
|
||||
if (bytes_written != wd.size)
|
||||
{
|
||||
// A real wiimote gives error 7 for failed write to i2c bus (mainly a non-existant slave)
|
||||
|
@ -488,8 +489,9 @@ bool Wiimote::ProcessReadDataRequest()
|
|||
}
|
||||
|
||||
// Top byte of address is ignored on the bus, but it IS maintained in the read-reply.
|
||||
auto const bytes_read = m_i2c_bus.BusRead(
|
||||
m_read_request.slave_address, (u8)m_read_request.address, bytes_to_read, reply.data);
|
||||
auto const bytes_read =
|
||||
m_i2c_bus.BusRead(m_read_request.slave_address, static_cast<u8>(m_read_request.address),
|
||||
bytes_to_read, reply.data);
|
||||
|
||||
if (bytes_read != bytes_to_read)
|
||||
{
|
||||
|
@ -504,7 +506,8 @@ bool Wiimote::ProcessReadDataRequest()
|
|||
break;
|
||||
|
||||
default:
|
||||
WARN_LOG_FMT(WIIMOTE, "ReadData: invalid address space: {:#x}", int(m_read_request.space));
|
||||
WARN_LOG_FMT(WIIMOTE, "ReadData: invalid address space: {:#x}",
|
||||
static_cast<int>(m_read_request.space));
|
||||
// A real wiimote gives error 6:
|
||||
error_code = ErrorCode::InvalidSpace;
|
||||
break;
|
||||
|
|
|
@ -521,12 +521,12 @@ EncryptionKey::KeyData KeyGen1stParty::GenerateKeyData(const EncryptionKey::Rand
|
|||
t0[i] = keygen_sbox_1st_party[rand[i]];
|
||||
|
||||
return {
|
||||
u8((std::rotr<u8>(ans[0] ^ t0[5], t0[2]) - t0[9]) ^ t0[4]),
|
||||
u8((std::rotr<u8>(ans[1] ^ t0[1], t0[0]) - t0[5]) ^ t0[7]),
|
||||
u8((std::rotr<u8>(ans[2] ^ t0[6], t0[8]) - t0[2]) ^ t0[0]),
|
||||
u8((std::rotr<u8>(ans[3] ^ t0[4], t0[7]) - t0[3]) ^ t0[2]),
|
||||
u8((std::rotr<u8>(ans[4] ^ t0[1], t0[6]) - t0[3]) ^ t0[4]),
|
||||
u8((std::rotr<u8>(ans[5] ^ t0[7], t0[8]) - t0[5]) ^ t0[9]),
|
||||
static_cast<u8>((std::rotr<u8>(ans[0] ^ t0[5], t0[2]) - t0[9]) ^ t0[4]),
|
||||
static_cast<u8>((std::rotr<u8>(ans[1] ^ t0[1], t0[0]) - t0[5]) ^ t0[7]),
|
||||
static_cast<u8>((std::rotr<u8>(ans[2] ^ t0[6], t0[8]) - t0[2]) ^ t0[0]),
|
||||
static_cast<u8>((std::rotr<u8>(ans[3] ^ t0[4], t0[7]) - t0[3]) ^ t0[2]),
|
||||
static_cast<u8>((std::rotr<u8>(ans[4] ^ t0[1], t0[6]) - t0[3]) ^ t0[4]),
|
||||
static_cast<u8>((std::rotr<u8>(ans[5] ^ t0[7], t0[8]) - t0[5]) ^ t0[9]),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -547,12 +547,12 @@ EncryptionKey::KeyData KeyGen3rdParty::GenerateKeyData(const EncryptionKey::Rand
|
|||
t0[i] = keygen_sbox_3rd_party[rand[i]];
|
||||
|
||||
return {
|
||||
u8(t0[7] ^ (t0[6] + std::rotl<u8>(ans[0] ^ t0[0], t0[1]))),
|
||||
u8(t0[1] ^ (t0[3] + std::rotl<u8>(ans[1] ^ t0[4], t0[2]))),
|
||||
u8(t0[5] ^ (t0[4] + std::rotl<u8>(ans[2] ^ t0[2], t0[8]))),
|
||||
u8(t0[0] ^ (t0[7] + std::rotl<u8>(ans[3] ^ t0[6], t0[9]))),
|
||||
u8(t0[1] ^ (t0[8] + std::rotl<u8>(ans[4] ^ t0[5], t0[4]))),
|
||||
u8(t0[5] ^ (t0[8] + std::rotl<u8>(ans[5] ^ t0[9], t0[3]))),
|
||||
static_cast<u8>(t0[7] ^ (t0[6] + std::rotl<u8>(ans[0] ^ t0[0], t0[1]))),
|
||||
static_cast<u8>(t0[1] ^ (t0[3] + std::rotl<u8>(ans[1] ^ t0[4], t0[2]))),
|
||||
static_cast<u8>(t0[5] ^ (t0[4] + std::rotl<u8>(ans[2] ^ t0[2], t0[8]))),
|
||||
static_cast<u8>(t0[0] ^ (t0[7] + std::rotl<u8>(ans[3] ^ t0[6], t0[9]))),
|
||||
static_cast<u8>(t0[1] ^ (t0[8] + std::rotl<u8>(ans[4] ^ t0[5], t0[4]))),
|
||||
static_cast<u8>(t0[5] ^ (t0[8] + std::rotl<u8>(ans[5] ^ t0[9], t0[3]))),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ Classic::Classic() : Extension1stParty("Classic", _trans("Classic Controller"))
|
|||
m_buttons->AddInput(Translatability::DoNotTranslate, HOME_BUTTON, "HOME");
|
||||
|
||||
// sticks
|
||||
constexpr auto gate_radius = ControlState(STICK_GATE_RADIUS) / CAL_STICK_RADIUS;
|
||||
constexpr auto gate_radius = static_cast<ControlState>(STICK_GATE_RADIUS) / CAL_STICK_RADIUS;
|
||||
groups.emplace_back(m_left_stick =
|
||||
new ControllerEmu::OctagonAnalogStick(LEFT_STICK_GROUP, gate_radius));
|
||||
groups.emplace_back(m_right_stick =
|
||||
|
|
|
@ -53,11 +53,11 @@ void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_st
|
|||
const u16 stylus_x = MapFloat<u16>(stylus_state.x, CENTER_X, MIN_X, MAX_X);
|
||||
const u16 stylus_y = MapFloat<u16>(-stylus_state.y, CENTER_Y, MAX_Y, MIN_Y);
|
||||
|
||||
tablet_data.stylus_x1 = u8(stylus_x);
|
||||
tablet_data.stylus_x2 = u8(stylus_x >> 8);
|
||||
tablet_data.stylus_x1 = static_cast<u8>(stylus_x);
|
||||
tablet_data.stylus_x2 = static_cast<u8>(stylus_x >> 8);
|
||||
|
||||
tablet_data.stylus_y1 = u8(stylus_y);
|
||||
tablet_data.stylus_y2 = u8(stylus_y >> 8);
|
||||
tablet_data.stylus_y1 = static_cast<u8>(stylus_y);
|
||||
tablet_data.stylus_y2 = static_cast<u8>(stylus_y >> 8);
|
||||
|
||||
const auto touch_state = m_touch->GetState(m_input_override_function);
|
||||
|
||||
|
@ -79,8 +79,8 @@ void DrawsomeTablet::BuildDesiredExtensionState(DesiredExtensionState* target_st
|
|||
|
||||
const u16 pressure = MapFloat<u16>(touch_state.data[0], 0, 0, MAX_PRESSURE);
|
||||
|
||||
tablet_data.pressure1 = u8(pressure);
|
||||
tablet_data.pressure2 = u8(pressure >> 8);
|
||||
tablet_data.pressure1 = static_cast<u8>(pressure);
|
||||
tablet_data.pressure2 = static_cast<u8>(pressure >> 8);
|
||||
}
|
||||
|
||||
void DrawsomeTablet::Update(const DesiredExtensionState& target_state)
|
||||
|
|
|
@ -100,7 +100,8 @@ void Drums::BuildDesiredExtensionState(DesiredExtensionState* target_state)
|
|||
state.drum_pads = 0;
|
||||
m_pads->GetState(&state.drum_pads, drum_pad_bitmasks.data(), m_input_override_function);
|
||||
|
||||
state.softness = u8(0x7F - std::lround(m_hit_strength_setting.GetValue() * 0x7F / 100));
|
||||
state.softness =
|
||||
static_cast<u8>(0x7F - std::lround(m_hit_strength_setting.GetValue() * 0x7F / 100));
|
||||
}
|
||||
|
||||
void Drums::Update(const DesiredExtensionState& target_state)
|
||||
|
@ -129,7 +130,7 @@ void Drums::Update(const DesiredExtensionState& target_state)
|
|||
drum_data.unk5 = 0b11;
|
||||
|
||||
// Send no velocity data by default.
|
||||
drum_data.velocity_id = u8(VelocityID::None);
|
||||
drum_data.velocity_id = static_cast<u8>(VelocityID::None);
|
||||
drum_data.no_velocity_data_1 = 1;
|
||||
drum_data.no_velocity_data_2 = 1;
|
||||
|
||||
|
@ -156,7 +157,7 @@ void Drums::Update(const DesiredExtensionState& target_state)
|
|||
// Clear the bit so velocity data is not sent again until the next hit.
|
||||
m_new_pad_hits &= ~drum_pad;
|
||||
|
||||
drum_data.velocity_id = u8(drum_pad_velocity_ids[i]);
|
||||
drum_data.velocity_id = static_cast<u8>(drum_pad_velocity_ids[i]);
|
||||
|
||||
drum_data.no_velocity_data_1 = 0;
|
||||
drum_data.no_velocity_data_2 = 0;
|
||||
|
|
|
@ -83,7 +83,7 @@ Guitar::Guitar() : Extension1stParty(_trans("Guitar"))
|
|||
m_buttons->AddInput(Translatability::DoNotTranslate, "+");
|
||||
|
||||
// stick
|
||||
constexpr auto gate_radius = ControlState(STICK_GATE_RADIUS) / STICK_RADIUS;
|
||||
constexpr auto gate_radius = static_cast<ControlState>(STICK_GATE_RADIUS) / STICK_RADIUS;
|
||||
groups.emplace_back(m_stick =
|
||||
new ControllerEmu::OctagonAnalogStick(_trans("Stick"), gate_radius));
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ Nunchuk::Nunchuk() : Extension1stParty(_trans("Nunchuk"))
|
|||
m_buttons->AddInput(Translatability::DoNotTranslate, Z_BUTTON);
|
||||
|
||||
// stick
|
||||
constexpr auto gate_radius = ControlState(STICK_GATE_RADIUS) / STICK_RADIUS;
|
||||
constexpr auto gate_radius = static_cast<ControlState>(STICK_GATE_RADIUS) / STICK_RADIUS;
|
||||
groups.emplace_back(m_stick = new ControllerEmu::OctagonAnalogStick(STICK_GROUP, gate_radius));
|
||||
|
||||
// Shake
|
||||
|
@ -104,9 +104,9 @@ void Nunchuk::BuildDesiredExtensionState(DesiredExtensionState* target_state)
|
|||
GetRotationalMatrix(-m_tilt_state.angle) * GetRotationalMatrix(-m_swing_state.angle);
|
||||
|
||||
Common::Vec3 accel =
|
||||
transformation *
|
||||
(m_swing_state.acceleration +
|
||||
m_imu_accelerometer->GetState().value_or(Common::Vec3(0, 0, float(GRAVITY_ACCELERATION))));
|
||||
transformation * (m_swing_state.acceleration +
|
||||
m_imu_accelerometer->GetState().value_or(Common::Vec3(
|
||||
0, 0, static_cast<float>(GRAVITY_ACCELERATION))));
|
||||
|
||||
// shake
|
||||
accel += m_shake_state.acceleration;
|
||||
|
|
|
@ -68,7 +68,7 @@ Turntable::Turntable() : Extension1stParty("Turntable", _trans("DJ Turntable"))
|
|||
new ControllerEmu::Slider("Table Right", _trans("Right Table")));
|
||||
|
||||
// stick
|
||||
constexpr auto gate_radius = ControlState(STICK_GATE_RADIUS) / STICK_RADIUS;
|
||||
constexpr auto gate_radius = static_cast<ControlState>(STICK_GATE_RADIUS) / STICK_RADIUS;
|
||||
groups.emplace_back(m_stick =
|
||||
new ControllerEmu::OctagonAnalogStick(_trans("Stick"), gate_radius));
|
||||
|
||||
|
|
|
@ -90,8 +90,8 @@ void UDrawTablet::BuildDesiredExtensionState(DesiredExtensionState* target_state
|
|||
|
||||
if (!is_stylus_lifted)
|
||||
{
|
||||
stylus_x = u16(center_x + stylus_state.x * (max_x - center_x));
|
||||
stylus_y = u16(center_y + stylus_state.y * (max_y - center_y));
|
||||
stylus_x = static_cast<u16>(center_x + stylus_state.x * (max_x - center_x));
|
||||
stylus_y = static_cast<u16>(center_y + stylus_state.y * (max_y - center_y));
|
||||
}
|
||||
|
||||
tablet_data.stylus_x1 = stylus_x & 0xff;
|
||||
|
|
|
@ -31,7 +31,7 @@ protected:
|
|||
// TODO: addr wraps around after 0xff
|
||||
|
||||
u8* src = reinterpret_cast<u8*>(reg_data) + addr;
|
||||
count = std::min(count, int(reinterpret_cast<u8*>(reg_data + 1) - src));
|
||||
count = std::min(count, static_cast<int>(reinterpret_cast<u8*>(reg_data + 1) - src));
|
||||
|
||||
std::copy_n(src, count, data_out);
|
||||
|
||||
|
@ -47,7 +47,7 @@ protected:
|
|||
// TODO: addr wraps around after 0xff
|
||||
|
||||
u8* dst = reinterpret_cast<u8*>(reg_data) + addr;
|
||||
count = std::min(count, int(reinterpret_cast<u8*>(reg_data + 1) - dst));
|
||||
count = std::min(count, static_cast<int>(reinterpret_cast<u8*>(reg_data + 1) - dst));
|
||||
|
||||
std::copy_n(data_in, count, dst);
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Common::Vec3 MotionPlus::DataFormat::Data::GetAngularVelocity(const CalibrationB
|
|||
const auto sign_fix = Common::Vec3(-1, +1, -1);
|
||||
|
||||
// Adjust deg/s to rad/s.
|
||||
constexpr auto scalar = float(MathUtil::TAU / 360);
|
||||
constexpr auto scalar = static_cast<float>(MathUtil::TAU / 360);
|
||||
|
||||
return gyro.GetNormalizedValue(calibration.value) * sign_fix * Common::Vec3(calibration.degrees) *
|
||||
scalar;
|
||||
|
@ -149,8 +149,8 @@ void MotionPlus::CalibrationData::UpdateChecksum()
|
|||
crc_result = Common::UpdateCRC32(crc_result, reinterpret_cast<const u8*>(this), 0xe);
|
||||
crc_result = Common::UpdateCRC32(crc_result, reinterpret_cast<const u8*>(this) + 0x10, 0xe);
|
||||
|
||||
crc32_lsb = u16(crc_result);
|
||||
crc32_msb = u16(crc_result >> 16);
|
||||
crc32_lsb = static_cast<u16>(crc_result);
|
||||
crc32_msb = static_cast<u16>(crc_result >> 16);
|
||||
}
|
||||
|
||||
void MotionPlus::DoState(PointerWrap& p)
|
||||
|
@ -435,14 +435,16 @@ void MotionPlus::Update(const DesiredExtensionState& target_state)
|
|||
{
|
||||
constexpr u8 INIT_OFFSET = offsetof(Register, init_trigger);
|
||||
std::array<u8, 1> enc_data = {0x55};
|
||||
m_i2c_bus.BusWrite(ACTIVE_DEVICE_ADDR, INIT_OFFSET, int(enc_data.size()), enc_data.data());
|
||||
m_i2c_bus.BusWrite(ACTIVE_DEVICE_ADDR, INIT_OFFSET, static_cast<int>(enc_data.size()),
|
||||
enc_data.data());
|
||||
}
|
||||
|
||||
// Read identifier
|
||||
{
|
||||
constexpr u8 ID_OFFSET = offsetof(Register, ext_identifier);
|
||||
std::array<u8, 6> id_data = {};
|
||||
m_i2c_bus.BusRead(ACTIVE_DEVICE_ADDR, ID_OFFSET, int(id_data.size()), id_data.data());
|
||||
m_i2c_bus.BusRead(ACTIVE_DEVICE_ADDR, ID_OFFSET, static_cast<int>(id_data.size()),
|
||||
id_data.data());
|
||||
m_reg_data.passthrough_ext_id_0 = id_data[0];
|
||||
m_reg_data.passthrough_ext_id_4 = id_data[4];
|
||||
m_reg_data.passthrough_ext_id_5 = id_data[5];
|
||||
|
@ -452,7 +454,7 @@ void MotionPlus::Update(const DesiredExtensionState& target_state)
|
|||
{
|
||||
constexpr u8 CAL_OFFSET = offsetof(Register, calibration_data);
|
||||
m_i2c_bus.BusRead(ACTIVE_DEVICE_ADDR, CAL_OFFSET,
|
||||
int(m_reg_data.passthrough_ext_calib.size()),
|
||||
static_cast<int>(m_reg_data.passthrough_ext_calib.size()),
|
||||
m_reg_data.passthrough_ext_calib.data());
|
||||
}
|
||||
}
|
||||
|
@ -538,7 +540,7 @@ MotionPlus::DataFormat::Data MotionPlus::GetGyroscopeData(const Common::Vec3& an
|
|||
result.is_slow.data[i] = is_slow;
|
||||
|
||||
const s32 value = std::lround(rad_per_sec * (is_slow ? SLOW_SCALE : FAST_SCALE));
|
||||
result.gyro.value.data[i] = u16(std::clamp(value + ZERO_VALUE, 0, MAX_VALUE));
|
||||
result.gyro.value.data[i] = static_cast<u16>(std::clamp(value + ZERO_VALUE, 0, MAX_VALUE));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -546,7 +548,8 @@ MotionPlus::DataFormat::Data MotionPlus::GetGyroscopeData(const Common::Vec3& an
|
|||
MotionPlus::DataFormat::Data MotionPlus::GetDefaultGyroscopeData()
|
||||
{
|
||||
return DataFormat::Data{DataFormat::GyroRawValue{DataFormat::GyroType{
|
||||
u16(ZERO_VALUE), u16(ZERO_VALUE), u16(ZERO_VALUE)}},
|
||||
static_cast<u16>(ZERO_VALUE), static_cast<u16>(ZERO_VALUE),
|
||||
static_cast<u16>(ZERO_VALUE)}},
|
||||
DataFormat::SlowType{true, true, true}};
|
||||
}
|
||||
|
||||
|
@ -627,19 +630,19 @@ void MotionPlus::PrepareInput(const MotionPlus::DataFormat::Data& gyroscope_data
|
|||
const u16 roll_value = gyroscope_data.gyro.value.y;
|
||||
const u16 yaw_value = gyroscope_data.gyro.value.z;
|
||||
|
||||
mplus_data.yaw_slow = u8(yaw_slow);
|
||||
mplus_data.roll_slow = u8(roll_slow);
|
||||
mplus_data.pitch_slow = u8(pitch_slow);
|
||||
mplus_data.yaw_slow = static_cast<u8>(yaw_slow);
|
||||
mplus_data.roll_slow = static_cast<u8>(roll_slow);
|
||||
mplus_data.pitch_slow = static_cast<u8>(pitch_slow);
|
||||
|
||||
// Bits 0-7
|
||||
mplus_data.yaw1 = u8(yaw_value);
|
||||
mplus_data.roll1 = u8(roll_value);
|
||||
mplus_data.pitch1 = u8(pitch_value);
|
||||
mplus_data.yaw1 = static_cast<u8>(yaw_value);
|
||||
mplus_data.roll1 = static_cast<u8>(roll_value);
|
||||
mplus_data.pitch1 = static_cast<u8>(pitch_value);
|
||||
|
||||
// Bits 8-13
|
||||
mplus_data.yaw2 = u8(yaw_value >> 8);
|
||||
mplus_data.roll2 = u8(roll_value >> 8);
|
||||
mplus_data.pitch2 = u8(pitch_value >> 8);
|
||||
mplus_data.yaw2 = static_cast<u8>(yaw_value >> 8);
|
||||
mplus_data.roll2 = static_cast<u8>(roll_value >> 8);
|
||||
mplus_data.pitch2 = static_cast<u8>(pitch_value >> 8);
|
||||
}
|
||||
|
||||
mplus_data.extension_connected = is_ext_connected;
|
||||
|
|
|
@ -131,7 +131,8 @@ public:
|
|||
|
||||
static constexpr u16 VALUE_SCALE =
|
||||
(CALIBRATION_SCALE_OFFSET >> (CALIBRATION_BITS - BITS_OF_PRECISION));
|
||||
static constexpr float VALUE_SCALE_DEGREES = VALUE_SCALE / float(MathUtil::TAU) * 360;
|
||||
static constexpr float VALUE_SCALE_DEGREES =
|
||||
VALUE_SCALE / static_cast<float>(MathUtil::TAU) * 360;
|
||||
|
||||
static constexpr float SLOW_SCALE = VALUE_SCALE_DEGREES / CALIBRATION_SLOW_SCALE_DEGREES;
|
||||
static constexpr float FAST_SCALE = VALUE_SCALE_DEGREES / CALIBRATION_FAST_SCALE_DEGREES;
|
||||
|
|
|
@ -77,13 +77,13 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
|||
// 8 bit PCM
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
samples[i] = ((s16)(s8)data[i]) * 0x100;
|
||||
samples[i] = static_cast<s16>(static_cast<s8>(data[i])) * 0x100;
|
||||
}
|
||||
|
||||
// Following details from http://wiibrew.org/wiki/Wiimote#Speaker
|
||||
sample_rate_dividend = 12000000;
|
||||
volume_divisor = 0xff;
|
||||
sample_length = (unsigned int)length;
|
||||
sample_length = static_cast<unsigned int>(length);
|
||||
}
|
||||
else if (reg_data.format == SpeakerLogic::DATA_FORMAT_ADPCM)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
|||
// Following details from http://wiibrew.org/wiki/Wiimote#Speaker
|
||||
sample_rate_dividend = 6000000;
|
||||
volume_divisor = 0x7F;
|
||||
sample_length = (unsigned int)length * 2;
|
||||
sample_length = static_cast<unsigned int>(length) * 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
|||
|
||||
// SetWiimoteSpeakerVolume expects values from 0 to 255.
|
||||
// Multiply by 256, floor to int, and clamp to 255 for a uniformly mapped conversion.
|
||||
const double volume = float(reg_data.volume) * 256.f / volume_divisor;
|
||||
const double volume = static_cast<float>(reg_data.volume) * 256.f / volume_divisor;
|
||||
|
||||
// This used the "Constant Power Pan Law", but it is undesirable
|
||||
// if the pan is 0, and it implied that the loudness of a wiimote speaker
|
||||
|
@ -123,8 +123,8 @@ void SpeakerLogic::SpeakerData(const u8* data, int length, float speaker_pan)
|
|||
// because you can lower their volume from the Wii settings and because they are
|
||||
// already extremely low quality, so any additional quality loss isn't welcome.
|
||||
speaker_pan = std::clamp(speaker_pan, -1.f, 1.f);
|
||||
const u32 l_volume = std::min(u32(std::min(1.f - speaker_pan, 1.f) * volume), 255u);
|
||||
const u32 r_volume = std::min(u32(std::min(1.f + speaker_pan, 1.f) * volume), 255u);
|
||||
const u32 l_volume = std::min(static_cast<u32>(std::min(1.f - speaker_pan, 1.f) * volume), 255u);
|
||||
const u32 r_volume = std::min(static_cast<u32>(std::min(1.f + speaker_pan, 1.f) * volume), 255u);
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
SoundStream* sound_stream = system.GetSoundStream();
|
||||
|
|
|
@ -461,14 +461,14 @@ GetPassthroughCameraPoints(ControllerEmu::IRPassthrough* ir_passthrough)
|
|||
const ControlState y = ir_passthrough->GetObjectPositionY(i);
|
||||
|
||||
camera_points[i].position.x =
|
||||
std::clamp(std::lround(x * ControlState(CameraLogic::CAMERA_RES_X - 1)), long(0),
|
||||
long(CameraLogic::CAMERA_RES_X - 1));
|
||||
std::clamp(std::lround(x * static_cast<ControlState>(CameraLogic::CAMERA_RES_X - 1)),
|
||||
static_cast<long>(0), static_cast<long>(CameraLogic::CAMERA_RES_X - 1));
|
||||
camera_points[i].position.y =
|
||||
std::clamp(std::lround(y * ControlState(CameraLogic::CAMERA_RES_Y - 1)), long(0),
|
||||
long(CameraLogic::CAMERA_RES_Y - 1));
|
||||
std::clamp(std::lround(y * static_cast<ControlState>(CameraLogic::CAMERA_RES_Y - 1)),
|
||||
static_cast<long>(0), static_cast<long>(CameraLogic::CAMERA_RES_Y - 1));
|
||||
camera_points[i].size =
|
||||
std::clamp(std::lround(size * ControlState(CameraLogic::MAX_POINT_SIZE)), long(0),
|
||||
long(CameraLogic::MAX_POINT_SIZE));
|
||||
std::clamp(std::lround(size * static_cast<ControlState>(CameraLogic::MAX_POINT_SIZE)),
|
||||
static_cast<long>(0), static_cast<long>(CameraLogic::MAX_POINT_SIZE));
|
||||
}
|
||||
|
||||
return camera_points;
|
||||
|
@ -506,7 +506,7 @@ void Wiimote::BuildDesiredWiimoteState(DesiredWiimoteState* target_state,
|
|||
target_state->camera_points = CameraLogic::GetCameraPoints(
|
||||
GetTotalTransformation(),
|
||||
Common::Vec2(m_fov_x_setting.GetValue(), m_fov_y_setting.GetValue()) / 360 *
|
||||
float(MathUtil::TAU));
|
||||
static_cast<float>(MathUtil::TAU));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -629,7 +629,7 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
|||
{
|
||||
// This happens when IR reporting is enabled but the camera hardware is disabled.
|
||||
// It commonly occurs when changing IR sensitivity.
|
||||
std::fill_n(ir_data, ir_size, u8(0xff));
|
||||
std::fill_n(ir_data, ir_size, static_cast<u8>(0xff));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,7 +656,7 @@ void Wiimote::SendDataReport(const DesiredWiimoteState& target_state)
|
|||
ExtensionPort::REPORT_I2C_ADDR, ext_size, ext_data))
|
||||
{
|
||||
// Real wiimote seems to fill with 0xff on failed bus read
|
||||
std::fill_n(ext_data, ext_size, u8(0xff));
|
||||
std::fill_n(ext_data, ext_size, static_cast<u8>(0xff));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,8 +870,8 @@ Common::Matrix44 Wiimote::GetTransformation(const Common::Matrix33& extra_rotati
|
|||
|
||||
Common::Quaternion Wiimote::GetOrientation() const
|
||||
{
|
||||
return Common::Quaternion::RotateZ(float(MathUtil::TAU / -4 * IsSideways())) *
|
||||
Common::Quaternion::RotateX(float(MathUtil::TAU / 4 * IsUpright()));
|
||||
return Common::Quaternion::RotateZ(static_cast<float>(MathUtil::TAU / -4 * IsSideways())) *
|
||||
Common::Quaternion::RotateX(static_cast<float>(MathUtil::TAU / 4 * IsUpright()));
|
||||
}
|
||||
|
||||
std::optional<Common::Vec3> Wiimote::OverrideVec3(const ControllerEmu::ControlGroup* control_group,
|
||||
|
@ -943,7 +943,7 @@ Wiimote::OverrideVec3(const ControllerEmu::ControlGroup* control_group, Common::
|
|||
|
||||
Common::Vec3 Wiimote::GetTotalAcceleration() const
|
||||
{
|
||||
const Common::Vec3 default_accel = Common::Vec3(0, 0, float(GRAVITY_ACCELERATION));
|
||||
const Common::Vec3 default_accel = Common::Vec3(0, 0, static_cast<float>(GRAVITY_ACCELERATION));
|
||||
const Common::Vec3 accel = m_imu_accelerometer->GetState().value_or(default_accel);
|
||||
|
||||
return OverrideVec3(m_imu_accelerometer, GetAcceleration(accel));
|
||||
|
|
|
@ -235,7 +235,7 @@ std::wstring GetDeviceProperty(const HDEVINFO& device_info, const PSP_DEVINFO_DA
|
|||
int IOWritePerSetOutputReport(HANDLE& dev_handle, const u8* buf, size_t len, DWORD* written)
|
||||
{
|
||||
const BOOLEAN result =
|
||||
pHidD_SetOutputReport(dev_handle, const_cast<u8*>(buf) + 1, (ULONG)(len - 1));
|
||||
pHidD_SetOutputReport(dev_handle, const_cast<u8*>(buf) + 1, static_cast<ULONG>(len - 1));
|
||||
if (!result)
|
||||
{
|
||||
const DWORD err = GetLastError();
|
||||
|
@ -254,7 +254,7 @@ int IOWritePerSetOutputReport(HANDLE& dev_handle, const u8* buf, size_t len, DWO
|
|||
|
||||
if (written)
|
||||
{
|
||||
*written = (result ? (DWORD)len : 0);
|
||||
*written = (result ? static_cast<DWORD>(len) : 0);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -265,7 +265,7 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
|
|||
{
|
||||
DWORD bytes_written;
|
||||
LPCVOID write_buffer = buf + 1;
|
||||
DWORD bytes_to_write = (DWORD)(len - 1);
|
||||
DWORD bytes_to_write = static_cast<DWORD>(len - 1);
|
||||
|
||||
u8 resized_buffer[MAX_PAYLOAD];
|
||||
|
||||
|
@ -368,7 +368,7 @@ bool GetParentDevice(const DEVINST& child_device_instance, HDEVINFO* parent_devi
|
|||
|
||||
// Get the device id of the parent, required to open the device info
|
||||
result =
|
||||
CM_Get_Device_ID(parent_device, parent_device_id.data(), (ULONG)parent_device_id.size(), 0);
|
||||
CM_Get_Device_ID(parent_device, parent_device_id.data(), static_cast<ULONG>(parent_device_id.size()), 0);
|
||||
if (result != CR_SUCCESS)
|
||||
{
|
||||
return false;
|
||||
|
@ -467,7 +467,7 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
|
|||
Common::ScopeGuard handle_guard{[&dev_handle] { CloseHandle(dev_handle); }};
|
||||
|
||||
u8 buf[MAX_PAYLOAD];
|
||||
u8 const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus), 0};
|
||||
u8 const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT, static_cast<u8>(OutputReportID::RequestStatus), 0};
|
||||
int invalid_report_count = 0;
|
||||
int rc = WriteToHandle(dev_handle, method, req_status_report, sizeof(req_status_report));
|
||||
while (rc > 0)
|
||||
|
@ -476,7 +476,7 @@ bool IsWiimote(const std::basic_string<TCHAR>& device_path, WinWriteMethod& meth
|
|||
if (rc <= 0)
|
||||
break;
|
||||
|
||||
switch (InputReportID(buf[1]))
|
||||
switch (static_cast<InputReportID>(buf[1]))
|
||||
{
|
||||
case InputReportID::Status:
|
||||
return true;
|
||||
|
|
|
@ -27,7 +27,7 @@ static bool IsDeviceUsable(const std::string& device_path)
|
|||
// Some third-party adapters (DolphinBar) always expose all four Wii Remotes as HIDs
|
||||
// even when they are not connected, which causes an endless error loop when we try to use them.
|
||||
// Try to write a report to the device to see if this Wii Remote is really usable.
|
||||
static const u8 report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus), 0};
|
||||
static const u8 report[] = {WR_SET_REPORT | BT_OUTPUT, static_cast<u8>(OutputReportID::RequestStatus), 0};
|
||||
const int result = hid_write(handle, report, sizeof(report));
|
||||
// The DolphinBar uses EPIPE to signal the absence of a Wii Remote connected to this HID.
|
||||
if (result == -1 && errno != EPIPE)
|
||||
|
|
|
@ -184,7 +184,7 @@ void Wiimote::WriteReport(Report rpt)
|
|||
{
|
||||
bool const new_rumble_state = (rpt[2] & 0x1) != 0;
|
||||
|
||||
switch (WiimoteCommon::OutputReportID(rpt[1]))
|
||||
switch (static_cast<WiimoteCommon::OutputReportID>(rpt[1]))
|
||||
{
|
||||
case OutputReportID::Rumble:
|
||||
// If this is a rumble report and the rumble state didn't change, we can drop this report.
|
||||
|
@ -218,7 +218,7 @@ void Wiimote::QueueReport(WiimoteCommon::OutputReportID rpt_id, const void* data
|
|||
|
||||
Report rpt(size + 2);
|
||||
rpt[0] = WR_SET_REPORT | BT_OUTPUT;
|
||||
rpt[1] = u8(rpt_id);
|
||||
rpt[1] = static_cast<u8>(rpt_id);
|
||||
std::copy_n(queue_data, size, rpt.begin() + 2);
|
||||
WriteReport(std::move(rpt));
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ void Wiimote::InterruptDataOutput(const u8* data, const u32 size)
|
|||
|
||||
// Disallow games from turning off all of the LEDs.
|
||||
// It makes Wiimote connection status confusing.
|
||||
if (rpt[1] == u8(OutputReportID::LED))
|
||||
if (rpt[1] == static_cast<u8>(OutputReportID::LED))
|
||||
{
|
||||
auto& leds_rpt = *reinterpret_cast<OutputReportLeds*>(&rpt[2]);
|
||||
if (0 == leds_rpt.leds)
|
||||
|
@ -283,12 +283,12 @@ void Wiimote::InterruptDataOutput(const u8* data, const u32 size)
|
|||
leds_rpt.leds = 0xf;
|
||||
}
|
||||
}
|
||||
else if (rpt[1] == u8(OutputReportID::SpeakerData) &&
|
||||
else if (rpt[1] == static_cast<u8>(OutputReportID::SpeakerData) &&
|
||||
(!m_speaker_enabled_in_dolphin_config || !m_speaker_enable || m_speaker_mute))
|
||||
{
|
||||
rpt.resize(3);
|
||||
// Translate undesired speaker data reports into rumble reports.
|
||||
rpt[1] = u8(OutputReportID::Rumble);
|
||||
rpt[1] = static_cast<u8>(OutputReportID::Rumble);
|
||||
// Keep only the rumble bit.
|
||||
rpt[2] &= 0x1;
|
||||
}
|
||||
|
@ -359,10 +359,10 @@ bool Wiimote::IsBalanceBoard()
|
|||
// Initialise the extension by writing 0x55 to 0xa400f0, then writing 0x00 to 0xa400fb.
|
||||
// TODO: Use the structs for building these reports..
|
||||
static const u8 init_extension_rpt1[MAX_PAYLOAD] = {
|
||||
WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::WriteData), 0x04, 0xa4, 0x00, 0xf0, 0x01, 0x55};
|
||||
WR_SET_REPORT | BT_OUTPUT, static_cast<u8>(OutputReportID::WriteData), 0x04, 0xa4, 0x00, 0xf0, 0x01, 0x55};
|
||||
static const u8 init_extension_rpt2[MAX_PAYLOAD] = {
|
||||
WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::WriteData), 0x04, 0xa4, 0x00, 0xfb, 0x01, 0x00};
|
||||
static const u8 status_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::RequestStatus),
|
||||
WR_SET_REPORT | BT_OUTPUT, static_cast<u8>(OutputReportID::WriteData), 0x04, 0xa4, 0x00, 0xfb, 0x01, 0x00};
|
||||
static const u8 status_report[] = {WR_SET_REPORT | BT_OUTPUT, static_cast<u8>(OutputReportID::RequestStatus),
|
||||
0};
|
||||
if (!IOWrite(init_extension_rpt1, sizeof(init_extension_rpt1)) ||
|
||||
!IOWrite(init_extension_rpt2, sizeof(init_extension_rpt2)))
|
||||
|
@ -379,7 +379,7 @@ bool Wiimote::IsBalanceBoard()
|
|||
if (ret == -1)
|
||||
continue;
|
||||
|
||||
switch (InputReportID(buf[1]))
|
||||
switch (static_cast<InputReportID>(buf[1]))
|
||||
{
|
||||
case InputReportID::Status:
|
||||
{
|
||||
|
@ -389,7 +389,7 @@ bool Wiimote::IsBalanceBoard()
|
|||
return false;
|
||||
// Read two bytes from 0xa400fe to identify the extension.
|
||||
static const u8 identify_ext_rpt[] = {WR_SET_REPORT | BT_OUTPUT,
|
||||
u8(OutputReportID::ReadData),
|
||||
static_cast<u8>(OutputReportID::ReadData),
|
||||
0x04,
|
||||
0xa4,
|
||||
0x00,
|
||||
|
@ -431,7 +431,7 @@ bool Wiimote::IsBalanceBoard()
|
|||
|
||||
static bool IsDataReport(const Report& rpt)
|
||||
{
|
||||
return rpt.size() >= 2 && rpt[1] >= u8(InputReportID::ReportCore);
|
||||
return rpt.size() >= 2 && rpt[1] >= static_cast<u8>(InputReportID::ReportCore);
|
||||
}
|
||||
|
||||
bool Wiimote::GetNextReport(Report* report)
|
||||
|
@ -495,7 +495,7 @@ void Wiimote::Update(const WiimoteEmu::DesiredWiimoteState& target_state)
|
|||
return;
|
||||
|
||||
InterruptCallback(rpt.front(), rpt.data() + REPORT_HID_HEADER_SIZE,
|
||||
u32(rpt.size() - REPORT_HID_HEADER_SIZE));
|
||||
static_cast<u32>(rpt.size() - REPORT_HID_HEADER_SIZE));
|
||||
}
|
||||
|
||||
ButtonData Wiimote::GetCurrentlyPressedButtons()
|
||||
|
@ -503,7 +503,7 @@ ButtonData Wiimote::GetCurrentlyPressedButtons()
|
|||
Report& rpt = m_last_input_report;
|
||||
if (rpt.size() >= 4)
|
||||
{
|
||||
const auto mode = InputReportID(rpt[1]);
|
||||
const auto mode = static_cast<InputReportID>(rpt[1]);
|
||||
|
||||
// TODO: Button data could also be pulled out of non-data reports if really wanted.
|
||||
if (DataReportBuilder::IsValidMode(mode))
|
||||
|
@ -527,12 +527,12 @@ void Wiimote::Prepare()
|
|||
bool Wiimote::PrepareOnThread()
|
||||
{
|
||||
// Set reporting mode to non-continuous core buttons and turn on rumble.
|
||||
u8 static const mode_report[] = {WR_SET_REPORT | BT_OUTPUT, u8(OutputReportID::ReportMode), 1,
|
||||
u8(InputReportID::ReportCore)};
|
||||
u8 static const mode_report[] = {WR_SET_REPORT | BT_OUTPUT, static_cast<u8>(OutputReportID::ReportMode), 1,
|
||||
static_cast<u8>(InputReportID::ReportCore)};
|
||||
|
||||
// Request status and turn off rumble.
|
||||
u8 static const req_status_report[] = {WR_SET_REPORT | BT_OUTPUT,
|
||||
u8(OutputReportID::RequestStatus), 0};
|
||||
static_cast<u8>(OutputReportID::RequestStatus), 0};
|
||||
|
||||
return IOWrite(mode_report, sizeof(mode_report)) &&
|
||||
(Common::SleepCurrentThread(200), IOWrite(req_status_report, sizeof(req_status_report)));
|
||||
|
@ -947,7 +947,7 @@ static bool TryToConnectWiimoteToSlot(std::unique_ptr<Wiimote>& wm, unsigned int
|
|||
|
||||
// Set LEDs.
|
||||
OutputReportLeds led_report = {};
|
||||
led_report.leds = u8(1 << (i % WIIMOTE_BALANCE_BOARD));
|
||||
led_report.leds = static_cast<u8>(1 << (i % WIIMOTE_BALANCE_BOARD));
|
||||
wm->QueueReport(led_report);
|
||||
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ IPCReply GetVersion(Core::System& system, const IOCtlVRequest& request)
|
|||
return IPCReply(IPC_EINVAL);
|
||||
}
|
||||
|
||||
const auto length = std::min(size_t(request.io_vectors[0].size), Common::GetScmDescStr().size());
|
||||
const auto length = std::min(static_cast<size_t>(request.io_vectors[0].size), Common::GetScmDescStr().size());
|
||||
|
||||
auto& memory = system.GetMemory();
|
||||
memory.Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size);
|
||||
|
@ -71,7 +71,7 @@ IPCReply GetCPUSpeed(Core::System& system, const IOCtlVRequest& request)
|
|||
const bool overclock_enabled = Config::Get(Config::MAIN_OVERCLOCK_ENABLE);
|
||||
const float oc = overclock_enabled ? Config::Get(Config::MAIN_OVERCLOCK) : 1.0f;
|
||||
|
||||
const u32 core_clock = u32(float(system.GetSystemTimers().GetTicksPerSecond()) * oc);
|
||||
const u32 core_clock = static_cast<u32>(static_cast<float>(system.GetSystemTimers().GetTicksPerSecond()) * oc);
|
||||
|
||||
auto& memory = system.GetMemory();
|
||||
memory.Write_U32(core_clock, request.io_vectors[0].address);
|
||||
|
@ -114,7 +114,7 @@ IPCReply SetSpeedLimit(Core::System& system, const IOCtlVRequest& request)
|
|||
}
|
||||
|
||||
auto& memory = system.GetMemory();
|
||||
const float speed = float(memory.Read_U32(request.in_vectors[0].address)) / 100.0f;
|
||||
const float speed = static_cast<float>(memory.Read_U32(request.in_vectors[0].address)) / 100.0f;
|
||||
Config::SetCurrent(Config::MAIN_EMULATION_SPEED, speed);
|
||||
|
||||
return IPCReply(IPC_SUCCESS);
|
||||
|
|
|
@ -423,7 +423,7 @@ s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& da
|
|||
return fd.Get();
|
||||
}
|
||||
|
||||
if (fs.Write(fd.Get(), data.data(), u32(data.size()), {}, ticks) != s32(data.size()))
|
||||
if (fs.Write(fd.Get(), data.data(), static_cast<u32>(data.size()), {}, ticks) != static_cast<s32>(data.size()))
|
||||
{
|
||||
ERROR_LOG_FMT(IOS_ES, "Failed to write to temporary file {}", tmp_path);
|
||||
return ES_EIO;
|
||||
|
|
|
@ -189,7 +189,7 @@ FSCore::ScopedFd FSCore::Open(FS::Uid uid, FS::Gid gid, const std::string& path,
|
|||
if (path.size() >= 64)
|
||||
return {this, ConvertResult(ResultCode::Invalid), ticks};
|
||||
|
||||
const u64 fd = ipc_fd.has_value() ? u64(*ipc_fd) : m_next_fd++;
|
||||
const u64 fd = ipc_fd.has_value() ? static_cast<u64>(*ipc_fd) : m_next_fd++;
|
||||
|
||||
if (path == "/dev/fs")
|
||||
{
|
||||
|
@ -386,7 +386,7 @@ s32 FSCore::Write(u64 fd, const u8* data, u32 size, std::optional<u32> ipc_buffe
|
|||
std::optional<IPCReply> FSDevice::Seek(const SeekRequest& request)
|
||||
{
|
||||
return MakeIPCReply([&](Ticks t) {
|
||||
return m_core.Seek(request.fd, request.offset, HLE::FS::SeekMode(request.mode), t);
|
||||
return m_core.Seek(request.fd, request.offset, static_cast<HLE::FS::SeekMode>(request.mode), t);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ bool HostFileSystem::FstEntry::CheckPermission(Uid caller_uid, Gid caller_gid,
|
|||
file_mode = data.modes.owner;
|
||||
else if (data.gid == caller_gid)
|
||||
file_mode = data.modes.group;
|
||||
return (u8(requested_mode) & u8(file_mode)) == u8(requested_mode);
|
||||
return (static_cast<u8>(requested_mode) & static_cast<u8>(file_mode)) == static_cast<u8>(requested_mode);
|
||||
}
|
||||
|
||||
HostFileSystem::HostFileSystem(const std::string& root_path,
|
||||
|
@ -210,7 +210,7 @@ void HostFileSystem::SaveFst()
|
|||
SerializedFstEntry& serialized = to_write.emplace_back();
|
||||
serialized.SetName(entry.name);
|
||||
GetMetadataFields(serialized) = GetMetadataFields(entry.data);
|
||||
serialized.num_children = u32(entry.children.size());
|
||||
serialized.num_children = static_cast<u32>(entry.children.size());
|
||||
for (const FstEntry& child : entry.children)
|
||||
collect(collect, child);
|
||||
};
|
||||
|
@ -343,7 +343,7 @@ void HostFileSystem::DoStateWriteOrMeasure(PointerWrap& p, std::string start_dir
|
|||
}
|
||||
else
|
||||
{
|
||||
u32 size = (u32)entry.size;
|
||||
u32 size = static_cast<u32>(entry.size);
|
||||
p.Do(size);
|
||||
|
||||
File::IOFile handle(entry.physicalName, "rb");
|
||||
|
@ -460,7 +460,7 @@ ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::st
|
|||
return ResultCode::Invalid;
|
||||
}
|
||||
|
||||
if (!is_file && std::ranges::count(path, '/') > int(MaxPathDepth))
|
||||
if (!is_file && std::ranges::count(path, '/') > static_cast<int>(MaxPathDepth))
|
||||
return ResultCode::TooManyPathComponents;
|
||||
|
||||
const auto split_path = SplitPathAndBasename(path);
|
||||
|
@ -676,7 +676,7 @@ Result<std::vector<std::string>> HostFileSystem::ReadDirectory(Uid uid, Gid gid,
|
|||
std::unordered_map<std::string_view, int> sort_keys;
|
||||
sort_keys.reserve(entry->children.size());
|
||||
for (size_t i = 0; i < entry->children.size(); ++i)
|
||||
sort_keys.emplace(entry->children[i].name, int(i));
|
||||
sort_keys.emplace(entry->children[i].name, static_cast<int>(i));
|
||||
|
||||
const auto get_key = [&sort_keys](std::string_view key) {
|
||||
const auto it = sort_keys.find(key);
|
||||
|
|
|
@ -124,7 +124,7 @@ Result<u32> HostFileSystem::ReadBytesFromFile(Fd fd, u8* ptr, u32 count)
|
|||
if (!handle || !handle->host_file->IsOpen())
|
||||
return ResultCode::Invalid;
|
||||
|
||||
if ((u8(handle->mode) & u8(Mode::Read)) == 0)
|
||||
if ((static_cast<u8>(handle->mode) & static_cast<u8>(Mode::Read)) == 0)
|
||||
return ResultCode::AccessDenied;
|
||||
|
||||
const u32 file_size = static_cast<u32>(handle->host_file->GetSize());
|
||||
|
@ -151,7 +151,7 @@ Result<u32> HostFileSystem::WriteBytesToFile(Fd fd, const u8* ptr, u32 count)
|
|||
if (!handle || !handle->host_file->IsOpen())
|
||||
return ResultCode::Invalid;
|
||||
|
||||
if ((u8(handle->mode) & u8(Mode::Write)) == 0)
|
||||
if ((static_cast<u8>(handle->mode) & static_cast<u8>(Mode::Write)) == 0)
|
||||
return ResultCode::AccessDenied;
|
||||
|
||||
// File might be opened twice, need to seek before we read
|
||||
|
|
|
@ -509,9 +509,9 @@ static CertECC MakeBlankEccCert(const std::string& issuer, const std::string& na
|
|||
const u8* private_key, u32 key_id)
|
||||
{
|
||||
CertECC cert{};
|
||||
cert.signature.type = SignatureType(Common::swap32(u32(SignatureType::ECC)));
|
||||
cert.signature.type = static_cast<SignatureType>(Common::swap32(static_cast<u32>(SignatureType::ECC)));
|
||||
issuer.copy(cert.signature.issuer, sizeof(cert.signature.issuer) - 1);
|
||||
cert.header.public_key_type = PublicKeyType(Common::swap32(u32(PublicKeyType::ECC)));
|
||||
cert.header.public_key_type = static_cast<PublicKeyType>(Common::swap32(static_cast<u32>(PublicKeyType::ECC)));
|
||||
name.copy(cert.header.name, sizeof(cert.header.name) - 1);
|
||||
cert.header.id = Common::swap32(key_id);
|
||||
cert.public_key = Common::ec::PrivToPub(private_key);
|
||||
|
|
|
@ -193,7 +193,7 @@ static std::vector<InterfaceRouting> GetSystemInterfaceRouting()
|
|||
if (GetIpForwardTable(nullptr, &forward_table_size, FALSE) == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
forward_table =
|
||||
std::unique_ptr<MIB_IPFORWARDTABLE>((PMIB_IPFORWARDTABLE) operator new(forward_table_size));
|
||||
std::unique_ptr<MIB_IPFORWARDTABLE>(static_cast<PMIB_IPFORWARDTABLE>(operator new(forward_table_size)));
|
||||
}
|
||||
|
||||
DWORD result = GetIpForwardTable(forward_table.get(), &forward_table_size, FALSE);
|
||||
|
@ -354,7 +354,7 @@ static std::optional<DefaultInterface> GetSystemDefaultInterface()
|
|||
DWORD ip_table_size = 0;
|
||||
if (GetIpAddrTable(nullptr, &ip_table_size, FALSE) == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
ip_table = std::unique_ptr<MIB_IPADDRTABLE>((PMIB_IPADDRTABLE) operator new(ip_table_size));
|
||||
ip_table = std::unique_ptr<MIB_IPADDRTABLE>(static_cast<PMIB_IPADDRTABLE>(operator new(ip_table_size)));
|
||||
}
|
||||
|
||||
// find the interface IP used for the default route and use that
|
||||
|
@ -695,7 +695,7 @@ IPCReply NetIPTopDevice::HandleSetSockOptRequest(const IOCtlRequest& request)
|
|||
const u32 optname = memory.Read_U32(request.buffer_in + 8);
|
||||
u32 optlen = memory.Read_U32(request.buffer_in + 0xc);
|
||||
u8 optval[20];
|
||||
optlen = std::min(optlen, (u32)sizeof(optval));
|
||||
optlen = std::min(optlen, static_cast<u32>(sizeof(optval)));
|
||||
memory.CopyFromEmu(optval, request.buffer_in + 0x10, optlen);
|
||||
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
|
@ -1057,7 +1057,7 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque
|
|||
FREE(AdapterAddresses);
|
||||
}
|
||||
|
||||
AdapterAddresses = (PIP_ADAPTER_ADDRESSES)MALLOC(OutBufferLength);
|
||||
AdapterAddresses = static_cast<PIP_ADAPTER_ADDRESSES>(MALLOC(OutBufferLength));
|
||||
if (AdapterAddresses == nullptr)
|
||||
{
|
||||
RetVal = GetLastError();
|
||||
|
@ -1080,10 +1080,10 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque
|
|||
INFO_LOG_FMT(IOS_NET, "Name of valid interface: {}",
|
||||
WStringToUTF8(AdapterList->FriendlyName));
|
||||
INFO_LOG_FMT(IOS_NET, "DNS: {}.{}.{}.{}",
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4]),
|
||||
u8(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]));
|
||||
static_cast<u8>(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]),
|
||||
static_cast<u8>(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[3]),
|
||||
static_cast<u8>(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[4]),
|
||||
static_cast<u8>(AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[5]));
|
||||
address = Common::swap32(
|
||||
*(u32*)(&AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2]));
|
||||
break;
|
||||
|
@ -1295,7 +1295,7 @@ IPCReply NetIPTopDevice::HandleGetAddressInfoRequest(const IOCtlVRequest& reques
|
|||
memory.Write_U32(result_iter->ai_family, addr + 0x04);
|
||||
memory.Write_U32(result_iter->ai_socktype, addr + 0x08);
|
||||
memory.Write_U32(result_iter->ai_protocol, addr + 0x0C);
|
||||
memory.Write_U32((u32)result_iter->ai_addrlen, addr + 0x10);
|
||||
memory.Write_U32(static_cast<u32>(result_iter->ai_addrlen), addr + 0x10);
|
||||
// what to do? where to put? the buffer of 0x834 doesn't allow space for this
|
||||
memory.Write_U32(/*result->ai_cannonname*/ 0, addr + 0x14);
|
||||
|
||||
|
|
|
@ -178,12 +178,12 @@ void NWC24Config::SetChecksum(u32 checksum)
|
|||
|
||||
NWC24CreationStage NWC24Config::CreationStage() const
|
||||
{
|
||||
return NWC24CreationStage(Common::swap32(u32(m_data.creation_stage)));
|
||||
return static_cast<NWC24CreationStage>(Common::swap32(static_cast<u32>(m_data.creation_stage)));
|
||||
}
|
||||
|
||||
void NWC24Config::SetCreationStage(NWC24CreationStage creation_stage)
|
||||
{
|
||||
m_data.creation_stage = NWC24CreationStage(Common::swap32(u32(creation_stage)));
|
||||
m_data.creation_stage = static_cast<NWC24CreationStage>(Common::swap32(static_cast<u32>(creation_stage)));
|
||||
}
|
||||
|
||||
u32 NWC24Config::EnableBooting() const
|
||||
|
|
|
@ -96,7 +96,7 @@ s32 NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, HardwareModel h
|
|||
0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3, 0xC, 0x2, 0x6, 0xE, 0x8, 0x0, 0xA, 0x5,
|
||||
};
|
||||
|
||||
constexpr auto u64_get_byte = [](u64 value, u32 shift) -> u8 { return u8(value >> (shift * 8)); };
|
||||
constexpr auto u64_get_byte = [](u64 value, u32 shift) -> u8 { return static_cast<u8>(value >> (shift * 8)); };
|
||||
|
||||
constexpr auto u64_insert_byte = [](u64 value, u32 shift, u8 byte) -> u64 {
|
||||
const u64 mask = 0x00000000000000FFULL << (shift * 8);
|
||||
|
@ -104,7 +104,7 @@ s32 NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, HardwareModel h
|
|||
return (value & ~mask) | inst;
|
||||
};
|
||||
|
||||
u64 mix_id = (u64{area_code} << 50) | (u64(hardware_model) << 47) | (u64{hollywood_id} << 15) |
|
||||
u64 mix_id = (u64{area_code} << 50) | (static_cast<u64>(hardware_model) << 47) | (u64{hollywood_id} << 15) |
|
||||
(u64{id_ctr} << 10);
|
||||
const u64 mix_id_copy1 = mix_id;
|
||||
|
||||
|
@ -125,7 +125,7 @@ s32 NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, HardwareModel h
|
|||
for (ctr = 0; ctr <= 5; ctr++)
|
||||
{
|
||||
const u8 ret = u64_get_byte(mix_id, ctr);
|
||||
const u8 foobar = u8((u32{table1[(ret >> 4) & 0xF]} << 4) | table1[ret & 0xF]);
|
||||
const u8 foobar = static_cast<u8>((u32{table1[(ret >> 4) & 0xF]} << 4) | table1[ret & 0xF]);
|
||||
mix_id = u64_insert_byte(mix_id, ctr, foobar & 0xff);
|
||||
}
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ std::optional<IPCReply> NetKDRequestDevice::IOCtl(const IOCtlRequest& request)
|
|||
if (!area.empty() && !model.empty())
|
||||
{
|
||||
const u8 area_code = GetAreaCode(area);
|
||||
const u8 id_ctr = u8(m_config.IdGen());
|
||||
const u8 id_ctr = static_cast<u8>(m_config.IdGen());
|
||||
const HardwareModel hardware_model = GetHardwareModel(model);
|
||||
|
||||
const u32 hollywood_id = m_ios.GetIOSC().GetDeviceId();
|
||||
|
@ -1118,7 +1118,7 @@ std::optional<IPCReply> NetKDRequestDevice::IOCtl(const IOCtlRequest& request)
|
|||
WriteReturnValue(memory, NWC24::WC24_ERR_ID_REGISTERED, request.buffer_out);
|
||||
}
|
||||
memory.Write_U64(m_config.Id(), request.buffer_out + 4);
|
||||
memory.Write_U32(u32(m_config.CreationStage()), request.buffer_out + 0xC);
|
||||
memory.Write_U32(static_cast<u32>(m_config.CreationStage()), request.buffer_out + 0xC);
|
||||
break;
|
||||
|
||||
case IOCTL_NWC24_GET_SCHEDULER_STAT:
|
||||
|
|
|
@ -101,7 +101,7 @@ u64 NetKDTimeDevice::GetAdjustedUTC() const
|
|||
if (gm_time.tm_isdst == 1)
|
||||
dst_diff = 3600;
|
||||
|
||||
return u64(s64(emulated_time) + utcdiff - dst_diff);
|
||||
return static_cast<u64>(static_cast<s64>(emulated_time) + utcdiff - dst_diff);
|
||||
}
|
||||
|
||||
void NetKDTimeDevice::SetAdjustedUTC(u64 wii_utc)
|
||||
|
@ -116,6 +116,6 @@ void NetKDTimeDevice::SetAdjustedUTC(u64 wii_utc)
|
|||
if (gm_time.tm_isdst == 1)
|
||||
dst_diff = 3600;
|
||||
|
||||
utcdiff = s64(emulated_time - wii_utc - dst_diff);
|
||||
utcdiff = static_cast<s64>(emulated_time - wii_utc - dst_diff);
|
||||
}
|
||||
} // namespace IOS::HLE
|
||||
|
|
|
@ -1176,8 +1176,8 @@ WiiSockAddrIn WiiSockMan::ToWiiAddrIn(const sockaddr_in& from, socklen_t addrlen
|
|||
{
|
||||
WiiSockAddrIn result;
|
||||
|
||||
result.len = u8(addrlen > sizeof(WiiSockAddrIn) ? sizeof(WiiSockAddrIn) : addrlen);
|
||||
result.family = u8(from.sin_family & 0xFF);
|
||||
result.len = static_cast<u8>(addrlen > sizeof(WiiSockAddrIn) ? sizeof(WiiSockAddrIn) : addrlen);
|
||||
result.family = static_cast<u8>(from.sin_family & 0xFF);
|
||||
result.port = from.sin_port;
|
||||
result.addr.addr = from.sin_addr.s_addr;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ u16 SelectWifiChannel(u16 enabled_channels_mask, u16 current_channel)
|
|||
return next_channel;
|
||||
}
|
||||
// This does not make a lot of sense, but it is what WD does.
|
||||
return u16(enabled_channels[next_channel]);
|
||||
return static_cast<u16>(enabled_channels[next_channel]);
|
||||
}
|
||||
|
||||
u16 MakeNitroAllowedChannelMask(u16 enabled_channels_mask, u16 nitro_mask)
|
||||
|
@ -109,7 +109,7 @@ void NetWDCommandDevice::ProcessRecvRequests()
|
|||
// InvalidFd is returned.
|
||||
if (m_ipc_owner_fd < 0)
|
||||
{
|
||||
result = s32(ResultCode::InvalidFd);
|
||||
result = static_cast<s32>(ResultCode::InvalidFd);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -189,8 +189,8 @@ std::optional<IPCReply> NetWDCommandDevice::Open(const OpenRequest& request)
|
|||
{
|
||||
if (m_ipc_owner_fd < 0)
|
||||
{
|
||||
const auto flags = u32(request.flags);
|
||||
const auto mode = WD::Mode(flags & 0xFFFF);
|
||||
const auto flags = static_cast<u32>(request.flags);
|
||||
const auto mode = static_cast<WD::Mode>(flags & 0xFFFF);
|
||||
const auto buffer_flags = flags & 0x7FFF0000;
|
||||
INFO_LOG_FMT(IOS_NET, "Opening with mode={} buffer_flags={:08x}", mode, buffer_flags);
|
||||
|
||||
|
@ -199,7 +199,7 @@ std::optional<IPCReply> NetWDCommandDevice::Open(const OpenRequest& request)
|
|||
{
|
||||
ERROR_LOG_FMT(IOS_NET, "Unsupported WD operating mode: {}", mode);
|
||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::USES_UNCOMMON_WD_MODE);
|
||||
return IPCReply(s32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<s32>(ResultCode::UnavailableCommand));
|
||||
}
|
||||
|
||||
if (m_target_status == Status::Idle && mode <= WD::Mode::Unknown6)
|
||||
|
@ -216,10 +216,10 @@ std::optional<IPCReply> NetWDCommandDevice::Open(const OpenRequest& request)
|
|||
|
||||
std::optional<IPCReply> NetWDCommandDevice::Close(u32 fd)
|
||||
{
|
||||
if (m_ipc_owner_fd < 0 || fd != u32(m_ipc_owner_fd))
|
||||
if (m_ipc_owner_fd < 0 || fd != static_cast<u32>(m_ipc_owner_fd))
|
||||
{
|
||||
ERROR_LOG_FMT(IOS_NET, "Invalid close attempt.");
|
||||
return IPCReply(u32(ResultCode::InvalidFd));
|
||||
return IPCReply(static_cast<u32>(ResultCode::InvalidFd));
|
||||
}
|
||||
|
||||
INFO_LOG_FMT(IOS_NET, "Closing and resetting status to Idle");
|
||||
|
@ -234,7 +234,7 @@ IPCReply NetWDCommandDevice::SetLinkState(const IOCtlVRequest& request)
|
|||
{
|
||||
const auto* vector = request.GetVector(0);
|
||||
if (!vector || vector->address == 0)
|
||||
return IPCReply(u32(ResultCode::IllegalParameter));
|
||||
return IPCReply(static_cast<u32>(ResultCode::IllegalParameter));
|
||||
|
||||
auto& system = GetSystem();
|
||||
auto& memory = system.GetMemory();
|
||||
|
@ -244,7 +244,7 @@ IPCReply NetWDCommandDevice::SetLinkState(const IOCtlVRequest& request)
|
|||
if (state == 0)
|
||||
{
|
||||
if (!WD::IsValidMode(m_mode))
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
|
||||
m_target_status = Status::Idle;
|
||||
INFO_LOG_FMT(IOS_NET, "WD_SetLinkState: setting target status to {}", m_target_status);
|
||||
|
@ -252,14 +252,14 @@ IPCReply NetWDCommandDevice::SetLinkState(const IOCtlVRequest& request)
|
|||
else
|
||||
{
|
||||
if (state != 1)
|
||||
return IPCReply(u32(ResultCode::IllegalParameter));
|
||||
return IPCReply(static_cast<u32>(ResultCode::IllegalParameter));
|
||||
|
||||
if (!WD::IsValidMode(m_mode))
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
|
||||
const auto target_status = GetTargetStatusForMode(m_mode);
|
||||
if (m_status != target_status && m_info.enabled_channels == 0)
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
|
||||
INFO_LOG_FMT(IOS_NET, "WD_SetLinkState: setting target status to {}", target_status);
|
||||
m_target_status = target_status;
|
||||
|
@ -272,17 +272,17 @@ IPCReply NetWDCommandDevice::GetLinkState(const IOCtlVRequest& request) const
|
|||
{
|
||||
INFO_LOG_FMT(IOS_NET, "WD_GetLinkState called (status={}, mode={})", m_status, m_mode);
|
||||
if (!WD::IsValidMode(m_mode))
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
|
||||
// Contrary to what the name of the ioctl suggests, this returns a boolean, not the current state.
|
||||
return IPCReply(u32(m_status == GetTargetStatusForMode(m_mode)));
|
||||
return IPCReply(static_cast<u32>(m_status == GetTargetStatusForMode(m_mode)));
|
||||
}
|
||||
|
||||
IPCReply NetWDCommandDevice::Disassociate(const IOCtlVRequest& request)
|
||||
{
|
||||
const auto* vector = request.GetVector(0);
|
||||
if (!vector || vector->address == 0)
|
||||
return IPCReply(u32(ResultCode::IllegalParameter));
|
||||
return IPCReply(static_cast<u32>(ResultCode::IllegalParameter));
|
||||
|
||||
auto& system = GetSystem();
|
||||
auto& memory = system.GetMemory();
|
||||
|
@ -296,7 +296,7 @@ IPCReply NetWDCommandDevice::Disassociate(const IOCtlVRequest& request)
|
|||
m_mode != WD::Mode::Unknown6)
|
||||
{
|
||||
ERROR_LOG_FMT(IOS_NET, "WD_Disassociate: cannot disassociate in mode {}", m_mode);
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
}
|
||||
|
||||
const auto target_status = GetTargetStatusForMode(m_mode);
|
||||
|
@ -304,18 +304,18 @@ IPCReply NetWDCommandDevice::Disassociate(const IOCtlVRequest& request)
|
|||
{
|
||||
ERROR_LOG_FMT(IOS_NET, "WD_Disassociate: cannot disassociate in status {} (target {})",
|
||||
m_status, target_status);
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
}
|
||||
|
||||
// TODO: Check the input MAC address and only return 0x80008001 if it is unknown.
|
||||
return IPCReply(u32(ResultCode::IllegalParameter));
|
||||
return IPCReply(static_cast<u32>(ResultCode::IllegalParameter));
|
||||
}
|
||||
|
||||
IPCReply NetWDCommandDevice::GetInfo(const IOCtlVRequest& request) const
|
||||
{
|
||||
const auto* vector = request.GetVector(0);
|
||||
if (!vector || vector->address == 0)
|
||||
return IPCReply(u32(ResultCode::IllegalParameter));
|
||||
return IPCReply(static_cast<u32>(ResultCode::IllegalParameter));
|
||||
|
||||
auto& system = GetSystem();
|
||||
auto& memory = system.GetMemory();
|
||||
|
@ -328,9 +328,9 @@ std::optional<IPCReply> NetWDCommandDevice::IOCtlV(const IOCtlVRequest& request)
|
|||
switch (request.request)
|
||||
{
|
||||
case IOCTLV_WD_INVALID:
|
||||
return IPCReply(u32(ResultCode::UnavailableCommand));
|
||||
return IPCReply(static_cast<u32>(ResultCode::UnavailableCommand));
|
||||
case IOCTLV_WD_GET_MODE:
|
||||
return IPCReply(s32(m_mode));
|
||||
return IPCReply(static_cast<s32>(m_mode));
|
||||
case IOCTLV_WD_SET_LINKSTATE:
|
||||
return SetLinkState(request);
|
||||
case IOCTLV_WD_GET_LINKSTATE:
|
||||
|
@ -362,7 +362,7 @@ std::optional<IPCReply> NetWDCommandDevice::IOCtlV(const IOCtlVRequest& request)
|
|||
|
||||
const char* ssid = "dolphin-emu";
|
||||
strcpy((char*)bss->ssid, ssid);
|
||||
bss->ssid_length = Common::swap16((u16)strlen(ssid));
|
||||
bss->ssid_length = Common::swap16(static_cast<u16>(strlen(ssid)));
|
||||
|
||||
bss->channel = Common::swap16(2);
|
||||
}
|
||||
|
|
|
@ -496,7 +496,7 @@ bool BluetoothEmuDevice::SendEventInquiryResponse()
|
|||
const auto& wiimote = *iter;
|
||||
|
||||
SQueuedEvent event(
|
||||
u32(sizeof(SHCIEventInquiryResult) + num_responses * sizeof(hci_inquiry_response)), 0);
|
||||
static_cast<u32>(sizeof(SHCIEventInquiryResult) + num_responses * sizeof(hci_inquiry_response)), 0);
|
||||
|
||||
const auto inquiry_result = reinterpret_cast<SHCIEventInquiryResult*>(event.buffer);
|
||||
inquiry_result->EventType = HCI_EVENT_INQUIRY_RESULT;
|
||||
|
@ -518,8 +518,8 @@ bool BluetoothEmuDevice::SendEventInquiryResponse()
|
|||
response->bdaddr[5]);
|
||||
|
||||
inquiry_result->PayloadLength =
|
||||
u8(sizeof(SHCIEventInquiryResult) - 2 +
|
||||
(inquiry_result->num_responses * sizeof(hci_inquiry_response)));
|
||||
static_cast<u8>(sizeof(SHCIEventInquiryResult) - 2 +
|
||||
(inquiry_result->num_responses * sizeof(hci_inquiry_response)));
|
||||
|
||||
AddEventToQueue(event);
|
||||
SendEventInquiryComplete(num_responses);
|
||||
|
@ -739,7 +739,7 @@ void BluetoothEmuDevice::SendEventCommandComplete(u16 opcode, const void* data,
|
|||
|
||||
SHCIEventCommand* hci_event = reinterpret_cast<SHCIEventCommand*>(event.buffer);
|
||||
hci_event->EventType = HCI_EVENT_COMMAND_COMPL;
|
||||
hci_event->PayloadLength = (u8)(sizeof(SHCIEventCommand) - 2 + data_size);
|
||||
hci_event->PayloadLength = static_cast<u8>(sizeof(SHCIEventCommand) - 2 + data_size);
|
||||
hci_event->PacketIndicator = 0x01;
|
||||
hci_event->Opcode = opcode;
|
||||
|
||||
|
|
|
@ -802,7 +802,7 @@ void WiimoteDevice::SDPSendServiceSearchResponse(u16 cid, u16 transaction_id,
|
|||
buffer.Write8(offset, 0x00);
|
||||
offset++; // No continuation state;
|
||||
|
||||
header->length = (u16)(offset - sizeof(l2cap_hdr_t));
|
||||
header->length = static_cast<u16>(offset - sizeof(l2cap_hdr_t));
|
||||
m_host->SendACLPacket(GetBD(), data_frame, header->length + sizeof(l2cap_hdr_t));
|
||||
}
|
||||
|
||||
|
@ -892,7 +892,7 @@ void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 transaction_id,
|
|||
memcpy(buffer.GetPointer(offset), packet, packet_size);
|
||||
offset += packet_size;
|
||||
|
||||
header->length = (u16)(offset - sizeof(l2cap_hdr_t));
|
||||
header->length = static_cast<u16>(offset - sizeof(l2cap_hdr_t));
|
||||
m_host->SendACLPacket(GetBD(), data_frame, header->length + sizeof(l2cap_hdr_t));
|
||||
}
|
||||
|
||||
|
@ -994,7 +994,7 @@ void WiimoteDevice::InterruptDataInputCallback(u8 hid_type, const u8* data, u32
|
|||
static_assert(sizeof(data_frame) == sizeof(data_frame.data) + sizeof(u8) + sizeof(l2cap_hdr_t));
|
||||
|
||||
data_frame.header.dcid = channel->remote_cid;
|
||||
data_frame.header.length = u16(sizeof(hid_type) + size);
|
||||
data_frame.header.length = static_cast<u16>(sizeof(hid_type) + size);
|
||||
data_frame.hid_type = hid_type;
|
||||
std::copy_n(data, size, data_frame.data.data());
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue