Match SMediumAllocPuddle::InitBookKeeping

Former-commit-id: 8d531cf609
This commit is contained in:
Phillip Stephens 2023-10-02 23:47:00 -07:00
parent 10ad16df3e
commit 67e861c0f0
3 changed files with 33 additions and 8 deletions

View File

@ -9,8 +9,8 @@ gMediumAllocPtr__16CMediumAllocPool:
.section .text, "ax" .section .text, "ax"
.global InitBookKeeping__18SMediumAllocPuddleFPvUi .global InitBookKeeping__18SMediumAllocPuddleFPUcUs
InitBookKeeping__18SMediumAllocPuddleFPvUi: InitBookKeeping__18SMediumAllocPuddleFPUcUs:
/* 80350540 0034D4A0 54 85 04 3E */ clrlwi r5, r4, 0x10 /* 80350540 0034D4A0 54 85 04 3E */ clrlwi r5, r4, 0x10
/* 80350544 0034D4A4 28 05 00 04 */ cmplwi r5, 4 /* 80350544 0034D4A4 28 05 00 04 */ cmplwi r5, 4
/* 80350548 0034D4A8 40 80 00 48 */ bge lbl_80350590 /* 80350548 0034D4A8 40 80 00 48 */ bge lbl_80350590
@ -145,7 +145,7 @@ lbl_803506DC:
lbl_80350700: lbl_80350700:
/* 80350700 0034D660 7F C3 F3 78 */ mr r3, r30 /* 80350700 0034D660 7F C3 F3 78 */ mr r3, r30
/* 80350704 0034D664 57 A4 04 3E */ clrlwi r4, r29, 0x10 /* 80350704 0034D664 57 A4 04 3E */ clrlwi r4, r29, 0x10
/* 80350708 0034D668 4B FF FE 39 */ bl InitBookKeeping__18SMediumAllocPuddleFPvUi /* 80350708 0034D668 4B FF FE 39 */ bl InitBookKeeping__18SMediumAllocPuddleFPUcUs
/* 8035070C 0034D66C 57 80 06 3F */ clrlwi. r0, r28, 0x18 /* 8035070C 0034D66C 57 80 06 3F */ clrlwi. r0, r28, 0x18
/* 80350710 0034D670 41 82 00 24 */ beq lbl_80350734 /* 80350710 0034D670 41 82 00 24 */ beq lbl_80350734
/* 80350714 0034D674 7C 1E F8 40 */ cmplw r30, r31 /* 80350714 0034D674 7C 1E F8 40 */ cmplw r30, r31
@ -209,7 +209,7 @@ lbl_803507B8:
/* 803507D4 0034D734 54 04 04 3F */ clrlwi. r4, r0, 0x10 /* 803507D4 0034D734 54 04 04 3F */ clrlwi. r4, r0, 0x10
/* 803507D8 0034D738 41 82 00 0C */ beq lbl_803507E4 /* 803507D8 0034D738 41 82 00 0C */ beq lbl_803507E4
/* 803507DC 0034D73C 7C 7C DA 14 */ add r3, r28, r27 /* 803507DC 0034D73C 7C 7C DA 14 */ add r3, r28, r27
/* 803507E0 0034D740 4B FF FD 61 */ bl InitBookKeeping__18SMediumAllocPuddleFPvUi /* 803507E0 0034D740 4B FF FD 61 */ bl InitBookKeeping__18SMediumAllocPuddleFPUcUs
lbl_803507E4: lbl_803507E4:
/* 803507E4 0034D744 93 9A 00 0C */ stw r28, 0xc(r26) /* 803507E4 0034D744 93 9A 00 0C */ stw r28, 0xc(r26)
/* 803507E8 0034D748 7F 83 E3 78 */ mr r3, r28 /* 803507E8 0034D748 7F 83 E3 78 */ mr r3, r28
@ -328,7 +328,7 @@ __ct__18SMediumAllocPuddleFUiPvb:
/* 80350968 0034D8C8 50 C0 3E 30 */ rlwimi r0, r6, 7, 0x18, 0x18 /* 80350968 0034D8C8 50 C0 3E 30 */ rlwimi r0, r6, 7, 0x18, 0x18
/* 8035096C 0034D8CC 98 1F 00 20 */ stb r0, 0x20(r31) /* 8035096C 0034D8CC 98 1F 00 20 */ stb r0, 0x20(r31)
/* 80350970 0034D8D0 80 7F 00 08 */ lwz r3, 8(r31) /* 80350970 0034D8D0 80 7F 00 08 */ lwz r3, 8(r31)
/* 80350974 0034D8D4 4B FF FB CD */ bl InitBookKeeping__18SMediumAllocPuddleFPvUi /* 80350974 0034D8D4 4B FF FB CD */ bl InitBookKeeping__18SMediumAllocPuddleFPUcUs
/* 80350978 0034D8D8 80 01 00 14 */ lwz r0, 0x14(r1) /* 80350978 0034D8D8 80 01 00 14 */ lwz r0, 0x14(r1)
/* 8035097C 0034D8DC 7F E3 FB 78 */ mr r3, r31 /* 8035097C 0034D8DC 7F E3 FB 78 */ mr r3, r31
/* 80350980 0034D8E0 83 E1 00 0C */ lwz r31, 0xc(r1) /* 80350980 0034D8E0 83 E1 00 0C */ lwz r31, 0xc(r1)

View File

@ -18,7 +18,7 @@ struct SMediumAllocPuddle {
bool GetUnk2() const { return x20_unk2; } bool GetUnk2() const { return x20_unk2; }
static uint GetBlockOffset(const void* ptrA, const void* ptrB); static uint GetBlockOffset(const void* ptrA, const void* ptrB);
static void InitBookKeeping(void* bookKeepingPtr, uint blockCount); static void InitBookKeeping(uchar* bookKeepingPtr, const ushort blockCount);
private: private:
rstl::auto_ptr< void > x0_mainData; rstl::auto_ptr< void > x0_mainData;

View File

@ -88,7 +88,7 @@ SMediumAllocPuddle::SMediumAllocPuddle(const uint numBlocks, void* data, const b
, x18_numAllocs(0) , x18_numAllocs(0)
, x1c_numEntries(numBlocks) , x1c_numEntries(numBlocks)
, x20_unk2(unk) { , x20_unk2(unk) {
SMediumAllocPuddle::InitBookKeeping(x8_bookKeeping, numBlocks & 0xFFFF); SMediumAllocPuddle::InitBookKeeping(x8_bookKeeping, numBlocks);
} }
SMediumAllocPuddle::~SMediumAllocPuddle() {} SMediumAllocPuddle::~SMediumAllocPuddle() {}
@ -119,4 +119,29 @@ bool SMediumAllocPuddle::Free(const void* ptr) {}
uint SMediumAllocPuddle::GetBlockOffset(const void* ptrA, const void* ptrB) { return 0; } uint SMediumAllocPuddle::GetBlockOffset(const void* ptrA, const void* ptrB) { return 0; }
void SMediumAllocPuddle::InitBookKeeping(void* bookKeepingPtr, uint blockCount) {} void SMediumAllocPuddle::InitBookKeeping(uchar* bookKeepingPtr, ushort blockCount) {
if (blockCount < 4) {
uint tmp;
if (blockCount == 3) {
tmp = 96;
} else {
tmp = 32;
if (blockCount == 2) {
tmp = 64;
}
}
tmp |= 0x80;
bookKeepingPtr[0] = tmp & 0xFF;
if (blockCount > 1) {
bookKeepingPtr[blockCount - 1] = tmp & 0xFF;
}
} else {
uchar tmp = (blockCount >> 8) | 0x80;
bookKeepingPtr[0] = tmp & 0xFF;
bookKeepingPtr[1] = blockCount;
bookKeepingPtr[blockCount - 2] = blockCount;
bookKeepingPtr[blockCount - 1] = tmp & 0xFF;
}
}