Mii: Difference between revisions

Wwylele (talk | contribs)
m Mii Database: Fix obvious offset/size typo
TimmSkiller (talk | contribs)
move CFLStoreData here
 
(25 intermediate revisions by 8 users not shown)
Line 2: Line 2:


See [[Mii Maker]] for the application chiefly designed to create, edit, delete, and trade Miis or convert them from and to a QR code.
See [[Mii Maker]] for the application chiefly designed to create, edit, delete, and trade Miis or convert them from and to a QR code.
The default endianness in this page is little-endian, unless explicitly specified.


==Mii Database==
==Mii Database==
Line 18: Line 20:
| 0x4
| 0x4
| 0x4
| 0x4
| Header 0x00010000
| Header 0x00000100
|-
|-
| 0x8
| 0x8
Line 29: Line 31:
|-
|-
| 0x23FC
| 0x23FC
| 0x4
| 0x2
| Header 0xFFFFFFFF
| Linked list tail index. 0xFFFF if the list is empty
|-
| 0x23FE
| 0x2
| Linked list head index. 0xFFFF if the list is empty
|-
|-
| 0x2400
| 0x2400
| 0xA41E
| 0xA410 (3000 * 0xE)
| Array of objects? See chapter
| Linked list of objects? See chapter
|-
| 0xC810
| 0xE
| Padding?
|-
|-
| 0xC81E
| 0xC81E
Line 46: Line 56:
| 0xC824
| 0xC824
| 0x4
| 0x4
| Header? 0x39000000
| Mii count in this section. Maximum 100
|-
|-
| 0xC861
| 0xC828
| 0x2B
| 0x64 (100 * 0x1)
| Weird padding? 0x00
| Order index of Mii in this section?
|-
|-
| 0xC88C
| 0xC88C
| 0x1C20 (?)
| 0x1C20 (100 * 0x48)
| Array of Miis contributed from games, used for Mii Plaza "invitations" feature.<br/>The format isn't that of a full Mii.
| Array of Miis contributed from games, used for Mii Plaza "invitations" feature.<br/>The format isn't that of a full Mii. The "author" field is missing
|-
|-
| 0xE4AC
| 0xE4AC
| 0x14
| 0x12
| 01 00 [..] 00 D2 74
| 01 00 [..] 00
|-
| 0xE4BE
| 0x2
| Checksum over the data above starting from 0xC820
|-
|-
| 0xE4C0
| 0xE4C0
| 0x3D860
| 0x3D860 (3000 * 0x54)
| Empty (00)
| Another array of Miis. Seems related to the CFHE section. <br/>The Mii format in this section is modified. The "author" field is missing, A 4-byte timestamp (seconds since 2000) together with 8-byte zeros(?) is appended at the end.
|}
|}
When encrypted in QR codes, 4 additional bytes are added. Two null bytes and a CRC-16. It's the exact same CRC-16 as for the Wii blocks on the 0x5e first bytes. It seems that the CRC is ignored, the Mii Maker expecting the result of APT:Unwrap to detect integrity loss.
When encrypted in QR codes, 4 additional bytes are added. Two null bytes and a CRC-16. It's the exact same CRC-16 as for the Wii blocks on the 0x5e first bytes. It seems that the CRC is ignored, the Mii Maker expecting the result of APT:Unwrap to detect integrity loss.
Line 68: Line 82:
==CFHE object==
==CFHE object==


A 0xE-byte long item.
A 0xE-byte long linked list node. The format is 4-byte Mii ID (See Mii format) + 6-byte MAC + 2-byte previous node index (prev) + 2-byte next node index (next).


On my database, they're all 0000 0000 0000 0000 0000 FF7F FF7F.
An invalid node has value: ID = 0, MAC = 0, prev = 0x7FFF, next = 0x7FFF.


Wild speculation: blacklist of already scanned celebrity (gold) Mii QRs?
The highest bit of these fields has some special meaning and isn't part of the index value.
 
Alternative interpretation: FFFF FFFF 0000 0000 0000 0000 0000 is the 1st item;  FF7F FF7F 0000 [...] the 2nd, etc;


==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 84: 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 114: Line 123:


==Mii format==
==Mii format==
Note: 0x18-3B have been copied as-is from [[Mii_Maker#Mii_QR_Code_format|the QR code specification]], so they're unverified.


{| class="wikitable"
{| class="wikitable"
Line 124: Line 131:
|-
|-
| 0x0
| 0x0
| 0x4
| 0x1
| Mii ID (see chapter)
| Mii Version - Always 3
|-
| 0x1
| 0x1
| bit 0: allow copying<br/>bit 1: profanity flag (whether in Mii name or creator name does not matter)<br/>bit 2-3: region lock (0=no lock, 1=JPN, 2=USA, 3=EUR)<br/>bit4-5:character set(0=JPN+USA+EUR, 1=CHN, 2=KOR, 3=TWN)
|-
| 0x2
| 0x1
| Mii position shown on the selection screen<br/>bit 0-3: page index <br/>bit 4-7: slot index
|-
| 0x3
| 0x1
| bit 0-3: ?<br/>bit 4-6: Device Mii was originally made on (1=Wii, 2=DS, 3=3DS, 4=Wii U/Switch)
|-
|-
| 0x4
| 0x4
Line 133: Line 152:
| 0xC
| 0xC
| 0x4
| 0x4
| Specialness and date of creation (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 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 145: Line 164:
| 0x18
| 0x18
| 0x2
| 0x2
| Bit-mapped: Birthday (4bit-day,5bit-month), Sex, Shirt color, Favorite (0x40 bit at 0x19)
| bit 0: sex (0 if male, 1 if female)<br/>bit 1-4: birthday month<br/>bit 5-9: birthday day<br/>bit 10-13: favorite color<br/>bit 14: favorite mii (0 if false, 1 if true)
|-
|-
| 0x1A
| 0x1A
Line 173: Line 192:
| 0x34
| 0x34
| 0x4
| 0x4
| unknown
| bit 0-5: eye style<br/>bit 6-8: eye color <br/>bit 9-12: eye scale <br/>bit 13-15: eye yscale<br/>bit 16-20: eye rotation<br/>bit 21-24: eye x spacing<br/>bit 25-29: eye y position
|-
|-
| 0x38
| 0x38
| 0x1
| 0x4
| bit 0-4: eyebrow style<br/>bit 5-7: eyebrow color
| bit 0-4: eyebrow style<br/>bit 5-7: eyebrow color <br/>bit 8-11: eyebrow scale<br/>bit 12-14: eyebrow yscale <br/>bit 16-19: eyebrow rotation<br/>bit 21-24: eyebrow x spacing<br/>bit 25-29: eyebrow y position
|-
| 0x3C
| 0x2
| bit 0-4: nose style<br/>bit 5-8: nose scale<br/>bit 9-13: nose y position
|-
|-
| 0x39
| 0x3E
| 0x1
| 0x2
| bit 0-3: eyebrow scale<br/>bit 4-6: eyebrow yscale
| bit 0-5: mouth style<br/>bit 6-8: mouth color<br/>bit 9-12: mouth scale<br/>bit 13-15: mouth yscale
|-
|-
| 0x3A
| 0x40
| 0x2
| 0x2
| note that the bytes are swapped over (little-endian layout)<br/>bit 0-3: eyebrow rotation<br/>bit 5-8: eyebrow x spacing<br/>bit 9-13: eyebrow y position
| bit 0-4: mouth y position<br/>bit 5-7: mustach style
|-
|-
| 0x3C
| 0x42
| 0x4
| 0x2
| unknown
| bit 0-2: beard style<br/>bit 3-5: beard color<br/>bit 6-9: mustache scale<br/>bit 10-14:mustache y position
|-
|-
| 0x40
| 0x44
| 0x1
| 0x2
| Allow Copying (?) (0D on 0E off 8D on)
| bit 0-3: glasses style<br/>bit 4-6: glasses color<br/>bit 7-10: glasses scale<br/>bit 11-15: glasses y position
|-
|-
| 0x41
| 0x46
| 0x7
| 0x2
| unknown
| bit 0: enable mole<br/>bit 1-4: mole scale<br/>bit 5-9: mole x position<br/>bit 10-14: mole y position
|-
|-
| 0x48
| 0x48
Line 204: Line 227:
|}
|}


==Mii ID==
== CFLStoreData ==
* Byte 0: generally equals 3 (category?)
This is a common Mii container object, used in games and system modules like [[Friend_Services|FRD]] and [[ACT_Services|ACT]].
* Byte 1: 0/1 = copying off/on
{| class="wikitable" border="1"
* Byte 2, most significant hex digit: position on page (0-9)
|-
* Byte 2, least significant hex digit: page (0-9)
! Offset !! Size !! Description
* Byte 3: generally 0x30 (always for user-created ones?)
|-
| 0x0 || 0x5C || Base Mii data in the above format
|-
| 0x5C || 0x2 || padding, left as zeros usually
|-
| 0x5E || 0x2 || CRC16 over the previous 0x5E of data
|}


===Mii categories (pants colors)===
==Mii categories (pants colors)==


====Special (gold) Miis====
====Special (gold) Miis====
Specialness will override any other color and make the Mii non-editable.
Specialness will override any other pants color.


Copying is rumored to have to be disabled.
A special Mii cannot have sharing on or else it will be deemed invalid.


Zeroed system-id and timestamp?
Zeroed system-id and timestamp?
Line 232: Line 261:
====Personal (red) Mii====
====Personal (red) Mii====
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 favorited.


==Mii values==
==Mii values==
Line 565: Line 596:
     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,
Line 596: Line 627:
     0x0f,0x0d,0x16,
     0x0f,0x0d,0x16,
     0x12,0x10,0x17]
     0x12,0x10,0x17]
],
eyes: [
    [0x02,0x04,0x00,
    0x08,0x27,0x11,
    0x01,0x1a,0x10,
    0x0f,0x1b,0x14],
    [0x21,0x0b,0x13,
    0x20,0x09,0x0c,
    0x17,0x22,0x15,
    0x19,0x28,0x23],
    [0x05,0x29,0x0d,
    0x24,0x25,0x06,
    0x18,0x1e,0x1f,
    0x12,0x1c,0x2e],
    [0x07,0x2c,0x26,
    0x2a,0x2d,0x1d,
    0x03,0x2b,0x16,
    0x0a,0x0e,0x2f],
    [0x30,0x31,0x32,
    0x35,0x3b,0x38,
    0x36,0x3a,0x39,
    0x37,0x33,0x34]
],
],
nose: [
nose: [