Fixed ui textures

This commit is contained in:
Jan Racek
2026-03-26 20:27:23 +01:00
parent d5be174247
commit 6bf74fa929
2 changed files with 18 additions and 3 deletions

View File

@@ -287,9 +287,10 @@ namespace SplashEdit.RuntimeCode
data.ClutY = (ushort)tex.ClutPackingY; data.ClutY = (ushort)tex.ClutPackingY;
data.U0 = (byte)(tex.PackingX * expander); data.U0 = (byte)(tex.PackingX * expander);
data.V0 = (byte)tex.PackingY; data.V0 = (byte)tex.PackingY;
// Width is already in source pixels = texture-pixel units // U1/V1 are the LAST texel (inclusive), not one-past-end.
data.U1 = (byte)(tex.PackingX * expander + tex.Width); // Without -1, values >= 256 overflow byte to 0.
data.V1 = (byte)(tex.PackingY + tex.Height); data.U1 = (byte)(tex.PackingX * expander + tex.Width - 1);
data.V1 = (byte)(tex.PackingY + tex.Height - 1);
data.BitDepthIndex = tex.BitDepth switch data.BitDepthIndex = tex.BitDepth switch
{ {
PSXBPP.TEX_4BIT => 0, PSXBPP.TEX_4BIT => 0,
@@ -297,6 +298,16 @@ namespace SplashEdit.RuntimeCode
PSXBPP.TEX_16BIT => 2, PSXBPP.TEX_16BIT => 2,
_ => 2 _ => 2
}; };
Debug.Log($"[UIImage] '{img.ElementName}' src='{(tex.OriginalTexture ? tex.OriginalTexture.name : "null")}' " +
$"bpp={(int)tex.BitDepth} W={tex.Width} H={tex.Height} QW={tex.QuantizedWidth} " +
$"packXY=({tex.PackingX},{tex.PackingY}) tpage=({tex.TexpageX},{tex.TexpageY}) " +
$"clutXY=({tex.ClutPackingX},{tex.ClutPackingY}) " +
$"UV=({data.U0},{data.V0})->({data.U1},{data.V1}) expander={expander} bitIdx={data.BitDepthIndex}");
}
else
{
Debug.LogWarning($"[UIImage] '{img.ElementName}' has NULL PackedTexture!");
} }
elements.Add(data); elements.Add(data);

View File

@@ -54,6 +54,10 @@ namespace SplashEdit.RuntimeCode
_reservedAreas.Add(framebuffers[0]); _reservedAreas.Add(framebuffers[0]);
_reservedAreas.Add(framebuffers[1]); _reservedAreas.Add(framebuffers[1]);
// Reserve the font column (x=960-1023) — custom fonts and the system font
// are placed here by PSXUIExporter, outside the packer's control.
_reservedAreas.Add(new Rect(960, 0, 64, VramHeight));
_vramPixels = new VRAMPixel[VramWidth, VramHeight]; _vramPixels = new VRAMPixel[VramWidth, VramHeight];
} }