diff options
| author | petrie911 <69443847+petrie911@users.noreply.github.com> | 2024-03-14 15:50:01 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-14 14:50:01 -0600 |
| commit | a6face7240aaa2a95656143069c6c1de96a1ea98 (patch) | |
| tree | 4033df471b07d10b6e3f4a11b375b5da9eae54a8 | |
| parent | 70568034c212d432a1c3aaed013977a69e9ec998 (diff) | |
ObjInit can now make header entries (#42)
* 3D
* and env
* so much to fix
* Everything can be solved with triangles
* fixes
* initfix
| -rw-r--r-- | src/factories/sf64/ObjInitFactory.cpp | 11 | ||||
| -rw-r--r-- | src/factories/sf64/ObjInitFactory.h | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/factories/sf64/ObjInitFactory.cpp b/src/factories/sf64/ObjInitFactory.cpp index 8894036..a2e42eb 100644 --- a/src/factories/sf64/ObjInitFactory.cpp +++ b/src/factories/sf64/ObjInitFactory.cpp @@ -5,6 +5,17 @@ #define NUM(x, w) std::dec << std::setfill(' ') << std::setw(w) << x #define FLOAT(x, w) std::dec << std::setfill(' ') << std::setw(w) << std::fixed << std::setprecision(1) << x << "f" +void SF64::ObjInitHeaderExporter::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; + } + + write << "extern ObjectInit " << symbol << "[];\n"; +} + void SF64::ObjInitCodeExporter::Export(std::ostream &write, std::shared_ptr<IParsedData> raw, std::string& entryName, YAML::Node &node, std::string* replacement ) { auto symbol = GetSafeNode(node, "symbol", entryName); auto offset = GetSafeNode<uint32_t>(node, "offset"); diff --git a/src/factories/sf64/ObjInitFactory.h b/src/factories/sf64/ObjInitFactory.h index fcaff69..2abfab5 100644 --- a/src/factories/sf64/ObjInitFactory.h +++ b/src/factories/sf64/ObjInitFactory.h @@ -21,6 +21,10 @@ public: explicit ObjInitData(std::vector<ObjectInit> objInit) : mObjInit(objInit) {} }; +class ObjInitHeaderExporter : public BaseExporter { + void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override; +}; + class ObjInitBinaryExporter : public BaseExporter { void Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override; }; @@ -37,6 +41,7 @@ public: } inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override { return { + REGISTER(Header, ObjInitHeaderExporter) REGISTER(Binary, ObjInitBinaryExporter) REGISTER(Code, ObjInitCodeExporter) }; |
