diff --git a/include/kabufuda/Card.hpp b/include/kabufuda/Card.hpp index 6b16324..1aa9ea7 100644 --- a/include/kabufuda/Card.hpp +++ b/include/kabufuda/Card.hpp @@ -334,11 +334,10 @@ public: const uint8_t* getCurrentMaker() const; /** - * @brief Retrieves the format assigned serial in two 32bit parts - * @param s0 - * @param s1 + * @brief Retrieves the format assigned serial + * @param serial */ - void getSerial(uint32_t* s0, uint32_t* s1); + void getSerial(uint64_t& serial); /** * @brief Retrieves the checksum values of the Card system header diff --git a/lib/kabufuda/Card.cpp b/lib/kabufuda/Card.cpp index d63eaf3..622a244 100644 --- a/lib/kabufuda/Card.cpp +++ b/lib/kabufuda/Card.cpp @@ -645,13 +645,15 @@ const uint8_t* Card::getCurrentMaker() const return nullptr; } -void Card::getSerial(uint32_t* s0, uint32_t* s1) +void Card::getSerial(uint64_t& serial) { - uint32_t serial[8]; + Card copy = *this; + copy._swapEndian(); + uint32_t serialBuf[8]; for (uint32_t i = 0; i < 8; i++) - memcpy(&serial[i], reinterpret_cast(m_serial + (i * 4)), 4); - *s0 = serial[0] ^ serial[2] ^ serial[4] ^ serial[6]; - *s1 = serial[1] ^ serial[3] ^ serial[5] ^ serial[7]; + serialBuf[i] = SBig(*reinterpret_cast(copy.__raw + (i * 4))); + serial = uint64_t(serialBuf[0] ^ serialBuf[2] ^ serialBuf[4] ^ serialBuf[6]) << 32 | + (serialBuf[1] ^ serialBuf[3] ^ serialBuf[5] ^ serialBuf[7]); } void Card::getChecksum(uint16_t* checksum, uint16_t* inverse) diff --git a/test/main.cpp b/test/main.cpp index ef7abfe..e1e99f9 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -6,6 +6,9 @@ int main() kabufuda::Card mc{_S("test.USA.raw"), "GM8E", "01"}; if (!mc) mc.format(kabufuda::EDeviceId::SlotA, kabufuda::ECardSize::Card2043Mb); + uint64_t a = 0; + mc.getSerial(a); + kabufuda::Card mc2{_S("test2.USA.raw"), "GM8E", "01"}; if (!mc2) mc2.format(kabufuda::EDeviceId::SlotA, kabufuda::ECardSize::Card2043Mb); @@ -19,6 +22,7 @@ int main() mc.setCanMove(f, true); } + if (f) { mc.setBannerFormat(f, kabufuda::EImageFormat::C8);