Skip to content

Commit

Permalink
Sign-extend WDC1 Immediate values
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlamin committed Aug 9, 2024
1 parent 64479c5 commit 93740e8
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions DBCD.IO/Writers/BaseWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,34 @@ public void HandleCompression(IDictionary<int, T> storage)
newCompressedSize = 32;
else
{
var maxValue = storage.Values.Count switch
if ((meta.Immediate.Flags & 0x1) == 0x1)
{
0 => 0U,
_ => storage.Values.AsParallel().Max(row =>
var largestMSB = storage.Values.Count switch
{
var value32 = Value32.Create(info.Getter(row));
return value32.GetValue<uint>();
}),
};

newCompressedSize = maxValue.MostSignificantBit();
0 => 0,
_ => storage.Values.AsParallel().Max(row =>
{
var value32 = Value32.Create(info.Getter(row));
return value32.GetValue<int>().MostSignificantBit();
}),
};

newCompressedSize = largestMSB + 1;
}
else
{
var maxValue = storage.Values.Count switch
{
0 => 0U,
_ => storage.Values.AsParallel().Max(row =>
{
var value32 = Value32.Create(info.Getter(row));
return value32.GetValue<uint>();
}),
};

newCompressedSize = maxValue.MostSignificantBit();
}
}
break;
}
Expand Down

0 comments on commit 93740e8

Please sign in to comment.