Huge refactor: Make Core a singleton

This commit is contained in:
irisz64
2025-07-29 11:08:05 +02:00
parent e0e887ce90
commit 3061334004
56 changed files with 426 additions and 594 deletions

View File

@@ -1,7 +1,7 @@
#include <Core.hpp>
namespace n64 {
Interpreter::Interpreter(ParallelRDP &parallel) : mem(regs, parallel) {}
Interpreter::Interpreter(ParallelRDP &parallel) {}
bool Interpreter::ShouldServiceInterrupt() const {
const bool interrupts_pending = (regs.cop0.status.im & regs.cop0.cause.interruptPending) != 0;
@@ -26,7 +26,7 @@ Disassembler::DisassemblyResult Interpreter::Disassemble(const u32 address) {
if (!regs.cop0.MapVAddr(Cop0::LOAD, address, paddr)) {
return {};
}
return Disassembler::GetInstance().Disassemble(address, mem.Read<u32>(regs, paddr));
return Disassembler::GetInstance().Disassemble(address, mem.Read<u32>(paddr));
}
int Interpreter::Step() {
@@ -48,7 +48,7 @@ int Interpreter::Step() {
return 1;
}
const u32 instruction = mem.Read<u32>(regs, paddr);
const u32 instruction = mem.Read<u32>(paddr);
if (ShouldServiceInterrupt()) {
regs.cop0.FireException(ExceptionCode::Interrupt, 0, regs.pc);
@@ -63,16 +63,4 @@ int Interpreter::Step() {
return 1;
}
std::vector<u8> Interpreter::Serialize() {
std::vector<u8> res{};
res.resize(sizeof(Registers));
memcpy(res.data(), &regs, sizeof(Registers));
return res;
}
void Interpreter::Deserialize(const std::vector<u8> &data) { memcpy(&regs, data.data(), sizeof(Registers)); }
} // namespace n64