From 951e84d97d15204bbae2fcb036dc57eaaf4039ae Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sun, 10 Mar 2024 16:09:20 -0600 Subject: Replaced displaylists and vertices with size:, and added debug for textures --- src/factories/DisplayListFactory.cpp | 7 +++---- src/factories/TextureFactory.cpp | 23 ++++++++++++++++++++++- src/factories/VtxFactory.cpp | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp index 4d9360f..caaa87a 100644 --- a/src/factories/DisplayListFactory.cpp +++ b/src/factories/DisplayListFactory.cpp @@ -127,14 +127,13 @@ void DListCodeExporter::Export(std::ostream &write, std::shared_ptr write << "};\n"; if (Companion::Instance->IsDebug()) { + const auto sz = (sizeof(uint32_t) * cmds.size()); - std::string str = ((sizeof(uint32_t) * cmds.size()) / 8) == 1 ? " displaylist" : " displaylists"; - - write << "// " << std::hex << std::uppercase << ((sizeof(uint32_t) * cmds.size()) / 8) << str << "\n"; + write << "// size: 0x" << std::hex << std::uppercase << (sz / 8) << "\n"; if (IS_SEGMENTED(offset)) { offset = SEGMENT_OFFSET(offset); } - write << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(uint32_t) * (cmds.size()))) << "\n"; + write << "// 0x" << std::hex << std::uppercase << (offset + sz) << "\n"; } write << "\n"; diff --git a/src/factories/TextureFactory.cpp b/src/factories/TextureFactory.cpp index a9d0c44..7c9ec4f 100644 --- a/src/factories/TextureFactory.cpp +++ b/src/factories/TextureFactory.cpp @@ -6,6 +6,7 @@ extern "C" { #include "n64graphics/n64graphics.h" +#include "BaseFactory.h" } static const std::unordered_map gTextureFormats = { @@ -95,6 +96,7 @@ void TextureHeaderExporter::Export(std::ostream &write, std::shared_ptr raw, std::string& entryName, YAML::Node &node, std::string* replacement) { auto texture = std::static_pointer_cast(raw); auto data = texture->mBuffer; + auto offset = GetSafeNode(node, "offset"); auto symbol = GetSafeNode(node, "symbol", entryName); auto format = GetSafeNode(node, "format"); @@ -129,6 +131,13 @@ void TextureCodeExporter::Export(std::ostream &write, std::shared_ptrIsDebug()) { + if (IS_SEGMENTED(offset)) { + offset = SEGMENT_OFFSET(offset); + } + write << "// 0x" << std::hex << std::uppercase << offset << "\n"; + } + if (Companion::Instance->GetGBIMinorVersion() == GBIMinorVersion::Mk64) { write << "u8 " << symbol << "[] = {\n"; } else { @@ -139,7 +148,19 @@ void TextureCodeExporter::Export(std::ostream &write, std::shared_ptrGetOutputPath() + "/" << (*replacement) << ".inc.c\"\n"; - write << "};\n\n"; + write << "};\n"; + + if (Companion::Instance->IsDebug()) { + const auto sz = data.size(); + + write << "// size: 0x" << std::hex << std::uppercase << sz << "\n"; + if (IS_SEGMENTED(offset)) { + offset = SEGMENT_OFFSET(offset); + } + write << "// 0x" << std::hex << std::uppercase << (offset + sz) << "\n"; + } + + write << "\n"; } void TextureBinaryExporter::Export(std::ostream &write, std::shared_ptr raw, std::string& entryName, YAML::Node &node, std::string* replacement) { diff --git a/src/factories/VtxFactory.cpp b/src/factories/VtxFactory.cpp index 2c225f9..c0b06ea 100644 --- a/src/factories/VtxFactory.cpp +++ b/src/factories/VtxFactory.cpp @@ -61,7 +61,7 @@ void VtxCodeExporter::Export(std::ostream &write, std::shared_ptr r write << "};\n"; if (Companion::Instance->IsDebug()) { - write << "// " << vtx.size() << " vertices\n"; + write << "// size: " << vtx.size() << "\n"; write << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(VtxRaw) * vtx.size())) << "\n"; } -- cgit v1.2.3