From bbac4e315e63f3c444de10a115a46ddf9ea7839e Mon Sep 17 00:00:00 2001 From: SimoneN64 Date: Sun, 26 May 2024 22:11:14 +0200 Subject: [PATCH] Small fixes and improvements --- src/backend/Core.cpp | 10 +++++----- src/backend/core/mmio/PI.cpp | 2 +- src/backend/core/registers/Registers.hpp | 2 +- src/utils/log.hpp | 9 +++++++-- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/backend/Core.cpp b/src/backend/Core.cpp index 0b257145..a3834919 100644 --- a/src/backend/Core.cpp +++ b/src/backend/Core.cpp @@ -59,15 +59,15 @@ void Core::Run(float volumeL, float volumeR) { for(; cycles < mem.mmio.vi.cyclesPerHalfline; cycles++, frameCycles++) { u32 taken = cpu->Step(); taken += regs.PopStalledCycles(); - static u32 cpuSteps = 0; - cpuSteps += taken; + + regs.steps += taken; if(mmio.rsp.spStatus.halt) { - cpuSteps = 0; + regs.steps = 0; mmio.rsp.steps = 0; } else { - while(cpuSteps > 2) { + while(regs.steps > 2) { mmio.rsp.steps += 2; - cpuSteps -= 3; + regs.steps -= 3; } while(mmio.rsp.steps > 0) { diff --git a/src/backend/core/mmio/PI.cpp b/src/backend/core/mmio/PI.cpp index 5828529f..083f1669 100644 --- a/src/backend/core/mmio/PI.cpp +++ b/src/backend/core/mmio/PI.cpp @@ -271,7 +271,7 @@ template <> void PI::BusWrite(u32 addr, u32 val) { if (val < CART_ISVIEWER_SIZE) { std::string message(val + 1, 0); std::copy(mem.isviewer.begin(), mem.isviewer.begin() + val, message.begin()); - Util::print("{}", message); + Util::always("{}", message); } else { Util::panic("ISViewer buffer size is emulated at {} bytes, but received a flush command for {} bytes!", CART_ISVIEWER_SIZE, val); } diff --git a/src/backend/core/registers/Registers.hpp b/src/backend/core/registers/Registers.hpp index 71e2220e..c182e818 100644 --- a/src/backend/core/registers/Registers.hpp +++ b/src/backend/core/registers/Registers.hpp @@ -13,7 +13,7 @@ struct Registers { s64 oldPC{}, pc{}, nextPC{}; s64 hi{}, lo{}; bool prevDelaySlot{}, delaySlot{}; - int steps = 0; + u32 steps = 0; u32 extraCycles = 0; void CpuStall(u32 cycles) { diff --git a/src/utils/log.hpp b/src/utils/log.hpp index b45647a5..8ad7e7d2 100644 --- a/src/utils/log.hpp +++ b/src/utils/log.hpp @@ -9,7 +9,7 @@ namespace Util { enum LogLevel : u8 { - Trace, Debug, Info, Warn, Error + Trace, Debug, Info, Warn, Error, Always }; #ifndef NDEBUG @@ -26,7 +26,7 @@ constexpr void print(const std::string& fmt, Args... args) { fmt::print(fmt::emphasis::bold | fg(fmt::color::red), fmt, args...); } else if constexpr(messageType == Warn) { fmt::print(fg(fmt::color::yellow), fmt, args...); - } else if constexpr(messageType == Info || messageType == Trace) { + } else if constexpr(messageType == Info || messageType == Trace || messageType == Always) { fmt::print(fmt, args...); } else if constexpr(messageType == Debug) { #ifndef NDEBUG @@ -76,6 +76,11 @@ constexpr void trace(const std::string& fmt, Args... args) { print("[TRACE] " + fmt + "\n", args...); } +template +constexpr void always(const std::string& fmt, Args... args) { + print(fmt + "\n", args...); +} + template constexpr void panic_trace(const std::string& fmt, Args... args) { #if !defined(NDEBUG) && !defined(_WIN32)