diff --git a/include/kabufuda/Directory.hpp b/include/kabufuda/Directory.hpp index de5fdf4..18cd252 100644 --- a/include/kabufuda/Directory.hpp +++ b/include/kabufuda/Directory.hpp @@ -15,9 +15,12 @@ class Directory { uint16_t m_checksum; uint16_t m_checksumInv; }; + + using RawData = std::array; + union { Data data; - std::array raw; + RawData raw; }; #pragma pack(pop) @@ -27,7 +30,7 @@ class Directory { public: Directory(); - Directory(uint8_t data[BlockSize]); + explicit Directory(const RawData& rawData); ~Directory() = default; bool hasFreeFile() const; diff --git a/include/kabufuda/File.hpp b/include/kabufuda/File.hpp index b7071a6..eb7d4d1 100644 --- a/include/kabufuda/File.hpp +++ b/include/kabufuda/File.hpp @@ -10,6 +10,8 @@ class File { friend class Directory; friend class Card; #pragma pack(push, 4) + using RawData = std::array; + union { struct { std::array m_game; @@ -28,7 +30,7 @@ class File { uint16_t m_reserved2; uint32_t m_commentAddr; }; - std::array raw; + RawData raw; }; #pragma pack(pop) @@ -36,8 +38,8 @@ class File { public: File(); - File(char data[0x40]); - File(const char* filename); + explicit File(const RawData& rawData); + explicit File(const char* filename); ~File() = default; }; } // namespace kabufuda diff --git a/lib/kabufuda/Directory.cpp b/lib/kabufuda/Directory.cpp index fb4e464..79ba813 100644 --- a/lib/kabufuda/Directory.cpp +++ b/lib/kabufuda/Directory.cpp @@ -35,7 +35,7 @@ Directory::Directory() { updateChecksum(); } -Directory::Directory(uint8_t data[]) { std::memcpy(raw.data(), data, BlockSize); } +Directory::Directory(const RawData& rawData) : raw{rawData} {} bool Directory::hasFreeFile() const { return std::any_of(data.m_files.cbegin(), data.m_files.cend(), diff --git a/lib/kabufuda/File.cpp b/lib/kabufuda/File.cpp index 2afd3ba..55349ae 100644 --- a/lib/kabufuda/File.cpp +++ b/lib/kabufuda/File.cpp @@ -8,7 +8,7 @@ namespace kabufuda { File::File() { raw.fill(0xFF); } -File::File(char data[]) { std::memcpy(raw.data(), data, raw.size()); } +File::File(const RawData& rawData) : raw{rawData} {} File::File(const char* filename) { raw.fill(0);