Polished factories!

This commit is contained in:
KiritoDv
2024-03-11 00:05:16 -06:00
committed by Lywx
parent 1daff9dc0d
commit 4de8d6b8dc
3 changed files with 22 additions and 13 deletions
+20 -11
View File
@@ -80,7 +80,8 @@ std::vector<uint8_t> alloc_ia8_text_from_i1(uint16_t *in, int16_t width, int16_t
}
void TextureHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement) {
auto symbol = GetSafeNode(node, "symbol", entryName);
const auto symbol = GetSafeNode(node, "symbol", entryName);
const auto offset = GetSafeNode<uint32_t>(node, "offset");
auto data = std::static_pointer_cast<TextureData>(raw)->mBuffer;
if(Companion::Instance->IsOTRMode()){
@@ -88,10 +89,18 @@ void TextureHeaderExporter::Export(std::ostream &write, std::shared_ptr<IParsedD
return;
}
if(node["ctype"]) {
write << "extern " << node["ctype"].as<std::string>() << " " << symbol << "[];\n";
const auto searchTable = Companion::Instance->SearchTable(offset);
if(searchTable.has_value()){
const auto [name, start, end, mode] = searchTable.value();
if(start != offset){
return;
}
write << "extern " << GetSafeNode<std::string>(node, "ctype", "u8") << " " << name << "[][" << data.size() << "];\n";
} else {
write << "extern u8 " << symbol << "[];\n";
write << "extern " << GetSafeNode<std::string>(node, "ctype", "u8") << " " << symbol << "[];\n";
}
}
@@ -133,13 +142,6 @@ void TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedDat
file.close();
if (Companion::Instance->IsDebug()) {
if (IS_SEGMENTED(offset)) {
offset = SEGMENT_OFFSET(offset);
}
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
}
const auto searchTable = Companion::Instance->SearchTable(offset);
if(searchTable.has_value()){
@@ -161,6 +163,13 @@ void TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedDat
write << "};\n";
}
} else {
if (Companion::Instance->IsDebug()) {
if (IS_SEGMENTED(offset)) {
offset = SEGMENT_OFFSET(offset);
}
write << "// 0x" << std::hex << std::uppercase << offset << "\n";
}
write << GetSafeNode<std::string>(node, "ctype", "static const u8") << " " << symbol << "[] = {\n";
write << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << *replacement << ".inc.c\"\n";
+1 -1
View File
@@ -57,7 +57,7 @@ void SF64::MessageHeaderExporter::Export(std::ostream &write, std::shared_ptr<IP
return;
}
write << "extern Vtx " << symbol << "[];\n";
write << "extern u16 " << symbol << "[];\n";
}
void TextToStream(std::ostream& stream, int charCode) {
+1 -1
View File
@@ -47,7 +47,7 @@ void SF64::MessageLookupCodeExporter::Export(std::ostream &write, std::shared_pt
msgSymbol = GetSafeNode<std::string>(node, "symbol");
}
write << "{ " << m.id << ", " << msgSymbol << " }, ";
write << "{ " << m.id << std::dec << ", " << msgSymbol << " }, ";
}
write << "\n};\n";