HUGE performance boost thanks to advice from @fleroviux ❤️
This commit is contained in:
@@ -21,30 +21,36 @@ inline void CheckCompareInterrupt(MI& mi, Registers& regs) {
|
||||
}
|
||||
}
|
||||
|
||||
void Interpreter::Step(Mem& mem) {
|
||||
CheckCompareInterrupt(mem.mmio.mi, regs);
|
||||
int Interpreter::Run(Mem& mem) {
|
||||
MMIO& mmio = mem.mmio;
|
||||
int count = 0;
|
||||
for(;count <= mmio.vi.cyclesPerHalfline; count++) {
|
||||
CheckCompareInterrupt(mem.mmio.mi, regs);
|
||||
|
||||
regs.prevDelaySlot = regs.delaySlot;
|
||||
regs.delaySlot = false;
|
||||
regs.prevDelaySlot = regs.delaySlot;
|
||||
regs.delaySlot = false;
|
||||
|
||||
u32 paddr = 0;
|
||||
if(!MapVAddr(regs, LOAD, regs.pc, paddr)) {
|
||||
HandleTLBException(regs, regs.pc);
|
||||
FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, LOAD), 0, false);
|
||||
return;
|
||||
u32 paddr = 0;
|
||||
if(!MapVAddr(regs, LOAD, regs.pc, paddr)) {
|
||||
HandleTLBException(regs, regs.pc);
|
||||
FireException(regs, GetTLBExceptionCode(regs.cop0.tlbError, LOAD), 0, false);
|
||||
return count;
|
||||
}
|
||||
|
||||
u32 instruction = mem.Read32(regs, paddr);
|
||||
|
||||
if(ShouldServiceInterrupt(regs)) {
|
||||
FireException(regs, ExceptionCode::Interrupt, 0, false);
|
||||
return count;
|
||||
}
|
||||
|
||||
regs.oldPC = regs.pc;
|
||||
regs.pc = regs.nextPC;
|
||||
regs.nextPC += 4;
|
||||
|
||||
Exec(mem, instruction);
|
||||
}
|
||||
|
||||
u32 instruction = mem.Read32(regs, paddr);
|
||||
|
||||
if(ShouldServiceInterrupt(regs)) {
|
||||
FireException(regs, ExceptionCode::Interrupt, 0, false);
|
||||
return;
|
||||
}
|
||||
|
||||
regs.oldPC = regs.pc;
|
||||
regs.pc = regs.nextPC;
|
||||
regs.nextPC += 4;
|
||||
|
||||
Exec(mem, instruction);
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace n64 {
|
||||
struct Interpreter {
|
||||
Interpreter() = default;
|
||||
~Interpreter() = default;
|
||||
void Step(Mem&);
|
||||
int Run(Mem&);
|
||||
void Reset() {
|
||||
regs.Reset();
|
||||
}
|
||||
|
||||
@@ -66,16 +66,28 @@ inline void logRSP(const RSP& rsp, const u32 instr) {
|
||||
}
|
||||
*/
|
||||
|
||||
void RSP::Step(Registers& regs, Mem& mem) {
|
||||
gpr[0] = 0;
|
||||
u32 instr = Util::ReadAccess<u32>(imem, pc & IMEM_DSIZE);
|
||||
oldPC = pc & 0xFFC;
|
||||
pc = nextPC & 0xFFC;
|
||||
nextPC += 4;
|
||||
void RSP::Run(int cpuCount, Registers& regs, Mem& mem) {
|
||||
while(cpuCount--) {
|
||||
if (!spStatus.halt) {
|
||||
regs.steps++;
|
||||
if (regs.steps > 2) {
|
||||
steps += 2;
|
||||
regs.steps -= 3;
|
||||
}
|
||||
|
||||
Exec(regs, mem, instr);
|
||||
while (steps > 0) {
|
||||
steps--;
|
||||
gpr[0] = 0;
|
||||
u32 instr = Util::ReadAccess<u32>(imem, pc & IMEM_DSIZE);
|
||||
oldPC = pc & 0xFFC;
|
||||
pc = nextPC & 0xFFC;
|
||||
nextPC += 4;
|
||||
|
||||
//logRSP(*this, instr);
|
||||
Exec(regs, mem, instr);
|
||||
//logRSP(*this, instr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto RSP::Read(u32 addr) -> u32{
|
||||
|
||||
@@ -113,7 +113,7 @@ struct Registers;
|
||||
struct RSP {
|
||||
RSP();
|
||||
void Reset();
|
||||
void Step(Registers& regs, Mem& mem);
|
||||
void Run(int, Registers& regs, Mem& mem);
|
||||
auto Read(u32 addr) -> u32;
|
||||
void Write(Mem& mem, Registers& regs, u32 addr, u32 value);
|
||||
void Exec(Registers& regs, Mem& mem, u32 instr);
|
||||
|
||||
Reference in New Issue
Block a user