Triforce v0.9.0

Character tab, faster renderer defaults, HD rumble shipped, and the 11-30 bug pass: ending softlock below 60 fps, adult first-night lock, Intel Arc robust buffers, adult map, randomizer load order.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-30 20:55:14 -06:00
parent 8cb23131f9
commit 822ee913bc
86 changed files with 8128 additions and 438 deletions

View File

@@ -18,6 +18,9 @@ namespace Triforce.Core.GameFiles;
public sealed record BntxTexture(string Name, int Width, int Height, uint Format, int MipCount, int TileMode,
int BlockHeightLog2, long DataOffset, long ImageSize, byte[] ChannelSources)
{
/// <summary>((Triforce, 11-29) Where each mip level's data starts in the file (level 0 is DataOffset).</summary>
public long[] MipOffsets { get; init; } = Array.Empty<long>();
/// <summary>The format's kind (high byte), e.g. 0x2d for ASTC 4x4.</summary>
public int Kind => (int)(Format >> 8);
@@ -58,8 +61,11 @@ public sealed class Bntx
if (nameLength > 1024 || nameAt + 2 + nameLength > data.Length) throw new InvalidDataException("BNTX texture " + i + "'s name is too long");
var name = Encoding.UTF8.GetString(data, (int)nameAt + 2, nameLength);
var mips = (long)U64(p + 0x70);
int mipCount = Math.Clamp((int)U16(p + 0x16), 1, 16);
var offs = new long[mipCount];
for (var k = 0; k < mipCount; k++) offs[k] = mips + 8L * k + 8 <= data.Length ? (long)U64(mips + 8L * k) : 0;
var tex = new BntxTexture(name, (int)U32(p + 0x24), (int)U32(p + 0x28), U32(p + 0x1C), U16(p + 0x16), U16(p + 0x12),
(int)(U32(p + 0x34) & 7), (long)U64(mips), U32(p + 0x50), data[(int)(p + 0x58)..(int)(p + 0x5C)]);
(int)(U32(p + 0x34) & 7), (long)U64(mips), U32(p + 0x50), data[(int)(p + 0x58)..(int)(p + 0x5C)]) { MipOffsets = offs };
list.Add(tex);
byName.TryAdd(name, tex);
}
@@ -96,6 +102,7 @@ public sealed class Bntx
0x1c => BlockCompression.Decode(linear, t.Width, t.Height, BlockCompression.Kind.BC3),
0x1d => BlockCompression.Decode(linear, t.Width, t.Height, BlockCompression.Kind.BC4),
0x1e => BlockCompression.Decode(linear, t.Width, t.Height, BlockCompression.Kind.BC5),
0x20 => Bc7.Decode(linear, t.Width, t.Height),
0x0b => linear,
0x0c => Swap(linear, 2, 1, 0, 3),
0x02 => Expand(linear, 1),
@@ -108,13 +115,13 @@ public sealed class Bntx
}
/// <summary>The block size and bytes per block of a format (1x1 for an uncompressed one).</summary>
static (int W, int H, int Bytes) BlockInfo(uint format) => (format >> 8) switch
public static (int W, int H, int Bytes) BlockInfo(uint format) => (format >> 8) switch
{
0x02 => (1, 1, 1),
0x09 => (1, 1, 2),
0x0b or 0x0c => (1, 1, 4),
0x1a or 0x1d => (4, 4, 8),
0x1b or 0x1c or 0x1e => (4, 4, 16),
0x1b or 0x1c or 0x1e or 0x20 => (4, 4, 16),
var k and >= 0x2d and <= 0x3a => (AstcBlocks[k - 0x2d].W, AstcBlocks[k - 0x2d].H, 16),
_ => throw new NotSupportedException("texture format " + FormatName(format) + " is not supported"),
};