Add layouts for some WAD models

This commit is contained in:
Matt Nadareski
2024-04-23 15:56:43 -04:00
parent 8f3be17850
commit 8583baa862
3 changed files with 53 additions and 18 deletions

View File

@@ -1,12 +1,26 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.WAD
{
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
[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; }
/// <summary>
/// "WAD3"
/// </summary>
/// <remarks>4 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string? Signature;
/// <summary>
/// Number of lumps in the file
/// </summary>
public uint LumpCount;
/// <summary>
/// Offset where lumps are stored
/// </summary>
public uint LumpOffset;
}
}

View File

@@ -1,22 +1,27 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.WAD
{
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
[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; }
/// <remarks>16 bytes</remarks>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)]
public string? Name;
}
}

View File

@@ -1,22 +1,38 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.WAD
{
/// <see href="https://github.com/RavuAlHemio/hllib/blob/master/HLLib/WADFile.h"/>
public sealed class LumpInfo
{
public string? Name { get; set; }
/// <summary>
/// Type 0x42 has no name, type 0x43 does
/// </summary>
/// <remarks>16 bytes</remarks>
[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
/// <summary>
/// Unknown data
/// </summary>
/// <remarks>12 bytes</remarks>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
public byte[]? UnknownData;
/// <remarks>Width * Height bytes located at PixelOffset</remarks>
public byte[]? PixelData { get; set; }
// TODO: Determine what mipmap data looks like
public uint PaletteSize { get; set; }
/// <remarks>PaletteSize * 3 bytes</remarks>
public byte[]? PaletteData { get; set; }
}
}