Skip to content

Commit

Permalink
Document previously unknown fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Pokechu22 committed Jul 28, 2019
1 parent 1f50ad2 commit 67104bd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
13 changes: 6 additions & 7 deletions Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void BalanceBoard::Update()
bb_data.bottom_right = Common::swap16(ConvertToSensorWeight(bottom_right));
bb_data.top_left = Common::swap16(ConvertToSensorWeight(top_left));
bb_data.bottom_left = Common::swap16(ConvertToSensorWeight(bottom_left));
bb_data.unknown1 = 0x19;
bb_data.battery = 0x83;
bb_data.temperature = TEMPERATURE;
bb_data.battery = 0x83; // Above the threshold for 4 bars

Common::BitCastPtr<DataFormat>(&m_reg.controller_data) = bb_data;
}
Expand All @@ -74,7 +74,7 @@ void BalanceBoard::Reset()
m_reg.identifier = balance_board_id;

// Build calibration data:
m_reg.calibration = {{// Unknown byte data
m_reg.calibration = {{// Unused battery calibration
0x01, 0x69, 0x00, 0x00,
// Top right 0kg
u8(WEIGHT_0_KG >> 8), u8(WEIGHT_0_KG & 0xFF),
Expand Down Expand Up @@ -102,8 +102,7 @@ void BalanceBoard::Reset()
u8(WEIGHT_34_KG >> 8), u8(WEIGHT_34_KG & 0xFF),
// Checksum - computed later
0xff, 0xff, 0xff, 0xff}};
m_reg.bboard_unknown = {{// 2 used unknown bytes
0x19, 0x01}};
m_reg.bboard_temperature_calibration = {{TEMPERATURE, 0x01}};

ComputeCalibrationChecksum();
}
Expand Down Expand Up @@ -186,8 +185,8 @@ void BalanceBoard::ComputeCalibrationChecksum()
data[0x17] = m_reg.calibration2[0xb];
data[0x18] = m_reg.calibration[0];
data[0x19] = m_reg.calibration[1];
data[0x1a] = m_reg.bboard_unknown[0];
data[0x1b] = m_reg.bboard_unknown[1];
data[0x1a] = m_reg.bboard_temperature_calibration[0];
data[0x1b] = m_reg.bboard_temperature_calibration[1];

constexpr u32 CRC_POLYNOMIAL = 0xEDB88320; // Reversed

Expand Down
7 changes: 5 additions & 2 deletions Source/Core/Core/HW/WiimoteEmu/Extension/BalanceBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class BalanceBoard : public Extension1stParty
u16 bottom_right;
u16 top_left;
u16 bottom_left;
u8 unknown1;
u8 pad;
u8 temperature;
u8 padding;
u8 battery;
};
static_assert(sizeof(DataFormat) == 12, "Wrong size");
Expand All @@ -56,6 +56,9 @@ class BalanceBoard : public Extension1stParty
static constexpr u16 WEIGHT_0_KG = 0;
static constexpr u16 WEIGHT_17_KG = 17000;
static constexpr u16 WEIGHT_34_KG = 34000;
// Chosen arbitrarily from the value for pokechu22's board. As long as the calibration and
// actual temperatures match, the value here doesn't matter.
static constexpr u8 TEMPERATURE = 0x19;

private:
u16 ConvertToSensorWeight(double weight_in_kilos);
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/WiimoteEmu/Extension/Extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class EncryptedExtension : public Extension
std::array<u8, 0x10> encryption_key_data;
u8 unknown3[0x10];
// Address 0x60
std::array<u8, 2> bboard_unknown;
std::array<u8, 2> bboard_temperature_calibration;
u8 unknown4[0x8e];

// address 0xF0
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/TAS/WiiTASInputWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ void WiiTASInputWindow::GetValues(DataReportBuilder& rpt, int ext,
bb_data.bottom_right = Common::swap16(bottom_right);
bb_data.top_left = Common::swap16(top_left);
bb_data.bottom_left = Common::swap16(bottom_left);
bb_data.unknown1 = 0x19;
bb_data.temperature = 0x19;
bb_data.battery = 0x83;

Common::BitCastPtr<BalanceBoard::DataFormat>(ext_data) = bb_data;
Expand Down

0 comments on commit 67104bd

Please sign in to comment.