2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
37 QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate);
38 QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter);
40 __int64 counterRate; // LARGE_INTEGER type has no math functions so use int64
43 static AppTime g_appTime;
47 void CopyCStringToPascal( const char* src, unsigned char dst[256])
49 int len = strlen( src);
51 memcpy( dst + 1, src, len);
55 void CopyPascalStringToC( const unsigned char* src, char* dst)
58 memcpy( dst, src + 1, len);
66 QueryPerformanceCounter( (LARGE_INTEGER*)&counter);
68 counter -= g_appTime.baseCounter;
71 time.lo = (unsigned long)counter;
72 time.hi = (unsigned long)(counter >> 32);
77 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b)
82 __int64 value2 = b.hi;
88 return durationImmediate;
90 __int64 frac = value % g_appTime.counterRate;
91 value /= g_appTime.counterRate;
98 frac /= g_appTime.counterRate;
99 time = (Duration)frac;
104 frac /= g_appTime.counterRate;
107 time = (Duration)value;
114 static char g_filename[ 256];
115 char* ConvertFileName( const char* orgfilename)
117 // translate filename into proper path name
118 if (orgfilename[ 0] == ':')
120 strcpy( g_filename, orgfilename);
122 for (int n = 0; g_filename[ n]; n++)
124 if (g_filename[ n] == ':')
125 g_filename[ n] = '/';
131 char* ConvertFileName( const char* orgfilename, const char* junk)
133 return ConvertFileName(orgfilename);