#pragma once #include #include #include #include #include #include #include #include "factories/BaseFactory.h" #include "n64/Cartridge.h" class SWrapper; namespace fs = std::filesystem; enum class GBIVersion { f3d, f3dex, f3db, f3dex2, f3dexb, }; enum class GBIMinorVersion { None, Mk64, }; class Companion { public: static Companion* Instance; explicit Companion(std::filesystem::path rom, bool otr, bool debug) : gRomPath(std::move(rom)), gOTRMode(otr), gIsDebug(debug) {} void Init(ExportType type); void Process(); bool IsOTRMode() { return this->gOTRMode; } bool IsDebug() { return this->gIsDebug; } N64::Cartridge* GetCartridge() { return this->gCartridge; } std::vector GetRomData() { return this->gRomData; } std::string GetOutputPath() { return this->gOutputPath; } GBIVersion GetGBIVersion() { return this->gGBIVersion; } GBIMinorVersion GetGBIMinorVersion() { return this->gGBIMinorVersion; } std::optional GetSegmentedAddr(uint8_t segment); std::optional> GetNodeByAddr(uint32_t addr); std::optional> GetFactory(const std::string& type); static void Pack(const std::string& folder, const std::string& output); std::string NormalizeAsset(const std::string& name) const; void RegisterAsset(const std::string& name, YAML::Node& node); private: bool gOTRMode = false; bool gIsDebug = false; GBIVersion gGBIVersion = GBIVersion::f3d; GBIMinorVersion gGBIMinorVersion = GBIMinorVersion::None; std::string gOutputPath; std::string gCurrentFile; ExportType gExporterType; fs::path gCurrentDirectory; N64::Cartridge* gCartridge; std::vector gRomData; std::filesystem::path gRomPath; std::vector gSegments; std::variant, std::string> gWriteOrder; std::unordered_map> gFactories; std::map>> gAssetDependencies; std::map>>> gWriteMap; std::unordered_map>> gAddrMap; void RegisterFactory(const std::string& type, const std::shared_ptr& factory); void ExtractNode(YAML::Node& node, std::string& name, SWrapper* binary); };