crunchlib
These commands pack and unpack data in memory with the packers that
were common on the Amiga. Implode packs a buffer with the Imploder
method and Deplode unpacks it again; CrMDecrunch unpacks
Crunch-Mania data and PPDecrunch PowerPacker data. A file is loaded
into memory first, for example with LoadBank or ReadMem.
n.l=Implode(Bank(0),BankSize(0))
If n>0 Then NPrint "Packed to ",n," bytes"
If Deplode(Bank(0)) Then NPrint "Unpacked again"The unpacking commands check the data only in a few places: damaged data can make them write outside the destination. Unpack only data that the packer of the format made.
Library number 74.
Commands
CrMDecrunch
Unpacks Crunch-Mania data at Bufferadr in place, or to a second address if one is given.
Statement. Help text: Bufferadr
2 forms:
.l.l, .l
Unpacking in place, and to a second address that overlaps the data, first moves the packed data in front of the destination, as the Crunch-Mania format requires: keep as many bytes free in front of the buffer as the word at offset 4 of the header gives. The data are not checked beyond their header and tables; unpack only data packed with Crunch-Mania.
Deplode
Unpacks Imploder data at Startadr in place and returns true (-1), or false (0) if they are not Imploder data.
Function, result .l. Help text: Success=Startadr
Arguments: .l
The buffer must be as large as the unpacked data. The data are not checked; unpack only data packed with the Imploder.
Implode
Packs the DataLen bytes at Bufferadr in place with the Imploder method and returns the packed length; 0 if the data cannot be packed (less than 64 bytes, or not shorter enough), -1 if the user broke off with the left mouse button.
Function, result .l. Help text: Error/CrunchedLen=Bufferadr,DataLen
Arguments: .l, .l
While it packs, the background colour of the screen flickers. It packs in place, so after a result of 0 or -1 the buffer is partly overwritten and the data are lost: implode a copy if you still need them. The search reads up to 254 bytes behind the data.
PPDecrunch
Unpacks PowerPacker data from Bufferadr to Bufferend, the end of the packed file, to Destinationadr.
Statement. Help text: Bufferadr,Bufferend,Destinationadr
Arguments: .l, .l, .l
Data whose header has an efficiency value outside 1 to 15 are not unpacked. The data are not checked beyond their header; unpack only data packed with PowerPacker.