avoid spamming host-RX checks every 8us if the host isn't responding

This commit is contained in:
Arisotura
2023-03-11 21:42:55 +01:00
parent 4905673d05
commit 4e6f054ffa

View File

@ -112,6 +112,7 @@ bool IsMP;
bool IsMPClient; bool IsMPClient;
u64 NextSync; // for clients: timestamp for next sync point u64 NextSync; // for clients: timestamp for next sync point
u64 RXTimestamp; u64 RXTimestamp;
u64 LastHostRXCheck;
// multiplayer host TX sequence: // multiplayer host TX sequence:
// 1. preamble // 1. preamble
@ -264,6 +265,7 @@ void Reset()
IsMPClient = false; IsMPClient = false;
NextSync = 0; NextSync = 0;
RXTimestamp = 0; RXTimestamp = 0;
LastHostRXCheck = 0;
WifiAP::Reset(); WifiAP::Reset();
} }
@ -340,6 +342,7 @@ void DoSavestate(Savestate* file)
file->Bool32(&IsMPClient); file->Bool32(&IsMPClient);
file->Var64(&NextSync); file->Var64(&NextSync);
file->Var64(&RXTimestamp); file->Var64(&RXTimestamp);
file->Var64(&LastHostRXCheck);
} }
@ -1658,8 +1661,12 @@ void USTimer(u32 param)
if (USTimestamp >= NextSync) if (USTimestamp >= NextSync)
{ {
// TODO: not do this every tick if it fails to receive a frame! u64 delay = USTimestamp - LastHostRXCheck;
if (delay >= 512)
{
CheckRX(2); CheckRX(2);
LastHostRXCheck = USTimestamp;
}
} }
} }