An implementation of the inflate decompression algorithm from RFC1951, as used by gzip and other compatible utilities. In other words, it’s like gunzip for the Sam.
SAMflate requires two consecutive pages as temporary storage. Load the code at an offset of 8k into the second of these pages (or in other words, at any multiple of 16384 bytes from the starting address in the image).
Then load your gz file somewhere else in memory, and simply:
CALL samflate, gzdata, destination
Where samflate is the address you loaded the samflate code, gzdata is the address you loaded your gzipped file, and destination is the address you would like it decoded to.
All three addresses are in BASIC’s format (i.e. 16384 is the start of page 0)
It’s usually OK for the end of the decoded data to overlap with the beginning of the gzipped data (but not the other way around!)