stfu/Source/timer.c

26 lines
430 B
C

#if defined(STFU_MAIN) && !defined(STFU_TIMER)
#define STFU_TIMER
#include <math.h>
#include "config.h"
struct stfu_timer {
float v, a;
} stfu_init_timer() {
struct stfu_timer r;
r.v = 0;
r.a = (1.0f / STFU_AUDIO_FRAME_RATE);
return r;
}
// todo: Pass period parameter?
struct stfu_timer stfu_pump_timer(struct stfu_timer wave) {
wave.v += wave.a;
if (wave.v > 1000)
wave.v -= 1000;
return wave;
}
#endif