2022-04-04 05:12:17 +00:00
|
|
|
#include "dynos.cpp.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "include/level_misc_macros.h"
|
2024-04-17 17:02:28 +00:00
|
|
|
#include "game/moving_texture.h"
|
2022-04-04 05:12:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wnarrowing"
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Parsing //
|
|
|
|
/////////////
|
|
|
|
|
2022-04-12 05:56:44 +00:00
|
|
|
#define movtexqc_constant(x) if (_Arg == #x) { return (Movtex*) (x); }
|
2022-04-04 05:12:17 +00:00
|
|
|
static Movtex* ParseMovtexQCSymbolArg(GfxData* aGfxData, DataNode<MovtexQC>* aNode, u64 aTokenIndex) {
|
|
|
|
const String& _Arg = aNode->mTokens[aTokenIndex];
|
|
|
|
|
2022-04-12 05:54:36 +00:00
|
|
|
// Other constants
|
2022-04-12 05:56:44 +00:00
|
|
|
movtexqc_constant(NULL);
|
2022-04-12 05:54:36 +00:00
|
|
|
|
2022-04-04 05:12:17 +00:00
|
|
|
// Movtexs
|
|
|
|
for (auto& _Node : aGfxData->mMovtexs) {
|
|
|
|
if (_Arg == _Node->mName) {
|
|
|
|
return DynOS_Movtex_Parse(aGfxData, _Node, false)->mData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unknown
|
2023-05-19 11:20:08 +00:00
|
|
|
PrintDataError(" ERROR: Unknown movtexqc arg: %s", _Arg.begin());
|
2022-04-04 05:12:17 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_Parse(GfxData* aGfxData, DataNode<MovtexQC>* aNode) {
|
|
|
|
if (aNode->mData) return aNode;
|
|
|
|
|
|
|
|
// MovtexQC data
|
|
|
|
aNode->mSize = (u32) (aNode->mTokens.Count() / 2);
|
|
|
|
aNode->mData = New<MovtexQC>(aNode->mSize);
|
|
|
|
for (u32 i = 0; i != aNode->mSize; ++i) {
|
|
|
|
s16 id = (s16) aNode->mTokens[2 * i + 0].ParseInt();
|
|
|
|
Movtex* quadArraySegmented = ParseMovtexQCSymbolArg(aGfxData, aNode, 2 * i + 1);
|
|
|
|
aNode->mData[i] = { id, quadArraySegmented };
|
|
|
|
aGfxData->mPointerList.Add(aNode->mData[i].quadArraySegmented);
|
|
|
|
}
|
|
|
|
aNode->mLoadIndex = aGfxData->mLoadIndex++;
|
|
|
|
return aNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Writing //
|
|
|
|
/////////////
|
|
|
|
|
2022-06-25 07:52:53 +00:00
|
|
|
void DynOS_MovtexQC_Write(BinFile* aFile, GfxData* aGfxData, DataNode<MovtexQC> *aNode) {
|
2022-04-04 05:12:17 +00:00
|
|
|
if (!aNode->mData) return;
|
|
|
|
|
|
|
|
// Name
|
2022-06-25 07:52:53 +00:00
|
|
|
aFile->Write<u8>(DATA_TYPE_MOVTEXQC);
|
2022-04-04 05:12:17 +00:00
|
|
|
aNode->mName.Write(aFile);
|
|
|
|
|
|
|
|
// Data
|
2022-06-25 07:52:53 +00:00
|
|
|
aFile->Write<u32>(aNode->mSize);
|
2022-04-04 05:12:17 +00:00
|
|
|
for (u32 i = 0; i != aNode->mSize; ++i) {
|
2022-06-25 07:52:53 +00:00
|
|
|
aFile->Write<s16>(aNode->mData[i].id);
|
2022-04-04 05:12:17 +00:00
|
|
|
DynOS_Pointer_Write(aFile, (const void *) (aNode->mData[i].quadArraySegmented), aGfxData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Reading //
|
|
|
|
/////////////
|
|
|
|
|
2022-06-25 07:52:53 +00:00
|
|
|
DataNode<MovtexQC>* DynOS_MovtexQC_Load(BinFile *aFile, GfxData *aGfxData) {
|
2022-04-04 05:12:17 +00:00
|
|
|
DataNode<MovtexQC> *_Node = New<DataNode<MovtexQC>>();
|
|
|
|
|
|
|
|
// Name
|
|
|
|
_Node->mName.Read(aFile);
|
|
|
|
|
|
|
|
// Data
|
2022-06-25 07:52:53 +00:00
|
|
|
_Node->mSize = aFile->Read<u32>();
|
2022-04-04 05:12:17 +00:00
|
|
|
_Node->mData = New<MovtexQC>(_Node->mSize);
|
|
|
|
for (u32 i = 0; i != _Node->mSize; ++i) {
|
2022-06-25 07:52:53 +00:00
|
|
|
_Node->mData[i].id = aFile->Read<s16>();
|
|
|
|
u32 _Value = aFile->Read<u32>();
|
2022-05-04 07:14:33 +00:00
|
|
|
void *_Ptr = DynOS_Pointer_Load(aFile, aGfxData, _Value, &_Node->mFlags);
|
2022-04-04 05:12:17 +00:00
|
|
|
_Node->mData[i].quadArraySegmented = (Movtex*)_Ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add it
|
|
|
|
if (aGfxData != NULL) {
|
|
|
|
aGfxData->mMovtexQCs.Add(_Node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _Node;
|
|
|
|
}
|