dmtools/progs/zalgo/main.cpp

35 lines
1.1 KiB
C++

// Copyright 2024 The DMBMX2Tools Authors
// SPDX-License-Identifier: MIT
#include <base/FourCC.hpp>
#include <base/io/FileStream.hpp>
#include <base/io/MemoryStream.hpp>
#include <dmbmx/ZiffInputStream.hpp>
int main(int argc, char** argv) {
auto fs = dmtools::io::FileStream {};
if(fs.Open("/data/sda/lily/games/dmbmx2/ps2/ASSETS/LEVELS/WOODWARD/WOODWARD.ZIT", dmtools::io::FileStream::OpenMode::Read)) {
auto ziffStream = dmtools::dmbmx::ZiffInputStream { fs, dmtools::FourCC<"FSCN">() };
ziffStream.SetChunkCallback([&](dmtools::dmbmx::ZiffInputStream::Chunk& chunk) {
auto stream = dmtools::io::MemoryStream { chunk.chunkData.data(), chunk.chunkData.size() };
auto terrStream = dmtools::dmbmx::ZiffInputStream { stream, dmtools::FourCC<"TERR">() };
terrStream.SetChunkCallback([&](auto& chunk) {
auto* gotBytes = std::bit_cast<u8*>(&chunk.chunkHeader.ckId);
std::printf("inner stream ckId '%c%c%c%c' with size %d\n",
gotBytes[0], gotBytes[1], gotBytes[2], gotBytes[3], chunk.chunkHeader.ckSz);
});
terrStream.Process();
});
ziffStream.Process();
} else {
printf("Failed to open io::FileStream\n");
}
return 0;
}