2016-09-18 23:47:48 +00:00
|
|
|
#include "ATBL.hpp"
|
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
namespace DataSpec::DNAAudio
|
2016-09-18 23:47:48 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
bool ATBL::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
|
|
|
{
|
2018-05-19 05:16:08 +00:00
|
|
|
uint32_t idxCount = rs.readUint32Big();
|
2016-09-18 23:47:48 +00:00
|
|
|
athena::io::YAMLDocWriter w("ATBL");
|
2018-05-19 05:16:08 +00:00
|
|
|
for (uint32_t i=0 ; i<idxCount ; ++i)
|
2016-09-18 23:47:48 +00:00
|
|
|
{
|
|
|
|
uint16_t idx = rs.readUint16Big();
|
|
|
|
if (idx == 0xffff)
|
|
|
|
continue;
|
|
|
|
char iStr[16];
|
|
|
|
snprintf(iStr, 16, "0x%04X", int(i));
|
|
|
|
w.writeUint16(iStr, idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
athena::io::FileWriter fw(outPath.getAbsolutePath());
|
|
|
|
w.finish(&fw);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ATBL::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
|
|
|
|
{
|
|
|
|
athena::io::FileReader r(inPath.getAbsolutePath());
|
|
|
|
if (r.hasError())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
athena::io::YAMLDocReader dr;
|
|
|
|
if (!dr.parse(&r))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
unsigned long maxI = 0;
|
|
|
|
for (const auto& pair : dr.getRootNode()->m_mapChildren)
|
|
|
|
{
|
|
|
|
unsigned long i = strtoul(pair.first.c_str(), nullptr, 0);
|
|
|
|
maxI = std::max(maxI, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<uint16_t> vecOut;
|
|
|
|
vecOut.resize(maxI + 1, 0xffff);
|
|
|
|
|
|
|
|
for (const auto& pair : dr.getRootNode()->m_mapChildren)
|
|
|
|
{
|
|
|
|
unsigned long i = strtoul(pair.first.c_str(), nullptr, 0);
|
|
|
|
vecOut[i] = hecl::SBig(uint16_t(strtoul(pair.second->m_scalarString.c_str(), nullptr, 0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
athena::io::FileWriter w(outPath.getAbsolutePath());
|
|
|
|
if (w.hasError())
|
|
|
|
return false;
|
2018-05-19 05:16:08 +00:00
|
|
|
w.writeUint32Big(uint32_t(vecOut.size()));
|
2016-09-18 23:47:48 +00:00
|
|
|
w.writeBytes(vecOut.data(), vecOut.size() * 2);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|