mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-03-21 17:44:58 -05:00
50 lines
747 B
Go
50 lines
747 B
Go
package common
|
|
|
|
// References:
|
|
// https://wiibrew.org/wiki/Mii_Data
|
|
// https://github.com/kiwi515/ogws/tree/master/src/RVLFaceLib
|
|
|
|
type Mii [0x4C]byte
|
|
|
|
func (data Mii) RFLCalculateCRC() uint16 {
|
|
crc := uint16(0)
|
|
|
|
for _, val := range data {
|
|
for j := 0; j < 8; j++ {
|
|
if crc&0x8000 != 0 {
|
|
crc <<= 1
|
|
crc ^= 0x1021
|
|
} else {
|
|
crc <<= 1
|
|
}
|
|
|
|
if val&0x80 != 0 {
|
|
crc ^= 0x1
|
|
}
|
|
|
|
val <<= 1
|
|
}
|
|
}
|
|
|
|
return crc
|
|
}
|
|
|
|
var officialMiiList = []uint64{
|
|
0x80000000ECFF82D2,
|
|
0x80000001ECFF82D2,
|
|
0x80000002ECFF82D2,
|
|
0x80000003ECFF82D2,
|
|
0x80000004ECFF82D2,
|
|
0x80000005ECFF82D2,
|
|
}
|
|
|
|
func RFLSearchOfficialData(id uint64) (bool, int) {
|
|
for i, v := range officialMiiList {
|
|
if v == id {
|
|
return true, i
|
|
}
|
|
}
|
|
|
|
return false, -1
|
|
}
|