mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2025-01-06 07:32:57 +00:00
commit
fb7e03030f
@ -1,5 +1,5 @@
|
|||||||
;
|
;
|
||||||
; Speed-optimized LZSA1 decompressor by spke & uniabis (111 bytes)
|
; Speed-optimized LZSA1 decompressor by spke & uniabis (109 bytes)
|
||||||
;
|
;
|
||||||
; ver.00 by spke for LZSA 0.5.4 (03-24/04/2019, 134 bytes);
|
; ver.00 by spke for LZSA 0.5.4 (03-24/04/2019, 134 bytes);
|
||||||
; ver.01 by spke for LZSA 0.5.6 (25/04/2019, 110(-24) bytes, +0.2% speed);
|
; ver.01 by spke for LZSA 0.5.6 (25/04/2019, 110(-24) bytes, +0.2% speed);
|
||||||
@ -9,7 +9,8 @@
|
|||||||
; ver.05 by uniabis (22/08/2019, 107(-2) bytes, same speed);
|
; ver.05 by uniabis (22/08/2019, 107(-2) bytes, same speed);
|
||||||
; ver.06 by spke for LZSA 1.0.7 (27/08/2019, 111(+4) bytes, +2.1% speed);
|
; ver.06 by spke for LZSA 1.0.7 (27/08/2019, 111(+4) bytes, +2.1% speed);
|
||||||
; ver.07 by spke for LZSA 1.1.0 (25/09/2019, added full revision history);
|
; ver.07 by spke for LZSA 1.1.0 (25/09/2019, added full revision history);
|
||||||
; ver.08 by spke for LZSA 1.1.2 (22/10/2019, re-organized macros and added an option for unrolled copying of long matches)
|
; ver.08 by spke for LZSA 1.1.2 (22/10/2019, re-organized macros and added an option for unrolled copying of long matches);
|
||||||
|
; ver.09 by spke for LZSA 1.2.1 (02/01/2020, 109(-2) bytes, same speed)
|
||||||
;
|
;
|
||||||
; The data must be compressed using the command line compressor by Emmanuel Marty
|
; The data must be compressed using the command line compressor by Emmanuel Marty
|
||||||
; The compression is done as follows:
|
; The compression is done as follows:
|
||||||
@ -102,11 +103,12 @@
|
|||||||
@DecompressLZSA1:
|
@DecompressLZSA1:
|
||||||
ld b,0 : jr ReadToken
|
ld b,0 : jr ReadToken
|
||||||
|
|
||||||
NoLiterals: xor (hl)
|
NoLiterals: xor (hl) : NEXT_HL : jp m,LongOffset
|
||||||
push de : NEXT_HL : ld e,(hl) : jp m,LongOffset
|
|
||||||
|
ShortOffset: push de : ld e,(hl) : ld d,#FF
|
||||||
|
|
||||||
; short matches have length 0+3..14+3
|
; short matches have length 0+3..14+3
|
||||||
ShortOffset: ld d,#FF : add 3 : cp 15+3 : jr nc,LongerMatch
|
add 3 : cp 15+3 : jr nc,LongerMatch
|
||||||
|
|
||||||
; placed here this saves a JP per iteration
|
; placed here this saves a JP per iteration
|
||||||
CopyMatch: ld c,a
|
CopyMatch: ld c,a
|
||||||
@ -121,18 +123,16 @@ ReadToken: ; first a byte token "O|LLL|MMMM" is read from the stream,
|
|||||||
ld a,(hl) : and #70 : jr z,NoLiterals
|
ld a,(hl) : and #70 : jr z,NoLiterals
|
||||||
|
|
||||||
cp #70 : jr z,MoreLiterals ; LLL=7 means 7+ literals...
|
cp #70 : jr z,MoreLiterals ; LLL=7 means 7+ literals...
|
||||||
rrca : rrca : rrca : rrca ; LLL<7 means 0..6 literals...
|
rrca : rrca : rrca : rrca : ld c,a ; LLL<7 means 0..6 literals...
|
||||||
|
|
||||||
ld c,a : ld a,(hl)
|
ld a,(hl) : NEXT_HL
|
||||||
NEXT_HL : COPYBC
|
COPYBC
|
||||||
|
|
||||||
; next we read the first byte of the offset
|
|
||||||
push de : ld e,(hl)
|
|
||||||
; the top bit of token is set if the offset contains two bytes
|
; the top bit of token is set if the offset contains two bytes
|
||||||
and #8F : jp p,ShortOffset
|
and #8F : jp p,ShortOffset
|
||||||
|
|
||||||
LongOffset: ; read second byte of the offset
|
LongOffset: ; read second byte of the offset
|
||||||
NEXT_HL : ld d,(hl)
|
push de : ld e,(hl) : NEXT_HL : ld d,(hl)
|
||||||
add -128+3 : cp 15+3 : jp c,CopyMatch
|
add -128+3 : cp 15+3 : jp c,CopyMatch
|
||||||
|
|
||||||
IFNDEF UNROLL_LONG_MATCHES
|
IFNDEF UNROLL_LONG_MATCHES
|
||||||
@ -186,13 +186,12 @@ VeryLongMatch: ; the codes are designed to overflow;
|
|||||||
ENDIF
|
ENDIF
|
||||||
|
|
||||||
MoreLiterals: ; there are three possible situations here
|
MoreLiterals: ; there are three possible situations here
|
||||||
xor (hl) : exa
|
xor (hl) : NEXT_HL : exa
|
||||||
ld a,7 : NEXT_HL : add (hl) : jr c,ManyLiterals
|
ld a,7 : add (hl) : jr c,ManyLiterals
|
||||||
|
|
||||||
CopyLiterals: ld c,a
|
CopyLiterals: ld c,a
|
||||||
.UseC NEXT_HL : COPYBC
|
.UseC NEXT_HL : COPYBC
|
||||||
|
|
||||||
push de : ld e,(hl)
|
|
||||||
exa : jp p,ShortOffset : jr LongOffset
|
exa : jp p,ShortOffset : jr LongOffset
|
||||||
|
|
||||||
ManyLiterals:
|
ManyLiterals:
|
||||||
|
Loading…
Reference in New Issue
Block a user