help me make a wii fit/ wii fit plus data parser using tkinter. File FitPlus0.dat
Byte Offset | Length | Description
0x0 | 8 | RPHE0000 (header)
0x8 | 22 | Name of Mii
0x1E | 1 | Unknown
0x1F | 1 | Height (in cm)
0x20 | 4 | Date of birth (stored in BCD: e.g. 1980 0228)
0x24 | | Unknown
0x95 | | Dates with data (rowlen=10)
0x35CF | | Start of some other section (unknown)
0x38A1 | | Body Test measurement data section (rowlen=21)
+0 | 4 | Date (in bitfield format)
+4 | 2 | Weight (in kg * 10)
+6 | 2 | BMI (* 100)
+8 | 2 | Balance percent (* 10)
+10 | 2 | simple value 4 ??
+12 | 1 | extended 1 ??
+13 | 1 | extended 2 ??
+14 | 1 | extended 3 ??
+15 | 1 | extended 4 ??
+16 | 2 | extended 5 ??
+18 | 1 | extended 6 ??
+19 | 1 | extended 7 ??
0x9288 | 1 | Last byte of profile
Assistant
Creating a basic parser in Python using tkinter to open and read the FitPlus0.dat file based on your structure is definitely possible. Here's a step-by-step example script that:
Opens the .dat file using a file dialog.
Parses some key information:
Header
Mii name
Height
Date of birth (in BCD format)
Body Test measurement data section (first entry parsed for demo)
Displays parsed data in a simple tkinter UI.
This will serve as a starting point you can expand on.
python
import tkinter as tk
from tkinter import filedialog, messagebox
import struct
def bcd_to_int(bcd_bytes):
# Convert BCD bytes to integer (e.g. b'\x19\x80' -> 1980)
result = 0
for b in bcd_bytes:
high = (b >> 4) & 0xF
low = b & 0xF
# Each nibble is a digit in BCD
result = result * 100 + high * 10 + low
return result
def parse_date_bcd(bcd_bytes):
# Given 4 bytes BCD: YYYYMMDD
if len(bcd_bytes) != 4:
return "Invalid BCD date"
year = bcd_to_int(bcd_bytes[0:2]) # first 2 bytes for year
month = bcd_to_int(bcd_bytes[2:3]) # 3rd byte high nibble month, low nibble day leading digit?
day = bcd_to_int(bcd_bytes[3:4]) # 4th byte day
# Better: parse YYMMDD from these 4 bytes using BCD nibbles directly:
# Let's do it nibble by nibble
nibbles = []
for b in bcd_bytes:
nibbles.append((b >> 4) & 0xF)
nibbles.append(b & 0xF)
# nibbles is [Y1, Y2, Y3, Y4, M1, M2, D1, D2]
year = nibbles[0]*1000 + nibbles[1]*100 + nibbles[2]*10 + nibbles[3]
month = nibbles[4]*10 + nibbles[5]
day = nibbles[6]*10 + nibbles[7]
return f"{year:04d}-{month:02d}-{day:02d}"
def parse_body_test_measurement(data):
# data is 21 bytes, parse per given structure
# Date (4 bytes) - bitfield format (not further decoded here)
date_bytes = data[0:4]
weight_raw = struct.unpack('<H', data[4:6])[0] # 2 bytes, little endian
bmi_raw = struct.unpack('<H', data[6:8])[0]
balance_raw = struct.unpack('<H', data[8:10])[0]
weight = weight_raw / 10.0
bmi = bmi_raw / 100.0
balance = balance_raw / 10.0
# Other bytes extended etc
unknown = data[10:21]
return {
'date_raw': date_bytes,
'weight': weight,
'bmi': bmi,
'balance': balance,
'unknown_bytes': unknown
}
def open_file():
filename = filedialog.askopenfilename(title="Open FitPlus0.dat file", filetypes=[("DAT files", "*.dat")])
if not filename:
return
try:
with open(filename, 'rb') as f:
content = f.read()
# Header (0x0 - 8 bytes)
header = content[0:8].decode('ascii', errors='replace')
# Mii Name (0x8 - 22 bytes)
mii_name_raw = content[0x8:0x8+22]
mii_name = mii_name_raw.decode('utf-16le', errors='replace').strip('\x00')
# Height (0x1F - 1 byte)
height_cm = content[0x1F]
# Date of Birth (0x20 - 4 bytes BCD)
dob_bytes = content[0x20:0x24]
dob = parse_date_bcd(dob_bytes)
# Body Test measurements start at 0x38A1, 21 bytes per row.
# Let's try to parse the first row for demonstration
if len(content) < 0x38A1 + 21:
raise ValueError("File too short to contain body test data section")
body_test_data_first = content[0x38A1:0x38A1+21]
body_test = parse_body_test_measurement(body_test_data_first)
except Exception as e:
messagebox.showerror("Error", f"Failed to parse file: {e}")
return
# Update UI with parsed data
header_var.set(header)
mii_name_var.set(mii_name)
height_var.set(f"{height_cm} cm")
dob_var.set(dob)
weight_var.set(f"{body_test['weight']} kg")
bmi_var.set(str(body_test['bmi']))
balance_var.set(f"{body_test['balance']} %")
app = tk.Tk()
app.title("Wii Fit Plus Data Parser")
# StringVars to display data
header_var = tk.StringVar()
mii_name_var = tk.StringVar()
height_var = tk.StringVar()
dob_var = tk.StringVar()
weight_var = tk.StringVar()
bmi_var = tk.StringVar()
balance_var = tk.StringVar()
frame = tk.Frame(app,padx=10,pady=10)
frame.pack()
tk.Button(frame, text="Open FitPlus0.dat", command=open_file).grid(row=0, column=0, columnspan=2, pady=(0,10))
tk.Label(frame, text="Header:").grid(row=1, column=0, sticky="e")
tk.Label(frame, textvariable=header_var).grid(row=1, column=1, sticky="w")
tk.Label(frame, text="Mii Name:").grid(row=2, column=0, sticky="e")
tk.Label(frame, textvariable=mii_name_var).grid(row=2, column=1, sticky="w")
tk.Label(frame, text="Height:").grid(row=3, column=0, sticky="e")
tk.Label(frame, textvariable=height_var).grid(row=3, column=1, sticky="w")
tk.Label(frame, text="Date of Birth:").grid(row=4, column=0, sticky="e")
tk.Label(frame, textvariable=dob_var).grid(row=4, column=1, sticky="w")
tk.Label(frame, text="Weight:").grid(row=5, column=0, sticky="e")
tk.Label(frame, textvariable=weight_var).grid(row=5, column=1, sticky="w")
tk.Label(frame, text="BMI:").grid(row=6, column=0, sticky="e")
tk.Label(frame, textvariable=bmi_var).grid(row=6, column=1, sticky="w")
tk.Label(frame, text="Balance:").grid(row=7, column=0, sticky="e")
tk.Label(frame, textvariable=balance_var).grid(row=7, column=1, sticky="w")
app.mainloop()
Explanation
The parser decodes the header from ASCII.
The Mii name is extracted as UTF-16LE from 22 bytes starting at 0x8 as Mii names are often UTF-16 in Nintendo data.
Height at 0x1F is single byte integer.
Date of birth is 4 bytes stored in BCD format, decoded nibble-wise.
The Weight (kg * 10), BMI (x100), and Balance (x10) values are unpacked from the first 21-byte row in the body test data section at 0x38A1.
Shows the data in a simple tkinter window.
This serves as a foundation which you can extend, for example:
Parsing all body test data rows
Handling other unknown sections
Adding data visualizations
Let me know if you'd like assistance expanding this further!