asdjkfhaskdjdf

This commit is contained in:
2026-05-25 17:14:11 +02:00
parent 3b7bdceabd
commit 670cc6cacd
8 changed files with 31 additions and 53 deletions
+20 -16
View File
@@ -52,18 +52,6 @@ bool Interpreter::MaybeAdvance() {
return false;
}
regs.push_to_stack_trace(regs.pc);
if ((u32)regs.pc == 0x4) {
auto &regs = Core::GetRegs();
std::sort(regs.stack_trace.begin(), regs.stack_trace.end());
std::println("Stack trace:");
for (int i = 0; i < regs.stack_trace.size(); i++) {
std::println(" [{:016X}]", regs.stack_trace[i]);
}
exit(1);
}
regs.oldPC = regs.pc;
regs.pc = regs.nextPC;
regs.nextPC += 4;
@@ -105,6 +93,14 @@ u32 Interpreter::Step() {
DecodeExecute(instr);
if (!mem.mmio.rsp.spStatus.halt) {
rspSyncCount++;
if (rspSyncCount >= 3)
Scheduler::GetInstance().EnqueueRelative(0, RSP_STEP);
}
Scheduler::GetInstance().HandleEvents();
return 1;
}
@@ -142,7 +138,7 @@ void CachedState::EvictLine(u64 addr) {
u32 Interpreter::ExecuteCached() {
auto addr = regs.pc;
auto block_addr = addr;
auto blockAddr = addr;
auto line = cachedState.GetLine(addr);
if (line) {
@@ -153,8 +149,7 @@ u32 Interpreter::ExecuteCached() {
Instruction instr = line->code[i];
DecodeExecute(instr);
Core::GetInstance().StepRSP(1);
Scheduler::GetInstance().HandleEvents();
// Branch likely with false condition, it wasn't taken so don't execute the delay slot
if (IsBranchLikely(instr) && !regs.delaySlot)
break;
@@ -192,7 +187,16 @@ u32 Interpreter::ExecuteCached() {
}
}
cachedState.InsertLine(block_addr, std::make_shared<CachedLine>(code, i, i));
if (!mem.mmio.rsp.spStatus.halt) {
for (int j = 1; j <= (int)std::floor((double)i / 3); j++) {
Scheduler::GetInstance().EnqueueRelative(j * 3, RSP_STEP);
}
} else {
regs.steps = 0;
mem.mmio.rsp.steps = 0;
}
cachedState.InsertLine(blockAddr, std::make_shared<CachedLine>(code, i, i));
return ExecuteCached();
}
+1
View File
@@ -64,6 +64,7 @@ struct Interpreter final {
Registers &regs;
Mem &mem;
u64 cop2Latch{};
u32 rspSyncCount = 0;
bool Fetch(Instruction &, u64);
void CacheTypeData(u8, u64, u32, u32);
+1 -4
View File
@@ -85,10 +85,7 @@ auto RSP::Read(const u32 addr) -> u32 {
default:
{
auto &regs = Core::GetRegs();
std::println("Stack trace:");
for (int i = 0; i < regs.stack_trace.size(); i++) {
std::println(" [{:016X}]", regs.stack_trace[i]);
}
panic("Unimplemented SP register read {:08X} (cpu pc: 0x{:016X}, rsp pc: 0x{:04X}, ra: 0x{:016X})", addr,
(u64)regs.oldPC, pc & 0xffc, (u64)regs.gpr[31]);
}
+1 -5
View File
@@ -6,10 +6,7 @@ namespace n64 {
#ifdef KAIZEN_JIT_ENABLED
Registers::Registers(JIT &jit) : jit(jit) { Reset(); }
#else
Registers::Registers() {
stack_trace.resize(0x10000000);
Reset();
}
Registers::Registers() { Reset(); }
#endif
void Registers::Reset() {
@@ -17,7 +14,6 @@ void Registers::Reset() {
lo = 0;
delaySlot = false;
prevDelaySlot = false;
std::fill(stack_trace.begin(), stack_trace.end(), 0);
gpr.fill(0);
regIsConstant = 1; // first bit is true indicating $zero is constant which yes it is always
-8
View File
@@ -48,14 +48,6 @@ struct Registers {
Cop0 cop0;
Cop1 cop1;
std::vector<u64> stack_trace;
int stack_count = 0;
void push_to_stack_trace(s64 val) {
stack_trace[stack_count++] = val;
stack_count %= stack_trace.size();
}
void CpuStall(u32 cycles) { extraCycles += cycles; }
u32 PopStalledCycles() {