ksys/Utils: Add DualFrameHeap

This commit is contained in:
Léo Lam 2020-09-06 22:51:43 +02:00
parent 69dc675a95
commit 96deb88e27
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
2 changed files with 42 additions and 1 deletions

@ -1 +1 @@
Subproject commit 57301b4c5c6aa257e63860e2f6ae5872ef8d2af4
Subproject commit 8a00c624536738a26fc087d478db025e2752fc12

View File

@ -2,6 +2,7 @@
#include <basis/seadTypes.h>
#include <heap/seadExpHeap.h>
#include <heap/seadFrameHeap.h>
#include <heap/seadHeap.h>
#include "KingSystem/Utils/Types.h"
@ -42,8 +43,48 @@ protected:
u8 _120;
void* _128;
};
KSYS_CHECK_SIZE_NX150(sead::ExpHeap, 0x110);
KSYS_CHECK_SIZE_NX150(DualHeap, 0x130);
class DualFrameHeap : public sead::FrameHeap {
SEAD_RTTI_OVERRIDE(DualFrameHeap, sead::FrameHeap)
public:
static DualFrameHeap* tryCreate(size_t size, const sead::SafeString& name, Heap* parent1,
Heap* parent2, s32 alignment, HeapDirection direction, bool b);
static DualFrameHeap* create(size_t size, const sead::SafeString& name, Heap* parent1,
Heap* parent2, s32 alignment, HeapDirection direction, bool b);
size_t adjust() override;
void* tryAlloc(size_t size, s32 alignment) override;
void free(void* ptr) override;
size_t getFreeSize() const override;
size_t getMaxAllocatableSize(int alignment) const override;
bool isInclude(const void* p_void) const override;
bool isEmpty() const override;
bool isAdjustable() const override;
void genInformation_(sead::hostio::Context* context) override;
void makeMetaString_(sead::BufferedSafeString* string) override;
protected:
DualFrameHeap(size_t size, const sead::SafeString& name, Heap* parent1, Heap* parent2,
s32 alignment, HeapDirection direction, bool b);
~DualFrameHeap() override;
sead::Heap* mHeap2;
void* _f8;
u8 _100;
};
KSYS_CHECK_SIZE_NX150(sead::FrameHeap, 0xf0);
KSYS_CHECK_SIZE_NX150(DualFrameHeap, 0x108);
sead::Heap* tryCreateDualHeap(size_t size, const sead::SafeString& name, sead::Heap* heap1,
sead::Heap* heap2, sead::Heap::HeapDirection direction);
/// Same as tryCreateDualHeap, but asserts on failure.
sead::Heap* createDualHeap(size_t size, const sead::SafeString& name, sead::Heap* heap1,
sead::Heap* heap2, sead::Heap::HeapDirection direction);
/// Returns the specified heap if it is not null. Otherwise, this returns the current heap.
sead::Heap* getHeapOrCurrentHeap(sead::Heap* heap);