Translate strings in fopAcM_entrySolidHeap

This commit is contained in:
LagoLunatic
2025-02-11 16:25:06 -05:00
parent 7297cbaf38
commit 458c40ede8
7 changed files with 40 additions and 26 deletions
+2 -1
View File
@@ -50,11 +50,12 @@ private:
/* 0x70 */ u8* mSolidHead;
/* 0x74 */ u8* mSolidTail;
/* 0x78 */ Unknown* field_0x78;
/* 0x7C */ u8 field_0x7C[0x80 - 0x7C];
public:
s32 adjustSize(void);
static JKRSolidHeap* create(u32, JKRHeap*, bool);
};
}; // Size: 0x80
#endif /* JKRSOLIDHEAP_H */
+2 -2
View File
@@ -108,7 +108,7 @@ public:
void erase() {}
};
typedef int (*heapCallbackFunc)(fopAc_ac_c*);
typedef BOOL (*heapCallbackFunc)(fopAc_ac_c*);
typedef int (*createFunc)(void*);
inline s8 fopAcM_GetRoomNo(fopAc_ac_c* pActor) {
@@ -491,7 +491,7 @@ fpc_ProcID fopAcM_createChildFromOffset(char* pProcNameString, fpc_ProcID parent
void fopAcM_DeleteHeap(fopAc_ac_c* p_actor);
bool fopAcM_entrySolidHeap(fopAc_ac_c* p_actor, heapCallbackFunc p_heapCallback, u32 size);
bool fopAcM_entrySolidHeap(fopAc_ac_c* p_actor, heapCallbackFunc p_heapCallback, u32 estimatedHeapSize);
inline void fopAcM_SetMin(fopAc_ac_c* p_actor, f32 minX, f32 minY, f32 minZ) {
#ifdef __MWERKS__
+2 -2
View File
@@ -299,7 +299,7 @@ void* JKRExpHeap::allocFromTail(u32 size, int align) {
if (foundBlock != NULL) {
if (offset >= sizeof(CMemBlock)) {
newBlock->initiate(NULL, NULL, usedSize, mCurrentGroupId, -0x80);
newBlock->initiate(NULL, NULL, usedSize, mCurrentGroupId, 0x80);
foundBlock->size = foundBlock->size - usedSize - sizeof(CMemBlock);
appendUsedList(newBlock);
return newBlock->getContent();
@@ -311,7 +311,7 @@ void* JKRExpHeap::allocFromTail(u32 size, int align) {
return newBlock->getContent();
} else {
removeFreeBlock(foundBlock);
newBlock->initiate(NULL, NULL, usedSize, mCurrentGroupId, -0x80);
newBlock->initiate(NULL, NULL, usedSize, mCurrentGroupId, 0x80);
appendUsedList(newBlock);
return newBlock->getContent();
}
+2 -2
View File
@@ -15,12 +15,12 @@ JKRSolidHeap* JKRSolidHeap::create(u32 size, JKRHeap* heap, bool useErrorHandler
heap = getRootHeap();
}
if (size == 0xffffffff) {
if (size == -1) {
size = heap->getMaxAllocatableSize(0x10);
}
u32 alignedSize = ALIGN_PREV(size, 0x10);
u32 solidHeapSize = ALIGN_NEXT(sizeof(JKRSolidHeap), 0x10);
u32 solidHeapSize = sizeof(JKRSolidHeap);
if (alignedSize < solidHeapSize)
return NULL;
+2 -2
View File
@@ -14,12 +14,12 @@ JUTGraphFifo* JUTGraphFifo::sCurrentFifo;
JUTGraphFifo::JUTGraphFifo(u32 size) {
mSize = size + 0x1F & ~0x1F;
if (sInitiated) {
mFifo = (GXFifoObj*)JKRAllocFromSysHeap(mSize + 0x80, 32);
mFifo = (GXFifoObj*)JKRAllocFromSysHeap(sizeof(GXFifoObj) + mSize, 0x20);
mBase = mFifo + 1;
GXInitFifoBase(mFifo, mBase, mSize);
GXInitFifoPtrs(mFifo, mBase, mBase);
} else {
mBase = JKRAllocFromSysHeap(mSize + 0xA0, 32);
mBase = JKRAllocFromSysHeap(0xA0 + mSize, 0x20); // TODO: What struct is 0xA0 bytes in size?
mBase = (void*)((int)mBase + 0x1F & ~0x1F);
mFifo = GXInit(mBase, mSize);
sInitiated = true;
+27 -14
View File
@@ -303,18 +303,18 @@ void fopAcM_DeleteHeap(fopAc_ac_c* i_this) {
}
namespace fopAcM {
bool HeapAdjustEntry;
bool HeapAdjustVerbose;
bool HeapAdjustQuiet;
bool HeapAdjustEntry = false;
bool HeapAdjustVerbose = false;
bool HeapAdjustQuiet = false;
}
/* 80024D24-800250E4 .text fopAcM_entrySolidHeap__FP10fopAc_ac_cPFP10fopAc_ac_c_iUl */
bool fopAcM_entrySolidHeap(fopAc_ac_c* i_this, heapCallbackFunc createHeapCB, u32 maxHeapSize) {
bool fopAcM_entrySolidHeap(fopAc_ac_c* i_this, heapCallbackFunc createHeapCB, u32 estimatedHeapSize) {
const char * pProcNameString = fopAcM_getProcNameString(i_this);
JKRSolidHeap * heap = NULL;
if (maxHeapSize != 0) {
heap = mDoExt_createSolidHeapFromGameToCurrent(maxHeapSize, 0x20);
if (estimatedHeapSize != 0) {
heap = mDoExt_createSolidHeapFromGameToCurrent(estimatedHeapSize, 0x20);
if (heap != NULL) {
bool result = createHeapCB(i_this);
if (heap->getFreeSize() >= 0x20)
@@ -323,24 +323,30 @@ bool fopAcM_entrySolidHeap(fopAc_ac_c* i_this, heapCallbackFunc createHeapCB, u3
mDoExt_restoreCurrentHeap();
if (!result) {
if (!fopAcM::HeapAdjustQuiet)
OSReport_Error("見積もりヒープサイズ(%08x)で登録失敗しました。[%s]\n", maxHeapSize, pProcNameString);
if (!fopAcM::HeapAdjustQuiet) {
// "Entry failed with estimated heap size (%08x). [%s]\n"
OSReport_Error("見積もりヒープサイズ(%08x)で登録失敗しました。[%s]\n", estimatedHeapSize, pProcNameString);
}
mDoExt_destroySolidHeap(heap);
heap = NULL;
} else {
u32 allocSize = ALIGN_NEXT(heap->getSize() - heap->getFreeSize(), 0x20);
if (maxHeapSize < allocSize + 0x40) {
if (estimatedHeapSize < allocSize + 0x40) {
mDoExt_adjustSolidHeap(heap);
i_this->heap = heap;
return true;
}
if (fopAcM::HeapAdjustVerbose)
OSReport_Warning("見積もりヒープサイズでは空きが多すぎます。 %08x %08x\n\x1b[m", allocSize, maxHeapSize);
if (fopAcM::HeapAdjustVerbose) {
// "The estimated heap size leaves too much free space. %08x %08x\n\x1b[m"
OSReport_Warning("見積もりヒープサイズでは空きが多すぎます。 %08x %08x\n\x1b[m", allocSize, estimatedHeapSize);
}
}
} else {
if (!fopAcM::HeapAdjustQuiet)
if (!fopAcM::HeapAdjustQuiet) {
// "Failed to allocate the estimated heap size.\n"
OSReport_Warning("見積もりヒープが確保できませんでした。\n");
}
}
}
@@ -352,6 +358,7 @@ bool fopAcM_entrySolidHeap(fopAc_ac_c* i_this, heapCallbackFunc createHeapCB, u3
mDoExt_restoreCurrentHeap();
if (!result) {
// "Entry failed with the max allocatable heap size. [%s]\n"
OSReport_Error("最大空きヒープサイズで登録失敗。[%s]\n", pProcNameString);
mDoExt_destroySolidHeap(heap);
return false;
@@ -368,19 +375,23 @@ bool fopAcM_entrySolidHeap(fopAc_ac_c* i_this, heapCallbackFunc createHeapCB, u3
return true;
}
// If fopAcM::HeapAdjustEntry is set, try to reallocate everything a second time.
// This time we set the estimated maximum heap size to the exact size allocated last time.
JKRSolidHeap * heap1 = NULL;
u32 allocSize = ALIGN_NEXT(heap->getSize() - heap->getFreeSize(), 0x10);
if (allocSize + 0x90 < mDoExt_getGameHeap()->getFreeSize())
if (allocSize + 0x10 + sizeof(JKRSolidHeap) < mDoExt_getGameHeap()->getFreeSize())
heap1 = mDoExt_createSolidHeapFromGameToCurrent(allocSize, 0x20);
if (heap1 != NULL) {
if (heap1 < heap) {
// The exact size heap allocated successfully, and it is located before the original (larger) heap.
mDoExt_destroySolidHeap(heap);
heap = NULL;
bool result = createHeapCB(i_this);
mDoExt_restoreCurrentHeap();
JUT_ASSERT(0x48d, result != FALSE);
if (result == 0) {
if (result == FALSE) {
// "Entry failed with the exact size heap? (Bug)\n"
OSReport_Error("ぴったりサイズで、登録失敗?(バグ)\n");
mDoExt_destroySolidHeap(heap1);
heap1 = NULL;
@@ -404,10 +415,12 @@ bool fopAcM_entrySolidHeap(fopAc_ac_c* i_this, heapCallbackFunc createHeapCB, u3
return true;
}
// "Buggy!\n"
OSReport_Error("ばぐばぐです\n");
JUT_ASSERT(0x4b5, FALSE);
}
// "fopAcM_entrySolidHeap failed. [%s]\n"
OSReport_Error("fopAcM_entrySolidHeap だめでした [%s]\n", pProcNameString);
return false;
}
+3 -3
View File
@@ -907,7 +907,7 @@ JKRSolidHeap* mDoExt_createSolidHeap(u32 i_size, JKRHeap* i_heap, u32 i_alignmen
createdHeap = JKRSolidHeap::create(-1, i_heap, false);
} else {
i_size = ALIGN_NEXT(i_size, 0x10);
i_size += 0x80;
i_size += sizeof(JKRSolidHeap);
if (0x10 < i_alignment) {
i_size = (i_alignment - 0x10 + i_size);
@@ -968,8 +968,8 @@ s32 mDoExt_adjustSolidHeap(JKRSolidHeap* i_heap) {
return 0;
s32 result = i_heap->adjustSize();
if (result >= 0x80u)
result -= 0x80;
if (result >= sizeof(JKRSolidHeap))
result -= sizeof(JKRSolidHeap);
return result;
}