LZ4 I/O stream decompressor (132 bytes long, no ZeroPage use or 118 bytes using ZeroPage).
CODE: xxl, fox ENTRY: destination adress store in DEST
unlz4
jsr xBIOS_GET_BYTE ; length of literals
sta token
:4 lsr
beq read_offset ; there is no literal
cmp #$0f
jsr getlength
literals jsr xBIOS_GET_BYTE
jsr store
bne literals
read_offset jsr xBIOS_GET_BYTE
tay
sec
eor #$ff
adc dest
sta src
tya
php
jsr xBIOS_GET_BYTE
plp
bne not_done
tay
beq unlz4_done
not_done eor #$ff
adc dest+1
sta src+1
; c=1
lda #$ff
token equ *-1
and #$0f
adc #$03 ; 3+1=4
cmp #$13
jsr getLength
@ lda $ffff
src equ *-2
inw src
jsr store
bne @-
beq unlz4 ; zawsze
store sta $ffff
dest equ *-2
inw dest
dec lenL
bne unlz4_done
dec lenH
unlz4_done rts
getLength_next jsr xBIOS_GET_BYTE
tay
clc
adc #$00
lenL equ *-1
bcc @+
inc lenH
@ iny
getLength sta lenL
beq getLength_next
tay
beq @+
inc lenH
@ rts
lenH .byte $00 Jeśli dane znajdują się w pamięci a nie w pliku należy wymienić odwołania: jsr xBIOS_GET_BYTE na jsr GET_BYTEget_byte lda $ffff source equ *-2 inw source rtsJest to wariant dekompresora bez użycia komórek na stronie zerowej.
WAŻNE: Pomijamy nagłówek spakowanych danych (11 bajtów) oraz od 2 do 6 bajtów z końca pliku w zależności od kompresora.
opt h- ; nie potrzeba naglowka DOS ins 'TEST.LZ4',$0b,.FILESIZE 'TEST.LZ4'-$0b-$06 ; -$02 / -$06zobacz:
https://lz4.github.io/lz4/
https://github.com/lz4/lz4/releases/tag/v1.9.2
https://create.stephan-brumme.com/smallz4/
https://github.com/emmanuel-marty/lz4ultra
