#include "timer.h"

#include <assert.h>

void timer_init(struct timer* restrict timer, UINT interval, TIMERPROC timer_proc) {
	timer->id = 0;
	timer->interval = interval;
	timer->timer_proc = timer_proc;
}

int timer_set(struct timer* restrict timer) {
	assert(!timer->id);

	return !!(timer->id = SetTimer(NULL, timer->id, timer->interval, timer->timer_proc));
}

int timer_stop(struct timer* restrict timer) {
	assert(timer->id);

	BOOL ret = KillTimer(NULL, timer->id);
	timer->id = 0;
	return ret;
}
