aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dc/dc.c4
-rw-r--r--teensy/context.c10
2 files changed, 12 insertions, 2 deletions
diff --git a/dc/dc.c b/dc/dc.c
index c88937d..6285fd6 100644
--- a/dc/dc.c
+++ b/dc/dc.c
@@ -2,7 +2,7 @@
#include <teensy.h>
#include <math.h>
-#include <unistd.h>
+#include <time.h>
#define QOI_IMPLEMENTATION
#include "third/qoi.h"
@@ -80,7 +80,7 @@ int main(void)
ty_draw_end();
ty_tick();
- usleep(1000000 / (hints.ticrate * 2));
+ ty_sleep(1000 / hints.ticrate);
}
ty_free_image(img);
diff --git a/teensy/context.c b/teensy/context.c
index 7095fe3..060254c 100644
--- a/teensy/context.c
+++ b/teensy/context.c
@@ -2,6 +2,7 @@
#include "renderer.h"
#include <math.h>
+#include <time.h>
#include "platform.h"
@@ -49,3 +50,12 @@ int ty_tick(void)
}
return tics;
}
+
+// TODO: Find a better place for this
+void ty_sleep(uint64_t ms)
+{
+ struct timespec ts;
+ ts.tv_sec = ms / 1000;
+ ts.tv_nsec = (ms % 1000) * 1000000;
+ nanosleep(&ts, NULL);
+}