Skip to content

Commit

Permalink
Added ctype for texture and header into file config
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed Feb 17, 2024
1 parent b964a4d commit 32f3d32
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/Companion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ void Companion::ParseCurrentFileConfig(YAML::Node node) {
SPDLOG_DEBUG("Segment {} replaced with 0x{:X}", id, replacement);
}
}
if(node["header"]) {
for(auto line = node["header"].begin(); line != node["header"].end(); ++line) {
this->gFileHeader += line->as<std::string>() + "\n";
}
}
}

void Companion::Process() {
Expand Down Expand Up @@ -329,6 +334,7 @@ void Companion::Process() {
// Stupid hack because the iteration broke the assets
root = YAML::LoadFile(yamlPath);
this->gConfig.segment.local.clear();
this->gFileHeader.clear();

if(root[":config"]) {
this->ParseCurrentFileConfig(root[":config"]);
Expand Down Expand Up @@ -389,7 +395,7 @@ void Companion::Process() {
break;
}
case ExportType::Code: {
output += "/root.inc.c";
output += "/bin.c";
break;
}
default: break;
Expand Down Expand Up @@ -456,6 +462,9 @@ void Companion::Process() {
file << buffer;
file << std::endl << "#endif" << std::endl;
} else {
if(!this->gFileHeader.empty()) {
file << this->gFileHeader << std::endl;
}
file << buffer;
}

Expand Down
1 change: 1 addition & 0 deletions src/Companion.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class Companion {

// Temporal Variables
std::string gCurrentFile;
std::string gFileHeader;
std::variant<std::vector<std::string>, std::string> gWriteOrder;
std::unordered_map<std::string, std::shared_ptr<BaseFactory>> gFactories;
std::map<std::string, std::map<std::string, std::pair<YAML::Node, bool>>> gAssetDependencies;
Expand Down
6 changes: 5 additions & 1 deletion src/factories/TextureFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ void TextureCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedDat
if (Companion::Instance->GetGBIMinorVersion() == GBIMinorVersion::Mk64) {
write << "u8 " << symbol << "[] = {\n";
} else {
write << "ALIGNED8 static const u8 " << symbol << "[] = {\n";
if(node["ctype"]) {
write << node["ctype"].as<std::string>() << " " << symbol << "[] = {\n";
} else {
write << "static const u8 " << symbol << "[] = {\n";
}
}
write << tab << "#include \"" << Companion::Instance->GetOutputPath() + "/" << (*replacement) << ".inc.c\"\n";
write << "};\n\n";
Expand Down

0 comments on commit 32f3d32

Please sign in to comment.