#include #include #include #include /* updates 18.2 times per second by default */ volatile uint32_t ticks = 0; static _go32_dpmi_seginfo old_handler, new_handler; static void timer_handler() { ticks++; } void timer_init() { _go32_dpmi_get_protected_mode_interrupt_vector(0x1c, &old_handler); new_handler.pm_offset = (unsigned long)timer_handler; new_handler.pm_selector = _go32_my_cs(); _go32_dpmi_chain_protected_mode_interrupt_vector(0x1c, &new_handler); } void timer_free() { if (_go32_dpmi_set_protected_mode_interrupt_vector(0x1c, &old_handler) == -1) fprintf(stderr, "Failed to free the timer :(\n"); }