linuxstuff.cpp
892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <unistd.h>
#include <sys/time.h>
#include "dependencies.h"
int kernelInit(void)
{
return 1;
}
void WaitForKeyboard(void)
{
}
void common_sleep(unsigned int mseconds )
{
// 1 milliseconds = 1000 microsecond.
// Windows Sleep uses miliseconds
// linux usleep uses microsecond
// and since the default
// usage of the code was under windows
// so the argument is coming in millisecond.
usleep( mseconds * 1000 );
}
/* Time functions */
//#include <rtl_time.h>
status_t
initftime(void) {
// nothing
return B_OK;
}
// you would have to start up with initftime() at the beginning
// of the game. And check for errors
bigtime_t
system_time (void) /* time since booting in microseconds */
{
// return (bigtime_t)gethrtime();
timeval tv;
timezone tz;
gettimeofday (&tv, &tz);
return (bigtime_t)tv.tv_sec * 1000000 + tv.tv_usec;
}