source: Daodan/src/Daodan_Utility.c@ 383

Last change on this file since 383 was 380, checked in by rossy, 15 years ago

Update to one of Oni's timing functions. It might fix timing on Linux and on buggy Windows machines. It could also break animation and make Oni run slower that usual.

File size: 1.5 KB
Line 
1#include <windows.h>
2#include <stdlib.h>
3#include <stdarg.h>
4#include <stdint.h>
5#include "oni_stdio.h"
6
7#include "Daodan_Utility.h"
8#include "BFW_Utility.h"
9
10const double fps = 60.0;
11
12void __cdecl DDrStartupMessage(const char* fmt, ...)
13{
14 va_list ap;
15 va_start(ap, fmt);
16 char* buffer = malloc(vsnprintf(NULL, 0, fmt, ap) + 1);
17
18 vsprintf(buffer, fmt, ap);
19 va_end(ap);
20
21 if (!ONgFileStartup)
22 if (!(ONgFileStartup = oni_fopen("startup.txt", "w")))
23 return;
24
25 oni_fprintf(ONgFileStartup, "%s\n", buffer);
26 free(buffer);
27
28 oni_fflush(ONgFileStartup);
29 return;
30}
31
32/*
33int64_t ONICALL DDrMachineTime_Sixtieths()
34{
35 static int64_t LastTime, Time;
36 int64_t Current;
37
38 Current = LastTime + GetTickCount();
39
40 if (Current > Time)
41 {
42 LastTime += 1;
43 Current += 1;
44 }
45
46 Time = Current;
47
48 return (Time * 3) / 50;
49}
50*/
51
52int64_t ONICALL DDrMachineTime_Sixtieths()
53{
54 static uint32_t startticks = 0;
55 double ticks = 0;
56
57 if (startticks)
58 ticks = GetTickCount() - startticks;
59 else
60 startticks = GetTickCount();
61
62 return (int64_t)(ticks / 1000.0 * fps);
63}
64
65int64_t ONICALL DDrMachineTime_High()
66{
67// LARGE_INTEGER PerfCount;
68//
69// if (!QueryPerformanceCounter(&PerfCount))
70// PerfCount.QuadPart = GetTickCount();
71//
72// return PerfCount.QuadPart;
73 return GetTickCount();
74}
75
76double ONICALL DDrMachineTime_High_Frequency()
77{
78// LARGE_INTEGER Frequency;
79//
80// if (!QueryPerformanceFrequency(&Frequency))
81 return 1000.0;
82
83// return Frequency.QuadPart;
84}
Note: See TracBrowser for help on using the repository browser.