aPLib I/O stream decompressor.
CODE: xxl ENTRY: destination adress store in DEST_AP source packed data in memsrc
aPL_depack lda #$80
sta token
literal lsr bl
jsr xBIOS_GET_BYTE
write jsr store
nxt_token jsr get_token_bit
bcc literal ; literal -> 0
jsr get_token_bit
bcc block ; block -> 10
jsr get_token_bit
bcc short_block ; short block -> 110
single_byte lsr bl ; single byte -> 111
lda #$10
@ pha
jsr get_token_bit
pla
rol @
bcc @-
beq write
jmp len01
aPL_done rts
short_block jsr xBIOS_GET_BYTE
lsr @
beq aPL_done
sta EBPL
ldx #0
stx EBPH
ldx #$02
bcc @+
inx
@ sec
ror bl
jmp len0203
block jsr getgamma
dex
lda #$ff
bl equ *-1
bmi normalcodepair
dex
bne normalcodepair
jsr getgamma
lda #$ff
EBPL equ *-1
sta offsetL
lda #$ff
EBPH equ *-1
sta offsetH
jmp lenffff
normalcodepair dex
stx offsetH
stx EBPH
jsr xBIOS_GET_BYTE
sta offsetL
sta EBPL
jsr getgamma
lda offsetH
beq _ceck7f
cmp #$7d
bcs plus2
cmp #$05
bcs plus1
bcc normal1 ; zawsze
_ceck7f lda offsetL
bmi normal1
plus2 inx
bne plus1
iny
plus1 inx
normal1
lenffff iny
sec
ror bl
bne domatch ; zawsze
getgamma lda #$00
pha
lda #$01
pha
@ jsr get_token_bit
tsx
rol $101,x
rol $102,x
jsr get_token_bit
bcs @-
pla
tax
pla
tay
rts
get_token_bit asl token
bne @+
php
jsr xBIOS_GET_BYTE
plp
rol @
sta token
@ rts
token .byte $00
store sta $ffff
dest_ap equ *-2
inw dest_ap
rts
len01 ldx #$01
len0203 ldy #$00
sta offsetL
sty offsetH
iny
domatch lda dest_ap
sec
sbc #$ff
offsetL equ *-1
sta src
lda dest_ap+1
sbc #$ff
offsetH equ *-1
sta src+1
source lda $ffff
src equ *-2
inw src
jsr store
dex
bne source
dey
bne source
jmp nxt_token
Jeśli dane znajdują się w pamięci a nie w pliku należy wymienić odwołania:
jsr xBIOS_GET_BYTE na jsr GET_BYTE
get_byte lda $ffff
memsrc equ *-2
inw memsrc
rts
Jest to wariant dekompresora bez użycia komórek na stronie zerowej.
WAŻNE: Pomijamy nagłówek spakowanych danych (24 bajty kompresor APPACK, 12 bajtów kompresor APLPAK64 lub 0 bajtów kompresor APULTRA)
opt h- ; nie potrzeba naglowka DOS
ins 'TEST.APL',$18,.FILESIZE 'TEST.APL'-$18
or
ins 'TEST.APL'
zobacz:
http://ibsensoftware.com/products_aPLib.html
