Revert "run arm 7 first?"

Caused performance issues in games???
This commit is contained in:
Jaklyy 2024-12-16 13:13:24 -05:00
parent d383381260
commit cacf891330
1 changed files with 44 additions and 43 deletions

View File

@ -1651,88 +1651,89 @@ u32 NDS::RunFrame()
while (Running && GPU.TotalScanlines==0) while (Running && GPU.TotalScanlines==0)
{ {
u64 target = NextTarget(); u64 target = NextTarget();
ARM7Target = target; ARM9Target = target << ARM9ClockShift;
//ARM7Target = target; //ARM7Target = target;
//while (ARM7Timestamp < ARM7Target) while (std::max(std::max(ARM9Timestamp, DMA9Timestamp), A9ContentionTS << ARM9ClockShift) < ARM9Target)
{ {
//printf("A7 LOOP: %lli %lli\n", ARM9Timestamp>>ARM9ClockShift, ARM7Timestamp); CurCPU = 0;
CurCPU = 1; RunTimers(0);
RunTimers(1); GPU.GPU3D.Run();
if (ARM7.MRTrack.Type == MainRAMType::Null) if (ARM9.MRTrack.Type == MainRAMType::Null)
{ {
if (CPUStop & CPUStop_DMA7) if (CPUStop & CPUStop_GXStall)
{ {
DMAs[4].Run(); // GXFIFO stall
if (ARM7.MRTrack.Type == MainRAMType::Null) DMAs[5].Run(); s32 cycles = GPU.GPU3D.CyclesToRunFor();
if (ARM7.MRTrack.Type == MainRAMType::Null) DMAs[6].Run(); DMA9Timestamp = std::min(ARM9Target, std::max(ARM9Timestamp+(cycles<<ARM9ClockShift), DMA9Timestamp+(cycles<<ARM9ClockShift)));
if (ARM7.MRTrack.Type == MainRAMType::Null) DMAs[7].Run(); }
else if (CPUStop & CPUStop_DMA9)
{
DMAs[0].Run();
if (!(CPUStop & CPUStop_GXStall) && (ARM9.MRTrack.Type == MainRAMType::Null)) DMAs[1].Run();
if (!(CPUStop & CPUStop_GXStall) && (ARM9.MRTrack.Type == MainRAMType::Null)) DMAs[2].Run();
if (!(CPUStop & CPUStop_GXStall) && (ARM9.MRTrack.Type == MainRAMType::Null)) DMAs[3].Run();
if (ConsoleType == 1) if (ConsoleType == 1)
{ {
auto& dsi = dynamic_cast<melonDS::DSi&>(*this); auto& dsi = dynamic_cast<melonDS::DSi&>(*this);
dsi.RunNDMAs(1); dsi.RunNDMAs(0);
} }
} }
else else
{ {
//if (ARM7.abt > 16) ARM7Timestamp = ARM7Target; //if (ARM9.abt) ARM9Timestamp = ARM9Target;
ARM7.Execute<cpuMode>(); ARM9.Execute<cpuMode>();
} }
} }
RunTimers(1);
//printf("MAIN LOOP: 9 %lli %08X %08llX %i 7 %lli %08X %08llX %i %i %08X\n", ARM9Timestamp>>ARM9ClockShift, ARM9.PC, ARM9.CurInstr, (u8)ARM9.MRTrack.Type, ARM7Timestamp, ARM7.R[15], ARM7.CurInstr, (u8)ARM7.MRTrack.Type, IME[1], IE[1]); //printf("MAIN LOOP: 9 %lli %08X %08llX %i 7 %lli %08X %08llX %i %i %08X\n", ARM9Timestamp>>ARM9ClockShift, ARM9.PC, ARM9.CurInstr, (u8)ARM9.MRTrack.Type, ARM7Timestamp, ARM7.R[15], ARM7.CurInstr, (u8)ARM7.MRTrack.Type, IME[1], IE[1]);
RunTimers(0);
GPU.GPU3D.Run();
//if (MainRAMHandle()) break; //if (MainRAMHandle()) break;
MainRAMHandle(); MainRAMHandle();
target = ARM7Timestamp << ARM9ClockShift;//std::max(std::max(ARM9Timestamp, DMA9Timestamp) >> ARM9ClockShift, A9ContentionTS); target = std::max(std::max(ARM9Timestamp, DMA9Timestamp) >> ARM9ClockShift, A9ContentionTS);
if (target <= std::max(std::max(ARM9Timestamp, DMA9Timestamp), A9ContentionTS << ARM9ClockShift)) target = std::max(std::max(ARM9Timestamp, DMA9Timestamp), A9ContentionTS << ARM9ClockShift) + 1; if (target == ARM7Timestamp) target++;
while (std::max(std::max(ARM9Timestamp, DMA9Timestamp), A9ContentionTS << ARM9ClockShift) < target) while (ARM7Timestamp < target)
{ {
ARM9Target = target; ARM7Target = target;
CurCPU = 0; //printf("A7 LOOP: %lli %lli\n", ARM9Timestamp>>ARM9ClockShift, ARM7Timestamp);
RunTimers(0); CurCPU = 1;
GPU.GPU3D.Run(); RunTimers(1);
if (ARM9.MRTrack.Type == MainRAMType::Null) if (ARM7.MRTrack.Type == MainRAMType::Null)
{ {
if (CPUStop & CPUStop_GXStall) if (CPUStop & CPUStop_DMA7)
{ {
// GXFIFO stall DMAs[4].Run();
s32 cycles = GPU.GPU3D.CyclesToRunFor(); if (ARM7.MRTrack.Type == MainRAMType::Null) DMAs[5].Run();
DMA9Timestamp = std::min(ARM9Target, std::max(ARM9Timestamp+(cycles<<ARM9ClockShift), DMA9Timestamp+(cycles<<ARM9ClockShift))); if (ARM7.MRTrack.Type == MainRAMType::Null) DMAs[6].Run();
} if (ARM7.MRTrack.Type == MainRAMType::Null) DMAs[7].Run();
else if (CPUStop & CPUStop_DMA9)
{
DMAs[0].Run();
if (!(CPUStop & CPUStop_GXStall) && (ARM9.MRTrack.Type == MainRAMType::Null)) DMAs[1].Run();
if (!(CPUStop & CPUStop_GXStall) && (ARM9.MRTrack.Type == MainRAMType::Null)) DMAs[2].Run();
if (!(CPUStop & CPUStop_GXStall) && (ARM9.MRTrack.Type == MainRAMType::Null)) DMAs[3].Run();
if (ConsoleType == 1) if (ConsoleType == 1)
{ {
auto& dsi = dynamic_cast<melonDS::DSi&>(*this); auto& dsi = dynamic_cast<melonDS::DSi&>(*this);
dsi.RunNDMAs(0); dsi.RunNDMAs(1);
} }
} }
else else
{ {
//if (ARM9.abt) ARM9Timestamp = ARM9Target; //if (ARM7.abt > 16) ARM7Timestamp = ARM7Target;
ARM9.Execute<cpuMode>(); ARM7.Execute<cpuMode>();
} }
} }
RunTimers(0);
GPU.GPU3D.Run();
if (MainRAMHandle()) break; RunTimers(1);
if (!MainRAMHandle()) break;
} }
} }
RunSystem(target>>ARM9ClockShift); RunSystem(target);
if (CPUStop & CPUStop_Sleep) if (CPUStop & CPUStop_Sleep)
{ {