2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-21 00:59:13 +00:00

RE COutput/InputStream and friends and migrate over

This branch is probably still horribly broken, but it's a good first step to migrating away from having hecl embedded in the runtime
This commit is contained in:
2022-02-17 23:37:54 -08:00
parent c679c2e0f8
commit dad7249927
172 changed files with 3629 additions and 2780 deletions

View File

@@ -1,5 +1,5 @@
#include "Runtime/RetroTypes.hpp"
#include "Runtime/IOStreams.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/IMain.hpp"
@@ -8,28 +8,42 @@
namespace metaforce {
logvisor::Module Log("metaforce::RetroTypes::CAssetId");
SObjectTag::SObjectTag(CInputStream& in) {
in.ReadBytes(reinterpret_cast<char*>(&type), 4);
id = in.Get<CAssetId>();
}
void SObjectTag::ReadMLVL(CInputStream& in) {
id = in.Get<CAssetId>();
in.ReadBytes(reinterpret_cast<char*>(&type), 4);
}
CAssetId::CAssetId(CInputStream& in) {
if (g_Main) {
if (g_Main->GetExpectedIdSize() == sizeof(u32))
Assign(in.readUint32Big());
else if (g_Main->GetExpectedIdSize() == sizeof(u64))
Assign(in.readUint64Big());
else
if (g_Main != nullptr) {
if (g_Main->GetExpectedIdSize() == sizeof(u32)) {
Assign(in.ReadLong());
} else if (g_Main->GetExpectedIdSize() == sizeof(u64)) {
Assign(in.ReadLongLong());
} else {
Log.report(logvisor::Fatal, FMT_STRING("Unsupported id length {}"), g_Main->GetExpectedIdSize());
} else
}
} else {
Log.report(logvisor::Fatal, FMT_STRING("Input constructor called before runtime Main entered!"));
}
}
void CAssetId::PutTo(COutputStream& out) {
if (g_Main) {
if (g_Main->GetExpectedIdSize() == sizeof(u32))
out.writeUint32Big(u32(id));
else if (g_Main->GetExpectedIdSize() == sizeof(u64))
out.writeUint64Big(id);
else
if (g_Main != nullptr) {
if (g_Main->GetExpectedIdSize() == sizeof(u32)) {
out.Put(u32(id));
} else if (g_Main->GetExpectedIdSize() == sizeof(u64)) {
out.Put(id);
} else {
Log.report(logvisor::Fatal, FMT_STRING("Unsupported id length {}"), g_Main->GetExpectedIdSize());
} else
}
} else {
Log.report(logvisor::Fatal, FMT_STRING("PutTo called before runtime Main entered!"));
}
}
} // namespace metaforce