2006-02-24 05:17:19 +00:00
|
|
|
#ifndef __ZDBSP_H__
|
|
|
|
#define __ZDBSP_H__
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma once
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
#include <exception>
|
2006-05-31 20:25:20 +00:00
|
|
|
#include <stdexcept>
|
2006-02-24 05:17:19 +00:00
|
|
|
|
2006-06-03 04:12:33 +00:00
|
|
|
#ifdef _MSC_VER
|
2006-06-01 17:32:32 +00:00
|
|
|
typedef unsigned __int32 uint32_t;
|
|
|
|
typedef __int32 int32_t;
|
|
|
|
#else
|
|
|
|
#include <stdint.h>
|
|
|
|
#endif
|
|
|
|
|
2009-06-23 01:46:40 +00:00
|
|
|
#define ZDBSP_VERSION "1.12"
|
2006-02-24 05:17:19 +00:00
|
|
|
|
|
|
|
enum EBlockmapMode
|
|
|
|
{
|
|
|
|
EBM_Rebuild,
|
|
|
|
EBM_Create0
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ERejectMode
|
|
|
|
{
|
|
|
|
ERM_DontTouch,
|
|
|
|
ERM_CreateZeroes,
|
|
|
|
ERM_Create0,
|
|
|
|
ERM_Rebuild
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const char *Map;
|
|
|
|
extern const char *InName;
|
|
|
|
extern const char *OutName;
|
|
|
|
extern bool BuildNodes, BuildGLNodes, ConformNodes, GLOnly;
|
|
|
|
extern bool NoPrune;
|
|
|
|
extern EBlockmapMode BlockmapMode;
|
|
|
|
extern ERejectMode RejectMode;
|
|
|
|
extern int MaxSegs;
|
|
|
|
extern int SplitCost;
|
|
|
|
extern int AAPreference;
|
|
|
|
extern bool CheckPolyobjs;
|
|
|
|
extern bool ShowMap;
|
2006-06-01 01:05:24 +00:00
|
|
|
extern bool CompressNodes, CompressGLNodes, V5GLNodes;
|
2006-06-26 20:39:57 +00:00
|
|
|
extern bool HaveSSE1, HaveSSE2;
|
2006-02-24 05:17:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define FIXED_MAX INT_MAX
|
|
|
|
#define FIXED_MIN INT_MIN
|
|
|
|
|
|
|
|
#define FRACBITS 16
|
|
|
|
|
|
|
|
typedef int fixed_t;
|
|
|
|
typedef unsigned char BYTE;
|
|
|
|
typedef unsigned short WORD;
|
|
|
|
typedef signed short SWORD;
|
2006-06-01 17:32:32 +00:00
|
|
|
#ifdef _WIN32
|
2006-02-24 05:17:19 +00:00
|
|
|
typedef unsigned long DWORD;
|
2006-06-01 17:32:32 +00:00
|
|
|
#else
|
|
|
|
typedef uint32_t DWORD;
|
|
|
|
#endif
|
|
|
|
typedef uint32_t angle_t;
|
2006-02-24 05:17:19 +00:00
|
|
|
|
|
|
|
angle_t PointToAngle (fixed_t x, fixed_t y);
|
|
|
|
|
2009-03-15 12:18:25 +00:00
|
|
|
static const WORD NO_MAP_INDEX = 0xffff;
|
|
|
|
static const DWORD NO_INDEX = 0xffffffff;
|
2006-02-24 05:17:19 +00:00
|
|
|
static const angle_t ANGLE_MAX = 0xffffffff;
|
|
|
|
static const DWORD DWORD_MAX = 0xffffffff;
|
|
|
|
static const angle_t ANGLE_180 = (1u<<31);
|
|
|
|
static const angle_t ANGLE_EPSILON = 5000;
|
|
|
|
|
|
|
|
void Warn (const char *format, ...);
|
|
|
|
|
2006-06-01 01:05:24 +00:00
|
|
|
#if defined(_MSC_VER) && defined(_M_IX86)
|
2006-02-24 05:17:19 +00:00
|
|
|
|
|
|
|
#pragma warning (disable: 4035)
|
|
|
|
|
|
|
|
inline fixed_t Scale (fixed_t a, fixed_t b, fixed_t c)
|
|
|
|
{
|
|
|
|
__asm mov eax,a
|
|
|
|
__asm mov ecx,c
|
|
|
|
__asm imul b
|
|
|
|
__asm idiv ecx
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DivScale30 (fixed_t a, fixed_t b)
|
|
|
|
{
|
|
|
|
__asm mov edx,a
|
|
|
|
__asm sar edx,2
|
|
|
|
__asm mov eax,a
|
|
|
|
__asm shl eax,30
|
|
|
|
__asm idiv b
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t MulScale30 (fixed_t a, fixed_t b)
|
|
|
|
{
|
|
|
|
__asm mov eax,a
|
|
|
|
__asm imul b
|
|
|
|
__asm shrd eax,edx,30
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DMulScale32 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
|
|
|
{
|
|
|
|
__asm mov eax,a
|
|
|
|
__asm imul b
|
|
|
|
__asm mov ebx,eax
|
|
|
|
__asm mov eax,c
|
|
|
|
__asm mov esi,edx
|
|
|
|
__asm imul d
|
|
|
|
__asm add eax,ebx
|
|
|
|
__asm adc edx,esi
|
|
|
|
__asm mov eax,edx
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma warning (default: 4035)
|
|
|
|
|
2006-06-03 04:12:33 +00:00
|
|
|
#elif defined(__GNUC__)
|
|
|
|
|
|
|
|
inline fixed_t Scale (fixed_t a, fixed_t b, fixed_t c)
|
|
|
|
{
|
|
|
|
fixed_t result, dummy;
|
|
|
|
|
|
|
|
asm volatile
|
|
|
|
("imull %3\n\t"
|
|
|
|
"idivl %4"
|
|
|
|
: "=a,a,a,a,a,a" (result),
|
|
|
|
"=&d,&d,&d,&d,d,d" (dummy)
|
|
|
|
: "a,a,a,a,a,a" (a),
|
|
|
|
"m,r,m,r,d,d" (b),
|
|
|
|
"r,r,m,m,r,m" (c)
|
|
|
|
: "%cc"
|
|
|
|
);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DivScale30 (fixed_t a, fixed_t b)
|
|
|
|
{
|
|
|
|
fixed_t result, dummy;
|
|
|
|
asm volatile
|
|
|
|
("idivl %4"
|
|
|
|
: "=a,a" (result),
|
|
|
|
"=d,d" (dummy)
|
|
|
|
: "a,a" (a<<30),
|
|
|
|
"d,d" (a>>2),
|
|
|
|
"r,m" (b) \
|
|
|
|
: "%cc");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t MulScale30 (fixed_t a, fixed_t b)
|
|
|
|
{
|
|
|
|
return ((int64_t)a * b) >> 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DMulScale30 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
|
|
|
{
|
|
|
|
return (((int64_t)a * b) + ((int64_t)c * d)) >> 30;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DMulScale32 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
|
|
|
{
|
|
|
|
return (((int64_t)a * b) + ((int64_t)c * d)) >> 32;
|
|
|
|
}
|
|
|
|
|
2006-02-24 05:17:19 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
inline fixed_t Scale (fixed_t a, fixed_t b, fixed_t c)
|
|
|
|
{
|
|
|
|
return (fixed_t)(double(a)*double(b)/double(c));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DivScale30 (fixed_t a, fixed_t b)
|
|
|
|
{
|
|
|
|
return (fixed_t)(double(a)/double(b)*double(1<<30));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t MulScale30 (fixed_t a, fixed_t b)
|
|
|
|
{
|
|
|
|
return (fixed_t)(double(a)*double(b)/double(1<<30));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline fixed_t DMulScale30 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
|
|
|
{
|
|
|
|
return (fixed_t)((double(a)*double(b)+double(c)*double(d))/double(1<<30));
|
|
|
|
}
|
|
|
|
|
2006-05-31 20:25:20 +00:00
|
|
|
inline fixed_t DMulScale32 (fixed_t a, fixed_t b, fixed_t c, fixed_t d)
|
|
|
|
{
|
|
|
|
return (fixed_t)((double(a)*double(b)+double(c)*double(d))/4294967296.0);
|
|
|
|
}
|
|
|
|
|
2006-02-24 05:17:19 +00:00
|
|
|
#endif
|
|
|
|
|
2006-06-01 01:05:24 +00:00
|
|
|
// FIXME: No macros defined for big-endian machines.
|
|
|
|
#define LittleShort(x) (x)
|
|
|
|
#define LittleLong(x) (x)
|
2006-02-24 05:17:19 +00:00
|
|
|
|
2006-05-31 20:25:20 +00:00
|
|
|
#endif //__ZDBSP_H__
|