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:
MxBitset() { Tidy(); }
// SIZE 0x8
class Reference {
friend class MxBitset<N>;
@ -27,8 +28,8 @@ class MxBitset {
private:
Reference(MxBitset<N>& p_bitset, size_t p_offset) : m_bitset(&p_bitset), m_offset(p_offset) {}
MxBitset<N>* m_bitset;
size_t m_offset;
MxBitset<N>* m_bitset; // 0x00
size_t m_offset; // 0x04
};
Reference operator[](size_t p_bit) { return (Reference(*this, p_bit)); }
@ -44,7 +45,7 @@ class MxBitset {
size_t Count()
{
// debug only
// debug only, intentionally unimplemented
return 0;
}
@ -88,7 +89,7 @@ class MxBitset {
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

View File

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

View File

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

View File

@ -8,6 +8,10 @@
#include <algorithm>
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
MxStreamer::MxStreamer()
@ -18,7 +22,7 @@ MxStreamer::MxStreamer()
// FUNCTION: LEGO1 0x100b9190
MxResult MxStreamer::Create()
{
if (m_pool1.Allocate() || m_pool2.Allocate()) {
if (m_pool64.Allocate() || m_pool128.Allocate()) {
return FAILURE;
}