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. 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 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. The formats allowed when compressing a file. Parses the IO arguments of the input. The arguments to parse. 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. 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. Compressor and decompressor for the Huffman format used in many of the games for the newer Nintendo consoles and handhelds. 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. 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 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. 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. Returns a seuqnce over the nodes of the sub-tree with this node as root in a pre-order fashion. (Root-Left-Right) 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. 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.