mirror of https://github.com/PrimeDecomp/prime.git
parent
5aee142c62
commit
ba98f00f60
2
Makefile
2
Makefile
|
@ -130,7 +130,7 @@ $(METROTRK_FILES): MWCC_VERSION := 1.2.5
|
||||||
$(METROTRK_FILES): CFLAGS := $(CFLAGS_BASE)
|
$(METROTRK_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||||
$(BASE_FILES): MWCC_VERSION := 1.2.5
|
$(BASE_FILES): MWCC_VERSION := 1.2.5
|
||||||
$(BASE_FILES): CFLAGS := $(CFLAGS_BASE)
|
$(BASE_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||||
$(AI_FILES): MWCC_VERSION := 1.2.5e
|
$(AI_FILES): MWCC_VERSION := 1.2.5
|
||||||
$(AI_FILES): CFLAGS := $(CFLAGS_BASE)
|
$(AI_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||||
$(OS_FILES): MWCC_VERSION := 1.2.5
|
$(OS_FILES): MWCC_VERSION := 1.2.5
|
||||||
$(OS_FILES): CFLAGS := $(CFLAGS_BASE)
|
$(OS_FILES): CFLAGS := $(CFLAGS_BASE)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
.global mRefCount__10CSfxHandle
|
.global mRefCount__10CSfxHandle
|
||||||
mRefCount__10CSfxHandle:
|
mRefCount__10CSfxHandle:
|
||||||
.skip 0x8
|
.skip 0x4
|
||||||
|
|
||||||
.section .text, "ax"
|
.section .text, "ax"
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ public:
|
||||||
CSfxHandle(uint value);
|
CSfxHandle(uint value);
|
||||||
|
|
||||||
uint GetIndex() const { return mID & 0xFFF; }
|
uint GetIndex() const { return mID & 0xFFF; }
|
||||||
static NullHandle() { return CSfxHandle(); }
|
static CSfxHandle NullHandle() { return CSfxHandle(); }
|
||||||
bool operator=(const CSfxHandle& other) { mID = other.mID; }
|
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; }
|
||||||
bool operator!=(const CSfxHandle& other) { return mID != other.mID; }
|
bool operator!=(const CSfxHandle& other) { return mID != other.mID; }
|
||||||
operator bool() const { return mID != 0; }
|
operator bool() const { return mID != 0; }
|
||||||
|
|
|
@ -587,7 +587,7 @@ KYOTO_2 :=\
|
||||||
$(BUILD_DIR)/src/Kyoto/Input/CDolphinController.o\
|
$(BUILD_DIR)/src/Kyoto/Input/CDolphinController.o\
|
||||||
$(BUILD_DIR)/asm/Kyoto/DolphinCDvdFile.o\
|
$(BUILD_DIR)/asm/Kyoto/DolphinCDvdFile.o\
|
||||||
$(BUILD_DIR)/asm/Kyoto/Alloc/CMediumAllocPool.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/Alloc/CGameAllocator.o\
|
||||||
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinnedModel.o\
|
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinnedModel.o\
|
||||||
$(BUILD_DIR)/asm/Kyoto/Animation/DolphinCSkinRules.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) {
|
void* CSmallAllocPool::FindFree(int len) {
|
||||||
|
u8* bookKeepingPtr;
|
||||||
|
s32 size = (s32)len / 2;
|
||||||
if (xc_cachedBookKeepingOffset == nullptr) {
|
if (xc_cachedBookKeepingOffset == nullptr) {
|
||||||
xc_cachedBookKeepingOffset = x4_bookKeeping;
|
xc_cachedBookKeepingOffset = x4_bookKeeping;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* curKeepingOffset = static_cast<u8*>(xc_cachedBookKeepingOffset);
|
u8* curKeepingOffset = static_cast<u8*>(xc_cachedBookKeepingOffset);
|
||||||
u8* bookKeepingPtr = static_cast<u8*>(x4_bookKeeping);
|
bookKeepingPtr = static_cast<u8*>(x4_bookKeeping);
|
||||||
u8* bookKeepingEndPtr = bookKeepingPtr + (x8_numBlocks >> 1);
|
u8* bookKeepingEndPtr = bookKeepingPtr + ((u32)x8_numBlocks >> 1);
|
||||||
u8* curKeepingIter = curKeepingOffset;
|
u8* curKeepingIter = curKeepingOffset;
|
||||||
while (true) {
|
while(true) {
|
||||||
u8* tmpIter = nullptr;
|
u8* iter;
|
||||||
if (static_cast<u8*>(curKeepingIter)[0] != 0 || curKeepingIter == bookKeepingEndPtr){
|
if (static_cast<u8*>(curKeepingIter)[0] != 0 || curKeepingIter == bookKeepingEndPtr) {
|
||||||
tmpIter = bookKeepingPtr;
|
if (curKeepingIter == bookKeepingEndPtr) {
|
||||||
if (curKeepingIter != bookKeepingEndPtr) {
|
curKeepingIter = bookKeepingPtr;
|
||||||
u32 tmp = static_cast<u8*>(curKeepingIter)[0];
|
} else {
|
||||||
tmpIter = curKeepingIter + (tmp >> 5);
|
s32 tmp = static_cast<u8*>(curKeepingIter)[0];
|
||||||
|
s32 reg = tmp >> 4;
|
||||||
|
curKeepingIter += (reg / 2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tmpIter = curKeepingIter;
|
u8* tempIter = curKeepingIter + size;
|
||||||
while (static_cast<u8*>(tmpIter)[0] == 0) {
|
iter = curKeepingIter + 1;
|
||||||
++tmpIter;
|
while (iter != curKeepingOffset && iter != bookKeepingEndPtr && iter != tempIter) {
|
||||||
if (tmpIter == curKeepingOffset || tmpIter == bookKeepingEndPtr || tmpIter == curKeepingIter + (len / 2)) {
|
if (static_cast<u8*>(iter)[0] == 0) {
|
||||||
break;
|
iter++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (tmpIter == curKeepingIter + (len / 2)) {
|
if (iter == curKeepingIter + size) {
|
||||||
if (tmpIter == bookKeepingEndPtr) {
|
if (iter == bookKeepingEndPtr) {
|
||||||
xc_cachedBookKeepingOffset = bookKeepingPtr;
|
xc_cachedBookKeepingOffset = bookKeepingPtr;
|
||||||
} else {
|
} else {
|
||||||
xc_cachedBookKeepingOffset = curKeepingIter;
|
xc_cachedBookKeepingOffset = curKeepingIter;
|
||||||
|
@ -48,71 +53,68 @@ void* CSmallAllocPool::FindFree(int len) {
|
||||||
return curKeepingIter;
|
return curKeepingIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmpIter == curKeepingOffset) {
|
if (iter == curKeepingOffset) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (tmpIter == bookKeepingEndPtr) {
|
if (iter == bookKeepingEndPtr) {
|
||||||
tmpIter = bookKeepingPtr;
|
curKeepingIter = bookKeepingPtr;
|
||||||
|
} else {
|
||||||
|
curKeepingIter = iter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
curKeepingIter = tmpIter;
|
if (curKeepingIter == curKeepingOffset) {
|
||||||
if (tmpIter == curKeepingOffset) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void* CSmallAllocPool::Alloc(uint size) {
|
void* CSmallAllocPool::Alloc(uint size) {
|
||||||
u32 len = size >= 4 ? len = (size + 3) / 4 : 1;
|
u32 len = size >= 4 ? len = (size + 3) / 4 : 1;
|
||||||
|
|
||||||
if ((len & 1) != 0) {
|
if ((len & 1) != 0) {
|
||||||
len += 1;
|
len += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* freePtr = static_cast<u8*>(FindFree(len));
|
u8* freePtr = static_cast< u8* >(FindFree(len));
|
||||||
if (freePtr == NULL) {
|
if (freePtr == nullptr) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 sub = len - 2;
|
s32 sub = len - 2;
|
||||||
s32 blockSize = (sub >> 31) & 1;
|
u8* bufPtr = GetPtrFromIndex(freePtr - static_cast< u8* >(x4_bookKeeping));
|
||||||
blockSize = blockSize + sub;
|
*static_cast< u8* >(freePtr) = (len << 4) | 0xf;
|
||||||
u8* bookKeepingStart = static_cast<u8*>(x4_bookKeeping);
|
s32 blockSize = sub / 2;
|
||||||
blockSize >>= 1;
|
u8* freePtrIter = freePtr + 1;
|
||||||
u8* bufPtr = GetPtrFromIndex(freePtr - bookKeepingStart);
|
while (blockSize--) {
|
||||||
*static_cast<u8*>(freePtr) = (len << 4) | 0xf;
|
*freePtrIter = 0xff;
|
||||||
u8* freePtrIter = freePtr + 1;
|
++freePtrIter;
|
||||||
while(blockSize--) {
|
}
|
||||||
*freePtrIter = 0xff;
|
|
||||||
++freePtrIter;
|
|
||||||
}
|
|
||||||
|
|
||||||
x18_numBlocksAvailable -= len;
|
x18_numBlocksAvailable -= len;
|
||||||
++x1c_numAllocs;
|
++x1c_numAllocs;
|
||||||
|
|
||||||
return bufPtr;
|
return bufPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CSmallAllocPool::Free(const void* arg0) {
|
bool CSmallAllocPool::Free(const void* arg0) {
|
||||||
s32 temp_r8 = GetIndexFromPtr(arg0);
|
s32 temp_r8 = GetIndexFromPtr(arg0);
|
||||||
s32 mask = (temp_r8 & 1) ? 0 : 4;
|
s32 mask = (temp_r8 & 1) ? 0 : 4;
|
||||||
u32 temp_r9 = (u32)temp_r8 / 2;
|
u32 temp_r9 = (u32)temp_r8 / 2;
|
||||||
s32 temp_r4_2 = GetEntryValue(temp_r9);
|
s32 temp_r4_2 = GetEntryValue(temp_r9);
|
||||||
temp_r4_2 = (temp_r4_2 >> mask) & 0xF;
|
temp_r4_2 = (temp_r4_2 >> mask) & 0xF;
|
||||||
x18_numBlocksAvailable += temp_r4_2;
|
x18_numBlocksAvailable += temp_r4_2;
|
||||||
s32 var_r5 = temp_r4_2;
|
s32 var_r5 = temp_r4_2;
|
||||||
x1c_numAllocs -= 1;
|
x1c_numAllocs -= 1;
|
||||||
x14_ = temp_r8;
|
x14_ = temp_r8;
|
||||||
if ((u32) temp_r8 == (u32) x10_) {
|
if ((u32)temp_r8 == (u32)x10_) {
|
||||||
x10_ = -1;
|
x10_ = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
u8* var_r3 = ((u8*)x4_bookKeeping) + temp_r9;
|
u8* var_r3 = ((u8*)x4_bookKeeping) + temp_r9;
|
||||||
while (var_r5 != 0) {
|
while (var_r5 != 0) {
|
||||||
*var_r3 = 0;
|
*var_r3 = 0;
|
||||||
var_r5 -= 2;
|
var_r5 -= 2;
|
||||||
++var_r3;
|
++var_r3;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue