#ifndef WL_DEF_H #define WL_DEF_H #include #include #include #include #include #include #if defined(_arch_dreamcast) # include #elif !defined(_WIN32) # include # include # include #elif defined(__GNUC__) # include #endif #include #if !defined O_BINARY # define O_BINARY 0 #endif #ifdef _arch_dreamcast typedef uint8 uint8_t; typedef uint16 uint16_t; typedef uint32 uint32_t; typedef int8 int8_t; typedef int16 int16_t; typedef int32 int32_t; typedef int64 int64_t; typedef ptr_t uintptr_t; #endif #define FRACBITS 16 #define FRACUNIT (1<(0xFFFFFFFFu-x+1u)) typedef uint32_t angle_t; #define TEXTURESHIFT 6 #define TEXTURESIZE (1<> 16); } static inline fixed FixedDiv(fixed a, fixed b) { return (fixed)(((((int64_t)a)<<32) / b) >> 16); } #define GetTicks() ((SDL_GetTicks()*7)/100) #define CHECKMALLOCRESULT(x) if(!(x)) Quit("Out of memory at %s:%i", __FILE__, __LINE__) #ifndef _WIN32 static inline char* itoa(int value, char* string, int radix) { sprintf(string, "%d", value); return string; } static inline char* ltoa(long value, char* string, int radix) { sprintf(string, "%ld", value); return string; } #endif #define typeoffsetof(type,variable) ((int)(size_t)&((type*)1)->variable - 1) #define lengthof(x) (sizeof(x) / sizeof(*(x))) #define endof(x) ((x) + lengthof(x)) static inline word READWORD(byte *&ptr) { word val = ptr[0] | ptr[1] << 8; ptr += 2; return val; } static inline longword READLONGWORD(byte *&ptr) { longword val = ptr[0] | ptr[1] << 8 | ptr[2] << 16 | ptr[3] << 24; ptr += 4; return val; } /* ============================================================================= FEATURE DEFINITIONS ============================================================================= */ #ifdef USE_FEATUREFLAGS // The currently available feature flags #define FF_STARSKY 0x0001 #define FF_PARALLAXSKY 0x0002 #define FF_CLOUDSKY 0x0004 #define FF_RAIN 0x0010 #define FF_SNOW 0x0020 // The ffData... variables contain the 16-bit values of the according corners of the current level. // The corners are overwritten with adjacent tiles after initialization in SetupGameLevel // to avoid interpretation as e.g. doors. extern int ffDataTopLeft, ffDataTopRight, ffDataBottomLeft, ffDataBottomRight; /************************************************************* * Current usage of ffData... variables: * ffDataTopLeft: lower 8-bit: ShadeDefID * ffDataTopRight: FeatureFlags * ffDataBottomLeft: CloudSkyDefID or ParallaxStartTexture * ffDataBottomRight: unused *************************************************************/ // The feature flags are stored as a wall in the upper right corner of each level static inline word GetFeatureFlags() { return ffDataTopRight; } #endif #ifdef USE_PARALLAX void DrawParallax(byte *vbuf, unsigned vbufPitch); #endif #ifdef USE_DIR3DSPR void Scale3DShape(byte *vbuf, unsigned vbufPitch, statobj_t *ob); #endif #endif