Join declarations and assignments

This commit is contained in:
Dr. Dystopia 2024-08-19 11:12:39 +02:00
parent 4ff5ff2772
commit 69fcf27799
24 changed files with 76 additions and 121 deletions

View File

@ -72,7 +72,7 @@ u64 Timer::GetLocalTimeSinceJan1970()
// std::chrono::current_zone() until 19H1, and other compilers don't even provide support for // std::chrono::current_zone() until 19H1, and other compilers don't even provide support for
// timezone-related parts of chrono. Someday! // timezone-related parts of chrono. Someday!
// see https://bugs.dolphin-emu.org/issues/13007#note-4 // see https://bugs.dolphin-emu.org/issues/13007#note-4
time_t sysTime, tzDiff, tzDST; time_t sysTime, tzDST;
time(&sysTime); time(&sysTime);
tm* gmTime = localtime(&sysTime); tm* gmTime = localtime(&sysTime);
@ -84,7 +84,7 @@ u64 Timer::GetLocalTimeSinceJan1970()
// Lazy way to get local time in sec // Lazy way to get local time in sec
gmTime = gmtime(&sysTime); gmTime = gmtime(&sysTime);
tzDiff = sysTime - mktime(gmTime); time_t tzDiff = sysTime - mktime(gmTime);
return static_cast<u64>(sysTime + tzDiff + tzDST); return static_cast<u64>(sysTime + tzDiff + tzDST);
} }

View File

@ -247,11 +247,9 @@ static u8 verifycode(const u32* codes, u16 size)
static void unscramble1(u32* addr, u32* val) static void unscramble1(u32* addr, u32* val)
{ {
u32 tmp;
*val = std::rotl(*val, 4); *val = std::rotl(*val, 4);
tmp = ((*addr ^ *val) & 0xF0F0F0F0); u32 tmp = ((*addr ^ *val) & 0xF0F0F0F0);
*addr ^= tmp; *addr ^= tmp;
*val = std::rotr((*val ^ tmp), 0x14); *val = std::rotr((*val ^ tmp), 0x14);
@ -274,11 +272,9 @@ static void unscramble1(u32* addr, u32* val)
static void unscramble2(u32* addr, u32* val) static void unscramble2(u32* addr, u32* val)
{ {
u32 tmp;
*val = std::rotr(*val, 1); *val = std::rotr(*val, 1);
tmp = ((*addr ^ *val) & 0xAAAAAAAA); u32 tmp = ((*addr ^ *val) & 0xAAAAAAAA);
*val ^= tmp; *val ^= tmp;
*addr = std::rotr((*addr ^ tmp), 9); *addr = std::rotr((*addr ^ tmp), 9);
@ -302,15 +298,14 @@ static void unscramble2(u32* addr, u32* val)
static void decryptcode(const u32* seeds, u32* code) static void decryptcode(const u32* seeds, u32* code)
{ {
u32 addr, val; u32 addr, val;
u32 tmp, tmp2;
int i = 0; int i = 0;
getcode(code, &addr, &val); getcode(code, &addr, &val);
unscramble1(&addr, &val); unscramble1(&addr, &val);
while (i < 32) while (i < 32)
{ {
tmp = (std::rotr(val, 4) ^ seeds[i++]); u32 tmp = (std::rotr(val, 4) ^ seeds[i++]);
tmp2 = (val ^ seeds[i++]); u32 tmp2 = (val ^ seeds[i++]);
addr ^= (table6[tmp & 0x3F] ^ table4[(tmp >> 8) & 0x3F] ^ table2[(tmp >> 16) & 0x3F] ^ addr ^= (table6[tmp & 0x3F] ^ table4[(tmp >> 8) & 0x3F] ^ table2[(tmp >> 16) & 0x3F] ^
table0[(tmp >> 24) & 0x3F] ^ table7[tmp2 & 0x3F] ^ table5[(tmp2 >> 8) & 0x3F] ^ table0[(tmp >> 24) & 0x3F] ^ table7[tmp2 & 0x3F] ^ table5[(tmp2 >> 8) & 0x3F] ^
table3[(tmp2 >> 16) & 0x3F] ^ table1[(tmp2 >> 24) & 0x3F]); table3[(tmp2 >> 16) & 0x3F] ^ table1[(tmp2 >> 24) & 0x3F]);
@ -417,7 +412,6 @@ static int alphatobin(u32* dst, const std::vector<std::string>& alpha, int size)
int ret = 0; int ret = 0;
int org = size + 1; int org = size + 1;
u32 bin[2]; u32 bin[2];
u8 parity;
for (; size; --size) for (; size; --size)
{ {
@ -439,7 +433,7 @@ static int alphatobin(u32* dst, const std::vector<std::string>& alpha, int size)
// verify parity bit // verify parity bit
int k = 0; int k = 0;
parity = 0; u8 parity = 0;
for (int i = 0; i < 64; i++) for (int i = 0; i < 64; i++)
{ {
if (i == 32) if (i == 32)

View File

@ -276,9 +276,7 @@ char* DSPAssembler::FindBrackets(char* src, char* dst)
s32 len = (s32)strlen(src); s32 len = (s32)strlen(src);
s32 first = -1; s32 first = -1;
s32 count = 0; s32 count = 0;
s32 i, j; for (s32 i = 0, j = 0; i < len; i++)
j = 0;
for (i = 0; i < len; i++)
{ {
if (src[i] == '(') if (src[i] == '(')
{ {

View File

@ -1034,10 +1034,10 @@ void ZeldaAudioRenderer::PrepareFrame()
// Prepare patterns 2/3 - they are not constant unlike 0/1. // Prepare patterns 2/3 - they are not constant unlike 0/1.
s16* pattern2 = m_const_patterns.data() + 2 * 0x40; s16* pattern2 = m_const_patterns.data() + 2 * 0x40;
s32 yn2 = pattern2[0x40 - 2], yn1 = pattern2[0x40 - 1], v; s32 yn2 = pattern2[0x40 - 2], yn1 = pattern2[0x40 - 1];
for (int i = 0; i < 0x40; i += 2) for (int i = 0; i < 0x40; i += 2)
{ {
v = yn2 * yn1 - (pattern2[i] << 16); s32 v = yn2 * yn1 - (pattern2[i] << 16);
yn2 = yn1; yn2 = yn1;
yn1 = pattern2[i]; yn1 = pattern2[i];
pattern2[i] = v >> 16; pattern2[i] = v >> 16;

View File

@ -341,7 +341,6 @@ CEXIETHERNET::BuiltInBBAInterface::TryGetDataFromSocket(StackRef* ref)
void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket& packet) void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket& packet)
{ {
const auto& [hwdata, ip_header, tcp_header, ip_options, tcp_options, data] = packet; const auto& [hwdata, ip_header, tcp_header, ip_options, tcp_options, data] = packet;
sf::IpAddress target;
StackRef* ref = m_network_ref.GetTCPSlot(tcp_header.source_port, tcp_header.destination_port, StackRef* ref = m_network_ref.GetTCPSlot(tcp_header.source_port, tcp_header.destination_port,
std::bit_cast<u32>(ip_header.destination_addr)); std::bit_cast<u32>(ip_header.destination_addr));
const u16 flags = ntohs(tcp_header.properties) & 0xfff; const u16 flags = ntohs(tcp_header.properties) & 0xfff;
@ -395,7 +394,7 @@ void CEXIETHERNET::BuiltInBBAInterface::HandleTCPFrame(const Common::TCPPacket&
ref->ready = false; ref->ready = false;
ref->ip = std::bit_cast<u32>(ip_header.destination_addr); ref->ip = std::bit_cast<u32>(ip_header.destination_addr);
target = sf::IpAddress(ntohl(destination_ip)); sf::IpAddress target = sf::IpAddress(ntohl(destination_ip));
ref->tcp_socket.Connect(target, ntohs(tcp_header.destination_port), m_current_ip); ref->tcp_socket.Connect(target, ntohs(tcp_header.destination_port), m_current_ip);
} }
else else

View File

@ -15,11 +15,10 @@ namespace Win32TAPHelper
bool IsTAPDevice(const TCHAR* guid) bool IsTAPDevice(const TCHAR* guid)
{ {
HKEY netcard_key; HKEY netcard_key;
LONG status;
DWORD len; DWORD len;
int i = 0; int i = 0;
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &netcard_key); LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &netcard_key);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return false; return false;
@ -90,13 +89,12 @@ bool IsTAPDevice(const TCHAR* guid)
bool GetGUIDs(std::vector<std::basic_string<TCHAR>>& guids) bool GetGUIDs(std::vector<std::basic_string<TCHAR>>& guids)
{ {
LONG status;
HKEY control_net_key; HKEY control_net_key;
DWORD len; DWORD len;
DWORD cSubKeys = 0; DWORD cSubKeys = 0;
status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0, KEY_READ | KEY_QUERY_VALUE, LONG status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, NETWORK_CONNECTIONS_KEY, 0,
&control_net_key); KEY_READ | KEY_QUERY_VALUE, &control_net_key);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return false; return false;

View File

@ -37,9 +37,8 @@ CEXIAgp::~CEXIAgp()
std::string path; std::string path;
std::string filename; std::string filename;
std::string ext; std::string ext;
std::string gbapath;
SplitPath(Config::Get(Config::GetInfoForAGPCartPath(m_slot)), &path, &filename, &ext); SplitPath(Config::Get(Config::GetInfoForAGPCartPath(m_slot)), &path, &filename, &ext);
gbapath = path + filename; std::string gbapath = path + filename;
SaveFileFromEEPROM(gbapath + ".sav"); SaveFileFromEEPROM(gbapath + ".sav");
} }

View File

@ -1068,7 +1068,6 @@ bool GCMemcard::Format(const CardFlashId& flash_id, u16 size_mbits, bool shift_j
s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer) std::vector<GCMBlock>& FileBuffer)
{ {
u32 i, j;
u16 chksum = 0xFFFF; u16 chksum = 0xFFFF;
// check for F-Zero GX system file // check for F-Zero GX system file
@ -1089,12 +1088,12 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry&
*(u16*)&FileBuffer[1].m_block[0x0200] = Common::swap16(u16(Common::swap32(serial2) & 0xFFFF)); *(u16*)&FileBuffer[1].m_block[0x0200] = Common::swap16(u16(Common::swap32(serial2) & 0xFFFF));
// calc 16-bit checksum // calc 16-bit checksum
for (i = 0x02; i < 0x8000; i++) for (u32 i = 0x02; i < 0x8000; i++)
{ {
const int block = i / 0x2000; const int block = i / 0x2000;
const int offset = i % 0x2000; const int offset = i % 0x2000;
chksum ^= (FileBuffer[block].m_block[offset] & 0xFF); chksum ^= (FileBuffer[block].m_block[offset] & 0xFF);
for (j = 8; j > 0; j--) for (u32 j = 8; j > 0; j--)
{ {
if (chksum & 1) if (chksum & 1)
chksum = (chksum >> 1) ^ 0x8408; chksum = (chksum >> 1) ^ 0x8408;
@ -1123,7 +1122,6 @@ s32 GCMemcard::FZEROGX_MakeSaveGameValid(const Header& cardheader, const DEntry&
s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry, s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& direntry,
std::vector<GCMBlock>& FileBuffer) std::vector<GCMBlock>& FileBuffer)
{ {
u32 i, j;
u32 chksum; u32 chksum;
u32 crc32LUT[256]; u32 crc32LUT[256];
u32 pso3offset = 0x00; u32 pso3offset = 0x00;
@ -1152,10 +1150,10 @@ s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& dir
*(u32*)&FileBuffer[1].m_block[0x015C] = serial2; *(u32*)&FileBuffer[1].m_block[0x015C] = serial2;
// generate crc32 LUT // generate crc32 LUT
for (i = 0; i < 256; i++) for (u32 i = 0; i < 256; i++)
{ {
chksum = i; chksum = i;
for (j = 8; j > 0; j--) for (u32 j = 8; j > 0; j--)
{ {
if (chksum & 1) if (chksum & 1)
chksum = (chksum >> 1) ^ 0xEDB88320; chksum = (chksum >> 1) ^ 0xEDB88320;
@ -1170,7 +1168,7 @@ s32 GCMemcard::PSO_MakeSaveGameValid(const Header& cardheader, const DEntry& dir
chksum = 0xDEBB20E3; chksum = 0xDEBB20E3;
// calc 32-bit checksum // calc 32-bit checksum
for (i = 0x004C; i < 0x0164 + pso3offset; i++) for (u32 i = 0x004C; i < 0x0164 + pso3offset; i++)
{ {
chksum = ((chksum >> 8) & 0xFFFFFF) ^ crc32LUT[(chksum ^ FileBuffer[1].m_block[i]) & 0xFF]; chksum = ((chksum >> 8) & 0xFFFFFF) ^ crc32LUT[(chksum ^ FileBuffer[1].m_block[i]) & 0xFF];
} }

View File

@ -345,10 +345,9 @@ bool GetParentDevice(const DEVINST& child_device_instance, HDEVINFO* parent_devi
{ {
ULONG status; ULONG status;
ULONG problem_number; ULONG problem_number;
CONFIGRET result;
// Check if that device instance has device node present // Check if that device instance has device node present
result = CM_Get_DevNode_Status(&status, &problem_number, child_device_instance, 0); CONFIGRET result = CM_Get_DevNode_Status(&status, &problem_number, child_device_instance, 0);
if (result != CR_SUCCESS) if (result != CR_SUCCESS)
{ {
return false; return false;

View File

@ -867,8 +867,8 @@ IPCReply NetIPTopDevice::HandleGetInterfaceOptRequest(const IOCtlVRequest& reque
{ {
PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr; PIP_ADAPTER_ADDRESSES AdapterAddresses = nullptr;
ULONG OutBufferLength = 0; ULONG OutBufferLength = 0;
ULONG RetVal = 0, i; ULONG RetVal = 0;
for (i = 0; i < 5; ++i) for (int i = 0; i < 5; ++i)
{ {
RetVal = GetAdaptersAddresses(AF_INET, 0, nullptr, AdapterAddresses, &OutBufferLength); RetVal = GetAdaptersAddresses(AF_INET, 0, nullptr, AdapterAddresses, &OutBufferLength);

View File

@ -597,7 +597,6 @@ InfinityBase::LoadFigure(const std::array<u8, INFINITY_NUM_BLOCKS * INFINITY_BLO
File::IOFile in_file, FigureUIPosition position) File::IOFile in_file, FigureUIPosition position)
{ {
std::lock_guard lock(m_infinity_mutex); std::lock_guard lock(m_infinity_mutex);
u8 order_added;
std::vector<u8> sha1_calc = {SHA1_CONSTANT.begin(), SHA1_CONSTANT.end() - 1}; std::vector<u8> sha1_calc = {SHA1_CONSTANT.begin(), SHA1_CONSTANT.end() - 1};
for (int i = 0; i < 7; i++) for (int i = 0; i < 7; i++)
@ -625,7 +624,7 @@ InfinityBase::LoadFigure(const std::array<u8, INFINITY_NUM_BLOCKS * INFINITY_BLO
figure.order_added = m_figure_order; figure.order_added = m_figure_order;
m_figure_order++; m_figure_order++;
} }
order_added = figure.order_added; u8 order_added = figure.order_added;
FigureBasePosition derived_position = DeriveFigurePosition(position); FigureBasePosition derived_position = DeriveFigurePosition(position);
if (derived_position == FigureBasePosition::Unknown) if (derived_position == FigureBasePosition::Unknown)

View File

@ -1585,10 +1585,9 @@ void NetPlayClient::ThreadFunc()
{ {
INFO_LOG_FMT(NETPLAY, "NetPlayClient starting."); INFO_LOG_FMT(NETPLAY, "NetPlayClient starting.");
Common::QoSSession qos_session;
if (Config::Get(Config::NETPLAY_ENABLE_QOS)) if (Config::Get(Config::NETPLAY_ENABLE_QOS))
{ {
qos_session = Common::QoSSession(m_server); Common::QoSSession qos_session = Common::QoSSession(m_server);
if (qos_session.Successful()) if (qos_session.Successful())
{ {

View File

@ -364,24 +364,21 @@ static void HandleIsThreadAlive()
static void wbe32hex(u8* p, u32 v) static void wbe32hex(u8* p, u32 v)
{ {
u32 i; for (u32 i = 0; i < 8; i++)
for (i = 0; i < 8; i++)
p[i] = Nibble2hex(v >> (28 - 4 * i)); p[i] = Nibble2hex(v >> (28 - 4 * i));
} }
static void wbe64hex(u8* p, u64 v) static void wbe64hex(u8* p, u64 v)
{ {
u32 i; for (u32 i = 0; i < 16; i++)
for (i = 0; i < 16; i++)
p[i] = Nibble2hex(v >> (60 - 4 * i)); p[i] = Nibble2hex(v >> (60 - 4 * i));
} }
static u32 re32hex(u8* p) static u32 re32hex(u8* p)
{ {
u32 i;
u32 res = 0; u32 res = 0;
for (i = 0; i < 8; i++) for (u32 i = 0; i < 8; i++)
res = (res << 4) | Hex2char(p[i]); res = (res << 4) | Hex2char(p[i]);
return res; return res;
@ -389,10 +386,9 @@ static u32 re32hex(u8* p)
static u64 re64hex(u8* p) static u64 re64hex(u8* p)
{ {
u32 i;
u64 res = 0; u64 res = 0;
for (i = 0; i < 16; i++) for (u32 i = 0; i < 16; i++)
res = (res << 4) | Hex2char(p[i]); res = (res << 4) | Hex2char(p[i]);
return res; return res;
@ -404,10 +400,9 @@ static void ReadRegister()
auto& ppc_state = system.GetPPCState(); auto& ppc_state = system.GetPPCState();
static u8 reply[64]; static u8 reply[64];
u32 id;
memset(reply, 0, sizeof reply); memset(reply, 0, sizeof reply);
id = Hex2char(s_cmd_bfr[1]); u32 id = Hex2char(s_cmd_bfr[1]);
if (s_cmd_bfr[2] != '\0') if (s_cmd_bfr[2] != '\0')
{ {
id <<= 4; id <<= 4;
@ -588,11 +583,10 @@ static void ReadRegisters()
static u8 bfr[GDB_BFR_MAX - 4]; static u8 bfr[GDB_BFR_MAX - 4];
u8* bufptr = bfr; u8* bufptr = bfr;
u32 i;
memset(bfr, 0, sizeof bfr); memset(bfr, 0, sizeof bfr);
for (i = 0; i < 32; i++) for (u32 i = 0; i < 32; i++)
{ {
wbe32hex(bufptr + i * 8, ppc_state.gpr[i]); wbe32hex(bufptr + i * 8, ppc_state.gpr[i]);
} }
@ -606,10 +600,9 @@ static void WriteRegisters()
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
auto& ppc_state = system.GetPPCState(); auto& ppc_state = system.GetPPCState();
u32 i;
u8* bufptr = s_cmd_bfr; u8* bufptr = s_cmd_bfr;
for (i = 0; i < 32; i++) for (u32 i = 0; i < 32; i++)
{ {
ppc_state.gpr[i] = re32hex(bufptr + i * 8); ppc_state.gpr[i] = re32hex(bufptr + i * 8);
} }
@ -623,11 +616,9 @@ static void WriteRegister()
auto& system = Core::System::GetInstance(); auto& system = Core::System::GetInstance();
auto& ppc_state = system.GetPPCState(); auto& ppc_state = system.GetPPCState();
u32 id;
u8* bufptr = s_cmd_bfr + 3; u8* bufptr = s_cmd_bfr + 3;
id = Hex2char(s_cmd_bfr[1]); u32 id = Hex2char(s_cmd_bfr[1]);
if (s_cmd_bfr[2] != '=') if (s_cmd_bfr[2] != '=')
{ {
++bufptr; ++bufptr;
@ -808,16 +799,14 @@ static void WriteRegister()
static void ReadMemory(const Core::CPUThreadGuard& guard) static void ReadMemory(const Core::CPUThreadGuard& guard)
{ {
static u8 reply[GDB_BFR_MAX - 4]; static u8 reply[GDB_BFR_MAX - 4];
u32 addr, len;
u32 i;
i = 1; u32 i = 1;
addr = 0; u32 addr = 0;
while (s_cmd_bfr[i] != ',') while (s_cmd_bfr[i] != ',')
addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]); addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]);
i++; i++;
len = 0; u32 len = 0;
while (i < s_cmd_len) while (i < s_cmd_len)
len = (len << 4) | Hex2char(s_cmd_bfr[i++]); len = (len << 4) | Hex2char(s_cmd_bfr[i++]);
INFO_LOG_FMT(GDB_STUB, "gdb: read memory: {:08x} bytes from {:08x}", len, addr); INFO_LOG_FMT(GDB_STUB, "gdb: read memory: {:08x} bytes from {:08x}", len, addr);
@ -838,16 +827,13 @@ static void ReadMemory(const Core::CPUThreadGuard& guard)
static void WriteMemory(const Core::CPUThreadGuard& guard) static void WriteMemory(const Core::CPUThreadGuard& guard)
{ {
u32 addr, len; u32 i = 1;
u32 i; u32 addr = 0;
i = 1;
addr = 0;
while (s_cmd_bfr[i] != ',') while (s_cmd_bfr[i] != ',')
addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]); addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]);
i++; i++;
len = 0; u32 len = 0;
while (s_cmd_bfr[i] != ':') while (s_cmd_bfr[i] != ':')
len = (len << 4) | Hex2char(s_cmd_bfr[i++]); len = (len << 4) | Hex2char(s_cmd_bfr[i++]);
INFO_LOG_FMT(GDB_STUB, "gdb: write memory: {:08x} bytes to {:08x}", len, addr); INFO_LOG_FMT(GDB_STUB, "gdb: write memory: {:08x} bytes to {:08x}", len, addr);
@ -901,14 +887,13 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
static void HandleAddBreakpoint() static void HandleAddBreakpoint()
{ {
u32 type; u32 addr = 0, len = 0;
u32 i, addr = 0, len = 0;
type = Hex2char(s_cmd_bfr[1]); u32 type = Hex2char(s_cmd_bfr[1]);
if (type > NUM_BREAKPOINT_TYPES) if (type > NUM_BREAKPOINT_TYPES)
return SendReply("E01"); return SendReply("E01");
i = 3; u32 i = 3;
while (s_cmd_bfr[i] != ',') while (s_cmd_bfr[i] != ',')
addr = addr << 4 | Hex2char(s_cmd_bfr[i++]); addr = addr << 4 | Hex2char(s_cmd_bfr[i++]);
i++; i++;
@ -923,16 +908,14 @@ static void HandleAddBreakpoint()
static void HandleRemoveBreakpoint() static void HandleRemoveBreakpoint()
{ {
u32 type, addr, len, i; u32 type = Hex2char(s_cmd_bfr[1]);
type = Hex2char(s_cmd_bfr[1]);
if (type > NUM_BREAKPOINT_TYPES) if (type > NUM_BREAKPOINT_TYPES)
return SendReply("E01"); return SendReply("E01");
addr = 0; u32 addr = 0;
len = 0; u32 len = 0;
i = 3; u32 i = 3;
while (s_cmd_bfr[i] != ',') while (s_cmd_bfr[i] != ',')
addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]); addr = (addr << 4) | Hex2char(s_cmd_bfr[i++]);
i++; i++;

View File

@ -576,13 +576,12 @@ void MemoryWidget::ValidateAndPreviewInputValue()
if (!bytes.empty()) if (!bytes.empty())
{ {
QString hex_string;
std::string s; std::string s;
for (const u8 c : bytes) for (const u8 c : bytes)
s.append(fmt::format("{:02x}", c)); s.append(fmt::format("{:02x}", c));
hex_string = QString::fromStdString(s); QString hex_string = QString::fromStdString(s);
int output_length = hex_string.length(); int output_length = hex_string.length();
if (output_length > 16) if (output_length > 16)

View File

@ -530,11 +530,10 @@ void RenderWidget::PassEventToPresenter(const QEvent* event)
const u32 key = static_cast<u32>(key_event->key() & 0x1FF); const u32 key = static_cast<u32>(key_event->key() & 0x1FF);
const char* chars = nullptr; const char* chars = nullptr;
QByteArray utf8;
if (is_down) if (is_down)
{ {
utf8 = key_event->text().toUtf8(); QByteArray utf8 = key_event->text().toUtf8();
if (utf8.size()) if (utf8.size())
chars = utf8.constData(); chars = utf8.constData();

View File

@ -516,9 +516,8 @@ void SkylanderPortalWindow::LoadSelected()
if (file_path.isEmpty()) if (file_path.isEmpty())
{ {
QMessageBox::StandardButton create_file_response; QMessageBox::StandardButton create_file_response = QMessageBox::question(
create_file_response = this, tr("Create Skylander File"),
QMessageBox::question(this, tr("Create Skylander File"),
tr("Skylander not found in this collection. Create new file?"), tr("Skylander not found in this collection. Create new file?"),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);

View File

@ -34,8 +34,7 @@ bool D3DBoundingBox::Initialize()
data.pSysMem = initial_values; data.pSysMem = initial_values;
data.SysMemPitch = NUM_BBOX_VALUES * sizeof(BBoxType); data.SysMemPitch = NUM_BBOX_VALUES * sizeof(BBoxType);
data.SysMemSlicePitch = 0; data.SysMemSlicePitch = 0;
HRESULT hr; HRESULT hr = D3D::device->CreateBuffer(&desc, &data, &m_buffer);
hr = D3D::device->CreateBuffer(&desc, &data, &m_buffer);
ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Buffer: {}", DX11HRWrap(hr)); ASSERT_MSG(VIDEO, SUCCEEDED(hr), "Failed to create BoundingBox Buffer: {}", DX11HRWrap(hr));
if (FAILED(hr)) if (FAILED(hr))
return false; return false;

View File

@ -226,9 +226,8 @@ bool SwapChain::SelectSurfaceFormat()
bool SwapChain::SelectPresentMode() bool SwapChain::SelectPresentMode()
{ {
VkResult res;
u32 mode_count; u32 mode_count;
res = vkGetPhysicalDeviceSurfacePresentModesKHR(g_vulkan_context->GetPhysicalDevice(), m_surface, VkResult res = vkGetPhysicalDeviceSurfacePresentModesKHR(g_vulkan_context->GetPhysicalDevice(), m_surface,
&mode_count, nullptr); &mode_count, nullptr);
if (res != VK_SUCCESS || mode_count == 0) if (res != VK_SUCCESS || mode_count == 0)
{ {

View File

@ -381,7 +381,6 @@ void VKTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
const u32 num_rows = Common::AlignUp(height, block_size) / block_size; const u32 num_rows = Common::AlignUp(height, block_size) / block_size;
const u32 source_pitch = CalculateStrideForFormat(m_config.format, row_length); const u32 source_pitch = CalculateStrideForFormat(m_config.format, row_length);
const u32 upload_size = source_pitch * num_rows; const u32 upload_size = source_pitch * num_rows;
std::unique_ptr<StagingBuffer> temp_buffer;
VkBuffer upload_buffer; VkBuffer upload_buffer;
VkDeviceSize upload_buffer_offset; VkDeviceSize upload_buffer_offset;
@ -409,8 +408,8 @@ void VKTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8*
else else
{ {
// Create a temporary staging buffer that is destroyed after the image is copied. // Create a temporary staging buffer that is destroyed after the image is copied.
temp_buffer = StagingBuffer::Create(STAGING_BUFFER_TYPE_UPLOAD, upload_size, std::unique_ptr<StagingBuffer> temp_buffer = StagingBuffer::Create(
VK_BUFFER_USAGE_TRANSFER_SRC_BIT); STAGING_BUFFER_TYPE_UPLOAD, upload_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT);
if (!temp_buffer || !temp_buffer->Map()) if (!temp_buffer || !temp_buffer->Map())
{ {
PanicAlertFmt("Failed to allocate staging texture for large texture upload."); PanicAlertFmt("Failed to allocate staging texture for large texture upload.");

View File

@ -316,11 +316,10 @@ static inline u32 DecodePixel_IA8(u16 val)
static inline u32 DecodePixel_RGB565(u16 val) static inline u32 DecodePixel_RGB565(u16 val)
{ {
int r, g, b, a; int r = Convert5To8((val >> 11) & 0x1f);
r = Convert5To8((val >> 11) & 0x1f); int g = Convert6To8((val >> 5) & 0x3f);
g = Convert6To8((val >> 5) & 0x3f); int b = Convert5To8((val) & 0x1f);
b = Convert5To8((val)&0x1f); int a = 0xFF;
a = 0xFF;
return r | (g << 8) | (b << 16) | (a << 24); return r | (g << 8) | (b << 16) | (a << 24);
} }

View File

@ -34,11 +34,10 @@ static inline u32 DecodePixel_IA8(u16 val)
static inline u32 DecodePixel_RGB565(u16 val) static inline u32 DecodePixel_RGB565(u16 val)
{ {
int r, g, b, a; int r = Convert5To8((val >> 11) & 0x1f);
r = Convert5To8((val >> 11) & 0x1f); int g = Convert6To8((val >> 5) & 0x3f);
g = Convert6To8((val >> 5) & 0x3f); int b = Convert5To8((val) & 0x1f);
b = Convert5To8((val)&0x1f); int a = 0xFF;
a = 0xFF;
return r | (g << 8) | (b << 16) | (a << 24); return r | (g << 8) | (b << 16) | (a << 24);
} }
@ -410,14 +409,13 @@ static void TexDecoder_DecodeImpl_I8_SSSE3(u32* dst, const u8* src, int width, i
const __m128i mask3210 = _mm_set_epi8(3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0); const __m128i mask3210 = _mm_set_epi8(3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0);
const __m128i mask7654 = _mm_set_epi8(7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4); const __m128i mask7654 = _mm_set_epi8(7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4);
__m128i *quaddst, r, rgba0, rgba1;
// Load 64 bits from `src` into an __m128i with upper 64 bits zeroed: (0000 0000 hgfe dcba) // Load 64 bits from `src` into an __m128i with upper 64 bits zeroed: (0000 0000 hgfe dcba)
r = _mm_loadl_epi64((const __m128i*)(src + 8 * xStep)); __m128i r = _mm_loadl_epi64((const __m128i*)(src + 8 * xStep));
// Shuffle select bytes to expand from (0000 0000 hgfe dcba) to: // Shuffle select bytes to expand from (0000 0000 hgfe dcba) to:
rgba0 = _mm_shuffle_epi8(r, mask3210); // (dddd cccc bbbb aaaa) __m128i rgba0 = _mm_shuffle_epi8(r, mask3210); // (dddd cccc bbbb aaaa)
rgba1 = _mm_shuffle_epi8(r, mask7654); // (hhhh gggg ffff eeee) __m128i rgba1 = _mm_shuffle_epi8(r, mask7654); // (hhhh gggg ffff eeee)
quaddst = (__m128i*)(dst + (y + iy) * width + x); __m128i* quaddst = (__m128i*)(dst + (y + iy) * width + x);
_mm_storeu_si128(quaddst, rgba0); _mm_storeu_si128(quaddst, rgba0);
_mm_storeu_si128(quaddst + 1, rgba1); _mm_storeu_si128(quaddst + 1, rgba1);
} }

View File

@ -33,8 +33,8 @@ void SetCol(VertexLoader* loader, u32 val)
// BARG -> AABBGGRR // BARG -> AABBGGRR
void SetCol4444(VertexLoader* loader, u16 val_) void SetCol4444(VertexLoader* loader, u16 val_)
{ {
u32 col, val = val_; u32 val = val_;
col = val & 0x00F0; // col = 000000R0; u32 col = val & 0x00F0; // col = 000000R0;
col |= (val & 0x000F) << 12; // col |= 0000G000; col |= (val & 0x000F) << 12; // col |= 0000G000;
col |= (val & 0xF000) << 8; // col |= 00B00000; col |= (val & 0xF000) << 8; // col |= 00B00000;
col |= (val & 0x0F00) << 20; // col |= A0000000; col |= (val & 0x0F00) << 20; // col |= A0000000;
@ -58,8 +58,8 @@ void SetCol6666(VertexLoader* loader, u32 val)
// RRRRRGGG GGGBBBBB // RRRRRGGG GGGBBBBB
void SetCol565(VertexLoader* loader, u16 val_) void SetCol565(VertexLoader* loader, u16 val_)
{ {
u32 col, val = val_; u32 val = val_;
col = (val >> 8) & 0x0000F8; u32 col = (val >> 8) & 0x0000F8;
col |= (val << 5) & 0x00FC00; col |= (val << 5) & 0x00FC00;
col |= (val << 19) & 0xF80000; col |= (val << 19) & 0xF80000;
col |= (col >> 5) & 0x070007; col |= (col >> 5) & 0x070007;

View File

@ -70,12 +70,12 @@ TEST(BitSet, Count)
TEST(BitSet, BitOps) TEST(BitSet, BitOps)
{ {
BitSet32 a(3), b(5), c; BitSet32 a(3), b(5);
EXPECT_EQ(BitSet32(7), a | b); EXPECT_EQ(BitSet32(7), a | b);
EXPECT_EQ(BitSet32(6), a ^ b); EXPECT_EQ(BitSet32(6), a ^ b);
EXPECT_EQ(BitSet32(1), a & b); EXPECT_EQ(BitSet32(1), a & b);
EXPECT_EQ(BitSet32(0xfffffffc), ~a); EXPECT_EQ(BitSet32(0xfffffffc), ~a);
c = a; BitSet32 c = a;
c |= b; c |= b;
EXPECT_EQ(BitSet32(7), c); EXPECT_EQ(BitSet32(7), c);
c = a; c = a;

View File

@ -76,9 +76,7 @@ TEST(FileSystem, BasicPathValidity)
TEST(FileSystem, PathSplitting) TEST(FileSystem, PathSplitting)
{ {
SplitPathResult result; SplitPathResult result = {"/shared1", "00000042.app"};
result = {"/shared1", "00000042.app"};
EXPECT_EQ(SplitPathAndBasename("/shared1/00000042.app"), result); EXPECT_EQ(SplitPathAndBasename("/shared1/00000042.app"), result);
result = {"/shared2/sys", "SYSCONF"}; result = {"/shared2/sys", "SYSCONF"};