diff options
| author | Lywx <kiritodev01@gmail.com> | 2024-03-20 21:17:11 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 21:17:11 -0600 |
| commit | f0c70f855a892ca7dc21cee4b4037dad983adb8f (patch) | |
| tree | f15cc271b00166476a2e7b780e50d911770a7316 /src/factories/DisplayListFactory.cpp | |
| parent | 8465919ab7aba6cfde7d25ad1731673e5da01642 (diff) | |
Auto pad and overlap detection (#47)
* Fully implemented pad and overlap detection
* Cleaned code, fixed pad generation and added alignment
* Added debug size on pads
Diffstat (limited to 'src/factories/DisplayListFactory.cpp')
| -rw-r--r-- | src/factories/DisplayListFactory.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/factories/DisplayListFactory.cpp b/src/factories/DisplayListFactory.cpp index c001049..8f55f3e 100644 --- a/src/factories/DisplayListFactory.cpp +++ b/src/factories/DisplayListFactory.cpp @@ -64,18 +64,19 @@ void GFXDSetGBIVersion(){ } } -void DListHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) { +ExportResult DListHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) { const auto symbol = GetSafeNode(node, "symbol", entryName); if(Companion::Instance->IsOTRMode()){ write << "static const char " << symbol << "[] = \"__OTR__" << (*replacement) << "\";\n\n"; - return; + return std::nullopt; } write << "extern Gfx " << symbol << "[];\n"; + return std::nullopt; } -void DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { +ExportResult DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { const auto cmds = std::static_pointer_cast<DListData>(raw)->mGfxs; const auto symbol = GetSafeNode(node, "symbol", entryName); auto offset = GetSafeNode<uint32_t>(node, "offset"); @@ -125,18 +126,13 @@ void DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> write << std::string(out); write << "};\n"; + const auto sz = (sizeof(uint32_t) * cmds.size()); if (Companion::Instance->IsDebug()) { - const auto sz = (sizeof(uint32_t) * cmds.size()); - write << "// count: " << std::to_string(sz / 8) << " Gfx\n"; - if (IS_SEGMENTED(offset)) { - offset = SEGMENT_OFFSET(offset); - } - write << "// 0x" << std::hex << std::uppercase << (offset + sz) << "\n"; } - write << "\n"; + return (IS_SEGMENTED(offset) ? SEGMENT_OFFSET(offset) : offset) + sz; } void DebugDisplayList(uint32_t w0, uint32_t w1){ @@ -181,7 +177,7 @@ std::optional<std::tuple<std::string, YAML::Node>> SearchVtx(uint32_t ptr){ return std::nullopt; } -void DListBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { +ExportResult DListBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { auto cmds = std::static_pointer_cast<DListData>(raw)->mGfxs; auto writer = LUS::BinaryWriter(); |
