More CGameArea

Former-commit-id: 9465f35d9a
This commit is contained in:
Henrique Gemignani Passos Lima 2023-07-31 18:58:47 +03:00
parent 7b4c11136f
commit d46423af7e
3 changed files with 56 additions and 24 deletions

View File

@ -29,8 +29,8 @@ lbl_803DA234:
.4byte IGetNumAttachedAreas__9CGameAreaCFv .4byte IGetNumAttachedAreas__9CGameAreaCFv
.4byte IGetAttachedAreaId__9CGameAreaCFi .4byte IGetAttachedAreaId__9CGameAreaCFi
.4byte IIsActive__9CGameAreaCFv .4byte IIsActive__9CGameAreaCFv
.4byte IGetAreaAssetID__9CGameAreaCFv .4byte IGetAreaAssetId__9CGameAreaCFv
.4byte IGetAreaId__9CGameAreaCFv .4byte IGetAreaSaveId__9CGameAreaCFv
.4byte IGetScriptingMemoryAlways__9CGameAreaCFv .4byte IGetScriptingMemoryAlways__9CGameAreaCFv
.global lbl_803DA260 .global lbl_803DA260
@ -1237,13 +1237,13 @@ IGetScriptingMemoryAlways__9CGameAreaCFv:
/* 8005EB20 0005BA80 38 21 00 10 */ addi r1, r1, 0x10 /* 8005EB20 0005BA80 38 21 00 10 */ addi r1, r1, 0x10
/* 8005EB24 0005BA84 4E 80 00 20 */ blr /* 8005EB24 0005BA84 4E 80 00 20 */ blr
.global IGetAreaId__9CGameAreaCFv .global IGetAreaSaveId__9CGameAreaCFv
IGetAreaId__9CGameAreaCFv: IGetAreaSaveId__9CGameAreaCFv:
/* 8005EB28 0005BA88 80 63 00 88 */ lwz r3, 0x88(r3) /* 8005EB28 0005BA88 80 63 00 88 */ lwz r3, 0x88(r3)
/* 8005EB2C 0005BA8C 4E 80 00 20 */ blr /* 8005EB2C 0005BA8C 4E 80 00 20 */ blr
.global IGetAreaAssetID__9CGameAreaCFv .global IGetAreaAssetId__9CGameAreaCFv
IGetAreaAssetID__9CGameAreaCFv: IGetAreaAssetId__9CGameAreaCFv:
/* 8005EB30 0005BA90 80 63 00 84 */ lwz r3, 0x84(r3) /* 8005EB30 0005BA90 80 63 00 84 */ lwz r3, 0x84(r3)
/* 8005EB34 0005BA94 4E 80 00 20 */ blr /* 8005EB34 0005BA94 4E 80 00 20 */ blr

View File

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

View File

@ -1,13 +1,42 @@
#include "MetroidPrime/CGameArea.hpp" #include "MetroidPrime/CGameArea.hpp"
#include "Kyoto/CResFactory.hpp"
#include "Kyoto/CDvdRequest.hpp" #include "Kyoto/CDvdRequest.hpp"
#include "Kyoto/CResFactory.hpp"
#define ROUND_UP_32(val) (((val) + 31) & ~31) #define ROUND_UP_32(val) (((val) + 31) & ~31)
rstl::pair< rstl::auto_ptr< uchar >, int > GetScriptingMemoryAlways(const IGameArea& area) {
SObjectTag tag('MREA', area.IGetAreaAssetId());
rstl::auto_ptr< char > buf = new char[0x60];
CInputStream* resource = gpResourceFactory->GetResLoader().LoadNewResourceSync(tag, 0, 0x60, buf.get());
if (!resource || *(uint*)(buf.get()) != 0xdeadbeef) {
return rstl::pair< rstl::auto_ptr< uchar >, int >(nullptr, 0);
}
}
CGameArea::CPostConstructed::CPostConstructed() {} CGameArea::CPostConstructed::CPostConstructed() {}
CGameArea::CPostConstructed::~CPostConstructed() {} CGameArea::CPostConstructed::~CPostConstructed() {}
const CTransform4f& CGameArea::IGetTM() const { return xc_transform; }
CAssetId CGameArea::IGetStringTableAssetId() const { return x8_nameSTRG; }
uint CGameArea::IGetNumAttachedAreas() const { return x8c_attachedAreaIndices.size(); }
TAreaId CGameArea::IGetAttachedAreaId(int i) const { return x8c_attachedAreaIndices[i]; }
bool CGameArea::IIsActive() const { return xf0_25_active; }
CAssetId CGameArea::IGetAreaAssetId() const { return x84_mrea; }
int CGameArea::IGetAreaSaveId() const { return x88_areaId; }
rstl::pair< rstl::auto_ptr< uchar >, int > CGameArea::IGetScriptingMemoryAlways() const {
return GetScriptingMemoryAlways(*this);
}
bool CGameArea::StartStreamingMainArea() { bool CGameArea::StartStreamingMainArea() {
if (xf0_24_postConstructed) if (xf0_24_postConstructed)
return false; return false;
@ -48,7 +77,8 @@ bool CGameArea::StartStreamingMainArea() {
SObjectTag tag('MREA', x84_mrea); SObjectTag tag('MREA', x84_mrea);
// for (uint i = 0; i < secCount; ++i) // for (uint i = 0; i < secCount; ++i)
// totalSz += CBasics::SwapBytes(reinterpret_cast<u32*>(x110_mreaSecBufs[1].first.get())[i]); // totalSz +=
// CBasics::SwapBytes(reinterpret_cast<u32*>(x110_mreaSecBufs[1].first.get())[i]);
// AllocNewAreaData(x128_mreaDataOffset, totalSz); // AllocNewAreaData(x128_mreaDataOffset, totalSz);
@ -58,7 +88,8 @@ bool CGameArea::StartStreamingMainArea() {
// uint curOff = 0; // uint curOff = 0;
// for (uint i = 0; i < secCount; ++i) { // for (uint i = 0; i < secCount; ++i) {
// uint size = CBasics::SwapBytes(reinterpret_cast<u32*>(x110_mreaSecBufs[1].first.get())[i]); // uint size =
// CBasics::SwapBytes(reinterpret_cast<u32*>(x110_mreaSecBufs[1].first.get())[i]);
// m_resolvedBufs.emplace_back(x110_mreaSecBufs[2].first.get() + curOff, size); // m_resolvedBufs.emplace_back(x110_mreaSecBufs[2].first.get() + curOff, size);
// curOff += size; // curOff += size;
// } // }
@ -73,15 +104,15 @@ bool CGameArea::StartStreamingMainArea() {
targetSecCount += 1; targetSecCount += 1;
} }
rstl::auto_ptr<char> buf = (char*) CMemory::Alloc(totalSz, IAllocator::kHI_RoundUpLen); rstl::auto_ptr< char > buf = (char*)CMemory::Alloc(totalSz, IAllocator::kHI_RoundUpLen);
xf8_loadTransactions.push_back( xf8_loadTransactions.push_back(
rstl::rc_ptr< CDvdRequest >(gpResourceFactory->GetResLoader().LoadResourcePartAsync(tag, x128_mreaDataOffset, totalSz, buf.get())) rstl::rc_ptr< CDvdRequest >(gpResourceFactory->GetResLoader().LoadResourcePartAsync(
); tag, x128_mreaDataOffset, totalSz, buf.get())));
x128_mreaDataOffset += totalSz; x128_mreaDataOffset += totalSz;
x110_mreaSecBufs.push_back(rstl::pair< rstl::auto_ptr<char>, int>( buf, 0 )); x110_mreaSecBufs.push_back(rstl::pair< rstl::auto_ptr< char >, int >(buf, 0));
for (int i = secCount + 1; i < targetSecCount; ++i) { for (int i = secCount + 1; i < targetSecCount; ++i) {
x110_mreaSecBufs.push_back(rstl::pair< rstl::auto_ptr<char>, int>( nullptr, 0 )); x110_mreaSecBufs.push_back(rstl::pair< rstl::auto_ptr< char >, int >(nullptr, 0));
} }
x124_secCount = targetSecCount; x124_secCount = targetSecCount;
if (targetSecCount == partSizes) { if (targetSecCount == partSizes) {