#pragma once #include "input/InputSource.h" #include "GcmDisc.h" #include #include #include #include #include namespace GC { struct Window { uint32_t segment; uint32_t imageOffset; uint32_t size; }; class GameCubeInput : public InputSource { public: explicit GameCubeInput(std::shared_ptr disc) : mDisc(std::move(disc)) {} static std::shared_ptr FromPath(const std::filesystem::path& path); static std::shared_ptr FromMemory(std::vector& data); void Open() override; void Build(YAML::Node& rom) override; std::string GetHash() override { return mDolHash; } std::string GetTitle() override { return mTitle; } uint32_t GetVersionCRC() override { return mVersionCRC; } std::vector& GetImage() override { return mImage; } void LogInfo() override; const std::vector& GetWindows() const { return mWindows; } const std::unordered_map& GetRelHashSemantics() const { return mRelHashSemantics; } private: struct Placement { uint32_t segment; uint32_t offset; std::vector data; std::vector names; }; void PlaceDol(YAML::Node node, std::vector& out); void PlaceRel(YAML::Node node, std::vector& out); void PlaceFile(YAML::Node node, std::vector& out); void Assemble(std::vector& placements); std::shared_ptr mDisc; std::vector mDol; std::string mDolHash; std::string mTitle; uint8_t mRevision = 0; uint32_t mVersionCRC = 0; std::vector mImage; std::vector mWindows; std::unordered_map mRelHashSemantics; }; std::string Sha1Hex(const std::vector& data); } // namespace GC