aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/bitbuf.h
diff options
context:
space:
mode:
authorNorthstar <northstar@northstar.tf>2022-04-13 19:29:44 -0300
committerBarichello <artur@barichello.me>2022-04-13 19:30:40 -0300
commit47ea109be0d73120ddfe6896494e1fce986515b3 (patch)
treefb440b3ab2a00bf506182a9c9a9500d1c4711e0c /NorthstarDedicatedTest/bitbuf.h
parent04b0b417d1c9f45a708d3e2eec9146fabe09c1d1 (diff)
downloadNorthstarLauncher-47ea109be0d73120ddfe6896494e1fce986515b3.tar.gz
NorthstarLauncher-47ea109be0d73120ddfe6896494e1fce986515b3.zip
Format project
Diffstat (limited to 'NorthstarDedicatedTest/bitbuf.h')
-rw-r--r--NorthstarDedicatedTest/bitbuf.h133
1 files changed, 104 insertions, 29 deletions
diff --git a/NorthstarDedicatedTest/bitbuf.h b/NorthstarDedicatedTest/bitbuf.h
index 902a9976..520e5d0a 100644
--- a/NorthstarDedicatedTest/bitbuf.h
+++ b/NorthstarDedicatedTest/bitbuf.h
@@ -32,9 +32,15 @@ using iptr = intptr_t;
// Endianess, don't use on PPC64 nor ARM64BE
#define LittleDWord(val) (val)
-static INLINE void StoreLittleDWord(u32* base, size_t dwordIndex, u32 dword) { base[dwordIndex] = LittleDWord(dword); }
+static INLINE void StoreLittleDWord(u32* base, size_t dwordIndex, u32 dword)
+{
+ base[dwordIndex] = LittleDWord(dword);
+}
-static INLINE u32 LoadLittleDWord(u32* base, size_t dwordIndex) { return LittleDWord(base[dwordIndex]); }
+static INLINE u32 LoadLittleDWord(u32* base, size_t dwordIndex)
+{
+ return LittleDWord(base[dwordIndex]);
+}
#include <algorithm>
@@ -84,13 +90,25 @@ enum EBitCoordType
class BitBufferBase
{
protected:
- INLINE void SetName(const char* name) { m_BufferName = name; }
+ INLINE void SetName(const char* name)
+ {
+ m_BufferName = name;
+ }
public:
- INLINE bool IsOverflowed() { return m_Overflow; }
- INLINE void SetOverflowed() { m_Overflow = true; }
+ INLINE bool IsOverflowed()
+ {
+ return m_Overflow;
+ }
+ INLINE void SetOverflowed()
+ {
+ m_Overflow = true;
+ }
- INLINE const char* GetName() { return m_BufferName; }
+ INLINE const char* GetName()
+ {
+ return m_BufferName;
+ }
private:
const char* m_BufferName = "";
@@ -419,13 +437,28 @@ class BFRead : public BitBufferBase
return fReturn;
}
- INLINE i32 ReadChar() { return ReadSBitLong(sizeof(char) << 3); }
- INLINE u32 ReadByte() { return ReadUBitLong(sizeof(unsigned char) << 3); }
+ INLINE i32 ReadChar()
+ {
+ return ReadSBitLong(sizeof(char) << 3);
+ }
+ INLINE u32 ReadByte()
+ {
+ return ReadUBitLong(sizeof(unsigned char) << 3);
+ }
- INLINE i32 ReadShort() { return ReadSBitLong(sizeof(short) << 3); }
- INLINE u32 ReadWord() { return ReadUBitLong(sizeof(unsigned short) << 3); }
+ INLINE i32 ReadShort()
+ {
+ return ReadSBitLong(sizeof(short) << 3);
+ }
+ INLINE u32 ReadWord()
+ {
+ return ReadUBitLong(sizeof(unsigned short) << 3);
+ }
- INLINE i32 ReadLong() { return (i32)(ReadUBitLong(sizeof(i32) << 3)); }
+ INLINE i32 ReadLong()
+ {
+ return (i32)(ReadUBitLong(sizeof(i32) << 3));
+ }
INLINE float ReadFloat()
{
u32 temp = ReadUBitLong(sizeof(float) << 3);
@@ -654,23 +687,35 @@ class BFRead : public BitBufferBase
return std::min(nCurOfs + nAdjust, m_DataBits);
}
- INLINE bool SeekRelative(size_t offset) { return Seek(GetNumBitsRead() + offset); }
+ INLINE bool SeekRelative(size_t offset)
+ {
+ return Seek(GetNumBitsRead() + offset);
+ }
- INLINE size_t TotalBytesAvailable() { return m_DataBytes; }
+ INLINE size_t TotalBytesAvailable()
+ {
+ return m_DataBytes;
+ }
- INLINE size_t GetNumBitsLeft() { return m_DataBits - GetNumBitsRead(); }
- INLINE size_t GetNumBytesLeft() { return GetNumBitsLeft() >> 3; }
+ INLINE size_t GetNumBitsLeft()
+ {
+ return m_DataBits - GetNumBitsRead();
+ }
+ INLINE size_t GetNumBytesLeft()
+ {
+ return GetNumBitsLeft() >> 3;
+ }
private:
- size_t m_DataBits; // 0x0010
+ size_t m_DataBits; // 0x0010
size_t m_DataBytes; // 0x0018
- u32 m_CachedBufWord; // 0x0020
+ u32 m_CachedBufWord; // 0x0020
u32 m_CachedBitsLeft; // 0x0024
- const u32* m_DataIn; // 0x0028
+ const u32* m_DataIn; // 0x0028
const u32* m_DataEnd; // 0x0030
- const u32* m_Data; // 0x0038
+ const u32* m_Data; // 0x0038
};
class BFWrite : public BitBufferBase
@@ -698,7 +743,10 @@ class BFWrite : public BitBufferBase
m_DataEnd = reinterpret_cast<u32*>(reinterpret_cast<u8*>(m_Data) + m_DataBytes);
}
- INLINE int GetNumBitsLeft() { return m_OutBitsLeft + (32 * (m_DataEnd - m_DataOut - 1)); }
+ INLINE int GetNumBitsLeft()
+ {
+ return m_OutBitsLeft + (32 * (m_DataEnd - m_DataOut - 1));
+ }
INLINE void Reset()
{
@@ -727,7 +775,10 @@ class BFWrite : public BitBufferBase
return reinterpret_cast<u8*>(m_Data);
}
- INLINE u8* GetData() { return GetBasePointer(); }
+ INLINE u8* GetData()
+ {
+ return GetBasePointer();
+ }
INLINE void Finish()
{
@@ -800,7 +851,10 @@ class BFWrite : public BitBufferBase
}
}
- INLINE void WriteSBitLong(i32 data, i32 numBits) { WriteUBitLong((u32)data, numBits, false); }
+ INLINE void WriteSBitLong(i32 data, i32 numBits)
+ {
+ WriteUBitLong((u32)data, numBits, false);
+ }
INLINE void WriteUBitVar(u32 n)
{
@@ -857,19 +911,40 @@ class BFWrite : public BitBufferBase
return !IsOverflowed();
}
- INLINE bool WriteBytes(const uptr data, i32 numBytes) { return WriteBits(data, numBytes << 3); }
+ INLINE bool WriteBytes(const uptr data, i32 numBytes)
+ {
+ return WriteBits(data, numBytes << 3);
+ }
- INLINE i32 GetNumBitsWritten() { return (32 - m_OutBitsLeft) + (32 * (m_DataOut - m_Data)); }
+ INLINE i32 GetNumBitsWritten()
+ {
+ return (32 - m_OutBitsLeft) + (32 * (m_DataOut - m_Data));
+ }
- INLINE i32 GetNumBytesWritten() { return (GetNumBitsWritten() + 7) >> 3; }
+ INLINE i32 GetNumBytesWritten()
+ {
+ return (GetNumBitsWritten() + 7) >> 3;
+ }
- INLINE void WriteChar(i32 val) { WriteSBitLong(val, sizeof(char) << 3); }
+ INLINE void WriteChar(i32 val)
+ {
+ WriteSBitLong(val, sizeof(char) << 3);
+ }
- INLINE void WriteByte(i32 val) { WriteUBitLong(val, sizeof(unsigned char) << 3, false); }
+ INLINE void WriteByte(i32 val)
+ {
+ WriteUBitLong(val, sizeof(unsigned char) << 3, false);
+ }
- INLINE void WriteShort(i32 val) { WriteSBitLong(val, sizeof(short) << 3); }
+ INLINE void WriteShort(i32 val)
+ {
+ WriteSBitLong(val, sizeof(short) << 3);
+ }
- INLINE void WriteWord(i32 val) { WriteUBitLong(val, sizeof(unsigned short) << 3); }
+ INLINE void WriteWord(i32 val)
+ {
+ WriteUBitLong(val, sizeof(unsigned short) << 3);
+ }
INLINE bool WriteString(const char* str)
{