fix branches being able to break the queue system

fixes bw2
This commit is contained in:
Jaklyy 2024-12-08 22:41:32 -05:00
parent 7a4234dcd8
commit f823a92020
3 changed files with 15 additions and 14 deletions

View File

@ -331,7 +331,7 @@ void ARMv5::JumpTo(u32 addr, bool restorecpsr, u8 R15)
{ {
//printf("JUMP! %08X %i %i\n", addr, restorecpsr, R15); //printf("JUMP! %08X %i %i\n", addr, restorecpsr, R15);
NDS.MonitorARM9Jump(addr); NDS.MonitorARM9Jump(addr);
BranchRestore = restorecpsr; BranchRestore = restorecpsr;
BranchUpdate = R15; BranchUpdate = R15;
BranchAddr = addr; BranchAddr = addr;
@ -382,15 +382,13 @@ void ARMv5::JumpTo_2()
// doesn't matter if we put garbage in the MSbs there // doesn't matter if we put garbage in the MSbs there
if (BranchAddr & 0x2) if (BranchAddr & 0x2)
{ {
DelayedQueue = &ARMv5::JumpTo_3A;
CodeRead32(BranchAddr-2); CodeRead32(BranchAddr-2);
QueueFunction(&ARMv5::JumpTo_3A);
} }
else else
{ {
DelayedQueue = &ARMv5::JumpTo_3B;
CodeRead32(BranchAddr); CodeRead32(BranchAddr);
QueueFunction(&ARMv5::JumpTo_3B);
} }
} }
else else
@ -399,19 +397,17 @@ void ARMv5::JumpTo_2()
R[15] = BranchAddr+4; R[15] = BranchAddr+4;
CPSR &= ~0x20; CPSR &= ~0x20;
DelayedQueue = &ARMv5::JumpTo_3C;
CodeRead32(BranchAddr); CodeRead32(BranchAddr);
QueueFunction(&ARMv5::JumpTo_3C);
} }
} }
void ARMv5::JumpTo_3A() void ARMv5::JumpTo_3A()
{ {
NextInstr[0] = RetVal >> 16; NextInstr[0] = RetVal >> 16;
DelayedQueue = &ARMv5::JumpTo_4;
CodeRead32(BranchAddr+2); CodeRead32(BranchAddr+2);
QueueFunction(&ARMv5::JumpTo_4);
} }
void ARMv5::JumpTo_3B() void ARMv5::JumpTo_3B()
@ -423,9 +419,8 @@ void ARMv5::JumpTo_3B()
void ARMv5::JumpTo_3C() void ARMv5::JumpTo_3C()
{ {
NextInstr[0] = RetVal; NextInstr[0] = RetVal;
DelayedQueue = &ARMv5::JumpTo_4;
CodeRead32(BranchAddr+4); CodeRead32(BranchAddr+4);
QueueFunction(&ARMv5::JumpTo_4);
} }
void ARMv5::JumpTo_4() void ARMv5::JumpTo_4()
@ -1377,12 +1372,13 @@ void ARMv5::CodeFetch()
if (NDS.ARM9Timestamp < TimestampMemory) NDS.ARM9Timestamp = TimestampMemory; if (NDS.ARM9Timestamp < TimestampMemory) NDS.ARM9Timestamp = TimestampMemory;
Store = false; Store = false;
DataRegion = Mem9_Null; DataRegion = Mem9_Null;
QueueFunction(&ARMv5::AddExecute);
} }
else else
{ {
DelayedQueue = &ARMv5::AddExecute;
CodeRead32(PC); CodeRead32(PC);
} }
QueueFunction(&ARMv5::AddExecute);
} }
void ARMv5::AddExecute() void ARMv5::AddExecute()

View File

@ -839,7 +839,7 @@ public:
u64 ITCMTimestamp; u64 ITCMTimestamp;
u64 TimestampMemory; u64 TimestampMemory;
void (ARMv5::*FuncQueue[32])(void); void (ARMv5::*FuncQueue[32])(void);
void (ARMv5::*DelayedQueue)(void); void (ARMv5::*DelayedQueue)(void); // adding more than one new entry to the queue while it's already active does not work. so uh. we use this to work around that. it's less than ideal...
u32 PC; u32 PC;
bool NullFetch; bool NullFetch;
bool Store; bool Store;

View File

@ -443,6 +443,7 @@ bool ARMv5::ICacheLookup(const u32 addr)
Store = false; Store = false;
RetVal = cacheLine[(addr & (ICACHE_LINELENGTH -1)) / 4]; RetVal = cacheLine[(addr & (ICACHE_LINELENGTH -1)) / 4];
QueueFunction(DelayedQueue);
return true; return true;
} }
} }
@ -554,6 +555,7 @@ void ARMv5::ICacheLookup_2()
} }
Store = false; Store = false;
DataRegion = Mem9_Null; DataRegion = Mem9_Null;
QueueFunction(DelayedQueue);
} }
void ARMv5::ICacheInvalidateByAddr(const u32 addr) void ARMv5::ICacheInvalidateByAddr(const u32 addr)
@ -2181,6 +2183,7 @@ void ARMv5::CodeRead32(u32 addr)
DataRegion = Mem9_Null; DataRegion = Mem9_Null;
Store = false; Store = false;
RetVal = ((u64)1<<63); RetVal = ((u64)1<<63);
QueueFunction(DelayedQueue);
return; return;
} }
@ -2192,6 +2195,7 @@ void ARMv5::CodeRead32(u32 addr)
DataRegion = Mem9_Null; DataRegion = Mem9_Null;
Store = false; Store = false;
RetVal = *(u32*)&ITCM[addr & (ITCMPhysicalSize - 1)]; RetVal = *(u32*)&ITCM[addr & (ITCMPhysicalSize - 1)];
QueueFunction(DelayedQueue);
return; return;
} }
@ -2253,6 +2257,7 @@ void ARMv5::CodeRead32_2()
Store = false; Store = false;
DataRegion = Mem9_Null; DataRegion = Mem9_Null;
QueueFunction(DelayedQueue);
return; return;
} }