mirror of https://github.com/PrimeDecomp/prime.git
Link CSmallAllocPool.cpp, minor fixes
This commit is contained in:
parent
79301314e9
commit
7f768f8405
2
Makefile
2
Makefile
|
@ -130,7 +130,7 @@ $(METROTRK_FILES): MWCC_VERSION := 1.2.5
|
|||
$(METROTRK_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
$(BASE_FILES): MWCC_VERSION := 1.2.5
|
||||
$(BASE_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
$(AI_FILES): MWCC_VERSION := 1.2.5e
|
||||
$(AI_FILES): MWCC_VERSION := 1.2.5
|
||||
$(AI_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
$(OS_FILES): MWCC_VERSION := 1.2.5
|
||||
$(OS_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
.global mRefCount__10CSfxHandle
|
||||
mRefCount__10CSfxHandle:
|
||||
.skip 0x8
|
||||
.skip 0x4
|
||||
|
||||
.section .text, "ax"
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ public:
|
|||
CSfxHandle(uint value);
|
||||
|
||||
uint GetIndex() const { return mID & 0xFFF; }
|
||||
static NullHandle() { return CSfxHandle(); }
|
||||
bool operator=(const CSfxHandle& other) { mID = other.mID; }
|
||||
static CSfxHandle NullHandle() { return CSfxHandle(); }
|
||||
void operator=(const CSfxHandle& other) { mID = other.mID; }
|
||||
bool operator==(const CSfxHandle& other) { return mID == other.mID; }
|
||||
bool operator!=(const CSfxHandle& other) { return mID != other.mID; }
|
||||
operator bool() const { return mID != 0; }
|
||||
|
|
|
@ -587,7 +587,7 @@ KYOTO_2 :=\
|
|||
$(BUILD_DIR)/src/Kyoto/Input/CDolphinController.o\
|
||||
$(BUILD_DIR)/asm/Kyoto/DolphinCDvdFile.o\
|
||||
$(BUILD_DIR)/asm/Kyoto/Alloc/CMediumAllocPool.o\
|
||||
$(BUILD_DIR)/asm/Kyoto/Alloc/CSmallAllocPool.o\
|
||||
$(BUILD_DIR)/src/Kyoto/Alloc/CSmallAllocPool.o\
|
||||
$(BUILD_DIR)/asm/Kyoto/Alloc/CGameAllocator.o\
|
||||
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinnedModel.o\
|
||||
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinRules.o\
|
||||
|
|
|
@ -14,33 +14,38 @@ CSmallAllocPool::CSmallAllocPool(uint len, void* mainData, void* bookKeeping)
|
|||
}
|
||||
|
||||
void* CSmallAllocPool::FindFree(int len) {
|
||||
u8* bookKeepingPtr;
|
||||
s32 size = (s32)len / 2;
|
||||
if (xc_cachedBookKeepingOffset == nullptr) {
|
||||
xc_cachedBookKeepingOffset = x4_bookKeeping;
|
||||
}
|
||||
|
||||
u8* curKeepingOffset = static_cast<u8*>(xc_cachedBookKeepingOffset);
|
||||
u8* bookKeepingPtr = static_cast<u8*>(x4_bookKeeping);
|
||||
u8* bookKeepingEndPtr = bookKeepingPtr + (x8_numBlocks >> 1);
|
||||
bookKeepingPtr = static_cast<u8*>(x4_bookKeeping);
|
||||
u8* bookKeepingEndPtr = bookKeepingPtr + ((u32)x8_numBlocks >> 1);
|
||||
u8* curKeepingIter = curKeepingOffset;
|
||||
while(true) {
|
||||
u8* tmpIter = nullptr;
|
||||
u8* iter;
|
||||
if (static_cast<u8*>(curKeepingIter)[0] != 0 || curKeepingIter == bookKeepingEndPtr) {
|
||||
tmpIter = bookKeepingPtr;
|
||||
if (curKeepingIter != bookKeepingEndPtr) {
|
||||
u32 tmp = static_cast<u8*>(curKeepingIter)[0];
|
||||
tmpIter = curKeepingIter + (tmp >> 5);
|
||||
if (curKeepingIter == bookKeepingEndPtr) {
|
||||
curKeepingIter = bookKeepingPtr;
|
||||
} else {
|
||||
s32 tmp = static_cast<u8*>(curKeepingIter)[0];
|
||||
s32 reg = tmp >> 4;
|
||||
curKeepingIter += (reg / 2);
|
||||
}
|
||||
} else {
|
||||
tmpIter = curKeepingIter;
|
||||
while (static_cast<u8*>(tmpIter)[0] == 0) {
|
||||
++tmpIter;
|
||||
if (tmpIter == curKeepingOffset || tmpIter == bookKeepingEndPtr || tmpIter == curKeepingIter + (len / 2)) {
|
||||
u8* tempIter = curKeepingIter + size;
|
||||
iter = curKeepingIter + 1;
|
||||
while (iter != curKeepingOffset && iter != bookKeepingEndPtr && iter != tempIter) {
|
||||
if (static_cast<u8*>(iter)[0] == 0) {
|
||||
iter++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpIter == curKeepingIter + (len / 2)) {
|
||||
if (tmpIter == bookKeepingEndPtr) {
|
||||
if (iter == curKeepingIter + size) {
|
||||
if (iter == bookKeepingEndPtr) {
|
||||
xc_cachedBookKeepingOffset = bookKeepingPtr;
|
||||
} else {
|
||||
xc_cachedBookKeepingOffset = curKeepingIter;
|
||||
|
@ -48,18 +53,19 @@ void* CSmallAllocPool::FindFree(int len) {
|
|||
return curKeepingIter;
|
||||
}
|
||||
|
||||
if (tmpIter == curKeepingOffset) {
|
||||
if (iter == curKeepingOffset) {
|
||||
return nullptr;
|
||||
}
|
||||
if (tmpIter == bookKeepingEndPtr) {
|
||||
tmpIter = bookKeepingPtr;
|
||||
if (iter == bookKeepingEndPtr) {
|
||||
curKeepingIter = bookKeepingPtr;
|
||||
} else {
|
||||
curKeepingIter = iter;
|
||||
}
|
||||
}
|
||||
curKeepingIter = tmpIter;
|
||||
if (tmpIter == curKeepingOffset) {
|
||||
if (curKeepingIter == curKeepingOffset) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void* CSmallAllocPool::Alloc(uint size) {
|
||||
|
@ -70,17 +76,14 @@ void* CSmallAllocPool::Alloc(uint size) {
|
|||
}
|
||||
|
||||
u8* freePtr = static_cast< u8* >(FindFree(len));
|
||||
if (freePtr == NULL) {
|
||||
return NULL;
|
||||
if (freePtr == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s32 sub = len - 2;
|
||||
s32 blockSize = (sub >> 31) & 1;
|
||||
blockSize = blockSize + sub;
|
||||
u8* bookKeepingStart = static_cast<u8*>(x4_bookKeeping);
|
||||
blockSize >>= 1;
|
||||
u8* bufPtr = GetPtrFromIndex(freePtr - bookKeepingStart);
|
||||
u8* bufPtr = GetPtrFromIndex(freePtr - static_cast< u8* >(x4_bookKeeping));
|
||||
*static_cast< u8* >(freePtr) = (len << 4) | 0xf;
|
||||
s32 blockSize = sub / 2;
|
||||
u8* freePtrIter = freePtr + 1;
|
||||
while (blockSize--) {
|
||||
*freePtrIter = 0xff;
|
||||
|
@ -93,7 +96,6 @@ void* CSmallAllocPool::Alloc(uint size) {
|
|||
return bufPtr;
|
||||
}
|
||||
|
||||
|
||||
bool CSmallAllocPool::Free(const void* arg0) {
|
||||
s32 temp_r8 = GetIndexFromPtr(arg0);
|
||||
s32 mask = (temp_r8 & 1) ? 0 : 4;
|
||||
|
|
Loading…
Reference in New Issue