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 <**/
36 QueryPerformanceFrequency( (LARGE_INTEGER*)&counterRate);
37 QueryPerformanceCounter( (LARGE_INTEGER*)&baseCounter);
39 __int64 counterRate; // LARGE_INTEGER type has no math functions so use int64
42 static AppTime g_appTime;
46 void CopyCStringToPascal( const char* src, unsigned char dst[256])
48 int len = strlen( src);
50 memcpy( dst + 1, src, len);
54 void CopyPascalStringToC( const unsigned char* src, char* dst)
57 memcpy( dst, src + 1, len);
65 QueryPerformanceCounter( (LARGE_INTEGER*)&counter);
67 counter -= g_appTime.baseCounter;
70 time.lo = (unsigned long)counter;
71 time.hi = (unsigned long)(counter >> 32);
76 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b)
81 __int64 value2 = b.hi;
87 return durationImmediate;
89 __int64 frac = value % g_appTime.counterRate;
90 value /= g_appTime.counterRate;
96 frac /= g_appTime.counterRate;
97 time = (Duration)frac;
100 frac /= g_appTime.counterRate;
103 time = (Duration)value;
110 static char g_filename[ 256];
111 char* ConvertFileName( const char* orgfilename)
113 // translate filename into proper path name
114 if (orgfilename[ 0] == ':')
116 strcpy( g_filename, orgfilename);
118 for (int n = 0; g_filename[ n]; n++) {
119 if (g_filename[ n] == ':')
120 g_filename[ n] = '/';
126 char* ConvertFileName( const char* orgfilename, const char* junk)
128 return ConvertFileName(orgfilename);