More CGameArea::StartStreamingMainArea

Former-commit-id: 977372a3cd
This commit is contained in:
Henrique Gemignani Passos Lima 2023-07-31 16:35:09 +03:00
parent 61cf94d072
commit 7b4c11136f
5 changed files with 54 additions and 20 deletions

View File

@ -2549,7 +2549,7 @@ lbl_8005FC4C:
/* 8005FC88 0005CBE8 7C 64 1B 78 */ mr r4, r3
lbl_8005FC8C:
/* 8005FC8C 0005CBEC 38 7E 01 2C */ addi r3, r30, 0x12c
/* 8005FC90 0005CBF0 48 00 04 41 */ bl sub_800600d0
/* 8005FC90 0005CBF0 48 00 04 41 */ bl "Set__Q24rstl42single_ptr<Q29CGameArea16CPostConstructed>FPQ29CGameArea16CPostConstructed"
/* 8005FC94 0005CBF4 38 00 00 01 */ li r0, 1
/* 8005FC98 0005CBF8 90 1E 00 F4 */ stw r0, 0xf4(r30)
/* 8005FC9C 0005CBFC 48 00 04 1C */ b lbl_800600B8
@ -2847,8 +2847,8 @@ lbl_800600BC:
/* 800600C8 0005D028 38 21 00 70 */ addi r1, r1, 0x70
/* 800600CC 0005D02C 4E 80 00 20 */ blr
.global sub_800600d0
sub_800600d0:
.global "Set__Q24rstl42single_ptr<Q29CGameArea16CPostConstructed>FPQ29CGameArea16CPostConstructed"
"Set__Q24rstl42single_ptr<Q29CGameArea16CPostConstructed>FPQ29CGameArea16CPostConstructed":
/* 800600D0 0005D030 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 800600D4 0005D034 7C 08 02 A6 */ mflr r0
/* 800600D8 0005D038 90 01 00 14 */ stw r0, 0x14(r1)
@ -3552,7 +3552,7 @@ lbl_80060A38:
lbl_80060A58:
/* 80060A58 0005D9B8 38 7D 01 2C */ addi r3, r29, 0x12c
/* 80060A5C 0005D9BC 38 80 00 00 */ li r4, 0
/* 80060A60 0005D9C0 4B FF F6 71 */ bl sub_800600d0
/* 80060A60 0005D9C0 4B FF F6 71 */ bl "Set__Q24rstl42single_ptr<Q29CGameArea16CPostConstructed>FPQ29CGameArea16CPostConstructed"
/* 80060A64 0005D9C4 38 00 00 00 */ li r0, 0
/* 80060A68 0005D9C8 7F A3 EB 78 */ mr r3, r29
/* 80060A6C 0005D9CC 90 1D 00 F4 */ stw r0, 0xf4(r29)
@ -3578,7 +3578,7 @@ lbl_80060A9C:
/* 80060AB4 0005DA14 4B FF EC F9 */ bl RemoveStaticGeometry__9CGameAreaFv
/* 80060AB8 0005DA18 38 7D 01 2C */ addi r3, r29, 0x12c
/* 80060ABC 0005DA1C 38 80 00 00 */ li r4, 0
/* 80060AC0 0005DA20 4B FF F6 11 */ bl sub_800600d0
/* 80060AC0 0005DA20 4B FF F6 11 */ bl "Set__Q24rstl42single_ptr<Q29CGameArea16CPostConstructed>FPQ29CGameArea16CPostConstructed"
/* 80060AC4 0005DA24 88 1D 00 F0 */ lbz r0, 0xf0(r29)
/* 80060AC8 0005DA28 38 80 00 00 */ li r4, 0
/* 80060ACC 0005DA2C 50 80 3E 30 */ rlwimi r0, r4, 7, 0x18, 0x18

View File

@ -27,7 +27,7 @@ public:
void AsyncIdlePakLoading();
bool AreAllPaksLoaded() const;
CInputStream* LoadNewResourceSync(const SObjectTag& tag, char* extBuf);
CARAMDvdRequest* LoadResourcePartAsync(const SObjectTag& tag, int, int, void*);
CARAMDvdRequest* LoadResourcePartAsync(const SObjectTag& tag, int, int, char*);
FourCC GetResourceTypeById(CAssetId) const;
uint ResourceSize(const SObjectTag& tag) const;

View File

@ -122,7 +122,7 @@ public:
private:
void AllocNewAreaData(int, int);
void CullDeadAreaRequests();
void VerifyHeader() const;
int VerifyHeader() const;
int GetNumPartSizes() const;
@ -169,6 +169,9 @@ public:
const CScriptAreaAttributes* x10d8_areaAttributes;
EOcclusionState x10dc_occlusionState;
uchar x10e0_pad[0x60];
CPostConstructed();
~CPostConstructed();
};
CAssetId GetAreaAssetId() const { return x84_mrea; }

View File

@ -30,8 +30,17 @@ public:
x0_ptr = nullptr;
return ptr;
}
// This is certainly not real, but handy to force not-inline
single_ptr& Set(T* ptr);
};
template < typename T >
single_ptr< T >& single_ptr< T >::Set(T* ptr) {
return *this = ptr;
}
typedef single_ptr< void > unk_singleptr;
CHECK_SIZEOF(unk_singleptr, 0x4);
} // namespace rstl

View File

@ -5,6 +5,9 @@
#define ROUND_UP_32(val) (((val) + 31) & ~31)
CGameArea::CPostConstructed::CPostConstructed() {}
CGameArea::CPostConstructed::~CPostConstructed() {}
bool CGameArea::StartStreamingMainArea() {
if (xf0_24_postConstructed)
return false;
@ -13,13 +16,13 @@ bool CGameArea::StartStreamingMainArea() {
case kP_LoadHeader: {
x110_mreaSecBufs.reserve(3);
AllocNewAreaData(0, 96);
x12c_postConstructed = new CPostConstructed();
x12c_postConstructed.Set(new CPostConstructed());
xf4_phase = kP_LoadSecSizes;
break;
}
case kP_LoadSecSizes: {
CullDeadAreaRequests();
if (xf8_loadTransactions.size())
if (!xf8_loadTransactions.empty())
break;
VerifyHeader();
AllocNewAreaData(x110_mreaSecBufs[0].second, ROUND_UP_32(GetNumPartSizes() * 4));
@ -28,7 +31,7 @@ bool CGameArea::StartStreamingMainArea() {
}
case kP_ReserveSections: {
CullDeadAreaRequests();
if (xf8_loadTransactions.size() == 0) {
if (xf8_loadTransactions.empty()) {
x110_mreaSecBufs.reserve(GetNumPartSizes() + 2);
x124_secCount = 0;
x128_mreaDataOffset = x110_mreaSecBufs[0].second + x110_mreaSecBufs[1].second;
@ -39,8 +42,11 @@ bool CGameArea::StartStreamingMainArea() {
case kP_LoadDataSections: {
CullDeadAreaRequests();
uint totalSz = 0;
uint secCount = GetNumPartSizes();
int totalSz = 0;
int secCount = x124_secCount;
int partSizes = GetNumPartSizes();
SObjectTag tag('MREA', x84_mrea);
// for (uint i = 0; i < secCount; ++i)
// totalSz += CBasics::SwapBytes(reinterpret_cast<u32*>(x110_mreaSecBufs[1].first.get())[i]);
@ -57,22 +63,38 @@ bool CGameArea::StartStreamingMainArea() {
// curOff += size;
// }
SObjectTag tag('MREA', x84_mrea);
void* buf = CMemory::Alloc(totalSz, IAllocator::kHI_RoundUpLen);
int dif = partSizes - secCount;
int targetSecCount = secCount;
for (int i = secCount; i < partSizes; ++i) {
int size = x110_mreaSecBufs[i].second;
if (targetSecCount != secCount && 0x10000 < size + totalSz)
break;
totalSz += size;
targetSecCount += 1;
}
rstl::auto_ptr<char> buf = (char*) CMemory::Alloc(totalSz, IAllocator::kHI_RoundUpLen);
xf8_loadTransactions.push_back(
rstl::rc_ptr< CDvdRequest >(gpResourceFactory->GetResLoader().LoadResourcePartAsync(tag, x128_mreaDataOffset, totalSz, buf))
rstl::rc_ptr< CDvdRequest >(gpResourceFactory->GetResLoader().LoadResourcePartAsync(tag, x128_mreaDataOffset, totalSz, buf.get()))
);
x128_mreaDataOffset += totalSz;
// x110_mreaSecBufs.push_back(buf);
x110_mreaSecBufs.push_back(rstl::pair< rstl::auto_ptr<char>, int>( buf, 0 ));
xf4_phase = kP_WaitForFinish;
for (int i = secCount + 1; i < targetSecCount; ++i) {
x110_mreaSecBufs.push_back(rstl::pair< rstl::auto_ptr<char>, int>( nullptr, 0 ));
}
x124_secCount = targetSecCount;
if (targetSecCount == partSizes) {
x120_unk = x128_mreaDataOffset;
xf4_phase = kP_WaitForFinish;
}
break;
}
case kP_WaitForFinish: {
CullDeadAreaRequests();
if (xf8_loadTransactions.size())
break;
return false;
if (xf8_loadTransactions.empty())
return false;
break;
}
default:
break;