diff --git a/Src/Graphics/New3D/New3D.cpp b/Src/Graphics/New3D/New3D.cpp index 44553f3..3d418d2 100644 --- a/Src/Graphics/New3D/New3D.cpp +++ b/Src/Graphics/New3D/New3D.cpp @@ -351,7 +351,7 @@ void CNew3D::DescendCullingNode(UINT32 addr) sibling2Ptr = node[0x08 - m_offset] & 0x1FFFFFF; // mask colour table bits matrixOffset = node[0x03 - m_offset] & 0xFFF; - short extent = node[9 - m_offset] >> 16; + float test = ToFloat(Convert16BitProFloat(node[9 - m_offset] >> 16)); if ((node[0x00] & 0x07) != 0x06) { // colour table seems to indicate no siblings if (!(sibling2Ptr & 0x1000000) && sibling2Ptr) { @@ -1175,5 +1175,24 @@ void CNew3D::CalcTexOffset(int offX, int offY, int page, int x, int y, int& newX newY += ((oldPage + page) & 1) * 1024; // max page 0-1 } +UINT32 CNew3D::ConvertProFloat(UINT32 a1) +{ + int exponent = ((a1 & 0x7E000000) >> 25) + 127; + + int mantissa = (a1 & 0x1FFFFFF) >> 2; + + return (a1 & 0x80000000) | (exponent << 23) | mantissa; +} + +UINT32 CNew3D::Convert16BitProFloat(UINT32 a1) +{ + return ConvertProFloat(a1 << 15); +} + +float CNew3D::ToFloat(UINT32 a1) +{ + return *(float*)(&a1); +} + } // New3D diff --git a/Src/Graphics/New3D/New3D.h b/Src/Graphics/New3D/New3D.h index 110e88e..c28206c 100644 --- a/Src/Graphics/New3D/New3D.h +++ b/Src/Graphics/New3D/New3D.h @@ -178,6 +178,9 @@ private: void CalcTexOffset(int offX, int offY, int page, int x, int y, int& newX, int& newY); + UINT32 ConvertProFloat(UINT32 a1); // return float in hex or integer format + UINT32 Convert16BitProFloat(UINT32 a1); + float ToFloat(UINT32 a1); // integer float to actual IEEE 754 float /* * Data