ndspy.codeCompression: Code Compression

ndspy.codeCompression provides functions for the compression format used for executable code files. (This is essentially the same as LZ10 compression, except that the file is decompressed in reverse, beginning at the end of the file. This allows for in-place decompression, which is more efficient.)

Note

If you’re using the ndspy.code module, compression is handled automatically for you, and you shouldn’t need to use this module explicitly.

ndspy.codeCompression.compress(data[, isArm9=False])

Compress code data. This is the inverse of decompress().

Parameters:
  • data (bytes) – The data to compress.
  • isArm9 (bool) –

    Whether the data to be compressed is a main ARM9 code file or not. ARM9 code needs to be compressed slightly differently. (This should be False for overlays.)

    default:False
Returns:

The compressed data.

Return type:

bytes

ndspy.codeCompression.decompress(data)

Decompress data that was compressed using code compression. This is the inverse of compress().

If the data does not seem to be compressed, it will be returned unmodified.

Parameters:data (bytes) – The compressed data.
Returns:The decompressed data.
Return type:bytes