@@ -14,7 +14,7 @@ namespace DSP::HLE
{
CARDUCode::CARDUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
{
INFO_LOG(DSPHLE, "CARDUCode - initialized");
INFO_LOG_FMT(DSPHLE, "CARDUCode - initialized");
}

CARDUCode::~CARDUCode()
@@ -44,7 +44,7 @@ void CARDUCode::HandleMail(u32 mail)
}
else
{
WARN_LOG(DSPHLE, "CARDUCode - unknown command: %x", mail);
WARN_LOG_FMT(DSPHLE, "CARDUCode - unknown command: {:x}", mail);
}

m_mail_handler.PushMail(DSP_DONE);
@@ -64,10 +64,10 @@ void ProcessGBACrypto(u32 address)
HLEMemory_Write_U32(dest_addr + 4, t3);

// Done!
DEBUG_LOG(DSPHLE,
"\n%08x -> challenge: %08x, len: %08x, dest_addr: %08x, "
"palette: %08x, speed: %08x key: %08x, auth_code: %08x",
address, challenge, length, dest_addr, logo_palette, logo_speed_32, key, t3);
DEBUG_LOG_FMT(DSPHLE,
"\n{:08x} -> challenge: {:08x}, len: {:08x}, dest_addr: {:08x}, "
"palette: {:08x}, speed: {:08x} key: {:08x}, auth_code: {:08x}",
address, challenge, length, dest_addr, logo_palette, logo_speed_32, key, t3);
}

GBAUCode::GBAUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
@@ -126,13 +126,13 @@ void GBAUCode::HandleMail(u32 mail)
m_dsphle->SetUCode(UCODE_ROM);
break;
default:
WARN_LOG(DSPHLE, "GBAUCode - unknown 0xcdd1 command: %08x", mail);
WARN_LOG_FMT(DSPHLE, "GBAUCode - unknown 0xcdd1 command: {:08x}", mail);
break;
}
}
else
{
WARN_LOG(DSPHLE, "GBAUCode - unknown command: %08x", mail);
WARN_LOG_FMT(DSPHLE, "GBAUCode - unknown command: {:08x}", mail);
}
}
} // namespace DSP::HLE
@@ -14,7 +14,7 @@ namespace DSP::HLE
{
INITUCode::INITUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
{
INFO_LOG(DSPHLE, "INITUCode - initialized");
INFO_LOG_FMT(DSPHLE, "INITUCode - initialized");
}

INITUCode::~INITUCode()
@@ -25,7 +25,7 @@ namespace DSP::HLE
ROMUCode::ROMUCode(DSPHLE* dsphle, u32 crc)
: UCodeInterface(dsphle, crc), m_current_ucode(), m_boot_task_num_steps(0), m_next_parameter(0)
{
INFO_LOG(DSPHLE, "UCode_Rom - initialized");
INFO_LOG_FMT(DSPHLE, "UCode_Rom - initialized");
}

ROMUCode::~ROMUCode()
@@ -73,8 +73,8 @@ void ROMUCode::HandleMail(u32 mail)
m_current_ucode.m_dmem_length = mail & 0xffff;
if (m_current_ucode.m_dmem_length)
{
NOTICE_LOG(DSPHLE, "m_current_ucode.m_dmem_length = 0x%04x.",
m_current_ucode.m_dmem_length);
NOTICE_LOG_FMT(DSPHLE, "m_current_ucode.m_dmem_length = {:#06x}.",
m_current_ucode.m_dmem_length);
}
break;

@@ -109,13 +109,13 @@ void ROMUCode::BootUCode()
m_current_ucode.m_length, ector_crc);
}

INFO_LOG(DSPHLE, "CurrentUCode SOURCE Addr: 0x%08x", m_current_ucode.m_ram_address);
INFO_LOG(DSPHLE, "CurrentUCode Length: 0x%08x", m_current_ucode.m_length);
INFO_LOG(DSPHLE, "CurrentUCode DEST Addr: 0x%08x", m_current_ucode.m_imem_address);
INFO_LOG(DSPHLE, "CurrentUCode DMEM Length: 0x%08x", m_current_ucode.m_dmem_length);
INFO_LOG(DSPHLE, "CurrentUCode init_vector: 0x%08x", m_current_ucode.m_start_pc);
INFO_LOG(DSPHLE, "CurrentUCode CRC: 0x%08x", ector_crc);
INFO_LOG(DSPHLE, "BootTask - done");
INFO_LOG_FMT(DSPHLE, "CurrentUCode SOURCE Addr: {:#010x}", m_current_ucode.m_ram_address);
INFO_LOG_FMT(DSPHLE, "CurrentUCode Length: {:#010x}", m_current_ucode.m_length);
INFO_LOG_FMT(DSPHLE, "CurrentUCode DEST Addr: {:#010x}", m_current_ucode.m_imem_address);
INFO_LOG_FMT(DSPHLE, "CurrentUCode DMEM Length: {:#010x}", m_current_ucode.m_dmem_length);
INFO_LOG_FMT(DSPHLE, "CurrentUCode init_vector: {:#010x}", m_current_ucode.m_start_pc);
INFO_LOG_FMT(DSPHLE, "CurrentUCode CRC: {:#010x}", ector_crc);
INFO_LOG_FMT(DSPHLE, "BootTask - done");

m_dsphle->SetUCode(ector_crc);
}
@@ -190,22 +190,22 @@ void UCodeInterface::PrepareBootUCode(u32 mail)
ector_crc);
}

DEBUG_LOG(DSPHLE, "PrepareBootUCode 0x%08x", ector_crc);
DEBUG_LOG(DSPHLE, "DRAM -> MRAM: src %04x dst %08x size %04x", m_next_ucode.mram_dram_addr,
m_next_ucode.mram_dest_addr, m_next_ucode.mram_size);
DEBUG_LOG(DSPHLE, "MRAM -> IRAM: src %08x dst %04x size %04x startpc %04x",
m_next_ucode.iram_mram_addr, m_next_ucode.iram_dest, m_next_ucode.iram_size,
m_next_ucode.iram_startpc);
DEBUG_LOG(DSPHLE, "MRAM -> DRAM: src %08x dst %04x size %04x", m_next_ucode.dram_mram_addr,
m_next_ucode.dram_dest, m_next_ucode.dram_size);
DEBUG_LOG_FMT(DSPHLE, "PrepareBootUCode {:#010x}", ector_crc);
DEBUG_LOG_FMT(DSPHLE, "DRAM -> MRAM: src {:04x} dst {:08x} size {:04x}",
m_next_ucode.mram_dram_addr, m_next_ucode.mram_dest_addr, m_next_ucode.mram_size);
DEBUG_LOG_FMT(DSPHLE, "MRAM -> IRAM: src {:08x} dst {:04x} size {:04x} startpc {:04x}",
m_next_ucode.iram_mram_addr, m_next_ucode.iram_dest, m_next_ucode.iram_size,
m_next_ucode.iram_startpc);
DEBUG_LOG_FMT(DSPHLE, "MRAM -> DRAM: src {:08x} dst {:04x} size {:04x}",
m_next_ucode.dram_mram_addr, m_next_ucode.dram_dest, m_next_ucode.dram_size);

if (m_next_ucode.mram_size)
{
WARN_LOG(DSPHLE, "Trying to boot new ucode with DRAM download - not implemented");
WARN_LOG_FMT(DSPHLE, "Trying to boot new ucode with DRAM download - not implemented");
}
if (m_next_ucode.dram_size)
{
WARN_LOG(DSPHLE, "Trying to boot new ucode with DRAM upload - not implemented");
WARN_LOG_FMT(DSPHLE, "Trying to boot new ucode with DRAM upload - not implemented");
}

m_dsphle->SwapUCode(ector_crc);
@@ -225,19 +225,19 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
switch (crc)
{
case UCODE_ROM:
INFO_LOG(DSPHLE, "Switching to ROM ucode");
INFO_LOG_FMT(DSPHLE, "Switching to ROM ucode");
return std::make_unique<ROMUCode>(dsphle, crc);

case UCODE_INIT_AUDIO_SYSTEM:
INFO_LOG(DSPHLE, "Switching to INIT ucode");
INFO_LOG_FMT(DSPHLE, "Switching to INIT ucode");
return std::make_unique<INITUCode>(dsphle, crc);

case 0x65d6cc6f: // CARD
INFO_LOG(DSPHLE, "Switching to CARD ucode");
INFO_LOG_FMT(DSPHLE, "Switching to CARD ucode");
return std::make_unique<CARDUCode>(dsphle, crc);

case 0xdd7e72d5:
INFO_LOG(DSPHLE, "Switching to GBA ucode");
INFO_LOG_FMT(DSPHLE, "Switching to GBA ucode");
return std::make_unique<GBAUCode>(dsphle, crc);

case 0x3ad3b7ac: // Naruto 3, Paper Mario - The Thousand Year Door
@@ -252,7 +252,7 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
// Zelda:OOT, Tony Hawk, Viewtiful Joe
case 0xe2136399: // Billy Hatcher, Dragon Ball Z, Mario Party 5, TMNT, 1080° Avalanche
case 0x3389a79e: // MP1/MP2 Wii (Metroid Prime Trilogy)
INFO_LOG(DSPHLE, "CRC %08x: AX ucode chosen", crc);
INFO_LOG_FMT(DSPHLE, "CRC {:08x}: AX ucode chosen", crc);
return std::make_unique<AXUCode>(dsphle, crc);

case 0x86840740: // Zelda WW - US
@@ -277,24 +277,26 @@ std::unique_ptr<UCodeInterface> UCodeFactory(u32 crc, DSPHLE* dsphle, bool wii)
case 0xadbc06bd: // Elebits
case 0x4cc52064: // Bleach: Versus Crusade
case 0xd9c4bf34: // WiiMenu
INFO_LOG(DSPHLE, "CRC %08x: Wii - AXWii chosen", crc);
INFO_LOG_FMT(DSPHLE, "CRC {:08x}: Wii - AXWii chosen", crc);
return std::make_unique<AXWiiUCode>(dsphle, crc);

default:
if (wii)
{
PanicAlertT("This title might be incompatible with DSP HLE emulation. Try using LLE if this "
"is homebrew.\n\n"
"Unknown ucode (CRC = %08x) - forcing AXWii.",
crc);
PanicAlertFmtT(
"This title might be incompatible with DSP HLE emulation. Try using LLE if this "
"is homebrew.\n\n"
"Unknown ucode (CRC = {0:08x}) - forcing AXWii.",
crc);
return std::make_unique<AXWiiUCode>(dsphle, crc);
}
else
{
PanicAlertT("This title might be incompatible with DSP HLE emulation. Try using LLE if this "
"is homebrew.\n\n"
"DSPHLE: Unknown ucode (CRC = %08x) - forcing AX.",
crc);
PanicAlertFmtT(
"This title might be incompatible with DSP HLE emulation. Try using LLE if this "
"is homebrew.\n\n"
"DSPHLE: Unknown ucode (CRC = {0:08x}) - forcing AX.",
crc);
return std::make_unique<AXUCode>(dsphle, crc);
}

@@ -119,12 +119,12 @@ ZeldaUCode::ZeldaUCode(DSPHLE* dsphle, u32 crc) : UCodeInterface(dsphle, crc)
{
auto it = UCODE_FLAGS.find(crc);
if (it == UCODE_FLAGS.end())
PanicAlert("No flags definition found for Zelda CRC %08x", crc);
PanicAlertFmt("No flags definition found for Zelda CRC {:08x}", crc);

m_flags = it->second;
m_renderer.SetFlags(m_flags);

INFO_LOG(DSPHLE, "Zelda UCode loaded, crc=%08x, flags=%08x", crc, m_flags);
INFO_LOG_FMT(DSPHLE, "Zelda UCode loaded, crc={:08x}, flags={:08x}", crc, m_flags);
}

ZeldaUCode::~ZeldaUCode()
@@ -202,21 +202,21 @@ void ZeldaUCode::HandleMailDefault(u32 mail)
{
if ((mail >> 16) != 0xCDD1)
{
PanicAlert("Rendering end mail without prefix CDD1: %08x", mail);
PanicAlertFmt("Rendering end mail without prefix CDD1: {:08x}", mail);
}

switch (mail & 0xFFFF)
{
case 1:
m_cmd_can_execute = true;
RunPendingCommands();
NOTICE_LOG(DSPHLE, "UCode being replaced.");
NOTICE_LOG_FMT(DSPHLE, "UCode being replaced.");
m_upload_setup_in_progress = true;
SetMailState(MailState::WAITING);
break;

case 2:
NOTICE_LOG(DSPHLE, "UCode being rebooted to ROM.");
NOTICE_LOG_FMT(DSPHLE, "UCode being rebooted to ROM.");
SetMailState(MailState::HALTED);
m_dsphle->SetUCode(UCODE_ROM);
break;
@@ -227,9 +227,10 @@ void ZeldaUCode::HandleMailDefault(u32 mail)
break;

default:
NOTICE_LOG(DSPHLE, "Unknown end rendering action. Halting.");
NOTICE_LOG_FMT(DSPHLE, "Unknown end rendering action. Halting.");
[[fallthrough]];
case 0:
NOTICE_LOG(DSPHLE, "UCode asked to halt. Stopping any processing.");
NOTICE_LOG_FMT(DSPHLE, "UCode asked to halt. Stopping any processing.");
SetMailState(MailState::HALTED);
break;
}
@@ -242,8 +243,8 @@ void ZeldaUCode::HandleMailDefault(u32 mail)
}
else
{
NOTICE_LOG(DSPHLE, "Sync mail (%08x) received when rendering was not active. Halting.",
mail);
NOTICE_LOG_FMT(DSPHLE,
"Sync mail ({:08x}) received when rendering was not active. Halting.", mail);
SetMailState(MailState::HALTED);
}
}
@@ -290,7 +291,7 @@ void ZeldaUCode::HandleMailDefault(u32 mail)
break;

case MailState::HALTED:
WARN_LOG(DSPHLE, "Received mail %08x while we're halted.", mail);
WARN_LOG_FMT(DSPHLE, "Received mail {:08x} while we're halted.", mail);
break;
}
}
@@ -302,8 +303,8 @@ void ZeldaUCode::HandleMailLight(u32 mail)
switch (m_mail_current_state)
{
case MailState::WAITING:
if (!(mail & 0x80000000))
PanicAlert("Mail received in waiting state has MSB=0: %08x", mail);
if ((mail & 0x80000000) == 0)
PanicAlertFmt("Mail received in waiting state has MSB=0: {:08x}", mail);

// Start of a command. We have to hardcode the number of mails required
// for each command - the alternative is to rewrite command handling as
@@ -336,7 +337,7 @@ void ZeldaUCode::HandleMailLight(u32 mail)
break;

default:
PanicAlert("Received unknown command in light protocol: %08x", mail);
PanicAlertFmt("Received unknown command in light protocol: {:08x}", mail);
break;
}
if (m_mail_expected_cmd_mails)
@@ -362,7 +363,7 @@ void ZeldaUCode::HandleMailLight(u32 mail)

case MailState::RENDERING:
if (mail != 0)
PanicAlert("Sync mail is not zero: %08x", mail);
PanicAlertFmt("Sync mail is not zero: {:08x}", mail);

// No per-voice syncing in the light protocol.
m_sync_max_voice_id = 0xFFFFFFFF;
@@ -372,22 +373,21 @@ void ZeldaUCode::HandleMailLight(u32 mail)
break;

case MailState::HALTED:
WARN_LOG(DSPHLE, "Received mail %08x while we're halted.", mail);
WARN_LOG_FMT(DSPHLE, "Received mail {:08x} while we're halted.", mail);
break;
}
}

void ZeldaUCode::SetMailState(MailState new_state)
{
// WARN_LOG(DSPHLE, "MailState %d -> %d", m_mail_current_state, new_state);
m_mail_current_state = new_state;
}

u32 ZeldaUCode::Read32()
{
if (m_read_offset == m_write_offset)
{
ERROR_LOG(DSPHLE, "Reading too many command params");
ERROR_LOG_FMT(DSPHLE, "Reading too many command params");
return 0;
}

@@ -413,13 +413,13 @@ void ZeldaUCode::RunPendingCommands()

while (m_pending_commands_count)
{
u32 cmd_mail = Read32();
if (!(cmd_mail & 0x80000000))
const u32 cmd_mail = Read32();
if ((cmd_mail & 0x80000000) == 0)
continue;

u32 command = (cmd_mail >> 24) & 0x7f;
u32 sync = cmd_mail >> 16;
u32 extra_data = cmd_mail & 0xFFFF;
const u32 command = (cmd_mail >> 24) & 0x7f;
const u32 sync = cmd_mail >> 16;
const u32 extra_data = cmd_mail & 0xFFFF;

m_pending_commands_count--;

@@ -431,7 +431,7 @@ void ZeldaUCode::RunPendingCommands()
case 0x0F:
// NOP commands. Log anyway in case we encounter a new version
// where these are not NOPs anymore.
NOTICE_LOG(DSPHLE, "Received a NOP command: %d", command);
NOTICE_LOG_FMT(DSPHLE, "Received a NOP command: {}", command);
SendCommandAck(CommandAck::STANDARD, sync);
break;

@@ -440,7 +440,7 @@ void ZeldaUCode::RunPendingCommands()
// since it's going directly back to the dispatcher with no ack.
if (m_flags & LIGHT_PROTOCOL)
{
PanicAlert("Received a 03 command on light protocol.");
PanicAlertFmt("Received a 03 command on light protocol.");
break;
}
SendCommandAck(CommandAck::STANDARD, sync);
@@ -457,7 +457,7 @@ void ZeldaUCode::RunPendingCommands()
//
// TODO: These are not crashes on light protocol, however I've never seen
// them used so far.
NOTICE_LOG(DSPHLE, "Received a crashy command: %d", command);
NOTICE_LOG_FMT(DSPHLE, "Received a crashy command: {}", command);
SetMailState(MailState::HALTED);
return;

@@ -547,12 +547,12 @@ void ZeldaUCode::RunPendingCommands()
else if (m_flags & WEIRD_CMD_0C)
{
// TODO
NOTICE_LOG(DSPHLE, "Received an unhandled 0C command, params: %08x %08x", Read32(),
Read32());
NOTICE_LOG_FMT(DSPHLE, "Received an unhandled 0C command, params: {:08x} {:08x}", Read32(),
Read32());
}
else
{
WARN_LOG(DSPHLE, "Received a NOP 0C command. Flags=%08x", m_flags);
WARN_LOG_FMT(DSPHLE, "Received a NOP 0C command. Flags={:08x}", m_flags);
}
SendCommandAck(CommandAck::STANDARD, sync);
break;
@@ -561,27 +561,27 @@ void ZeldaUCode::RunPendingCommands()
case 0x0D:
if (m_flags & NO_CMD_0D)
{
WARN_LOG(DSPHLE, "Received a 0D command which is NOP'd on this UCode.");
WARN_LOG_FMT(DSPHLE, "Received a 0D command which is NOP'd on this UCode.");
SendCommandAck(CommandAck::STANDARD, sync);
break;
}

WARN_LOG(DSPHLE, "CMD0D: %08x", Read32());
WARN_LOG_FMT(DSPHLE, "CMD0D: {:08x}", Read32());
SendCommandAck(CommandAck::STANDARD, sync);
break;

// Command 0E: Sets the base address of the ARAM for Wii UCodes. Used
// because the Wii does not have an ARAM, so it simulates it with MRAM
// and DMAs.
case 0x0E:
if (!(m_flags & NO_ARAM))
PanicAlert("Setting base ARAM addr on non Wii DAC.");
if ((m_flags & NO_ARAM) == 0)
PanicAlertFmt("Setting base ARAM addr on non Wii DAC.");
m_renderer.SetARAMBaseAddr(Read32());
SendCommandAck(CommandAck::STANDARD, sync);
break;

default:
NOTICE_LOG(DSPHLE, "Received a non-existing command (%d), halting.", command);
NOTICE_LOG_FMT(DSPHLE, "Received a non-existing command ({}), halting.", command);
SetMailState(MailState::HALTED);
return;
}
@@ -621,7 +621,7 @@ void ZeldaUCode::RenderAudio()
{
if (!RenderingInProgress())
{
WARN_LOG(DSPHLE, "Trying to render audio while no rendering should be happening.");
WARN_LOG_FMT(DSPHLE, "Trying to render audio while no rendering should be happening.");
return;
}

@@ -980,7 +980,7 @@ void ZeldaAudioRenderer::PrepareFrame()
// uses this AFAICT. PanicAlert to help me find places that use this.
#ifdef STRICT_ZELDA_HLE
if (!(m_flags & LIGHT_PROTOCOL) && (m_buf_back_left[0] != 0 || m_buf_back_right[0] != 0))
PanicAlert("Zelda HLE using back mixing buffers");
PanicAlertFmt("Zelda HLE using back mixing buffers");
#endif

// Add reverb data from previous frame.
@@ -1027,7 +1027,7 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)
if (!m_reverb_pb_base_addr)
{
#ifdef STRICT_ZELDA_HLE
PanicAlert("Trying to apply reverb without available parameters.");
PanicAlertFmt("Trying to apply reverb without available parameters.");
#endif
return;
}
@@ -1102,7 +1102,7 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)
if (!dest_buffer)
{
#ifdef STRICT_ZELDA_HLE
PanicAlert("RPB mixing to an unknown buffer: %04x", dest.buffer_id);
PanicAlertFmt("RPB mixing to an unknown buffer: {:04x}", dest.buffer_id);
#endif
continue;
}
@@ -1292,7 +1292,7 @@ void ZeldaAudioRenderer::AddVoice(u16 voice_id)
if (!dst_buffer)
{
#ifdef STRICT_ZELDA_HLE
PanicAlert("Mixing to an unmapped buffer: %04x", vpb.channels[i].id);
PanicAlertFmt("Mixing to an unmapped buffer: {:04x}", vpb.channels[i].id);
#endif
continue;
}
@@ -1480,7 +1480,7 @@ void ZeldaAudioRenderer::LoadInputSamples(MixingBuffer* buffer, VPB* vpb)
break;

default:
PanicAlert("Using an unknown/unimplemented sample source: %04x", vpb->samples_source_type);
PanicAlertFmt("Using an unknown/unimplemented sample source: {:04x}", vpb->samples_source_type);
buffer->fill(0);
return;
}
@@ -19,7 +19,7 @@ namespace DSP::LLE
{
void DSPPatches::Patch(std::size_t index)
{
PanicAlert("Patch functionality not supported in DSP module.");
PanicAlertFmt("Patch functionality not supported in DSP module.");
}

DSPDebugInterface::DSPDebugInterface() = default;
@@ -252,12 +252,12 @@ bool DSPDebugInterface::IsMemCheck(u32 address, size_t size) const

void DSPDebugInterface::ClearAllMemChecks()
{
PanicAlert("MemCheck functionality not supported in DSP module.");
PanicAlertFmt("MemCheck functionality not supported in DSP module.");
}

void DSPDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool log)
{
PanicAlert("MemCheck functionality not supported in DSP module.");
PanicAlertFmt("MemCheck functionality not supported in DSP module.");
}

// =======================================================
@@ -81,7 +81,7 @@ void CodeLoaded(const u8* ptr, size_t size)
DSP::DumpDSPCode(ptr, size, g_dsp.iram_crc);
}

NOTICE_LOG(DSPLLE, "g_dsp.iram_crc: %08x", g_dsp.iram_crc);
NOTICE_LOG_FMT(DSPLLE, "g_dsp.iram_crc: {:08x}", g_dsp.iram_crc);

Symbols::Clear();
Symbols::AutoDisassembly(0x0, 0x1000);
@@ -129,8 +129,8 @@ static bool LoadDSPRom(u16* rom, const std::string& filename, u32 size_in_bytes)

if (bytes.size() != size_in_bytes)
{
ERROR_LOG(DSPLLE, "%s has a wrong size (%zu, expected %u)", filename.c_str(), bytes.size(),
size_in_bytes);
ERROR_LOG_FMT(DSPLLE, "{} has a wrong size ({}, expected {})", filename, bytes.size(),
size_in_bytes);
return false;
}

@@ -264,7 +264,7 @@ void DSPLLE::DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value)
if (gdsp_mbox_peek(MAILBOX_CPU) & 0x80000000)
{
// the DSP didn't read the previous value
WARN_LOG(DSPLLE, "Mailbox isn't empty ... strange");
WARN_LOG_FMT(DSPLLE, "Mailbox isn't empty ... strange");
}

#if PROFILE
@@ -278,7 +278,7 @@ void DSPLLE::DSP_WriteMailBoxHigh(bool cpu_mailbox, u16 value)
}
else
{
ERROR_LOG(DSPLLE, "CPU can't write to DSP mailbox");
ERROR_LOG_FMT(DSPLLE, "CPU can't write to DSP mailbox");
}
}

@@ -290,7 +290,7 @@ void DSPLLE::DSP_WriteMailBoxLow(bool cpu_mailbox, u16 value)
}
else
{
ERROR_LOG(DSPLLE, "CPU can't write to DSP mailbox");
ERROR_LOG_FMT(DSPLLE, "CPU can't write to DSP mailbox");
}
}

@@ -86,11 +86,10 @@ void AutoDisassembly(u16 start_addr, u16 end_addr)
std::string buf;
if (!disasm.DisassembleOpcode(ptr, &addr, buf))
{
ERROR_LOG(DSPLLE, "disasm failed at %04x", addr);
ERROR_LOG_FMT(DSPLLE, "disasm failed at {:04x}", addr);
break;
}

// NOTICE_LOG(DSPLLE, "Added %04x %i %s", addr, line_counter, buf.c_str());
lines.push_back(buf);
line_counter++;
}

Large diffs are not rendered by default.

@@ -151,7 +151,7 @@ double CalculateRotationalLatency(u64 offset, double time, bool wii_disc)

const double result = angle_diff / MAX_ANGLE / rotations_per_second;

DEBUG_LOG(DVDINTERFACE, "Rotational latency: %lf ms", result * 1000);
DEBUG_LOG_FMT(DVDINTERFACE, "Rotational latency: {} ms", result * 1000);

return result;
}
@@ -183,8 +183,8 @@ double CalculateRawDiscReadTime(u64 offset, u64 length, bool wii_disc)
GC_DISC_INNER_READ_SPEED;
}

DEBUG_LOG(DVDINTERFACE, "Read 0x%" PRIx64 " @ 0x%" PRIx64 " @%lf mm: %lf us, %lf MiB/s", length,
offset, physical_offset * 1000, length / speed * 1000 * 1000, speed / 1024 / 1024);
DEBUG_LOG_FMT(DVDINTERFACE, "Read {:#x} @ {:#x} @{} mm: {} us, {} MiB/s", length, offset,
physical_offset * 1000, length / speed * 1000 * 1000, speed / 1024 / 1024);

return length / speed;
}
@@ -4,7 +4,6 @@

#include "Core/HW/DVD/DVDThread.h"

#include <cinttypes>
#include <map>
#include <memory>
#include <mutex>
@@ -159,7 +158,7 @@ void DoState(PointerWrap& p)
if (had_disc != HasDisc())
{
if (had_disc)
PanicAlertT("An inserted disc was expected but not found.");
PanicAlertFmtT("An inserted disc was expected but not found.");
else
s_disc.reset();
}
@@ -333,20 +332,20 @@ static void FinishRead(u64 id, s64 cycles_late)
const ReadRequest& request = result.first;
const std::vector<u8>& buffer = result.second;

DEBUG_LOG(DVDINTERFACE,
"Disc has been read. Real time: %" PRIu64 " us. "
"Real time including delay: %" PRIu64 " us. "
"Emulated time including delay: %" PRIu64 " us.",
request.realtime_done_us - request.realtime_started_us,
Common::Timer::GetTimeUs() - request.realtime_started_us,
(CoreTiming::GetTicks() - request.time_started_ticks) /
(SystemTimers::GetTicksPerSecond() / 1000000));
DEBUG_LOG_FMT(DVDINTERFACE,
"Disc has been read. Real time: {} us. "
"Real time including delay: {} us. "
"Emulated time including delay: {} us.",
request.realtime_done_us - request.realtime_started_us,
Common::Timer::GetTimeUs() - request.realtime_started_us,
(CoreTiming::GetTicks() - request.time_started_ticks) /
(SystemTimers::GetTicksPerSecond() / 1000000));

DVDInterface::DIInterruptType interrupt;
if (buffer.size() != request.length)
{
PanicAlertT("The disc could not be read (at 0x%" PRIx64 " - 0x%" PRIx64 ").",
request.dvd_offset, request.dvd_offset + request.length);
PanicAlertFmtT("The disc could not be read (at {:#x} - {:#x}).", request.dvd_offset,
request.dvd_offset + request.length);

DVDInterface::SetDriveError(DVDInterface::DriveError::BlockOOB);
interrupt = DVDInterface::DIInterruptType::DEINT;
@@ -82,9 +82,9 @@ void Log(const DiscIO::Volume& volume, const DiscIO::Partition& partition, u64 o
const std::string path = file_info->GetPath();
const std::string log_string = fmt::format("{} kB {}", size_string, path);
if (IsSoundFile(path))
INFO_LOG(FILEMON, "%s", log_string.c_str());
INFO_LOG_FMT(FILEMON, "{}", log_string);
else
WARN_LOG(FILEMON, "%s", log_string.c_str());
WARN_LOG_FMT(FILEMON, "{}", log_string);

// Update the last accessed file
s_previous_partition = partition;
@@ -22,11 +22,11 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()

if ((fd = open("/dev/tap0", O_RDWR)) < 0)
{
ERROR_LOG(SP1, "Couldn't open /dev/tap0, unable to init BBA");
ERROR_LOG_FMT(SP1, "Couldn't open /dev/tap0, unable to init BBA");
return false;
}

INFO_LOG(SP1, "BBA initialized.");
INFO_LOG_FMT(SP1, "BBA initialized.");
return RecvInit();
}

@@ -48,12 +48,13 @@ bool CEXIETHERNET::TAPNetworkInterface::IsActivated()

bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
{
INFO_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(frame, size, 0x10).c_str());
INFO_LOG_FMT(SP1, "SendFrame {}\n{}", size, ArrayToString(frame, size, 0x10));

int writtenBytes = write(fd, frame, size);
if ((u32)writtenBytes != size)
const int written_bytes = write(fd, frame, size);
if (u32(written_bytes) != size)
{
ERROR_LOG(SP1, "SendFrame(): expected to write %d bytes, instead wrote %d", size, writtenBytes);
ERROR_LOG_FMT(SP1, "SendFrame(): expected to write {} bytes, instead wrote {}", size,
written_bytes);
return false;
}
else
@@ -77,16 +78,16 @@ void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* s
if (select(self->fd + 1, &rfds, nullptr, nullptr, &timeout) <= 0)
continue;

int readBytes = read(self->fd, self->m_eth_ref->mRecvBuffer.get(), BBA_RECV_SIZE);
if (readBytes < 0)
const int read_bytes = read(self->fd, self->m_eth_ref->mRecvBuffer.get(), BBA_RECV_SIZE);
if (read_bytes < 0)
{
ERROR_LOG(SP1, "Failed to read from BBA, err=%d", readBytes);
ERROR_LOG_FMT(SP1, "Failed to read from BBA, err={}", read_bytes);
}
else if (self->readEnabled.IsSet())
{
INFO_LOG(SP1, "Read data: %s",
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), readBytes, 0x10).c_str());
self->m_eth_ref->mRecvBufferLength = readBytes;
INFO_LOG_FMT(SP1, "Read data: {}",
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), read_bytes, 0x10));
self->m_eth_ref->mRecvBufferLength = read_bytes;
self->m_eth_ref->RecvHandlePacket();
}
}
@@ -26,7 +26,7 @@
namespace ExpansionInterface
{
#define NOTIMPLEMENTED(Name) \
NOTICE_LOG(SP1, "CEXIETHERNET::%s not implemented for your UNIX", Name);
NOTICE_LOG_FMT(SP1, "CEXIETHERNET::{} not implemented for your UNIX", Name);

bool CEXIETHERNET::TAPNetworkInterface::Activate()
{
@@ -39,7 +39,7 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()

if ((fd = open("/dev/net/tun", O_RDWR)) < 0)
{
ERROR_LOG(SP1, "Couldn't open /dev/net/tun, unable to init BBA");
ERROR_LOG_FMT(SP1, "Couldn't open /dev/net/tun, unable to init BBA");
return false;
}

@@ -59,7 +59,7 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()
{
close(fd);
fd = -1;
ERROR_LOG(SP1, "TUNSETIFF failed: Interface=%s err=%d", ifr.ifr_name, err);
ERROR_LOG_FMT(SP1, "TUNSETIFF failed: Interface={} err={}", ifr.ifr_name, err);
return false;
}
}
@@ -70,7 +70,7 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()
}
ioctl(fd, TUNSETNOCSUM, 1);

INFO_LOG(SP1, "BBA initialized with associated tap %s", ifr.ifr_name);
INFO_LOG_FMT(SP1, "BBA initialized with associated tap {}", ifr.ifr_name);
return RecvInit();
#else
NOTIMPLEMENTED("Activate");
@@ -105,12 +105,13 @@ bool CEXIETHERNET::TAPNetworkInterface::IsActivated()
bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
{
#ifdef __linux__
DEBUG_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(frame, size, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "SendFrame {}\n{}", size, ArrayToString(frame, size, 0x10));

int writtenBytes = write(fd, frame, size);
if ((u32)writtenBytes != size)
{
ERROR_LOG(SP1, "SendFrame(): expected to write %d bytes, instead wrote %d", size, writtenBytes);
ERROR_LOG_FMT(SP1, "SendFrame(): expected to write {} bytes, instead wrote {}", size,
writtenBytes);
return false;
}
else
@@ -142,12 +143,12 @@ void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* s
int readBytes = read(self->fd, self->m_eth_ref->mRecvBuffer.get(), BBA_RECV_SIZE);
if (readBytes < 0)
{
ERROR_LOG(SP1, "Failed to read from BBA, err=%d", readBytes);
ERROR_LOG_FMT(SP1, "Failed to read from BBA, err={}", readBytes);
}
else if (self->readEnabled.IsSet())
{
DEBUG_LOG(SP1, "Read data: %s",
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), readBytes, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "Read data: {}",
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), readBytes, 0x10));
self->m_eth_ref->mRecvBufferLength = readBytes;
self->m_eth_ref->RecvHandlePacket();
}
@@ -159,7 +159,7 @@ bool OpenTAP(HANDLE& adapter, const std::basic_string<TCHAR>& device_guid)

if (adapter == INVALID_HANDLE_VALUE)
{
INFO_LOG(SP1, "Failed to open TAP at %s", device_path.c_str());
INFO_LOG_FMT(SP1, "Failed to open TAP at {}", WStringToUTF8(device_path));
return false;
}
return true;
@@ -179,21 +179,21 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()

if (!Win32TAPHelper::GetGUIDs(device_guids))
{
ERROR_LOG(SP1, "Failed to find a TAP GUID");
ERROR_LOG_FMT(SP1, "Failed to find a TAP GUID");
return false;
}

for (size_t i = 0; i < device_guids.size(); i++)
for (const auto& device_guid : device_guids)
{
if (Win32TAPHelper::OpenTAP(mHAdapter, device_guids.at(i)))
if (Win32TAPHelper::OpenTAP(mHAdapter, device_guid))
{
INFO_LOG(SP1, "OPENED %s", device_guids.at(i).c_str());
INFO_LOG_FMT(SP1, "OPENED {}", WStringToUTF8(device_guid));
break;
}
}
if (mHAdapter == INVALID_HANDLE_VALUE)
{
PanicAlert("Failed to open any TAP");
PanicAlertFmt("Failed to open any TAP");
return false;
}

@@ -202,16 +202,17 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()
if (DeviceIoControl(mHAdapter, TAP_IOCTL_GET_VERSION, &info, sizeof(info), &info, sizeof(info),
&len, nullptr))
{
INFO_LOG(SP1, "TAP-Win32 Driver Version %d.%d %s", info[0], info[1], info[2] ? "(DEBUG)" : "");
INFO_LOG_FMT(SP1, "TAP-Win32 Driver Version {}.{} {}", info[0], info[1],
info[2] ? "(DEBUG)" : "");
}
if (!(info[0] > TAP_WIN32_MIN_MAJOR ||
(info[0] == TAP_WIN32_MIN_MAJOR && info[1] >= TAP_WIN32_MIN_MINOR)))
{
PanicAlertT("ERROR: This version of Dolphin requires a TAP-Win32 driver"
" that is at least version %d.%d -- If you recently upgraded your Dolphin"
" distribution, a reboot is probably required at this point to get"
" Windows to see the new driver.",
TAP_WIN32_MIN_MAJOR, TAP_WIN32_MIN_MINOR);
PanicAlertFmtT("ERROR: This version of Dolphin requires a TAP-Win32 driver"
" that is at least version {0}.{1} -- If you recently upgraded your Dolphin"
" distribution, a reboot is probably required at this point to get"
" Windows to see the new driver.",
TAP_WIN32_MIN_MAJOR, TAP_WIN32_MIN_MINOR);
return false;
}

@@ -220,8 +221,8 @@ bool CEXIETHERNET::TAPNetworkInterface::Activate()
if (!DeviceIoControl(mHAdapter, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof(status), &status,
sizeof(status), &len, nullptr))
{
ERROR_LOG(SP1, "WARNING: The TAP-Win32 driver rejected a"
"TAP_IOCTL_SET_MEDIA_STATUS DeviceIoControl call.");
ERROR_LOG_FMT(SP1, "WARNING: The TAP-Win32 driver rejected a"
"TAP_IOCTL_SET_MEDIA_STATUS DeviceIoControl call.");
return false;
}

@@ -283,7 +284,7 @@ void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* s
// IO should be pending.
if (GetLastError() != ERROR_IO_PENDING)
{
ERROR_LOG(SP1, "ReadFile failed (err=0x%X)", GetLastError());
ERROR_LOG_FMT(SP1, "ReadFile failed (err={:#x})", GetLastError());
continue;
}

@@ -295,14 +296,14 @@ void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* s
continue;

// Something else went wrong.
ERROR_LOG(SP1, "GetOverlappedResult failed (err=0x%X)", GetLastError());
ERROR_LOG_FMT(SP1, "GetOverlappedResult failed (err={:#x})", GetLastError());
continue;
}
}

// Copy to BBA buffer, and fire interrupt if enabled.
DEBUG_LOG(SP1, "Received %u bytes:\n %s", transferred,
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), transferred, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "Received {} bytes:\n {}", transferred,
ArrayToString(self->m_eth_ref->mRecvBuffer.get(), transferred, 0x10));
if (self->readEnabled.IsSet())
{
self->m_eth_ref->mRecvBufferLength = transferred;
@@ -313,15 +314,15 @@ void CEXIETHERNET::TAPNetworkInterface::ReadThreadHandler(TAPNetworkInterface* s

bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
{
DEBUG_LOG(SP1, "SendFrame %u bytes:\n%s", size, ArrayToString(frame, size, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "SendFrame {} bytes:\n{}", size, ArrayToString(frame, size, 0x10));

// Check for a background write. We can't issue another one until this one has completed.
DWORD transferred;
if (mWritePending)
{
// Wait for previous write to complete.
if (!GetOverlappedResult(mHAdapter, &mWriteOverlapped, &transferred, TRUE))
ERROR_LOG(SP1, "GetOverlappedResult failed (err=0x%X)", GetLastError());
ERROR_LOG_FMT(SP1, "GetOverlappedResult failed (err={:#x})", GetLastError());
}

// Copy to write buffer.
@@ -339,7 +340,7 @@ bool CEXIETHERNET::TAPNetworkInterface::SendFrame(const u8* frame, u32 size)
// IO should be pending.
if (GetLastError() != ERROR_IO_PENDING)
{
ERROR_LOG(SP1, "WriteFile failed (err=0x%X)", GetLastError());
ERROR_LOG_FMT(SP1, "WriteFile failed (err={:#x})", GetLastError());
ResetEvent(mWriteOverlapped.hEvent);
mWritePending = false;
return false;
@@ -29,7 +29,7 @@ bool CEXIETHERNET::XLinkNetworkInterface::Activate()

if (m_sf_socket.bind(sf::Socket::AnyPort) != sf::Socket::Done)
{
ERROR_LOG(SP1, "Couldn't open XLink Kai UDP socket, unable to initialize BBA");
ERROR_LOG_FMT(SP1, "Couldn't open XLink Kai UDP socket, unable to initialize BBA");
return false;
}

@@ -44,14 +44,14 @@ bool CEXIETHERNET::XLinkNetworkInterface::Activate()
const auto size = u32(cmd.length());
memmove(buffer, cmd.c_str(), size);

DEBUG_LOG(SP1, "SendCommandPayload %x\n%s", size, ArrayToString(buffer, size, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "SendCommandPayload {:x}\n{}", size, ArrayToString(buffer, size, 0x10));

if (m_sf_socket.send(buffer, size, m_sf_recipient_ip, m_dest_port) != sf::Socket::Done)
{
ERROR_LOG(SP1, "Activate(): failed to send connect message to XLink Kai client");
ERROR_LOG_FMT(SP1, "Activate(): failed to send connect message to XLink Kai client");
}

INFO_LOG(SP1, "BBA initialized.");
INFO_LOG_FMT(SP1, "BBA initialized.");

return RecvInit();
}
@@ -66,14 +66,14 @@ void CEXIETHERNET::XLinkNetworkInterface::Deactivate()
u8 buffer[255] = {};
memmove(buffer, cmd.c_str(), size);

DEBUG_LOG(SP1, "SendCommandPayload %x\n%s", size, ArrayToString(buffer, size, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "SendCommandPayload {:x}\n{}", size, ArrayToString(buffer, size, 0x10));

if (m_sf_socket.send(buffer, size, m_sf_recipient_ip, m_dest_port) != sf::Socket::Done)
{
ERROR_LOG(SP1, "Deactivate(): failed to send disconnect message to XLink Kai client");
ERROR_LOG_FMT(SP1, "Deactivate(): failed to send disconnect message to XLink Kai client");
}

NOTICE_LOG(SP1, "XLink Kai BBA deactivated");
NOTICE_LOG_FMT(SP1, "XLink Kai BBA deactivated");

m_bba_link_up = false;

@@ -118,11 +118,12 @@ bool CEXIETHERNET::XLinkNetworkInterface::SendFrame(const u8* frame, u32 size)
size += 4;

// Only uncomment for debugging, the performance hit is too big otherwise
// INFO_LOG(SP1, "SendFrame %x\n%s", size, ArrayToString(m_out_frame, size, 0x10).c_str());
// INFO_LOG_FMT(SP1, "SendFrame {}\n{}", size, ArrayToString(m_out_frame, size, 0x10)));

if (m_sf_socket.send(m_out_frame, size, m_sf_recipient_ip, m_dest_port) != sf::Socket::Done)
{
ERROR_LOG(SP1, "SendFrame(): expected to write %u bytes, but failed, errno %d", size, errno);
ERROR_LOG_FMT(SP1, "SendFrame(): expected to write {} bytes, but failed, errno {}", size,
errno);
return false;
}
else
@@ -150,7 +151,7 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
port) != sf::Socket::Done &&
self->m_bba_link_up)
{
ERROR_LOG(SP1, "Failed to read from BBA, err=%zu", bytes_read);
ERROR_LOG_FMT(SP1, "Failed to read from BBA, err={}", bytes_read);
}

// Make sure *anything* was recieved before going any further
@@ -174,13 +175,13 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
// Check the frame size again after the header is removed
if (bytes_read < 1)
{
ERROR_LOG(SP1, "Failed to read from BBA, err=%zu", bytes_read - 4);
ERROR_LOG_FMT(SP1, "Failed to read from BBA, err={}", bytes_read - 4);
}
else if (self->m_read_enabled.IsSet())
{
// Only uncomment for debugging, the performance hit is too big otherwise
// DEBUG_LOG(SP1, "Read data: %s", ArrayToString(self->m_eth_ref->mRecvBuffer.get(),
// u32(bytes_read - 4), 0x10).c_str());
// 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->RecvHandlePacket();
}
@@ -189,13 +190,13 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
// Otherwise we recieved control data or junk
else
{
std::string control_msg(self->m_in_frame, self->m_in_frame + bytes_read);
INFO_LOG(SP1, "Received XLink Kai control data: %s", control_msg.c_str());
const std::string control_msg(self->m_in_frame, self->m_in_frame + bytes_read);
INFO_LOG_FMT(SP1, "Received XLink Kai control data: {}", control_msg);

// connected;identifier;
if (StringBeginsWith(control_msg, "connected"))
{
NOTICE_LOG(SP1, "XLink Kai BBA connected");
NOTICE_LOG_FMT(SP1, "XLink Kai BBA connected");
OSD::AddMessage("XLink Kai BBA connected", 4500);

self->m_bba_link_up = true;
@@ -210,21 +211,21 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
u8 buffer[255] = {};
memmove(buffer, cmd.data(), size);

DEBUG_LOG(SP1, "SendCommandPayload %x\n%s", size,
ArrayToString(buffer, size, 0x10).c_str());
DEBUG_LOG_FMT(SP1, "SendCommandPayload {:x}\n{}", size,
ArrayToString(buffer, size, 0x10));

if (self->m_sf_socket.send(buffer, size, self->m_sf_recipient_ip, self->m_dest_port) !=
sf::Socket::Done)
{
ERROR_LOG(SP1,
"ReadThreadHandler(): failed to send setting message to XLink Kai client");
ERROR_LOG_FMT(
SP1, "ReadThreadHandler(): failed to send setting message to XLink Kai client");
}
}
}
// disconnected;optional_identifier;optional_message;
else if (StringBeginsWith(control_msg, "disconnected"))
{
NOTICE_LOG(SP1, "XLink Kai BBA disconnected");
NOTICE_LOG_FMT(SP1, "XLink Kai BBA disconnected");
// Show OSD message for 15 seconds to make sure the user sees it
OSD::AddMessage("XLink Kai BBA disconnected", 15000);

@@ -245,25 +246,24 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
// keepalive;
else if (StringBeginsWith(control_msg, "keepalive"))
{
DEBUG_LOG(SP1, "XLink Kai BBA keepalive");
DEBUG_LOG_FMT(SP1, "XLink Kai BBA keepalive");

// Only uncomment for debugging, just clogs the log otherwise
// INFO_LOG(SP1, "SendCommandPayload %x\n%s", 2, ArrayToString(m_in_frame, 2,
// 0x10).c_str());
// INFO_LOG_FMT(SP1, "SendCommandPayload {:x}\n{}", 2, ArrayToString(m_in_frame, 2, 0x10));

// Reply (using the message that came in!)
if (self->m_sf_socket.send(self->m_in_frame, 10, self->m_sf_recipient_ip,
self->m_dest_port) != sf::Socket::Done)
{
ERROR_LOG(SP1, "ReadThreadHandler(): failed to reply to XLink Kai client keepalive");
ERROR_LOG_FMT(SP1, "ReadThreadHandler(): failed to reply to XLink Kai client keepalive");
}
}
// message;message_text;
else if (StringBeginsWith(control_msg, "message"))
{
std::string msg = control_msg.substr(8, control_msg.length() - 1);

NOTICE_LOG(SP1, "XLink Kai message: %s", msg.c_str());
NOTICE_LOG_FMT(SP1, "XLink Kai message: {}", msg);
// Show OSD message for 15 seconds to make sure the user sees it
OSD::AddMessage(std::move(msg), 15000);
}
@@ -272,15 +272,15 @@ void CEXIETHERNET::XLinkNetworkInterface::ReadThreadHandler(
{
std::string msg = control_msg.substr(5, control_msg.length() - 1);

NOTICE_LOG(SP1, "XLink Kai chat: %s", msg.c_str());
NOTICE_LOG_FMT(SP1, "XLink Kai chat: {}", msg);
OSD::AddMessage(std::move(msg), 5000);
}
// directmessage;message_text;
else if (StringBeginsWith(control_msg, "directmessage"))
{
std::string msg = control_msg.substr(14, control_msg.length() - 1);

NOTICE_LOG(SP1, "XLink Kai direct message: %s", msg.c_str());
NOTICE_LOG_FMT(SP1, "XLink Kai direct message: {}", msg);
OSD::AddMessage(std::move(msg), 5000);
}
// else junk/unsupported control message
@@ -9,6 +9,7 @@
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"

#include "Core/CoreTiming.h"
#include "Core/HW/EXI/EXI.h"
@@ -178,10 +179,10 @@ void CEXIChannel::AddDevice(std::unique_ptr<IEXIDevice> device, const int device
{
DEBUG_ASSERT(device_num < NUM_DEVICES);

INFO_LOG(EXPANSIONINTERFACE,
"Changing EXI channel %d, device %d to type %d (notify software: %s)",
static_cast<int>(m_channel_id), device_num, static_cast<int>(device->m_device_type),
notify_presence_changed ? "true" : "false");
INFO_LOG_FMT(EXPANSIONINTERFACE,
"Changing EXI channel {}, device {} to type {} (notify software: {})", m_channel_id,
device_num, static_cast<int>(device->m_device_type),
notify_presence_changed ? "true" : "false");

// Replace it with the new one
m_devices[device_num] = std::move(device);
@@ -76,15 +76,14 @@ void CEXIAgp::LoadRom()
std::string path;
std::string filename;
std::string ext;
std::string gbapath;
SplitPath(m_slot == 0 ? SConfig::GetInstance().m_strGbaCartA :
SConfig::GetInstance().m_strGbaCartB,
&path, &filename, &ext);
gbapath = path + filename;
const std::string gbapath = path + filename;
LoadFileToROM(gbapath + ext);
INFO_LOG(EXPANSIONINTERFACE, "Loaded GBA rom: %s card: %d", gbapath.c_str(), m_slot);
INFO_LOG_FMT(EXPANSIONINTERFACE, "Loaded GBA rom: {} card: {}", gbapath, m_slot);
LoadFileToEEPROM(gbapath + ".sav");
INFO_LOG(EXPANSIONINTERFACE, "Loaded GBA sav: %s card: %d", gbapath.c_str(), m_slot);
INFO_LOG_FMT(EXPANSIONINTERFACE, "Loaded GBA sav: {} card: {}", gbapath, m_slot);
}

void CEXIAgp::LoadFileToROM(const std::string& filename)
@@ -272,7 +271,7 @@ void CEXIAgp::ImmWrite(u32 _uData, u32 _uSize)

u8 HashCmd;
u64 Mask;
DEBUG_LOG(EXPANSIONINTERFACE, "AGP command %x", _uData);
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "AGP command {:x}", _uData);
switch (m_current_cmd)
{
case 0xAE020000: // set up 24 bit address for read 2 bytes
@@ -17,25 +17,25 @@ CEXIDummy::CEXIDummy(const std::string& name) : m_name{name}

void CEXIDummy::ImmWrite(u32 data, u32 size)
{
INFO_LOG(EXPANSIONINTERFACE, "EXI DUMMY %s ImmWrite: %08x", m_name.c_str(), data);
INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI DUMMY {} ImmWrite: {:08x}", m_name, data);
}

u32 CEXIDummy::ImmRead(u32 size)
{
INFO_LOG(EXPANSIONINTERFACE, "EXI DUMMY %s ImmRead", m_name.c_str());
INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI DUMMY {} ImmRead", m_name);
return 0;
}

void CEXIDummy::DMAWrite(u32 address, u32 size)
{
INFO_LOG(EXPANSIONINTERFACE, "EXI DUMMY %s DMAWrite: %08x bytes, from %08x to device",
m_name.c_str(), size, address);
INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI DUMMY {} DMAWrite: {:08x} bytes, from {:08x} to device",
m_name, size, address);
}

void CEXIDummy::DMARead(u32 address, u32 size)
{
INFO_LOG(EXPANSIONINTERFACE, "EXI DUMMY %s DMARead: %08x bytes, from device to %08x",
m_name.c_str(), size, address);
INFO_LOG_FMT(EXPANSIONINTERFACE, "EXI DUMMY {} DMARead: {:08x} bytes, from device to {:08x}",
m_name, size, address);
}

bool CEXIDummy::IsPresent() const
@@ -46,7 +46,7 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type)
{
case BBADeviceType::TAP:
m_network_interface = std::make_unique<TAPNetworkInterface>(this);
INFO_LOG(SP1, "Created TAP physical network interface.");
INFO_LOG_FMT(SP1, "Created TAP physical network interface.");
break;
case BBADeviceType::XLINK:
// TODO start BBA with network link down, bring it up after "connected" response from XLink
@@ -57,18 +57,19 @@ CEXIETHERNET::CEXIETHERNET(BBADeviceType type)
if (!StringBeginsWith(mac_addr_setting, "00:09:bf") &&
!StringBeginsWith(mac_addr_setting, "00:17:ab"))
{
PanicAlertT("BBA MAC address %s invalid for XLink Kai. A valid Nintendo GameCube MAC address "
"must be used. Generate a new MAC address starting with 00:09:bf or 00:17:ab.",
mac_addr_setting.c_str());
PanicAlertFmtT(
"BBA MAC address {0} invalid for XLink Kai. A valid Nintendo GameCube MAC address "
"must be used. Generate a new MAC address starting with 00:09:bf or 00:17:ab.",
mac_addr_setting);
}

// m_client_mdentifier should be unique per connected emulator from the XLink kai client's
// perspective so lets use "dolphin<bba mac>"
m_network_interface = std::make_unique<XLinkNetworkInterface>(
this, SConfig::GetInstance().m_bba_xlink_ip, 34523,
"dolphin" + SConfig::GetInstance().m_bba_mac, SConfig::GetInstance().m_bba_xlink_chat_osd);
INFO_LOG(SP1, "Created XLink Kai BBA network interface connection to %s:34523",
SConfig::GetInstance().m_bba_xlink_ip.c_str());
INFO_LOG_FMT(SP1, "Created XLink Kai BBA network interface connection to {}:34523",
SConfig::GetInstance().m_bba_xlink_ip);
break;
}

@@ -123,14 +124,15 @@ void CEXIETHERNET::ImmWrite(u32 data, u32 size)
transfer.address = (data >> 8) & 0xffff;
transfer.direction = IsWriteCommand(data) ? transfer.WRITE : transfer.READ;

DEBUG_LOG(SP1, "%s %s %s %x", IsMXCommand(data) ? "mx " : "exi",
IsWriteCommand(data) ? "write" : "read ", GetRegisterName(), transfer.address);
DEBUG_LOG_FMT(SP1, "{} {} {} {:x}", IsMXCommand(data) ? "mx " : "exi",
IsWriteCommand(data) ? "write" : "read ", GetRegisterName(), transfer.address);

if (transfer.address == BBA_IOB && transfer.region == transfer.MX)
{
ERROR_LOG(SP1, "Usage of BBA_IOB indicates that the rx packet descriptor has been corrupted. "
"Killing Dolphin...");
exit(0);
ERROR_LOG_FMT(SP1,
"Usage of BBA_IOB indicates that the rx packet descriptor has been corrupted. "
"Killing Dolphin...");
std::exit(0);
}

// transfer has been setup
@@ -139,7 +141,7 @@ void CEXIETHERNET::ImmWrite(u32 data, u32 size)

// Reach here if we're actually writing data to the EXI or MX region.

DEBUG_LOG(SP1, "%s write %0*x", transfer.region == transfer.MX ? "mx " : "exi", size * 2, data);
DEBUG_LOG_FMT(SP1, "{} write {:x}", transfer.region == transfer.MX ? "mx " : "exi", data);

if (transfer.region == transfer.EXI)
{
@@ -193,7 +195,7 @@ u32 CEXIETHERNET::ImmRead(u32 size)
ret |= mBbaMem[transfer.address++] << (i * 8);
}

DEBUG_LOG(SP1, "imm r%i: %0*x", size, size * 2, ret);
DEBUG_LOG_FMT(SP1, "imm r{}: {:x}", size, ret);

ret <<= (4 - size) * 8;

@@ -202,7 +204,7 @@ u32 CEXIETHERNET::ImmRead(u32 size)

void CEXIETHERNET::DMAWrite(u32 addr, u32 size)
{
DEBUG_LOG(SP1, "DMA write: %08x %x", addr, size);
DEBUG_LOG_FMT(SP1, "DMA write: {:08x} {:x}", addr, size);

if (transfer.region == transfer.MX && transfer.direction == transfer.WRITE &&
transfer.address == BBA_WRTXFIFOD)
@@ -211,15 +213,15 @@ void CEXIETHERNET::DMAWrite(u32 addr, u32 size)
}
else
{
ERROR_LOG(SP1, "DMA write in %s %s mode - not implemented",
transfer.region == transfer.EXI ? "exi" : "mx",
transfer.direction == transfer.READ ? "read" : "write");
ERROR_LOG_FMT(SP1, "DMA write in {} {} mode - not implemented",
transfer.region == transfer.EXI ? "exi" : "mx",
transfer.direction == transfer.READ ? "read" : "write");
}
}

void CEXIETHERNET::DMARead(u32 addr, u32 size)
{
DEBUG_LOG(SP1, "DMA read: %08x %x", addr, size);
DEBUG_LOG_FMT(SP1, "DMA read: {:08x} {:x}", addr, size);

Memory::CopyToEmu(addr, &mBbaMem[transfer.address], size);

@@ -334,36 +336,36 @@ void CEXIETHERNET::MXCommandHandler(u32 data, u32 size)
switch (transfer.address)
{
case BBA_NCRA:
if (data & NCRA_RESET)
if ((data & NCRA_RESET) != 0)
{
INFO_LOG(SP1, "Software reset");
INFO_LOG_FMT(SP1, "Software reset");
// MXSoftReset();
m_network_interface->Activate();
}

if ((mBbaMem[BBA_NCRA] & NCRA_SR) ^ (data & NCRA_SR))
if (((mBbaMem[BBA_NCRA] & NCRA_SR) ^ (data & NCRA_SR)) != 0)
{
DEBUG_LOG(SP1, "%s rx", (data & NCRA_SR) ? "start" : "stop");
DEBUG_LOG_FMT(SP1, "{} rx", (data & NCRA_SR) ? "start" : "stop");

if (data & NCRA_SR)
if ((data & NCRA_SR) != 0)
m_network_interface->RecvStart();
else
m_network_interface->RecvStop();
}

// Only start transfer if there isn't one currently running
if (!(mBbaMem[BBA_NCRA] & (NCRA_ST0 | NCRA_ST1)))
if ((mBbaMem[BBA_NCRA] & (NCRA_ST0 | NCRA_ST1)) == 0)
{
// Technically transfer DMA status is kept in TXDMA - not implemented

if (data & NCRA_ST0)
if ((data & NCRA_ST0) != 0)
{
INFO_LOG(SP1, "start tx - local DMA");
INFO_LOG_FMT(SP1, "start tx - local DMA");
SendFromPacketBuffer();
}
else if (data & NCRA_ST1)
else if ((data & NCRA_ST1) != 0)
{
DEBUG_LOG(SP1, "start tx - direct FIFO");
DEBUG_LOG_FMT(SP1, "start tx - direct FIFO");
SendFromDirectFIFO();
// Kind of a hack: send completes instantly, so we don't
// actually write the "send in status" bit to the register
@@ -426,7 +428,7 @@ void CEXIETHERNET::SendFromDirectFIFO()

void CEXIETHERNET::SendFromPacketBuffer()
{
ERROR_LOG(SP1, "tx packet buffer not implemented.");
ERROR_LOG_FMT(SP1, "tx packet buffer not implemented.");
}

void CEXIETHERNET::SendComplete()
@@ -523,11 +525,11 @@ bool CEXIETHERNET::RecvHandlePacket()
goto wait_for_next;

#ifdef BBA_TRACK_PAGE_PTRS
INFO_LOG(SP1, "RecvHandlePacket %x\n%s", mRecvBufferLength,
ArrayToString(mRecvBuffer, mRecvBufferLength, 0x100).c_str());
INFO_LOG_FMT(SP1, "RecvHandlePacket {:x}\n{}", mRecvBufferLength,
ArrayToString(mRecvBuffer, mRecvBufferLength, 0x100));

INFO_LOG(SP1, "%x %x %x %x", page_ptr(BBA_BP), page_ptr(BBA_RRP), page_ptr(BBA_RWP),
page_ptr(BBA_RHBP));
INFO_LOG_FMT(SP1, "{:x} {:x} {:x} {:x}", page_ptr(BBA_BP), page_ptr(BBA_RRP), page_ptr(BBA_RWP),
page_ptr(BBA_RHBP));
#endif

write_ptr = ptr_from_page_ptr(BBA_RWP);
@@ -574,23 +576,23 @@ bool CEXIETHERNET::RecvHandlePacket()
inc_rwp();

#ifdef BBA_TRACK_PAGE_PTRS
INFO_LOG(SP1, "%x %x %x %x", page_ptr(BBA_BP), page_ptr(BBA_RRP), page_ptr(BBA_RWP),
page_ptr(BBA_RHBP));
INFO_LOG_FMT(SP1, "{:x} {:x} {:x} {:x}", page_ptr(BBA_BP), page_ptr(BBA_RRP), page_ptr(BBA_RWP),
page_ptr(BBA_RHBP));
#endif

// Is the current frame multicast?
if (mRecvBuffer[0] & 0x01)
if ((mRecvBuffer[0] & 1) != 0)
status |= DESC_MF;

if (status & DESC_BF)
if ((status & DESC_BF) != 0)
{
if (mBbaMem[BBA_MISC2] & MISC2_AUTORCVR)
if ((mBbaMem[BBA_MISC2] & MISC2_AUTORCVR) != 0)
{
*(u16*)&mBbaMem[BBA_RWP] = rwp_initial;
}
else
{
ERROR_LOG(SP1, "RBF while AUTORCVR == 0!");
ERROR_LOG_FMT(SP1, "RBF while AUTORCVR == 0!");
}
}

@@ -599,7 +601,7 @@ bool CEXIETHERNET::RecvHandlePacket()
mBbaMem[BBA_LRPS] = status;

// Raise interrupt
if (mBbaMem[BBA_IMR] & INT_R)
if ((mBbaMem[BBA_IMR] & INT_R) != 0)
{
mBbaMem[BBA_IR] |= INT_R;

@@ -609,11 +611,11 @@ bool CEXIETHERNET::RecvHandlePacket()
else
{
// This occurs if software is still processing the last raised recv interrupt
WARN_LOG(SP1, "NOT raising recv interrupt");
WARN_LOG_FMT(SP1, "NOT raising recv interrupt");
}

wait_for_next:
if (mBbaMem[BBA_NCRA] & NCRA_SR)
if ((mBbaMem[BBA_NCRA] & NCRA_SR) != 0)
m_network_interface->RecvStart();

return true;
@@ -221,7 +221,7 @@ void CEXIGecko::ImmReadWrite(u32& _uData, u32 _uSize)
}

default:
ERROR_LOG(EXPANSIONINTERFACE, "Unknown USBGecko command %x", _uData);
ERROR_LOG_FMT(EXPANSIONINTERFACE, "Unknown USBGecko command {:x}", _uData);
break;
}
}
@@ -112,7 +112,8 @@ CEXIIPL::CEXIIPL()
// Descramble the encrypted section (contains BS1 and BS2)
Descrambler(&m_rom[0x100], 0x1afe00);
// yay for null-terminated strings
INFO_LOG(BOOT, "Loaded bootrom: %s", &m_rom[0]);
const std::string_view name{reinterpret_cast<char*>(m_rom.get())};
INFO_LOG_FMT(BOOT, "Loaded bootrom: {}", name);
}
else
{
@@ -232,10 +233,10 @@ void CEXIIPL::LoadFontFile(const std::string& filename, u32 offset)

// Official Windows-1252 and Shift JIS fonts present on the IPL dumps are 0x2575 and 0x4a24d
// bytes long respectively, so, determine the size of the font being loaded based on the offset
u64 fontsize = (offset == 0x1aff00) ? 0x4a24d : 0x2575;
const u64 fontsize = (offset == 0x1aff00) ? 0x4a24d : 0x2575;

INFO_LOG(BOOT, "Found IPL dump, loading %s font from %s",
((offset == 0x1aff00) ? "Shift JIS" : "Windows-1252"), (ipl_rom_path).c_str());
INFO_LOG_FMT(BOOT, "Found IPL dump, loading {} font from {}",
(offset == 0x1aff00) ? "Shift JIS" : "Windows-1252", ipl_rom_path);

stream.Seek(offset, 0);
stream.ReadBytes(&m_rom[offset], fontsize);
@@ -279,17 +280,18 @@ void CEXIIPL::TransferByte(u8& data)
// This is technically not very accurate :(
UpdateRTC();

DEBUG_LOG(EXPANSIONINTERFACE, "IPL-DEV cmd %s %08x %02x",
m_command.is_write() ? "write" : "read", m_command.address(), m_command.low_bits());
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "IPL-DEV cmd {} {:08x} {:02x}",
m_command.is_write() ? "write" : "read", m_command.address(),
m_command.low_bits());
}
}
else
{
// Actually read or write a byte
u32 address = m_command.address();
const u32 address = m_command.address();

DEBUG_LOG(EXPANSIONINTERFACE, "IPL-DEV data %s %08x %02x",
m_command.is_write() ? "write" : "read", address, data);
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "IPL-DEV data {} {:08x} {:02x}",
m_command.is_write() ? "write" : "read", address, data);

#define IN_RANGE(x) (address >= x##_BASE && address < x##_BASE + x##_SIZE)
#define DEV_ADDR(x) (address - x##_BASE)
@@ -303,7 +305,7 @@ void CEXIIPL::TransferByte(u8& data)

if (data == '\r')
{
NOTICE_LOG(OSREPORT, "%s", SHIFTJISToUTF8(m_buffer).c_str());
NOTICE_LOG_FMT(OSREPORT, "{}", SHIFTJISToUTF8(m_buffer));
m_buffer.clear();
}
}
@@ -328,13 +330,13 @@ void CEXIIPL::TransferByte(u8& data)
{
if (dev_addr >= 0x001FCF00)
{
PanicAlertT("Error: Trying to access Windows-1252 fonts but they are not loaded. "
"Games may not show fonts correctly, or crash.");
PanicAlertFmtT("Error: Trying to access Windows-1252 fonts but they are not loaded. "
"Games may not show fonts correctly, or crash.");
}
else
{
PanicAlertT("Error: Trying to access Shift JIS fonts but they are not loaded. "
"Games may not show fonts correctly, or crash.");
PanicAlertFmtT("Error: Trying to access Shift JIS fonts but they are not loaded. "
"Games may not show fonts correctly, or crash.");
}
// Don't be a nag
m_fonts_loaded = true;
@@ -361,7 +363,7 @@ void CEXIIPL::TransferByte(u8& data)
// Seen being written to after reading 4 bytes from barnacle
break;
case 0x4c:
DEBUG_LOG(OSREPORT, "UART Barnacle %x", data);
DEBUG_LOG_FMT(OSREPORT, "UART Barnacle {:x}", data);
break;
}
}
@@ -387,7 +389,7 @@ void CEXIIPL::TransferByte(u8& data)
}
else
{
NOTICE_LOG(EXPANSIONINTERFACE, "IPL-DEV Accessing unknown device");
NOTICE_LOG_FMT(EXPANSIONINTERFACE, "IPL-DEV Accessing unknown device");
}

#undef DEV_ADDR_CURSOR
@@ -199,7 +199,7 @@ void CEXIMemoryCard::SetupGciFolder(const Memcard::HeaderData& header_data)
{
if (File::Rename(strDirectoryName, strDirectoryName + ".original"))
{
PanicAlertT("%s was not a directory, moved to *.original", strDirectoryName.c_str());
PanicAlertFmtT("{0} was not a directory, moved to *.original", strDirectoryName);
if (migrate)
MigrateFromMemcardFile(strDirectoryName + DIR_SEP, card_index);
else
@@ -208,10 +208,10 @@ void CEXIMemoryCard::SetupGciFolder(const Memcard::HeaderData& header_data)
else // we tried but the user wants to crash
{
// TODO more user friendly abort
PanicAlertT("%s is not a directory, failed to move to *.original.\n Verify your "
"write permissions or move the file outside of Dolphin",
strDirectoryName.c_str());
exit(0);
PanicAlertFmtT("{0} is not a directory, failed to move to *.original.\n Verify your "
"write permissions or move the file outside of Dolphin",
strDirectoryName);
std::exit(0);
}
}

@@ -338,7 +338,7 @@ bool CEXIMemoryCard::IsInterruptSet()

void CEXIMemoryCard::TransferByte(u8& byte)
{
DEBUG_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: > %02x", byte);
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: > {:02x}", byte);
if (m_uPosition == 0)
{
command = byte; // first byte is command
@@ -361,11 +361,11 @@ void CEXIMemoryCard::TransferByte(u8& byte)
case cmdPageProgram:
case cmdExtraByteProgram:
case cmdChipErase:
DEBUG_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: command %02x at position 0. seems normal.",
command);
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0. seems normal.",
command);
break;
default:
WARN_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: command %02x at position 0", command);
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0", command);
break;
}
if (command == cmdClearStatus)
@@ -486,12 +486,12 @@ void CEXIMemoryCard::TransferByte(u8& byte)
break;

default:
WARN_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: unknown command byte %02x", byte);
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: unknown command byte {:02x}", byte);
byte = 0xFF;
}
}
m_uPosition++;
DEBUG_LOG(EXPANSIONINTERFACE, "EXI MEMCARD: < %02x", byte);
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: < {:02x}", byte);
}

void CEXIMemoryCard::DoState(PointerWrap& p)
@@ -534,7 +534,7 @@ void CEXIMemoryCard::DMARead(u32 _uAddr, u32 _uSize)

if ((address + _uSize) % Memcard::BLOCK_SIZE == 0)
{
INFO_LOG(EXPANSIONINTERFACE, "reading from block: %x", address / Memcard::BLOCK_SIZE);
INFO_LOG_FMT(EXPANSIONINTERFACE, "reading from block: {:x}", address / Memcard::BLOCK_SIZE);
}

// Schedule transfer complete later based on read speed
@@ -550,7 +550,7 @@ void CEXIMemoryCard::DMAWrite(u32 _uAddr, u32 _uSize)

if (((address + _uSize) % Memcard::BLOCK_SIZE) == 0)
{
INFO_LOG(EXPANSIONINTERFACE, "writing to block: %x", address / Memcard::BLOCK_SIZE);
INFO_LOG_FMT(EXPANSIONINTERFACE, "writing to block: {:x}", address / Memcard::BLOCK_SIZE);
}

// Schedule transfer complete later based on write speed
@@ -82,33 +82,33 @@ void CEXIMic::StreamStart()
u32 minimum_latency;
if (cubeb_get_min_latency(m_cubeb_ctx.get(), &params, &minimum_latency) != CUBEB_OK)
{
WARN_LOG(EXPANSIONINTERFACE, "Error getting minimum latency");
WARN_LOG_FMT(EXPANSIONINTERFACE, "Error getting minimum latency");
}

if (cubeb_stream_init(m_cubeb_ctx.get(), &m_cubeb_stream, "Dolphin Emulated GameCube Microphone",
nullptr, &params, nullptr, nullptr,
std::max<u32>(buff_size_samples, minimum_latency), DataCallback,
state_callback, this) != CUBEB_OK)
{
ERROR_LOG(EXPANSIONINTERFACE, "Error initializing cubeb stream");
ERROR_LOG_FMT(EXPANSIONINTERFACE, "Error initializing cubeb stream");
return;
}

if (cubeb_stream_start(m_cubeb_stream) != CUBEB_OK)
{
ERROR_LOG(EXPANSIONINTERFACE, "Error starting cubeb stream");
ERROR_LOG_FMT(EXPANSIONINTERFACE, "Error starting cubeb stream");
return;
}

INFO_LOG(EXPANSIONINTERFACE, "started cubeb stream");
INFO_LOG_FMT(EXPANSIONINTERFACE, "started cubeb stream");
}

void CEXIMic::StreamStop()
{
if (m_cubeb_stream)
{
if (cubeb_stream_stop(m_cubeb_stream) != CUBEB_OK)
ERROR_LOG(EXPANSIONINTERFACE, "Error stopping cubeb stream");
ERROR_LOG_FMT(EXPANSIONINTERFACE, "Error stopping cubeb stream");
cubeb_stream_destroy(m_cubeb_stream);
m_cubeb_stream = nullptr;
}
@@ -266,7 +266,7 @@ void CEXIMic::TransferByte(u8& byte)
break;

default:
ERROR_LOG(EXPANSIONINTERFACE, "EXI MIC: unknown command byte %02x", command);
ERROR_LOG_FMT(EXPANSIONINTERFACE, "EXI MIC: unknown command byte {:02x}", command);
break;
}

@@ -184,17 +184,17 @@ template <typename T>
ReadHandlingMethod<T>* InvalidRead()
{
return ComplexRead<T>([](u32 addr) {
ERROR_LOG(MEMMAP, "Trying to read %zu bits from an invalid MMIO (addr=%08x)", 8 * sizeof(T),
addr);
ERROR_LOG_FMT(MEMMAP, "Trying to read {} bits from an invalid MMIO (addr={:08x})",
8 * sizeof(T), addr);
return -1;
});
}
template <typename T>
WriteHandlingMethod<T>* InvalidWrite()
{
return ComplexWrite<T>([](u32 addr, T val) {
ERROR_LOG(MEMMAP, "Trying to write %zu bits to an invalid MMIO (addr=%08x, val=%08x)",
8 * sizeof(T), addr, (u32)val);
ERROR_LOG_FMT(MEMMAP, "Trying to write {} bits to an invalid MMIO (addr={:08x}, val={:08x})",
8 * sizeof(T), addr, val);
});
}

@@ -299,7 +299,7 @@ void Init()

if (!*region.out_pointer)
{
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
PanicAlertFmt("MemoryMap_Setup: Failed finding a memory base.");
exit(0);
}
}
@@ -311,7 +311,7 @@ void Init()

Clear();

INFO_LOG(MEMMAP, "Memory system initialized. RAM at %p", m_pRAM);
INFO_LOG_FMT(MEMMAP, "Memory system initialized. RAM at {}", fmt::ptr(m_pRAM));
m_IsInitialized = true;
}

@@ -379,7 +379,7 @@ void UpdateLogicalMemory(const PowerPC::BatTable& dbat_table)
void* mapped_pointer = g_arena.CreateView(position, mapped_size, base);
if (!mapped_pointer)
{
PanicAlert("MemoryMap_Setup: Failed finding a memory base.");
PanicAlertFmt("MemoryMap_Setup: Failed finding a memory base.");
exit(0);
}
logical_mapped_entries.push_back({mapped_pointer, mapped_size});
@@ -418,7 +418,7 @@ void Shutdown()
}
g_arena.ReleaseSHMSegment();
mmio_mapping.reset();
INFO_LOG(MEMMAP, "Memory system shut down.");
INFO_LOG_FMT(MEMMAP, "Memory system shut down.");
}

void ShutdownFastmemArena()
@@ -482,7 +482,7 @@ void CopyFromEmu(void* data, u32 address, size_t size)
void* pointer = GetPointerForRange(address, size);
if (!pointer)
{
PanicAlert("Invalid range in CopyFromEmu. %zx bytes from 0x%08x", size, address);
PanicAlertFmt("Invalid range in CopyFromEmu. {:x} bytes from {:#010x}", size, address);
return;
}
memcpy(data, pointer, size);
@@ -496,7 +496,7 @@ void CopyToEmu(u32 address, const void* data, size_t size)
void* pointer = GetPointerForRange(address, size);
if (!pointer)
{
PanicAlert("Invalid range in CopyToEmu. %zx bytes to 0x%08x", size, address);
PanicAlertFmt("Invalid range in CopyToEmu. {:x} bytes to {:#010x}", size, address);
return;
}
memcpy(pointer, data, size);
@@ -510,7 +510,7 @@ void Memset(u32 address, u8 value, size_t size)
void* pointer = GetPointerForRange(address, size);
if (!pointer)
{
PanicAlert("Invalid range in Memset. %zx bytes at 0x%08x", size, address);
PanicAlertFmt("Invalid range in Memset. {:x} bytes at {:#010x}", size, address);
return;
}
memset(pointer, value, size);
@@ -547,8 +547,7 @@ u8* GetPointer(u32 address)
return m_pEXRAM + (address & GetExRamMask());
}

PanicAlert("Unknown Pointer 0x%08x PC 0x%08x LR 0x%08x", address, PC, LR);

PanicAlertFmt("Unknown Pointer {:#010x} PC {:#010x} LR {:#010x}", address, PC, LR);
return nullptr;
}

@@ -7,8 +7,10 @@
#include <cstdio>
#include <memory>

#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/HW/DVD/DVDInterface.h"
@@ -109,16 +111,17 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::DirectWrite<u32>(&Fifo_CPUWritePointer, 0xFFFFFFE0));

mmio->Register(base | PI_FIFO_RESET, MMIO::InvalidRead<u32>(),
MMIO::ComplexWrite<u32>(
[](u32, u32 val) { WARN_LOG(PROCESSORINTERFACE, "Fifo reset (%08x)", val); }));
MMIO::ComplexWrite<u32>([](u32, u32 val) {
WARN_LOG_FMT(PROCESSORINTERFACE, "Fifo reset ({:08x})", val);
}));

mmio->Register(base | PI_RESET_CODE, MMIO::ComplexRead<u32>([](u32) {
DEBUG_LOG(PROCESSORINTERFACE, "Read PI_RESET_CODE: %08x", m_ResetCode);
DEBUG_LOG_FMT(PROCESSORINTERFACE, "Read PI_RESET_CODE: {:08x}", m_ResetCode);
return m_ResetCode;
}),
MMIO::ComplexWrite<u32>([](u32, u32 val) {
m_ResetCode = val;
INFO_LOG(PROCESSORINTERFACE, "Wrote PI_RESET_CODE: %08x", m_ResetCode);
INFO_LOG_FMT(PROCESSORINTERFACE, "Wrote PI_RESET_CODE: {:08x}", m_ResetCode);
if (!SConfig::GetInstance().bWii && ~m_ResetCode & 0x4)
{
DVDInterface::ResetDrive(true);
@@ -193,13 +196,14 @@ void SetInterrupt(u32 cause_mask, bool set)

if (set && !(m_InterruptCause & cause_mask))
{
DEBUG_LOG(PROCESSORINTERFACE, "Setting Interrupt %s (set)", Debug_GetInterruptName(cause_mask));
DEBUG_LOG_FMT(PROCESSORINTERFACE, "Setting Interrupt {} (set)",
Debug_GetInterruptName(cause_mask));
}

if (!set && (m_InterruptCause & cause_mask))
{
DEBUG_LOG(PROCESSORINTERFACE, "Setting Interrupt %s (clear)",
Debug_GetInterruptName(cause_mask));
DEBUG_LOG_FMT(PROCESSORINTERFACE, "Setting Interrupt {} (clear)",
Debug_GetInterruptName(cause_mask));
}

if (set)
@@ -63,7 +63,7 @@ void InitSRAM()
{
if (!file.ReadArray(&g_SRAM, 1))
{
ERROR_LOG(EXPANSIONINTERFACE, "EXI IPL-DEV: Could not read all of SRAM");
ERROR_LOG_FMT(EXPANSIONINTERFACE, "EXI IPL-DEV: Could not read all of SRAM");
g_SRAM = sram_dump;
}
}
@@ -46,7 +46,6 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule:
#include "Core/HW/SystemTimers.h"

#include <cfloat>
#include <cinttypes>
#include <cmath>
#include <cstdlib>

@@ -193,8 +192,8 @@ void ThrottleCallback(u64 last_time, s64 cyclesLate)
const s64 max_fallback = config.iTimingVariance * 1000;
if (std::abs(diff) > max_fallback)
{
DEBUG_LOG(COMMON, "system too %s, %" PRIi64 " ms skipped", diff < 0 ? "slow" : "fast",
std::abs(diff) - max_fallback);
DEBUG_LOG_FMT(COMMON, "system too {}, {} ms skipped", diff < 0 ? "slow" : "fast",
std::abs(diff) - max_fallback);
last_time = time - max_fallback;
}
else if (diff > 1000)
@@ -315,9 +315,9 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
base | VI_VERTICAL_BEAM_POSITION,
MMIO::ComplexRead<u16>([](u32) { return 1 + (s_half_line_count) / 2; }),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
WARN_LOG(VIDEOINTERFACE,
"Changing vertical beam position to 0x%04x - not documented or implemented yet",
val);
WARN_LOG_FMT(
VIDEOINTERFACE,
"Changing vertical beam position to {:#06x} - not documented or implemented yet", val);
}));
mmio->Register(
base | VI_HORIZONTAL_BEAM_POSITION, MMIO::ComplexRead<u16>([](u32) {
@@ -327,9 +327,10 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
return std::clamp<u16>(value, 1, m_HTiming0.HLW * 2);
}),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
WARN_LOG(VIDEOINTERFACE,
"Changing horizontal beam position to 0x%04x - not documented or implemented yet",
val);
WARN_LOG_FMT(
VIDEOINTERFACE,
"Changing horizontal beam position to {:#06x} - not documented or implemented yet",
val);
}));

// The following MMIOs are interrupts related and update interrupt status
@@ -363,13 +364,13 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
MMIO::ComplexRead<u16>([](u32) { return m_UnkAARegister >> 16; }),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
m_UnkAARegister = (m_UnkAARegister & 0x0000FFFF) | ((u32)val << 16);
WARN_LOG(VIDEOINTERFACE, "Writing to the unknown AA register (hi)");
WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (hi)");
}));
mmio->Register(base | VI_UNK_AA_REG_LO,
MMIO::ComplexRead<u16>([](u32) { return m_UnkAARegister & 0xFFFF; }),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
m_UnkAARegister = (m_UnkAARegister & 0xFFFF0000) | val;
WARN_LOG(VIDEOINTERFACE, "Writing to the unknown AA register (lo)");
WARN_LOG_FMT(VIDEOINTERFACE, "Writing to the unknown AA register (lo)");
}));

// Control register writes only updates some select bits, and additional
@@ -744,16 +745,17 @@ static void LogField(FieldType field, u32 xfb_address)

const auto field_index = static_cast<size_t>(field);

DEBUG_LOG(VIDEOINTERFACE,
"(VI->BeginField): Address: %.08X | WPL %u | STD %u | EQ %u | PRB %u | "
"ACV %u | PSB %u | Field %s",
xfb_address, m_PictureConfiguration.WPL, m_PictureConfiguration.STD,
m_VerticalTimingRegister.EQU, vert_timing[field_index]->PRB,
m_VerticalTimingRegister.ACV, vert_timing[field_index]->PSB,
field_type_names[field_index]);

DEBUG_LOG(VIDEOINTERFACE, "HorizScaling: %04x | fbwidth %d | %u | %u", m_HorizontalScaling.Hex,
m_FBWidth.Hex, GetTicksPerEvenField(), GetTicksPerOddField());
DEBUG_LOG_FMT(VIDEOINTERFACE,
"(VI->BeginField): Address: {:08X} | WPL {} | STD {} | EQ {} | PRB {} | "
"ACV {} | PSB {} | Field {}",
xfb_address, m_PictureConfiguration.WPL, m_PictureConfiguration.STD,
m_VerticalTimingRegister.EQU, vert_timing[field_index]->PRB,
m_VerticalTimingRegister.ACV, vert_timing[field_index]->PSB,
field_type_names[field_index]);

DEBUG_LOG_FMT(VIDEOINTERFACE, "HorizScaling: {:04x} | fbwidth {} | {} | {}",
m_HorizontalScaling.Hex, m_FBWidth.Hex, GetTicksPerEvenField(),
GetTicksPerOddField());
}

static void BeginField(FieldType field, u64 ticks)
@@ -145,7 +145,7 @@ void Init()

void Reset()
{
INFO_LOG(WII_IPC, "Resetting ...");
INFO_LOG_FMT(WII_IPC, "Resetting ...");
InitState();
}

@@ -238,22 +238,22 @@ void ClearX1()
ctrl.X1 = 0;
}

void GenerateAck(u32 _Address)
void GenerateAck(u32 address)
{
ctrl.Y2 = 1;
DEBUG_LOG(WII_IPC, "GenerateAck: %08x | %08x [R:%i A:%i E:%i]", ppc_msg, _Address, ctrl.Y1,
ctrl.Y2, ctrl.X1);
DEBUG_LOG_FMT(WII_IPC, "GenerateAck: {:08x} | {:08x} [R:{} A:{} E:{}]", ppc_msg, address, ctrl.Y1,
ctrl.Y2, ctrl.X1);
// Based on a hardware test, the IPC interrupt takes approximately 100 TB ticks to fire
// after Y2 is seen in the control register.
CoreTiming::ScheduleEvent(100 * SystemTimers::TIMER_RATIO, updateInterrupts);
}

void GenerateReply(u32 _Address)
void GenerateReply(u32 address)
{
arm_msg = _Address;
arm_msg = address;
ctrl.Y1 = 1;
DEBUG_LOG(WII_IPC, "GenerateReply: %08x | %08x [R:%i A:%i E:%i]", ppc_msg, _Address, ctrl.Y1,
ctrl.Y2, ctrl.X1);
DEBUG_LOG_FMT(WII_IPC, "GenerateReply: {:08x} | {:08x} [R:{} A:{} E:{}]", ppc_msg, address,
ctrl.Y1, ctrl.Y2, ctrl.X1);
// Based on a hardware test, the IPC interrupt takes approximately 100 TB ticks to fire
// after Y1 is seen in the control register.
CoreTiming::ScheduleEvent(100 * SystemTimers::TIMER_RATIO, updateInterrupts);
@@ -74,8 +74,8 @@ void DoState(PointerWrap& p);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base);

void ClearX1();
void GenerateAck(u32 _Address);
void GenerateReply(u32 _Address);
void GenerateAck(u32 address);
void GenerateReply(u32 address);

bool IsReady();
} // namespace IOS
@@ -11,7 +11,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstdio>
#include <cstring>
#include <mbedtls/md5.h>
@@ -255,11 +254,12 @@ class DataBinStorage final : public Storage
std::array<u8, 0x10> iv = s_sd_initial_iv;
m_iosc.Decrypt(IOS::HLE::IOSC::HANDLE_SD_KEY, iv.data(), reinterpret_cast<const u8*>(&header),
sizeof(Header), reinterpret_cast<u8*>(&header), IOS::PID_ES);
u32 banner_size = header.banner_size;
const u32 banner_size = header.banner_size;
if ((banner_size < FULL_BNR_MIN) || (banner_size > FULL_BNR_MAX) ||
(((banner_size - BNR_SZ) % ICON_SZ) != 0))
{
ERROR_LOG(CONSOLE, "Not a Wii save or read failure for file header size %x", banner_size);
ERROR_LOG_FMT(CONSOLE, "Not a Wii save or read failure for file header size {:x}",
banner_size);
return {};
}

@@ -269,9 +269,9 @@ class DataBinStorage final : public Storage
mbedtls_md5_ret(reinterpret_cast<const u8*>(&header), sizeof(Header), md5_calc.data());
if (md5_file != md5_calc)
{
ERROR_LOG(CONSOLE, "MD5 mismatch\n %016" PRIx64 "%016" PRIx64 " != %016" PRIx64 "%016" PRIx64,
Common::swap64(md5_file.data()), Common::swap64(md5_file.data() + 8),
Common::swap64(md5_calc.data()), Common::swap64(md5_calc.data() + 8));
ERROR_LOG_FMT(CONSOLE, "MD5 mismatch\n {:016x}{:016x} != {:016x}{:016x}",
Common::swap64(md5_file.data()), Common::swap64(md5_file.data() + 8),
Common::swap64(md5_calc.data()), Common::swap64(md5_calc.data() + 8));
return {};
}
return header;
@@ -392,7 +392,7 @@ class DataBinStorage final : public Storage

if (!WriteSignatures())
{
ERROR_LOG(CORE, "WiiSave::WriteFiles: Failed to write signatures");
ERROR_LOG_FMT(CORE, "WiiSave::WriteFiles: Failed to write signatures");
return false;
}
return true;
@@ -447,13 +447,14 @@ StoragePointer MakeDataBinStorage(IOS::HLE::IOSC* iosc, const std::string& path,
}

template <typename T>
static bool Copy(const char* description, Storage* source, std::optional<T> (Storage::*read_fn)(),
Storage* dest, bool (Storage::*write_fn)(const T&))
static bool Copy(std::string_view description, Storage* source,
std::optional<T> (Storage::*read_fn)(), Storage* dest,
bool (Storage::*write_fn)(const T&))
{
const std::optional<T> data = (source->*read_fn)();
if (data && (dest->*write_fn)(*data))
return true;
ERROR_LOG(CORE, "WiiSave::Copy: Failed to %s %s", !data ? "read" : "write", description);
ERROR_LOG_FMT(CORE, "WiiSave::Copy: Failed to {} {}", !data ? "read" : "write", description);
return false;
}

@@ -471,7 +472,7 @@ bool Import(const std::string& data_bin_path, std::function<bool()> can_overwrit
const std::optional<Header> header = data_bin->ReadHeader();
if (!header)
{
ERROR_LOG(CORE, "WiiSave::Import: Failed to read header");
ERROR_LOG_FMT(CORE, "WiiSave::Import: Failed to read header");
return false;
}
const auto nand = MakeNandStorage(ios.GetFS().get(), header->tid);