diff --git a/src/NDS.cpp b/src/NDS.cpp index fea5e5ca..b6aca36a 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -806,136 +806,6 @@ void NDS::SetARM9BIOS(const std::array& bios) noexcept ARM9BIOSNative = CRC32(ARM9BIOS.data(), ARM9BIOS.size()) == ARM9BIOSCRC32; } -u64 NDS::NextTarget() -{ - u64 minEvent = UINT64_MAX; - - u32 mask = SchedListMask; - for (int i = 0; i < Event_MAX; i++) - { - if (!mask) break; - if (mask & 0x1) - { - if (SchedList[i].Timestamp < minEvent) - minEvent = SchedList[i].Timestamp; - } - - mask >>= 1; - } - - u64 max = SysTimestamp + kMaxIterationCycles; - - if (minEvent < max + kIterationCycleMargin) - return minEvent; - - return max; -} - -void NDS::RunSystem(u64 timestamp) -{ - SysTimestamp = timestamp; - - u32 mask = SchedListMask; - for (int i = 0; i < Event_MAX; i++) - { - if (!mask) break; - if (mask & 0x1) - { - SchedEvent& evt = SchedList[i]; - - if (evt.Timestamp <= SysTimestamp) - { - SchedListMask &= ~(1<>= 1; - } -} - -void NDS::RunEventManual(u32 id) -{ - if (SchedListMask & (1<> ARM9ClockShift); - SchedEvent& evt = SchedList[id]; - - if (evt.Timestamp <= curts) - { - evt.Funcs[evt.FuncID](evt.That, evt.Param); - SchedListMask &= ~(1<>= 1; - } - - return minEvent; -} - -void NDS::RunSystemSleep(u64 timestamp) -{ - u64 offset = timestamp - SysTimestamp; - SysTimestamp = timestamp; - - u32 mask = SchedListMask; - for (int i = 0; i < Event_MAX; i++) - { - if (!mask) break; - if (i == Event_SPU || i == Event_RTC) - { - if (mask & 0x1) - { - SchedEvent& evt = SchedList[i]; - - if (evt.Timestamp <= SysTimestamp) - { - SchedListMask &= ~(1<>= 1; - } -} - #define A9WENTLAST (!MainRAMLastAccess) #define A7WENTLAST ( MainRAMLastAccess) #define A9LAST false @@ -1747,6 +1617,136 @@ bool NDS::MainRAMHandle() #undef A9PRIORITY #undef A7PRIORITY +u64 NDS::NextTarget() +{ + u64 minEvent = UINT64_MAX; + + u32 mask = SchedListMask; + for (int i = 0; i < Event_MAX; i++) + { + if (!mask) break; + if (mask & 0x1) + { + if (SchedList[i].Timestamp < minEvent) + minEvent = SchedList[i].Timestamp; + } + + mask >>= 1; + } + + u64 max = SysTimestamp + kMaxIterationCycles; + + if (minEvent < max + kIterationCycleMargin) + return minEvent; + + return max; +} + +void NDS::RunSystem(u64 timestamp) +{ + SysTimestamp = timestamp; + + u32 mask = SchedListMask; + for (int i = 0; i < Event_MAX; i++) + { + if (!mask) break; + if (mask & 0x1) + { + SchedEvent& evt = SchedList[i]; + + if (evt.Timestamp <= SysTimestamp) + { + SchedListMask &= ~(1<>= 1; + } +} + +void NDS::RunEventManual(u32 id) +{ + if (SchedListMask & (1<> ARM9ClockShift); + SchedEvent& evt = SchedList[id]; + + if (evt.Timestamp <= curts) + { + evt.Funcs[evt.FuncID](evt.That, evt.Param); + SchedListMask &= ~(1<>= 1; + } + + return minEvent; +} + +void NDS::RunSystemSleep(u64 timestamp) +{ + u64 offset = timestamp - SysTimestamp; + SysTimestamp = timestamp; + + u32 mask = SchedListMask; + for (int i = 0; i < Event_MAX; i++) + { + if (!mask) break; + if (i == Event_SPU || i == Event_RTC) + { + if (mask & 0x1) + { + SchedEvent& evt = SchedList[i]; + + if (evt.Timestamp <= SysTimestamp) + { + SchedListMask &= ~(1<>= 1; + } +} + template u32 NDS::RunFrame() {