Loading...
Searching...
No Matches
lzss.h File Reference

LZSS (LZ77) Decompression for SNES. More...

#include <snes/types.h>

Go to the source code of this file.

Functions

void LzssDecodeVram (u8 *source, u16 address)
 Decompress LZ77 data directly to VRAM.
 

Detailed Description

LZSS (LZ77) Decompression for SNES.

Provides LZ77 decompression directly to VRAM. Used for compressed tile/tilemap data generated by gfx4snes or external LZ77 tools.

LZ77 Format

  • Tag byte: 0x10
  • 3-byte little-endian uncompressed data length
  • Flag bytes: 8 bits each (1=reference, 0=literal)
  • References: 12-bit distance, 4-bit length (min 3 bytes)

Usage

extern u8 compressed_tiles[], compressed_tiles_end[];
// Decompress to VRAM during force blank
REG_INIDISP = 0x80; // Force blank (required for VRAM writes)
LzssDecodeVram(compressed_tiles, 0x0000);
REG_INIDISP = 0x0F; // Screen on, full brightness
#define REG_INIDISP
Display control (W)
Definition registers.h:49
unsigned char u8
8-bit unsigned integer (0 to 255)
Definition types.h:46
void LzssDecodeVram(u8 *source, u16 address)
Decompress LZ77 data directly to VRAM.
Warning
VRAM writes must happen during VBlank or force blank. LzssDecodeVram disables interrupts internally, so call it during force blank for safety.
Author
OpenSNES Team (ported from PVSnesLib by Alekmaul)

Function Documentation

◆ LzssDecodeVram()

void LzssDecodeVram ( u8 source,
u16  address 
)

Decompress LZ77 data directly to VRAM.

Reads LZ77-compressed data from ROM/RAM and writes decompressed output directly to VRAM via PPU registers. Disables interrupts during decompression to prevent NMI handler from interfering.

Parameters
sourcePointer to LZ77-compressed data (tag byte 0x10)
addressVRAM word address to write decompressed data
Note
The source data must start with the LZ77 tag byte (0x10). If the tag doesn't match, the function returns immediately.
Interrupts are disabled during decompression and restored after.