Annotations and size asserts

This commit is contained in:
disinvite 2024-03-13 21:29:34 -04:00
parent a4d2179378
commit 0425b1e65e
4 changed files with 23 additions and 15 deletions

View File

@ -13,6 +13,7 @@ class MxBitset {
public: public:
MxBitset() { Tidy(); } MxBitset() { Tidy(); }
// SIZE 0x8
class Reference { class Reference {
friend class MxBitset<N>; friend class MxBitset<N>;
@ -27,8 +28,8 @@ class MxBitset {
private: private:
Reference(MxBitset<N>& p_bitset, size_t p_offset) : m_bitset(&p_bitset), m_offset(p_offset) {} Reference(MxBitset<N>& p_bitset, size_t p_offset) : m_bitset(&p_bitset), m_offset(p_offset) {}
MxBitset<N>* m_bitset; MxBitset<N>* m_bitset; // 0x00
size_t m_offset; size_t m_offset; // 0x04
}; };
Reference operator[](size_t p_bit) { return (Reference(*this, p_bit)); } Reference operator[](size_t p_bit) { return (Reference(*this, p_bit)); }
@ -44,7 +45,7 @@ class MxBitset {
size_t Count() size_t Count()
{ {
// debug only // debug only, intentionally unimplemented
return 0; return 0;
} }
@ -88,7 +89,7 @@ class MxBitset {
e_blocksRequired = N == 0 ? 0 : (N - 1) / e_bitsPerBlock e_blocksRequired = N == 0 ? 0 : (N - 1) / e_bitsPerBlock
}; };
MxU32 m_blocks[e_blocksRequired + 1]; // 0x0 MxU32 m_blocks[e_blocksRequired + 1]; // 0x00
}; };
#endif // MXBITSET_H #endif // MXBITSET_H

View File

@ -10,7 +10,7 @@
template <size_t BS, size_t NB> template <size_t BS, size_t NB>
class MxMemoryPool { class MxMemoryPool {
public: public:
MxMemoryPool() : m_pool(NULL), m_blockSize(BS){}; MxMemoryPool() : m_pool(NULL), m_blockSize(BS) {}
~MxMemoryPool() { delete[] m_pool; } ~MxMemoryPool() { delete[] m_pool; }
MxResult Allocate(); MxResult Allocate();
@ -20,9 +20,9 @@ class MxMemoryPool {
MxU32 GetPoolSize() const { return m_blockRef.Size(); } MxU32 GetPoolSize() const { return m_blockRef.Size(); }
private: private:
MxU8* m_pool; MxU8* m_pool; // 0x00
MxU32 m_blockSize; MxU32 m_blockSize; // 0x04
MxBitset<NB> m_blockRef; MxBitset<NB> m_blockRef; // 0x08
}; };
template <size_t BS, size_t NB> template <size_t BS, size_t NB>

View File

@ -12,6 +12,9 @@
#include <assert.h> #include <assert.h>
#include <list> #include <list>
typedef MxMemoryPool<64, 22> MxMemoryPool64;
typedef MxMemoryPool<128, 2> MxMemoryPool128;
// VTABLE: LEGO1 0x100dc760 // VTABLE: LEGO1 0x100dc760
class MxStreamerNotification : public MxNotificationParam { class MxStreamerNotification : public MxNotificationParam {
public: public:
@ -72,10 +75,10 @@ class MxStreamer : public MxCore {
{ {
switch (p_blockSize) { switch (p_blockSize) {
case 0x40: case 0x40:
return m_pool1.Get(); return m_pool64.Get();
case 0x80: case 0x80:
return m_pool2.Get(); return m_pool128.Get();
default: default:
assert("Invalid block size for memory pool" == NULL); assert("Invalid block size for memory pool" == NULL);
@ -89,11 +92,11 @@ class MxStreamer : public MxCore {
{ {
switch (p_blockSize) { switch (p_blockSize) {
case 0x40: case 0x40:
m_pool1.Release(p_block); m_pool64.Release(p_block);
break; break;
case 0x80: case 0x80:
m_pool2.Release(p_block); m_pool128.Release(p_block);
break; break;
default: default:
@ -104,8 +107,8 @@ class MxStreamer : public MxCore {
private: private:
list<MxStreamController*> m_openStreams; // 0x08 list<MxStreamController*> m_openStreams; // 0x08
MxMemoryPool<0x40, 22> m_pool1; // 0x14 MxMemoryPool64 m_pool64; // 0x14
MxMemoryPool<0x80, 2> m_pool2; // 0x20 MxMemoryPool128 m_pool128; // 0x20
}; };
// clang-format off // clang-format off

View File

@ -8,6 +8,10 @@
#include <algorithm> #include <algorithm>
DECOMP_SIZE_ASSERT(MxStreamer, 0x2c); DECOMP_SIZE_ASSERT(MxStreamer, 0x2c);
DECOMP_SIZE_ASSERT(MxMemoryPool64, 0xc);
DECOMP_SIZE_ASSERT(MxMemoryPool128, 0xc);
DECOMP_SIZE_ASSERT(MxBitset<22>, 0x4);
DECOMP_SIZE_ASSERT(MxBitset<2>, 0x4);
// FUNCTION: LEGO1 0x100b8f00 // FUNCTION: LEGO1 0x100b8f00
MxStreamer::MxStreamer() MxStreamer::MxStreamer()
@ -18,7 +22,7 @@ MxStreamer::MxStreamer()
// FUNCTION: LEGO1 0x100b9190 // FUNCTION: LEGO1 0x100b9190
MxResult MxStreamer::Create() MxResult MxStreamer::Create()
{ {
if (m_pool1.Allocate() || m_pool2.Allocate()) { if (m_pool64.Allocate() || m_pool128.Allocate()) {
return FAILURE; return FAILURE;
} }