diff --git a/WAD/Header.cs b/WAD/Header.cs index f544587..e49a7e8 100644 --- a/WAD/Header.cs +++ b/WAD/Header.cs @@ -1,12 +1,26 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.WAD { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class Header { - public string? Signature { get; set; } - - public uint LumpCount { get; set; } - - public uint LumpOffset { get; set; } + /// + /// "WAD3" + /// + /// 4 bytes + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)] + public string? Signature; + + /// + /// Number of lumps in the file + /// + public uint LumpCount; + + /// + /// Offset where lumps are stored + /// + public uint LumpOffset; } } diff --git a/WAD/Lump.cs b/WAD/Lump.cs index a184507..5ba8aa5 100644 --- a/WAD/Lump.cs +++ b/WAD/Lump.cs @@ -1,22 +1,27 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.WAD { /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public sealed class Lump { - public uint Offset { get; set; } + public uint Offset; - public uint DiskLength { get; set; } + public uint DiskLength; - public uint Length { get; set; } + public uint Length; - public byte Type { get; set; } + public byte Type; - public byte Compression { get; set; } + public byte Compression; - public byte Padding0 { get; set; } + public byte Padding0; - public byte Padding1 { get; set; } + public byte Padding1; - public string? Name { get; set; } + /// 16 bytes + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] + public string? Name; } } diff --git a/WAD/LumpInfo.cs b/WAD/LumpInfo.cs index 4caeb5e..c6e9646 100644 --- a/WAD/LumpInfo.cs +++ b/WAD/LumpInfo.cs @@ -1,22 +1,38 @@ +using System.Runtime.InteropServices; + namespace SabreTools.Models.WAD { /// public sealed class LumpInfo { - public string? Name { get; set; } + /// + /// Type 0x42 has no name, type 0x43 does + /// + /// 16 bytes + [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] + public string? Name; - public uint Width { get; set; } + public uint Width; - public uint Height { get; set; } + public uint Height; - public uint PixelOffset { get; set; } + public uint PixelOffset; - // 12 bytes of unknown data + /// + /// Unknown data + /// + /// 12 bytes + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] + public byte[]? UnknownData; + /// Width * Height bytes located at PixelOffset public byte[]? PixelData { get; set; } + // TODO: Determine what mipmap data looks like + public uint PaletteSize { get; set; } + /// PaletteSize * 3 bytes public byte[]? PaletteData { get; set; } } }