0 Members and 1 Guest are viewing this topic.
Because they contain fast routines so you don't have to write you own (most of the time slower) ones, for in example accessing archive etc
I think we should keep it at 6MHz for the main engine and routines so that it stays nicely compatible with the 83+
ETAOINSHRDLCUMFGYPBVKWXJQZ,?!.0123456789/-:'
CompressStr: call LoadInc ld hl,Codec1 dec a jr nz,$+5 ld hl,Codec2 jr $+5CompData: call CustCodec ld (TempWord2),hl call StringOrName ld (TempWord1),hl push bc push af push hl inc bc inc bc call MakeAnsStrX pop hl pop af pop bc ex de,hl ld (hl),c inc hl ld (hl),b inc hl ex de,hl push bc push de call ReadArc pop hl pop bc push hl push de ld de,(TempWord1) ld ix,(TempWord2) call TextComp pop de inc hl;HL points to the end of where it was converted ex de,hl or a sbc hl,de ex de,hl;DE is the size of the data to delete;HL points to where to delete the data push hl bcall(4357h) pop hl pop de dec de dec de or a sbc hl,de ex de,hl dec hl ld (hl),d dec hl ld (hl),e retTextComp:;Inputs:; DE points to the text to convert; HL points to where to convert to; BC is the size of the string; IX points to the codec call CodecStats ld (8478h),bc ld b,0 ld (hl),0TextCompLoop: push hl push bc ld bc,(8478h) ld a,b \ or c jr nz,$+11 pop bc pop hl bit 0,b ret z xor a rld ret dec bc ld (8478h),bc ld a,(de) inc de ld c,(ix) push ix pop hl inc hl cpir push hl push af ld a,(ix) dec a ld h,a pop af ld a,h pop hl jr z,$+3 ld c,a sub c pop bc pop hl exx cp c exx jr c,$+23 exx sub b exx rlca \ rlca \ rlca \ rlca rld rlca \ rlca \ rlca \ rlca inc b bit 0,b jr nz,$+4 inc hl ld (hl),0 rld inc b bit 0,b jr nz,TextCompLoop inc hl jr TextCompLoop-2Codec1:;46 chars; ETAOINSHRDLCUMFGYPBVKWXJQZ,?!.0123456789/-:' .db Codec1End-Codec1 .db 29h,"ETAOINSHRDLCUMFGYPBVKWXJQZ",2Bh .db $AF,2Dh,3Ah,"0123456789",83h,71h,3Eh,$AECodec1End:Codec2:;Includes lowercase tokens .db Codec2End-Codec2 .db $29,$BB,$45,$B4,$54,$C4,$41,$B0,$4F,$BF,$49,$B8,$4E,$BE,$53,$C3,$48,$B7,$52,$C2,$44,$B3,$4C,$BC .db $43,$B2,$55,$C5,$4D,$BD,$46,$B5,$47,$B6,$59,$C9,$50,$C0,$42,$B1,$56,$C6,$4B,$BA,$57,$C7,$58,$C8 .db $4A,$B9,$51,$C1,$5A,$CA,$2B,$AF,$2D,$3A,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$83,$71,$3E,$AE;need 4 more bytes .db 3Fh,82h,70h,$B0Codec2End:CustCodec: call StringOrName ld de,86ECh push de call ReadArc pop hl retDeCompStr: call LoadInc ld hl,Codec1 dec a jr nz,$+5 ld hl,Codec2 jr $+5DeCompData: call CustCodec ld (TempWord2),hl call StringOrName or a jp nz,ARCH dec bc dec bc push bc ld c,(hl) inc hl ld b,(hl) inc hl push hl inc bc call MakeAnsStrX ld (TempWord1),bc pop hl pop bc push de ld ix,(TempWord2) call TextDeComp;DE is the size of the data to delete;HL points to where to delete the data ex de,hl ld de,1 bcall(4357h) pop hl dec hl dec hl ld a,(hl) dec a ld (hl),a inc a ret nz inc hl dec (hl) retCodecStats:; IX points to the codec; codec format is the first byte is the size, followed by the bytes allowed;Output:; B' is the adjusting value for one-byte values; C' is the cut-off for half-byte values; A is the same as B' di exx ld a,(ix) rlca rlca rlca rlca and 15 ld b,a ld a,(ix) and 15 add a,b and 240 jr z,$+3 inc b ld a,16 sub b ; ld c,a ;number of half nibbles ld a,b rlca rlca rlca rlca or c ld b,a exx retTextDeComp:;Inputs:; HL points to the text to decompress; DE points to where to convert to; BC is the size of the string; IX points to the codec call CodecStats ld (8478h),bc ld b,0TextDeCompLoop: call GetNextNibble ld a,c exx cp c exx jr c,$+15 ld (de),a call GetNextNibble ld a,(de) rlca \ rlca \ rlca \ rlca or c exx add a,b exx push hl push ix pop hl inc hl add a,l jr nc,$+3 inc h ld l,a ld a,(hl) pop hl ld (de),a inc de push bc ld bc,(8478h) ld a,b \ or c pop bc jr nz,TextDeCompLoop retGetNextNibble:; z flag set if the last xor a inc b bit 0,b jr z,$+8 rld ld c,a rrd ret rrd ld c,a rld push bc ld bc,(8478h) dec bc ld (8478h),bc pop bc inc hl ret GetCodec: call StringOrName or a ret nz or b or c jp z,NO_DATA call CountBytes call MakeAnsStrX dec bc ld a,c ld (de),a inc de ld hl,88ECh ldir retCountBytes: push hl push bc xor a ld hl,86ECh ld (hl),a ld d,h ld e,l inc de ld bc,2FFh ldir pop bc pop hlGetCodecLoop: push bc ld e,(hl) ld d,0 ex de,hl add hl,hl ld bc,86ECh add hl,bc inc (hl) jr nz,$+4 inc hl inc (hl) ex de,hl pop bc cpi jp pe,GetCodecLoop call Order ld b,0 inc bc retOrder: di ld hl,86ECh ;points to the density list (512 bytes) ld de,88ECh ;points to where the output is ld bc,0 ld (TempWord1),hl exx ld hl,0 ;MaxVal exxOrderLoop: push bc ld c,(hl) inc hl ld b,(hl) inc hl push bc exx pop de or a sbc hl,de add hl,de jr nc,$+3 ex de,hl exx pop bc djnz OrderLoop ld hl,(TempWord1) exx ld a,h or l exx ret z xor aOrderLoop1: push bc ld c,(hl) inc hl ld b,(hl) push bc exx pop de or a sbc hl,de add hl,de exx pop bc jr nz,$+12 ld (de),a inc de ld (hl),0 dec hl ld (hl),0 inc hl inc c ret z inc hl inc a djnz OrderLoop1 ld hl,(TempWord1) jr OrderLoop-5