diff --git a/CSharp/DSDecmp/DSDecmp.csproj b/CSharp/DSDecmp/DSDecmp.csproj index aa3ccea..afdfb04 100644 --- a/CSharp/DSDecmp/DSDecmp.csproj +++ b/CSharp/DSDecmp/DSDecmp.csproj @@ -58,7 +58,6 @@ - diff --git a/CSharp/DSDecmp/Formats/CompositeFormat.cs b/CSharp/DSDecmp/Formats/CompositeFormat.cs index 5a212e9..c10cdad 100644 --- a/CSharp/DSDecmp/Formats/CompositeFormat.cs +++ b/CSharp/DSDecmp/Formats/CompositeFormat.cs @@ -5,19 +5,43 @@ using System.IO; namespace DSDecmp.Formats { + /// + /// A format that is composed of multiple formats. + /// When compressing, the input is compressed using the best contained format. + /// When decompressing, all contained formats will try to decompress the file, until one succeeds. + /// public abstract class CompositeFormat : CompressionFormat { + /// + /// The actual list of formats this format is somposed of. + /// private List formats; + + #region Constructors + + /// + /// Creates a new composite format based on the given sequence of formats. + /// protected CompositeFormat(IEnumerable formats) { this.formats = new List(formats); } + /// + /// Creates a new composite format based on the given formats. + /// protected CompositeFormat(params CompressionFormat[] formats) { this.formats = new List(formats); } + #endregion + + + #region Method: Supports + /// + /// Checks if any of the contained formats supports the given input. + /// public override bool Supports(System.IO.Stream stream, long inLength) { foreach (CompositeFormat fmt in this.formats) @@ -27,7 +51,13 @@ namespace DSDecmp.Formats } return false; } + #endregion + #region Method: Decompress + /// + /// Attempts to decompress the given input by letting all contained formats + /// try to decompress the input. + /// public override long Decompress(System.IO.Stream instream, long inLength, System.IO.Stream outstream) { byte[] inputData = new byte[instream.Length]; @@ -57,8 +87,17 @@ namespace DSDecmp.Formats throw new InvalidDataException("Input cannot be decompressed using the " + this.ShortFormatString + " formats."); } + #endregion + #region Method: Compress & Field: LastUsedCompressFormatString + /// + /// Gets the ShortFormatString of the last CompressionFormat that was used to compress input. + /// public string LastUsedCompressFormatString { get; private set; } + /// + /// Compresses the given input using the contained format that yields the best results in terms of + /// size reduction. + /// public override int Compress(System.IO.Stream instream, long inLength, System.IO.Stream outstream) { // only read the input data once from the file. @@ -110,7 +149,12 @@ namespace DSDecmp.Formats this.LastUsedCompressFormatString = bestFormatString; return minCompSize; } + #endregion + #region Method: ParseCompressionOptions(args) + /// + /// Handles the compression options for each of the contained compression formats. + /// public override int ParseCompressionOptions(string[] args) { // try each option on each of the formats. @@ -144,5 +188,7 @@ namespace DSDecmp.Formats } return totalOptionCount; } + #endregion + } } diff --git a/CSharp/DSDecmp/Formats/LZOvl.cs b/CSharp/DSDecmp/Formats/LZOvl.cs index ec85580..ebdf499 100644 --- a/CSharp/DSDecmp/Formats/LZOvl.cs +++ b/CSharp/DSDecmp/Formats/LZOvl.cs @@ -13,21 +13,33 @@ namespace DSDecmp.Formats /// public sealed class LZOvl : CompressionFormat { + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "LZ-Ovl"; } } + /// + /// Gets a short description of this compression format (used in the program usage). + /// public override string Description { get { return "Reverse LZ format, mainly used in 'overlay' files of NDS games."; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "lzovl"; } } + /// + /// Gets if this format supports compressing a file. + /// public override bool SupportsCompression { get { return true; } @@ -44,6 +56,10 @@ namespace DSDecmp.Formats set { lookAhead = value; } } + /// + /// Checks if the given aguments have the '-opt' option, which makes this format + /// compress using (near-)optimal compression instead of the original compression algorithm. + /// public override int ParseCompressionOptions(string[] args) { if (args.Length > 0) @@ -56,6 +72,9 @@ namespace DSDecmp.Formats } #region Method: Supports(string file) + /// + /// Checks if this format supports decompressing the given file. + /// public override bool Supports(string file) { using (FileStream fstr = File.OpenRead(file)) @@ -70,6 +89,9 @@ namespace DSDecmp.Formats #endregion #region Method: Supports(Stream, long) + /// + /// Checks if this format supports decompressing the given input. + /// public override bool Supports(System.IO.Stream stream, long inLength) { // assume the 'inLength' does not include the 12 bytes at the end of arm9.bin @@ -113,6 +135,9 @@ namespace DSDecmp.Formats #endregion #region Method: Decompress(string, string) + /// + /// Decompresses the given input file to the given output file using the LZ-Overlay compression format. + /// public override void Decompress(string infile, string outfile) { // make sure the output directory exists @@ -133,6 +158,9 @@ namespace DSDecmp.Formats #endregion #region Decompression method + /// + /// Decompresses the given input using the LZ-Overlay compression scheme. + /// public override long Decompress(System.IO.Stream instream, long inLength, System.IO.Stream outstream) { #region Format description @@ -325,6 +353,9 @@ namespace DSDecmp.Formats #endregion #region Compression method; delegates to CompressNormal + /// + /// Compresses the input using the LZ-Overlay compression scheme. + /// public override int Compress(System.IO.Stream instream, long inLength, System.IO.Stream outstream) { // don't bother trying to get the optimal not-compressed - compressed ratio for now. diff --git a/CSharp/DSDecmp/Formats/Nitro/CompositeFormats.cs b/CSharp/DSDecmp/Formats/Nitro/CompositeFormats.cs index fff944e..25edb70 100644 --- a/CSharp/DSDecmp/Formats/Nitro/CompositeFormats.cs +++ b/CSharp/DSDecmp/Formats/Nitro/CompositeFormats.cs @@ -4,52 +4,88 @@ using System.Text; namespace DSDecmp.Formats.Nitro { + /// + /// A composite format with all formats supported natively by the GBA. + /// public class CompositeGBAFormat : CompositeFormat { + /// + /// Creates a new instance of the format composed of all native GBA compression formats. + /// public CompositeGBAFormat() : base(new Huffman4(), new Huffman8(), new LZ10()) { } + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "GBA"; } } + /// + /// Gets a short description of this compression format (used in the program usage). + /// public override string Description { get { return "All formats natively supported by the GBA."; } } + /// + /// Gets if this format supports compressing a file. + /// public override bool SupportsCompression { get { return true; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "gba*"; } } } + /// + /// A composite format with all formats supported natively by the NDS (but not LZ-Overlay) + /// public class CompositeNDSFormat : CompositeFormat { + /// + /// Creates a new instance of the format composed of all native NDS compression formats. + /// public CompositeNDSFormat() : base(new Huffman4(), new Huffman8(), new LZ10(), new LZ11()) { } + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "NDS"; } } + /// + /// Gets a short description of this compression format (used in the program usage). + /// public override string Description { get { return "All formats natively supported by the NDS."; } } + /// + /// Gets if this format supports compressing a file. + /// public override bool SupportsCompression { get { return true; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "nds*"; } diff --git a/CSharp/DSDecmp/Formats/Nitro/Huffman.cs b/CSharp/DSDecmp/Formats/Nitro/Huffman.cs index 1632678..e765018 100644 --- a/CSharp/DSDecmp/Formats/Nitro/Huffman.cs +++ b/CSharp/DSDecmp/Formats/Nitro/Huffman.cs @@ -11,25 +11,66 @@ namespace DSDecmp.Formats.Nitro /// public abstract class Huffman : NitroCFormat { - public enum BlockSize : byte { FOURBIT = 0x24, EIGHTBIT = 0x28 } + #region Enum: BlockSize + /// + /// The possible data sizes used in Huffman compression formats on the GBA/NDS. + /// + public enum BlockSize : byte + { + /// + /// Each data block is four bits long. + /// + FOURBIT = 0x24, + /// + /// Each data block is eight bits long. + /// + EIGHTBIT = 0x28 + } + #endregion /// /// Sets the block size used when using the Huffman format to compress. /// public BlockSize CompressBlockSize { get; set; } + /// + /// Gets if this format supports compression. Always returns true. + /// public override bool SupportsCompression { get { return true; } } - public Huffman(BlockSize blockSize) + + #region Internal Constructor(BlockSize) + /// + /// Creates a new generic instance of the Huffman compression format. + /// + /// The block size used. + internal Huffman(BlockSize blockSize) : base((byte)blockSize) { this.CompressBlockSize = blockSize; } + #endregion + #region Decompression method + /// + /// Decompresses the given stream, writing the decompressed data to the given output stream. + /// Assumes Supports(instream) returns true. + /// After this call, the input stream will be positioned at the end of the compressed stream, + /// or at the initial position + inLength, whichever comes first. + /// + /// The stream to decompress. At the end of this method, the position + /// of this stream is directly after the compressed data. + /// The length of the input data. Not necessarily all of the + /// input data may be read (if there is padding, for example), however never more than + /// this number of bytes is read from the input stream. + /// The stream to write the decompressed data to. + /// The length of the output data. + /// When the given length of the input data + /// is not enough to properly decompress the input. public override long Decompress(Stream instream, long inLength, Stream outstream) { #region GBATEK format specification @@ -415,6 +456,9 @@ namespace DSDecmp.Formats.Nitro } #endregion + /// + /// Generates and returns a string-representation of the huffman tree starting at this node. + /// public override string ToString() { if (this.isData) @@ -431,23 +475,38 @@ namespace DSDecmp.Formats.Nitro #endregion } - public class Huffman4 : Huffman + /// + /// The Huffman compression scheme using 4-bit data blocks. + /// + public sealed class Huffman4 : Huffman { + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "Huffman-4"; } } + /// + /// Gets a short description of this compression format. + /// public override string Description { get { return "Huffman compression scheme using 4-bit datablocks."; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "huff4"; } } + /// + /// Creates a new instance of the 4-bit Huffman compression format. + /// public Huffman4() : base(BlockSize.FOURBIT) { } @@ -618,23 +677,38 @@ namespace DSDecmp.Formats.Nitro #endregion } - public class Huffman8 : Huffman + /// + /// The Huffman compression scheme using 8-bit data blocks. + /// + public sealed class Huffman8 : Huffman { + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "Huffman-8"; } } + /// + /// Gets a short description of this compression format. + /// public override string Description { get { return "Huffman compression scheme using 8-bit datablocks."; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "huff8"; } } + /// + /// Creates a new instance of the 4-bit Huffman compression format. + /// public Huffman8() : base(BlockSize.EIGHTBIT) { } @@ -950,26 +1024,44 @@ namespace DSDecmp.Formats.Nitro #endregion } + /// + /// Composite compression format representing both Huffman compression schemes. + /// public class HuffmanAny : CompositeFormat { + /// + /// Creates a new instance of the general Huffman compression format. + /// public HuffmanAny() : base(new Huffman4(), new Huffman8()) { } + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "Huffman"; } } + /// + /// Gets a short description of this compression format. + /// public override string Description { get { return "Either the Huffman-4 or Huffman-8 format."; } } + /// + /// Gets if this format supports compression. Always returns true. + /// public override bool SupportsCompression { get { return true; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "huff"; } diff --git a/CSharp/DSDecmp/Formats/Nitro/LZ10.cs b/CSharp/DSDecmp/Formats/Nitro/LZ10.cs index d0f50da..5815980 100644 --- a/CSharp/DSDecmp/Formats/Nitro/LZ10.cs +++ b/CSharp/DSDecmp/Formats/Nitro/LZ10.cs @@ -10,21 +10,33 @@ namespace DSDecmp.Formats.Nitro /// public sealed class LZ10 : NitroCFormat { + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "LZ-10"; } } + /// + /// Gets a short description of this compression format (used in the program usage). + /// public override string Description { get { return "Common LZ-type compression used in many post-GBC Nintendo games."; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "lz10"; } } + /// + /// Gets if this format supports compressing a file. + /// public override bool SupportsCompression { get { return true; } @@ -41,8 +53,15 @@ namespace DSDecmp.Formats.Nitro set { lookAhead = value; } } + /// + /// Creates a new instance of the LZ-10 compression format. + /// public LZ10() : base(0x10) { } + /// + /// Checks if the given aguments have the '-opt' option, which makes this format + /// compress using (near-)optimal compression instead of the original compression algorithm. + /// public override int ParseCompressionOptions(string[] args) { if (args.Length > 0) @@ -201,6 +220,11 @@ namespace DSDecmp.Formats.Nitro #endregion #region Original Compress method + /// + /// Compresses the input using the 'original', unoptimized compression algorithm. + /// This algorithm should yield files that are the same as those found in the games. + /// (delegates to the optimized method if LookAhead is set) + /// public unsafe override int Compress(Stream instream, long inLength, Stream outstream) { // make sure the decompressed size fits in 3 bytes. diff --git a/CSharp/DSDecmp/Formats/Nitro/LZ11.cs b/CSharp/DSDecmp/Formats/Nitro/LZ11.cs index 7a9c61c..8df76e7 100644 --- a/CSharp/DSDecmp/Formats/Nitro/LZ11.cs +++ b/CSharp/DSDecmp/Formats/Nitro/LZ11.cs @@ -11,21 +11,33 @@ namespace DSDecmp.Formats.Nitro /// public sealed class LZ11 : NitroCFormat { + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "LZ-11"; } } + /// + /// Gets a short description of this compression format (used in the program usage). + /// public override string Description { get { return "Variant of the LZ-0x10 format to support longer repetitions."; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "lz11"; } } + /// + /// Gets if this format supports compressing a file. + /// public override bool SupportsCompression { get { return true; } @@ -42,8 +54,15 @@ namespace DSDecmp.Formats.Nitro set { lookAhead = value; } } + /// + /// Creates a new instance of the LZ-11 compression format. + /// public LZ11() : base(0x11) { } + /// + /// Checks if the given aguments have the '-opt' option, which makes this format + /// compress using (near-)optimal compression instead of the original compression algorithm. + /// public override int ParseCompressionOptions(string[] args) { LookAhead = false; @@ -57,6 +76,9 @@ namespace DSDecmp.Formats.Nitro } #region Decompression method + /// + /// Decompresses the input using the LZ-11 compression scheme. + /// public override long Decompress(Stream instream, long inLength, Stream outstream) { #region Format definition in NDSTEK style @@ -268,6 +290,11 @@ namespace DSDecmp.Formats.Nitro #endregion #region Original compression method + /// + /// Compresses the input using the 'original', unoptimized compression algorithm. + /// This algorithm should yield files that are the same as those found in the games. + /// (delegates to the optimized method if LookAhead is set) + /// public unsafe override int Compress(Stream instream, long inLength, Stream outstream) { // make sure the decompressed size fits in 3 bytes. diff --git a/CSharp/DSDecmp/Formats/Nitro/NitroCFormat.cs b/CSharp/DSDecmp/Formats/Nitro/NitroCFormat.cs index 1199d73..98cec2f 100644 --- a/CSharp/DSDecmp/Formats/Nitro/NitroCFormat.cs +++ b/CSharp/DSDecmp/Formats/Nitro/NitroCFormat.cs @@ -27,11 +27,18 @@ namespace DSDecmp.Formats.Nitro /// protected byte magicByte; - public NitroCFormat(byte magicByte) + /// + /// Creates a new instance of the Nitro Compression Format base class. + /// + /// The expected first byte of the file for this format. + protected NitroCFormat(byte magicByte) { this.magicByte = magicByte; } + /// + /// Checks if the first four bytes match the format used in nitro compression formats. + /// public override bool Supports(System.IO.Stream stream, long inLength) { long startPosition = stream.Position; diff --git a/CSharp/DSDecmp/Formats/Nitro/RLE.cs b/CSharp/DSDecmp/Formats/Nitro/RLE.cs index 7843371..2f7b3af 100644 --- a/CSharp/DSDecmp/Formats/Nitro/RLE.cs +++ b/CSharp/DSDecmp/Formats/Nitro/RLE.cs @@ -11,28 +11,47 @@ namespace DSDecmp.Formats.Nitro /// public sealed class RLE : NitroCFormat { + /// + /// Gets a short string identifying this compression format. + /// public override string ShortFormatString { get { return "RLE"; } } + /// + /// Gets a short description of this compression format (used in the program usage). + /// public override string Description { get { return "Run-Length Encoding used in some modern Nintendo games."; } } + /// + /// Gets the value that must be given on the command line in order to compress using this format. + /// public override string CompressionFlag { get { return "rle"; } } + /// + /// Gets if this format supports compressing a file. + /// public override bool SupportsCompression { get { return true; } } + /// + /// Creates a new instance of the RLE compression format. + /// public RLE() : base(0x30) { } + #region Method: Decompress + /// + /// Decompresses the input using the RLE compression scheme. + /// public override long Decompress(Stream instream, long inLength, Stream outstream) { /* @@ -147,7 +166,12 @@ namespace DSDecmp.Formats.Nitro return decompressedSize; } + #endregion Decompress + #region Method: Compress + /// + /// Compresses the input using the RLE compression scheme. + /// public override int Compress(Stream instream, long inLength, Stream outstream) { @@ -273,5 +297,6 @@ namespace DSDecmp.Formats.Nitro // the total compressed stream length is the compressed data length + the 4-byte header return compLen + 4; } + #endregion Compress } } diff --git a/CSharp/DSDecmp/NewestProgram.cs b/CSharp/DSDecmp/NewestProgram.cs index b5f1cd1..bce536c 100644 --- a/CSharp/DSDecmp/NewestProgram.cs +++ b/CSharp/DSDecmp/NewestProgram.cs @@ -169,6 +169,9 @@ namespace DSDecmp bool decompressed = false; foreach (CompressionFormat format in formats) { + if (!format.SupportsDecompression) + continue; + #region try to decompress using the current format using (MemoryStream inStr = new MemoryStream(inputData), @@ -262,8 +265,19 @@ namespace DSDecmp #endregion Method: Decompress #region Method: Compress + /// + /// (Attempts to) Compress the given input to the given output, using the given format. + /// + /// The I/O arguments from the program input. + /// The desired format to compress with. private static void Compress(string[] ioArgs, CompressionFormat format) { + if (!format.SupportsCompression) + { + Console.WriteLine("Cannot compress using " + format.ShortFormatString + "; compression is not supported."); + return; + } + string[] inputFiles; string outputDir; bool copyErrors; @@ -302,7 +316,11 @@ namespace DSDecmp outStr.WriteTo(output); } compressed = true; - Console.WriteLine(format.ShortFormatString + "-compressed " + input + " to " + outputFile); + if (format is CompositeFormat) + Console.Write((format as CompositeFormat).LastUsedCompressFormatString); + else + Console.Write(format.ShortFormatString); + Console.WriteLine("-compressed " + input + " to " + outputFile); } } catch (Exception) { } @@ -346,6 +364,7 @@ namespace DSDecmp /// Parses the IO arguments of the input. /// /// The arguments to parse. + /// If the arguments are used for compression. If not, decompression is assumed. (used for default output folder name) /// The files to handle as input. /// The directory to save the handled files in. If this is null, /// the files should be overwritten. If this does not exist, it is the output file @@ -452,6 +471,12 @@ namespace DSDecmp } #endregion ParseIOArguments + #region Method: GuessExtension(magic, defaultExt) + /// + /// Guess the extension of a file by looking at the given magic bytes of a file. + /// If they are alphanumeric (without accents), they could indicate the type of file. + /// If no sensible extension could be found from the magic bytes, the given default extension is returned. + /// private static string GuessExtension(byte[] magic, string defaultExt) { string ext = ""; @@ -469,6 +494,7 @@ namespace DSDecmp return defaultExt; return ext; } + #endregion /// /// Copies the source file to the destination path. diff --git a/CSharp/PluginDistro/DSDecmp.xml b/CSharp/PluginDistro/DSDecmp.xml index 88aa0ad..acc65e7 100644 --- a/CSharp/PluginDistro/DSDecmp.xml +++ b/CSharp/PluginDistro/DSDecmp.xml @@ -247,6 +247,66 @@ Nitro Dcompressor instance. + + + Creates a new instance of the Nitro Compression Format base class. + + The expected first byte of the file for this format. + + + + Checks if the first four bytes match the format used in nitro compression formats. + + + + + A format that is composed of multiple formats. + When compressing, the input is compressed using the best contained format. + When decompressing, all contained formats will try to decompress the file, until one succeeds. + + + + + The actual list of formats this format is somposed of. + + + + + Creates a new composite format based on the given sequence of formats. + + + + + Creates a new composite format based on the given formats. + + + + + Checks if any of the contained formats supports the given input. + + + + + Attempts to decompress the given input by letting all contained formats + try to decompress the input. + + + + + Compresses the given input using the contained format that yields the best results in terms of + size reduction. + + + + + Handles the compression options for each of the contained compression formats. + + + + + Gets the ShortFormatString of the last CompressionFormat that was used to compress input. + + An exception thrown by the compression or decompression function, indicating that the @@ -264,6 +324,29 @@ newer Nintendo consoles and handhelds. + + + Creates a new instance of the LZ-11 compression format. + + + + + Checks if the given aguments have the '-opt' option, which makes this format + compress using (near-)optimal compression instead of the original compression algorithm. + + + + + Decompresses the input using the LZ-11 compression scheme. + + + + + Compresses the input using the 'original', unoptimized compression algorithm. + This algorithm should yield files that are the same as those found in the games. + (delegates to the optimized method if LookAhead is set) + + Variation of the original compression method, making use of Dynamic Programming to 'look ahead' @@ -284,6 +367,26 @@ The 'disp' values of the compressed blocks. May be 0, in which case the corresponding length will never be anything other than 1. + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format (used in the program usage). + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + Gets if this format supports compressing a file. + + Sets the flag that determines if 'look-ahead'/DP should be used when compressing @@ -297,6 +400,17 @@ newer Nintendo consoles and handhelds. + + + Creates a new instance of the LZ-10 compression format. + + + + + Checks if the given aguments have the '-opt' option, which makes this format + compress using (near-)optimal compression instead of the original compression algorithm. + + Decompress a stream that is compressed in the LZ-10 format. @@ -305,6 +419,13 @@ The length of the input stream. The output stream, where the decompressed data is written to. + + + Compresses the input using the 'original', unoptimized compression algorithm. + This algorithm should yield files that are the same as those found in the games. + (delegates to the optimized method if LookAhead is set) + + Variation of the original compression method, making use of Dynamic Programming to 'look ahead' @@ -324,6 +445,26 @@ The 'disp' values of the compressed blocks. May be 0, in which case the corresponding length will never be anything other than 1. + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format (used in the program usage). + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + Gets if this format supports compressing a file. + + Sets the flag that determines if 'look-ahead'/DP should be used when compressing @@ -337,6 +478,41 @@ newer Nintendo consoles and handhelds. + + + Creates a new instance of the RLE compression format. + + + + + Decompresses the input using the RLE compression scheme. + + + + + Compresses the input using the RLE compression scheme. + + + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format (used in the program usage). + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + Gets if this format supports compressing a file. + + The LZ-Overlay compression format. Compresses part of the file from end to start. @@ -345,6 +521,37 @@ decompressing arm9.bin. This is done automatically if a file is given instead of a stream. + + + Checks if the given aguments have the '-opt' option, which makes this format + compress using (near-)optimal compression instead of the original compression algorithm. + + + + + Checks if this format supports decompressing the given file. + + + + + Checks if this format supports decompressing the given input. + + + + + Decompresses the given input file to the given output file using the LZ-Overlay compression format. + + + + + Decompresses the given input using the LZ-Overlay compression scheme. + + + + + Compresses the input using the LZ-Overlay compression scheme. + + Compresses the given input stream with the LZ-Ovl compression, but compresses _forward_ @@ -382,6 +589,26 @@ The lengths of the compressed blocks, as gotten from GetOptimalCompressionLengths. The 'optimal' length of the compressed part of the file. + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format (used in the program usage). + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + Gets if this format supports compressing a file. + + Sets the flag that determines if 'look-ahead'/DP should be used when compressing @@ -389,16 +616,19 @@ implementation. - + - The formats allowed when compressing a file. + (Attempts to) Compress the given input to the given output, using the given format. + The I/O arguments from the program input. + The desired format to compress with. Parses the IO arguments of the input. The arguments to parse. + If the arguments are used for compression. If not, decompression is assumed. (used for default output folder name) The files to handle as input. The directory to save the handled files in. If this is null, the files should be overwritten. If this does not exist, it is the output file @@ -406,6 +636,13 @@ If files that cannot be handled (properly) should be copied to the output directory. True iff parsing of the arguments succeeded. + + + Guess the extension of a file by looking at the given magic bytes of a file. + If they are alphanumeric (without accents), they could indicate the type of file. + If no sensible extension could be found from the magic bytes, the given default extension is returned. + + Copies the source file to the destination path. @@ -504,12 +741,95 @@ Gets the number of items in this queue. + + + A composite format with all formats supported natively by the GBA. + + + + + Creates a new instance of the format composed of all native GBA compression formats. + + + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format (used in the program usage). + + + + + Gets if this format supports compressing a file. + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + A composite format with all formats supported natively by the NDS (but not LZ-Overlay) + + + + + Creates a new instance of the format composed of all native NDS compression formats. + + + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format (used in the program usage). + + + + + Gets if this format supports compressing a file. + + + + + Gets the value that must be given on the command line in order to compress using this format. + + Compressor and decompressor for the Huffman format used in many of the games for the newer Nintendo consoles and handhelds. + + + Creates a new generic instance of the Huffman compression format. + + The block size used. + + + + Decompresses the given stream, writing the decompressed data to the given output stream. + Assumes Supports(instream) returns true. + After this call, the input stream will be positioned at the end of the compressed stream, + or at the initial position + inLength, whichever comes first. + + The stream to decompress. At the end of this method, the position + of this stream is directly after the compressed data. + The length of the input data. Not necessarily all of the + input data may be read (if there is padding, for example), however never more than + this number of bytes is read from the input stream. + The stream to write the decompressed data to. + The length of the output data. + When the given length of the input data + is not enough to properly decompress the input. + Gets the tree node with the lowest priority (frequency) from the leaf and node queues. @@ -521,6 +841,26 @@ Sets the block size used when using the Huffman format to compress. + + + Gets if this format supports compression. Always returns true. + + + + + The possible data sizes used in Huffman compression formats on the GBA/NDS. + + + + + Each data block is four bits long. + + + + + Each data block is eight bits long. + + A single node in a Huffman tree. @@ -551,6 +891,12 @@ The child of this node at side 1 + + + The index of this node in the array for building the proper ordering. + If -1, this node has not yet been placed in the array. + + Manually creates a new node for a huffman tree. @@ -572,6 +918,11 @@ The indicated end of the huffman tree. If the stream is past this position, the tree is invalid. + + + Generates and returns a string-representation of the huffman tree starting at this node. + + The data contained in this node. May not mean anything when isData == false. @@ -620,9 +971,14 @@ Calculates the size of the sub-tree with this node as root. - + - Returns a seuqnce over the nodes of the sub-tree with this node as root in a pre-order fashion. (Root-Left-Right) + The Huffman compression scheme using 4-bit data blocks. + + + + + Creates a new instance of the 4-bit Huffman compression format. @@ -634,6 +990,31 @@ The stream to write the decompressed data to. The size of the decompressed data. + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format. + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + The Huffman compression scheme using 8-bit data blocks. + + + + + Creates a new instance of the 4-bit Huffman compression format. + + Applies Huffman compression with a datablock size of 8 bits. @@ -643,5 +1024,69 @@ The stream to write the decompressed data to. The size of the decompressed data. + + + Inserts the given node into the given array, in such a location that + the offset to both of its children is at most the given maximum, and as large as possible. + In order to do this, the contents of the array may be shifted to the right. + + The node to insert. + The array to insert the node in. + The maximum offset between parent and children. + + + + Shifts the node at the given index one to the right. + If the distance between parent and child becomes too large due to this shift, the parent is shifted as well. + + The array to shift the node in. + The index of the node to shift. + The maximum distance between parent and children. + + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format. + + + + + Gets the value that must be given on the command line in order to compress using this format. + + + + + Composite compression format representing both Huffman compression schemes. + + + + + Creates a new instance of the general Huffman compression format. + + + + + Gets a short string identifying this compression format. + + + + + Gets a short description of this compression format. + + + + + Gets if this format supports compression. Always returns true. + + + + + Gets the value that must be given on the command line in order to compress using this format. + + diff --git a/CSharp/PluginDistro/GoldenSunDD.dll b/CSharp/PluginDistro/GoldenSunDD.dll index 9274000..070f46c 100644 Binary files a/CSharp/PluginDistro/GoldenSunDD.dll and b/CSharp/PluginDistro/GoldenSunDD.dll differ diff --git a/CSharp/PluginDistro/LuminousArc.dll b/CSharp/PluginDistro/LuminousArc.dll index 2540b90..b4e0105 100644 Binary files a/CSharp/PluginDistro/LuminousArc.dll and b/CSharp/PluginDistro/LuminousArc.dll differ