mirror of https://github.com/AxioDL/kabufuda.git
Proper getSerial implementation
This commit is contained in:
parent
fa70961027
commit
8d2d1134ae
|
@ -334,11 +334,10 @@ public:
|
||||||
const uint8_t* getCurrentMaker() const;
|
const uint8_t* getCurrentMaker() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Retrieves the format assigned serial in two 32bit parts
|
* @brief Retrieves the format assigned serial
|
||||||
* @param s0
|
* @param serial
|
||||||
* @param s1
|
|
||||||
*/
|
*/
|
||||||
void getSerial(uint32_t* s0, uint32_t* s1);
|
void getSerial(uint64_t& serial);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Retrieves the checksum values of the Card system header
|
* @brief Retrieves the checksum values of the Card system header
|
||||||
|
|
|
@ -645,13 +645,15 @@ const uint8_t* Card::getCurrentMaker() const
|
||||||
return nullptr;
|
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++)
|
for (uint32_t i = 0; i < 8; i++)
|
||||||
memcpy(&serial[i], reinterpret_cast<uint8_t*>(m_serial + (i * 4)), 4);
|
serialBuf[i] = SBig(*reinterpret_cast<uint32_t*>(copy.__raw + (i * 4)));
|
||||||
*s0 = serial[0] ^ serial[2] ^ serial[4] ^ serial[6];
|
serial = uint64_t(serialBuf[0] ^ serialBuf[2] ^ serialBuf[4] ^ serialBuf[6]) << 32 |
|
||||||
*s1 = serial[1] ^ serial[3] ^ serial[5] ^ serial[7];
|
(serialBuf[1] ^ serialBuf[3] ^ serialBuf[5] ^ serialBuf[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Card::getChecksum(uint16_t* checksum, uint16_t* inverse)
|
void Card::getChecksum(uint16_t* checksum, uint16_t* inverse)
|
||||||
|
|
|
@ -6,6 +6,9 @@ int main()
|
||||||
kabufuda::Card mc{_S("test.USA.raw"), "GM8E", "01"};
|
kabufuda::Card mc{_S("test.USA.raw"), "GM8E", "01"};
|
||||||
if (!mc)
|
if (!mc)
|
||||||
mc.format(kabufuda::EDeviceId::SlotA, kabufuda::ECardSize::Card2043Mb);
|
mc.format(kabufuda::EDeviceId::SlotA, kabufuda::ECardSize::Card2043Mb);
|
||||||
|
uint64_t a = 0;
|
||||||
|
mc.getSerial(a);
|
||||||
|
|
||||||
kabufuda::Card mc2{_S("test2.USA.raw"), "GM8E", "01"};
|
kabufuda::Card mc2{_S("test2.USA.raw"), "GM8E", "01"};
|
||||||
if (!mc2)
|
if (!mc2)
|
||||||
mc2.format(kabufuda::EDeviceId::SlotA, kabufuda::ECardSize::Card2043Mb);
|
mc2.format(kabufuda::EDeviceId::SlotA, kabufuda::ECardSize::Card2043Mb);
|
||||||
|
@ -19,6 +22,7 @@ int main()
|
||||||
mc.setCanMove(f, true);
|
mc.setCanMove(f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (f)
|
if (f)
|
||||||
{
|
{
|
||||||
mc.setBannerFormat(f, kabufuda::EImageFormat::C8);
|
mc.setBannerFormat(f, kabufuda::EImageFormat::C8);
|
||||||
|
|
Loading…
Reference in New Issue