libnds
Loading...
Searching...
No Matches
Enumerations | Functions
decompress.h File Reference

Wraps the bios decompress functionality into something a bit easier to use. More...

#include <nds/bios.h>
#include <nds/ndstypes.h>

Enumerations

enum  DecompressType {
  LZ77 ,
  LZ77Vram ,
  HUFF ,
  RLE ,
  RLEVram
}
 The types of decompression available. More...
 

Functions

void decompress (const void *data, void *dst, DecompressType type)
 Decompresses data using the suported type.
 
void decompressStream (const void *data, void *dst, DecompressType type, getByteCallback readCB, getHeaderCallback getHeaderCB)
 Decompresses data using the suported type.
 
void decompressStreamStruct (const void *data, void *dst, DecompressType type, void *param, TDecompressionStream *ds)
 Decompresses data using the suported type.
 

Detailed Description

Wraps the bios decompress functionality into something a bit easier to use.

Enumeration Type Documentation

◆ DecompressType

The types of decompression available.

VRAM only accepts 16-bit and 32-bit writes. If the CPU tries to write in 8-bit units, the write is ignored. Due to how the BIOS decompresses data, some of the options of this enum are safe to be used in VRAM, and others aren't.

Enumerator
LZ77 

LZ77 decompression.

LZ77Vram 

LZ77 decompression (VRAM can be used as destination).

HUFF 

Huffman decompression (VRAM can be used as destination).

RLE 

Run Length Encoding decompression.

RLEVram 

Run Length Encoding decompression (VRAM can be used as detination).

Function Documentation

◆ decompress()

void decompress ( const void *  data,
void *  dst,
DecompressType  type 
)

Decompresses data using the suported type.

When 'type' is HUFF, this function will allocate 512 bytes in the stack as a temporary buffer.

Parameters
dstDestination to decompress to.
dataData to decompress.
typeType of data to decompress.

◆ decompressStream()

void decompressStream ( const void *  data,
void *  dst,
DecompressType  type,
getByteCallback  readCB,
getHeaderCallback  getHeaderCB 
)

Decompresses data using the suported type.

Only LZ77Vram, HUFF and RLEVram support streaming, but HUFF isn't supported by this function at all, use decompressStreamStruct() instead.

Parameters
dstDestination to decompress to.
dataData to decompress.
typeType of data to decompress.
readCBA callback to read the next byte of data.
getHeaderCBA callback to read the 32 byte header.

◆ decompressStreamStruct()

void decompressStreamStruct ( const void *  data,
void *  dst,
DecompressType  type,
void *  param,
TDecompressionStream ds 
)

Decompresses data using the suported type.

Only LZ77Vram, HUFF and RLEVram support streaming.

For HUFF, make sure to pass a 512 byte buffer in 'param' to be used as a temporary buffer by the decompression code.

Parameters
dstDestination to decompress to.
dataData to decompress.
typeType of data to decompress.
paramA value to be passed to getHeaderCallback(), or a temporary buffer for HUFF.
dsA struct with callbacks to be used by the decompression routine.