Mii: Difference between revisions

Checksum: The implementation is not wrong it's just a different one called CRC-16/XMODEM
(3 intermediate revisions by 2 users not shown)
Line 90: Line 90:
==Checksum==
==Checksum==


The algorithm used to verify the integrity of the database is based on [http://srecord.sourceforge.net/crc16-ccitt.html CRC16-CCITT], though it's an incorrect implementation. It is the same algorithm used to verify [http://wiibrew.org/wiki/Mii_Data#Block_format Mii Data on the Wii].
The algorithm used to verify the integrity of the database is based on CRC-16/XMODEM. It is the same algorithm used to verify [http://wiibrew.org/wiki/Mii_Data#Block_format Mii Data on the Wii].


To obtain the correct value for the checksum, apply the algorithm to the first 0xC81E bytes of the database. This can be done using [https://gbatemp.net/threads/tutorial-give-your-mii-gold-pants-and-use-it-for-streetpass.379146/page-24#post-6569186 FixCRC]; alternativly a pseudocode implementation of the checksum algorithm is given below:
To obtain the correct value for the checksum, apply the algorithm to the first 0xC81E bytes of the database. This can be done using [https://gbatemp.net/threads/tutorial-give-your-mii-gold-pants-and-use-it-for-streetpass.379146/page-24#post-6569186 FixCRC]; alternativly a pseudocode implementation of the checksum algorithm is given below:
Line 96: Line 96:
<source lang="python">
<source lang="python">
def crc16_CCITTWii(u8[]: data) -> u16:
def crc16_CCITTWii(u8[]: data) -> u16:
     """Calculate a checksum of data using the CRC16-CCITT implementation of the Wii
     """Calculate a checksum of data using the CRC-16/XMODEM implementation


     This implementation uses 0x0000 as the starting value, which is different
     CRC-16/XMODEM implementation uses 0x0000 as the starting value
    from what CRC16-CCITT specifies.
     """
     """
 
      
     # note: a correct implementation of CRC16-CCITT
    #      would initialize this to 0xffff
     u32 crc := 0x0
     u32 crc := 0x0


Line 155: Line 152:
| 0xC
| 0xC
| 0x4
| 0x4
| Mii ID (big-endian 32bit unsigned integer):<br/>Bit 0..27: (bit[0..27] * 2) = date of creation (seconds since 01/01/2010 00:00:00)<br/>Bit 28: Always set?<br/>Bit 29: set for temporary Mii<br/>Bit 30: Set for DSi mii?<br/>Bit 31: not set iff Mii is special
| Mii ID (big-endian 32bit unsigned integer):<br/>Bit 0..27: (bit[0..27] * 2) = date of creation (seconds since 01/01/2010 00:00:00)<br/>Bit 28: Always set?<br/>Bit 29: set for temporary Mii<br/>Bit 30: Set for DSi mii?<br/>Bit 31: not set if Mii is special
|-
|-
| 0x10
| 0x10
Line 252: Line 249:
A red Mii that happens to be the first in the file!
A red Mii that happens to be the first in the file!


The Mii doesn't really need to be red, it is only red because the personal Mii is always favorite
The Mii doesn't really need to be red, it is only red because the personal Mii is always favorited.


==Mii values==
==Mii values==
Line 586: Line 583:
     0x64,0x06,0x14,
     0x64,0x06,0x14,
     0x5d,0x66,0x1b,
     0x5d,0x66,0x1b,
     0x04,0x11,0x6e]
     0x04,0x11,0x6e],
     [0x7b,0x08,0x6a,
     [0x7b,0x08,0x6a,
     0x48,0x03,0x15,
     0x48,0x03,0x15,