Skip to content

Commit

Permalink
[Misc] Use fmt::format instead of std::format and Misc Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xphalnos committed Mar 9, 2025
1 parent c4ad6a5 commit cd13fce
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Xenon/Base/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void saveConfig(const std::filesystem::path &path) {
data["General"]["VSync"] = vsyncEnabled;
data["General"]["QuitOnWindowClosure"] = shouldQuitOnWindowClosure;
data["General"]["LogLevel"].comments().push_back("# Controls the current log level output filter");
data["General"]["LogLevel"] = (int)currentLogLevel;
data["General"]["LogLevel"] = static_cast<int>(currentLogLevel);
data["General"]["LogAdvanced"] = islogAdvanced;

// SMC.
Expand Down
6 changes: 3 additions & 3 deletions Xenon/Base/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ void SetCurrentThreadRealtime(const std::chrono::nanoseconds period_ns) {
struct mach_timebase_info timebase {};
mach_timebase_info(&timebase);
const auto ticks_per_ns =
static_cast<double>(timebase.denom) / static_cast<double>(timebase.numer);
static_cast<f64>(timebase.denom) / static_cast<f64>(timebase.numer);

const auto period_ticks =
static_cast<u32>(static_cast<double>(period_ns.count()) * ticks_per_ns);
static_cast<u32>(static_cast<f64>(period_ns.count()) * ticks_per_ns);
const auto computation_ticks =
static_cast<u32>(static_cast<double>(computation_ns.count()) * ticks_per_ns);
static_cast<u32>(static_cast<f64>(computation_ns.count()) * ticks_per_ns);

thread_time_constraint_policy policy = {
.period = period_ticks,
Expand Down
6 changes: 3 additions & 3 deletions Xenon/Base/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#pragma once

#include <format>
#include <fmt/format.h>
#include <type_traits>

// Vali0004: Helper macro to make me sane when doing RAII
Expand Down Expand Up @@ -107,7 +107,7 @@ template <typename cT, typename T>
// Associative container
size_t cSize = c.size();
if (cSize <= idx) [[unlikely]] {
assert_fail_debug_msg(std::format("Range check failed! (index: {}{})", idx, cSize != max_v<size_t> ? std::format(", size: {}", cSize) : ""));
assert_fail_debug_msg(fmt::format("Range check failed! (index: {}{})", idx, cSize != max_v<size_t> ? fmt::format(", size: {}", cSize) : ""));
}
auto it = std::begin(std::forward<cT>(c));
std::advance(it, idx);
Expand All @@ -123,7 +123,7 @@ template <typename cT, typename T>
if constexpr ((requires() { c.size(); }))
cSize = c.size();
if (found == c.end()) [[unlikely]] {
assert_fail_debug_msg(std::format("Range check failed! (index: {}{})", idx, cSize != max_v<size_t> ? std::format(", size: {}", cSize) : ""));
assert_fail_debug_msg(fmt::format("Range check failed! (index: {}{})", idx, cSize != max_v<size_t> ? fmt::format(", size: {}", cSize) : ""));
}
return found->second;
}
Expand Down
2 changes: 1 addition & 1 deletion Xenon/Core/RootBus/HostBridge/PCIBridge/SMC/SMC.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2025 XeEmulator Project
// Copyright 2025 Xenon Emulator Project

#include "SMC.h"

Expand Down
4 changes: 2 additions & 2 deletions Xenon/Core/XCPU/Interpreter/Interpreter_Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ u32 PPCInterpreter::CRCompU(PPU_STATE *ppuState, u64 num1, u64 num2) {
u32 PPCInterpreter::CRCompS32(PPU_STATE *ppuState, u32 num1, u32 num2) {
u32 CR = 0;

if ((long)num1 < (long)num2)
if (static_cast<sl32>(num1) < static_cast<sl32>(num2))
BSET(CR, 4, CR_BIT_LT);
else if ((long)num1 > (long)num2)
else if (static_cast<sl32>(num1) > static_cast<sl32>(num2))
BSET(CR, 4, CR_BIT_GT);
else
BSET(CR, 4, CR_BIT_EQ);
Expand Down
4 changes: 2 additions & 2 deletions Xenon/Core/XCPU/Interpreter/PPC_LS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ void PPCInterpreter::PPCInterpreter_lfd(PPU_STATE *ppuState) {
if (_ex & PPU_EX_DATASEGM || _ex & PPU_EX_DATASTOR)
return;

FPRi(frd).valueAsDouble = static_cast<double>(data);
FPRi(frd).valueAsDouble = static_cast<f64>(data);
}

// Load Floating-Point Single (x'C000 0000')
Expand All @@ -1062,5 +1062,5 @@ void PPCInterpreter::PPCInterpreter_lfs(PPU_STATE *ppuState) {
if (_ex & PPU_EX_DATASEGM || _ex & PPU_EX_DATASTOR)
return;

FPRi(frd).valueAsDouble = static_cast<double>(singlePresFP.valueAsFloat);
FPRi(frd).valueAsDouble = static_cast<f64>(singlePresFP.valueAsFloat);
}
10 changes: 5 additions & 5 deletions Xenon/Core/XCPU/Interpreter/PPC_System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ void PPCInterpreter::PPCInterpreter_rfid(PPU_STATE *ppuState) {
void PPCInterpreter::PPCInterpreter_tw(PPU_STATE *ppuState) {
X_FORM_TO_rA_rB;

long a = (long)ppuState->ppuThread[ppuState->currentThread].GPR[rA];
long b = (long)ppuState->ppuThread[ppuState->currentThread].GPR[rB];
sl32 a = static_cast<sl32>(ppuState->ppuThread[ppuState->currentThread].GPR[rA]);
sl32 b = static_cast<sl32>(ppuState->ppuThread[ppuState->currentThread].GPR[rB]);

if ((a < b && BGET(TO, 5, 0)) || (a > b && BGET(TO, 5, 1)) ||
(a == b && BGET(TO, 5, 2)) || (static_cast<u32>(a) < static_cast<u32>(b) && BGET(TO, 5, 3)) ||
Expand All @@ -168,10 +168,10 @@ void PPCInterpreter::PPCInterpreter_twi(PPU_STATE *ppuState) {
D_FORM_TO_rA_SI;
SI = EXTS(SI, 16);

long a = (long)ppuState->ppuThread[ppuState->currentThread].GPR[rA];
sl32 a = static_cast<sl32>(ppuState->ppuThread[ppuState->currentThread].GPR[rA]);

if ((a < (long)SI && BGET(TO, 5, 0)) || (a > (long)SI && BGET(TO, 5, 1)) ||
(a == (long)SI && BGET(TO, 5, 2)) || (static_cast<u32>(a) < SI && BGET(TO, 5, 3)) ||
if ((a < static_cast<sl32>(SI) && BGET(TO, 5, 0)) || (a > static_cast<sl32>(SI) && BGET(TO, 5, 1)) ||
(a == static_cast<sl32>(SI) && BGET(TO, 5, 2)) || (static_cast<u32>(a) < SI && BGET(TO, 5, 3)) ||
(static_cast<u32>(a) > SI && BGET(TO, 5, 4))) {
ppcInterpreterTrap(ppuState, static_cast<u32>(SI));
}
Expand Down
4 changes: 2 additions & 2 deletions Xenon/Core/XCPU/PPU/PowerPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@ typedef struct SOCSECENG_BLOCK { // Addr = 80000200_00024000

union SFPRegister // Single Precision
{
float valueAsFloat;
f32 valueAsFloat;
u32 valueAsU32;
};

union FPRegister // Double Precision
{
double valueAsDouble;
f64 valueAsDouble;
u64 valueAsU64;
};

Expand Down
2 changes: 1 addition & 1 deletion Xenon/Render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Render::Renderer::Start() {
LOG_ERROR(System, "Failed to initialize SDL: {}", SDL_GetError());
}

std::string title = std::format("Xenon {}", Base::VERSION);
const std::string title = fmt::format("Xenon {}", Base::VERSION);
// SDL3 window properties.
SDL_PropertiesID props = SDL_CreateProperties();
SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title.c_str());
Expand Down

0 comments on commit cd13fce

Please sign in to comment.