mirror of
https://github.com/emmanuel-marty/lzsa.git
synced 2025-02-19 23:29:24 +00:00
Merge pull request #22 from specke/master
incorporated improvements by uniabis
This commit is contained in:
commit
3c690b04f5
@ -1,5 +1,6 @@
|
||||
;
|
||||
; Speed-optimized LZSA decompressor by spke (v.1 03-25/04/2019 +patch1-30/07/2019, 109 bytes)
|
||||
; Speed-optimized LZSA1 decompressor by spke (v.1 03-25/04/2019, 109 bytes);
|
||||
; with improvements by uniabis (30/07/2019, -1 byte, +3% speed).
|
||||
;
|
||||
; The data must be compressed using the command line compressor by Emmanuel Marty
|
||||
; The compression is done as follows:
|
||||
@ -12,7 +13,7 @@
|
||||
;
|
||||
; ld hl,FirstByteOfCompressedData
|
||||
; ld de,FirstByteOfMemoryForDecompressedData
|
||||
; call DecompressLZSA
|
||||
; call DecompressLZSA1
|
||||
;
|
||||
; Backward compression is also supported; you can compress files backward using:
|
||||
;
|
||||
@ -22,11 +23,11 @@
|
||||
;
|
||||
; ld hl,LastByteOfCompressedData
|
||||
; ld de,LastByteOfMemoryForDecompressedData
|
||||
; call DecompressLZSA
|
||||
; call DecompressLZSA1
|
||||
;
|
||||
; (do not forget to uncomment the BACKWARD_DECOMPRESS option in the decompressor).
|
||||
;
|
||||
; Of course, LZSA compression algorithm is (c) 2019 Emmanuel Marty,
|
||||
; Of course, LZSA compression algorithms are (c) 2019 Emmanuel Marty,
|
||||
; see https://github.com/emmanuel-marty/lzsa for more information
|
||||
;
|
||||
; Drop me an email if you have any comments/ideas/suggestions: zxintrospec@gmail.com
|
||||
@ -49,21 +50,7 @@
|
||||
|
||||
; DEFINE BACKWARD_DECOMPRESS
|
||||
|
||||
IFDEF BACKWARD_DECOMPRESS
|
||||
|
||||
MACRO NEXT_HL
|
||||
dec hl
|
||||
ENDM
|
||||
|
||||
MACRO ADD_OFFSET
|
||||
push hl : or a : sbc hl,de : pop de
|
||||
ENDM
|
||||
|
||||
MACRO BLOCKCOPY
|
||||
lddr
|
||||
ENDM
|
||||
|
||||
ELSE
|
||||
IFNDEF BACKWARD_DECOMPRESS
|
||||
|
||||
MACRO NEXT_HL
|
||||
inc hl
|
||||
@ -77,9 +64,24 @@
|
||||
ldir
|
||||
ENDM
|
||||
|
||||
ELSE
|
||||
|
||||
MACRO NEXT_HL
|
||||
dec hl
|
||||
ENDM
|
||||
|
||||
MACRO ADD_OFFSET
|
||||
ex de,hl : ld a,e : sub l : ld l,a
|
||||
ld a,d : sbc h : ld h,a ; 4*4+3*4 = 28t / 7 bytes
|
||||
ENDM
|
||||
|
||||
MACRO BLOCKCOPY
|
||||
lddr
|
||||
ENDM
|
||||
|
||||
ENDIF
|
||||
|
||||
@DecompressLZSA:
|
||||
@DecompressLZSA1:
|
||||
ld b,0 : jr ReadToken
|
||||
|
||||
NoLiterals: xor (hl) : NEXT_HL
|
||||
@ -90,7 +92,7 @@ ShortOffset: ld d,#FF : add 3 : cp 15+3 : jr nc,LongerMatch
|
||||
|
||||
; placed here this saves a JP per iteration
|
||||
CopyMatch: ld c,a
|
||||
.UseC ex (sp),hl ; BC = len, DE = offset, HL = dest, SP ->[src]
|
||||
.UseC ex (sp),hl ; BC = len, DE = offset, HL = dest, SP ->[dest,src]
|
||||
ADD_OFFSET ; BC = len, DE = dest, HL = dest-offset, SP->[src]
|
||||
BLOCKCOPY : pop hl ; BC = 0, DE = dest, HL = src
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
;
|
||||
; Size-optimized LZSA decompressor by spke (v.1 23/04/2019 +patch1-30/07/2019, 68 bytes)
|
||||
; Size-optimized LZSA1 decompressor by spke (v.1 23/04/2019, 68 bytes);
|
||||
; with improvements by uniabis (30/07/2019, -1 byte, +3% speed).
|
||||
;
|
||||
; The data must be compressed using the command line compressor by Emmanuel Marty
|
||||
; The compression is done as follows:
|
||||
@ -12,7 +13,7 @@
|
||||
;
|
||||
; ld hl,FirstByteOfCompressedData
|
||||
; ld de,FirstByteOfMemoryForDecompressedData
|
||||
; call DecompressLZSA
|
||||
; call DecompressLZSA1
|
||||
;
|
||||
; Backward compression is also supported; you can compress files backward using:
|
||||
;
|
||||
@ -22,11 +23,11 @@
|
||||
;
|
||||
; ld hl,LastByteOfCompressedData
|
||||
; ld de,LastByteOfMemoryForDecompressedData
|
||||
; call DecompressLZSA
|
||||
; call DecompressLZSA1
|
||||
;
|
||||
; (do not forget to uncomment the BACKWARD_DECOMPRESS option in the decompressor).
|
||||
;
|
||||
; Of course, LZSA compression algorithm is (c) 2019 Emmanuel Marty,
|
||||
; Of course, LZSA compression algorithms are (c) 2019 Emmanuel Marty,
|
||||
; see https://github.com/emmanuel-marty/lzsa for more information
|
||||
;
|
||||
; Drop me an email if you have any comments/ideas/suggestions: zxintrospec@gmail.com
|
||||
@ -49,21 +50,7 @@
|
||||
|
||||
; DEFINE BACKWARD_DECOMPRESS
|
||||
|
||||
IFDEF BACKWARD_DECOMPRESS
|
||||
|
||||
MACRO NEXT_HL
|
||||
dec hl
|
||||
ENDM
|
||||
|
||||
MACRO ADD_OFFSET
|
||||
push hl : or a : sbc hl,de : pop de
|
||||
ENDM
|
||||
|
||||
MACRO BLOCKCOPY
|
||||
lddr
|
||||
ENDM
|
||||
|
||||
ELSE
|
||||
IFNDEF BACKWARD_DECOMPRESS
|
||||
|
||||
MACRO NEXT_HL
|
||||
inc hl
|
||||
@ -77,9 +64,23 @@
|
||||
ldir
|
||||
ENDM
|
||||
|
||||
ELSE
|
||||
|
||||
MACRO NEXT_HL
|
||||
dec hl
|
||||
ENDM
|
||||
|
||||
MACRO ADD_OFFSET
|
||||
push hl : or a : sbc hl,de : pop de ; 11+4+15+10 = 40t / 5 bytes
|
||||
ENDM
|
||||
|
||||
MACRO BLOCKCOPY
|
||||
lddr
|
||||
ENDM
|
||||
|
||||
ENDIF
|
||||
|
||||
@DecompressLZSA:
|
||||
@DecompressLZSA1:
|
||||
ld b,0
|
||||
|
||||
; first a byte token "O|LLL|MMMM" is read from the stream,
|
||||
@ -106,10 +107,10 @@ ShortOffset: and #0F : add 3 ; MMMM<15 means match lengths 0+3..14+3
|
||||
cp 15+3 : call z,ReadLongBA ; MMMM=15 means lengths 14+3+
|
||||
ld c,a
|
||||
|
||||
ex (sp),hl ; BC = len, DE = -offset, HL = dest, SP ->[src]
|
||||
ADD_OFFSET ; BC = len, DE = dest, HL = dest+(-offset), SP->[src]
|
||||
BLOCKCOPY : pop hl ; BC = 0, DE = dest, HL = src
|
||||
jr ReadToken
|
||||
ex (sp),hl ; BC = len, DE = -offset, HL = dest, SP -> [src]
|
||||
ADD_OFFSET ; BC = len, DE = dest, HL = dest+(-offset), SP -> [src]
|
||||
BLOCKCOPY ; BC = 0, DE = dest
|
||||
pop hl : jr ReadToken ; HL = src
|
||||
|
||||
; a standard routine to read extended codes
|
||||
; into registers B (higher byte) and A (lower byte).
|
||||
|
Loading…
x
Reference in New Issue
Block a user