Browse Source

Start stripping out more old defines from CoreLib.

Darryl Pogue 14 years ago
parent
commit
7c5eb380e0
  1. 48
      Sources/Plasma/CoreLib/hsConfig.h
  2. 6
      Sources/Plasma/CoreLib/hsGeometry3.cpp
  3. 29
      Sources/Plasma/CoreLib/hsScalar.h
  4. 159
      Sources/Plasma/CoreLib/hsStream.cpp
  5. 90
      Sources/Plasma/CoreLib/hsTypes.h
  6. 2
      Sources/Plasma/CoreLib/hsUtils.cpp

48
Sources/Plasma/CoreLib/hsConfig.h

@ -44,51 +44,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
///////////////////////Impulse Defines////////////////////////////////////////////////
#define HS_IMPULSE_SUPPORT_GRAY4 0
///////////////////////Plasma Defines //////////////////////////////////////////////////
#ifdef HS_BUILD_PLASMA
#define HS_IGNORE_T2K 1
#define HS_SUPPORT_NFNT_FONTS 1
#endif // HS_BUILD_PLASMA
//////////////////// Specific Compiler Stuff This Section is computed ////////////
#if defined(macintosh) && defined(__POWERPC__)
#define HS_BUILD_FOR_MACPPC 1
#define HS_CPU_BENDIAN 1
#elif defined(macintosh)
#define HS_BUILD_FOR_MAC68K 1
#elif defined(_M_IX86) && defined(_WIN32)
#elif defined(_WIN32)
#define HS_BUILD_FOR_WIN32 1
#define HS_CPU_LENDIAN 1
#elif defined(__unix__)
#define HS_BUILD_FOR_UNIX 1
#if defined(__intel__) || defined(__i386__)
#define HS_CPU_LENDIAN 1
#elif defined(__mips__)
#define HS_CPU_BENDIAN 1
#endif
#elif !HS_BUILD_FOR_PS2
#define HS_BUILD_FOR_REFERENCE 1
#endif
#if defined(HS_BUILD_FOR_MAC68K) || defined(HS_BUILD_FOR_MACPPC)
#define HS_BUILD_FOR_MAC 1
#endif
#if defined(__INTEL__) && defined(HS_BUILD_FOR_MAC)
#error "Can't have HS_BUILD_FOR_MAC defined"
#endif
#if (defined(GENERATING68K) || defined(GENERATINGPOWERPC)) && defined(HS_BUILD_FOR_WIN32)
#define "Can't define HS_BUILD_FOR_WIN32"
#endif
#define HS_SCALAR_IS_FIXED !(HS_SCALAR_IS_FLOAT)
@ -133,17 +98,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#endif
/////////////////////Myst3D Defines /////////////////////////////////////
#ifdef M3DRELEASE
#define PLASMA_NO_NETWORK 1
#define NEXUS_NO_2D 1
#define NO_LOAD_MSG 1
#define PLASMA_NO_CONSOLE 1
#define NEXUS_NO_DEBUG 1
#endif
///////////////////// Required facilities ///////////////////////////////
#ifndef HeadSpinHDefined
#include "HeadSpin.h"

6
Sources/Plasma/CoreLib/hsGeometry3.cpp

@ -73,12 +73,6 @@ void hsScalarTriple::Read(hsStream *stream)
// DANGER for speed read directly into these variables...ASSUMES fX,fY, and fZ are in contiguous order (PBG)
stream->Read12Bytes(&fX);
#if HS_BUILD_FOR_MAC
fX = hsSwapEndianFloat(fX);
fY = hsSwapEndianFloat(fY);
fZ = hsSwapEndianFloat(fZ);
#endif
}
void hsScalarTriple::Write(hsStream *stream) const

29
Sources/Plasma/CoreLib/hsScalar.h

@ -153,35 +153,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
inline float hsScalarAverage(float a, float b) { return (a + b) * float(0.5); }
inline float hsScalarAverage(float a, float b, float t) { return a + t * (b - a); }
#if (HS_BUILD_FOR_BE || (HS_BUILD_FOR_UNIX && !HS_BUILD_FOR_GCC322))
#define acosf(x) (float)acos(x)
#define asinf(x) (float)asin(x)
#define atanf(x) (float)atan(x)
#define atan2f(x, y) (float)atan2(x, y)
#define ceilf(x) (float)ceil(x)
#define cosf(x) (float)cos(x)
#define coshf(x) (float)cosh(x)
#define expf(x) (float)exp(x)
#define fabsf(x) (float)fabs(x)
#define floorf(x) (float)floor(x)
#define fmodf(x, y) (float)fmod(x, y)
#define logf(x) (float)log(x)
#define log10f(x) (float)log10(x)
#define powf(x, y) (float)pow(x, y)
#define sinf(x) (float)sin(x)
#define sinhf(x) (float)sinh(x)
#define sqrtf(x) (float)sqrt(x)
#define tanf(x) (float)tan(x)
#define tanhf(x) (float)tanh(x)
inline float modff(float x, float* y)
{
double _Di, _Df = modf(x, &_Di);
*y = (float)_Di;
return ((float)_Df);
}
#endif
inline hsScalar hsSquareRoot(hsScalar scalar) { return sqrtf(scalar); }
inline hsScalar hsSine(hsScalar angle) { return sinf(angle); }
inline hsScalar hsCosine(hsScalar angle) { return cosf(angle); }

159
Sources/Plasma/CoreLib/hsStream.cpp

@ -54,86 +54,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//////////////////////////////////////////////////////////////////////////////////
#if HS_CPU_BENDIAN
static void swapIt(Int32 *swap)
{
Byte* c = (Byte*)swap;
Byte t = c[0];
c[0] = c[3];
c[3] = t;
t = c[1];
c[1] = c[2];
c[2] = t;
}
static void swapIt(int *swap)
{
swapIt((Int32*)swap);
}
static void swapIt(float *swap)
{
swapIt((Int32*)swap);
}
static void swapIt(double *swap)
{
float* a = (float*)&swap;
float* b = (float*)(((Byte*)&swap)+4);
swapIt(a);
swapIt(b);
}
static void swapIt(Int16 *swap)
{
Byte *c = (Byte*)swap;
Byte t;
t = c[0];
c[0] = c[1];
c[1] = t;
}
#define unswapIt(value)
#else
#define swapIt(value)
static void unswapIt(Int32 *swap)
{
Byte* c = (Byte*)swap;
Byte t = c[0];
c[0] = c[3];
c[3] = t;
t = c[1];
c[1] = c[2];
c[2] = t;
}
static void unswapIt(int *swap)
{
unswapIt((Int32*)swap);
}
static void unswapIt(float *swap)
{
unswapIt((Int32*)swap);
}
static void unswapIt(double *swap)
{
float* a = (float*)&swap;
float* b = (float*)(((Byte*)&swap)+4);
swapIt(a);
swapIt(b);
}
static void unswapIt(Int16 *swap)
{
Byte *c = (Byte*)swap;
Byte t;
t = c[0];
c[0] = c[1];
c[1] = t;
}
#endif
//////////////////////////////////////////////////////////////////////////////////
void hsStream::FastFwd()
{
hsThrow("FastFwd unimplemented by subclass of stream");
@ -567,87 +487,77 @@ UInt16 hsStream::ReadSwap16()
{
UInt16 value;
this->Read(sizeof(UInt16), &value);
swapIt((Int16*)&value);
value = hsSWAP16(value);
return value;
}
void hsStream::ReadSwap16(int count, UInt16 values[])
{
this->Read(count * sizeof(UInt16), values);
#if HS_CPU_BENDIAN
for (int i = 0; i < count; i++)
swapIt((Int16*)&values[i]);
#endif
values[i] = hsSWAP16(values[i]);
}
UInt32 hsStream::ReadSwap32()
{
UInt32 value;
Read4Bytes(&value);
swapIt((Int32*)&value);
value = hsSWAP32(value);
return value;
}
void hsStream::ReadSwap32(int count, UInt32 values[])
{
this->Read(count * sizeof(UInt32), values);
#if HS_CPU_BENDIAN
for (int i = 0; i < count; i++)
swapIt((Int32*)&values[i]);
#endif
values[i] = hsSWAP32(values[i]);
}
UInt32 hsStream::ReadUnswap32()
{
UInt32 value;
Read4Bytes(&value);
unswapIt((Int32*)&value);
value = hsUNSWAP32(value);
return value;
}
#if HS_CAN_USE_FLOAT
double hsStream::ReadSwapDouble()
{
double ival;
Read8Bytes(&ival);
double *pval = (double *)&ival; // all in the name of speed,
swapIt(pval);
return *pval;
double value;
Read8Bytes(&value);
value = hsSWAPDouble(value);
return value;
}
void hsStream::ReadSwapDouble(int count, double values[])
{
this->Read(count * sizeof(double), values);
#if HS_CPU_BENDIAN
for (int i = 0; i < count; i++)
swapIt(&values[i]);
#endif
}
for (int i = 0; i < count; i++)
values[i] = hsSWAPDouble(values[i]);
}
float hsStream::ReadSwapFloat()
{
UInt32 ival;
Read4Bytes(&ival);
float *pval = (float *)&ival; // all in the name of speed,
swapIt(pval);
return *pval;
float value;
Read4Bytes(&value);
value = hsSWAPFloat(value);
return value;
}
void hsStream::ReadSwapFloat(int count, float values[])
{
this->Read(count * sizeof(float), values);
#if HS_CPU_BENDIAN
for (int i = 0; i < count; i++)
swapIt(&values[i]);
#endif
values[i] = hsSWAPFloat(values[i]);
}
float hsStream::ReadUnswapFloat()
{
float value;
float value;
this->Read(sizeof(float), &value);
unswapIt(&value);
value = hsUNSWAPFloat(value);
return value;
}
#endif
@ -688,7 +598,7 @@ void hsStream::WriteByte(UInt8 value)
void hsStream::WriteSwap16(UInt16 value)
{
swapIt((Int16*)&value);
value = hsSWAP16(value);
this->Write(sizeof(Int16), &value);
}
@ -700,7 +610,7 @@ void hsStream::WriteSwap16(int count, const UInt16 values[])
void hsStream::WriteSwap32(UInt32 value)
{
swapIt((Int32*)&value);
value = hsSWAP32(value);
this->Write(sizeof(Int32), &value);
}
@ -712,14 +622,14 @@ void hsStream::WriteSwap32(int count, const UInt32 values[])
void hsStream::WriteUnswap32(UInt32 value)
{
unswapIt((Int32*)&value);
value = hsUNSWAP32(value);
this->Write(sizeof(Int32), &value);
}
#if HS_CAN_USE_FLOAT
void hsStream::WriteSwapDouble(double value)
{
swapIt(&value);
value = hsSWAPDouble(value);
this->Write(sizeof(double), &value);
}
@ -731,7 +641,7 @@ void hsStream::WriteUnswap32(UInt32 value)
void hsStream::WriteSwapFloat(float value)
{
swapIt(&value);
value = hsSWAPFloat(value);
this->Write(sizeof(float), &value);
}
@ -743,7 +653,7 @@ void hsStream::WriteUnswap32(UInt32 value)
void hsStream::WriteUnswapFloat(float value)
{
unswapIt(&value);
value = hsUNSWAPFloat(value);
this->Write(sizeof(float), &value);
}
#endif
@ -1061,8 +971,6 @@ void hsFileStream::Truncate()
//////////////////////////////////////////////////////////////////////////////////////
#if !HS_BUILD_FOR_PS2
#if !(HS_BUILD_FOR_REFERENCE)
hsUNIXStream::~hsUNIXStream()
{
@ -1187,23 +1095,12 @@ void hsUNIXStream::Truncate()
{
if (!fRef)
return;
#if! __MWERKS__
int handle = _fileno(fRef);
#if !HS_BUILD_FOR_UNIX
int handle = fileno(fRef);
#if HS_BUILD_FOR_WIN32
_chsize(handle, fPosition);
#else
ftruncate(handle, fPosition);
#endif
#else
#if 1
UInt32 handle = (UInt32)fRef->handle;
OSErr err = ::SetEOF(handle, fPosition);
if(err != noErr)
{
hsThrow("Truncate error!");
}
#endif
#endif
}
void hsUNIXStream::Flush()
@ -1213,8 +1110,6 @@ void hsUNIXStream::Flush()
(void)::fflush(fRef);
}
#endif
#endif
//////////////////////////////////////////////////////////////////////////////////////

90
Sources/Plasma/CoreLib/hsTypes.h

@ -30,18 +30,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
/************************** Other Includes *****************************/
#include <stdlib.h>
#include <stdio.h>
#if !(HS_BUILD_FOR_REFERENCE)
#if HS_BUILD_FOR_MAC
#include <Types.h>
#include <string.h>
#include <ctype.h>
#include <memory.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#endif
#if HS_CAN_USE_FLOAT
#include <math.h>
#endif
@ -170,30 +161,59 @@ typedef UInt32 hsGSeedValue;
}
inline UInt32 hsSwapEndian32(UInt32 value)
{
return (value << 24) |
((value & 0xFF00) << 8) |
((value >> 8) & 0xFF00) |
(value >> 24);
return ((value) << 24) |
((value & 0x0000ff00) << 8) |
((value & 0x00ff0000) >> 8) |
((value) >> 24);
}
inline UInt64 hsSwapEndian64(UInt64 value)
{
return ((value) << 56) |
((value & 0x000000000000ff00) << 40) |
((value & 0x0000000000ff0000) << 24) |
((value & 0x00000000ff000000) << 8) |
((value & 0x000000ff00000000) >> 8) |
((value & 0x0000ff0000000000) >> 24) |
((value & 0x00ff000000000000) >> 40) |
((value) >> 56);
}
#if HS_CAN_USE_FLOAT
inline float hsSwapEndianFloat(float fvalue)
{
UInt32 value = *(UInt32*)&fvalue;
value = hsSwapEndian32(value);
return *(float*)&value;
}
inline float hsSwapEndianFloat(float fvalue)
{
UInt32 value = *(UInt32*)&fvalue;
value = hsSwapEndian32(value);
return *(float*)&value;
}
inline double hsSwapEndianDouble(double dvalue)
{
UInt64 value = *(UInt64*)&dvalue;
value = hsSwapEndian64(value);
return *(double*)&value;
}
#endif
#if HS_CPU_LENDIAN
#define hsUNSWAP16(n) hsSwapEndian16(n)
#define hsUNSWAP32(n) hsSwapEndian32(n)
#define hsSWAP16(n) (n)
#define hsSWAP32(n) (n)
#if LITTLE_ENDIAN
#define hsUNSWAP16(n) hsSwapEndian16(n)
#define hsUNSWAP32(n) hsSwapEndian32(n)
#define hsUNSWAP64(n) hsSwapEndian64(n)
#define hsUNSWAPFloat(n) hsSwapEndianFloat(n)
#define hsUNSWAPDouble(n) hsSwapEndianDouble(n)
#define hsSWAP16(n) (n)
#define hsSWAP32(n) (n)
#define hsSWAP64(n) (n)
#define hsSWAPFloat(n) (n)
#define hsSWAPDouble(n) (n)
#else
#define hsUNSWAP16(n) (n)
#define hsUNSWAP32(n) (n)
#define hsSWAP16(n) hsSwapEndian16(n)
#define hsSWAP32(n) hsSwapEndian32(n)
#define hsUNSWAP16(n) (n)
#define hsUNSWAP32(n) (n)
#define hsUNSWAP64(n) (n)
#define hsUNSWAPFloat(n) (n)
#define hsUNSWAPDouble(n) (n)
#define hsSWAP16(n) hsSwapEndian16(n)
#define hsSWAP32(n) hsSwapEndian32(n)
#define hsSWAP64(n) hsSwapEndian64(n)
#define hsSWAPFloat(n) hsSwapEndianFloat(n)
#define hsSWAPDouble(n) hsSwapEndianDouble(n)
#endif
inline void hsSwap(Int32& a, Int32& b)
@ -224,17 +244,7 @@ typedef UInt32 hsGSeedValue;
struct hsColor32 {
#if 1 // hsColor32 fixed-format optimization
UInt8 b, g, r, a;
#else
#if (HS_BUILD_FOR_WIN32 || HS_BUILD_FOR_BE)
UInt8 b, g, r, a;
#elif (HS_BUILD_FOR_UNIX && HS_CPU_BENDIAN)
UInt8 a, b, g, r;
#else
UInt8 a, r, g, b;
#endif
#endif
#ifdef __cplusplus
void SetARGB(UInt8 aa, UInt8 rr, UInt8 gg, UInt8 bb)

2
Sources/Plasma/CoreLib/hsUtils.cpp

@ -72,7 +72,6 @@ static char hsStrBuf[100];
char *hsScalarToStr(hsScalar s)
{
#if !(HS_BUILD_FOR_REFERENCE)
if (s == hsIntToScalar(hsScalarToInt(s)))
sprintf(hsStrBuf, "%d", hsScalarToInt(s));
else
@ -81,7 +80,6 @@ char *hsScalarToStr(hsScalar s)
#else
sprintf(hsStrBuf, "%d:%lu", hsFixedToInt(s), (UInt16)s);
#endif
#endif
return hsStrBuf;
}

Loading…
Cancel
Save