Further simplify LZ models

This commit is contained in:
Matt Nadareski
2024-12-11 03:48:10 -05:00
parent 6e1f8bf55e
commit 9d1b1ca36d
4 changed files with 5 additions and 100 deletions

View File

@@ -7,13 +7,5 @@ namespace SabreTools.Models.Compression.LZ
public static readonly byte[] SZDDSignatureBytes = [0x53, 0x5A, 0x44, 0x44, 0x88, 0xF0, 0x27, 0x33];
public static readonly byte[] QBasicSignatureBytes = [0x53, 0x5A, 0x20, 0x88, 0xF0, 0x27, 0x33, 0xD1];
public const int GETLEN = 2048;
public const int LZ_TABLE_SIZE = 0x1000;
public const int MAX_LZSTATES = 16;
public const int LZ_MIN_HANDLE = 0x400;
}
}

View File

@@ -70,28 +70,13 @@ namespace SabreTools.Models.Compression.LZ
HasAdditionalText = 0x0020,
}
/// <see href="https://github.com/wine-mirror/wine/blob/master/include/lzexpand.h"/>
public enum LZERROR
{
LZERROR_OK = 1,
LZERROR_NOT_LZ = 0,
LZERROR_BADINHANDLE = -1,
LZERROR_BADOUTHANDLE = -2,
LZERROR_READ = -3,
LZERROR_WRITE = -4,
LZERROR_GLOBALLOC = -5,
LZERROR_GLOBLOCK = -6,
LZERROR_BADVALUE = -7,
LZERROR_UNKNOWNALG = -8,
}
/// <see href="https://github.com/wine-mirror/wine/blob/master/dlls/kernel32/lzexpand.c"/>
/// <see href="https://www.cabextract.org.uk/libmspack/doc/szdd_kwaj_format.html"/>
public enum SZDDCompressionType : byte
public enum ExpandCompressionType : byte
{
/// <summary>
/// Only valid compression type: 'A'
/// </summary>
LZ = 0x41,
A = 0x41,
}
}

View File

@@ -8,7 +8,7 @@ namespace SabreTools.Models.Compression.LZ
/// <see href="https://github.com/wine-mirror/wine/blob/master/dlls/kernel32/lzexpand.c"/>
/// <see href="https://www.cabextract.org.uk/libmspack/doc/szdd_kwaj_format.html"/>
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public sealed class SZDDHeader
public sealed class ExpandHeader
{
/// <summary>
/// "SZDD" signature
@@ -19,9 +19,9 @@ namespace SabreTools.Models.Compression.LZ
/// <summary>
/// Compression mode
/// </summary>
/// <remarks>Only <see cref="SZDDCompressionType.LZ"/> is supported</remarks>
/// <remarks>Only <see cref="ExpandCompressionType.A"/> is supported</remarks>
[MarshalAs(UnmanagedType.U1)]
public SZDDCompressionType CompressionType;
public ExpandCompressionType CompressionType;
/// <summary>
/// The character missing from the end of the filename

View File

@@ -1,72 +0,0 @@
using System.IO;
namespace SabreTools.Models.Compression.LZ
{
public sealed class State
{
/// <summary>
/// Internal backing stream
/// </summary>
public Stream? Source { get; set; }
/// <summary>
/// The last char of the filename for replacement
/// </summary>
public char LastChar { get; set; }
/// <summary>
/// Decompressed length of the file
/// </summary>
public uint RealLength { get; set; }
/// <summary>
/// Position the decompressor currently is
/// </summary>
public uint RealCurrent { get; set; }
/// <summary>
/// Position the user wants to read from
/// </summary>
public uint RealWanted { get; set; }
/// <summary>
/// The rotating LZ table
/// </summary>
public byte[]? Table { get; set; }
/// <summary>
/// CURrent TABle ENTry
/// </summary>
public uint CurrentTableEntry { get; set; }
/// <summary>
/// Length and position of current string
/// </summary>
public byte StringLength { get; set; }
/// <summary>
/// From stringtable
/// </summary>
public uint StringPosition { get; set; }
/// <summary>
/// Bitmask within blocks
/// </summary>
public ushort ByteType { get; set; }
/// <summary>
/// GETLEN bytes
/// </summary>
public byte[]? Window { get; set; }
/// <summary>
/// Current read
/// </summary>
public uint WindowCurrent { get; set; }
/// <summary>
/// Length last got
/// </summary>
public uint WindowLength { get; set; }
}
}