Giter Club home page Giter Club logo

compress-lzsspack's Introduction

LzssPack

LzssPack is a simple command line packer with focus on vintage computing platforms. It uses byte-aligned compression scheme based on the Lempel–Ziv–Storer–Szymanski algorithm. The format was devised by Pavel "Zilog" Cimbal in 1998 during development of his program Trasher for Sinclair ZX Spectrum. The compression ratio was decent for the time, though it doesn't match the efficiency of contemporary utilities like LZSA, ZX0, LzxPack etc. Nevertheless, the format's simplicity makes it occasionally usable for quick on-the-fly decompression.

Stream Format

The stream uses byte-aligned markers. There are two types of blocks, literals and offset-length pairs (phrases). Literals can contain up to 128 bytes. Phrases are 3 to 10 bytes long with offsets ranging from 1 to 4095 bytes. Zero offset indicates end of stream.

The compressed stream is interpreted as follows (in binary):

CCCCCCC1 - Copy the next CCCCCCC + 1 bytes to the output.

CCCHHHH0 LLLLLLLL - Copy CCC + 3 bytes from the offset HHHHLLLLLLLL relative to the current output position.

00000000 00000000 - End of stream.

Sample Decoder

The following code is a Zilog Z80 implementation of the decoder (assumes reversed stream), created around the year 2000 by Pavel "Zilog" Cimbal with some help from demogroup 3SC (Milos "Baze" Bazelides, Juraj "Hvge" Durech and Marian "Beetle" Bobrik).

;       HL = source address
;       DE = destination address

Read    xor     a
        rr      (hl)
        ld      c,(hl)
        rrd
        ld      b,(hl)
        dec     hl
        jr      c,Copy
        ld      c,a
        or      (hl)
        ret     z
        push    hl
        ld      l,(hl)
        ld      h,c
        add     hl,de
        ld      c,b
        inc     c
        inc     c
Copy    inc     c
        ld      b,0
        lddr
        jr      c,Read
        pop     hl
        dec     hl
        jr      Read

compress-lzsspack's People

Contributors

mbaze avatar sp-milos avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.