mirror of https://github.com/AxioDL/metaforce.git
Fixes to get Metaforce booting again!
This commit is contained in:
parent
8afab43876
commit
1655d229cf
|
@ -21,16 +21,16 @@ constexpr std::array TypeTable{
|
|||
|
||||
CFactoryFnReturn CFactoryMgr::MakeObject(const SObjectTag& tag, metaforce::CInputStream& in,
|
||||
const CVParamTransfer& paramXfer, CObjectReference* selfRef) {
|
||||
auto search = m_factories.find(tag.type);
|
||||
if (search == m_factories.end())
|
||||
auto search = x10_factories.find(tag.type);
|
||||
if (search == x10_factories.end())
|
||||
return {};
|
||||
|
||||
return search->second(tag, in, paramXfer, selfRef);
|
||||
}
|
||||
|
||||
bool CFactoryMgr::CanMakeMemory(const metaforce::SObjectTag& tag) const {
|
||||
auto search = m_memFactories.find(tag.type);
|
||||
return search != m_memFactories.cend();
|
||||
auto search = x24_memFactories.find(tag.type);
|
||||
return search != x24_memFactories.cend();
|
||||
}
|
||||
|
||||
CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size,
|
||||
|
@ -39,8 +39,8 @@ CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::u
|
|||
OPTICK_EVENT();
|
||||
std::unique_ptr<u8[]> localBuf = std::move(buf);
|
||||
|
||||
const auto memFactoryIter = m_memFactories.find(tag.type);
|
||||
if (memFactoryIter != m_memFactories.cend()) {
|
||||
const auto memFactoryIter = x24_memFactories.find(tag.type);
|
||||
if (memFactoryIter != x24_memFactories.cend()) {
|
||||
if (compressed) {
|
||||
std::unique_ptr<CInputStream> compRead =
|
||||
std::make_unique<CMemoryInStream>(localBuf.get(), size, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
|
@ -53,8 +53,8 @@ CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::u
|
|||
return memFactoryIter->second(tag, std::move(localBuf), size, paramXfer, selfRef);
|
||||
}
|
||||
} else {
|
||||
const auto factoryIter = m_factories.find(tag.type);
|
||||
if (factoryIter == m_factories.end()) {
|
||||
const auto factoryIter = x10_factories.find(tag.type);
|
||||
if (factoryIter == x10_factories.end()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ class CVParamTransfer;
|
|||
class IObj;
|
||||
|
||||
class CFactoryMgr {
|
||||
std::unordered_map<FourCC, FFactoryFunc> m_factories;
|
||||
std::unordered_map<FourCC, FMemFactoryFunc> m_memFactories;
|
||||
std::unordered_map<FourCC, FFactoryFunc> x10_factories;
|
||||
std::unordered_map<FourCC, FMemFactoryFunc> x24_memFactories;
|
||||
|
||||
public:
|
||||
CFactoryFnReturn MakeObject(const SObjectTag& tag, metaforce::CInputStream& in, const CVParamTransfer& paramXfer,
|
||||
|
@ -21,8 +21,8 @@ public:
|
|||
bool CanMakeMemory(const metaforce::SObjectTag& tag) const;
|
||||
CFactoryFnReturn MakeObjectFromMemory(const SObjectTag& tag, std::unique_ptr<u8[]>&& buf, int size, bool compressed,
|
||||
const CVParamTransfer& paramXfer, CObjectReference* selfRef);
|
||||
void AddFactory(FourCC key, FFactoryFunc func) { m_factories.insert_or_assign(key, std::move(func)); }
|
||||
void AddFactory(FourCC key, FMemFactoryFunc func) { m_memFactories.insert_or_assign(key, std::move(func)); }
|
||||
void AddFactory(FourCC key, FFactoryFunc func) { x10_factories.insert_or_assign(key, std::move(func)); }
|
||||
void AddFactory(FourCC key, FMemFactoryFunc func) { x24_memFactories.insert_or_assign(key, std::move(func)); }
|
||||
|
||||
enum class ETypeTable : u8 {
|
||||
CLSN,
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
namespace metaforce {
|
||||
|
||||
static u32 ReadCount(CInputStream& in) {
|
||||
u32 result = in.ReadLong();
|
||||
if (result == UINT32_MAX) {
|
||||
s32 result = in.ReadLong();
|
||||
if (result == -1) {
|
||||
return in.ReadLong();
|
||||
}
|
||||
u8 junk[784];
|
||||
|
|
|
@ -32,8 +32,8 @@ public:
|
|||
|
||||
class CSkinRules {
|
||||
std::vector<CVirtualBone> x0_bones;
|
||||
u32 x10_vertexCount;
|
||||
u32 x14_normalCount;
|
||||
u32 x10_vertexCount = 0;
|
||||
u32 x14_normalCount = 0;
|
||||
|
||||
public:
|
||||
explicit CSkinRules(CInputStream& in);
|
||||
|
|
|
@ -31,29 +31,30 @@ bool CInputStream::InternalReadNext() {
|
|||
bool CInputStream::GrabAnotherBlock() { return InternalReadNext(); }
|
||||
|
||||
void CInputStream::Get(u8* dest, u32 len) {
|
||||
u32 readLen = 0;
|
||||
x20_bitOffset = 0;
|
||||
u32 readCount = 0;
|
||||
while (len != 0) {
|
||||
u32 blockLen = x8_blockLen - x4_blockOffset;
|
||||
if (len < blockLen) {
|
||||
blockLen = len;
|
||||
}
|
||||
|
||||
if (blockLen != 0) {
|
||||
memcpy(dest + readLen, x10_ptr + x4_blockOffset, blockLen);
|
||||
len -= blockLen;
|
||||
readLen += blockLen;
|
||||
x4_blockOffset += blockLen;
|
||||
} else if (len > 256) {
|
||||
u32 tmp = Read(dest + readLen, len);
|
||||
len -= tmp;
|
||||
readLen += tmp;
|
||||
if (blockLen == 0) {
|
||||
if (len <= 256) {
|
||||
GrabAnotherBlock();
|
||||
} else {
|
||||
u32 readLen = Read(dest + readCount, len);
|
||||
len -= readLen;
|
||||
readCount += readLen;
|
||||
}
|
||||
} else {
|
||||
GrabAnotherBlock();
|
||||
memcpy(dest + readCount, x10_ptr + x4_blockOffset, blockLen);
|
||||
len -= blockLen;
|
||||
readCount += blockLen;
|
||||
x4_blockOffset += blockLen;
|
||||
}
|
||||
}
|
||||
|
||||
x18_readPosition += readLen;
|
||||
x18_readPosition += readCount;
|
||||
}
|
||||
|
||||
u32 CInputStream::ReadBytes(void* dest, u32 len) {
|
||||
|
|
Loading…
Reference in New Issue