DSDecmp An exception indication that the input has more data than required in order to decompress it. This may indicate that more sub-files are present in the file. Creates a new exception indicating that the input has more data than necessary for decompressing th stream. It may indicate that other data is present after the compressed stream. The number of bytes read by the decompressor. The indicated length of the input stream. Gets the number of bytes read by the decompressed to decompress the stream. An exception indicating that the file cannot be compressed, because the decompressed size cannot be represented in the current compression format. Creates a new exception that indicates that the input is too big to be compressed. Class for I/O-related utility methods. Returns a 4-byte unsigned integer as used on the NDS converted from four bytes at a specified position in a byte array. The source of the data. The location of the data in the source. The indicated 4 bytes converted to uint Returns a 4-byte signed integer as used on the NDS converted from four bytes at a specified position in a byte array. The source of the data. The location of the data in the source. The indicated 4 bytes converted to int Converts a u32 value into a sequence of bytes that would make ToNDSu32 return the given input value. Returns a 3-byte integer as used in the built-in compression formats in the DS, convrted from three bytes at a specified position in a byte array, The source of the data. The location of the data in the source. The indicated 3 bytes converted to an integer. (Attempts to) load compression formats from the given file. The dll file to load. If formats without an empty contrsuctor should get a print. A list with an instance of all compression formats found in the given dll file. If the given file does not exist. If the file could not be loaded. If the file is not a valid assembly, or the loaded assembly is compiled with a higher version of .NET. Loads all compression formats found in the given folder. The folder to load plugins from. A list with an instance of all compression formats found in the given folder. Gets the full path to the parent directory of the given path. The path to get the parent directory path of. The full path to the parent directory of teh given path. Base class for all compression formats. Checks if the decompressor for this format supports the given file. Assumes the file exists. Returns false when it is certain that the given file is not supported. False positives may occur, as this method should not do any decompression, and may mis-interpret a similar file format as compressed. The name of the file to check. False if the file can certainly not be decompressed using this decompressor. True if the file may potentially be decompressed using this decompressor. Checks if the decompressor for this format supports the data from the given stream. Returns false when it is certain that the given data is not supported. False positives may occur, as this method should not do any decompression, and may mis-interpret a similar data format as compressed. The stream that may or may not contain compressed data. The position of this stream may change during this call, but will be returned to its original position when the method returns. The length of the input stream. False if the data can certainly not be decompressed using this decompressor. True if the data may potentially be decompressed using this decompressor. Decompresses the given file, writing the deocmpressed data to the given output file. The output file will be overwritten if it already exists. Assumes Supports(infile) returns true. The file to decompress. The target location of the decompressed file. 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. Compresses the given input file, and writes the compressed data to the given output file. The file to compress. The file to write the compressed data to. The size of the compressed file. If -1, the file could not be compressed. Compresses the next inLength bytes from the input stream, and writes the compressed data to the given output stream. The stream to read plaintext data from. The length of the plaintext data. The stream to write the compressed data to. The size of the compressed stream. If -1, the file could not be compressed. Parses any input specific for this format. Does nothing by default. Any arguments that may be used by the format. The number of input arguments consumed by this format. 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 if this format supports decompressing a file. Gets the value that must be given on the command line in order to compress using this format. Utility class for compression using LZ-like compression schemes. Determine the maximum size of a LZ-compressed block starting at newPtr, using the already compressed data starting at oldPtr. Takes O(inLength * oldLength) = O(n^2) time. The start of the data that needs to be compressed. The number of bytes that still need to be compressed. (or: the maximum number of bytes that _may_ be compressed into one block) The start of the raw file. The number of bytes already compressed. The offset of the start of the longest block to refer to. The minimum allowed value for 'disp'. The length of the longest sequence of bytes that can be copied from the already decompressed data. Base class for Nitro-based decompressors. Uses the 1-byte magic and 3-byte decompression size format. If true, Nitro Decompressors will not decompress files that have a decompressed size (plaintext size) larger than MaxPlaintextSize. The maximum allowed size of the decompressed file (plaintext size) allowed for Nitro Decompressors. Only used when SkipLargePlaintexts = true. The first byte of every file compressed with the format for this particular 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 (or eight) 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 given input length was too large for the given input stream. Creates a new exception that indicates that the stream was shorter than the given input length. Compressor and decompressor for the LZ-0x11 format used in many of the games for the 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' and determine the optimal 'length' values for the compressed blocks. Is not 100% optimal, as the flag-bytes are not taken into account. Gets the optimal compression lengths for each start of a compressed block using Dynamic Programming. This takes O(n^2) time, although in practice it will often be O(n^3) since one of the constants is 0x10110 (the maximum length of a compressed block) The data to compress. The length of the data to compress. The optimal 'length' of the compressed blocks. For each byte in the input data, this value is the optimal 'length' value. If it is 1, the block should not be compressed. 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 with the LZ-11 format. The default is false, which is what is used in the original implementation. Compressor and decompressor for the LZ-0x10 format used in many of the games for the 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. The compressed stream. 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' and determine the optimal 'length' values for the compressed blocks. Is not 100% optimal, as the flag-bytes are not taken into account. Gets the optimal compression lengths for each start of a compressed block using Dynamic Programming. This takes O(n^2) time. The data to compress. The length of the data to compress. The optimal 'length' of the compressed blocks. For each byte in the input data, this value is the optimal 'length' value. If it is 1, the block should not be compressed. 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 with the LZ-10 format. The default is false, which is what is used in the original implementation. Compressor and decompressor for the RLE format used in several of the games for the 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. Is used for the 'overlay' files in NDS games, as well as arm9.bin. Note that the last 12 bytes should not be included in the 'inLength' argument when 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_ instad of backwards. The input stream to compress. The length of the input stream. The stream to write to. Variation of the original compression method, making use of Dynamic Programming to 'look ahead' and determine the optimal 'length' values for the compressed blocks. Is not 100% optimal, as the flag-bytes are not taken into account. Gets the optimal compression lengths for each start of a compressed block using Dynamic Programming. This takes O(n^2) time. The data to compress. The length of the data to compress. The optimal 'length' of the compressed blocks. For each byte in the input data, this value is the optimal 'length' value. If it is 1, the block should not be compressed. The 'disp' values of the compressed blocks. May be less than 3, in which case the corresponding length will never be anything other than 1. Gets the 'optimal' length of the compressed part of the file. Or rather: the length in such a way that compressing any more will not result in a shorter file. 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 with the LZ-Ovl format. The default is false, which is what is used in the original implementation. (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 (the input may only contain one file if that si the case). 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. Gets the compression format corresponding to the given format string. Gets a sequence over all compression formats currently supported; both built-in and plugin-based. Gets a sequence over all built-in compression formats. If the built-in composite formats should also be part of the sequence. Gets a sequence over all formats that can be used from plugins. Gets the first item from the given sequence, or the default value of the type in the sequence if it is empty. An exception that is thrown by the decompression functions when there is not enough data available in order to properly decompress the input. Creates a new NotEnoughDataException. The actual number of written bytes. The desired number of written bytes. Gets the actual number of written bytes. Gets the number of bytes that was supposed to be written. Very simplistic implementation of a priority queue that returns items with lowest priority first. This is not the most efficient implementation, but required the least work while using the classes from the .NET collections, and without requiring importing another dll or several more class files in order to make it work. The type of the priority values. The type of item to put into the queue. Creates a new, empty reverse priority queue. Enqueues the given value, using the given priority. The priority of the value. The value to enqueue. Gets the current value with the lowest priority from this queue, without dequeueing the value. The priority of the returned value. The current value with the lowest priority. If there are no items left in this queue. Dequeues the current value at the head of thisreverse priority queue. The priority of the dequeued value. The dequeued value, that used to be at the head of this queue. If this queue does not contain any items. 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. If the priority is the same for both head items in the queues, the node from the leaf queue is picked. 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. The data contained in this node. May not mean anything when isData == false A flag indicating if this node has been filled. A flag indicating if this node contains data. If not, this is not a leaf node. The child of this node at side 0 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. The data for this node. If this node represents data. The child of this node on the 0 side. The child of this node on the 1 side. Creates a new node in the Huffman tree. The stream to read from. It is assumed that there is (at least) one more byte available to read. If this node is a data-node. The offset of this node in the source data, relative to the start of the compressed file. 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. Throws a NullReferenceException when this node has not been defined (ie: reference was outside the bounds of the tree definition) Returns true if this node represents data. The child of this node at side 0 The child of this node at side 1 The parent node of this node. Determines if this is the Child0 of the parent node. Assumes there is a parent. Determines if this is the Child1 of the parent node. Assumes there is a parent. Get or set the depth of this node. Will not be set automatically, but will be set recursively (the depth of all child nodes will be updated when this is set). Calculates the size of the sub-tree with this node as root. The Huffman compression scheme using 4-bit data blocks. Creates a new instance of the 4-bit Huffman compression format. Applies Huffman compression with a datablock size of 4 bits. The stream to compress. The length of the input stream. 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. The stream to compress. The length of the input stream. 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. 'Compression' format without any compression whatsoever. Compression using this format will only prepend 0x00 plus the original file size to the file. Creates a new instance of the NULL-compression format. Checks if the given stream is (or could be) 'compressed' using the NULL compression format. 'Decompresses' the given input stream using the NULL format. 'Compresses' the given input stream using the NULL format. 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.