diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-11-05 11:22:55 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-11-05 11:31:28 +0000 |
commit | 2fbdf974338bde8576efdae40a819a76b2391033 (patch) | |
tree | 64d41a37470143f142344f9a439d96de3e7918c2 /tools/rasm_src/decrunch/lz49decrunch_v001.asm | |
download | kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.tar.gz kitsunes-curse-2fbdf974338bde8576efdae40a819a76b2391033.zip |
Initial import of the open source release
Diffstat (limited to 'tools/rasm_src/decrunch/lz49decrunch_v001.asm')
-rw-r--r-- | tools/rasm_src/decrunch/lz49decrunch_v001.asm | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/tools/rasm_src/decrunch/lz49decrunch_v001.asm b/tools/rasm_src/decrunch/lz49decrunch_v001.asm new file mode 100644 index 0000000..7f811b5 --- /dev/null +++ b/tools/rasm_src/decrunch/lz49decrunch_v001.asm @@ -0,0 +1,138 @@ +;
+; LZ48 decrunch
+; input
+; hl compressed data adress
+; de output adress of data
+;
+; output
+; hl last adress of compressed data read (you must inc once for LZ48 stream)
+; de last adress of decrunched data write +1
+; bc always 3
+; a always zero
+; lx undetermined
+; flags (inc a -> 0)
+
+org #8000
+
+; CALL #8000,source,destination
+di
+
+; parameters
+ld h,(ix+3)
+ld l,(ix+2)
+ld d,(ix+1)
+ld e,(ix+0)
+
+call LZ49_decrunch
+
+ei
+ret
+
+
+
+
+
+LZ49_decrunch
+ldi
+ld b,0
+
+nextsequence
+ld a,(hl)
+inc hl
+ld lx,a
+and #70
+jr z,lzunpack ; no litteral bytes
+rrca
+rrca
+rrca
+rrca
+
+ld c,a
+cp 7 ; more bytes for length?
+jr nz,copyliteral
+
+getadditionallength
+ld a,(hl)
+inc hl
+inc a
+jr nz,lengthnext
+inc b
+dec bc
+jr getadditionallength
+lengthnext
+dec a
+add a,c
+ld c,a
+ld a,b
+adc a,0
+ld b,a ; bc=length
+
+copyliteral
+ldir
+
+lzunpack
+ld a,lx
+and #F
+add 3
+ld c,a
+cp 18 ; more bytes for length?
+jr nz,readoffset
+
+getadditionallengthbis
+ld a,(hl)
+inc hl
+inc a
+jr nz,lengthnextbis
+inc b
+dec bc
+jr getadditionallengthbis
+lengthnextbis
+dec a
+add a,c
+ld c,a
+ld a,b
+adc a,0
+ld b,a ; bc=length
+
+readoffset
+ld a,lx
+add a
+jr c,extendedoffset
+; read encoded offset
+ld a,(hl)
+inc a
+ret z ; LZ48 end with zero offset
+inc hl
+push hl
+ld l,a
+ld a,e
+sub l
+ld l,a
+ld a,d
+sbc a,0
+ld h,a
+; source=dest-copyoffset
+ldir
+pop hl
+jr nextsequence
+
+extendedoffset
+ld a,(hl)
+inc hl
+push hl
+inc a
+ld l,a
+ld a,e
+sub l
+ld l,a
+ld a,d
+sbc a,1
+ld h,a
+; source=dest-copyoffset
+ldir
+pop hl
+jr nextsequence
+
+
+
+
|