summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorleo2001-01-03 13:48:15 +0000
committerleo2001-01-03 13:48:15 +0000
commit518bfd7a804a166b4a13281e304e227b23270e21 (patch)
tree9c035141d647d012d932b964d9b60e949bd00e25 /common
parent8639eb91fed187ed70792883efd8aa29ae5746ac (diff)
Big Endian fixes
git-svn-id: http://svn.leocad.org/trunk@199 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common')
-rw-r--r--common/matrix.cpp22
-rw-r--r--common/pieceinf.cpp2
2 files changed, 23 insertions, 1 deletions
diff --git a/common/matrix.cpp b/common/matrix.cpp
index 5356a0c..a23bc88 100644
--- a/common/matrix.cpp
+++ b/common/matrix.cpp
@@ -7,6 +7,7 @@
#include "matrix.h"
#include "file.h"
#include "defines.h"
+#include "config.h"
static float Identity[16] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
@@ -177,9 +178,30 @@ Matrix::~Matrix()
{
}
+#ifdef LC_BIG_ENDIAN
+
+float __LittleFloat (float l)
+{
+ union { unsigned char b[4]; float f; } in, out;
+
+ in.f = l;
+ out.b[0] = in.b[3];
+ out.b[1] = in.b[2];
+ out.b[2] = in.b[1];
+ out.b[3] = in.b[0];
+
+ return out.f;
+}
+#endif
+
// Expand from the .bin file
void Matrix::FromPacked (const float *mat)
{
+#ifdef LC_BIG_ENDIAN
+ for (int j = 0; j < 12; j++)
+ mat[i] = __LittleFloat (mat[i]);
+#endif
+
m[0] = mat[0];
m[1] = mat[1];
m[2] = mat[2];
diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp
index 158a242..533a522 100644
--- a/common/pieceinf.cpp
+++ b/common/pieceinf.cpp
@@ -532,7 +532,7 @@ void PieceInfo::LoadInformation()
pGroup->connections[bt] = 0xFFFF;
while(bt--)
{
- unsigned short tmp = GUINT16(*bytes);
+ unsigned short tmp = GUINT16(*((unsigned short*)bytes));
pGroup->connections[bt] = tmp;
bytes += sizeof(unsigned short);
}