mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
Merge pull request #8326 from lioncash/fmt
ActionReplay: Make use of fmt where applicable
This commit is contained in:
commit
6282b0d83e
@ -23,7 +23,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstdarg>
|
||||
#include <iterator>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
@ -31,12 +30,13 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "Common/BitUtils.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/ARDecrypt.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
@ -298,7 +298,7 @@ void SaveCodes(IniFile* local_ini, const std::vector<ARCode>& codes)
|
||||
lines.emplace_back("$" + code.name);
|
||||
for (const ActionReplay::AREntry& op : code.ops)
|
||||
{
|
||||
lines.emplace_back(StringFromFormat("%08X %08X", op.cmd_addr, op.value));
|
||||
lines.emplace_back(fmt::format("{:08X} {:08X}", op.cmd_addr, op.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,18 +306,16 @@ void SaveCodes(IniFile* local_ini, const std::vector<ARCode>& codes)
|
||||
local_ini->SetLines("ActionReplay", lines);
|
||||
}
|
||||
|
||||
static void LogInfo(const char* format, ...)
|
||||
static void VLogInfo(std::string_view format, fmt::format_args args)
|
||||
{
|
||||
if (s_disable_logging)
|
||||
return;
|
||||
bool use_internal_log = s_use_internal_log.load(std::memory_order_relaxed);
|
||||
|
||||
const bool use_internal_log = s_use_internal_log.load(std::memory_order_relaxed);
|
||||
if (MAX_LOGLEVEL < LogTypes::LINFO && !use_internal_log)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
std::string text = StringFromFormatV(format, args);
|
||||
va_end(args);
|
||||
std::string text = fmt::vformat(format, args);
|
||||
INFO_LOG(ACTIONREPLAY, "%s", text.c_str());
|
||||
|
||||
if (use_internal_log)
|
||||
@ -327,6 +325,12 @@ static void LogInfo(const char* format, ...)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
static void LogInfo(std::string_view format, const Args&... args)
|
||||
{
|
||||
VLogInfo(format, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
void EnableSelfLogging(bool enable)
|
||||
{
|
||||
s_use_internal_log.store(enable, std::memory_order_relaxed);
|
||||
@ -355,8 +359,8 @@ static bool Subtype_RamWriteAndFill(const ARAddr& addr, const u32 data)
|
||||
{
|
||||
const u32 new_addr = addr.GCAddress();
|
||||
|
||||
LogInfo("Hardware Address: %08x", new_addr);
|
||||
LogInfo("Size: %08x", addr.size);
|
||||
LogInfo("Hardware Address: {:08x}", new_addr);
|
||||
LogInfo("Size: {:08x}", addr.size);
|
||||
|
||||
switch (addr.size)
|
||||
{
|
||||
@ -364,11 +368,11 @@ static bool Subtype_RamWriteAndFill(const ARAddr& addr, const u32 data)
|
||||
{
|
||||
LogInfo("8-bit Write");
|
||||
LogInfo("--------");
|
||||
u32 repeat = data >> 8;
|
||||
const u32 repeat = data >> 8;
|
||||
for (u32 i = 0; i <= repeat; ++i)
|
||||
{
|
||||
PowerPC::HostWrite_U8(data & 0xFF, new_addr + i);
|
||||
LogInfo("Wrote %08x to address %08x", data & 0xFF, new_addr + i);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", data & 0xFF, new_addr + i);
|
||||
}
|
||||
LogInfo("--------");
|
||||
break;
|
||||
@ -378,11 +382,11 @@ static bool Subtype_RamWriteAndFill(const ARAddr& addr, const u32 data)
|
||||
{
|
||||
LogInfo("16-bit Write");
|
||||
LogInfo("--------");
|
||||
u32 repeat = data >> 16;
|
||||
const u32 repeat = data >> 16;
|
||||
for (u32 i = 0; i <= repeat; ++i)
|
||||
{
|
||||
PowerPC::HostWrite_U16(data & 0xFFFF, new_addr + i * 2);
|
||||
LogInfo("Wrote %08x to address %08x", data & 0xFFFF, new_addr + i * 2);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", data & 0xFFFF, new_addr + i * 2);
|
||||
}
|
||||
LogInfo("--------");
|
||||
break;
|
||||
@ -393,7 +397,7 @@ static bool Subtype_RamWriteAndFill(const ARAddr& addr, const u32 data)
|
||||
LogInfo("32-bit Write");
|
||||
LogInfo("--------");
|
||||
PowerPC::HostWrite_U32(data, new_addr);
|
||||
LogInfo("Wrote %08x to address %08x", data, new_addr);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", data, new_addr);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
|
||||
@ -413,8 +417,8 @@ static bool Subtype_WriteToPointer(const ARAddr& addr, const u32 data)
|
||||
const u32 new_addr = addr.GCAddress();
|
||||
const u32 ptr = PowerPC::HostRead_U32(new_addr);
|
||||
|
||||
LogInfo("Hardware Address: %08x", new_addr);
|
||||
LogInfo("Size: %08x", addr.size);
|
||||
LogInfo("Hardware Address: {:08x}", new_addr);
|
||||
LogInfo("Size: {:08x}", addr.size);
|
||||
|
||||
switch (addr.size)
|
||||
{
|
||||
@ -424,11 +428,11 @@ static bool Subtype_WriteToPointer(const ARAddr& addr, const u32 data)
|
||||
LogInfo("--------");
|
||||
const u8 thebyte = data & 0xFF;
|
||||
const u32 offset = data >> 8;
|
||||
LogInfo("Pointer: %08x", ptr);
|
||||
LogInfo("Byte: %08x", thebyte);
|
||||
LogInfo("Offset: %08x", offset);
|
||||
LogInfo("Pointer: {:08x}", ptr);
|
||||
LogInfo("Byte: {:08x}", thebyte);
|
||||
LogInfo("Offset: {:08x}", offset);
|
||||
PowerPC::HostWrite_U8(thebyte, ptr + offset);
|
||||
LogInfo("Wrote %08x to address %08x", thebyte, ptr + offset);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", thebyte, ptr + offset);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
}
|
||||
@ -439,11 +443,11 @@ static bool Subtype_WriteToPointer(const ARAddr& addr, const u32 data)
|
||||
LogInfo("--------");
|
||||
const u16 theshort = data & 0xFFFF;
|
||||
const u32 offset = (data >> 16) << 1;
|
||||
LogInfo("Pointer: %08x", ptr);
|
||||
LogInfo("Byte: %08x", theshort);
|
||||
LogInfo("Offset: %08x", offset);
|
||||
LogInfo("Pointer: {:08x}", ptr);
|
||||
LogInfo("Byte: {:08x}", theshort);
|
||||
LogInfo("Offset: {:08x}", offset);
|
||||
PowerPC::HostWrite_U16(theshort, ptr + offset);
|
||||
LogInfo("Wrote %08x to address %08x", theshort, ptr + offset);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", theshort, ptr + offset);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
}
|
||||
@ -453,7 +457,7 @@ static bool Subtype_WriteToPointer(const ARAddr& addr, const u32 data)
|
||||
LogInfo("Write 32-bit to pointer");
|
||||
LogInfo("--------");
|
||||
PowerPC::HostWrite_U32(data, ptr);
|
||||
LogInfo("Wrote %08x to address %08x", data, ptr);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", data, ptr);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
|
||||
@ -472,8 +476,8 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data)
|
||||
// Used to increment/decrement a value in memory
|
||||
const u32 new_addr = addr.GCAddress();
|
||||
|
||||
LogInfo("Hardware Address: %08x", new_addr);
|
||||
LogInfo("Size: %08x", addr.size);
|
||||
LogInfo("Hardware Address: {:08x}", new_addr);
|
||||
LogInfo("Size: {:08x}", addr.size);
|
||||
|
||||
switch (addr.size)
|
||||
{
|
||||
@ -481,7 +485,7 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data)
|
||||
LogInfo("8-bit Add");
|
||||
LogInfo("--------");
|
||||
PowerPC::HostWrite_U8(PowerPC::HostRead_U8(new_addr) + data, new_addr);
|
||||
LogInfo("Wrote %02x to address %08x", PowerPC::HostRead_U8(new_addr), new_addr);
|
||||
LogInfo("Wrote {:02x} to address {:08x}", PowerPC::HostRead_U8(new_addr), new_addr);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
|
||||
@ -489,7 +493,7 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data)
|
||||
LogInfo("16-bit Add");
|
||||
LogInfo("--------");
|
||||
PowerPC::HostWrite_U16(PowerPC::HostRead_U16(new_addr) + data, new_addr);
|
||||
LogInfo("Wrote %04x to address %08x", PowerPC::HostRead_U16(new_addr), new_addr);
|
||||
LogInfo("Wrote {:04x} to address {:08x}", PowerPC::HostRead_U16(new_addr), new_addr);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
|
||||
@ -497,7 +501,7 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data)
|
||||
LogInfo("32-bit Add");
|
||||
LogInfo("--------");
|
||||
PowerPC::HostWrite_U32(PowerPC::HostRead_U32(new_addr) + data, new_addr);
|
||||
LogInfo("Wrote %08x to address %08x", PowerPC::HostRead_U32(new_addr), new_addr);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", PowerPC::HostRead_U32(new_addr), new_addr);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
|
||||
@ -512,9 +516,9 @@ static bool Subtype_AddCode(const ARAddr& addr, const u32 data)
|
||||
const float fread = read_float + static_cast<float>(data);
|
||||
const u32 newval = Common::BitCast<u32>(fread);
|
||||
PowerPC::HostWrite_U32(newval, new_addr);
|
||||
LogInfo("Old Value %08x", read);
|
||||
LogInfo("Increment %08x", data);
|
||||
LogInfo("New value %08x", newval);
|
||||
LogInfo("Old Value {:08x}", read);
|
||||
LogInfo("Increment {:08x}", data);
|
||||
LogInfo("New value {:08x}", newval);
|
||||
LogInfo("--------");
|
||||
break;
|
||||
}
|
||||
@ -555,11 +559,11 @@ static bool ZeroCode_FillAndSlide(const u32 val_last, const ARAddr& addr, const
|
||||
u32 val = addr;
|
||||
u32 curr_addr = new_addr;
|
||||
|
||||
LogInfo("Current Hardware Address: %08x", new_addr);
|
||||
LogInfo("Size: %08x", addr.size);
|
||||
LogInfo("Write Num: %08x", write_num);
|
||||
LogInfo("Address Increment: %i", addr_incr);
|
||||
LogInfo("Value Increment: %i", val_incr);
|
||||
LogInfo("Current Hardware Address: {:08x}", new_addr);
|
||||
LogInfo("Size: {:08x}", addr.size);
|
||||
LogInfo("Write Num: {:08x}", write_num);
|
||||
LogInfo("Address Increment: {}", addr_incr);
|
||||
LogInfo("Value Increment: {}", s32{val_incr});
|
||||
|
||||
switch (size)
|
||||
{
|
||||
@ -571,10 +575,10 @@ static bool ZeroCode_FillAndSlide(const u32 val_last, const ARAddr& addr, const
|
||||
PowerPC::HostWrite_U8(val & 0xFF, curr_addr);
|
||||
curr_addr += addr_incr;
|
||||
val += val_incr;
|
||||
LogInfo("Write %08x to address %08x", val & 0xFF, curr_addr);
|
||||
LogInfo("Write {:08x} to address {:08x}", val & 0xFF, curr_addr);
|
||||
|
||||
LogInfo("Value Update: %08x", val);
|
||||
LogInfo("Current Hardware Address Update: %08x", curr_addr);
|
||||
LogInfo("Value Update: {:08x}", val);
|
||||
LogInfo("Current Hardware Address Update: {:08x}", curr_addr);
|
||||
}
|
||||
LogInfo("--------");
|
||||
break;
|
||||
@ -585,11 +589,11 @@ static bool ZeroCode_FillAndSlide(const u32 val_last, const ARAddr& addr, const
|
||||
for (int i = 0; i < write_num; ++i)
|
||||
{
|
||||
PowerPC::HostWrite_U16(val & 0xFFFF, curr_addr);
|
||||
LogInfo("Write %08x to address %08x", val & 0xFFFF, curr_addr);
|
||||
LogInfo("Write {:08x} to address {:08x}", val & 0xFFFF, curr_addr);
|
||||
curr_addr += addr_incr * 2;
|
||||
val += val_incr;
|
||||
LogInfo("Value Update: %08x", val);
|
||||
LogInfo("Current Hardware Address Update: %08x", curr_addr);
|
||||
LogInfo("Value Update: {:08x}", val);
|
||||
LogInfo("Current Hardware Address Update: {:08x}", curr_addr);
|
||||
}
|
||||
LogInfo("--------");
|
||||
break;
|
||||
@ -600,11 +604,11 @@ static bool ZeroCode_FillAndSlide(const u32 val_last, const ARAddr& addr, const
|
||||
for (int i = 0; i < write_num; ++i)
|
||||
{
|
||||
PowerPC::HostWrite_U32(val, curr_addr);
|
||||
LogInfo("Write %08x to address %08x", val, curr_addr);
|
||||
LogInfo("Write {:08x} to address {:08x}", val, curr_addr);
|
||||
curr_addr += addr_incr * 4;
|
||||
val += val_incr;
|
||||
LogInfo("Value Update: %08x", val);
|
||||
LogInfo("Current Hardware Address Update: %08x", curr_addr);
|
||||
LogInfo("Value Update: {:08x}", val);
|
||||
LogInfo("Current Hardware Address Update: {:08x}", curr_addr);
|
||||
}
|
||||
LogInfo("--------");
|
||||
break;
|
||||
@ -628,9 +632,9 @@ static bool ZeroCode_MemoryCopy(const u32 val_last, const ARAddr& addr, const u3
|
||||
|
||||
const u8 num_bytes = data & 0x7FFF;
|
||||
|
||||
LogInfo("Dest Address: %08x", addr_dest);
|
||||
LogInfo("Src Address: %08x", addr_src);
|
||||
LogInfo("Size: %08x", num_bytes);
|
||||
LogInfo("Dest Address: {:08x}", addr_dest);
|
||||
LogInfo("Src Address: {:08x}", addr_src);
|
||||
LogInfo("Size: {:08x}", num_bytes);
|
||||
|
||||
if ((data & 0xFF0000) == 0)
|
||||
{
|
||||
@ -639,13 +643,13 @@ static bool ZeroCode_MemoryCopy(const u32 val_last, const ARAddr& addr, const u3
|
||||
LogInfo("Memory Copy With Pointers Support");
|
||||
LogInfo("--------");
|
||||
const u32 ptr_dest = PowerPC::HostRead_U32(addr_dest);
|
||||
LogInfo("Resolved Dest Address to: %08x", ptr_dest);
|
||||
LogInfo("Resolved Dest Address to: {:08x}", ptr_dest);
|
||||
const u32 ptr_src = PowerPC::HostRead_U32(addr_src);
|
||||
LogInfo("Resolved Src Address to: %08x", ptr_src);
|
||||
LogInfo("Resolved Src Address to: {:08x}", ptr_src);
|
||||
for (int i = 0; i < num_bytes; ++i)
|
||||
{
|
||||
PowerPC::HostWrite_U8(PowerPC::HostRead_U8(ptr_src + i), ptr_dest + i);
|
||||
LogInfo("Wrote %08x to address %08x", PowerPC::HostRead_U8(ptr_src + i), ptr_dest + i);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", PowerPC::HostRead_U8(ptr_src + i), ptr_dest + i);
|
||||
}
|
||||
LogInfo("--------");
|
||||
}
|
||||
@ -656,7 +660,8 @@ static bool ZeroCode_MemoryCopy(const u32 val_last, const ARAddr& addr, const u3
|
||||
for (int i = 0; i < num_bytes; ++i)
|
||||
{
|
||||
PowerPC::HostWrite_U8(PowerPC::HostRead_U8(addr_src + i), addr_dest + i);
|
||||
LogInfo("Wrote %08x to address %08x", PowerPC::HostRead_U8(addr_src + i), addr_dest + i);
|
||||
LogInfo("Wrote {:08x} to address {:08x}", PowerPC::HostRead_U8(addr_src + i),
|
||||
addr_dest + i);
|
||||
}
|
||||
LogInfo("--------");
|
||||
return true;
|
||||
@ -754,8 +759,8 @@ static bool ConditionalCode(const ARAddr& addr, const u32 data, int* const pSkip
|
||||
{
|
||||
const u32 new_addr = addr.GCAddress();
|
||||
|
||||
LogInfo("Size: %08x", addr.size);
|
||||
LogInfo("Hardware Address: %08x", new_addr);
|
||||
LogInfo("Size: {:08x}", addr.size);
|
||||
LogInfo("Hardware Address: {:08x}", new_addr);
|
||||
|
||||
bool result = true;
|
||||
|
||||
@ -824,8 +829,8 @@ static bool RunCodeLocked(const ARCode& arcode)
|
||||
|
||||
s_current_code = &arcode;
|
||||
|
||||
LogInfo("Code Name: %s", arcode.name.c_str());
|
||||
LogInfo("Number of codes: %zu", arcode.ops.size());
|
||||
LogInfo("Code Name: {}", arcode.name);
|
||||
LogInfo("Number of codes: {}", arcode.ops.size());
|
||||
|
||||
for (const AREntry& entry : arcode.ops)
|
||||
{
|
||||
@ -857,8 +862,7 @@ static bool RunCodeLocked(const ARCode& arcode)
|
||||
continue;
|
||||
}
|
||||
|
||||
LogInfo("--- Running Code: %08x %08x ---", addr.address, data);
|
||||
// LogInfo("Command: %08x", cmd);
|
||||
LogInfo("--- Running Code: {:08x} {:08x} ---", addr.address, data);
|
||||
|
||||
// Do Fill & Slide
|
||||
if (do_fill_and_slide)
|
||||
@ -900,7 +904,7 @@ static bool RunCodeLocked(const ARCode& arcode)
|
||||
{
|
||||
const u8 zcode = data >> 29;
|
||||
|
||||
LogInfo("Doing Zero Code %08x", zcode);
|
||||
LogInfo("Doing Zero Code {:08x}", zcode);
|
||||
|
||||
switch (zcode)
|
||||
{
|
||||
@ -948,8 +952,8 @@ static bool RunCodeLocked(const ARCode& arcode)
|
||||
}
|
||||
|
||||
// Normal codes
|
||||
LogInfo("Doing Normal Code %08x", addr.type);
|
||||
LogInfo("Subtype: %08x", addr.subtype);
|
||||
LogInfo("Doing Normal Code {:08x}", addr.type);
|
||||
LogInfo("Subtype: {:08x}", addr.subtype);
|
||||
|
||||
switch (addr.type)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user