Skip to content

Commit

Permalink
Update IsDebug (#25)
Browse files Browse the repository at this point in the history
Co-authored-by: = <=>
  • Loading branch information
MegaMech authored Mar 10, 2024
1 parent a2d735c commit c4bb1ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) {
gCurrentFileOffset = segments[0][1].as<uint32_t>();
gCurrentCompressionType = GetCompressionType(this->gRomData, gCurrentFileOffset);
} else {
throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [<segment>, <offset_of_compressed_file>]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]");
throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [<segment>, <file_offset>]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]");
}
}

Expand All @@ -232,7 +232,7 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) {
this->gConfig.segment.local[id] = replacement;
SPDLOG_DEBUG("Segment {} replaced with 0x{:X}", id, replacement);
} else {
throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [<segment>, <offset_of_compressed_file>]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]");
throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [<segment>, <file_offset>]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]");
}
}
}
Expand Down Expand Up @@ -414,7 +414,7 @@ void Companion::Process() {
gCurrentFileOffset = segments[0][1].as<uint32_t>();
gCurrentCompressionType = GetCompressionType(this->gRomData, gCurrentFileOffset);
} else {
throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [<segment>, <offset_of_compressed_file>]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]");
throw std::runtime_error("Incorrect yaml syntax for segments.\n\nThe yaml expects:\n:config:\n segments:\n - [<segment>, <file_offset>]\n\nLike so:\nsegments:\n - [0x06, 0x821D10]");
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion src/factories/DisplayListFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,20 @@ void DListCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData>
gfxd_execute();

write << std::string(out);
write << "}; // size = 0x" << std::hex << std::uppercase << (sizeof(uint32_t) * cmds.size()) << "\n\n";
write << "};\n";

if (Companion::Instance->IsDebug()) {

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";
if (IS_SEGMENTED(offset)) {
offset = SEGMENT_OFFSET(offset);
}
write << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(uint32_t) * (cmds.size()))) << "\n";
}

write << "\n";
}

void DebugDisplayList(uint32_t w0, uint32_t w1){
Expand Down
7 changes: 5 additions & 2 deletions src/factories/VtxFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ void VtxCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> r
write << "{{{" << NUM(x) << ", " << NUM(y) << ", " << NUM(z) << "}, " << flag << ", {" << NUM(tc1) << ", " << NUM(tc2) << "}, {" << COL(c1) << ", " << COL(c2) << ", " << COL(c3) << ", " << COL(c4) << "}}},\n";
}

write << "};\n";

if (Companion::Instance->IsDebug()) {
write << fourSpaceTab << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(VtxRaw) * vtx.size())) << "\n";
write << "// " << vtx.size() << " vertices\n";
write << "// 0x" << std::hex << std::uppercase << (offset + (sizeof(VtxRaw) * vtx.size())) << "\n";
}

write << "}; // size = 0x" << std::hex << std::uppercase << (sizeof(VtxRaw) * vtx.size()) << "\n\n";
write << "\n";
}

void VtxBinaryExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) {
Expand Down

0 comments on commit c4bb1ad

Please sign in to comment.