aboutsummaryrefslogtreecommitdiff
path: root/src/timer.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-06 21:44:15 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-06 21:44:15 +0100
commitba9fabf3367047a4e5db841ce8e73ef01d3f557c (patch)
treea4d57aeddd886ba50cfe294b6cb26d7836df251d /src/timer.c
parent7ee199c7ccd524bd92b1e2b3787a41e6e2b6a579 (diff)
downloadgold-mine-run-ba9fabf3367047a4e5db841ce8e73ef01d3f557c.tar.gz
gold-mine-run-ba9fabf3367047a4e5db841ce8e73ef01d3f557c.zip
Add timer wait
Diffstat (limited to 'src/timer.c')
-rw-r--r--src/timer.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/timer.c b/src/timer.c
index 73675dc..d7810b6 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -3,14 +3,15 @@
#include <go32.h>
#include <dpmi.h>
-/* updates 18.2 times per second by default */
volatile uint32_t ticks = 0;
+volatile static uint32_t ticks_to = 0;
static _go32_dpmi_seginfo old_handler, new_handler;
static void timer_handler()
{
ticks++;
+ ticks_to++;
}
void timer_init()
@@ -26,3 +27,9 @@ void timer_free()
if (_go32_dpmi_set_protected_mode_interrupt_vector(0x1c, &old_handler) == -1)
fprintf(stderr, "Failed to free the timer :(\n");
}
+
+void timer_wait(uint8_t t)
+{
+ while (ticks_to < t);
+ ticks_to = 0;
+}