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

View File

@ -839,7 +839,7 @@ public:
u64 ITCMTimestamp;
u64 TimestampMemory;
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;
bool NullFetch;
bool Store;

View File

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