2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../idlib/precompiled.h"
31 #include "sys_local.h"
33 const char * sysLanguageNames[] = {
34 "english", "spanish", "italian", "german", "french", "russian",
35 "polish", "korean", "japanese", "chinese", NULL
38 idCVar sys_lang( "sys_lang", "english", CVAR_SYSTEM | CVAR_ARCHIVE, "", sysLanguageNames, idCmdSystem::ArgCompletion_String<sysLanguageNames> );
41 idSys * sys = &sysLocal;
43 void idSysLocal::DebugPrintf( const char *fmt, ... ) {
46 va_start( argptr, fmt );
47 Sys_DebugVPrintf( fmt, argptr );
51 void idSysLocal::DebugVPrintf( const char *fmt, va_list arg ) {
52 Sys_DebugVPrintf( fmt, arg );
55 double idSysLocal::GetClockTicks( void ) {
56 return Sys_GetClockTicks();
59 double idSysLocal::ClockTicksPerSecond( void ) {
60 return Sys_ClockTicksPerSecond();
63 cpuid_t idSysLocal::GetProcessorId( void ) {
64 return Sys_GetProcessorId();
67 const char *idSysLocal::GetProcessorString( void ) {
68 return Sys_GetProcessorString();
71 const char *idSysLocal::FPU_GetState( void ) {
72 return Sys_FPU_GetState();
75 bool idSysLocal::FPU_StackIsEmpty( void ) {
76 return Sys_FPU_StackIsEmpty();
79 void idSysLocal::FPU_SetFTZ( bool enable ) {
80 Sys_FPU_SetFTZ( enable );
83 void idSysLocal::FPU_SetDAZ( bool enable ) {
84 Sys_FPU_SetDAZ( enable );
87 bool idSysLocal::LockMemory( void *ptr, int bytes ) {
88 return Sys_LockMemory( ptr, bytes );
91 bool idSysLocal::UnlockMemory( void *ptr, int bytes ) {
92 return Sys_UnlockMemory( ptr, bytes );
95 void idSysLocal::GetCallStack( address_t *callStack, const int callStackSize ) {
96 Sys_GetCallStack( callStack, callStackSize );
99 const char * idSysLocal::GetCallStackStr( const address_t *callStack, const int callStackSize ) {
100 return Sys_GetCallStackStr( callStack, callStackSize );
103 const char * idSysLocal::GetCallStackCurStr( int depth ) {
104 return Sys_GetCallStackCurStr( depth );
107 void idSysLocal::ShutdownSymbols( void ) {
108 Sys_ShutdownSymbols();
111 int idSysLocal::DLL_Load( const char *dllName ) {
112 return Sys_DLL_Load( dllName );
115 void *idSysLocal::DLL_GetProcAddress( int dllHandle, const char *procName ) {
116 return Sys_DLL_GetProcAddress( dllHandle, procName );
119 void idSysLocal::DLL_Unload( int dllHandle ) {
120 Sys_DLL_Unload( dllHandle );
123 void idSysLocal::DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) {
125 idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".dll", baseName );
126 #elif defined( __linux__ )
127 idStr::snPrintf( dllName, maxLength, "%s" CPUSTRING ".so", baseName );
128 #elif defined( MACOS_X )
129 idStr::snPrintf( dllName, maxLength, "%s" ".dylib", baseName );
131 #error OS define is required
135 sysEvent_t idSysLocal::GenerateMouseButtonEvent( int button, bool down ) {
138 ev.evValue = K_MOUSE1 + button - 1;
145 sysEvent_t idSysLocal::GenerateMouseMoveEvent( int deltax, int deltay ) {
147 ev.evType = SE_MOUSE;
149 ev.evValue2 = deltay;
155 void idSysLocal::FPU_EnableExceptions( int exceptions ) {
156 Sys_FPU_EnableExceptions( exceptions );
164 const char *Sys_TimeStampToStr( ID_TIME_T timeStamp ) {
165 static char timeString[MAX_STRING_CHARS];
166 timeString[0] = '\0';
168 tm* time = localtime( &timeStamp );
171 idStr lang = cvarSystem->GetCVarString( "sys_lang" );
172 if ( lang.Icmp( "english" ) == 0 ) {
173 // english gets "month/day/year hour:min" + "am" or "pm"
174 out = va( "%02d", time->tm_mon + 1 );
176 out += va( "%02d", time->tm_mday );
178 out += va( "%d", time->tm_year + 1900 );
180 if ( time->tm_hour > 12 ) {
181 out += va( "%02d", time->tm_hour - 12 );
182 } else if ( time->tm_hour == 0 ) {
185 out += va( "%02d", time->tm_hour );
188 out +=va( "%02d", time->tm_min );
189 if ( time->tm_hour >= 12 ) {
195 // europeans get "day/month/year 24hour:min"
196 out = va( "%02d", time->tm_mday );
198 out += va( "%02d", time->tm_mon + 1 );
200 out += va( "%d", time->tm_year + 1900 );
202 out += va( "%02d", time->tm_hour );
204 out += va( "%02d", time->tm_min );
206 idStr::Copynz( timeString, out, sizeof( timeString ) );