LZSS (LZ77) Decompression for SNES. More...
#include <snes/types.h>Go to the source code of this file.
Functions | |
| u16 | lzssDecodeRam (const u8 *source, u8 FAR *dest) |
| Decompress LZ77 data into RAM, screen on, interrupts left alone. | |
| void | lzssDecodeVram (const u8 *source, u16 address) |
| Decompress LZ77 data directly to VRAM. | |
LZSS (LZ77) Decompression for SNES.
LZ77 decompression into VRAM (lzssDecodeVram, under forced blank) or into RAM of any bank (lzssDecodeRam, screen on). Used for compressed tile/tilemap data written by opensnes-tileset convert --lz, opensnes-sprite sheet --lz or external LZ77 tools.
Decompress LZ77 data into RAM, screen on, interrupts left alone.
Expands an LZ77 stream (the format above, tag byte exactly 0x10) from ROM or RAM of any bank into RAM of any bank: a FAR buffer in bank $7E, the 64 KB of bank $7F, the low 8 KB. It writes no PPU register and does not mask interrupts, so it runs with the screen on while the NMI keeps its frame; the decoded block then goes to VRAM by DMA (dmaCopyVram, or the VRAM queue) like any RAM buffer.
Back references are copied with MVN when the destination is in bank $7E or $7F, and byte by byte through the data bank for any other bank. An overlapping reference (distance shorter than its length, distance 1 for a run of one byte) gives the LZ77 result, each byte read after the one before it is written.
Cost, measured with luna profile on examples/memory/lzss_ram (master cycles per output byte, SlowROM / FastROM): 104 / 88 for literals only, 101 / 87 for long references, 163 / 139 for a 2 bpp tile block (32768 bytes from 17856). 376 bytes of ROM, linked only by a ROM that calls it.
| source | LZ77 stream (tag 0x10, 3-byte length). It must not cross the end of its bank, as no asset section does. |
| dest | First byte written. The whole output must fit before the end of that bank. |
Decompress LZ77 data directly to VRAM.
Reads LZ77-compressed data from ROM/RAM and writes decompressed output directly to VRAM via PPU registers. It masks IRQs (sei) for the duration; it does NOT mask NMI — sei cannot — so call it under forced blank, where the NMI handler's own VRAM traffic is not a concern.
| source | Pointer to LZ77-compressed data (tag byte 0x10) |
| address | VRAM word address to write decompressed data |