From 30bf0f51335e87812ffeb54e9437f0b6a1514d67 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 6 Sep 2022 07:37:20 +0100 Subject: Updated rasm to 1.7 --- tools/rasm/decrunch/lz48decrunch_v006b.asm | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 tools/rasm/decrunch/lz48decrunch_v006b.asm (limited to 'tools/rasm/decrunch/lz48decrunch_v006b.asm') diff --git a/tools/rasm/decrunch/lz48decrunch_v006b.asm b/tools/rasm/decrunch/lz48decrunch_v006b.asm new file mode 100644 index 0000000..69162a4 --- /dev/null +++ b/tools/rasm/decrunch/lz48decrunch_v006b.asm @@ -0,0 +1,78 @@ +; +; LZ48 decrunch +; + +; In ; HL=compressed data address +; ; DE=output data address +; Out ; HL last address of compressed data read (you must inc once for LZ48 stream) +; ; DE last address of decrunched data write +1 +; ; BC always 3 +; ; A always zero +; ; IXL undetermined +; ; flags (inc a -> 0) +; Modif ; AF, BC, DE, HL, IXL +LZ48_decrunch + ldi + ld b,0 + +nextsequence + ld a,(hl) + inc hl + cp #10 + jr c,lzunpack ; no literal bytes + ld ixl,a + and #f0 + rrca + rrca + rrca + rrca + + cp 15 ; more bytes for literal length? + jr nz,copyliteral +getadditionallength + ld c,(hl) ; get additional literal length byte + inc hl + add a,c ; compute literal length total + jr nc,lengthNC + inc b +lengthNC + inc c + jr z,getadditionallength ; if last literal length byte was 255, we have more bytes to process +copyliteral + ld c,a + ldir + ld a,ixl + and #F +lzunpack + add 3 + cp 18 ; more bytes for match length? + jr nz,readoffset +getadditionallengthbis + ld c,(hl) ; get additional match length byte + inc hl + add a,c ; compute match length size total + jr nc,lengthNCbis + inc b +lengthNCbis + inc c + jr z,getadditionallengthbis ; if last match length byte was 255, we have more bytes to process + +readoffset + ld c,a +; read encoded offset + ld a,(hl) + inc a + ret z ; LZ48 end with zero offset + inc hl + push hl +; source=dest-copyoffset + ; A != 0 here + neg + ld l,a + ld h,#ff + add hl,de +copykey + ldir + + pop hl + jr nextsequence -- cgit v1.2.3