//
#include "timing.h"
-
-#include "types.h"
+#include <stdint.h>
#include "log.h"
#define EVENT_LIST_SIZE 512
void (* timerCallback)(void);
};
+
static Event eventList[EVENT_LIST_SIZE];
-static uint32 nextEvent;
+static uint32_t nextEvent;
+
void InitializeEventList(void)
{
- for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
eventList[i].valid = false;
}
+
//We just slap the next event into the list, no checking, no nada...
void SetCallbackTime(void (* callback)(void), double time)
{
- for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (!eventList[i].valid)
{
WriteLog("SetCallbackTime() failed to find an empty slot in the list!\n");
}
+
void RemoveCallback(void (* callback)(void))
{
- for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (eventList[i].valid && eventList[i].timerCallback == callback)
{
}
}
+
void AdjustCallbackTime(void (* callback)(void), double time)
{
- for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (eventList[i].valid && eventList[i].timerCallback == callback)
{
}
}
+
double GetTimeToNextEvent(void)
{
double time = 0;
bool firstTime = true;
- for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (eventList[i].valid)
{
return time;
}
+
void HandleNextEvent(void)
{
double elapsedTime = eventList[nextEvent].eventTime;
void (* event)(void) = eventList[nextEvent].timerCallback;
- for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
+ for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
if (eventList[i].valid)
eventList[i].eventTime -= elapsedTime;
(*event)();
}
+