2022-04-05 04:25:40 +00:00
|
|
|
#include "dynos.cpp.h"
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Parsing //
|
|
|
|
/////////////
|
|
|
|
|
|
|
|
DataNode<Ambient_t>* DynOS_AmbientT_Parse(GfxData* aGfxData, DataNode<Ambient_t>* aNode) {
|
|
|
|
if (aNode->mData) return aNode;
|
|
|
|
|
|
|
|
// Check tokens count
|
|
|
|
if (aNode->mTokens.Count() < 8) {
|
2023-05-19 11:20:08 +00:00
|
|
|
PrintDataError(" ERROR: %s: not enough data", aNode->mName.begin());
|
2022-04-05 04:25:40 +00:00
|
|
|
return aNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse data tokens
|
|
|
|
u8 cr = (u8) aNode->mTokens[0].ParseInt();
|
|
|
|
u8 cg = (u8) aNode->mTokens[1].ParseInt();
|
|
|
|
u8 cb = (u8) aNode->mTokens[2].ParseInt();
|
|
|
|
u8 c2r = (u8) aNode->mTokens[4].ParseInt();
|
|
|
|
u8 c2g = (u8) aNode->mTokens[5].ParseInt();
|
|
|
|
u8 c2b = (u8) aNode->mTokens[6].ParseInt();
|
|
|
|
aNode->mData = New<Ambient_t>();
|
|
|
|
*aNode->mData = {
|
|
|
|
{ cr, cg, cb}, 0,
|
|
|
|
{ c2r, c2g, c2b}, 0
|
|
|
|
};
|
|
|
|
aNode->mLoadIndex = aGfxData->mLoadIndex++;
|
|
|
|
return aNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Writing //
|
|
|
|
/////////////
|
|
|
|
|
2022-06-25 07:52:53 +00:00
|
|
|
void DynOS_AmbientT_Write(BinFile* aFile, GfxData* aGfxData, DataNode<Ambient_t> *aNode) {
|
2022-04-05 04:25:40 +00:00
|
|
|
if (!aNode->mData) return;
|
|
|
|
|
|
|
|
// Header
|
2022-06-25 07:52:53 +00:00
|
|
|
aFile->Write<u8>(DATA_TYPE_AMBIENT_T);
|
2022-04-05 04:25:40 +00:00
|
|
|
aNode->mName.Write(aFile);
|
|
|
|
|
|
|
|
// Data
|
2022-06-25 07:52:53 +00:00
|
|
|
aFile->Write<Ambient_t>(*aNode->mData);
|
2022-04-05 04:25:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////
|
|
|
|
// Reading //
|
|
|
|
/////////////
|
|
|
|
|
2022-06-25 07:52:53 +00:00
|
|
|
void DynOS_AmbientT_Load(BinFile *aFile, GfxData *aGfxData) {
|
2022-04-05 04:25:40 +00:00
|
|
|
DataNode<Ambient_t> *_Node = New<DataNode<Ambient_t>>();
|
|
|
|
|
|
|
|
// Name
|
|
|
|
_Node->mName.Read(aFile);
|
|
|
|
|
|
|
|
// Data
|
2023-05-13 09:42:35 +00:00
|
|
|
// HACK: allocate for Light_t size due to PC port rendering all ambients as lights
|
|
|
|
_Node->mData = (Ambient_t*)New<Light_t>();
|
2022-06-25 07:52:53 +00:00
|
|
|
*_Node->mData = aFile->Read<Ambient_t>();
|
2022-04-05 04:25:40 +00:00
|
|
|
|
|
|
|
// Append
|
|
|
|
aGfxData->mAmbientTs.Add(_Node);
|
|
|
|
}
|