Skip to content

Commit 4f8df65

Browse files
committed
* add atVec2f
1 parent 8d3524b commit 4f8df65

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ if(WIN32)
2424
list(APPEND CORE_EXTRA src/win32_largefilewrapper.c)
2525
elseif(APPLE)
2626
list(APPEND CORE_EXTRA src/osx_largefilewrapper.c)
27+
elseif(GEKKO)
28+
list(APPEND CORE_EXTRA src/gekko_support.c)
2729
endif()
2830

2931
add_library(AthenaCore
@@ -41,7 +43,6 @@ add_library(AthenaCore
4143
src/LZ77/LZBase.cpp
4244
src/Athena/FileInfo.cpp
4345
src/Athena/Dir.cpp
44-
src/gekko_support.c
4546
${CORE_EXTRA}
4647

4748
include/Athena/IStream.hpp

include/Athena/IStreamReader.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,28 @@ class IStreamReader : public IStream
221221
return val != 0;
222222
}
223223

224+
/*! \brief Reads an atVec2f (8 bytes) and advances the current position
225+
*
226+
* \return atVec2f The value at the current address
227+
* \throw IOException when address is out of range
228+
*/
229+
inline atVec2f readVec3f()
230+
{
231+
atVec2f val;
232+
readUBytesToBuf(&val, 8);
233+
if (m_endian == BigEndian)
234+
{
235+
utility::BigFloat(val.vec[0]);
236+
utility::BigFloat(val.vec[1]);
237+
}
238+
else
239+
{
240+
utility::LittleFloat(val.vec[0]);
241+
utility::LittleFloat(val.vec[1]);
242+
}
243+
return val;
244+
}
245+
224246
/*! \brief Reads an atVec3f (12 bytes) and advances the current position
225247
*
226248
* \return atVec3f The value at the current address

include/Athena/IStreamWriter.hpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,27 @@ class IStreamWriter : public IStream
204204
*/
205205
inline void writeBool(bool val) {writeUBytes((atUint8*)&val, 1);}
206206

207+
/*! \brief Writes an atVec2f (8 bytes) to the buffer and advances the buffer.
208+
* It also swaps the bytes depending on the platform and Stream settings.
209+
*
210+
* \sa Endian
211+
* \param vec The value to write to the buffer
212+
*/
213+
inline void writeVec2f(atVec2f vec)
214+
{
215+
if (m_endian == BigEndian)
216+
{
217+
utility::BigFloat(vec.vec[0]);
218+
utility::BigFloat(vec.vec[1]);
219+
}
220+
else
221+
{
222+
utility::LittleFloat(vec.vec[0]);
223+
utility::LittleFloat(vec.vec[1]);
224+
}
225+
writeUBytes((atUint8*)&vec, 8);
226+
}
227+
207228
/*! \brief Writes an atVec3f (12 bytes) to the buffer and advances the buffer.
208229
* It also swaps the bytes depending on the platform and Stream settings.
209230
*

include/Athena/Types.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ typedef unsigned long long atUint64;
4646
#include <xmmintrin.h>
4747
#endif
4848

49+
typedef union
50+
{
51+
#if __clang__
52+
float clangVec __attribute__((__vector_size__(8)));
53+
#endif
54+
#if __SSE__
55+
__m128 mVec128;
56+
#endif
57+
float vec[2];
58+
} atVec2f;
59+
4960
typedef union
5061
{
5162
#if __clang__

0 commit comments

Comments
 (0)