shithub: sce

Download patch

ref: c42559e6f69e773c74495eb586be64e113660536
parent: ab0aec975dbb6edd2e31cb425b7046cdde0ed93c
author: qwx <qwx@sciops.net>
date: Sun Feb 14 17:49:43 EST 2021

sce: equivalent, simpler timing code

--- a/sce.c
+++ b/sce.c
@@ -239,16 +239,12 @@
 	t0 = nsec();
 	for(;;){
 		step();
+		tc += 1;
 		t = nsec();
 		Δtc = (t - t0) / tdiv;
 		if(Δtc <= 0)
 			Δtc = 1;
-		else if(Δtc > 1){
-			t0 += (vlong)(Δtc - 1) * tdiv;
-			Δtc = 1;
-		}
 		t0 += Δtc * tdiv;
-		tc += Δtc;
 		dt = (t0 - t) / Te6;
 		if(dt > 0)
 			sleep(dt);