clockTicks calculation in latest version arm-new.h consume too much CPU power?
I didn't have experiences in emulator programming, so my question may be wrong or even don't make sense. But some point in arm cpu emulation confuse me a lot, so I post this question.
In comparison with v1.72, the major enhancement of latest version "arm-new.h" is instruction prefetch and more accurate clock ticks calculation (even includes clocks used by instruction fetch and data fetch).
My questions are:
(1) The inline functions to calcuate clocks used by instruction fetch and data feth are sort of complex in comparison with the instruction emulation it self. Almost every instruction need call once even twice one of the following functions.
Doesn't this a little too expensive?
(3) If my first question stands, then are prefetch mechanism and clock calculation the major reasons to make latest version VBA much slower than VBA 1.72?
(4) What's the major differences due to these enhancements when running GBA games?
I didn't have experiences in emulator programming, so my question may be wrong or even don't make sense. But some point in arm cpu emulation confuse me a lot, so I post this question.
In comparison with v1.72, the major enhancement of latest version "arm-new.h" is instruction prefetch and more accurate clock ticks calculation (even includes clocks used by instruction fetch and data fetch).
My questions are:
(1) The inline functions to calcuate clocks used by instruction fetch and data feth are sort of complex in comparison with the instruction emulation it self. Almost every instruction need call once even twice one of the following functions.
Doesn't this a little too expensive?
inline int codeTicksAccessSeq32(u32 address) // ARM SEQ
{
int addr = (address>>24)&15;
if ((addr>=0x08) && (addr<=0x0D))
{
if ((!(busPrefetch)) && (busPrefetchEnable) && (busPrefetchCount))
{
busPrefetchCount-=1;
return 0;
}
else if (busPrefetch)
{
busPrefetchCount-=2;
return 0;
}
else
return memoryWaitSeq32[addr];
}
else if (addr!=2)
{
return memoryWaitSeq32[addr];
}
else
{
return memoryWaitSeq32[addr] + 4;
}
}
(2) Most CPU hardware has an internal instruction queue and prefetch instructions is done by hardware circuit to increase CPU speed. But in emulated CPU, no matter prefetched instruction hit or not, instruction prefetch mechanism only add loading to PC's CPU. Why bother to emulated this hardware feature?inline int dataTicksAccessSeq32(u32 address)// DATA 32bits SEQ
{
int addr = (address>>24)&15;
int value = memoryWaitSeq32[addr]+1;
if ((addr>=0x08) && (addr<=0x0E))
{
busPrefetchCount=0;
busPrefetch=false;
}
else
{
// if ((addr>=0x05) && (addr<=0x07))
// {
// bool blank = (((DISPSTAT | (DISPSTAT>>1))&1==1) ? true : false);
// bool pixelDrawing = (((lcdTicks+40-clockTicks) & 3) == 0 ? true : false);
// value += ((!blank && pixelDrawing) ? videoMemoryWait[addr] : 0);
// }
busPrefetchCount+= value+1;
}
return value;
}
(3) If my first question stands, then are prefetch mechanism and clock calculation the major reasons to make latest version VBA much slower than VBA 1.72?
(4) What's the major differences due to these enhancements when running GBA games?