Poke_Transporter_GB/include/zx0_decompressor.h
Philippe Symons 652f781454 More optimization: move code to IWRAM.
We can now decompress a 512 byte charset in 1 ms. (well, 1.370 ms to be exact)
2025-04-28 12:34:19 +02:00

33 lines
1.2 KiB
C++

#ifndef _ZX0_DECODE_H
#define _ZX0_DECODE_H
#include <cstdint>
// The ZX0 decompressor offers functionality to decompress data
// compressed with the ZX0 algorithm (see tools/compressZX0)
// This algorithm was invented by Einar Saukas
// Original implementation can be found here: https://github.com/einar-saukas/ZX0
// However, we've implemented a custom variant of this algorithm.
// (for instance: we're storing the uncompressed size in the first 2 bytes in little endian)
extern "C"
{
/**
* @brief This function slots the specified input_data buffer into the zx0 decompressor.
* Calling this function effectively resets the ZX0 decompressors' internal state.
*/
void zx0_decompressor_start(uint8_t *output_buffer, const uint8_t *input_data);
/**
* @brief This function returns the uncompressed size of the current input_data buffer.
* It reads this from the first 2 bytes of input_data
*/
uint32_t zx0_decompressor_get_decompressed_size();
/**
* @brief This function copies <num_bytes> of decompressed data into the specified <output_buffer>
* It will trigger decompression on the go (streaming basis)
*/
void zx0_decompressor_read(uint32_t num_bytes);
}
#endif