mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-10 03:27:42 +01:00
WiimoteEmu: Make SerializedWiimoteState store camera points as IRExtended instead of custom layout.
This commit is contained in:
parent
6dd0793f1b
commit
e5b55bfc06
@ -83,14 +83,13 @@ SerializedWiimoteState SerializeDesiredState(const DesiredWiimoteState& state)
|
|||||||
|
|
||||||
if (has_camera)
|
if (has_camera)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < state.camera_points.size(); ++i)
|
for (auto& camera_point : state.camera_points)
|
||||||
{
|
{
|
||||||
const u16 camera_x = state.camera_points[i].position.x; // 10 bits
|
IRExtended irext;
|
||||||
const u16 camera_y = state.camera_points[i].position.y; // 10 bits
|
irext.SetPosition(camera_point.position);
|
||||||
const u8 camera_size = state.camera_points[i].size; // 4 bits
|
irext.size = camera_point.size;
|
||||||
s.data[s.length++] = u8((camera_x & 0b11) | ((camera_y & 0b11) << 2) | (camera_size << 4));
|
Common::BitCastPtr<IRExtended>(&s.data[s.length]) = irext;
|
||||||
s.data[s.length++] = u8(camera_x >> 2);
|
s.length += sizeof(irext);
|
||||||
s.data[s.length++] = u8(camera_y >> 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,24 +260,11 @@ bool DeserializeDesiredState(DesiredWiimoteState* state, const SerializedWiimote
|
|||||||
|
|
||||||
if (has_camera)
|
if (has_camera)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < state->camera_points.size(); ++i)
|
for (auto& camera_point : state->camera_points)
|
||||||
{
|
{
|
||||||
const u8 camera_misc = d[pos];
|
const IRExtended irext = Common::BitCastPtr<IRExtended>(&d[pos]);
|
||||||
const u8 camera_x_high = d[pos + 1];
|
camera_point = CameraPoint(irext.GetPosition(), irext.size);
|
||||||
const u8 camera_y_high = d[pos + 2];
|
pos += sizeof(irext);
|
||||||
const u16 camera_x = (camera_x_high << 2) | (camera_misc & 0b11);
|
|
||||||
const u16 camera_y = (camera_y_high << 2) | ((camera_misc >> 2) & 0b11);
|
|
||||||
const u8 camera_size = camera_misc >> 4;
|
|
||||||
if (camera_y < CameraLogic::CAMERA_RES_Y)
|
|
||||||
{
|
|
||||||
state->camera_points[i] = CameraPoint({camera_x, camera_y}, camera_size);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// indicates an invalid camera point
|
|
||||||
state->camera_points[i] = CameraPoint();
|
|
||||||
}
|
|
||||||
pos += 3;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user