mirror of https://github.com/AxioDL/metaforce.git
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:
parent
c679c2e0f8
commit
dad7249927
|
@ -4,7 +4,7 @@
|
|||
#include "DeafBabe.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "CMDL.hpp"
|
||||
#include "IOStreams.hpp"
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
#include <set>
|
||||
|
||||
namespace DataSpec {
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
#include "DataSpec/DNAMP2/CSKR.hpp"
|
||||
#include "DataSpec/DNAMP3/CMDLMaterials.hpp"
|
||||
#include "DataSpec/DNAMP3/CSKR.hpp"
|
||||
#include "IOStreams.hpp"
|
||||
|
||||
#include <athena/MemoryReader.hpp>
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
#include <fmt/format.h>
|
||||
#include <hecl/Blender/Connection.hpp>
|
||||
#include <zeus/CAABox.hpp>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "hecl/Blender/Connection.hpp"
|
||||
#include "zeus/CAABox.hpp"
|
||||
#include "DataSpec/DNACommon/AROTBuilder.hpp"
|
||||
#include <athena/MemoryReader.hpp>
|
||||
|
||||
namespace DataSpec::DNAPATH {
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@
|
|||
#include "hecl/Blender/Connection.hpp"
|
||||
#include "hecl/Blender/SDNARead.hpp"
|
||||
#include "nod/nod.hpp"
|
||||
#include <athena/MemoryReader.hpp>
|
||||
#include <athena/MemoryWriter.hpp>
|
||||
|
||||
namespace DataSpec {
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ amuse::AudioGroupData CAudioGroupSet::LoadData() {
|
|||
return SBig(value);
|
||||
};
|
||||
|
||||
athena::io::MemoryReader r(m_buffer.get(), INT32_MAX);
|
||||
x10_baseName = r.readString();
|
||||
x20_name = r.readString();
|
||||
CMemoryInStream r(m_buffer.get(), INT32_MAX, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
x10_baseName = r.Get<std::string>();
|
||||
x20_name = r.Get<std::string>();
|
||||
|
||||
u8* buf = m_buffer.get() + r.position();
|
||||
u8* buf = m_buffer.get() + r.GetReadPosition();
|
||||
const uint32_t poolLen = readU32(buf);
|
||||
unsigned char* pool = buf + 4;
|
||||
buf += poolLen + 4;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "Runtime/Audio/CMidiManager.hpp"
|
||||
|
||||
#include "Runtime/CInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
std::unordered_set<CMidiHandle> CMidiManager::m_MidiWrappers = {};
|
||||
|
@ -35,13 +37,13 @@ CMidiHandle CMidiManager::Play(const CMidiData& data, float fadeTime, bool stopE
|
|||
}
|
||||
|
||||
CMidiManager::CMidiData::CMidiData(CInputStream& in) {
|
||||
in.readUint32Big();
|
||||
x0_setupId = in.readUint32Big();
|
||||
x2_groupId = in.readUint32Big();
|
||||
x4_agscId = in.readUint32Big();
|
||||
u32 length = in.readUint32Big();
|
||||
in.ReadLong();
|
||||
x0_setupId = in.ReadLong();
|
||||
x2_groupId = in.ReadLong();
|
||||
x4_agscId = in.ReadLong();
|
||||
u32 length = in.ReadLong();
|
||||
x8_arrData.reset(new u8[length]);
|
||||
in.readUBytesToBuf(x8_arrData.get(), length);
|
||||
in.ReadBytes(reinterpret_cast<char*>(x8_arrData.get()), length);
|
||||
}
|
||||
|
||||
CFactoryFnReturn FMidiDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& parms,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "Runtime/Audio/CSfxManager.hpp"
|
||||
#include "Runtime/CInputStream.hpp"
|
||||
|
||||
#include "Runtime/CSimplePool.hpp"
|
||||
|
||||
|
@ -19,10 +20,10 @@ static amuse::EffectDelay* s_DelayState = nullptr;
|
|||
CFactoryFnReturn FAudioTranslationTableFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||
CObjectReference* selfRef) {
|
||||
std::unique_ptr<std::vector<u16>> obj = std::make_unique<std::vector<u16>>();
|
||||
u32 count = in.readUint32Big();
|
||||
u32 count = in.ReadLong();
|
||||
obj->reserve(count);
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
obj->push_back(in.readUint16Big());
|
||||
obj->push_back(in.ReadShort());
|
||||
return TToken<std::vector<u16>>::GetIObjObjectFor(std::move(obj));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
#include <array>
|
||||
#include <cstring>
|
||||
|
||||
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/GameGlobalObjects.hpp"
|
||||
#include "Runtime/AutoMapper/CMappableObject.hpp"
|
||||
#include "Runtime/World/CWorld.hpp"
|
||||
#include "Runtime/CBasics.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
constexpr std::array<zeus::CVector3f, 3> MinesPostTransforms{{
|
||||
|
@ -61,17 +62,17 @@ constexpr std::array<u8, 42> MinesPostTransformIndices{
|
|||
};
|
||||
|
||||
CMapArea::CMapArea(CInputStream& in, u32 size)
|
||||
: x0_magic(in.readUint32())
|
||||
, x4_version(in.readUint32Big())
|
||||
, x8_(in.readUint32Big())
|
||||
, xc_visibilityMode(EVisMode(in.readUint32Big()))
|
||||
, x10_box(zeus::CAABox::ReadBoundingBoxBig(in))
|
||||
, x28_mappableObjCount(in.readUint32Big())
|
||||
, x2c_vertexCount(in.readUint32Big())
|
||||
, x30_surfaceCount(in.readUint32Big())
|
||||
: x0_magic(in.ReadLong())
|
||||
, x4_version(in.ReadLong())
|
||||
, x8_(in.ReadLong())
|
||||
, xc_visibilityMode(EVisMode(in.ReadLong()))
|
||||
, x10_box(in.Get<zeus::CAABox>())
|
||||
, x28_mappableObjCount(in.ReadLong())
|
||||
, x2c_vertexCount(in.ReadLong())
|
||||
, x30_surfaceCount(in.ReadLong())
|
||||
, x34_size(size - 52) {
|
||||
x44_buf.reset(new u8[x34_size]);
|
||||
in.readUBytesToBuf(x44_buf.get(), x34_size);
|
||||
in.ReadBytes(x44_buf.get(), x34_size);
|
||||
PostConstruct();
|
||||
}
|
||||
|
||||
|
@ -120,14 +121,14 @@ void CMapArea::PostConstruct() {
|
|||
// CMapAreaSurface::Instance& instance = surf.m_instances.emplace_back(ctx, m_vbo, m_ibo);
|
||||
//
|
||||
// athena::io::MemoryReader r(surf.x1c_outlineOffset, INT_MAX);
|
||||
// u32 outlineCount = r.readUint32Big();
|
||||
// u32 outlineCount = r.ReadLong();
|
||||
//
|
||||
// std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
||||
// linePrims.reserve(outlineCount * 2);
|
||||
// for (u32 j = 0; j < 2; ++j) {
|
||||
// r.seek(4, athena::SeekOrigin::Begin);
|
||||
// for (u32 k = 0; k < outlineCount; ++k) {
|
||||
// const u32 count = r.readUint32Big();
|
||||
// const u32 count = r.ReadLong();
|
||||
// r.seek(count);
|
||||
// r.seekAlign4();
|
||||
// linePrims.emplace_back(ctx, CLineRenderer::EPrimitiveMode::LineStrip, count, nullptr, false, false, true);
|
||||
|
@ -179,11 +180,11 @@ const zeus::CVector3f& CMapArea::GetAreaPostTranslate(const IWorld& world, TArea
|
|||
}
|
||||
|
||||
CMapArea::CMapAreaSurface::CMapAreaSurface(const void* surfBuf) {
|
||||
athena::io::MemoryReader r(surfBuf, 32);
|
||||
x0_normal = r.readVec3fBig();
|
||||
xc_centroid = r.readVec3fBig();
|
||||
x18_surfOffset = reinterpret_cast<const u8*>(uintptr_t(r.readUint32Big()));
|
||||
x1c_outlineOffset = reinterpret_cast<const u8*>(uintptr_t(r.readUint32Big()));
|
||||
CMemoryInStream r(surfBuf, 32, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
x0_normal = r.Get<zeus::CVector3f>();
|
||||
xc_centroid = r.Get<zeus::CVector3f>();
|
||||
x18_surfOffset = reinterpret_cast<const u8*>(uintptr_t(r.ReadLong()));
|
||||
x1c_outlineOffset = reinterpret_cast<const u8*>(uintptr_t(r.ReadLong()));
|
||||
}
|
||||
|
||||
void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& index) {
|
||||
|
@ -193,24 +194,24 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
|
|||
m_primStart = index.size();
|
||||
bool start = true;
|
||||
{
|
||||
athena::io::MemoryReader r(x18_surfOffset, INT_MAX);
|
||||
u32 primCount = r.readUint32Big();
|
||||
CMemoryInStream r(x18_surfOffset, INT_MAX, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
u32 primCount = r.ReadLong();
|
||||
for (u32 i = 0; i < primCount; ++i) {
|
||||
GX::Primitive prim = GX::Primitive(r.readUint32Big());
|
||||
u32 count = r.readUint32Big();
|
||||
GX::Primitive prim = GX::Primitive(r.ReadLong());
|
||||
u32 count = r.ReadLong();
|
||||
switch (prim) {
|
||||
case GX::Primitive::TRIANGLES: {
|
||||
for (u32 v = 0; v < count; v += 3) {
|
||||
if (!start) {
|
||||
index.push_back(index.back());
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
index.push_back(index.back());
|
||||
} else {
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
start = false;
|
||||
}
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
index.push_back(r.ReadUint8());
|
||||
index.push_back(index.back());
|
||||
}
|
||||
break;
|
||||
|
@ -218,38 +219,41 @@ void CMapArea::CMapAreaSurface::PostConstruct(const u8* buf, std::vector<u32>& i
|
|||
case GX::Primitive::TRIANGLESTRIP: {
|
||||
if (!start) {
|
||||
index.push_back(index.back());
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
index.push_back(index.back());
|
||||
} else {
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
start = false;
|
||||
}
|
||||
for (u32 v = 1; v < count; ++v)
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
if (count & 1)
|
||||
index.push_back(index.back());
|
||||
break;
|
||||
}
|
||||
case GX::Primitive::TRIANGLEFAN: {
|
||||
u8 firstVert = r.readUByte();
|
||||
u8 firstVert = r.ReadUint8();
|
||||
if (!start) {
|
||||
index.push_back(index.back());
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
} else {
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
index.push_back(index.back());
|
||||
start = false;
|
||||
}
|
||||
for (u32 v = 1; v < count; ++v) {
|
||||
index.push_back(firstVert);
|
||||
index.push_back(r.readUByte());
|
||||
index.push_back(r.ReadUint8());
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
r.seekAlign4();
|
||||
u32 pos = r.GetReadPosition();
|
||||
while (r.GetReadPosition() != ROUND_UP_4(pos)) {
|
||||
r.ReadUint8();
|
||||
}
|
||||
}
|
||||
}
|
||||
m_primCount = index.size() - m_primStart;
|
||||
|
@ -269,8 +273,11 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
|
|||
|
||||
if (lineColor.a()) {
|
||||
bool draw2 = lineWidth > 1.f;
|
||||
athena::io::MemoryReader r(x1c_outlineOffset, INT_MAX);
|
||||
u32 outlineCount = r.readUint32Big();
|
||||
u32 outlineCount = *reinterpret_cast<u32*>(&x1c_outlineOffset);
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
outlineCount = CBasics::SwapBytes(outlineCount);
|
||||
#endif
|
||||
|
||||
|
||||
std::vector<CLineRenderer>& linePrims = instance.m_linePrims;
|
||||
zeus::CColor color = lineColor;
|
||||
|
@ -280,16 +287,21 @@ void CMapArea::CMapAreaSurface::Draw(const zeus::CVector3f* verts, const zeus::C
|
|||
|
||||
auto primIt = linePrims.begin();
|
||||
for (u32 j = 0; j <= u32(draw2); ++j) {
|
||||
r.seek(4, athena::SeekOrigin::Begin);
|
||||
CMemoryInStream r(x1c_outlineOffset, INT_MAX, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
r.ReadLong();
|
||||
for (u32 i = 0; i < outlineCount; ++i) {
|
||||
CLineRenderer& prim = *primIt++;
|
||||
prim.Reset();
|
||||
u32 count = r.readUint32Big();
|
||||
u32 count = r.ReadLong();
|
||||
for (u32 v = 0; v < count; ++v) {
|
||||
u8 idx = r.readUByte();
|
||||
u8 idx = r.ReadUint8();
|
||||
prim.AddVertex(verts[idx], color, width);
|
||||
}
|
||||
r.seekAlign4();
|
||||
|
||||
u32 pos = r.GetReadPosition();
|
||||
while (r.GetReadPosition() != ROUND_UP_4(pos)) {
|
||||
r.ReadUint8();
|
||||
}
|
||||
prim.Render();
|
||||
}
|
||||
width -= 1.f;
|
||||
|
|
|
@ -6,25 +6,25 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CMapUniverse::CMapUniverse(CInputStream& in, u32 version) : x0_hexagonId(in.readUint32Big()) {
|
||||
CMapUniverse::CMapUniverse(CInputStream& in, u32 version) : x0_hexagonId(in.Get<CAssetId>()) {
|
||||
x4_hexagonToken = g_SimplePool->GetObj({FOURCC('MAPA'), x0_hexagonId});
|
||||
u32 count = in.readUint32Big();
|
||||
u32 count = in.ReadLong();
|
||||
x10_worldDatas.reserve(count);
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
x10_worldDatas.emplace_back(in, version);
|
||||
}
|
||||
|
||||
CMapUniverse::CMapWorldData::CMapWorldData(CInputStream& in, u32 version)
|
||||
: x0_label(in.readString()), x10_worldAssetId(in.readUint32Big()) {
|
||||
x14_transform.read34RowMajor(in);
|
||||
const u32 worldCount = in.readUint32Big();
|
||||
: x0_label(in.Get<std::string>()), x10_worldAssetId(in.ReadLong()) {
|
||||
x14_transform = in.Get<zeus::CTransform>();
|
||||
const u32 worldCount = in.ReadLong();
|
||||
x44_hexagonXfs.reserve(worldCount);
|
||||
for (u32 i = 0; i < worldCount; ++i) {
|
||||
x44_hexagonXfs.emplace_back().read34RowMajor(in);
|
||||
x44_hexagonXfs.emplace_back() = in.Get<zeus::CTransform>();
|
||||
}
|
||||
|
||||
if (version != 0)
|
||||
x54_surfColorSelected.readRGBABig(in);
|
||||
x54_surfColorSelected = in.Get<zeus::CColor>();
|
||||
else
|
||||
x54_surfColorSelected.fromRGBA32(255 | (u32(x10_worldAssetId.Value()) & 0xFFFFFF00));
|
||||
|
||||
|
@ -115,8 +115,8 @@ void CMapUniverse::Draw(const CMapUniverseDrawParms& parms, const zeus::CVector3
|
|||
}
|
||||
|
||||
CFactoryFnReturn FMapUniverseFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&, CObjectReference*) {
|
||||
in.readUint32Big();
|
||||
u32 version = in.readUint32Big();
|
||||
in.ReadLong();
|
||||
u32 version = in.ReadLong();
|
||||
|
||||
return TToken<CMapUniverse>::GetIObjObjectFor(std::make_unique<CMapUniverse>(in, version));
|
||||
}
|
||||
|
|
|
@ -274,13 +274,13 @@ CMapWorld::CMapAreaData::CMapAreaData(CAssetId areaRes, EMapAreaList list, CMapA
|
|||
|
||||
CMapWorld::CMapWorld(CInputStream& in) {
|
||||
x10_listHeads.resize(3);
|
||||
in.readUint32Big();
|
||||
in.readUint32Big();
|
||||
u32 areaCount = in.readUint32Big();
|
||||
in.ReadLong();
|
||||
in.ReadLong();
|
||||
u32 areaCount = in.ReadLong();
|
||||
x0_areas.reserve(areaCount);
|
||||
x20_traversed.resize(areaCount);
|
||||
for (u32 i = 0; i < areaCount; ++i) {
|
||||
CAssetId mapaId = in.readUint32Big();
|
||||
CAssetId mapaId = in.ReadLong();
|
||||
x0_areas.emplace_back(mapaId, EMapAreaList::Unloaded, x0_areas.empty() ? nullptr : &x0_areas.back());
|
||||
}
|
||||
x10_listHeads[2] = &x0_areas.back();
|
||||
|
|
|
@ -5,52 +5,52 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CMapWorldInfo::CMapWorldInfo(CBitStreamReader& reader, const CWorldSaveGameInfo& savw, CAssetId mlvlId) {
|
||||
CMapWorldInfo::CMapWorldInfo(CInputStream& reader, const CWorldSaveGameInfo& savw, CAssetId mlvlId) {
|
||||
const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);
|
||||
|
||||
x4_visitedAreas.reserve((worldMem.GetAreaCount() + 31) / 32);
|
||||
for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) {
|
||||
const bool visited = reader.ReadEncoded(1) != 0;
|
||||
const bool visited = reader.ReadBits(1) != 0;
|
||||
SetAreaVisited(i, visited);
|
||||
}
|
||||
|
||||
x18_mappedAreas.reserve((worldMem.GetAreaCount() + 31) / 32);
|
||||
for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) {
|
||||
const bool mapped = reader.ReadEncoded(1) != 0;
|
||||
const bool mapped = reader.ReadBits(1) != 0;
|
||||
SetIsMapped(i, mapped);
|
||||
}
|
||||
|
||||
for (const auto& doorId : savw.GetDoors()) {
|
||||
SetDoorVisited(doorId, reader.ReadEncoded(1) != 0);
|
||||
SetDoorVisited(doorId, reader.ReadBits(1) != 0);
|
||||
}
|
||||
|
||||
x38_mapStationUsed = reader.ReadEncoded(1) != 0;
|
||||
x38_mapStationUsed = reader.ReadBits(1) != 0;
|
||||
}
|
||||
|
||||
void CMapWorldInfo::PutTo(CBitStreamWriter& writer, const CWorldSaveGameInfo& savw, CAssetId mlvlId) const {
|
||||
void CMapWorldInfo::PutTo(COutputStream& writer, const CWorldSaveGameInfo& savw, CAssetId mlvlId) const {
|
||||
const CSaveWorldMemory& worldMem = g_MemoryCardSys->GetSaveWorldMemory(mlvlId);
|
||||
|
||||
for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) {
|
||||
if (i < x0_visitedAreasAllocated) {
|
||||
writer.WriteEncoded(u32(IsAreaVisited(i)), 1);
|
||||
writer.WriteBits(u32(IsAreaVisited(i)), 1);
|
||||
} else {
|
||||
writer.WriteEncoded(0, 1);
|
||||
writer.WriteBits(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < worldMem.GetAreaCount(); ++i) {
|
||||
if (i < x14_mappedAreasAllocated) {
|
||||
writer.WriteEncoded(u32(IsMapped(i)), 1);
|
||||
writer.WriteBits(u32(IsMapped(i)), 1);
|
||||
} else {
|
||||
writer.WriteEncoded(0, 1);
|
||||
writer.WriteBits(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& doorId : savw.GetDoors()) {
|
||||
writer.WriteEncoded(u32(IsDoorVisited(doorId)), 1);
|
||||
writer.WriteBits(u32(IsDoorVisited(doorId)), 1);
|
||||
}
|
||||
|
||||
writer.WriteEncoded(u32(x38_mapStationUsed), 1);
|
||||
writer.WriteBits(u32(x38_mapStationUsed), 1);
|
||||
}
|
||||
|
||||
void CMapWorldInfo::SetDoorVisited(TEditorId eid, bool visited) { x28_visitedDoors[eid] = visited; }
|
||||
|
|
|
@ -19,8 +19,8 @@ class CMapWorldInfo {
|
|||
|
||||
public:
|
||||
CMapWorldInfo() = default;
|
||||
explicit CMapWorldInfo(CBitStreamReader& reader, const CWorldSaveGameInfo& saveWorld, CAssetId mlvlId);
|
||||
void PutTo(CBitStreamWriter& writer, const CWorldSaveGameInfo& savw, CAssetId mlvlId) const;
|
||||
explicit CMapWorldInfo(CInputStream& reader, const CWorldSaveGameInfo& saveWorld, CAssetId mlvlId);
|
||||
void PutTo(COutputStream& writer, const CWorldSaveGameInfo& savw, CAssetId mlvlId) const;
|
||||
bool IsMapped(TAreaId aid) const;
|
||||
void SetIsMapped(TAreaId aid, bool mapped);
|
||||
void SetDoorVisited(TEditorId eid, bool val);
|
||||
|
|
|
@ -15,12 +15,12 @@ std::array<u16, 24> CMappableObject::skDoorIndices{
|
|||
};
|
||||
|
||||
CMappableObject::CMappableObject(const void* buf) {
|
||||
athena::io::MemoryReader r(buf, 64);
|
||||
x0_type = EMappableObjectType(r.readUint32Big());
|
||||
x4_visibilityMode = EVisMode(r.readUint32Big());
|
||||
x8_objId = r.readUint32Big();
|
||||
xc_ = r.readUint32Big();
|
||||
x10_transform.read34RowMajor(r);
|
||||
CMemoryInStream r(buf, 64);
|
||||
x0_type = EMappableObjectType(r.ReadLong());
|
||||
x4_visibilityMode = EVisMode(r.ReadLong());
|
||||
x8_objId = r.ReadLong();
|
||||
xc_ = r.ReadLong();
|
||||
x10_transform = r.Get<zeus::CTransform>();
|
||||
}
|
||||
|
||||
zeus::CTransform CMappableObject::AdjustTransformForType() const {
|
||||
|
|
|
@ -40,6 +40,14 @@ public:
|
|||
|
||||
static OSCalendarTime ToCalendarTime(OSTime time) { return ToCalendarTime(FromWiiTime(time)); }
|
||||
static OSCalendarTime ToCalendarTime(std::chrono::system_clock::time_point time);
|
||||
static u16 SwapBytes(u16 v);
|
||||
static u32 SwapBytes(u32 v);
|
||||
static u64 SwapBytes(u64 v);
|
||||
static float SwapBytes(float v);
|
||||
static double SwapBytes(double s);
|
||||
static void Swap2Bytes(u8* v);
|
||||
static void Swap4Bytes(u8* v);
|
||||
static void Swap8Bytes(u8* v);
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -136,4 +136,63 @@ OSCalendarTime CBasics::ToCalendarTime(std::chrono::system_clock::time_point tim
|
|||
return ret;
|
||||
}
|
||||
|
||||
u16 CBasics::SwapBytes(u16 v) {
|
||||
Swap2Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
u32 CBasics::SwapBytes(u32 v) {
|
||||
Swap4Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
u64 CBasics::SwapBytes(u64 v) {
|
||||
Swap8Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
float CBasics::SwapBytes(float v) {
|
||||
Swap4Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
double CBasics::SwapBytes(double v) {
|
||||
Swap8Bytes(reinterpret_cast<u8*>(&v));
|
||||
return v;
|
||||
}
|
||||
|
||||
void CBasics::Swap2Bytes(u8* v) {
|
||||
u16* val = reinterpret_cast<u16*>(v);
|
||||
#if __GNUC__
|
||||
*val = __builtin_bswap16(*val);
|
||||
#elif _WIN32
|
||||
*val = _byteswap_ushort(*val);
|
||||
#else
|
||||
*val = (*val << 8) | ((*val >> 8) & 0xFF);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CBasics::Swap4Bytes(u8* v) {
|
||||
u32* val = reinterpret_cast<u32*>(v);
|
||||
#if __GNUC__
|
||||
*val = __builtin_bswap32(*val);
|
||||
#elif _WIN32
|
||||
*val = _byteswap_ulong(*val);
|
||||
#else
|
||||
*val = ((*val & 0x0000FFFF) << 16) | ((*val & 0xFFFF0000) >> 16) | ((*val & 0x00FF00FF) << 8) |
|
||||
((*val & 0xFF00FF00) >> 8);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CBasics::Swap8Bytes(u8* v) {
|
||||
u64* val = reinterpret_cast<u64*>(v);
|
||||
#if __GNUC__
|
||||
*val = __builtin_bswap64(*val);
|
||||
#elif _WIN32
|
||||
*val = _byteswap_uint64(val);
|
||||
#else
|
||||
*val = ((val & 0xFF00000000000000ULL) >> 56) | ((val & 0x00FF000000000000ULL) >> 40) |
|
||||
((val & 0x0000FF0000000000ULL) >> 24) | ((val & 0x000000FF00000000ULL) >> 8) |
|
||||
((val & 0x00000000FF000000ULL) << 8) | ((val & 0x0000000000FF0000ULL) << 24) |
|
||||
((val & 0x000000000000FF00ULL) << 40) | ((val & 0x00000000000000FFULL) << 56);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace metaforce {
|
|||
CDependencyGroup::CDependencyGroup(CInputStream& in) { ReadFromStream(in); }
|
||||
|
||||
void CDependencyGroup::ReadFromStream(CInputStream& in) {
|
||||
u32 depCount = in.readUint32Big();
|
||||
u32 depCount = in.ReadLong();
|
||||
x0_objectTags.reserve(depCount);
|
||||
for (u32 i = 0; i < depCount; i++)
|
||||
x0_objectTags.emplace_back(in);
|
||||
|
|
|
@ -42,10 +42,12 @@ CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::u
|
|||
const auto memFactoryIter = m_memFactories.find(tag.type);
|
||||
if (memFactoryIter != m_memFactories.cend()) {
|
||||
if (compressed) {
|
||||
std::unique_ptr<CInputStream> compRead = std::make_unique<athena::io::MemoryReader>(localBuf.get(), size);
|
||||
const u32 decompLen = compRead->readUint32Big();
|
||||
std::unique_ptr<CInputStream> compRead =
|
||||
std::make_unique<CMemoryInStream>(localBuf.get(), size, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
const u32 decompLen = compRead->ReadLong();
|
||||
CZipInputStream r(std::move(compRead));
|
||||
std::unique_ptr<u8[]> decompBuf = r.readUBytes(decompLen);
|
||||
std::unique_ptr<u8[]> decompBuf(new u8[decompLen]);
|
||||
r.Get(decompBuf.get(), decompLen);
|
||||
return memFactoryIter->second(tag, std::move(decompBuf), decompLen, paramXfer, selfRef);
|
||||
} else {
|
||||
return memFactoryIter->second(tag, std::move(localBuf), size, paramXfer, selfRef);
|
||||
|
@ -57,12 +59,14 @@ CFactoryFnReturn CFactoryMgr::MakeObjectFromMemory(const SObjectTag& tag, std::u
|
|||
}
|
||||
|
||||
if (compressed) {
|
||||
std::unique_ptr<CInputStream> compRead = std::make_unique<athena::io::MemoryReader>(localBuf.get(), size);
|
||||
compRead->readUint32Big();
|
||||
std::unique_ptr<CInputStream> compRead =
|
||||
std::make_unique<CMemoryInStream>(localBuf.get(), size, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
|
||||
compRead->ReadLong();
|
||||
CZipInputStream r(std::move(compRead));
|
||||
return factoryIter->second(tag, r, paramXfer, selfRef);
|
||||
} else {
|
||||
CMemoryInStream r(localBuf.get(), size);
|
||||
CMemoryInStream r(localBuf.get(), size, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
return factoryIter->second(tag, r, paramXfer, selfRef);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,29 +7,29 @@
|
|||
namespace metaforce {
|
||||
|
||||
CGameHintInfo::CGameHintInfo(CInputStream& in, s32 version) {
|
||||
u32 hintCount = in.readUint32Big();
|
||||
u32 hintCount = in.ReadLong();
|
||||
x0_hints.reserve(hintCount);
|
||||
for (u32 i = 0; i < hintCount; ++i)
|
||||
x0_hints.emplace_back(in, version);
|
||||
}
|
||||
|
||||
CGameHintInfo::CGameHint::CGameHint(CInputStream& in, s32 version)
|
||||
: x0_name(in.readString())
|
||||
, x10_immediateTime(in.readFloatBig())
|
||||
, x14_normalTime(in.readFloatBig())
|
||||
, x18_stringId(in.readUint32Big())
|
||||
, x1c_textTime(3.f * float(version <= 0 ? 1 : in.readUint32Big())) {
|
||||
u32 locationCount = in.readUint32Big();
|
||||
: x0_name(in.Get<std::string>())
|
||||
, x10_immediateTime(in.ReadFloat())
|
||||
, x14_normalTime(in.ReadFloat())
|
||||
, x18_stringId(in.ReadLong())
|
||||
, x1c_textTime(3.f * float(version <= 0 ? 1 : in.ReadLong())) {
|
||||
u32 locationCount = in.ReadLong();
|
||||
x20_locations.reserve(locationCount);
|
||||
for (u32 i = 0; i < locationCount; ++i)
|
||||
x20_locations.emplace_back(in, version);
|
||||
}
|
||||
|
||||
CGameHintInfo::SHintLocation::SHintLocation(CInputStream& in, s32)
|
||||
: x0_mlvlId(in.readUint32Big())
|
||||
, x4_mreaId(in.readUint32Big())
|
||||
, x8_areaId(in.readUint32Big())
|
||||
, xc_stringId(in.readUint32Big()) {}
|
||||
: x0_mlvlId(in.ReadLong())
|
||||
, x4_mreaId(in.ReadLong())
|
||||
, x8_areaId(in.ReadLong())
|
||||
, xc_stringId(in.ReadLong()) {}
|
||||
|
||||
int CGameHintInfo::FindHintIndex(std::string_view str) {
|
||||
const std::vector<CGameHint>& gameHints = g_MemoryCardSys->GetHints();
|
||||
|
@ -40,8 +40,8 @@ int CGameHintInfo::FindHintIndex(std::string_view str) {
|
|||
}
|
||||
|
||||
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&, CObjectReference*) {
|
||||
in.readUint32Big();
|
||||
s32 version = in.readInt32Big();
|
||||
in.ReadLong();
|
||||
s32 version = in.ReadInt32();
|
||||
|
||||
return TToken<CGameHintInfo>::GetIObjObjectFor(std::make_unique<CGameHintInfo>(in, version));
|
||||
}
|
||||
|
|
|
@ -96,26 +96,26 @@ constexpr std::array<std::pair<size_t, const SGameOption*>, 5> GameOptionsRegist
|
|||
{0, nullptr},
|
||||
}};
|
||||
|
||||
CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) {
|
||||
CPersistentOptions::CPersistentOptions(CInputStream& stream) {
|
||||
for (u8& entry : x0_nesState) {
|
||||
entry = stream.ReadEncoded(8);
|
||||
entry = stream.ReadBits(8);
|
||||
}
|
||||
|
||||
for (bool& entry : x68_) {
|
||||
entry = stream.ReadEncoded(8) != 0;
|
||||
entry = stream.ReadBits(8) != 0;
|
||||
}
|
||||
|
||||
xc0_frozenFpsCount = stream.ReadEncoded(2);
|
||||
xc4_frozenBallCount = stream.ReadEncoded(2);
|
||||
xc8_powerBombAmmoCount = stream.ReadEncoded(1);
|
||||
xcc_logScanPercent = stream.ReadEncoded(7);
|
||||
xd0_24_fusionLinked = stream.ReadEncoded(1) != 0;
|
||||
xd0_25_normalModeBeat = stream.ReadEncoded(1) != 0;
|
||||
xd0_26_hardModeBeat = stream.ReadEncoded(1) != 0;
|
||||
xd0_27_fusionBeat = stream.ReadEncoded(1) != 0;
|
||||
xc0_frozenFpsCount = stream.ReadBits(2);
|
||||
xc4_frozenBallCount = stream.ReadBits(2);
|
||||
xc8_powerBombAmmoCount = stream.ReadBits(1);
|
||||
xcc_logScanPercent = stream.ReadBits(7);
|
||||
xd0_24_fusionLinked = stream.ReadBits(1) != 0;
|
||||
xd0_25_normalModeBeat = stream.ReadBits(1) != 0;
|
||||
xd0_26_hardModeBeat = stream.ReadBits(1) != 0;
|
||||
xd0_27_fusionBeat = stream.ReadBits(1) != 0;
|
||||
xd0_28_fusionSuitActive = false;
|
||||
xd0_29_allItemsCollected = stream.ReadEncoded(1) != 0;
|
||||
xbc_autoMapperKeyState = stream.ReadEncoded(2);
|
||||
xd0_29_allItemsCollected = stream.ReadBits(1) != 0;
|
||||
xbc_autoMapperKeyState = stream.ReadBits(2);
|
||||
|
||||
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
||||
size_t cinematicCount = 0;
|
||||
|
@ -128,7 +128,7 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) {
|
|||
std::vector<bool> cinematicStates;
|
||||
cinematicStates.reserve(cinematicCount);
|
||||
for (size_t i = 0; i < cinematicCount; ++i) {
|
||||
cinematicStates.push_back(stream.ReadEncoded(1) != 0);
|
||||
cinematicStates.push_back(stream.ReadBits(1) != 0);
|
||||
}
|
||||
|
||||
for (const auto& world : memWorlds) {
|
||||
|
@ -142,25 +142,25 @@ CPersistentOptions::CPersistentOptions(CBitStreamReader& stream) {
|
|||
}
|
||||
}
|
||||
|
||||
void CPersistentOptions::PutTo(CBitStreamWriter& w) const {
|
||||
void CPersistentOptions::PutTo(COutputStream& w) const {
|
||||
for (const u8 entry : x0_nesState) {
|
||||
w.WriteEncoded(entry, 8);
|
||||
w.WriteBits(entry, 8);
|
||||
}
|
||||
|
||||
for (const bool entry : x68_) {
|
||||
w.WriteEncoded(u32(entry), 8);
|
||||
w.WriteBits(u32(entry), 8);
|
||||
}
|
||||
|
||||
w.WriteEncoded(xc0_frozenFpsCount, 2);
|
||||
w.WriteEncoded(xc4_frozenBallCount, 2);
|
||||
w.WriteEncoded(xc8_powerBombAmmoCount, 1);
|
||||
w.WriteEncoded(xcc_logScanPercent, 7);
|
||||
w.WriteEncoded(xd0_24_fusionLinked, 1);
|
||||
w.WriteEncoded(xd0_25_normalModeBeat, 1);
|
||||
w.WriteEncoded(xd0_26_hardModeBeat, 1);
|
||||
w.WriteEncoded(xd0_27_fusionBeat, 1);
|
||||
w.WriteEncoded(xd0_29_allItemsCollected, 1);
|
||||
w.WriteEncoded(xbc_autoMapperKeyState, 2);
|
||||
w.WriteBits(xc0_frozenFpsCount, 2);
|
||||
w.WriteBits(xc4_frozenBallCount, 2);
|
||||
w.WriteBits(xc8_powerBombAmmoCount, 1);
|
||||
w.WriteBits(xcc_logScanPercent, 7);
|
||||
w.WriteBits(xd0_24_fusionLinked, 1);
|
||||
w.WriteBits(xd0_25_normalModeBeat, 1);
|
||||
w.WriteBits(xd0_26_hardModeBeat, 1);
|
||||
w.WriteBits(xd0_27_fusionBeat, 1);
|
||||
w.WriteBits(xd0_29_allItemsCollected, 1);
|
||||
w.WriteBits(xbc_autoMapperKeyState, 2);
|
||||
|
||||
const auto& memWorlds = g_MemoryCardSys->GetMemoryWorlds();
|
||||
for (const auto& world : memWorlds) {
|
||||
|
@ -168,7 +168,7 @@ void CPersistentOptions::PutTo(CBitStreamWriter& w) const {
|
|||
g_SimplePool->GetObj(SObjectTag{FOURCC('SAVW'), world.second.GetSaveWorldAssetId()});
|
||||
|
||||
for (const auto& cineId : saveWorld->GetCinematics()) {
|
||||
w.WriteEncoded(u32(GetCinematicState(world.first, cineId)), 1);
|
||||
w.WriteBits(u32(GetCinematicState(world.first, cineId)), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,26 +194,26 @@ void CPersistentOptions::SetCinematicState(CAssetId mlvlId, TEditorId cineId, bo
|
|||
xac_cinematicStates.erase(existing);
|
||||
}
|
||||
|
||||
CGameOptions::CGameOptions(CBitStreamReader& stream) {
|
||||
CGameOptions::CGameOptions(CInputStream& stream) {
|
||||
for (u8& entry : x0_)
|
||||
entry = stream.ReadEncoded(8);
|
||||
entry = stream.ReadBits(8);
|
||||
|
||||
x44_soundMode = CAudioSys::ESurroundModes(stream.ReadEncoded(2));
|
||||
x48_screenBrightness = stream.ReadEncoded(4);
|
||||
x44_soundMode = CAudioSys::ESurroundModes(stream.ReadBits(2));
|
||||
x48_screenBrightness = stream.ReadBits(4);
|
||||
|
||||
x4c_screenXOffset = stream.ReadEncoded(6) - 30;
|
||||
x50_screenYOffset = stream.ReadEncoded(6) - 30;
|
||||
x54_screenStretch = stream.ReadEncoded(5) - 10;
|
||||
x58_sfxVol = stream.ReadEncoded(7);
|
||||
x5c_musicVol = stream.ReadEncoded(7);
|
||||
x60_hudAlpha = stream.ReadEncoded(8);
|
||||
x64_helmetAlpha = stream.ReadEncoded(8);
|
||||
x4c_screenXOffset = stream.ReadBits(6) - 30;
|
||||
x50_screenYOffset = stream.ReadBits(6) - 30;
|
||||
x54_screenStretch = stream.ReadBits(5) - 10;
|
||||
x58_sfxVol = stream.ReadBits(7);
|
||||
x5c_musicVol = stream.ReadBits(7);
|
||||
x60_hudAlpha = stream.ReadBits(8);
|
||||
x64_helmetAlpha = stream.ReadBits(8);
|
||||
|
||||
x68_24_hudLag = stream.ReadEncoded(1) != 0;
|
||||
x68_28_hintSystem = stream.ReadEncoded(1) != 0;
|
||||
x68_25_invertY = stream.ReadEncoded(1) != 0;
|
||||
x68_26_rumble = stream.ReadEncoded(1) != 0;
|
||||
x68_27_swapBeamsControls = stream.ReadEncoded(1) != 0;
|
||||
x68_24_hudLag = stream.ReadBits(1) != 0;
|
||||
x68_28_hintSystem = stream.ReadBits(1) != 0;
|
||||
x68_25_invertY = stream.ReadBits(1) != 0;
|
||||
x68_26_rumble = stream.ReadBits(1) != 0;
|
||||
x68_27_swapBeamsControls = stream.ReadBits(1) != 0;
|
||||
}
|
||||
|
||||
void CGameOptions::ResetToDefaults() {
|
||||
|
@ -235,26 +235,26 @@ void CGameOptions::ResetToDefaults() {
|
|||
EnsureSettings();
|
||||
}
|
||||
|
||||
void CGameOptions::PutTo(CBitStreamWriter& writer) const {
|
||||
void CGameOptions::PutTo(COutputStream& writer) const {
|
||||
for (const u8 entry : x0_)
|
||||
writer.WriteEncoded(entry, 8);
|
||||
writer.WriteBits(entry, 8);
|
||||
|
||||
writer.WriteEncoded(u32(x44_soundMode), 2);
|
||||
writer.WriteEncoded(x48_screenBrightness, 4);
|
||||
writer.WriteBits(u32(x44_soundMode), 2);
|
||||
writer.WriteBits(x48_screenBrightness, 4);
|
||||
|
||||
writer.WriteEncoded(x4c_screenXOffset + 30, 6);
|
||||
writer.WriteEncoded(x50_screenYOffset + 30, 6);
|
||||
writer.WriteEncoded(x54_screenStretch + 10, 5);
|
||||
writer.WriteEncoded(x58_sfxVol, 7);
|
||||
writer.WriteEncoded(x5c_musicVol, 7);
|
||||
writer.WriteEncoded(x60_hudAlpha, 8);
|
||||
writer.WriteEncoded(x64_helmetAlpha, 8);
|
||||
writer.WriteBits(x4c_screenXOffset + 30, 6);
|
||||
writer.WriteBits(x50_screenYOffset + 30, 6);
|
||||
writer.WriteBits(x54_screenStretch + 10, 5);
|
||||
writer.WriteBits(x58_sfxVol, 7);
|
||||
writer.WriteBits(x5c_musicVol, 7);
|
||||
writer.WriteBits(x60_hudAlpha, 8);
|
||||
writer.WriteBits(x64_helmetAlpha, 8);
|
||||
|
||||
writer.WriteEncoded(x68_24_hudLag, 1);
|
||||
writer.WriteEncoded(x68_28_hintSystem, 1);
|
||||
writer.WriteEncoded(x68_25_invertY, 1);
|
||||
writer.WriteEncoded(x68_26_rumble, 1);
|
||||
writer.WriteEncoded(x68_27_swapBeamsControls, 1);
|
||||
writer.WriteBits(x68_24_hudLag, 1);
|
||||
writer.WriteBits(x68_28_hintSystem, 1);
|
||||
writer.WriteBits(x68_25_invertY, 1);
|
||||
writer.WriteBits(x68_26_rumble, 1);
|
||||
writer.WriteBits(x68_27_swapBeamsControls, 1);
|
||||
}
|
||||
|
||||
CGameOptions::CGameOptions()
|
||||
|
@ -579,14 +579,14 @@ int CGameOptions::GetOption(EGameOption option) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
CHintOptions::CHintOptions(CBitStreamReader& stream) {
|
||||
CHintOptions::CHintOptions(CInputStream& stream) {
|
||||
const auto& hints = g_MemoryCardSys->GetHints();
|
||||
x0_hintStates.reserve(hints.size());
|
||||
|
||||
u32 hintIdx = 0;
|
||||
for ([[maybe_unused]] const auto& hint : hints) {
|
||||
const auto state = EHintState(stream.ReadEncoded(2));
|
||||
const s32 timeBits = stream.ReadEncoded(32);
|
||||
const auto state = EHintState(stream.ReadBits(2));
|
||||
const s32 timeBits = stream.ReadBits(32);
|
||||
float time;
|
||||
std::memcpy(&time, &timeBits, sizeof(s32));
|
||||
if (state == EHintState::Zero) {
|
||||
|
@ -602,14 +602,14 @@ CHintOptions::CHintOptions(CBitStreamReader& stream) {
|
|||
}
|
||||
}
|
||||
|
||||
void CHintOptions::PutTo(CBitStreamWriter& writer) const {
|
||||
void CHintOptions::PutTo(COutputStream& writer) const {
|
||||
for (const SHintState& hint : x0_hintStates) {
|
||||
writer.WriteEncoded(u32(hint.x0_state), 2);
|
||||
writer.WriteBits(u32(hint.x0_state), 2);
|
||||
|
||||
u32 timeBits;
|
||||
std::memcpy(&timeBits, &hint.x4_time, sizeof(timeBits));
|
||||
|
||||
writer.WriteEncoded(timeBits, 32);
|
||||
writer.WriteBits(timeBits, 32);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class CPersistentOptions {
|
|||
|
||||
public:
|
||||
CPersistentOptions() = default;
|
||||
explicit CPersistentOptions(CBitStreamReader& stream);
|
||||
explicit CPersistentOptions(CInputStream& stream);
|
||||
|
||||
bool GetCinematicState(CAssetId mlvlId, TEditorId cineId) const;
|
||||
void SetCinematicState(CAssetId mlvlId, TEditorId cineId, bool state);
|
||||
|
@ -93,7 +93,7 @@ public:
|
|||
bool GetShowPowerBombAmmoMessage() const { return xc8_powerBombAmmoCount != 1; }
|
||||
void IncrementPowerBombAmmoCount() { xc8_powerBombAmmoCount = std::min<u32>(1, xc8_powerBombAmmoCount + 1); }
|
||||
|
||||
void PutTo(CBitStreamWriter& w) const;
|
||||
void PutTo(COutputStream& w) const;
|
||||
|
||||
u8* GetNESState() { return x0_nesState.data(); }
|
||||
const u8* GetNESState() const { return x0_nesState.data(); }
|
||||
|
@ -122,11 +122,11 @@ class CGameOptions {
|
|||
|
||||
public:
|
||||
CGameOptions();
|
||||
explicit CGameOptions(CBitStreamReader& stream);
|
||||
explicit CGameOptions(CInputStream& stream);
|
||||
void ResetToDefaults();
|
||||
void InitSoundMode();
|
||||
void EnsureSettings();
|
||||
void PutTo(CBitStreamWriter& writer) const;
|
||||
void PutTo(COutputStream& writer) const;
|
||||
|
||||
float TuneScreenBrightness() const;
|
||||
void SetScreenBrightness(s32 value, bool apply);
|
||||
|
@ -189,8 +189,8 @@ private:
|
|||
|
||||
public:
|
||||
CHintOptions() = default;
|
||||
explicit CHintOptions(CBitStreamReader& stream);
|
||||
void PutTo(CBitStreamWriter& writer) const;
|
||||
explicit CHintOptions(CInputStream& stream);
|
||||
void PutTo(COutputStream& writer) const;
|
||||
void SetNextHintTime();
|
||||
void InitializeMemoryState();
|
||||
const SHintState* GetCurrentDisplayedHint() const;
|
||||
|
|
|
@ -23,12 +23,12 @@ union BitsToDouble {
|
|||
double doub;
|
||||
};
|
||||
|
||||
CScriptLayerManager::CScriptLayerManager(CBitStreamReader& reader, const CWorldSaveGameInfo& saveWorld) {
|
||||
const u32 bitCount = reader.ReadEncoded(10);
|
||||
CScriptLayerManager::CScriptLayerManager(CInputStream& reader, const CWorldSaveGameInfo& saveWorld) {
|
||||
const u32 bitCount = reader.ReadBits(10);
|
||||
x10_saveLayers.reserve(bitCount);
|
||||
|
||||
for (u32 i = 0; i < bitCount; ++i) {
|
||||
const bool bit = reader.ReadEncoded(1) != 0;
|
||||
const bool bit = reader.ReadBits(1) != 0;
|
||||
if (bit) {
|
||||
x10_saveLayers.setBit(i);
|
||||
} else {
|
||||
|
@ -37,18 +37,18 @@ CScriptLayerManager::CScriptLayerManager(CBitStreamReader& reader, const CWorldS
|
|||
}
|
||||
}
|
||||
|
||||
void CScriptLayerManager::PutTo(CBitStreamWriter& writer) const {
|
||||
void CScriptLayerManager::PutTo(COutputStream& writer) const {
|
||||
u32 totalLayerCount = 0;
|
||||
for (size_t i = 0; i < x0_areaLayers.size(); ++i) {
|
||||
totalLayerCount += GetAreaLayerCount(s32(i)) - 1;
|
||||
}
|
||||
|
||||
writer.WriteEncoded(totalLayerCount, 10);
|
||||
writer.WriteBits(totalLayerCount, 10);
|
||||
|
||||
for (size_t i = 0; i < x0_areaLayers.size(); ++i) {
|
||||
const u32 count = GetAreaLayerCount(s32(i));
|
||||
for (u32 l = 1; l < count; ++l) {
|
||||
writer.WriteEncoded(IsLayerActive(s32(i), s32(l)), 1);
|
||||
writer.WriteBits(IsLayerActive(s32(i), s32(l)), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -81,40 +81,40 @@ CWorldState::CWorldState(CAssetId id) : x0_mlvlId(id), x4_areaId(0) {
|
|||
x14_layerState = std::make_shared<CScriptLayerManager>();
|
||||
}
|
||||
|
||||
CWorldState::CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CWorldSaveGameInfo& saveWorld)
|
||||
CWorldState::CWorldState(CInputStream& reader, CAssetId mlvlId, const CWorldSaveGameInfo& saveWorld)
|
||||
: x0_mlvlId(mlvlId) {
|
||||
x4_areaId = TAreaId(reader.ReadEncoded(32));
|
||||
x10_desiredAreaAssetId = u32(reader.ReadEncoded(32));
|
||||
x4_areaId = TAreaId(reader.ReadBits(32));
|
||||
x10_desiredAreaAssetId = u32(reader.ReadBits(32));
|
||||
x8_mailbox = std::make_shared<CScriptMailbox>(reader, saveWorld);
|
||||
xc_mapWorldInfo = std::make_shared<CMapWorldInfo>(reader, saveWorld, mlvlId);
|
||||
x14_layerState = std::make_shared<CScriptLayerManager>(reader, saveWorld);
|
||||
}
|
||||
|
||||
void CWorldState::PutTo(CBitStreamWriter& writer, const CWorldSaveGameInfo& savw) const {
|
||||
writer.WriteEncoded(x4_areaId, 32);
|
||||
writer.WriteEncoded(u32(x10_desiredAreaAssetId.Value()), 32);
|
||||
void CWorldState::PutTo(COutputStream& writer, const CWorldSaveGameInfo& savw) const {
|
||||
writer.WriteBits(x4_areaId, 32);
|
||||
writer.WriteBits(u32(x10_desiredAreaAssetId.Value()), 32);
|
||||
x8_mailbox->PutTo(writer, savw);
|
||||
xc_mapWorldInfo->PutTo(writer, savw, x0_mlvlId);
|
||||
x14_layerState->PutTo(writer);
|
||||
}
|
||||
|
||||
CGameState::GameFileStateInfo CGameState::LoadGameFileState(const u8* data) {
|
||||
CBitStreamReader stream(data, 4096);
|
||||
CMemoryInStream stream(data, 4096, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
GameFileStateInfo ret;
|
||||
|
||||
for (u32 i = 0; i < 128; i++) {
|
||||
stream.ReadEncoded(8);
|
||||
stream.ReadBits(8);
|
||||
}
|
||||
ret.x14_timestamp = stream.ReadEncoded(32);
|
||||
ret.x14_timestamp = stream.ReadBits(32);
|
||||
|
||||
ret.x20_hardMode = stream.ReadEncoded(1) != 0;
|
||||
stream.ReadEncoded(1);
|
||||
const CAssetId origMLVL = u32(stream.ReadEncoded(32));
|
||||
ret.x20_hardMode = stream.ReadBits(1) != 0;
|
||||
stream.ReadBits(1);
|
||||
const CAssetId origMLVL = u32(stream.ReadBits(32));
|
||||
ret.x8_mlvlId = origMLVL;
|
||||
|
||||
BitsToDouble conv;
|
||||
conv.low = stream.ReadEncoded(32);
|
||||
conv.high = stream.ReadEncoded(32);
|
||||
conv.low = stream.ReadBits(32);
|
||||
conv.high = stream.ReadBits(32);
|
||||
ret.x0_playTime = conv.doub;
|
||||
|
||||
CPlayerState playerState(stream);
|
||||
|
@ -148,24 +148,24 @@ CGameState::CGameState() {
|
|||
}
|
||||
}
|
||||
|
||||
CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx(saveIdx) {
|
||||
CGameState::CGameState(CInputStream& stream, u32 saveIdx) : x20c_saveFileIdx(saveIdx) {
|
||||
x9c_transManager = std::make_shared<CWorldTransManager>();
|
||||
x228_24_hardMode = false;
|
||||
x228_25_initPowerupsAtFirstSpawn = true;
|
||||
|
||||
for (bool& value : x0_) {
|
||||
value = stream.ReadEncoded(8) != 0;
|
||||
value = stream.ReadBits(8) != 0;
|
||||
}
|
||||
stream.ReadEncoded(32);
|
||||
stream.ReadBits(32);
|
||||
|
||||
x228_24_hardMode = stream.ReadEncoded(1) != 0;
|
||||
x228_25_initPowerupsAtFirstSpawn = stream.ReadEncoded(1) != 0;
|
||||
x84_mlvlId = u32(stream.ReadEncoded(32));
|
||||
x228_24_hardMode = stream.ReadBits(1) != 0;
|
||||
x228_25_initPowerupsAtFirstSpawn = stream.ReadBits(1) != 0;
|
||||
x84_mlvlId = u32(stream.ReadBits(32));
|
||||
MP1::CMain::EnsureWorldPakReady(x84_mlvlId);
|
||||
|
||||
BitsToDouble conv;
|
||||
conv.low = stream.ReadEncoded(32);
|
||||
conv.high = stream.ReadEncoded(32);
|
||||
conv.low = stream.ReadBits(32);
|
||||
conv.high = stream.ReadBits(32);
|
||||
xa0_playTime = conv.doub;
|
||||
|
||||
x98_playerState = std::make_shared<CPlayerState>(stream);
|
||||
|
@ -185,7 +185,7 @@ CGameState::CGameState(CBitStreamReader& stream, u32 saveIdx) : x20c_saveFileIdx
|
|||
WriteBackupBuf();
|
||||
}
|
||||
|
||||
void CGameState::ReadPersistentOptions(CBitStreamReader& r) { xa8_systemOptions = CPersistentOptions(r); }
|
||||
void CGameState::ReadPersistentOptions(CInputStream& r) { xa8_systemOptions = r.Get<CPersistentOptions>(); }
|
||||
|
||||
void CGameState::ImportPersistentOptions(const CPersistentOptions& opts) {
|
||||
if (opts.xd0_24_fusionLinked)
|
||||
|
@ -212,24 +212,24 @@ void CGameState::ExportPersistentOptions(CPersistentOptions& opts) const {
|
|||
|
||||
void CGameState::WriteBackupBuf() {
|
||||
x218_backupBuf.resize(940);
|
||||
CBitStreamWriter w(x218_backupBuf.data(), 940);
|
||||
CMemoryStreamOut w(x218_backupBuf.data(), 940);
|
||||
PutTo(w);
|
||||
}
|
||||
|
||||
void CGameState::PutTo(CBitStreamWriter& writer) {
|
||||
void CGameState::PutTo(COutputStream& writer) {
|
||||
for (const bool value : x0_) {
|
||||
writer.WriteEncoded(u32(value), 8);
|
||||
writer.WriteBits(u32(value), 8);
|
||||
}
|
||||
|
||||
writer.WriteEncoded(CBasics::GetTime() / CBasics::TICKS_PER_SECOND, 32);
|
||||
writer.WriteEncoded(x228_24_hardMode, 1);
|
||||
writer.WriteEncoded(x228_25_initPowerupsAtFirstSpawn, 1);
|
||||
writer.WriteEncoded(u32(x84_mlvlId.Value()), 32);
|
||||
writer.WriteBits(CBasics::GetTime() / CBasics::TICKS_PER_SECOND, 32);
|
||||
writer.WriteBits(x228_24_hardMode, 1);
|
||||
writer.WriteBits(x228_25_initPowerupsAtFirstSpawn, 1);
|
||||
writer.WriteBits(u32(x84_mlvlId.Value()), 32);
|
||||
|
||||
BitsToDouble conv;
|
||||
conv.doub = xa0_playTime;
|
||||
writer.WriteEncoded(conv.low, 32);
|
||||
writer.WriteEncoded(conv.high, 32);
|
||||
writer.WriteBits(conv.low, 32);
|
||||
writer.WriteBits(conv.high, 32);
|
||||
|
||||
x98_playerState->PutTo(writer);
|
||||
x17c_gameOptions.PutTo(writer);
|
||||
|
|
|
@ -24,7 +24,7 @@ class CScriptLayerManager {
|
|||
|
||||
public:
|
||||
CScriptLayerManager() = default;
|
||||
CScriptLayerManager(CBitStreamReader& reader, const CWorldSaveGameInfo& saveWorld);
|
||||
CScriptLayerManager(CInputStream& reader, const CWorldSaveGameInfo& saveWorld);
|
||||
|
||||
bool IsLayerActive(int areaIdx, int layerIdx) const { return ((x0_areaLayers[areaIdx].m_layerBits >> layerIdx) & 1); }
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
u32 GetAreaLayerCount(int areaIdx) const { return x0_areaLayers[areaIdx].m_layerCount; }
|
||||
u32 GetAreaCount() const { return x0_areaLayers.size(); }
|
||||
|
||||
void PutTo(CBitStreamWriter& writer) const;
|
||||
void PutTo(COutputStream& writer) const;
|
||||
};
|
||||
|
||||
class CWorldState {
|
||||
|
@ -53,7 +53,7 @@ class CWorldState {
|
|||
|
||||
public:
|
||||
explicit CWorldState(CAssetId id);
|
||||
CWorldState(CBitStreamReader& reader, CAssetId mlvlId, const CWorldSaveGameInfo& saveWorld);
|
||||
CWorldState(CInputStream& reader, CAssetId mlvlId, const CWorldSaveGameInfo& saveWorld);
|
||||
CAssetId GetWorldAssetId() const { return x0_mlvlId; }
|
||||
void SetAreaId(TAreaId aid) { x4_areaId = aid; }
|
||||
TAreaId GetCurrentAreaId() const { return x4_areaId; }
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
const std::shared_ptr<CScriptMailbox>& Mailbox() const { return x8_mailbox; }
|
||||
const std::shared_ptr<CMapWorldInfo>& MapWorldInfo() const { return xc_mapWorldInfo; }
|
||||
const std::shared_ptr<CScriptLayerManager>& GetLayerState() const { return x14_layerState; }
|
||||
void PutTo(CBitStreamWriter& writer, const CWorldSaveGameInfo& savw) const;
|
||||
void PutTo(COutputStream& writer, const CWorldSaveGameInfo& savw) const;
|
||||
};
|
||||
|
||||
class CGameState {
|
||||
|
@ -86,7 +86,7 @@ class CGameState {
|
|||
|
||||
public:
|
||||
CGameState();
|
||||
CGameState(CBitStreamReader& stream, u32 saveIdx);
|
||||
CGameState(CInputStream& stream, u32 saveIdx);
|
||||
void SetCurrentWorldId(CAssetId id);
|
||||
std::shared_ptr<CPlayerState> GetPlayerState() const { return x98_playerState; }
|
||||
std::shared_ptr<CWorldTransManager> GetWorldTransitionManager() const { return x9c_transManager; }
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
CAssetId CurrentWorldAssetId() const { return x84_mlvlId; }
|
||||
void SetHardMode(bool v) { x228_24_hardMode = v; }
|
||||
bool GetHardMode() const { return x228_24_hardMode; }
|
||||
void ReadPersistentOptions(CBitStreamReader& r);
|
||||
void ReadPersistentOptions(CInputStream& r);
|
||||
void SetPersistentOptions(const CPersistentOptions& opts) { xa8_systemOptions = opts; }
|
||||
void ImportPersistentOptions(const CPersistentOptions& opts);
|
||||
void ExportPersistentOptions(CPersistentOptions& opts) const;
|
||||
|
@ -111,7 +111,7 @@ public:
|
|||
void SetFileIdx(u32 idx) { x20c_saveFileIdx = idx; }
|
||||
void SetCardSerial(u64 serial) { x210_cardSerial = serial; }
|
||||
u64 GetCardSerial() const { return x210_cardSerial; }
|
||||
void PutTo(CBitStreamWriter& writer);
|
||||
void PutTo(COutputStream& writer);
|
||||
float GetHardModeDamageMultiplier() const;
|
||||
float GetHardModeWeaponMultiplier() const;
|
||||
void InitializeMemoryWorlds();
|
||||
|
|
|
@ -0,0 +1,278 @@
|
|||
#include "CInputStream.hpp"
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
#include "Runtime/CBasics.hpp"
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace metaforce {
|
||||
static u32 min_containing_bytes(u32 v) {
|
||||
v = 32 - v;
|
||||
v = (v >> 3) - ((s32) - (v & 7) >> 31);
|
||||
return v;
|
||||
}
|
||||
|
||||
CInputStream::CInputStream(s32 len) : xc_len(len), x10_ptr(new u8[len]), x14_owned(true) {}
|
||||
CInputStream::CInputStream(const void* ptr, u32 len, bool owned)
|
||||
: x8_blockLen(len), xc_len(len), x10_ptr(reinterpret_cast<const u8*>(ptr)), x14_owned(owned) {}
|
||||
|
||||
CInputStream::~CInputStream() {
|
||||
if (x14_owned) {
|
||||
delete[] x10_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool CInputStream::InternalReadNext() {
|
||||
x8_blockLen = Read(const_cast<u8*>(x10_ptr), xc_len);
|
||||
x4_blockOffset = 0;
|
||||
return x8_blockLen != 0;
|
||||
}
|
||||
|
||||
bool CInputStream::GrabAnotherBlock() { return InternalReadNext(); }
|
||||
|
||||
void CInputStream::Get(u8* dest, u32 len) {
|
||||
x20_bitOffset = 0;
|
||||
u32 offset = 0;
|
||||
while (len != 0) {
|
||||
u32 blockLen = x8_blockLen - x4_blockOffset;
|
||||
if (len < blockLen) {
|
||||
blockLen = len;
|
||||
}
|
||||
|
||||
if (blockLen == 0) {
|
||||
if (len <= 256) {
|
||||
GrabAnotherBlock();
|
||||
} else {
|
||||
u32 readLen = Read(dest + offset, len);
|
||||
len -= readLen;
|
||||
offset += readLen;
|
||||
}
|
||||
} else {
|
||||
memcpy(dest + offset, x10_ptr + x4_blockOffset, blockLen);
|
||||
len -= blockLen;
|
||||
x4_blockOffset += blockLen;
|
||||
}
|
||||
}
|
||||
|
||||
x18_readPosition += offset;
|
||||
}
|
||||
|
||||
u32 CInputStream::ReadBytes(void* dest, u32 len) {
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (x4_blockOffset == x8_blockLen) {
|
||||
GrabAnotherBlock();
|
||||
}
|
||||
|
||||
u32 curReadLen = 0;
|
||||
u32 curLen = len;
|
||||
|
||||
do {
|
||||
while (true) {
|
||||
if (len <= curReadLen) {
|
||||
x18_readPosition += curReadLen;
|
||||
return curReadLen;
|
||||
}
|
||||
|
||||
u32 readCount = x8_blockLen - x4_blockOffset;
|
||||
if (readCount == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (curLen < readCount) {
|
||||
readCount = curLen;
|
||||
}
|
||||
|
||||
memcpy(reinterpret_cast<u8*>(dest) + curReadLen, x10_ptr + x4_blockOffset, readCount);
|
||||
curReadLen += readCount;
|
||||
curLen -= readCount;
|
||||
}
|
||||
} while (InternalReadNext());
|
||||
|
||||
return curReadLen;
|
||||
}
|
||||
|
||||
u32 CInputStream::ReadBits(u32 bitCount) {
|
||||
u32 ret = x20_bitOffset;
|
||||
if (ret < bitCount) {
|
||||
const u32 shiftAmt = bitCount - x20_bitOffset;
|
||||
const u32 mask = ret == 32 ? -1 : (1 << x20_bitOffset) - 1;
|
||||
|
||||
u32 uVar2 = x1c_bitWord;
|
||||
x20_bitOffset = 0;
|
||||
u32 len = min_containing_bytes(shiftAmt);
|
||||
Get(reinterpret_cast<u8*>(&x1c_bitWord), len);
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
x1c_bitWord = CBasics::SwapBytes(x1c_bitWord);
|
||||
#endif
|
||||
|
||||
const u32 retMask = shiftAmt == 32 ? -1 : (1 << shiftAmt) - 1;
|
||||
const u32 tmpOffset = x20_bitOffset;
|
||||
x20_bitOffset = len * 8;
|
||||
ret = ((mask & uVar2) >> (32 - ret) << shiftAmt) | (retMask & (x1c_bitWord >> (32 - shiftAmt))) << tmpOffset;
|
||||
x20_bitOffset -= shiftAmt;
|
||||
x1c_bitWord <<= shiftAmt;
|
||||
} else {
|
||||
x20_bitOffset -= bitCount;
|
||||
ret = bitCount == 32 ? -1 : (1 << bitCount) - 1;
|
||||
ret &= x1c_bitWord >> (32 - bitCount);
|
||||
x1c_bitWord <<= bitCount;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
char CInputStream::ReadChar() {
|
||||
u8 tmp = 0;
|
||||
Get(&tmp, sizeof(tmp));
|
||||
return static_cast<char>(tmp);
|
||||
}
|
||||
|
||||
bool CInputStream::ReadBool() { return Get<bool>(); }
|
||||
|
||||
s16 CInputStream::ReadInt16() {
|
||||
s16 tmp = 0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap2Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
u16 CInputStream::ReadUint16() {
|
||||
u16 tmp = 0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap2Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
s32 CInputStream::ReadInt32() {
|
||||
s32 tmp = 0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap4Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
u32 CInputStream::ReadUint32() {
|
||||
u32 tmp = 0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap4Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
s64 CInputStream::ReadInt64() {
|
||||
s64 tmp = 0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap8Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
u64 CInputStream::ReadUint64() {
|
||||
u64 tmp = 0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap8Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
float CInputStream::ReadFloat() {
|
||||
float tmp = 0.f;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap4Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
float CInputStream::ReadReal32() { return Get<float>(); }
|
||||
|
||||
double CInputStream::ReadDouble() {
|
||||
double tmp = 0.0;
|
||||
Get(reinterpret_cast<u8*>(&tmp), sizeof(tmp));
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
CBasics::Swap8Bytes(reinterpret_cast<u8*>(&tmp));
|
||||
#endif
|
||||
return tmp;
|
||||
}
|
||||
|
||||
double CInputStream::ReadReal64() { return Get<double>(); }
|
||||
|
||||
template <>
|
||||
bool cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadChar() != 0;
|
||||
}
|
||||
|
||||
template <>
|
||||
s8 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadChar();
|
||||
}
|
||||
template <>
|
||||
u8 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadChar();
|
||||
}
|
||||
|
||||
template <>
|
||||
s16 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadInt16();
|
||||
}
|
||||
|
||||
template <>
|
||||
s32 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadInt32();
|
||||
}
|
||||
|
||||
template <>
|
||||
u32 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadUint32();
|
||||
}
|
||||
|
||||
template <>
|
||||
s64 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadInt64();
|
||||
}
|
||||
|
||||
template <>
|
||||
u64 cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadUint64();
|
||||
}
|
||||
|
||||
template <>
|
||||
float cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadFloat();
|
||||
}
|
||||
|
||||
template <>
|
||||
double cinput_stream_helper(CInputStream& in) {
|
||||
return in.ReadDouble();
|
||||
}
|
||||
|
||||
template <>
|
||||
std::string cinput_stream_helper(CInputStream& in) {
|
||||
std::string ret;
|
||||
auto chr = in.ReadChar();
|
||||
while (chr != '\0') {
|
||||
ret += chr;
|
||||
chr = in.ReadChar();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u32 CInputStream::GetBitCount(u32 val) {
|
||||
int bits = 0;
|
||||
for (; val != 0; val >>= 1) {
|
||||
bits += 1;
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,83 @@
|
|||
#pragma once
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace metaforce {
|
||||
class CInputStream {
|
||||
u32 x4_blockOffset = 0;
|
||||
u32 x8_blockLen = 0;
|
||||
u32 xc_len = 0;
|
||||
const u8* x10_ptr = nullptr;
|
||||
bool x14_owned = false;
|
||||
u32 x18_readPosition = 0;
|
||||
u32 x1c_bitWord = 0;
|
||||
u32 x20_bitOffset = 0;
|
||||
|
||||
bool InternalReadNext();
|
||||
bool GrabAnotherBlock();
|
||||
|
||||
public:
|
||||
explicit CInputStream(s32 len);
|
||||
CInputStream(const void* ptr, u32 len, bool owned);
|
||||
virtual ~CInputStream();
|
||||
|
||||
virtual u32 Read(void* dest, u32 len) = 0;
|
||||
|
||||
u32 GetReadPosition() const { return x18_readPosition; }
|
||||
u32 ReadBits(u32 bitCount);
|
||||
u32 ReadBytes(void* dest, u32 len);
|
||||
s8 ReadInt8() { return Get<s8>(); }
|
||||
u8 ReadUint8() { return Get<u8>(); }
|
||||
char ReadChar();
|
||||
bool ReadBool();
|
||||
s16 ReadInt16();
|
||||
s16 ReadShort() { return Get<s16>(); }
|
||||
u16 ReadUint16();
|
||||
s32 ReadInt32();
|
||||
s32 ReadLong() { return Get<s32>(); }
|
||||
u32 ReadUint32();
|
||||
s64 ReadInt64();
|
||||
s64 ReadLongLong() { return Get<s64>(); }
|
||||
u64 ReadUint64();
|
||||
|
||||
float ReadReal32();
|
||||
float ReadFloat();
|
||||
double ReadReal64();
|
||||
double ReadDouble();
|
||||
|
||||
void Get(u8* dest, u32 len);
|
||||
template <typename T>
|
||||
T Get() {
|
||||
return cinput_stream_helper<T>(*this);
|
||||
}
|
||||
|
||||
static u32 GetBitCount(u32 val);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T cinput_stream_helper(CInputStream& in) {
|
||||
return T(in);
|
||||
}
|
||||
template <>
|
||||
bool cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
s8 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
u8 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
s16 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
s32 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
u32 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
s64 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
u64 cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
float cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
double cinput_stream_helper(CInputStream& in);
|
||||
template <>
|
||||
std::string cinput_stream_helper(CInputStream& in);
|
||||
} // namespace metaforce
|
|
@ -73,6 +73,11 @@ set(RUNTIME_SOURCES_B
|
|||
ITweak.hpp
|
||||
IMain.hpp
|
||||
CStopwatch.hpp
|
||||
CMemoryStreamOut.hpp CMemoryStreamOut.cpp
|
||||
CInputStream.hpp CInputStream.cpp
|
||||
COutputStream.hpp COutputStream.cpp
|
||||
CMemoryInStream.hpp
|
||||
CZipInputStream.hpp CZipInputStream.cpp
|
||||
CGameAllocator.hpp CGameAllocator.cpp
|
||||
CMemoryCardSys.hpp CMemoryCardSys.cpp
|
||||
CScannableObjectInfo.hpp CScannableObjectInfo.cpp
|
||||
|
@ -109,7 +114,7 @@ set(RUNTIME_SOURCES_B
|
|||
CToken.hpp CToken.cpp
|
||||
CFactoryMgr.hpp CFactoryMgr.cpp
|
||||
CPakFile.hpp CPakFile.cpp
|
||||
CStringExtras.hpp
|
||||
CStringExtras.hpp CStringExtras.cpp
|
||||
IOStreams.hpp IOStreams.cpp
|
||||
CMainFlowBase.hpp CMainFlowBase.cpp
|
||||
CMFGameBase.hpp
|
||||
|
@ -125,6 +130,7 @@ set(RUNTIME_SOURCES_B
|
|||
|
||||
function(add_runtime_common_library name)
|
||||
add_library(${name} ${ARGN})
|
||||
target_compile_definitions(${name} PUBLIC "-DMETAFORCE_TARGET_BYTE_ORDER=__BYTE_ORDER__")
|
||||
if (COMMAND add_sanitizers)
|
||||
add_sanitizers(${name})
|
||||
endif ()
|
||||
|
@ -209,6 +215,7 @@ add_executable(metaforce CMain.cpp ${PLAT_SRCS} ImGuiConsole.hpp ImGuiConsole.cp
|
|||
# target_atdna(metaforce atdna_ImGuiPlayerLoadouts.cpp ImGuiPlayerLoadouts.hpp)
|
||||
# RUNTIME_LIBRARIES repeated here for link ordering
|
||||
target_link_libraries(metaforce PUBLIC RuntimeCommon RuntimeCommonB ${RUNTIME_LIBRARIES} ${PLAT_LIBS})
|
||||
target_compile_definitions(metaforce PUBLIC "-DMETAFORCE_TARGET_BYTE_ORDER=__BYTE_ORDER__")
|
||||
|
||||
if (COMMAND add_sanitizers)
|
||||
add_sanitizers(metaforce)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "CMayaSpline.hpp"
|
||||
#include "Runtime/CMayaSpline.hpp"
|
||||
|
||||
namespace rstl {} // namespace rstl
|
||||
#include "Runtime/CInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
void ValidateTangent(zeus::CVector2f& tangent) {
|
||||
|
@ -21,19 +21,19 @@ void ValidateTangent(zeus::CVector2f& tangent) {
|
|||
}
|
||||
|
||||
CMayaSplineKnot::CMayaSplineKnot(CInputStream& in) {
|
||||
x0_time = in.readFloatBig();
|
||||
x4_amplitude = in.readFloatBig();
|
||||
x8_ = in.readByte();
|
||||
x9_ = in.readByte();
|
||||
x0_time = in.ReadFloat();
|
||||
x4_amplitude = in.ReadFloat();
|
||||
x8_ = in.ReadInt8();
|
||||
x9_ = in.ReadInt8();
|
||||
if (x8_ == 5) {
|
||||
float x = in.readFloatBig();
|
||||
float y = in.readFloatBig();
|
||||
float x = in.ReadFloat();
|
||||
float y = in.ReadFloat();
|
||||
xc_cachedTangentA = {x, y};
|
||||
}
|
||||
|
||||
if (x9_ == 5) {
|
||||
float x = in.readFloatBig();
|
||||
float y = in.readFloatBig();
|
||||
float x = in.ReadFloat();
|
||||
float y = in.ReadFloat();
|
||||
x14_cachedTangentB = {x, y};
|
||||
}
|
||||
}
|
||||
|
@ -166,17 +166,16 @@ void CMayaSplineKnot::CalculateTangents(CMayaSplineKnot* prev, CMayaSplineKnot*
|
|||
ValidateTangent(x14_cachedTangentB);
|
||||
}
|
||||
|
||||
CMayaSpline::CMayaSpline(CInputStream& in, s32 count) {
|
||||
x0_preInfinity = in.readByte();
|
||||
x4_postInfinity = in.readByte();
|
||||
u32 knotCount = in.readUint32Big();
|
||||
CMayaSpline::CMayaSpline(CInputStream& in, s32 count) : x0_preInfinity(in.ReadInt8()), x4_postInfinity(in.ReadInt8()) {
|
||||
|
||||
u32 knotCount = in.ReadLong();
|
||||
x8_knots.reserve(knotCount);
|
||||
for (size_t i = 0; i < knotCount; ++i) {
|
||||
x8_knots.emplace_back(in);
|
||||
}
|
||||
x18_clampMode = in.readByte();
|
||||
x1c_minAmplitudeTime = in.readFloatBig();
|
||||
x20_maxAmplitudeTime = in.readFloatBig();
|
||||
x18_clampMode = in.ReadInt8();
|
||||
x1c_minAmplitudeTime = in.ReadFloat();
|
||||
x20_maxAmplitudeTime = in.ReadFloat();
|
||||
}
|
||||
|
||||
float CMayaSpline::GetMinTime() const { return x8_knots.empty() ? 0.f : x8_knots[0].GetTime(); }
|
||||
|
|
|
@ -215,12 +215,12 @@ void CMemoryCardSys::CCardFileInfo::BuildCardBuffer() {
|
|||
u32 bannerSz = CalculateBannerDataSize();
|
||||
x104_cardBuffer.resize((bannerSz + xf4_saveBuffer.size() + 8191) & ~8191);
|
||||
|
||||
CMemoryOutStream w(x104_cardBuffer.data(), x104_cardBuffer.size());
|
||||
w.writeUint32Big(0);
|
||||
CMemoryStreamOut w(x104_cardBuffer.data(), x104_cardBuffer.size(), CMemoryStreamOut::EOwnerShip::NotOwned);
|
||||
w.WriteLong(0);
|
||||
char comment[64];
|
||||
std::memset(comment, 0, std::size(comment));
|
||||
std::strncpy(comment, x28_comment.data(), std::size(comment) - 1);
|
||||
w.writeBytes(comment, 64);
|
||||
w.Write(reinterpret_cast<const u8*>(comment), 64);
|
||||
WriteBannerData(w);
|
||||
WriteIconData(w);
|
||||
memmove(x104_cardBuffer.data() + bannerSz, xf4_saveBuffer.data(), xf4_saveBuffer.size());
|
||||
|
@ -230,7 +230,7 @@ void CMemoryCardSys::CCardFileInfo::BuildCardBuffer() {
|
|||
xf4_saveBuffer.clear();
|
||||
}
|
||||
|
||||
void CMemoryCardSys::CCardFileInfo::WriteBannerData(CMemoryOutStream& out) const {
|
||||
void CMemoryCardSys::CCardFileInfo::WriteBannerData(COutputStream& out) const {
|
||||
if (x3c_bannerTex.IsValid()) {
|
||||
const TLockedToken<CTexture>& tex = *x40_bannerTok;
|
||||
u32 bufSz;
|
||||
|
@ -239,16 +239,16 @@ void CMemoryCardSys::CCardFileInfo::WriteBannerData(CMemoryOutStream& out) const
|
|||
std::unique_ptr<u8[]> texels = tex->BuildMemoryCardTex(bufSz, fmt, palette);
|
||||
|
||||
if (fmt == ETexelFormat::RGB5A3)
|
||||
out.writeBytes(texels.get(), 6144);
|
||||
out.Write(texels.get(), 6144);
|
||||
else
|
||||
out.writeBytes(texels.get(), 3072);
|
||||
out.Write(texels.get(), 3072);
|
||||
|
||||
if (fmt == ETexelFormat::C8)
|
||||
out.writeBytes(palette.get(), 512);
|
||||
out.Write(palette.get(), 512);
|
||||
}
|
||||
}
|
||||
|
||||
void CMemoryCardSys::CCardFileInfo::WriteIconData(CMemoryOutStream& out) const {
|
||||
void CMemoryCardSys::CCardFileInfo::WriteIconData(COutputStream& out) const {
|
||||
std::unique_ptr<u8[]> palette;
|
||||
for (const Icon& icon : x50_iconToks) {
|
||||
u32 bufSz;
|
||||
|
@ -256,12 +256,12 @@ void CMemoryCardSys::CCardFileInfo::WriteIconData(CMemoryOutStream& out) const {
|
|||
std::unique_ptr<u8[]> texels = icon.x8_tex->BuildMemoryCardTex(bufSz, fmt, palette);
|
||||
|
||||
if (fmt == ETexelFormat::RGB5A3)
|
||||
out.writeBytes(texels.get(), 2048);
|
||||
out.Write(texels.get(), 2048);
|
||||
else
|
||||
out.writeBytes(texels.get(), 1024);
|
||||
out.Write(texels.get(), 1024);
|
||||
}
|
||||
if (palette)
|
||||
out.writeBytes(palette.get(), 512);
|
||||
out.Write(palette.get(), 512);
|
||||
}
|
||||
|
||||
ECardResult CMemoryCardSys::CCardFileInfo::PumpCardTransfer() {
|
||||
|
|
|
@ -6,11 +6,12 @@
|
|||
#include <vector>
|
||||
|
||||
#include "Runtime/CGameHintInfo.hpp"
|
||||
#include "Runtime/CWorldSaveGameInfo.hpp"
|
||||
#include "Runtime/CMemoryStreamOut.hpp"
|
||||
#include "Runtime/CToken.hpp"
|
||||
#include "Runtime/rstl.hpp"
|
||||
#include "Runtime/CWorldSaveGameInfo.hpp"
|
||||
#include "Runtime/GuiSys/CStringTable.hpp"
|
||||
#include "Runtime/World/CWorld.hpp"
|
||||
#include "Runtime/rstl.hpp"
|
||||
|
||||
#include <kabufuda/Card.hpp>
|
||||
|
||||
|
@ -137,13 +138,13 @@ public:
|
|||
void LockBannerToken(CAssetId bannerTxtr, CSimplePool& sp);
|
||||
void LockIconToken(CAssetId iconTxtr, kabufuda::EAnimationSpeed speed, CSimplePool& sp);
|
||||
|
||||
kabufuda::ECardSlot GetCardPort() const { return m_handle.slot; }
|
||||
int GetFileNo() const { return m_handle.getFileNo(); }
|
||||
u32 CalculateBannerDataSize() const;
|
||||
u32 CalculateTotalDataSize() const;
|
||||
[[nodiscard]] kabufuda::ECardSlot GetCardPort() const { return m_handle.slot; }
|
||||
[[nodiscard]] int GetFileNo() const { return m_handle.getFileNo(); }
|
||||
[[nodiscard]] u32 CalculateBannerDataSize() const;
|
||||
[[nodiscard]] u32 CalculateTotalDataSize() const;
|
||||
void BuildCardBuffer();
|
||||
void WriteBannerData(CMemoryOutStream& out) const;
|
||||
void WriteIconData(CMemoryOutStream& out) const;
|
||||
void WriteBannerData(COutputStream& out) const;
|
||||
void WriteIconData(COutputStream& out) const;
|
||||
void SetComment(const std::string& c) { x28_comment = c; }
|
||||
ECardResult PumpCardTransfer();
|
||||
ECardResult GetStatus(CardStat& stat) const;
|
||||
|
@ -151,9 +152,9 @@ public:
|
|||
ECardResult WriteFile();
|
||||
ECardResult CloseFile();
|
||||
|
||||
CMemoryOutStream BeginMemoryOut(u32 sz) {
|
||||
CMemoryStreamOut BeginMemoryOut(u32 sz) {
|
||||
xf4_saveBuffer.resize(sz);
|
||||
return CMemoryOutStream(xf4_saveBuffer.data(), sz);
|
||||
return CMemoryStreamOut(xf4_saveBuffer.data(), sz, CMemoryStreamOut::EOwnerShip::NotOwned, sz);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
#include "../../metaforce/Runtime/CInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
class CMemoryInStream final : public CInputStream {
|
||||
public:
|
||||
enum class EOwnerShip {
|
||||
NotOwned,
|
||||
Owned,
|
||||
};
|
||||
|
||||
public:
|
||||
CMemoryInStream(const void* ptr, u32 len) : CInputStream(ptr, len, false) {}
|
||||
CMemoryInStream(const void* ptr, u32 len, EOwnerShip ownership)
|
||||
: CInputStream(ptr, len, ownership == EOwnerShip::Owned) {}
|
||||
u32 Read(void* dest, u32 len) override { return 0; }
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,22 @@
|
|||
#include "CMemoryStreamOut.hpp"
|
||||
#include <cstring>
|
||||
|
||||
namespace metaforce {
|
||||
CMemoryStreamOut::~CMemoryStreamOut() {
|
||||
Flush();
|
||||
|
||||
if (x88_owned) {
|
||||
delete[] x7c_ptr;
|
||||
}
|
||||
}
|
||||
void CMemoryStreamOut::Write(const u8* ptr, u32 len) {
|
||||
const auto offset = (x80_len - x84_position);
|
||||
if (offset < len) {
|
||||
len = offset;
|
||||
}
|
||||
|
||||
if (len != 0) {
|
||||
memcpy(x7c_ptr + x84_position, ptr, len);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#include "Runtime/COutputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
class CMemoryStreamOut final : public COutputStream {
|
||||
public:
|
||||
enum class EOwnerShip {
|
||||
NotOwned,
|
||||
Owned,
|
||||
};
|
||||
private:
|
||||
u8* x7c_ptr = nullptr;
|
||||
u32 x80_len = 0;
|
||||
u32 x84_position = 0;
|
||||
bool x88_owned;
|
||||
|
||||
public:
|
||||
CMemoryStreamOut(u8* workBuf, u32 len, EOwnerShip ownership = EOwnerShip::NotOwned, s32 unk = 4096)
|
||||
: COutputStream(workBuf, unk), x7c_ptr(workBuf), x80_len(len), x88_owned(ownership == EOwnerShip::Owned) {}
|
||||
|
||||
~CMemoryStreamOut() override;
|
||||
|
||||
void Write(const u8* ptr, u32 len) override;
|
||||
};
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,209 @@
|
|||
#include "COutputStream.hpp"
|
||||
|
||||
#include "Runtime/CBasics.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace metaforce {
|
||||
static u32 min_containing_bytes(u32 v) {
|
||||
v = 32 - v;
|
||||
v = (v >> 3) - ((s32) - (v & 7) >> 31);
|
||||
return v;
|
||||
}
|
||||
|
||||
COutputStream::COutputStream(u8* ptr, s32 len) : x8_bufLen(len) {
|
||||
xc_ptr = len <= 64 ? reinterpret_cast<u8*>(((reinterpret_cast<uintptr_t>(x1c_scratch) + 7) & ~7) + 6) : new u8[len];
|
||||
}
|
||||
|
||||
COutputStream::~COutputStream() {
|
||||
if (x8_bufLen < 64) {
|
||||
delete[] xc_ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void COutputStream::DoFlush() {
|
||||
if (x4_position != 0) {
|
||||
Write(xc_ptr, x4_position);
|
||||
x4_position = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void COutputStream::DoPut(const u8* ptr, u32 len) {
|
||||
if (len == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
x10_numWrites += len;
|
||||
u32 offset = x4_position;
|
||||
u32 curLen = len;
|
||||
if (x8_bufLen < len + offset) {
|
||||
while (curLen != 0) {
|
||||
offset = x4_position;
|
||||
u32 count = x8_bufLen - offset;
|
||||
if (curLen < count) {
|
||||
count = curLen;
|
||||
}
|
||||
if (count == 0) {
|
||||
DoFlush();
|
||||
} else {
|
||||
memcpy(xc_ptr + offset, ptr + (len - curLen), count);
|
||||
curLen -= count;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memcpy(xc_ptr + offset, ptr, len);
|
||||
x4_position += len;
|
||||
}
|
||||
}
|
||||
|
||||
void COutputStream::FlushShiftRegister() {
|
||||
if (x18_shiftRegisterOffset < 32) {
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
x14_shiftRegister = CBasics::SwapBytes(x14_shiftRegister);
|
||||
#endif
|
||||
DoPut(reinterpret_cast<const u8*>(&x14_shiftRegister), min_containing_bytes(x18_shiftRegisterOffset));
|
||||
x14_shiftRegister = 0;
|
||||
x18_shiftRegisterOffset = 32;
|
||||
}
|
||||
}
|
||||
|
||||
void COutputStream::Flush() {
|
||||
FlushShiftRegister();
|
||||
DoFlush();
|
||||
}
|
||||
|
||||
void COutputStream::Put(const u8* ptr, u32 len) {
|
||||
FlushShiftRegister();
|
||||
DoPut(ptr, len);
|
||||
}
|
||||
|
||||
void COutputStream::WriteBits(u32 val, u32 bitCount) {
|
||||
const u32 bitOffset = x18_shiftRegisterOffset;
|
||||
if (x18_shiftRegisterOffset < bitCount) {
|
||||
/* OR remaining bits to cached value */
|
||||
const u32 shiftAmt = (bitCount - x18_shiftRegisterOffset);
|
||||
const u32 mask = bitOffset == 32 ? -1 : (1 << bitOffset) - 1;
|
||||
|
||||
/* Write out 32-bits */
|
||||
x14_shiftRegister |= (val >> shiftAmt) & mask;
|
||||
x18_shiftRegisterOffset = 0;
|
||||
FlushShiftRegister();
|
||||
|
||||
/* Cache remaining bits */
|
||||
x14_shiftRegister = (val & (shiftAmt == 32 ? -1 : (1 << shiftAmt) - 1)) << (32 - shiftAmt);
|
||||
x18_shiftRegisterOffset -= shiftAmt;
|
||||
} else {
|
||||
/* OR bits to cached value */
|
||||
const u32 mask = bitOffset == 0x20 ? -1 : (1 << bitOffset) - 1;
|
||||
x14_shiftRegister |= (val & mask) << (bitOffset - bitCount);
|
||||
/* New bit offset */
|
||||
x18_shiftRegisterOffset -= bitCount;
|
||||
}
|
||||
}
|
||||
|
||||
void COutputStream::WriteChar(u8 c) {
|
||||
FlushShiftRegister();
|
||||
if (x8_bufLen <= x4_position) {
|
||||
DoFlush();
|
||||
}
|
||||
++x10_numWrites;
|
||||
*reinterpret_cast<u8*>(xc_ptr + x4_position) = c;
|
||||
++x4_position;
|
||||
}
|
||||
void COutputStream::WriteShort(u16 s) {
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
s = CBasics::SwapBytes(s);
|
||||
#endif
|
||||
Put(reinterpret_cast<const u8*>(&s), sizeof(s));
|
||||
}
|
||||
void COutputStream::WriteLong(u32 l) {
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
l = CBasics::SwapBytes(l);
|
||||
#endif
|
||||
Put(reinterpret_cast<const u8*>(&l), sizeof(l));
|
||||
}
|
||||
void COutputStream::WriteLongLong(u64 ll) {
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
ll = CBasics::SwapBytes(ll);
|
||||
#endif
|
||||
Put(reinterpret_cast<const u8*>(&ll), sizeof(ll));
|
||||
}
|
||||
void COutputStream::WriteFloat(float f) {
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
f = CBasics::SwapBytes(f);
|
||||
#endif
|
||||
Put(reinterpret_cast<const u8*>(&f), sizeof(f));
|
||||
}
|
||||
|
||||
void COutputStream::WriteDouble(double d) {
|
||||
#if METAFORCE_TARGET_BYTE_ORDER == __ORDER_LITTLE_ENDIAN__
|
||||
d = CBasics::SwapBytes(d);
|
||||
#endif
|
||||
Put(reinterpret_cast<const u8*>(&d), sizeof(d));
|
||||
}
|
||||
|
||||
/* Default Stream Helpers */
|
||||
template <>
|
||||
void coutput_stream_helper(const bool& t, COutputStream& out) {
|
||||
out.WriteChar(static_cast<char>(t));
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const char& t, COutputStream& out) {
|
||||
out.WriteChar(static_cast<char>(t));
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const s8& t, COutputStream& out) {
|
||||
out.WriteChar(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const u8& t, COutputStream& out) {
|
||||
out.WriteChar(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const s16& t, COutputStream& out) {
|
||||
out.WriteShort(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const u16& t, COutputStream& out) {
|
||||
out.WriteShort(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const s32& t, COutputStream& out) {
|
||||
out.WriteLong(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const u32& t, COutputStream& out) {
|
||||
out.WriteLong(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const s64& t, COutputStream& out) {
|
||||
out.WriteLongLong(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const u64& t, COutputStream& out) {
|
||||
out.WriteLongLong(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const float& t, COutputStream& out) {
|
||||
out.WriteFloat(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const double& t, COutputStream& out) {
|
||||
out.WriteDouble(t);
|
||||
}
|
||||
template <>
|
||||
void coutput_stream_helper(const std::string& t, COutputStream& out) {
|
||||
for (size_t i = 0; i < t.size() + 1; ++i) {
|
||||
out.FlushShiftRegister();
|
||||
out.Put(t[i]);
|
||||
}
|
||||
}
|
||||
|
||||
u32 COutputStream::GetBitCount(u32 val) {
|
||||
int bits = 0;
|
||||
for (; val != 0; val >>= 1) {
|
||||
bits += 1;
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,88 @@
|
|||
#pragma once
|
||||
#include "Runtime/GCNTypes.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
||||
namespace metaforce {
|
||||
class COutputStream {
|
||||
friend class coutput_stream_helper;
|
||||
u32 x4_position = 0;
|
||||
u32 x8_bufLen = 0;
|
||||
u8* xc_ptr = nullptr;
|
||||
u32 x10_numWrites = 0;
|
||||
u32 x14_shiftRegister = 0;
|
||||
u32 x18_shiftRegisterOffset = 32;
|
||||
u8 x1c_scratch[96]{};
|
||||
|
||||
protected:
|
||||
|
||||
void DoFlush();
|
||||
void DoPut(const u8* ptr, u32 len);
|
||||
public:
|
||||
COutputStream(u8* ptr, s32 unk);
|
||||
virtual ~COutputStream();
|
||||
virtual void Write(const u8* ptr, u32 len) = 0;
|
||||
|
||||
void WriteBits(u32 val, u32 bitCount);
|
||||
void WriteChar(u8 c);
|
||||
void WriteShort(u16 s);
|
||||
void WriteLong(u32 l);
|
||||
void WriteLongLong(u64 ll);
|
||||
void WriteFloat(float f);
|
||||
void WriteDouble(double d);
|
||||
|
||||
void WriteInt8(s8 c) { Put(c); }
|
||||
void WriteUint8(u8 c) { Put(c); }
|
||||
void WriteInt16(s16 s) { Put(s); }
|
||||
void WriteUint16(u16 s) { Put(s); }
|
||||
void WriteInt32(s32 l) { Put(l); }
|
||||
void WriteUint32(u32 l) { Put(l); }
|
||||
void WriteInt64(u64 ll) { Put(ll); }
|
||||
void WriteUint64(u64 ll) { Put(ll); }
|
||||
void WriteReal32(float f) { Put(f); }
|
||||
void WriteReal64(double d) { Put(d); }
|
||||
|
||||
void FlushShiftRegister();
|
||||
void Flush();
|
||||
void Put(const u8* ptr, u32 len);
|
||||
template <typename T>
|
||||
void Put(const T& t) {
|
||||
coutput_stream_helper(t, *this);
|
||||
}
|
||||
|
||||
static u32 GetBitCount(u32 val);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
void coutput_stream_helper(const T& t, COutputStream& out) {
|
||||
t.PutTo(out);
|
||||
}
|
||||
|
||||
template <>
|
||||
void coutput_stream_helper(const bool& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const char& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const s8& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const u8& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const s16& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const u16& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const s32& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const u32& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const s64& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const u64& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const float& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const double& t, COutputStream& out);
|
||||
template <>
|
||||
void coutput_stream_helper(const std::string& t, COutputStream& out);
|
||||
}
|
|
@ -26,19 +26,19 @@ const SObjectTag* CPakFile::GetResIdByName(std::string_view name) const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void CPakFile::LoadResourceTable(athena::io::MemoryReader& r) {
|
||||
void CPakFile::LoadResourceTable(CInputStream& r) {
|
||||
x74_resList.reserve(
|
||||
std::max(size_t(64), size_t(ROUND_UP_32(x4c_resTableCount * sizeof(SResInfo)) + sizeof(SResInfo) - 1)) /
|
||||
sizeof(SResInfo));
|
||||
if (x28_24_buildDepList)
|
||||
x64_depList.reserve(x4c_resTableCount);
|
||||
for (u32 i = 0; i < x4c_resTableCount; ++i) {
|
||||
u32 flags = r.readUint32Big();
|
||||
u32 flags = r.ReadLong();
|
||||
FourCC fcc;
|
||||
r.readBytesToBuf(&fcc, 4);
|
||||
CAssetId id = r.readUint32Big();
|
||||
u32 size = r.readUint32Big();
|
||||
u32 offset = r.readUint32Big();
|
||||
r.ReadBytes(reinterpret_cast<u8*>(&fcc), 4);
|
||||
CAssetId id = r.ReadLong();
|
||||
u32 size = r.ReadLong();
|
||||
u32 offset = r.ReadLong();
|
||||
if (fcc == FOURCC('MLVL'))
|
||||
m_mlvlId = id;
|
||||
x74_resList.emplace_back(id, fcc, offset, size, flags);
|
||||
|
@ -50,7 +50,8 @@ void CPakFile::LoadResourceTable(athena::io::MemoryReader& r) {
|
|||
|
||||
void CPakFile::DataLoad() {
|
||||
x30_dvdReq.reset();
|
||||
athena::io::MemoryReader r(x38_headerData.data() + x48_resTableOffset, x38_headerData.size() - x48_resTableOffset);
|
||||
CMemoryInStream r(x38_headerData.data() + x48_resTableOffset, x38_headerData.size() - x48_resTableOffset,
|
||||
CMemoryInStream::EOwnerShip::NotOwned);
|
||||
LoadResourceTable(r);
|
||||
x2c_asyncLoadPhase = EAsyncPhase::Loaded;
|
||||
if (x28_26_worldPak) {
|
||||
|
@ -60,9 +61,9 @@ void CPakFile::DataLoad() {
|
|||
}
|
||||
|
||||
void CPakFile::InitialHeaderLoad() {
|
||||
athena::io::MemoryReader r(x38_headerData.data(), x38_headerData.size());
|
||||
CMemoryInStream r(x38_headerData.data(), x38_headerData.size(), CMemoryInStream::EOwnerShip::NotOwned);
|
||||
x30_dvdReq.reset();
|
||||
u32 version = r.readUint32Big();
|
||||
u32 version = r.ReadLong();
|
||||
if (version != 0x00030005) {
|
||||
Log.report(logvisor::Fatal,
|
||||
FMT_STRING("{}: Incompatible pak file version -- Current version is {:08X}, you're using {:08X}"),
|
||||
|
@ -70,18 +71,17 @@ void CPakFile::InitialHeaderLoad() {
|
|||
return;
|
||||
}
|
||||
|
||||
r.readUint32Big();
|
||||
u32 nameCount = r.readUint32Big();
|
||||
r.ReadLong();
|
||||
u32 nameCount = r.ReadLong();
|
||||
x54_nameList.reserve(nameCount);
|
||||
for (u32 i = 0; i < nameCount; ++i) {
|
||||
SObjectTag tag(r);
|
||||
u32 nameLen = r.readUint32Big();
|
||||
auto name = r.readString(nameLen);
|
||||
auto name = CStringExtras::ReadString(r);
|
||||
x54_nameList.emplace_back(name, tag);
|
||||
}
|
||||
|
||||
x4c_resTableCount = r.readUint32Big();
|
||||
x48_resTableOffset = u32(r.position());
|
||||
x4c_resTableCount = r.ReadLong();
|
||||
x48_resTableOffset = u32(r.GetReadPosition());
|
||||
x2c_asyncLoadPhase = EAsyncPhase::DataLoad;
|
||||
u32 newSize = ROUND_UP_32(x4c_resTableCount * 20 + x48_resTableOffset);
|
||||
u32 origSize = u32(x38_headerData.size());
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
std::vector<SResInfo> x74_resList;
|
||||
mutable s32 x84_currentSeek = -1;
|
||||
CAssetId m_mlvlId;
|
||||
void LoadResourceTable(athena::io::MemoryReader& r);
|
||||
void LoadResourceTable(CInputStream& r);
|
||||
void DataLoad();
|
||||
void InitialHeaderLoad();
|
||||
void Warmup();
|
||||
|
|
|
@ -76,63 +76,63 @@ constexpr std::array<float, 5> ComboAmmoPeriods{
|
|||
|
||||
CPlayerState::CPlayerState() { x24_powerups.resize(41); }
|
||||
|
||||
CPlayerState::CPlayerState(CBitStreamReader& stream) {
|
||||
x4_enabledItems = u32(stream.ReadEncoded(32));
|
||||
CPlayerState::CPlayerState(CInputStream& stream) {
|
||||
x4_enabledItems = u32(stream.ReadBits(32));
|
||||
|
||||
const u32 integralHP = u32(stream.ReadEncoded(32));
|
||||
const u32 integralHP = u32(stream.ReadBits(32));
|
||||
float realHP;
|
||||
std::memcpy(&realHP, &integralHP, sizeof(float));
|
||||
|
||||
xc_health.SetHP(realHP);
|
||||
x8_currentBeam = EBeamId(stream.ReadEncoded(CBitStreamReader::GetBitCount(5)));
|
||||
x20_currentSuit = EPlayerSuit(stream.ReadEncoded(CBitStreamReader::GetBitCount(4)));
|
||||
x8_currentBeam = EBeamId(stream.ReadBits(CInputStream::GetBitCount(5)));
|
||||
x20_currentSuit = EPlayerSuit(stream.ReadBits(CInputStream::GetBitCount(4)));
|
||||
x24_powerups.resize(41);
|
||||
for (size_t i = 0; i < x24_powerups.size(); ++i) {
|
||||
if (PowerUpMaxValues[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const u32 a = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
|
||||
const u32 b = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i])));
|
||||
const u32 a = u32(stream.ReadBits(CInputStream::GetBitCount(PowerUpMaxValues[i])));
|
||||
const u32 b = u32(stream.ReadBits(CInputStream::GetBitCount(PowerUpMaxValues[i])));
|
||||
x24_powerups[i] = CPowerUp(a, b);
|
||||
}
|
||||
|
||||
const auto& scanStates = g_MemoryCardSys->GetScanStates();
|
||||
x170_scanTimes.reserve(scanStates.size());
|
||||
for (const auto& state : scanStates) {
|
||||
float time = stream.ReadEncoded(1) ? 1.f : 0.f;
|
||||
float time = stream.ReadBits(1) ? 1.f : 0.f;
|
||||
x170_scanTimes.emplace_back(state.first, time);
|
||||
}
|
||||
|
||||
x180_scanCompletionRate.first = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100u)));
|
||||
x180_scanCompletionRate.second = u32(stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100u)));
|
||||
x180_scanCompletionRate.first = u32(stream.ReadBits(CInputStream::GetBitCount(0x100u)));
|
||||
x180_scanCompletionRate.second = u32(stream.ReadBits(CInputStream::GetBitCount(0x100u)));
|
||||
}
|
||||
|
||||
void CPlayerState::PutTo(CBitStreamWriter& stream) {
|
||||
stream.WriteEncoded(x4_enabledItems, 32);
|
||||
void CPlayerState::PutTo(COutputStream& stream) {
|
||||
stream.WriteBits(x4_enabledItems, 32);
|
||||
|
||||
const float realHP = xc_health.GetHP();
|
||||
u32 integralHP;
|
||||
std::memcpy(&integralHP, &realHP, sizeof(u32));
|
||||
|
||||
stream.WriteEncoded(integralHP, 32);
|
||||
stream.WriteEncoded(u32(x8_currentBeam), CBitStreamWriter::GetBitCount(5));
|
||||
stream.WriteEncoded(u32(x20_currentSuit), CBitStreamWriter::GetBitCount(4));
|
||||
stream.WriteBits(integralHP, 32);
|
||||
stream.WriteBits(u32(x8_currentBeam), COutputStream::GetBitCount(5));
|
||||
stream.WriteBits(u32(x20_currentSuit), COutputStream::GetBitCount(4));
|
||||
for (size_t i = 0; i < x24_powerups.size(); ++i) {
|
||||
const CPowerUp& pup = x24_powerups[i];
|
||||
stream.WriteEncoded(pup.x0_amount, CBitStreamWriter::GetBitCount(PowerUpMaxValues[i]));
|
||||
stream.WriteEncoded(pup.x4_capacity, CBitStreamWriter::GetBitCount(PowerUpMaxValues[i]));
|
||||
stream.WriteBits(pup.x0_amount, COutputStream::GetBitCount(PowerUpMaxValues[i]));
|
||||
stream.WriteBits(pup.x4_capacity, COutputStream::GetBitCount(PowerUpMaxValues[i]));
|
||||
}
|
||||
|
||||
for (const auto& scanTime : x170_scanTimes) {
|
||||
if (scanTime.second >= 1.f)
|
||||
stream.WriteEncoded(true, 1);
|
||||
stream.WriteBits(true, 1);
|
||||
else
|
||||
stream.WriteEncoded(false, 1);
|
||||
stream.WriteBits(false, 1);
|
||||
}
|
||||
|
||||
stream.WriteEncoded(x180_scanCompletionRate.first, CBitStreamWriter::GetBitCount(0x100));
|
||||
stream.WriteEncoded(x180_scanCompletionRate.second, CBitStreamWriter::GetBitCount(0x100));
|
||||
stream.WriteBits(x180_scanCompletionRate.first, COutputStream::GetBitCount(0x100));
|
||||
stream.WriteBits(x180_scanCompletionRate.second, COutputStream::GetBitCount(0x100));
|
||||
}
|
||||
|
||||
u32 CPlayerState::GetMissileCostForAltAttack() const { return costs[size_t(x8_currentBeam)]; }
|
||||
|
|
|
@ -164,8 +164,8 @@ public:
|
|||
CStaticInterference& GetStaticInterference() { return x188_staticIntf; }
|
||||
const std::vector<std::pair<CAssetId, float>>& GetScanTimes() const { return x170_scanTimes; }
|
||||
CPlayerState();
|
||||
explicit CPlayerState(CBitStreamReader& stream);
|
||||
void PutTo(CBitStreamWriter& stream);
|
||||
explicit CPlayerState(CInputStream& stream);
|
||||
void PutTo(COutputStream& stream);
|
||||
static u32 GetPowerUpMaxValue(EItemType type);
|
||||
static EItemType ItemNameToType(std::string_view name);
|
||||
static std::string_view ItemTypeToName(EItemType type);
|
||||
|
|
|
@ -44,7 +44,8 @@ std::unique_ptr<CInputStream> CResLoader::LoadNewResourcePartSync(const SObjectT
|
|||
|
||||
CPakFile* const file = FindResourceForLoad(tag);
|
||||
file->SyncSeekRead(buf, length, ESeekOrigin::Begin, x50_cachedResInfo->GetOffset() + offset);
|
||||
return std::make_unique<athena::io::MemoryReader>(buf, length, !extBuf);
|
||||
return std::make_unique<CMemoryInStream>(
|
||||
buf, length, extBuf == nullptr ? CMemoryInStream::EOwnerShip::Owned : CMemoryInStream::EOwnerShip::NotOwned);
|
||||
}
|
||||
|
||||
void CResLoader::LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]>& bufOut, int* sizeOut) {
|
||||
|
@ -57,9 +58,10 @@ void CResLoader::LoadMemResourceSync(const SObjectTag& tag, std::unique_ptr<u8[]
|
|||
|
||||
std::unique_ptr<CInputStream> CResLoader::LoadResourceFromMemorySync(const SObjectTag& tag, const void* buf) {
|
||||
FindResourceForLoad(tag);
|
||||
std::unique_ptr<CInputStream> newStrm = std::make_unique<athena::io::MemoryReader>(buf, x50_cachedResInfo->GetSize());
|
||||
std::unique_ptr<CInputStream> newStrm =
|
||||
std::make_unique<CMemoryInStream>(buf, x50_cachedResInfo->GetSize(), CMemoryInStream::EOwnerShip::NotOwned);
|
||||
if (x50_cachedResInfo->IsCompressed()) {
|
||||
newStrm->readUint32Big();
|
||||
newStrm->ReadLong();
|
||||
newStrm = std::make_unique<CZipInputStream>(std::move(newStrm));
|
||||
}
|
||||
return newStrm;
|
||||
|
@ -77,9 +79,10 @@ std::unique_ptr<CInputStream> CResLoader::LoadNewResourceSync(const SObjectTag&
|
|||
file->SyncSeekRead(buf, resSz, ESeekOrigin::Begin, x50_cachedResInfo->GetOffset());
|
||||
|
||||
const bool takeOwnership = extBuf == nullptr;
|
||||
std::unique_ptr<CInputStream> newStrm = std::make_unique<athena::io::MemoryReader>(buf, resSz, takeOwnership);
|
||||
std::unique_ptr<CInputStream> newStrm = std::make_unique<CMemoryInStream>(
|
||||
buf, resSz, takeOwnership ? CMemoryInStream::EOwnerShip::Owned : CMemoryInStream::EOwnerShip::NotOwned);
|
||||
if (x50_cachedResInfo->IsCompressed()) {
|
||||
newStrm->readUint32Big();
|
||||
newStrm->ReadLong();
|
||||
newStrm = std::make_unique<CZipInputStream>(std::move(newStrm));
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace metaforce {
|
||||
CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, CAssetId resId) : x0_scannableObjectId(resId) {
|
||||
const u32 version = in.readUint32Big();
|
||||
const u32 version = in.ReadLong();
|
||||
Load(in, version);
|
||||
|
||||
for (auto& bucket : x14_buckets) {
|
||||
|
@ -33,18 +33,18 @@ CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, CAssetId resId) : x
|
|||
}
|
||||
|
||||
void CScannableObjectInfo::Load(CInputStream& in, u32 version) {
|
||||
in.readUint32Big();
|
||||
in.readUint32Big();
|
||||
x4_stringId = in.readUint32Big();
|
||||
in.ReadLong();
|
||||
in.ReadLong();
|
||||
x4_stringId = in.ReadLong();
|
||||
if (version < 4) {
|
||||
x8_totalDownloadTime = in.readFloatBig();
|
||||
x8_totalDownloadTime = in.ReadFloat();
|
||||
} else {
|
||||
const u32 scanSpeed = in.readUint32Big();
|
||||
const u32 scanSpeed = in.ReadLong();
|
||||
x8_totalDownloadTime = g_tweakGui->GetScanSpeed(scanSpeed);
|
||||
}
|
||||
xc_category = in.readUint32Big();
|
||||
xc_category = in.ReadLong();
|
||||
if (version > 4) {
|
||||
x10_important = in.readBool();
|
||||
x10_important = in.ReadBool();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < x14_buckets.capacity(); i++) {
|
||||
|
@ -53,15 +53,15 @@ void CScannableObjectInfo::Load(CInputStream& in, u32 version) {
|
|||
}
|
||||
|
||||
CScannableObjectInfo::SBucket::SBucket(CInputStream& in, u32 version) {
|
||||
x0_texture = in.readUint32Big();
|
||||
x4_appearanceRange = in.readFloatBig();
|
||||
x8_imagePos = in.readUint32Big();
|
||||
x0_texture = in.ReadLong();
|
||||
x4_appearanceRange = in.ReadFloat();
|
||||
x8_imagePos = in.ReadLong();
|
||||
if (version > 1) {
|
||||
xc_size.x = in.readUint32Big();
|
||||
xc_size.y = in.readUint32Big();
|
||||
x14_interval = in.readFloatBig();
|
||||
xc_size.x = in.ReadLong();
|
||||
xc_size.y = in.ReadLong();
|
||||
x14_interval = in.ReadFloat();
|
||||
if (version >= 3)
|
||||
x18_fadeDuration = in.readFloatBig();
|
||||
x18_fadeDuration = in.ReadFloat();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CScriptMailbox::CScriptMailbox(CBitStreamReader& in, const CWorldSaveGameInfo& saveWorld) {
|
||||
CScriptMailbox::CScriptMailbox(CInputStream& in, const CWorldSaveGameInfo& saveWorld) {
|
||||
const u32 relayCount = saveWorld.GetRelayCount();
|
||||
if (saveWorld.GetRelayCount()) {
|
||||
std::vector<bool> relayStates(saveWorld.GetRelayCount());
|
||||
for (u32 i = 0; i < relayCount; ++i) {
|
||||
relayStates[i] = in.ReadEncoded(1);
|
||||
relayStates[i] = in.ReadBits(1);
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < relayCount; ++i) {
|
||||
|
@ -79,7 +79,7 @@ void CScriptMailbox::SendMsgs(TAreaId areaId, CStateManager& stateMgr) {
|
|||
}
|
||||
}
|
||||
|
||||
void CScriptMailbox::PutTo(CBitStreamWriter& out, const CWorldSaveGameInfo& saveWorld) {
|
||||
void CScriptMailbox::PutTo(COutputStream& out, const CWorldSaveGameInfo& saveWorld) {
|
||||
const u32 relayCount = saveWorld.GetRelayCount();
|
||||
std::vector<bool> relays(relayCount);
|
||||
|
||||
|
@ -91,7 +91,7 @@ void CScriptMailbox::PutTo(CBitStreamWriter& out, const CWorldSaveGameInfo& save
|
|||
}
|
||||
|
||||
for (u32 i = 0; i < relayCount; ++i) {
|
||||
out.WriteEncoded(u32(relays[i]), 1);
|
||||
out.WriteBits(u32(relays[i]), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,13 @@ class CScriptMailbox {
|
|||
|
||||
public:
|
||||
CScriptMailbox() = default;
|
||||
CScriptMailbox(CBitStreamReader& in, const CWorldSaveGameInfo& saveWorld);
|
||||
CScriptMailbox(CInputStream& in, const CWorldSaveGameInfo& saveWorld);
|
||||
|
||||
bool HasMsg(TEditorId id) const;
|
||||
void AddMsg(TEditorId id);
|
||||
void RemoveMsg(TEditorId id);
|
||||
void SendMsgs(TAreaId areaId, CStateManager& stateMgr);
|
||||
void PutTo(CBitStreamWriter& out, const CWorldSaveGameInfo& saveWorld);
|
||||
void PutTo(COutputStream& out, const CWorldSaveGameInfo& saveWorld);
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -439,7 +439,7 @@ void CStateManager::SetupParticleHook(const CActor& actor) const {
|
|||
|
||||
void CStateManager::MurderScriptInstanceNames() { xb40_uniqueInstanceNames.clear(); }
|
||||
|
||||
std::string CStateManager::HashInstanceName(CInputStream& in) { return in.readString(); }
|
||||
std::string CStateManager::HashInstanceName(CInputStream& in) { return in.Get<std::string>(); }
|
||||
|
||||
void CStateManager::SetActorAreaId(CActor& actor, TAreaId aid) {
|
||||
const TAreaId actorAid = actor.GetAreaIdAlways();
|
||||
|
@ -985,90 +985,90 @@ void CStateManager::DrawWorld() {
|
|||
}
|
||||
|
||||
void CStateManager::DrawActorCubeFaces(CActor& actor, int& cubeInst) const {
|
||||
// if (!actor.m_reflectionCube ||
|
||||
// (!TCastToPtr<CPlayer>(actor) && (!actor.GetActive() || !actor.IsDrawEnabled() || actor.xe4_30_outOfFrustum)))
|
||||
// return;
|
||||
//
|
||||
// const TAreaId visAreaId = actor.GetAreaIdAlways();
|
||||
// const SViewport backupVp = g_Viewport;
|
||||
//
|
||||
// int areaCount = 0;
|
||||
// std::array<const CGameArea*, 10> areaArr;
|
||||
// for (const CGameArea& area : *x850_world) {
|
||||
// if (areaCount == 10) {
|
||||
// break;
|
||||
// }
|
||||
// auto occState = CGameArea::EOcclusionState::Occluded;
|
||||
// if (area.IsPostConstructed()) {
|
||||
// occState = area.GetOcclusionState();
|
||||
// }
|
||||
// if (occState == CGameArea::EOcclusionState::Visible) {
|
||||
// areaArr[areaCount++] = &area;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int f = 0; f < 6; ++f) {
|
||||
// SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CStateManager::DrawActorCubeFaces [{}] {} {} {}"), f,
|
||||
// actor.GetUniqueId(), actor.GetEditorId(), actor.GetName())
|
||||
// .c_str(),
|
||||
// zeus::skOrange);
|
||||
// CGraphics::g_BooMainCommandQueue->setRenderTarget(actor.m_reflectionCube, f);
|
||||
// SetupViewForCubeFaceDraw(actor.GetRenderBounds().center(), f);
|
||||
// CGraphics::g_BooMainCommandQueue->clearTarget();
|
||||
//
|
||||
// std::sort(areaArr.begin(), areaArr.begin() + areaCount, [visAreaId](const CGameArea* a, const CGameArea* b) {
|
||||
// if (a->x4_selfIdx == b->x4_selfIdx) {
|
||||
// return false;
|
||||
// }
|
||||
// if (visAreaId == a->x4_selfIdx) {
|
||||
// return false;
|
||||
// }
|
||||
// if (visAreaId == b->x4_selfIdx) {
|
||||
// return true;
|
||||
// }
|
||||
// return CGraphics::g_ViewPoint.dot(a->GetAABB().center()) > CGraphics::g_ViewPoint.dot(b->GetAABB().center());
|
||||
// });
|
||||
//
|
||||
// int pvsCount = 0;
|
||||
// std::array<CPVSVisSet, 10> pvsArr;
|
||||
// for (auto area = areaArr.cbegin(); area != areaArr.cbegin() + areaCount; ++area) {
|
||||
// const CGameArea* areaPtr = *area;
|
||||
// CPVSVisSet& pvsSet = pvsArr[pvsCount++];
|
||||
// pvsSet.Reset(EPVSVisSetState::OutOfBounds);
|
||||
// GetVisSetForArea(areaPtr->x4_selfIdx, visAreaId, pvsSet);
|
||||
// }
|
||||
//
|
||||
// for (int i = areaCount - 1; i >= 0; --i) {
|
||||
// const CGameArea& area = *areaArr[i];
|
||||
// SetupFogForArea(area);
|
||||
// g_Renderer->EnablePVS(pvsArr[i], area.x4_selfIdx);
|
||||
// g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||
// g_Renderer->UpdateAreaUniforms(area.x4_selfIdx, EWorldShadowMode::None, true, cubeInst * 6 + f);
|
||||
// g_Renderer->DrawUnsortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
||||
// }
|
||||
//
|
||||
// if (!SetupFogForDraw()) {
|
||||
// g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack);
|
||||
// }
|
||||
//
|
||||
// x850_world->DrawSky(zeus::CTransform::Translate(CGraphics::g_ViewPoint));
|
||||
//
|
||||
// for (int i = 0; i < areaCount; ++i) {
|
||||
// const CGameArea& area = *areaArr[i];
|
||||
// CPVSVisSet& pvs = pvsArr[i];
|
||||
// SetupFogForArea(area);
|
||||
// g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||
// g_Renderer->EnablePVS(pvs, area.x4_selfIdx);
|
||||
// g_Renderer->DrawSortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// CGraphics::g_BooMainCommandQueue->generateMipmaps(actor.m_reflectionCube);
|
||||
//
|
||||
// CBooRenderer::BindMainDrawTarget();
|
||||
// g_Renderer->SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
||||
//
|
||||
// ++cubeInst;
|
||||
// if (!actor.m_reflectionCube ||
|
||||
// (!TCastToPtr<CPlayer>(actor) && (!actor.GetActive() || !actor.IsDrawEnabled() || actor.xe4_30_outOfFrustum)))
|
||||
// return;
|
||||
//
|
||||
// const TAreaId visAreaId = actor.GetAreaIdAlways();
|
||||
// const SViewport backupVp = g_Viewport;
|
||||
//
|
||||
// int areaCount = 0;
|
||||
// std::array<const CGameArea*, 10> areaArr;
|
||||
// for (const CGameArea& area : *x850_world) {
|
||||
// if (areaCount == 10) {
|
||||
// break;
|
||||
// }
|
||||
// auto occState = CGameArea::EOcclusionState::Occluded;
|
||||
// if (area.IsPostConstructed()) {
|
||||
// occState = area.GetOcclusionState();
|
||||
// }
|
||||
// if (occState == CGameArea::EOcclusionState::Visible) {
|
||||
// areaArr[areaCount++] = &area;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// for (int f = 0; f < 6; ++f) {
|
||||
// SCOPED_GRAPHICS_DEBUG_GROUP(fmt::format(FMT_STRING("CStateManager::DrawActorCubeFaces [{}] {} {} {}"), f,
|
||||
// actor.GetUniqueId(), actor.GetEditorId(), actor.GetName())
|
||||
// .c_str(),
|
||||
// zeus::skOrange);
|
||||
// CGraphics::g_BooMainCommandQueue->setRenderTarget(actor.m_reflectionCube, f);
|
||||
// SetupViewForCubeFaceDraw(actor.GetRenderBounds().center(), f);
|
||||
// CGraphics::g_BooMainCommandQueue->clearTarget();
|
||||
//
|
||||
// std::sort(areaArr.begin(), areaArr.begin() + areaCount, [visAreaId](const CGameArea* a, const CGameArea* b) {
|
||||
// if (a->x4_selfIdx == b->x4_selfIdx) {
|
||||
// return false;
|
||||
// }
|
||||
// if (visAreaId == a->x4_selfIdx) {
|
||||
// return false;
|
||||
// }
|
||||
// if (visAreaId == b->x4_selfIdx) {
|
||||
// return true;
|
||||
// }
|
||||
// return CGraphics::g_ViewPoint.dot(a->GetAABB().center()) > CGraphics::g_ViewPoint.dot(b->GetAABB().center());
|
||||
// });
|
||||
//
|
||||
// int pvsCount = 0;
|
||||
// std::array<CPVSVisSet, 10> pvsArr;
|
||||
// for (auto area = areaArr.cbegin(); area != areaArr.cbegin() + areaCount; ++area) {
|
||||
// const CGameArea* areaPtr = *area;
|
||||
// CPVSVisSet& pvsSet = pvsArr[pvsCount++];
|
||||
// pvsSet.Reset(EPVSVisSetState::OutOfBounds);
|
||||
// GetVisSetForArea(areaPtr->x4_selfIdx, visAreaId, pvsSet);
|
||||
// }
|
||||
//
|
||||
// for (int i = areaCount - 1; i >= 0; --i) {
|
||||
// const CGameArea& area = *areaArr[i];
|
||||
// SetupFogForArea(area);
|
||||
// g_Renderer->EnablePVS(pvsArr[i], area.x4_selfIdx);
|
||||
// g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||
// g_Renderer->UpdateAreaUniforms(area.x4_selfIdx, EWorldShadowMode::None, true, cubeInst * 6 + f);
|
||||
// g_Renderer->DrawUnsortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
||||
// }
|
||||
//
|
||||
// if (!SetupFogForDraw()) {
|
||||
// g_Renderer->SetWorldFog(ERglFogMode::None, 0.f, 1.f, zeus::skBlack);
|
||||
// }
|
||||
//
|
||||
// x850_world->DrawSky(zeus::CTransform::Translate(CGraphics::g_ViewPoint));
|
||||
//
|
||||
// for (int i = 0; i < areaCount; ++i) {
|
||||
// const CGameArea& area = *areaArr[i];
|
||||
// CPVSVisSet& pvs = pvsArr[i];
|
||||
// SetupFogForArea(area);
|
||||
// g_Renderer->SetWorldLightFadeLevel(area.GetPostConstructed()->x1128_worldLightingLevel);
|
||||
// g_Renderer->EnablePVS(pvs, area.x4_selfIdx);
|
||||
// g_Renderer->DrawSortedGeometry(area.x4_selfIdx, 0x2, 0x0);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// CGraphics::g_BooMainCommandQueue->generateMipmaps(actor.m_reflectionCube);
|
||||
//
|
||||
// CBooRenderer::BindMainDrawTarget();
|
||||
// g_Renderer->SetViewport(backupVp.x0_left, backupVp.x4_top, backupVp.x8_width, backupVp.xc_height);
|
||||
//
|
||||
// ++cubeInst;
|
||||
}
|
||||
|
||||
void CStateManager::DrawWorldCubeFaces() const {
|
||||
|
@ -1470,14 +1470,14 @@ CStateManager::GetIdListForScript(TEditorId id) const {
|
|||
}
|
||||
|
||||
void CStateManager::LoadScriptObjects(TAreaId aid, CInputStream& in, std::vector<TEditorId>& idsOut) {
|
||||
in.readUByte();
|
||||
in.ReadUint8();
|
||||
|
||||
const u32 objCount = in.readUint32Big();
|
||||
const u32 objCount = in.ReadLong();
|
||||
idsOut.reserve(idsOut.size() + objCount);
|
||||
for (u32 i = 0; i < objCount; ++i) {
|
||||
const auto objType = static_cast<EScriptObjectType>(in.readUByte());
|
||||
const u32 objSize = in.readUint32Big();
|
||||
const u32 pos = static_cast<u32>(in.position());
|
||||
const auto objType = static_cast<EScriptObjectType>(in.ReadUint8());
|
||||
const u32 objSize = in.ReadLong();
|
||||
const u32 pos = static_cast<u32>(in.GetReadPosition());
|
||||
const auto id = LoadScriptObject(aid, objType, objSize, in);
|
||||
if (id.first == kInvalidEditorId) {
|
||||
continue;
|
||||
|
@ -1502,15 +1502,15 @@ void CStateManager::LoadScriptObjects(TAreaId aid, CInputStream& in, std::vector
|
|||
std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, EScriptObjectType type, u32 length,
|
||||
CInputStream& in) {
|
||||
OPTICK_EVENT();
|
||||
const TEditorId id = in.readUint32Big();
|
||||
const u32 connCount = in.readUint32Big();
|
||||
const TEditorId id = in.ReadLong();
|
||||
const u32 connCount = in.ReadLong();
|
||||
length -= 8;
|
||||
std::vector<SConnection> conns;
|
||||
conns.reserve(connCount);
|
||||
for (u32 i = 0; i < connCount; ++i) {
|
||||
const auto state = EScriptObjectState(in.readUint32Big());
|
||||
const auto msg = EScriptObjectMessage(in.readUint32Big());
|
||||
const TEditorId target = in.readUint32Big();
|
||||
const auto state = EScriptObjectState(in.ReadLong());
|
||||
const auto msg = EScriptObjectMessage(in.ReadLong());
|
||||
const TEditorId target = in.ReadLong();
|
||||
// Metaforce Addition
|
||||
if (m_incomingConnections.find(target) == m_incomingConnections.cend()) {
|
||||
m_incomingConnections.emplace(target, std::set<SConnection>());
|
||||
|
@ -1521,9 +1521,9 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
|
|||
length -= 12;
|
||||
conns.push_back(SConnection{state, msg, target});
|
||||
}
|
||||
const u32 propCount = in.readUint32Big();
|
||||
const u32 propCount = in.ReadLong();
|
||||
length -= 4;
|
||||
const auto startPos = in.position();
|
||||
const auto startPos = in.GetReadPosition();
|
||||
|
||||
bool error = false;
|
||||
FScriptLoader loader = {};
|
||||
|
@ -1545,7 +1545,7 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
|
|||
error = true;
|
||||
}
|
||||
|
||||
const u32 readAmt = in.position() - startPos;
|
||||
const u32 readAmt = in.GetReadPosition() - startPos;
|
||||
if (readAmt > length) {
|
||||
LogModule.report(logvisor::Fatal, FMT_STRING("Script object overread while reading {}"),
|
||||
ScriptObjectTypeToStr(type));
|
||||
|
@ -1553,13 +1553,17 @@ std::pair<TEditorId, TUniqueId> CStateManager::LoadScriptObject(TAreaId aid, ESc
|
|||
|
||||
const u32 leftover = length - readAmt;
|
||||
for (u32 i = 0; i < leftover; ++i) {
|
||||
in.readByte();
|
||||
in.ReadChar();
|
||||
}
|
||||
|
||||
if (error || ent == nullptr) {
|
||||
in.seek(startPos, athena::SeekOrigin::Begin);
|
||||
while (in.GetReadPosition() != startPos) {
|
||||
in.ReadChar();
|
||||
}
|
||||
const std::string name = HashInstanceName(in);
|
||||
in.seek(startPos + length, athena::SeekOrigin::Begin);
|
||||
while (in.GetReadPosition() != startPos + length) {
|
||||
in.ReadChar();
|
||||
}
|
||||
LogModule.report(logvisor::Error, FMT_STRING("Script load error while loading {}, name: {}"),
|
||||
ScriptObjectTypeToStr(type), name);
|
||||
return {kInvalidEditorId, kInvalidUniqueId};
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#include "Runtime/CStringExtras.hpp"
|
||||
#include "Runtime/CInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
std::string CStringExtras::ReadString(CInputStream& in) {
|
||||
u32 strLen = in.ReadLong();
|
||||
std::string ret;
|
||||
u32 readLen = 512;
|
||||
char tmp[512] = {};
|
||||
for (; strLen > 0; strLen -= readLen) {
|
||||
readLen = 512;
|
||||
if (strLen <= 512) {
|
||||
readLen = strLen;
|
||||
}
|
||||
in.ReadBytes(tmp, readLen);
|
||||
ret.append(tmp, readLen);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
#include <string>
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
class CInputStream;
|
||||
class CStringExtras {
|
||||
public:
|
||||
// Checks if the provided views into string data can be considered equal or not based on
|
||||
|
@ -35,6 +35,8 @@ public:
|
|||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::string ReadString(CInputStream& in);
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
namespace metaforce {
|
||||
CTextureCache::CTextureCache(CInputStream& in) {
|
||||
u32 textureCount = in.readUint32Big();
|
||||
u32 textureCount = in.ReadLong();
|
||||
for (u32 i = 0; i < textureCount; ++i) {
|
||||
CAssetId uid(in);
|
||||
if (m_textureInfo.find(uid) == m_textureInfo.end())
|
||||
m_textureInfo.emplace(uid, CTextureInfo(in));
|
||||
m_textureInfo.emplace(uid, in.Get<CTextureInfo>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class CPaletteInfo {
|
|||
|
||||
public:
|
||||
explicit CPaletteInfo(CInputStream& in)
|
||||
: m_format(in.readUint32Big()), m_elementCount(in.readUint32Big()), m_dolphinHash(in.readUint64Big()) {}
|
||||
: m_format(in.ReadLong()), m_elementCount(in.ReadLong()), m_dolphinHash(in.ReadLongLong()) {}
|
||||
};
|
||||
class CTextureInfo {
|
||||
ETexelFormat m_format;
|
||||
|
@ -25,12 +25,12 @@ class CTextureInfo {
|
|||
|
||||
public:
|
||||
explicit CTextureInfo(CInputStream& in)
|
||||
: m_format(ETexelFormat(in.readUint32Big()))
|
||||
, m_mipCount(in.readUint32Big())
|
||||
, m_width(in.readUint16Big())
|
||||
, m_height(in.readUint16Big())
|
||||
, m_dolphinHash(in.readUint64Big()) {
|
||||
bool hasPal = in.readBool();
|
||||
: m_format(ETexelFormat(in.ReadLong()))
|
||||
, m_mipCount(in.ReadLong())
|
||||
, m_width(in.ReadShort())
|
||||
, m_height(in.ReadShort())
|
||||
, m_dolphinHash(in.ReadLongLong()) {
|
||||
bool hasPal = in.ReadBool();
|
||||
if (hasPal)
|
||||
m_paletteInfo.emplace(in);
|
||||
}
|
||||
|
|
|
@ -4,50 +4,50 @@
|
|||
|
||||
namespace metaforce {
|
||||
CWorldSaveGameInfo::CWorldSaveGameInfo(CInputStream& in) {
|
||||
in.readUint32Big();
|
||||
const u32 version = in.readUint32Big();
|
||||
in.ReadLong();
|
||||
const u32 version = in.ReadLong();
|
||||
if (version > 1) {
|
||||
x0_areaCount = in.readUint32Big();
|
||||
x0_areaCount = in.ReadLong();
|
||||
}
|
||||
|
||||
if (version > 2) {
|
||||
const u32 cinematicCount = in.readUint32Big();
|
||||
const u32 cinematicCount = in.ReadLong();
|
||||
x4_cinematics.reserve(cinematicCount);
|
||||
for (u32 i = 0; i < cinematicCount; ++i) {
|
||||
x4_cinematics.emplace_back(in.readUint32Big());
|
||||
x4_cinematics.emplace_back(in.ReadLong());
|
||||
}
|
||||
|
||||
const u32 relayCount = in.readUint32Big();
|
||||
const u32 relayCount = in.ReadLong();
|
||||
x14_relays.reserve(relayCount);
|
||||
for (u32 i = 0; i < relayCount; ++i) {
|
||||
x14_relays.emplace_back(in.readUint32Big());
|
||||
x14_relays.emplace_back(in.ReadLong());
|
||||
}
|
||||
}
|
||||
|
||||
const u32 layerCount = in.readUint32Big();
|
||||
const u32 layerCount = in.ReadLong();
|
||||
x24_layers.reserve(layerCount);
|
||||
for (u32 i = 0; i < layerCount; ++i) {
|
||||
SLayerState& st = x24_layers.emplace_back();
|
||||
st.x0_area = in.readUint32Big();
|
||||
st.x4_layer = in.readUint32Big();
|
||||
st.x0_area = in.ReadLong();
|
||||
st.x4_layer = in.ReadLong();
|
||||
}
|
||||
|
||||
const u32 doorCount = in.readUint32Big();
|
||||
const u32 doorCount = in.ReadLong();
|
||||
x34_doors.reserve(doorCount);
|
||||
for (u32 i = 0; i < doorCount; ++i) {
|
||||
x34_doors.emplace_back(in.readUint32Big());
|
||||
x34_doors.emplace_back(in.ReadLong());
|
||||
}
|
||||
|
||||
if (version <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const u32 scanCount = in.readUint32Big();
|
||||
const u32 scanCount = in.ReadLong();
|
||||
x44_scans.reserve(scanCount);
|
||||
for (u32 i = 0; i < scanCount; ++i) {
|
||||
SScanState& st = x44_scans.emplace_back();
|
||||
st.x0_id = in.readUint32Big();
|
||||
st.x4_category = EScanCategory(in.readUint32Big());
|
||||
st.x0_id = in.ReadLong();
|
||||
st.x4_category = EScanCategory(in.ReadLong());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#include "CZipInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
CZipInputStream::CZipInputStream(std::unique_ptr<CInputStream>&& strm)
|
||||
: CInputStream(4096), x24_compBuf(new u8[4096]), x28_strm(std::move(strm)) {
|
||||
x30_zstrm = std::make_unique<z_stream>();
|
||||
x30_zstrm->next_in = x24_compBuf.get();
|
||||
x30_zstrm->avail_in = 0;
|
||||
x30_zstrm->zalloc = [](void*, u32 c, u32 n) -> void* { return new u8[size_t{c} * size_t{n}]; };
|
||||
x30_zstrm->zfree = [](void*, void* buf) { delete[] static_cast<u8*>(buf); };
|
||||
inflateInit(x30_zstrm.get());
|
||||
}
|
||||
|
||||
CZipInputStream::~CZipInputStream() { inflateEnd(x30_zstrm.get()); }
|
||||
|
||||
u32 CZipInputStream::Read(void* buf, u32 len) {
|
||||
x30_zstrm->next_out = static_cast<Bytef*>(buf);
|
||||
x30_zstrm->avail_out = len;
|
||||
x30_zstrm->total_out = 0;
|
||||
while (x30_zstrm->avail_out != 0) {
|
||||
if (x30_zstrm->avail_in == 0) {
|
||||
u32 readSz = x28_strm->ReadBytes(x24_compBuf.get(), 4096);
|
||||
x30_zstrm->avail_in = readSz;
|
||||
x30_zstrm->next_in = x24_compBuf.get();
|
||||
}
|
||||
int inflateRet = inflate(x30_zstrm.get(), Z_NO_FLUSH);
|
||||
if (inflateRet != Z_OK) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return x30_zstrm->total_out;
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "CInputStream.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <zlib.h>
|
||||
namespace metaforce {
|
||||
class CZipInputStream : public CInputStream {
|
||||
std::unique_ptr<u8[]> x24_compBuf;
|
||||
std::unique_ptr<CInputStream> x28_strm;
|
||||
std::unique_ptr<z_stream> x30_zstrm = {};
|
||||
|
||||
public:
|
||||
explicit CZipInputStream(std::unique_ptr<CInputStream>&& strm);
|
||||
~CZipInputStream() override;
|
||||
|
||||
u32 Read(void* ptr, u32 len) override;
|
||||
};
|
||||
|
||||
} // namespace metaforce
|
|
@ -13,10 +13,10 @@ namespace metaforce {
|
|||
|
||||
SCameraShakePoint SCameraShakePoint::LoadCameraShakePoint(CInputStream& in) {
|
||||
u32 useEnvelope = ScriptLoader::LoadParameterFlags(in);
|
||||
float attackTime = in.readFloatBig();
|
||||
float sustainTime = in.readFloatBig();
|
||||
float duration = in.readFloatBig();
|
||||
float magnitude = in.readFloatBig();
|
||||
float attackTime = in.ReadFloat();
|
||||
float sustainTime = in.ReadFloat();
|
||||
float duration = in.ReadFloat();
|
||||
float magnitude = in.ReadFloat();
|
||||
return {useEnvelope != 0, attackTime, sustainTime, duration, magnitude};
|
||||
}
|
||||
|
||||
|
@ -28,15 +28,15 @@ CCameraShakerComponent CCameraShakerComponent::LoadNewCameraShakerComponent(CInp
|
|||
}
|
||||
|
||||
CCameraShakeData::CCameraShakeData(CInputStream& in) {
|
||||
in.readUint32Big();
|
||||
in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
in.readBool();
|
||||
in.ReadLong();
|
||||
in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
in.ReadBool();
|
||||
BuildProjectileCameraShake(0.5f, 0.75f);
|
||||
}
|
||||
|
||||
|
@ -100,13 +100,13 @@ float CCameraShakeData::GetMaxFMComponent() const {
|
|||
}
|
||||
|
||||
CCameraShakeData CCameraShakeData::LoadCameraShakeData(CInputStream& in) {
|
||||
const float xMag = in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
const float yMag = in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
const float zMag = in.readFloatBig();
|
||||
in.readFloatBig();
|
||||
const float duration = in.readFloatBig();
|
||||
const float xMag = in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
const float yMag = in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
const float zMag = in.ReadFloat();
|
||||
in.ReadFloat();
|
||||
const float duration = in.ReadFloat();
|
||||
|
||||
const SCameraShakePoint xAM(false, 0.f, 0.f, duration, 2.f * xMag);
|
||||
const SCameraShakePoint yAM(false, 0.f, 0.f, duration, 2.f * yMag);
|
||||
|
|
|
@ -60,6 +60,7 @@ class CCameraShakeData {
|
|||
public:
|
||||
static const CCameraShakeData skChargedShotCameraShakeData;
|
||||
|
||||
constexpr CCameraShakeData() = default;
|
||||
constexpr CCameraShakeData(float duration, float sfxDist, u32 flags, const zeus::CVector3f& sfxPos,
|
||||
const CCameraShakerComponent& shaker1, const CCameraShakerComponent& shaker2,
|
||||
const CCameraShakerComponent& shaker3) noexcept
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <memory>
|
||||
#include "Runtime/RetroTypes.hpp"
|
||||
#include "Runtime/CInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
class CAdditiveAnimationInfo;
|
||||
|
@ -16,8 +17,8 @@ class CAdditiveAnimationInfo {
|
|||
|
||||
public:
|
||||
void read(CInputStream& in) {
|
||||
x0_fadeInDur = in.readFloatBig();
|
||||
x4_fadeOutDur = in.readFloatBig();
|
||||
x0_fadeInDur = in.ReadFloat();
|
||||
x4_fadeOutDur = in.ReadFloat();
|
||||
}
|
||||
CAdditiveAnimationInfo() = default;
|
||||
explicit CAdditiveAnimationInfo(CInputStream& in) { read(in); }
|
||||
|
|
|
@ -26,7 +26,7 @@ void CAnimFormatUnion::SubConstruct(u8* storage, EAnimFormat fmt, CInputStream&
|
|||
}
|
||||
|
||||
CAnimFormatUnion::CAnimFormatUnion(CInputStream& in, IObjectStore& store) {
|
||||
x0_format = EAnimFormat(in.readUint32Big());
|
||||
x0_format = EAnimFormat(in.ReadLong());
|
||||
SubConstruct(x4_storage, x0_format, in, store);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
CAnimCharacterSet::CAnimCharacterSet(CInputStream& in)
|
||||
: x0_version(in.readUint16Big()), x4_characterSet(in), x1c_animationSet(in) {}
|
||||
: x0_version(in.ReadShort()), x4_characterSet(in), x1c_animationSet(in) {}
|
||||
|
||||
CFactoryFnReturn FAnimCharacterSet(const SObjectTag&, CInputStream& in, const CVParamTransfer&,
|
||||
CObjectReference* selfRef) {
|
||||
|
|
|
@ -4,24 +4,24 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CAnimPOIData::CAnimPOIData(CInputStream& in) : x0_version(in.readUint32Big()) {
|
||||
u32 boolCount = in.readUint32Big();
|
||||
CAnimPOIData::CAnimPOIData(CInputStream& in) : x0_version(in.ReadLong()) {
|
||||
u32 boolCount = in.ReadLong();
|
||||
x4_boolNodes.reserve(boolCount);
|
||||
for (u32 i = 0; i < boolCount; ++i)
|
||||
x4_boolNodes.emplace_back(in);
|
||||
|
||||
u32 int32Count = in.readUint32Big();
|
||||
u32 int32Count = in.ReadLong();
|
||||
x14_int32Nodes.reserve(int32Count);
|
||||
for (u32 i = 0; i < int32Count; ++i)
|
||||
x14_int32Nodes.emplace_back(in);
|
||||
|
||||
u32 particleCount = in.readUint32Big();
|
||||
u32 particleCount = in.ReadLong();
|
||||
x24_particleNodes.reserve(particleCount);
|
||||
for (u32 i = 0; i < particleCount; ++i)
|
||||
x24_particleNodes.emplace_back(in);
|
||||
|
||||
if (x0_version >= 2) {
|
||||
u32 soundCount = in.readUint32Big();
|
||||
u32 soundCount = in.ReadLong();
|
||||
x34_soundNodes.reserve(soundCount);
|
||||
for (u32 i = 0; i < soundCount; ++i)
|
||||
x34_soundNodes.emplace_back(in);
|
||||
|
|
|
@ -51,16 +51,16 @@ std::unique_ptr<float[]> RotationAndOffsetStorage::GetRotationsAndOffsets(const
|
|||
}
|
||||
|
||||
RotationAndOffsetStorage::CRotationAndOffsetVectors::CRotationAndOffsetVectors(CInputStream& in) {
|
||||
const u32 quatCount = in.readUint32Big();
|
||||
const u32 quatCount = in.ReadLong();
|
||||
x0_rotations.reserve(quatCount);
|
||||
for (u32 i = 0; i < quatCount; ++i) {
|
||||
x0_rotations.emplace_back().readBig(in);
|
||||
x0_rotations.emplace_back() = in.Get<zeus::CQuaternion>();
|
||||
}
|
||||
|
||||
const u32 vecCount = in.readUint32Big();
|
||||
const u32 vecCount = in.ReadLong();
|
||||
x10_offsets.reserve(vecCount);
|
||||
for (u32 i = 0; i < vecCount; ++i) {
|
||||
x10_offsets.emplace_back().readBig(in);
|
||||
x10_offsets.emplace_back() = in.Get<zeus::CVector3f>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,10 +75,10 @@ RotationAndOffsetStorage::RotationAndOffsetStorage(const CRotationAndOffsetVecto
|
|||
|
||||
static std::vector<u8> ReadIndexTable(CInputStream& in) {
|
||||
std::vector<u8> ret;
|
||||
u32 count = in.readUint32Big();
|
||||
u32 count = in.ReadLong();
|
||||
ret.reserve(count);
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
ret.push_back(in.readUByte());
|
||||
ret.push_back(in.ReadUint8());
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -103,12 +103,12 @@ void CAnimSource::CalcAverageVelocity() {
|
|||
CAnimSource::CAnimSource(CInputStream& in, IObjectStore& store)
|
||||
: x0_duration(in)
|
||||
, x8_interval(in)
|
||||
, x10_frameCount(in.readUint32Big())
|
||||
, x10_frameCount(in.ReadLong())
|
||||
, x1c_rootBone(in)
|
||||
, x20_rotationChannels(ReadIndexTable(in))
|
||||
, x30_translationChannels(ReadIndexTable(in))
|
||||
, x40_data(RotationAndOffsetStorage::CRotationAndOffsetVectors(in), x10_frameCount)
|
||||
, x54_evntId(in.readUint32Big()) {
|
||||
, x54_evntId(in.ReadLong()) {
|
||||
if (x54_evntId.IsValid()) {
|
||||
x58_evntData = store.GetObj({SBIG('EVNT'), x54_evntId});
|
||||
x58_evntData.GetObj();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
CAnimation::CAnimation(CInputStream& in) {
|
||||
x0_name = in.readString();
|
||||
x0_name = in.Get<std::string>();
|
||||
x10_anim = CMetaAnimFactory::CreateMetaAnim(in);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CAnimationSet::CAnimationSet(CInputStream& in) : x0_tableCount(in.readUint16Big()) {
|
||||
u32 animationCount = in.readUint32Big();
|
||||
CAnimationSet::CAnimationSet(CInputStream& in) : x0_tableCount(in.ReadShort()) {
|
||||
u32 animationCount = in.ReadLong();
|
||||
x4_animations.reserve(animationCount);
|
||||
for (u32 i = 0; i < animationCount; ++i)
|
||||
x4_animations.emplace_back(in);
|
||||
|
||||
u32 transitionCount = in.readUint32Big();
|
||||
u32 transitionCount = in.ReadLong();
|
||||
x14_transitions.reserve(transitionCount);
|
||||
for (u32 i = 0; i < transitionCount; ++i)
|
||||
x14_transitions.emplace_back(in);
|
||||
|
@ -18,28 +18,28 @@ CAnimationSet::CAnimationSet(CInputStream& in) : x0_tableCount(in.readUint16Big(
|
|||
x24_defaultTransition = CMetaTransFactory::CreateMetaTrans(in);
|
||||
|
||||
if (x0_tableCount > 1) {
|
||||
u32 additiveAnimCount = in.readUint32Big();
|
||||
u32 additiveAnimCount = in.ReadLong();
|
||||
x28_additiveInfo.reserve(additiveAnimCount);
|
||||
for (u32 i = 0; i < additiveAnimCount; ++i) {
|
||||
u32 id = in.readUint32Big();
|
||||
u32 id = in.ReadLong();
|
||||
x28_additiveInfo.emplace_back(id, in);
|
||||
}
|
||||
x38_defaultAdditiveInfo.read(in);
|
||||
}
|
||||
|
||||
if (x0_tableCount > 2) {
|
||||
u32 halfTransitionCount = in.readUint32Big();
|
||||
u32 halfTransitionCount = in.ReadLong();
|
||||
x40_halfTransitions.reserve(halfTransitionCount);
|
||||
for (u32 i = 0; i < halfTransitionCount; ++i)
|
||||
x40_halfTransitions.emplace_back(in);
|
||||
}
|
||||
|
||||
if (x0_tableCount > 3) {
|
||||
u32 animResourcesCount = in.readUint32Big();
|
||||
u32 animResourcesCount = in.ReadLong();
|
||||
x50_animRes.reserve(animResourcesCount);
|
||||
for (u32 i = 0; i < animResourcesCount; ++i) {
|
||||
CAssetId anim = in.readUint32Big();
|
||||
CAssetId evnt = in.readUint32Big();
|
||||
CAssetId anim = in.ReadLong();
|
||||
CAssetId evnt = in.ReadLong();
|
||||
x50_animRes.emplace_back(anim, evnt);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace metaforce {
|
|||
|
||||
CBoolPOINode::CBoolPOINode() : CPOINode("root", EPOIType::EmptyBool, CCharAnimTime(), -1, false, 1.f, -1, 0) {}
|
||||
|
||||
CBoolPOINode::CBoolPOINode(CInputStream& in) : CPOINode(in), x38_val(in.readBool()) {}
|
||||
CBoolPOINode::CBoolPOINode(CInputStream& in) : CPOINode(in), x38_val(in.ReadBool()) {}
|
||||
|
||||
CBoolPOINode CBoolPOINode::CopyNodeMinusStartTime(const CBoolPOINode& node, const CCharAnimTime& startTime) {
|
||||
CBoolPOINode ret = node;
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
constexpr CCharAnimTime() = default;
|
||||
constexpr CCharAnimTime(float time) : x0_time(time), x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {}
|
||||
constexpr CCharAnimTime(EType type, float t) : x0_time(t), x4_type(type) {}
|
||||
explicit CCharAnimTime(CInputStream& in) : x0_time(in.readFloatBig()), x4_type(EType(in.readUint32Big())) {}
|
||||
explicit CCharAnimTime(CInputStream& in) : x0_time(in.ReadFloat()), x4_type(EType(in.ReadLong())) {}
|
||||
|
||||
static constexpr CCharAnimTime Infinity() { return {EType::Infinity, 1.0f}; }
|
||||
float GetSeconds() const { return x0_time; }
|
||||
|
|
|
@ -32,30 +32,30 @@ CSegId CCharLayoutInfo::GetSegIdFromString(std::string_view name) const {
|
|||
|
||||
void CCharLayoutNode::Bone::read(CInputStream& in) {
|
||||
x0_parentId = CSegId(in);
|
||||
x4_origin.readBig(in);
|
||||
x4_origin = in.Get<zeus::CVector3f>();
|
||||
|
||||
const u32 chCount = in.readUint32Big();
|
||||
const u32 chCount = in.ReadLong();
|
||||
x10_children.reserve(chCount);
|
||||
for (u32 i = 0; i < chCount; ++i) {
|
||||
x10_children.emplace_back(in);
|
||||
}
|
||||
}
|
||||
|
||||
CCharLayoutNode::CCharLayoutNode(CInputStream& in) : x0_boneMap(in.readUint32Big()) {
|
||||
CCharLayoutNode::CCharLayoutNode(CInputStream& in) : x0_boneMap(in.ReadLong()) {
|
||||
const u32 cap = x0_boneMap.GetCapacity();
|
||||
|
||||
for (u32 i = 0; i < cap; ++i) {
|
||||
const u32 thisId = in.readUint32Big();
|
||||
const u32 thisId = in.ReadLong();
|
||||
Bone& bone = x0_boneMap[thisId];
|
||||
bone.read(in);
|
||||
}
|
||||
}
|
||||
|
||||
CCharLayoutInfo::CCharLayoutInfo(CInputStream& in) : x0_node(std::make_shared<CCharLayoutNode>(in)), x8_segIdList(in) {
|
||||
const atUint32 mapCount = in.readUint32Big();
|
||||
const atUint32 mapCount = in.ReadLong();
|
||||
|
||||
for (atUint32 i = 0; i < mapCount; ++i) {
|
||||
std::string key = in.readString();
|
||||
std::string key = in.Get<std::string>();
|
||||
x18_segIdMap.emplace(std::move(key), in);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,76 +1,77 @@
|
|||
#include "Runtime/Character/CCharacterInfo.hpp"
|
||||
#include "Runtime/IOStreams.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
|
||||
CCharacterInfo::CParticleResData::CParticleResData(CInputStream& in, u16 tableCount) {
|
||||
const u32 partCount = in.readUint32Big();
|
||||
const u32 partCount = in.ReadLong();
|
||||
x0_part.reserve(partCount);
|
||||
for (u32 i = 0; i < partCount; ++i) {
|
||||
x0_part.emplace_back(in.readUint32Big());
|
||||
x0_part.emplace_back(in.Get<CAssetId>());
|
||||
}
|
||||
|
||||
const u32 swhcCount = in.readUint32Big();
|
||||
const u32 swhcCount = in.ReadLong();
|
||||
x10_swhc.reserve(swhcCount);
|
||||
for (u32 i = 0; i < swhcCount; ++i) {
|
||||
x10_swhc.emplace_back(in.readUint32Big());
|
||||
x10_swhc.emplace_back(in.Get<CAssetId>());
|
||||
}
|
||||
|
||||
const u32 unkCount = in.readUint32Big();
|
||||
const u32 unkCount = in.ReadLong();
|
||||
x20_elsc.reserve(unkCount);
|
||||
for (u32 i = 0; i < unkCount; ++i) {
|
||||
x20_elsc.emplace_back(in.readUint32Big());
|
||||
x20_elsc.emplace_back(in.Get<CAssetId>());
|
||||
}
|
||||
|
||||
if (tableCount > 5) {
|
||||
const u32 elscCount = in.readUint32Big();
|
||||
const u32 elscCount = in.ReadLong();
|
||||
x30_elsc.reserve(elscCount);
|
||||
for (u32 i = 0; i < elscCount; ++i) {
|
||||
x30_elsc.emplace_back(in.readUint32Big());
|
||||
x30_elsc.emplace_back(in.Get<CAssetId>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static std::vector<std::pair<s32, std::pair<std::string, std::string>>> MakeAnimInfoVector(CInputStream& in) {
|
||||
std::vector<std::pair<s32, std::pair<std::string, std::string>>> ret;
|
||||
const u32 animInfoCount = in.readUint32Big();
|
||||
const u32 animInfoCount = in.ReadLong();
|
||||
ret.reserve(animInfoCount);
|
||||
for (u32 i = 0; i < animInfoCount; ++i) {
|
||||
const s32 idx = in.readInt32Big();
|
||||
std::string a = in.readString();
|
||||
std::string b = in.readString();
|
||||
const s32 idx = in.ReadLong();
|
||||
std::string a = in.Get<std::string>();
|
||||
std::string b = in.Get<std::string>();
|
||||
ret.emplace_back(idx, std::make_pair(std::move(a), std::move(b)));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
CCharacterInfo::CCharacterInfo(CInputStream& in)
|
||||
: x0_tableCount(in.readUint16Big())
|
||||
, x4_name(in.readString())
|
||||
, x14_cmdl(in.readUint32Big())
|
||||
, x18_cskr(in.readUint32Big())
|
||||
, x1c_cinf(in.readUint32Big())
|
||||
: x0_tableCount(in.ReadShort())
|
||||
, x4_name(in.Get<std::string>())
|
||||
, x14_cmdl(in.ReadLong())
|
||||
, x18_cskr(in.ReadLong())
|
||||
, x1c_cinf(in.ReadLong())
|
||||
, x20_animInfo(MakeAnimInfoVector(in))
|
||||
, x30_pasDatabase(in)
|
||||
, x44_partRes(in, x0_tableCount)
|
||||
, x84_unk(in.readUint32Big()) {
|
||||
, x84_unk(in.ReadLong()) {
|
||||
if (x0_tableCount > 1) {
|
||||
const u32 aabbCount = in.readUint32Big();
|
||||
const u32 aabbCount = in.ReadLong();
|
||||
x88_aabbs.reserve(aabbCount);
|
||||
for (u32 i = 0; i < aabbCount; ++i) {
|
||||
std::string name = in.readString();
|
||||
std::string name = in.Get<std::string>();
|
||||
x88_aabbs.emplace_back(std::move(name), zeus::CAABox());
|
||||
x88_aabbs.back().second.readBoundingBoxBig(in);
|
||||
x88_aabbs.back().second = in.Get<zeus::CAABox>();
|
||||
}
|
||||
}
|
||||
|
||||
if (x0_tableCount > 2) {
|
||||
const u32 effectCount = in.readUint32Big();
|
||||
const u32 effectCount = in.ReadLong();
|
||||
x98_effects.reserve(effectCount);
|
||||
for (u32 i = 0; i < effectCount; ++i) {
|
||||
std::string name = in.readString();
|
||||
std::string name = in.Get<std::string>();
|
||||
x98_effects.emplace_back(std::move(name), std::vector<CEffectComponent>());
|
||||
std::vector<CEffectComponent>& comps = x98_effects.back().second;
|
||||
const u32 compCount = in.readUint32Big();
|
||||
const u32 compCount = in.ReadLong();
|
||||
comps.reserve(compCount);
|
||||
for (u32 j = 0; j < compCount; ++j) {
|
||||
comps.emplace_back(in);
|
||||
|
@ -79,15 +80,15 @@ CCharacterInfo::CCharacterInfo(CInputStream& in)
|
|||
}
|
||||
|
||||
if (x0_tableCount > 3) {
|
||||
xa8_cmdlOverlay = in.readUint32Big();
|
||||
xac_cskrOverlay = in.readUint32Big();
|
||||
xa8_cmdlOverlay = in.ReadLong();
|
||||
xac_cskrOverlay = in.ReadLong();
|
||||
}
|
||||
|
||||
if (x0_tableCount > 4) {
|
||||
const u32 aidxCount = in.readUint32Big();
|
||||
const u32 aidxCount = in.ReadLong();
|
||||
xb0_animIdxs.reserve(aidxCount);
|
||||
for (u32 i = 0; i < aidxCount; ++i) {
|
||||
xb0_animIdxs.push_back(in.readInt32Big());
|
||||
xb0_animIdxs.push_back(in.ReadLong());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CCharacterSet::CCharacterSet(CInputStream& in) : x0_version(in.readUint16Big()) {
|
||||
u32 charCount = in.readUint32Big();
|
||||
CCharacterSet::CCharacterSet(CInputStream& in) : x0_version(in.ReadShort()) {
|
||||
u32 charCount = in.ReadLong();
|
||||
for (u32 i = 0; i < charCount; ++i) {
|
||||
u32 id = in.readUint32Big();
|
||||
u32 id = in.ReadLong();
|
||||
x4_characters.emplace(id, in);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
SObjectTag CEffectComponent::GetSObjectTagFromStream(CInputStream& in) { return SObjectTag(in); }
|
||||
SObjectTag CEffectComponent::GetSObjectTagFromStream(CInputStream& in) { return in.Get<SObjectTag>(); }
|
||||
|
||||
CEffectComponent::CEffectComponent(CInputStream& in) {
|
||||
x0_name = in.readString();
|
||||
x0_name = in.Get<std::string>();
|
||||
x10_tag = GetSObjectTagFromStream(in);
|
||||
x18_boneName = in.readString();
|
||||
x28_scale = in.readFloatBig();
|
||||
x2c_parentedMode = CParticleData::EParentedMode(in.readUint32Big());
|
||||
x30_flags = in.readUint32Big();
|
||||
x18_boneName = in.Get<std::string>();
|
||||
x28_scale = in.ReadFloat();
|
||||
x2c_parentedMode = CParticleData::EParentedMode(in.ReadLong());
|
||||
x30_flags = in.ReadLong();
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -23,8 +23,8 @@ void WriteValue(u8* data, T value) {
|
|||
} // Anonymous namespace
|
||||
|
||||
CFBStreamedCompression::CFBStreamedCompression(CInputStream& in, IObjectStore& objStore, bool pc) : m_pc(pc) {
|
||||
x0_scratchSize = in.readUint32Big();
|
||||
x4_evnt = in.readUint32Big();
|
||||
x0_scratchSize = in.ReadLong();
|
||||
x4_evnt = in.ReadLong();
|
||||
|
||||
xc_rotsAndOffs = GetRotationsAndOffsets(x0_scratchSize / 4 + 1, in);
|
||||
|
||||
|
@ -86,78 +86,78 @@ std::unique_ptr<u32[]> CFBStreamedCompression::GetRotationsAndOffsets(u32 words,
|
|||
std::memcpy(ret.get(), &head, sizeof(head));
|
||||
|
||||
u32* bitmapOut = &ret[9];
|
||||
const u32 bitmapBitCount = in.readUint32Big();
|
||||
const u32 bitmapBitCount = in.ReadLong();
|
||||
bitmapOut[0] = bitmapBitCount;
|
||||
const u32 bitmapWordCount = (bitmapBitCount + 31) / 32;
|
||||
for (u32 i = 0; i < bitmapWordCount; ++i) {
|
||||
bitmapOut[i + 1] = in.readUint32Big();
|
||||
bitmapOut[i + 1] = in.ReadLong();
|
||||
}
|
||||
|
||||
in.readUint32Big();
|
||||
in.ReadLong();
|
||||
u8* chans = reinterpret_cast<u8*>(bitmapOut + bitmapWordCount + 1);
|
||||
u8* bs = ReadBoneChannelDescriptors(chans, in);
|
||||
const u32 bsWords = ComputeBitstreamWords(chans);
|
||||
|
||||
u32* bsPtr = reinterpret_cast<u32*>(bs);
|
||||
for (u32 w = 0; w < bsWords; ++w)
|
||||
bsPtr[w] = in.readUint32Big();
|
||||
bsPtr[w] = in.ReadLong();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
u8* CFBStreamedCompression::ReadBoneChannelDescriptors(u8* out, CInputStream& in) const {
|
||||
const u32 boneChanCount = in.readUint32Big();
|
||||
const u32 boneChanCount = in.ReadLong();
|
||||
WriteValue(out, boneChanCount);
|
||||
out += 4;
|
||||
|
||||
if (m_pc) {
|
||||
for (u32 b = 0; b < boneChanCount; ++b) {
|
||||
WriteValue(out, in.readUint32Big());
|
||||
WriteValue(out, in.ReadLong());
|
||||
out += 4;
|
||||
|
||||
WriteValue(out, in.readUint32Big());
|
||||
WriteValue(out, in.ReadLong());
|
||||
out += 4;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
WriteValue(out, in.readUint32Big());
|
||||
WriteValue(out, in.ReadLong());
|
||||
out += 4;
|
||||
}
|
||||
|
||||
const u32 tCount = in.readUint32Big();
|
||||
const u32 tCount = in.ReadLong();
|
||||
WriteValue(out, tCount);
|
||||
out += 4;
|
||||
|
||||
if (tCount != 0) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
WriteValue(out, in.readUint32Big());
|
||||
WriteValue(out, in.ReadLong());
|
||||
out += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (u32 b = 0; b < boneChanCount; ++b) {
|
||||
WriteValue(out, in.readUint32Big());
|
||||
WriteValue(out, in.ReadLong());
|
||||
out += 4;
|
||||
|
||||
WriteValue(out, in.readUint16Big());
|
||||
WriteValue(out, in.ReadShort());
|
||||
out += 2;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
WriteValue(out, in.readInt16Big());
|
||||
WriteValue(out, in.ReadShort());
|
||||
out += 2;
|
||||
WriteValue(out, in.readUByte());
|
||||
WriteValue(out, in.ReadUint8());
|
||||
out += 1;
|
||||
}
|
||||
|
||||
const u16 tCount = in.readUint16Big();
|
||||
const u16 tCount = in.ReadShort();
|
||||
WriteValue(out, tCount);
|
||||
out += 2;
|
||||
|
||||
if (tCount != 0) {
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
WriteValue(out, in.readInt16Big());
|
||||
WriteValue(out, in.ReadShort());
|
||||
out += 2;
|
||||
WriteValue(out, in.readUByte());
|
||||
WriteValue(out, in.ReadUint8());
|
||||
out += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,23 +31,23 @@ public:
|
|||
|
||||
void read(CInputStream& in) {
|
||||
/* unk0 */
|
||||
unk0 = in.readUint32Big();
|
||||
unk0 = in.ReadLong();
|
||||
/* duration */
|
||||
duration = in.readFloatBig();
|
||||
duration = in.ReadFloat();
|
||||
/* interval */
|
||||
interval = in.readFloatBig();
|
||||
interval = in.ReadFloat();
|
||||
/* rootBoneId */
|
||||
rootBoneId = in.readUint32Big();
|
||||
rootBoneId = in.ReadLong();
|
||||
/* looping */
|
||||
looping = in.readUint32Big();
|
||||
looping = in.ReadLong();
|
||||
/* rotDiv */
|
||||
rotDiv = in.readUint32Big();
|
||||
rotDiv = in.ReadLong();
|
||||
/* translationMult */
|
||||
translationMult = in.readFloatBig();
|
||||
translationMult = in.ReadFloat();
|
||||
/* boneChannelCount */
|
||||
boneChannelCount = in.readUint32Big();
|
||||
boneChannelCount = in.ReadLong();
|
||||
/* unk3 */
|
||||
unk3 = in.readUint32Big();
|
||||
unk3 = in.ReadLong();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
CHalfTransition::CHalfTransition(CInputStream& in) {
|
||||
x0_id = in.readUint32Big();
|
||||
x0_id = in.ReadLong();
|
||||
x4_trans = CMetaTransFactory::CreateMetaTrans(in);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CInt32POINode::CInt32POINode(std::string_view name, EPOIType type, const CCharAn
|
|||
: CPOINode(name, type, time, index, unique, weight, charIndex, flags), x38_val(val), x3c_locatorName(locator) {}
|
||||
|
||||
CInt32POINode::CInt32POINode(CInputStream& in)
|
||||
: CPOINode(in), x38_val(in.readUint32Big()), x3c_locatorName(in.readString()) {}
|
||||
: CPOINode(in), x38_val(in.ReadLong()), x3c_locatorName(in.Get<std::string>()) {}
|
||||
|
||||
CInt32POINode CInt32POINode::CopyNodeMinusStartTime(const CInt32POINode& node, const CCharAnimTime& startTime) {
|
||||
CInt32POINode ret = node;
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace metaforce {
|
|||
CMetaAnimBlend::CMetaAnimBlend(CInputStream& in) {
|
||||
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
|
||||
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
|
||||
xc_blend = in.readFloatBig();
|
||||
x10_ = in.readBool();
|
||||
xc_blend = in.ReadFloat();
|
||||
x10_ = in.ReadBool();
|
||||
}
|
||||
|
||||
void CMetaAnimBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
std::shared_ptr<IMetaAnim> CMetaAnimFactory::CreateMetaAnim(CInputStream& in) {
|
||||
EMetaAnimType type = EMetaAnimType(in.readUint32Big());
|
||||
EMetaAnimType type = EMetaAnimType(in.ReadLong());
|
||||
|
||||
switch (type) {
|
||||
case EMetaAnimType::Play:
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace metaforce {
|
|||
CMetaAnimPhaseBlend::CMetaAnimPhaseBlend(CInputStream& in) {
|
||||
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
|
||||
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
|
||||
xc_blend = in.readFloatBig();
|
||||
x10_ = in.readBool();
|
||||
xc_blend = in.ReadFloat();
|
||||
x10_ = in.ReadBool();
|
||||
}
|
||||
|
||||
void CMetaAnimPhaseBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const {
|
||||
|
|
|
@ -7,12 +7,12 @@ namespace metaforce {
|
|||
|
||||
CMetaAnimRandom::RandomData CMetaAnimRandom::CreateRandomData(CInputStream& in) {
|
||||
CMetaAnimRandom::RandomData ret;
|
||||
u32 randCount = in.readUint32Big();
|
||||
u32 randCount = in.ReadLong();
|
||||
ret.reserve(randCount);
|
||||
|
||||
for (u32 i = 0; i < randCount; ++i) {
|
||||
std::shared_ptr<IMetaAnim> metaAnim = CMetaAnimFactory::CreateMetaAnim(in);
|
||||
ret.emplace_back(std::move(metaAnim), in.readUint32Big());
|
||||
ret.emplace_back(std::move(metaAnim), in.ReadLong());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace metaforce {
|
|||
|
||||
std::vector<std::shared_ptr<IMetaAnim>> CMetaAnimSequence::CreateSequence(CInputStream& in) {
|
||||
std::vector<std::shared_ptr<IMetaAnim>> ret;
|
||||
u32 seqCount = in.readUint32Big();
|
||||
u32 seqCount = in.ReadLong();
|
||||
ret.reserve(seqCount);
|
||||
|
||||
for (u32 i = 0; i < seqCount; ++i)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
std::shared_ptr<IMetaTrans> CMetaTransFactory::CreateMetaTrans(CInputStream& in) {
|
||||
EMetaTransType type = EMetaTransType(in.readUint32Big());
|
||||
EMetaTransType type = EMetaTransType(in.ReadLong());
|
||||
|
||||
switch (type) {
|
||||
case EMetaTransType::MetaAnim:
|
||||
|
|
|
@ -9,9 +9,9 @@ namespace metaforce {
|
|||
|
||||
CMetaTransPhaseTrans::CMetaTransPhaseTrans(CInputStream& in) {
|
||||
x4_transDur = CCharAnimTime(in);
|
||||
xc_ = in.readBool();
|
||||
xd_runA = in.readBool();
|
||||
x10_flags = in.readUint32Big();
|
||||
xc_ = in.ReadBool();
|
||||
xd_runA = in.ReadBool();
|
||||
x10_flags = in.ReadLong();
|
||||
}
|
||||
|
||||
std::shared_ptr<CAnimTreeNode> CMetaTransPhaseTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
namespace metaforce {
|
||||
|
||||
CMetaTransTrans::CMetaTransTrans(CInputStream& in) {
|
||||
x4_transDur = CCharAnimTime(in);
|
||||
xc_ = in.readBool();
|
||||
xd_runA = in.readBool();
|
||||
x10_flags = in.readUint32Big();
|
||||
x4_transDur = in.Get<CCharAnimTime>();
|
||||
xc_ = in.ReadBool();
|
||||
xd_runA = in.ReadBool();
|
||||
x10_flags = in.ReadLong();
|
||||
}
|
||||
|
||||
std::shared_ptr<CAnimTreeNode> CMetaTransTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
namespace metaforce {
|
||||
|
||||
CPASAnimState::CPASAnimState(CInputStream& in) {
|
||||
x0_id = static_cast<pas::EAnimationState>(in.readUint32Big());
|
||||
u32 parmCount = in.readUint32Big();
|
||||
u32 animCount = in.readUint32Big();
|
||||
x0_id = static_cast<pas::EAnimationState>(in.ReadLong());
|
||||
u32 parmCount = in.ReadLong();
|
||||
u32 animCount = in.ReadLong();
|
||||
|
||||
x4_parms.reserve(parmCount);
|
||||
x14_anims.reserve(animCount);
|
||||
|
@ -26,25 +26,25 @@ CPASAnimState::CPASAnimState(CInputStream& in) {
|
|||
x4_parms.emplace_back(in);
|
||||
|
||||
for (u32 i = 0; i < animCount; ++i) {
|
||||
s32 id = in.readUint32Big();
|
||||
s32 id = in.ReadLong();
|
||||
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> parms;
|
||||
for (const CPASParmInfo& parm : x4_parms) {
|
||||
CPASAnimParm::UParmValue val = {};
|
||||
switch (parm.GetParameterType()) {
|
||||
case CPASAnimParm::EParmType::Int32:
|
||||
val.m_int = in.readInt32Big();
|
||||
val.m_int = in.ReadInt32();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::UInt32:
|
||||
val.m_uint = in.readUint32Big();
|
||||
val.m_uint = in.ReadLong();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::Float:
|
||||
val.m_float = in.readFloatBig();
|
||||
val.m_float = in.ReadFloat();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::Bool:
|
||||
val.m_bool = in.readBool();
|
||||
val.m_bool = in.ReadBool();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::Enum:
|
||||
val.m_int = in.readInt32Big();
|
||||
val.m_int = in.ReadInt32();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -17,9 +17,9 @@ void CPASDatabase::AddAnimState(CPASAnimState&& state) {
|
|||
}
|
||||
|
||||
CPASDatabase::CPASDatabase(CInputStream& in) {
|
||||
in.readUint32Big();
|
||||
u32 animStateCount = in.readUint32Big();
|
||||
u32 defaultState = in.readUint32Big();
|
||||
in.ReadLong();
|
||||
u32 animStateCount = in.ReadLong();
|
||||
u32 defaultState = in.ReadLong();
|
||||
|
||||
x0_states.reserve(animStateCount);
|
||||
for (u32 i = 0; i < animStateCount; ++i) {
|
||||
|
|
|
@ -2,33 +2,33 @@
|
|||
|
||||
namespace metaforce {
|
||||
|
||||
CPASParmInfo::CPASParmInfo(CInputStream& in) {
|
||||
CPASParmInfo::CPASParmInfo(CInputStream& in)
|
||||
: x0_type(CPASAnimParm::EParmType(in.ReadLong())), x4_weightFunction(EWeightFunction(in.ReadLong())) {
|
||||
xc_min.m_int = 0;
|
||||
x10_max.m_int = 0;
|
||||
x0_type = CPASAnimParm::EParmType(in.readUint32Big());
|
||||
x4_weightFunction = EWeightFunction(in.readUint32Big());
|
||||
x8_weight = in.readFloatBig();
|
||||
|
||||
x8_weight = in.ReadFloat();
|
||||
|
||||
switch (x0_type) {
|
||||
case CPASAnimParm::EParmType::Int32:
|
||||
xc_min.m_int = in.readInt32Big();
|
||||
x10_max.m_int = in.readInt32Big();
|
||||
xc_min.m_int = in.ReadInt32();
|
||||
x10_max.m_int = in.ReadInt32();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::UInt32:
|
||||
xc_min.m_uint = in.readUint32Big();
|
||||
x10_max.m_uint = in.readUint32Big();
|
||||
xc_min.m_uint = in.ReadLong();
|
||||
x10_max.m_uint = in.ReadLong();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::Float:
|
||||
xc_min.m_float = in.readFloatBig();
|
||||
x10_max.m_float = in.readFloatBig();
|
||||
xc_min.m_float = in.ReadFloat();
|
||||
x10_max.m_float = in.ReadFloat();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::Bool:
|
||||
xc_min.m_bool = in.readBool();
|
||||
x10_max.m_bool = in.readBool();
|
||||
xc_min.m_bool = in.ReadBool();
|
||||
x10_max.m_bool = in.ReadBool();
|
||||
break;
|
||||
case CPASAnimParm::EParmType::Enum:
|
||||
xc_min.m_int = in.readInt32Big();
|
||||
x10_max.m_int = in.readInt32Big();
|
||||
xc_min.m_int = in.ReadInt32();
|
||||
x10_max.m_int = in.ReadInt32();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -21,15 +21,15 @@ CPOINode::CPOINode(std::string_view name, EPOIType type, const CCharAnimTime& ti
|
|||
, x34_flags(f) {}
|
||||
|
||||
CPOINode::CPOINode(CInputStream& in)
|
||||
: x4_(in.readUint16Big())
|
||||
, x8_name(in.readString())
|
||||
, x18_type(EPOIType(in.readUint16Big()))
|
||||
: x4_(in.ReadShort())
|
||||
, x8_name(in.Get<std::string>())
|
||||
, x18_type(EPOIType(in.ReadShort()))
|
||||
, x1c_time(in)
|
||||
, x24_index(in.readInt32Big())
|
||||
, x28_unique(in.readBool())
|
||||
, x2c_weight(in.readFloatBig())
|
||||
, x30_charIdx(in.readInt32Big())
|
||||
, x34_flags(in.readInt32Big()) {}
|
||||
, x24_index(in.ReadInt32())
|
||||
, x28_unique(in.ReadBool())
|
||||
, x2c_weight(in.ReadFloat())
|
||||
, x30_charIdx(in.ReadInt32())
|
||||
, x34_flags(in.ReadInt32()) {}
|
||||
|
||||
bool CPOINode::operator>(const CPOINode& other) const { return x1c_time > other.x1c_time; }
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace metaforce {
|
||||
|
||||
CParticleData::CParticleData(CInputStream& in)
|
||||
: x0_duration(in.readUint32Big())
|
||||
: x0_duration(in.ReadLong())
|
||||
, x4_particle(in)
|
||||
, xc_boneName(in.readString())
|
||||
, x1c_scale(in.readFloatBig())
|
||||
, x20_parentMode(EParentedMode(in.readUint32Big())) {}
|
||||
, xc_boneName(in.Get<std::string>())
|
||||
, x1c_scale(in.ReadFloat())
|
||||
, x20_parentMode(EParentedMode(in.ReadLong())) {}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace metaforce {
|
||||
|
||||
CPrimitive::CPrimitive(CInputStream& in) {
|
||||
x0_animId = in.readUint32Big();
|
||||
x4_animIdx = in.readUint32Big();
|
||||
x8_animName = in.readString();
|
||||
x0_animId = in.ReadLong();
|
||||
x4_animIdx = in.ReadLong();
|
||||
x8_animName = in.Get<std::string>();
|
||||
}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -11,7 +11,7 @@ class CSegId {
|
|||
public:
|
||||
constexpr CSegId() noexcept = default;
|
||||
constexpr CSegId(u8 id) noexcept : x0_segId(id) {}
|
||||
explicit CSegId(CInputStream& in) : x0_segId(in.readUint32Big()) {}
|
||||
explicit CSegId(CInputStream& in) : x0_segId(in.ReadUint8()) {}
|
||||
constexpr CSegId& operator++() noexcept {
|
||||
++x0_segId;
|
||||
return *this;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
CSegIdList::CSegIdList(CInputStream& in) {
|
||||
u32 count = in.readUint32Big();
|
||||
u32 count = in.ReadLong();
|
||||
x0_list.reserve(count);
|
||||
for (u32 i = 0; i < count; ++i)
|
||||
x0_list.emplace_back(in);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
namespace metaforce {
|
||||
|
||||
CSkinBank::CSkinBank(CInputStream& in) {
|
||||
u32 boneCount = in.readUint32Big();
|
||||
u32 boneCount = in.ReadLong();
|
||||
x0_segments.reserve(boneCount);
|
||||
for (u32 i = 0; i < boneCount; ++i)
|
||||
x0_segments.emplace_back(in);
|
||||
|
|
|
@ -7,16 +7,21 @@
|
|||
namespace metaforce {
|
||||
|
||||
static u32 ReadCount(CInputStream& in) {
|
||||
u32 result = in.readUint32Big();
|
||||
u32 result = in.ReadLong();
|
||||
if (result == UINT32_MAX) {
|
||||
return in.readUint32Big();
|
||||
return in.ReadLong();
|
||||
}
|
||||
u8 junk[784];
|
||||
for (u32 i = 0; i < (result * 3); ++i) {
|
||||
u32 iVar2 = ((result * 3) - i);
|
||||
iVar2 = 192 < iVar2 ? 192 : iVar2;
|
||||
in.Get(junk, iVar2 * 4);
|
||||
}
|
||||
in.seek(s64(result) * 3);
|
||||
return result;
|
||||
}
|
||||
|
||||
CSkinRules::CSkinRules(CInputStream& in) {
|
||||
u32 weightCount = in.readUint32Big();
|
||||
u32 weightCount = in.ReadLong();
|
||||
x0_bones.reserve(weightCount);
|
||||
for (int i = 0; i < weightCount; ++i) {
|
||||
x0_bones.emplace_back(in);
|
||||
|
@ -51,7 +56,7 @@ CFactoryFnReturn FSkinRulesFactory(const SObjectTag& tag, CInputStream& in, cons
|
|||
|
||||
auto StreamInSkinWeighting(CInputStream& in) {
|
||||
rstl::reserved_vector<SSkinWeighting, 3> weights;
|
||||
u32 weightCount = in.readUint32Big();
|
||||
u32 weightCount = in.ReadLong();
|
||||
for (int i = 0; i < std::min(3u, weightCount); ++i) {
|
||||
weights.emplace_back(in);
|
||||
}
|
||||
|
@ -62,5 +67,5 @@ auto StreamInSkinWeighting(CInputStream& in) {
|
|||
}
|
||||
|
||||
CVirtualBone::CVirtualBone(CInputStream& in)
|
||||
: x0_weights(StreamInSkinWeighting(in)), x1c_vertexCount(in.readUint32Big()) {}
|
||||
: x0_weights(StreamInSkinWeighting(in)), x1c_vertexCount(in.ReadLong()) {}
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -15,7 +15,7 @@ class CModel;
|
|||
struct SSkinWeighting {
|
||||
CSegId x0_id;
|
||||
float x4_weight;
|
||||
explicit SSkinWeighting(CInputStream& in) : x0_id(in), x4_weight(in.readFloatBig()) {}
|
||||
explicit SSkinWeighting(CInputStream& in) : x0_id(in), x4_weight(in.ReadFloat()) {}
|
||||
};
|
||||
|
||||
class CVirtualBone {
|
||||
|
|
|
@ -11,7 +11,7 @@ CSoundPOINode::CSoundPOINode()
|
|||
, x40_maxDist(0.f) {}
|
||||
|
||||
CSoundPOINode::CSoundPOINode(CInputStream& in)
|
||||
: CPOINode(in), x38_sfxId(in.readUint32Big()), x3c_falloff(in.readFloatBig()), x40_maxDist(in.readFloatBig()) {}
|
||||
: CPOINode(in), x38_sfxId(in.ReadLong()), x3c_falloff(in.ReadFloat()), x40_maxDist(in.ReadFloat()) {}
|
||||
|
||||
CSoundPOINode::CSoundPOINode(std::string_view name, EPOIType a, const CCharAnimTime& time, u32 b, bool c, float d,
|
||||
u32 e, u32 f, u32 sfxId, float falloff, float maxDist)
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace metaforce {
|
||||
|
||||
CTransition::CTransition(CInputStream& in)
|
||||
: x0_id(in.readUint32Big())
|
||||
, x4_animA(in.readUint32Big())
|
||||
, x8_animB(in.readUint32Big())
|
||||
: x0_id(in.ReadLong())
|
||||
, x4_animA(in.ReadLong())
|
||||
, x8_animB(in.ReadLong())
|
||||
, xc_trans(CMetaTransFactory::CreateMetaTrans(in)) {}
|
||||
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -538,14 +538,13 @@ CAreaOctTree::CAreaOctTree(const zeus::CAABox& aabb, Node::ETreeType treeType, c
|
|||
}
|
||||
|
||||
std::unique_ptr<CAreaOctTree> CAreaOctTree::MakeFromMemory(const u8* buf, unsigned int size) {
|
||||
athena::io::MemoryReader r(buf + 8, size - 8);
|
||||
r.readUint32Big();
|
||||
r.readUint32Big();
|
||||
zeus::CAABox aabb;
|
||||
aabb.readBoundingBoxBig(r);
|
||||
Node::ETreeType nodeType = Node::ETreeType(r.readUint32Big());
|
||||
u32 treeSize = r.readUint32Big();
|
||||
const u8* cur = reinterpret_cast<const u8*>(buf) + 8 + r.position();
|
||||
CMemoryInStream r(buf + 8, size - 8, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
r.ReadLong();
|
||||
r.ReadLong();
|
||||
zeus::CAABox aabb = r.Get<zeus::CAABox>();
|
||||
Node::ETreeType nodeType = Node::ETreeType(r.ReadLong());
|
||||
u32 treeSize = r.ReadLong();
|
||||
const u8* cur = reinterpret_cast<const u8*>(buf) + 8 + r.GetReadPosition();
|
||||
|
||||
const u8* treeBuf = cur;
|
||||
cur += treeSize;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace metaforce {
|
|||
constexpr CCollisionPrimitive::Type sType(CCollidableOBBTreeGroup::SetStaticTableIndex, "CCollidableOBBTreeGroup");
|
||||
|
||||
CCollidableOBBTreeGroupContainer::CCollidableOBBTreeGroupContainer(CInputStream& in) {
|
||||
const u32 treeCount = in.readUint32Big();
|
||||
const u32 treeCount = in.ReadLong();
|
||||
x0_trees.reserve(treeCount);
|
||||
|
||||
for (u32 i = 0; i < treeCount; i++) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "Runtime/Collision/CCollisionEdge.hpp"
|
||||
#include "Runtime/CInputStream.hpp"
|
||||
|
||||
namespace metaforce {
|
||||
CCollisionEdge::CCollisionEdge(CInputStream& in) {
|
||||
x0_index1 = in.readUint16Big();
|
||||
x2_index2 = in.readUint16Big();
|
||||
x0_index1 = in.ReadShort();
|
||||
x2_index2 = in.ReadShort();
|
||||
}
|
||||
} // namespace metaforce
|
||||
|
|
|
@ -100,7 +100,7 @@ bool CCollisionResponseData::CheckAndAddDecalToResponse(FourCC clsId, CInputStre
|
|||
return true;
|
||||
}
|
||||
|
||||
const CAssetId id{u64(in.readUint32Big())};
|
||||
const CAssetId id = in.Get<CAssetId>();
|
||||
if (!id.IsValid()) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,16 +41,16 @@ constexpr std::array<u16, 36> DefaultSurfaceIndices{
|
|||
};
|
||||
|
||||
/* This is exactly what retro did >.< */
|
||||
u32 verify_deaf_babe(CInputStream& in) { return in.readUint32Big(); }
|
||||
u32 verify_deaf_babe(CInputStream& in) { return in.ReadLong(); }
|
||||
|
||||
/* This is exactly what retro did >.< */
|
||||
u32 verify_version(CInputStream& in) { return in.readUint32Big(); }
|
||||
u32 verify_version(CInputStream& in) { return in.ReadLong(); }
|
||||
} // Anonymous namespace
|
||||
|
||||
COBBTree::COBBTree(CInputStream& in)
|
||||
: x0_magic(verify_deaf_babe(in))
|
||||
, x4_version(verify_version(in))
|
||||
, x8_memsize(in.readUint32())
|
||||
, x8_memsize(in.ReadLong())
|
||||
, x18_indexData(in)
|
||||
, x88_root(std::make_unique<CNode>(in)) {}
|
||||
|
||||
|
@ -158,38 +158,38 @@ zeus::CAABox COBBTree::CalculateAABox(const zeus::CTransform& xf) const {
|
|||
}
|
||||
|
||||
COBBTree::SIndexData::SIndexData(CInputStream& in) {
|
||||
u32 count = in.readUint32Big();
|
||||
u32 count = in.ReadLong();
|
||||
x0_materials.reserve(count);
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x0_materials.emplace_back(in.readUint32Big());
|
||||
x0_materials.emplace_back(in.ReadLong());
|
||||
}
|
||||
|
||||
count = in.readUint32Big();
|
||||
count = in.ReadLong();
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x10_vertMaterials.emplace_back(in.readUByte());
|
||||
x10_vertMaterials.emplace_back(in.ReadUint8());
|
||||
}
|
||||
count = in.readUint32Big();
|
||||
count = in.ReadLong();
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x20_edgeMaterials.emplace_back(in.readUByte());
|
||||
x20_edgeMaterials.emplace_back(in.ReadUint8());
|
||||
}
|
||||
count = in.readUint32Big();
|
||||
count = in.ReadLong();
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x30_surfaceMaterials.emplace_back(in.readUByte());
|
||||
x30_surfaceMaterials.emplace_back(in.ReadUint8());
|
||||
}
|
||||
|
||||
count = in.readUint32Big();
|
||||
count = in.ReadLong();
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x40_edges.emplace_back(in);
|
||||
}
|
||||
|
||||
count = in.readUint32Big();
|
||||
count = in.ReadLong();
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x50_surfaceIndices.emplace_back(in.readUint16Big());
|
||||
x50_surfaceIndices.emplace_back(in.ReadShort());
|
||||
}
|
||||
|
||||
count = in.readUint32Big();
|
||||
count = in.ReadLong();
|
||||
for (u32 i = 0; i < count; i++) {
|
||||
x60_vertices.emplace_back(zeus::CVector3f::ReadBig(in));
|
||||
x60_vertices.emplace_back(in.Get<zeus::CVector3f>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,8 +202,8 @@ COBBTree::CNode::CNode(const zeus::CTransform& xf, const zeus::CVector3f& point,
|
|||
, x48_leaf(std::move(leaf)) {}
|
||||
|
||||
COBBTree::CNode::CNode(CInputStream& in) {
|
||||
x0_obb = zeus::COBBox::ReadBig(in);
|
||||
x3c_isLeaf = in.readBool();
|
||||
x0_obb = in.Get<zeus::COBBox>();
|
||||
x3c_isLeaf = in.ReadBool();
|
||||
if (x3c_isLeaf)
|
||||
x48_leaf = std::make_unique<CLeafData>(in);
|
||||
else {
|
||||
|
@ -236,9 +236,9 @@ size_t COBBTree::CLeafData::GetMemoryUsage() const {
|
|||
}
|
||||
|
||||
COBBTree::CLeafData::CLeafData(CInputStream& in) {
|
||||
const u32 edgeCount = in.readUint32Big();
|
||||
const u32 edgeCount = in.ReadLong();
|
||||
for (u32 i = 0; i < edgeCount; i++) {
|
||||
x0_surface.emplace_back(in.readUint16Big());
|
||||
x0_surface.emplace_back(in.ReadShort());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -253,16 +253,16 @@ void CCubeModel::MakeTexturesFromMats(const u8* ptr, std::vector<TCachedToken<CT
|
|||
|
||||
#pragma region CCubeSurface
|
||||
CCubeSurface::CCubeSurface(u8* ptr) : x0_data(ptr) {
|
||||
CMemoryInStream mem(ptr, 10000); // Oversized so we can read everything in
|
||||
x0_center.readBig(mem);
|
||||
xc_materialIndex = mem.readUint32Big();
|
||||
x10_displayListSize = mem.readUint32Big();
|
||||
x14_parent = reinterpret_cast<CCubeModel*>(mem.readUint32Big());
|
||||
x18_nextSurface = reinterpret_cast<CCubeSurface*>(mem.readUint32Big());
|
||||
x1c_extraSize = mem.readUint32Big();
|
||||
x20_normal.readBig(mem);
|
||||
CMemoryInStream mem(ptr, 10000, CMemoryInStream::EOwnerShip::NotOwned); // Oversized so we can read everything in
|
||||
x0_center = mem.Get<zeus::CVector3f>();
|
||||
xc_materialIndex = mem.ReadLong();
|
||||
x10_displayListSize = mem.ReadLong();
|
||||
x14_parent = reinterpret_cast<CCubeModel*>(mem.ReadLong());
|
||||
x18_nextSurface = reinterpret_cast<CCubeSurface*>(mem.ReadLong());
|
||||
x1c_extraSize = mem.ReadLong();
|
||||
x20_normal = mem.Get<zeus::CVector3f>();
|
||||
if (x1c_extraSize > 0) {
|
||||
x2c_bounds = zeus::CAABox::ReadBoundingBoxBig(mem);
|
||||
x2c_bounds = mem.Get<zeus::CAABox>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ class CGraphicsPalette {
|
|||
public:
|
||||
explicit CGraphicsPalette(EPaletteFormat fmt, int count)
|
||||
: x0_fmt(fmt), x8_entryCount(count), xc_entries(new u16[count]) {}
|
||||
explicit CGraphicsPalette(CInputStream& in) : x0_fmt(EPaletteFormat(in.readUint32Big())) {
|
||||
u16 w = in.readUint16Big();
|
||||
u16 h = in.readUint16Big();
|
||||
explicit CGraphicsPalette(CInputStream& in) : x0_fmt(EPaletteFormat(in.ReadLong())) {
|
||||
u16 w = in.ReadShort();
|
||||
u16 h = in.ReadShort();
|
||||
x8_entryCount = w * h;
|
||||
|
||||
/* GX Tlut init here */
|
||||
|
|
|
@ -5,16 +5,16 @@ namespace metaforce {
|
|||
|
||||
CPVSAreaSet::CPVSAreaSet(const u8* data, u32 len) {
|
||||
CMemoryInStream r(data, len);
|
||||
x0_numFeatures = r.readUint32Big();
|
||||
x4_numLights = r.readUint32Big();
|
||||
x8_num2ndLights = r.readUint32Big();
|
||||
xc_numActors = r.readUint32Big();
|
||||
x10_leafSize = r.readUint32Big();
|
||||
x14_lightIndexCount = r.readUint32Big();
|
||||
x0_numFeatures = r.ReadLong();
|
||||
x4_numLights = r.ReadLong();
|
||||
x8_num2ndLights = r.ReadLong();
|
||||
xc_numActors = r.ReadLong();
|
||||
x10_leafSize = r.ReadLong();
|
||||
x14_lightIndexCount = r.ReadLong();
|
||||
x18_entityIndex.reserve(xc_numActors);
|
||||
for (u32 i = 0; i < xc_numActors; ++i)
|
||||
x18_entityIndex.push_back(r.readUint32Big());
|
||||
x1c_lightLeaves = data + r.position();
|
||||
x18_entityIndex.push_back(r.ReadLong());
|
||||
x1c_lightLeaves = data + r.GetReadPosition();
|
||||
const u8* octreeData = x1c_lightLeaves + x14_lightIndexCount * x10_leafSize;
|
||||
x20_octree = CPVSVisOctree::MakePVSVisOctree(octreeData);
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ namespace metaforce {
|
|||
|
||||
CPVSVisOctree CPVSVisOctree::MakePVSVisOctree(const u8* data) {
|
||||
CMemoryInStream r(data, 68);
|
||||
const zeus::CAABox aabb = zeus::CAABox::ReadBoundingBoxBig(r);
|
||||
const u32 numObjects = r.readUint32Big();
|
||||
const u32 numLights = r.readUint32Big();
|
||||
r.readUint32Big();
|
||||
return CPVSVisOctree(aabb, numObjects, numLights, data + r.position());
|
||||
const zeus::CAABox aabb = r.Get<zeus::CAABox>();
|
||||
const u32 numObjects = r.ReadLong();
|
||||
const u32 numLights = r.ReadLong();
|
||||
r.ReadLong();
|
||||
return CPVSVisOctree(aabb, numObjects, numLights, data + r.GetReadPosition());
|
||||
}
|
||||
|
||||
CPVSVisOctree::CPVSVisOctree(const zeus::CAABox& aabb, u32 numObjects, u32 numLights, const u8* c)
|
||||
|
|
|
@ -92,7 +92,7 @@ void CTexture::BuildI4FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < std::min(h, 8); ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u8, 4> source;
|
||||
in.readBytesToBuf(source.data(), std::min(size_t(w) / 4, source.size()));
|
||||
in.Get(source.data(), std::min(size_t(w) / 4, source.size()));
|
||||
for (size_t x = 0; x < std::min(w, 8); ++x) {
|
||||
target[x].r = Convert4To8(source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf);
|
||||
target[x].g = target[x].r;
|
||||
|
@ -132,7 +132,7 @@ void CTexture::BuildI8FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u8, 8> source;
|
||||
in.readBytesToBuf(source.data(), source.size());
|
||||
in.Get(source.data(), source.size());
|
||||
for (size_t x = 0; x < source.size(); ++x) {
|
||||
target[x].r = source[x];
|
||||
target[x].g = source[x];
|
||||
|
@ -172,7 +172,7 @@ void CTexture::BuildIA4FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u8, 8> source;
|
||||
in.readBytesToBuf(source.data(), source.size());
|
||||
in.Get(source.data(), source.size());
|
||||
for (size_t x = 0; x < source.size(); ++x) {
|
||||
const u8 intensity = Convert4To8(source[x] >> 4 & 0xf);
|
||||
target[x].r = intensity;
|
||||
|
@ -213,7 +213,7 @@ void CTexture::BuildIA8FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u16, 4> source;
|
||||
in.readBytesToBuf(source.data(), sizeof(source));
|
||||
in.Get(reinterpret_cast<u8*>(source.data()), sizeof(source));
|
||||
for (size_t x = 0; x < source.size(); ++x) {
|
||||
const u8 intensity = source[x] >> 8;
|
||||
target[x].r = intensity;
|
||||
|
@ -243,27 +243,27 @@ static std::vector<RGBA8> DecodePalette(int numEntries, CInputStream& in) {
|
|||
|
||||
enum class EPaletteType { IA8, RGB565, RGB5A3 };
|
||||
|
||||
EPaletteType format = EPaletteType(in.readUint32Big());
|
||||
in.readUint32Big();
|
||||
EPaletteType format = EPaletteType(in.ReadLong());
|
||||
in.ReadLong();
|
||||
switch (format) {
|
||||
case EPaletteType::IA8: {
|
||||
for (int e = 0; e < numEntries; ++e) {
|
||||
u8 intensity = in.readUByte();
|
||||
u8 alpha = in.readUByte();
|
||||
u8 intensity = in.ReadUint8();
|
||||
u8 alpha = in.ReadUint8();
|
||||
ret.push_back({intensity, intensity, intensity, alpha});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EPaletteType::RGB565: {
|
||||
for (int e = 0; e < numEntries; ++e) {
|
||||
u16 texel = in.readUint16Big();
|
||||
u16 texel = in.ReadShort();
|
||||
ret.push_back({Convert5To8(texel >> 11 & 0x1f), Convert6To8(texel >> 5 & 0x3f), Convert5To8(texel & 0x1f), 0xff});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EPaletteType::RGB5A3: {
|
||||
for (int e = 0; e < numEntries; ++e) {
|
||||
u16 texel = in.readUint16Big();
|
||||
u16 texel = in.ReadShort();
|
||||
if (texel & 0x8000) {
|
||||
ret.push_back(
|
||||
{Convert5To8(texel >> 10 & 0x1f), Convert5To8(texel >> 5 & 0x1f), Convert5To8(texel & 0x1f), 0xff});
|
||||
|
@ -296,7 +296,7 @@ void CTexture::BuildC4FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 8; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u8, 4> source;
|
||||
in.readBytesToBuf(source.data(), source.size());
|
||||
in.Get(source.data(), source.size());
|
||||
for (size_t x = 0; x < 8; ++x) {
|
||||
target[x] = palette[source[x / 2] >> ((x & 1) ? 0 : 4) & 0xf];
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ void CTexture::BuildC8FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u8, 8> source;
|
||||
in.readBytesToBuf(source.data(), source.size());
|
||||
in.Get(source.data(), source.size());
|
||||
for (size_t x = 0; x < source.size(); ++x) {
|
||||
target[x] = palette[source[x]];
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ void CTexture::BuildRGB565FromGCN(CInputStream& in, aurora::zstring_view label)
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
for (size_t x = 0; x < 4; ++x) {
|
||||
const u16 texel = in.readUint16Big();
|
||||
const u16 texel = in.ReadShort();
|
||||
target[x].r = Convert5To8(texel >> 11 & 0x1f);
|
||||
target[x].g = Convert6To8(texel >> 5 & 0x3f);
|
||||
target[x].b = Convert5To8(texel & 0x1f);
|
||||
|
@ -414,7 +414,7 @@ void CTexture::BuildRGB5A3FromGCN(CInputStream& in, aurora::zstring_view label)
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
for (size_t x = 0; x < 4; ++x) {
|
||||
const u16 texel = in.readUint16Big();
|
||||
const u16 texel = in.ReadShort();
|
||||
if ((texel & 0x8000) != 0) {
|
||||
target[x].r = Convert5To8(texel >> 10 & 0x1f);
|
||||
target[x].g = Convert5To8(texel >> 5 & 0x1f);
|
||||
|
@ -461,7 +461,7 @@ void CTexture::BuildRGBA8FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 4; ++y) {
|
||||
RGBA8* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<u8, 8> source;
|
||||
in.readBytesToBuf(source.data(), source.size());
|
||||
in.Get(source.data(), source.size());
|
||||
for (size_t x = 0; x < 4; ++x) {
|
||||
if (c != 0) {
|
||||
target[x].g = source[x * 2];
|
||||
|
@ -505,7 +505,7 @@ void CTexture::BuildDXT1FromGCN(CInputStream& in, aurora::zstring_view label) {
|
|||
for (int y = 0; y < 2; ++y) {
|
||||
DXT1Block* target = targetMip + (baseY + y) * w + baseX;
|
||||
std::array<DXT1Block, 2> source;
|
||||
in.readBytesToBuf(source.data(), sizeof(source));
|
||||
in.Get(reinterpret_cast<u8*>(source.data()), sizeof(source));
|
||||
for (size_t x = 0; x < source.size(); ++x) {
|
||||
target[x].color1 = hecl::SBig(source[x].color1);
|
||||
target[x].color2 = hecl::SBig(source[x].color2);
|
||||
|
@ -715,11 +715,11 @@ CTexture::CTexture(ETexelFormat fmt, s16 w, s16 h, s32 mips) : x0_fmt(fmt), x4_w
|
|||
CTexture::CTexture(std::unique_ptr<u8[]>&& in, u32 length, bool otex, const CTextureInfo* inf, CAssetId id)
|
||||
: m_textureInfo(inf) {
|
||||
std::unique_ptr<u8[]> owned = std::move(in);
|
||||
athena::io::MemoryReader r(owned.get(), length);
|
||||
x0_fmt = ETexelFormat(r.readUint32Big());
|
||||
x4_w = r.readUint16Big();
|
||||
x6_h = r.readUint16Big();
|
||||
x8_mips = r.readUint32Big();
|
||||
CMemoryInStream r(owned.get(), length, CMemoryInStream::EOwnerShip::NotOwned);
|
||||
x0_fmt = ETexelFormat(r.ReadLong());
|
||||
x4_w = r.ReadShort();
|
||||
x6_h = r.ReadShort();
|
||||
x8_mips = r.ReadLong();
|
||||
|
||||
auto label = fmt::format(FMT_STRING("TXTR {:08X} ({})"), id.Value(), TextureFormatString(x0_fmt));
|
||||
switch (x0_fmt) {
|
||||
|
|
|
@ -142,7 +142,7 @@ void CAuiEnergyBarT01::SetMaxEnergy(float maxEnergy) {
|
|||
|
||||
std::shared_ptr<CGuiWidget> CAuiEnergyBarT01::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) {
|
||||
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
|
||||
CAssetId tex = in.readUint32Big();
|
||||
CAssetId tex = in.ReadLong();
|
||||
std::shared_ptr<CGuiWidget> ret = std::make_shared<CAuiEnergyBarT01>(parms, sp, tex);
|
||||
ret->ParseBaseInfo(frame, in, parms);
|
||||
return ret;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue