Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

win_shared.c File Reference

#include "../game/q_shared.h"
#include "../qcommon/qcommon.h"
#include "win_local.h"
#include <lmerr.h>
#include <lmcons.h>
#include <lmwksta.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <direct.h>
#include <io.h>
#include <conio.h>

Include dependency graph for win_shared.c:

Include dependency graph

Go to the source code of this file.

Functions

void CPUID (int func, unsigned regs[4])
long fastftol (float f)
int Is3DNOW (void)
int IsKNI (void)
int IsMMX (void)
int IsPentium (void)
char * Sys_DefaultHomePath (void)
char * Sys_DefaultInstallPath (void)
char * Sys_GetCurrentUser (void)
int Sys_GetProcessorId (void)
int Sys_Milliseconds (void)
void Sys_SnapVector (float *v)

Variables

int sys_timeBase


Function Documentation

void CPUID int  func,
unsigned  regs[4]
[static]
 

Definition at line 111 of file win_shared.c.

References fh, and func().

Referenced by Is3DNOW(), IsKNI(), and IsMMX().

00112 {
00113     unsigned regEAX, regEBX, regECX, regEDX;
00114 
00115 #ifndef __VECTORC
00116     __asm mov eax, func
00117     __asm __emit 00fh
00118     __asm __emit 0a2h
00119     __asm mov regEAX, eax
00120     __asm mov regEBX, ebx
00121     __asm mov regECX, ecx
00122     __asm mov regEDX, edx
00123 
00124     regs[0] = regEAX;
00125     regs[1] = regEBX;
00126     regs[2] = regECX;
00127     regs[3] = regEDX;
00128 #else
00129     regs[0] = 0;
00130     regs[1] = 0;
00131     regs[2] = 0;
00132     regs[3] = 0;
00133 #endif
00134 }

Here is the call graph for this function:

long fastftol float  f  ) 
 

Definition at line 61 of file win_shared.c.

References f.

00061                          {
00062     static int tmp;
00063     __asm fld f
00064     __asm fistp tmp
00065     __asm mov eax, tmp
00066 }

int Is3DNOW void   )  [static]
 

Definition at line 169 of file win_shared.c.

References CPUID().

Referenced by Sys_GetProcessorId().

00170 {
00171     unsigned regs[4];
00172     char pstring[16];
00173     char processorString[13];
00174 
00175     // get name of processor
00176     CPUID( 0, ( unsigned int * ) pstring );
00177     processorString[0] = pstring[4];
00178     processorString[1] = pstring[5];
00179     processorString[2] = pstring[6];
00180     processorString[3] = pstring[7];
00181     processorString[4] = pstring[12];
00182     processorString[5] = pstring[13];
00183     processorString[6] = pstring[14];
00184     processorString[7] = pstring[15];
00185     processorString[8] = pstring[8];
00186     processorString[9] = pstring[9];
00187     processorString[10] = pstring[10];
00188     processorString[11] = pstring[11];
00189     processorString[12] = 0;
00190 
00191 //  REMOVED because you can have 3DNow! on non-AMD systems
00192 //  if ( strcmp( processorString, "AuthenticAMD" ) )
00193 //      return qfalse;
00194 
00195     // check AMD-specific functions
00196     CPUID( 0x80000000, regs );
00197     if ( regs[0] < 0x80000000 )
00198         return qfalse;
00199 
00200     // bit 31 of EDX denotes 3DNOW! support
00201     CPUID( 0x80000001, regs );
00202     if ( regs[3] & ( 1 << 31 ) )
00203         return qtrue;
00204 
00205     return qfalse;
00206 }

Here is the call graph for this function:

int IsKNI void   )  [static]
 

Definition at line 208 of file win_shared.c.

References CPUID().

Referenced by Sys_GetProcessorId().

00209 {
00210     unsigned regs[4];
00211 
00212     // get CPU feature bits
00213     CPUID( 1, regs );
00214 
00215     // bit 25 of EDX denotes KNI existence
00216     if ( regs[3] & ( 1 << 25 ) )
00217         return qtrue;
00218 
00219     return qfalse;
00220 }

Here is the call graph for this function:

int IsMMX void   )  [static]
 

Definition at line 222 of file win_shared.c.

References CPUID().

Referenced by Sys_GetProcessorId().

00223 {
00224     unsigned regs[4];
00225 
00226     // get CPU feature bits
00227     CPUID( 1, regs );
00228 
00229     // bit 23 of EDX denotes MMX existence
00230     if ( regs[3] & ( 1 << 23 ) )
00231         return qtrue;
00232     return qfalse;
00233 }

Here is the call graph for this function:

int IsPentium void   )  [static]
 

Definition at line 136 of file win_shared.c.

References err(), and test().

Referenced by Sys_GetProcessorId().

00137 {
00138     __asm 
00139     {
00140         pushfd                      // save eflags
00141         pop     eax
00142         test    eax, 0x00200000     // check ID bit
00143         jz      set21               // bit 21 is not set, so jump to set_21
00144         and     eax, 0xffdfffff     // clear bit 21
00145         push    eax                 // save new value in register
00146         popfd                       // store new value in flags
00147         pushfd
00148         pop     eax
00149         test    eax, 0x00200000     // check ID bit
00150         jz      good
00151         jmp     err                 // cpuid not supported
00152 set21:
00153         or      eax, 0x00200000     // set ID bit
00154         push    eax                 // store new value
00155         popfd                       // store new value in EFLAGS
00156         pushfd
00157         pop     eax
00158         test    eax, 0x00200000     // if bit 21 is on
00159         jnz     good
00160         jmp     err
00161     }
00162 
00163 err:
00164     return qfalse;
00165 good:
00166     return qtrue;
00167 }

Here is the call graph for this function:

char* Sys_DefaultHomePath void   ) 
 

Definition at line 298 of file win_shared.c.

Referenced by FS_Startup().

00298                                    {
00299     return NULL;
00300 }

char* Sys_DefaultInstallPath void   ) 
 

Definition at line 302 of file win_shared.c.

References Sys_Cwd().

Referenced by FS_Startup().

00303 {
00304     return Sys_Cwd();
00305 }

Here is the call graph for this function:

char* Sys_GetCurrentUser void   ) 
 

Definition at line 281 of file win_shared.c.

References strcpy().

Referenced by Sys_Init().

00282 {
00283     static char s_userName[1024];
00284     unsigned long size = sizeof( s_userName );
00285 
00286 
00287     if ( !GetUserName( s_userName, &size ) )
00288         strcpy( s_userName, "player" );
00289 
00290     if ( !s_userName[0] )
00291     {
00292         strcpy( s_userName, "player" );
00293     }
00294 
00295     return s_userName;
00296 }

Here is the call graph for this function:

int Sys_GetProcessorId void   ) 
 

Definition at line 235 of file win_shared.c.

References Is3DNOW(), IsKNI(), IsMMX(), and IsPentium().

Referenced by Sys_Init().

00236 {
00237 #if defined _M_ALPHA
00238     return CPUID_AXP;
00239 #elif !defined _M_IX86
00240     return CPUID_GENERIC;
00241 #else
00242 
00243     // verify we're at least a Pentium or 486 w/ CPUID support
00244     if ( !IsPentium() )
00245         return CPUID_INTEL_UNSUPPORTED;
00246 
00247     // check for MMX
00248     if ( !IsMMX() )
00249     {
00250         // Pentium or PPro
00251         return CPUID_INTEL_PENTIUM;
00252     }
00253 
00254     // see if we're an AMD 3DNOW! processor
00255     if ( Is3DNOW() )
00256     {
00257         return CPUID_AMD_3DNOW;
00258     }
00259 
00260     // see if we're an Intel Katmai
00261     if ( IsKNI() )
00262     {
00263         return CPUID_INTEL_KATMAI;
00264     }
00265 
00266     // by default we're functionally a vanilla Pentium/MMX or P2/MMX
00267     return CPUID_INTEL_MMX;
00268 
00269 #endif
00270 }

Here is the call graph for this function:

int Sys_Milliseconds void   ) 
 

Definition at line 42 of file win_shared.c.

References qboolean, sys_curtime, and sys_timeBase.

00043 {
00044     int         sys_curtime;
00045     static qboolean initialized = qfalse;
00046 
00047     if (!initialized) {
00048         sys_timeBase = timeGetTime();
00049         initialized = qtrue;
00050     }
00051     sys_curtime = timeGetTime() - sys_timeBase;
00052 
00053     return sys_curtime;
00054 }

void Sys_SnapVector float *  v  ) 
 

Definition at line 68 of file win_shared.c.

References f, and v.

Referenced by CL_CgameSystemCalls(), and SV_GameSystemCalls().

00069 {
00070     int i;
00071     float f;
00072 
00073     f = *v;
00074     __asm   fld     f;
00075     __asm   fistp   i;
00076     *v = i;
00077     v++;
00078     f = *v;
00079     __asm   fld     f;
00080     __asm   fistp   i;
00081     *v = i;
00082     v++;
00083     f = *v;
00084     __asm   fld     f;
00085     __asm   fistp   i;
00086     *v = i;
00087     /*
00088     *v = fastftol(*v);
00089     v++;
00090     *v = fastftol(*v);
00091     v++;
00092     *v = fastftol(*v);
00093     */
00094 }


Variable Documentation

int sys_timeBase
 

Definition at line 41 of file win_shared.c.


Generated on Thu Aug 25 15:44:29 2005 for Quake III Arena by  doxygen 1.3.9.1