NNID Mii to Mii Studio format converter (2018)
originally made 2018-12-10
by arian_
HTML
<img id="mii-preview" src="">
<form id="mii-submit">
<input type="text" placeholder="b64 mii goes here" id="mii-input">
<button id="submit-button">go</button>
</form>
CSS
#mii-preview {
margin-top: -120px;
height: 512px;
width: 512px;
}
img[src=""] {
visibility: hidden;
}
#mii-submit {
margin-top: -20px;
}
input, button {
border: 1px solid black;
border-radius: 5px;
background-color: #20262e;
color: white;
font-size: 24px;
}
form {
width: 358px;
}
button {
float: right;
}
button[disabled] {
background-color: #35404f;
}
button:not([disabled]):hover {
background-color: #1a1f26;
}
button:not([disabled]):active {
margin-top: 5px;
}
body {
background-color: #20262e;
}
JavaScript
// miiMap2Studio converts a mii "map" array with mii traits to a value that can be rendered by studio.mii.nintendo.com.
function miiMap2Studio(map) {
// map will be modified
const len = map.length;
// make some random int
const random = 0;
// randomCopy will be modified
var randomCopy = random;
for(let i = 0; i < len; i++) {
map[i] = (7 + (map[i] ^ randomCopy)) % 256;
randomCopy = map[i];
}
// add the random value to the front of the map
return [random].concat(map).map(i => {
for(var byte = (i % 256).toString(16); byte.length < 2;) {
// pad hex with zero
byte = '0' + byte;
}
return byte;
}).join('');
}
// u8Mii2Map converts a uint8array of a mii in bytes (can be converted from a base64 mii) to a mii "map" struct which can then be used in miiMap2Studio
function u8Mii2Map(u8) {
// u8 is a Uint8Array that shouldn't be modified
return [
// beard color
(u8[0x42] >> 0x03) & 0x07,
// beard type (0 for none)
u8[0x42] & 0x07,
// fatness
u8[0x2f],
// eye thickness
u8[0x35] >> 0x05,
// eye color (!)
(u8[0x34] & 0x01) + (u8[0x35] >> 0x06),
// eye rotation
u8[0x36] & 0x07,
// eye scale
(0x0e & u8[0x35]) >> 0x01,
// eye type
u8[0x34] & 0x3f,
// eye distance
u8[0x36] >> 0x05,
// eye height
(u8[0x37] & 0x1f) >> 0x01,
// eyebrow thickness
(0x0e & u8[0x3a]) >> 0x01,
// eyebrow color
u8[0x38] >> 0x05,
// eyebrow rotation
u8[0x3a] & 0x07,
// eyebrow scale
u8[0x39] & 0x07,
// eyebrow type
u8[0x38] & 0x1f,
// eyebrow distance
(u8[0x3b] & 0x01) + (u8[0x3a] >> 0x05),
// eyebrow height
u8[0x3b] >> 0x01,
// face color (!)
u8[0x30] >> 0x05,
// blush type (0 for none)
u8[0x31] >> 0x04,
// face type
(0x0e & u8[0x30]) >> 0x01,
// face style (wrinkles) (0 for none)
u8[0x31] & 0x0f,
// shirt color
(0x3c & u8[0x19]) >> 0x02,
// male/female
u8[0x18] & 0x01,
//...