Poke_Transporter_GB/include/text_data_table.h
Philippe Symons 47cd143de6 Replace ZX0 by the builtin LZ10 compression.
LZ10 decompression is builtin to the GBA's bios, so we don't need ZX0. It's also significantly faster
(618 usec instead of 2311 usec in my personal benchmark code for decompression of the same data)

And it seems like by doing so, we saved 1 KB as well!

So, seems like replacing ZX0 is the right move.

The reason I didn't initially is because I misunderstood the documentation. I assumed LZ77UnCompWram could only uncompress into EWRAM, not IWRAM.
But it turns out it can do both.

And using standardized tools is usually better than using a custom implementation.

The only downside of this right now, is that we can no longer stream text tables through a smaller buffer than the entire decompressed size.

Anyway, things seem to work fine, so bye bye ZX0. It's been fun.
2025-07-18 16:19:34 +02:00

42 lines
1.1 KiB
C++

#ifndef _TEXT_DATA_TABLE_H
#define _TEXT_DATA_TABLE_H
#include <cstdint>
/**
* This class fully decompresses a text table in the specified decompression_buffer
* and then gives you utility functions to retrieve the text entries
*
* But it requires a buffer large enough to contain the entire decompressed table.
*/
class text_data_table
{
public:
text_data_table(uint8_t *decompression_buffer);
/**
* This function will start the full decompression for the specified compressed_table
* and stores it in the decompression_buffer_
*/
void decompress(const uint8_t *compressed_table);
/**
* Returns the number of text entries in the decompression_buffer_
*/
uint16_t get_number_of_text_entries() const;
/**
* This function returns a pointer to a text entry in the decompression_buffer
*/
const uint8_t* get_text_entry(uint16_t index) const;
/**
* This function returns the text entry size in bytes at the given index
*/
uint16_t get_text_entry_size(uint16_t index) const;
private:
uint8_t *decompression_buffer_;
uint32_t decompressed_size_;
};
#endif