public static int Delta(ForwardDeltaSimulationFrame beforeDeltaFrame, ForwardDeltaSimulationFrame currentDeltaFrame) { var delta = 0; var beforeShort = beforeDeltaFrame.DeltaFrame; var current = currentDeltaFrame.DeltaFrame; if (current < beforeShort) { // Wrap around delta = (256 - beforeShort) + current; } else { delta = current - beforeShort; } if (delta > 127) { throw new Exception($"short simulation frames are too close {beforeShort} and {current}"); } return(delta); }
public static AbsoluteSimulationFrame ToSimulationFrame(AbsoluteSimulationFrame simulationFrameReference, ForwardDeltaSimulationFrame shortSimulationFrame) { var referenceShort = FromSimulationFrame(simulationFrameReference); var delta = Delta(referenceShort, shortSimulationFrame); return(new AbsoluteSimulationFrame { Frame = simulationFrameReference.Frame + delta }); }