WWW.XYZW.DE The homepage of Dierk "Chaos" Ohlerich  
Home Releases Codes
Types FPU intrinsics Input Lag Iterate & Delete Load & Save Memory Leaks About Exceptions AGP Writes

Throughout this website, you will find references to symbols like sInt, sDPrintF or sVector

This refers to my types.hpp header file that defines lot's of basic types and stuff. S is for Sanity, my first real demo group.

I am not going to explain anything here, I just dump a section of my current types.hpp here. You are not supposed to use it as it is here, It's just for your reference when looking at sources on this page. There is no definite types.hpp, I change it from project to project to fit it my need. So if you want to adopt my header, modify it as you like. Maybe I will release a definite header later, but it will change most likely very often. Also note that I edited this file without trying to recompile, and I cut out all inline implementations since they are obvious.




#ifndef __TYPES_HPP__
#define __TYPES_HPP__

#define sDEBUG 1
#define sNORETURN __declspec(noreturn)  // use this for dead end funtions

/****************************************************************************/
/***                                                                      ***/
/***   Base Types and Funcs                                               ***/
/***                                                                      ***/
/****************************************************************************/

typedef unsigned char             sU8;
typedef signed char               sS8;
typedef unsigned short            sU16;
typedef short                     sS16;
typedef unsigned int              sU32;
typedef int                       sS32;
typedef float                     sF32;
typedef unsigned __int64          sU64;
typedef signed __int64            sS64;
typedef double                    sF64;
typedef int                       sInt;
typedef char                      sChar;
typedef signed char               sBool;
typedef void*                     sPtr;

/****************************************************************************/

#define sVARARG(p,i) (((sInt *)(p))[(i)+1])
#define sVARARGF(p,i) (*(sF64*)&(((sInt *)(p))[(i)+1]))
#define sOFFSET(t,m) ((sInt)(&((t*)0)->m))
#define sMAKECID(u,s,c) (((u)<<16)|((s)<<8)|(c))
#define sMAKE2(a,b) (((b)<<16)|(a))
#define sMAKE4(a,b,c,d) (((d)<<24)|((c)<<16)|((b)<<8)|(a))

/****************************************************************************/

#define sTRUE   (!0)
#define sFALSE  0
#define sPI     3.1415926535897932384626433832795
#define sPI2    6.28318530717958647692528676655901
#define sPIF    3.1415926535897932384626433832795f
#define sPI2F   6.28318530717958647692528676655901f

/****************************************************************************/

template  Type sMin(Type a,Type b);
template  Type sMax(Type a,Type b);
template  Type sSign(Type a);
template  Type sRange(Type a,Type b,Type c);
template  void sSwap(Type &a,Type &b);
template  Type sAlign(Type &a,sInt b);
sF32 sFade(sF32 a,sF32 b,sF32 fade);

sU32 sGetRnd();
sU32 sGetRnd(sU32 max);
sF32 sFGetRnd();
sF32 sFGetRnd(sF32 max);
void sSetRndSeed(sInt seed);
sInt sMakePower2(sInt val);
sInt sGetPower2(sInt val);
sU32 sDec3(sF32 x,sF32 y,sF32 z);

/****************************************************************************/
/***                                                                      ***/
/***   Intrinsics                                                         ***/
/***                                                                      ***/
/****************************************************************************/

sInt sAbs(sInt i);
void sSetMem(sPtr dd,sInt s,sInt c);
void sCopyMem(sPtr dd,sPtr ss,sInt c);
sInt sCmpMem(sPtr dd,sPtr ss,sInt c);
sInt sGetStringLen(sChar *s);


sF64 sFATan(sF64 f);
sF64 sFATan2(sF64 a,sF64 b);
sF64 sFCos(sF64 f);
sF64 sFAbs(sF64 f);
sF64 sFLog(sF64 f);
sF64 sFLog10(sF64 f);
sF64 sFSin(sF64 f);
sF64 sFSqrt(sF64 f);

sF64 sFACos(sF64 f);
sF64 sFASin(sF64 f);
sF64 sFCosH(sF64 f);
sF64 sFSinH(sF64 f);
sF64 sFTanH(sF64 f);

sF64 sFInvSqrt(sF64 f);

sF64 sFPow(sF64 a,sF64 b);
sF64 sFMod(sF64 a,sF64 b);
sF64 sFExp(sF64 f);

/****************************************************************************/
/***                                                                      ***/
/***   asm                                                                ***/
/***                                                                      ***/
/****************************************************************************/

sInt sFtol (const float f);
sF32 sFRound (const float f);
sInt sMulDiv(sInt var_a,sInt var_b,sInt var_c);
sInt sMulShift(sInt var_a,sInt var_b);
sInt sDivShift(sInt var_a,sInt var_b);

/****************************************************************************/
/***                                                                      ***/
/***   Memory and String                                                  ***/
/***                                                                      ***/
/****************************************************************************/

void sCopyString(sChar *d,sChar *s,sInt size);
sChar *sDupString(sChar *s,sInt minsize=8);
void sAppendString(sChar *d,sChar *s,sInt size);
void sParentString(sChar *path);
sInt sCmpString(sChar *a,sChar *b);
sInt sCmpStringI(sChar *a,sChar *b);
sChar *sFindString(sChar *s,sChar *f);
sChar *sFindStringI(sChar *s,sChar *f);

void __cdecl sSPrintF(sChar *buffer,sInt size,sChar *format,...); 
void sFormatString(sChar *buffer,sInt size,sChar *format,sChar **fp);

/****************************************************************************/
/***                                                                      ***/
/***   Debugging                                                          ***/
/***                                                                      ***/
/****************************************************************************/

sNORETURN void sVerifyFalse(sChar *file,sInt line);
void sDPrint(sChar *text);
void __cdecl sDPrintF(sChar *format,...);
sNORETURN void __cdecl sFatal(sChar *format,...);
#define sVERIFY(x) {if(!(x))sVerifyFalse(__FILE__,__LINE__);}
#define sVERIFYFALSE {sVerifyFalse(__FILE__,__LINE__);}

/****************************************************************************/
/***                                                                      ***/
/***   Simple Structs                                                     ***/
/***                                                                      ***/
/****************************************************************************/

struct sRect
{
  sInt x0,y0,x1,y1;
  void Init();
  void Init(sInt X0,sInt Y0,sInt X1,sInt Y1);
  sInt XSize() const;
  sInt YSize() const;
  void Init(struct sFRect &r);

  sBool Hit(sInt x,sInt y);
  sBool Hit(sRect &);
  sBool Inside(sRect &);
  void And(sRect &r);
  void Or(sRect &r);
  void Sort();
  void Extend(sInt i);
};

/****************************************************************************/
/***                                                                      ***/
/***   Vector and Matrix                                                  ***/
/***                                                                      ***/
/****************************************************************************/

struct sDLLSYSTEM sVector
{
  sF32 x,y,z,w;

  // lost of obvious functions ommited
};

/****************************************************************************/

struct sDLLSYSTEM sMatrix
{
  sVector i,j,k,l;

  // lost of obvious functions ommited
};