diff --git a/src/backend/core/Dynarec.cpp b/src/backend/core/Dynarec.cpp index 22600512..ccfd2601 100644 --- a/src/backend/core/Dynarec.cpp +++ b/src/backend/core/Dynarec.cpp @@ -6,7 +6,7 @@ Dynarec::Dynarec() : code(Xbyak::DEFAULT_MAX_CODE_SIZE, Xbyak::AutoGrow) {} void Dynarec::Recompile(Registers& regs, Mem& mem) { bool branch = false, prevBranch = false; - u16 start_addr = regs.pc; + u32 start_addr = regs.pc; Fn block = code.getCurr(); while(!prevBranch) { @@ -22,12 +22,13 @@ void Dynarec::Recompile(Registers& regs, Mem& mem) { } code.ret(); - codeCache[start_addr >> 12][start_addr & 15] = block; + codeCache[start_addr >> 20][start_addr & 0xFFF] = block; block(); } void Dynarec::AllocateOuter(Registers& regs) { - codeCache[regs.pc >> 20] = (Fn*)calloc(0xFFF, sizeof(Fn)); + u32 pc = regs.pc & 0xffffffff; + codeCache[pc >> 20] = (Fn*)calloc(0xFFF, sizeof(Fn)); } int Dynarec::Step(Mem &mem, Registers& regs) { @@ -36,9 +37,11 @@ int Dynarec::Step(Mem &mem, Registers& regs) { regs.prevDelaySlot = regs.delaySlot; regs.delaySlot = false; - if(codeCache[regs.pc >> 20]) { - if(codeCache[regs.pc >> 20][regs.pc & 0xfff]) { - codeCache[regs.pc >> 20][regs.pc & 0xfff](); + u32 pc = regs.pc & 0xffffffff; + + if(codeCache[pc >> 20]) { + if(codeCache[pc >> 20][pc & 0xfff]) { + codeCache[pc >> 20][pc & 0xfff](); } else { Recompile(regs, mem); } diff --git a/src/main.cpp b/src/main.cpp index 8d8d4050..d71a6b21 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #ifdef _WIN32 #define main SDL_main