mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-07 21:49:01 -06:00
Core: Replace usages of StringFromFormat with fmt where applicable
Migrates usages of StringFromFormat over to using fmt.
This commit is contained in:
@ -10,6 +10,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
@ -73,16 +75,16 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
|
||||
{
|
||||
case P_REG:
|
||||
if (settings_.decode_registers)
|
||||
buf += StringFromFormat("$%s", pdregname(val));
|
||||
buf += fmt::format("${}", pdregname(val));
|
||||
else
|
||||
buf += StringFromFormat("$%d", val);
|
||||
buf += fmt::format("${}", val);
|
||||
break;
|
||||
|
||||
case P_PRG:
|
||||
if (settings_.decode_registers)
|
||||
buf += StringFromFormat("@$%s", pdregname(val));
|
||||
buf += fmt::format("@${}", pdregname(val));
|
||||
else
|
||||
buf += StringFromFormat("@$%d", val);
|
||||
buf += fmt::format("@${}", val);
|
||||
break;
|
||||
|
||||
case P_VAL:
|
||||
@ -94,22 +96,27 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
|
||||
}
|
||||
else
|
||||
{
|
||||
buf += StringFromFormat("0x%04x", val);
|
||||
buf += fmt::format("0x{:04x}", val);
|
||||
}
|
||||
break;
|
||||
|
||||
case P_IMM:
|
||||
if (opc.params[j].size != 2)
|
||||
{
|
||||
if (opc.params[j].mask == 0x003f) // LSL, LSR, ASL, ASR
|
||||
buf += StringFromFormat("#%d",
|
||||
(val & 0x20) ? (val | 0xFFFFFFC0) : val); // 6-bit sign extension
|
||||
// LSL, LSR, ASL, ASR
|
||||
if (opc.params[j].mask == 0x003f)
|
||||
{
|
||||
// 6-bit sign extension
|
||||
buf += fmt::format("#{}", (val & 0x20) != 0 ? (val | 0xFFFFFFC0) : val);
|
||||
}
|
||||
else
|
||||
buf += StringFromFormat("#0x%02x", val);
|
||||
{
|
||||
buf += fmt::format("#0x{:02x}", val);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf += StringFromFormat("#0x%04x", val);
|
||||
buf += fmt::format("#0x{:04x}", val);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -118,9 +125,9 @@ std::string DSPDisassembler::DisassembleParameters(const DSPOPCTemplate& opc, u1
|
||||
val = (u16)(s16)(s8)val;
|
||||
|
||||
if (settings_.decode_names)
|
||||
buf += StringFromFormat("@%s", pdname(val));
|
||||
buf += fmt::format("@{}", pdname(val));
|
||||
else
|
||||
buf += StringFromFormat("@0x%04x", val);
|
||||
buf += fmt::format("@0x{:04x}", val);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -174,7 +181,7 @@ bool DSPDisassembler::DisassembleOpcode(const u16* binbuf, u16* pc, std::string&
|
||||
// printing
|
||||
|
||||
if (settings_.show_pc)
|
||||
dest += StringFromFormat("%04x ", *pc);
|
||||
dest += fmt::format("{:04x} ", *pc);
|
||||
|
||||
u16 op2;
|
||||
|
||||
@ -183,25 +190,25 @@ bool DSPDisassembler::DisassembleOpcode(const u16* binbuf, u16* pc, std::string&
|
||||
{
|
||||
op2 = binbuf[(*pc + 1) & 0x0fff];
|
||||
if (settings_.show_hex)
|
||||
dest += StringFromFormat("%04x %04x ", op1, op2);
|
||||
dest += fmt::format("{:04x} {:04x} ", op1, op2);
|
||||
}
|
||||
else
|
||||
{
|
||||
op2 = 0;
|
||||
if (settings_.show_hex)
|
||||
dest += StringFromFormat("%04x ", op1);
|
||||
dest += fmt::format("{:04x} ", op1);
|
||||
}
|
||||
|
||||
std::string opname = opc->name;
|
||||
if (is_extended)
|
||||
opname += StringFromFormat("%c%s", settings_.ext_separator, opc_ext->name);
|
||||
opname += fmt::format("{}{}", settings_.ext_separator, opc_ext->name);
|
||||
if (settings_.lower_case_ops)
|
||||
std::transform(opname.begin(), opname.end(), opname.begin(), ::tolower);
|
||||
|
||||
if (settings_.print_tabs)
|
||||
dest += StringFromFormat("%s\t", opname.c_str());
|
||||
dest += fmt::format("{}\t", opname);
|
||||
else
|
||||
dest += StringFromFormat("%-12s", opname.c_str());
|
||||
dest += fmt::format("{:<12}", opname);
|
||||
|
||||
if (opc->param_count > 0)
|
||||
dest += DisassembleParameters(*opc, op1, op2);
|
||||
|
Reference in New Issue
Block a user