Commit 8d2d1134 authored by Phillip Stephens's avatar Phillip Stephens

Proper getSerial implementation

parent fa709610
......@@ -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
......
......@@ -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<uint8_t*>(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<uint32_t*>(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)
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment