Skip to content

Commit

Permalink
Small fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneN64 committed May 26, 2024
1 parent f6afa56 commit bbac4e3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/backend/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/core/mmio/PI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ template <> void PI::BusWrite<u32, false>(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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/core/registers/Registers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions src/utils/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Util {
enum LogLevel : u8 {
Trace, Debug, Info, Warn, Error
Trace, Debug, Info, Warn, Error, Always
};

#ifndef NDEBUG
Expand All @@ -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
Expand Down Expand Up @@ -76,6 +76,11 @@ constexpr void trace(const std::string& fmt, Args... args) {
print<Trace>("[TRACE] " + fmt + "\n", args...);
}

template <typename ...Args>
constexpr void always(const std::string& fmt, Args... args) {
print<Always>(fmt + "\n", args...);
}

template <typename ...Args>
constexpr void panic_trace(const std::string& fmt, Args... args) {
#if !defined(NDEBUG) && !defined(_WIN32)
Expand Down

0 comments on commit bbac4e3

Please sign in to comment.