** ** $Id: $ ** $Revision: $ ** ** $Filename: DecompressBlock.S $ ** $Author: Christian A. Weber $ ** $Release: $ ** $Date: 92/05/12 22:26:30 $ ** ** iff.library/IFFLib_DecompressBlock ** ** COPYRIGHT (C) 1987-1992 BY CHRISTIAN A. WEBER, BRUGGERWEG 2, ** CH-8037 ZUERICH, SWITZERLAND. ALL RIGHTS RESERVED. NO PART ** OF THIS SOFTWARE MAY BE COPIED, REPRODUCED, OR TRANSMITTED ** IN ANY FORM OR BY ANY MEANS, WITHOUT THE PRIOR WRITTEN PER- ** MISSION OF THE AUTHOR. USE AT YOUR OWN RISK. ** IDNT IFFLib_DecompressBlock SECTION text,CODE INCLUDE "IffLib.i" XREF ClearError XDEF DecompressBlockFunc ******* iff.library/IFFLib_DecompressBlock ************************************ * * NAME * IFFLib_DecompressBlock -- Decompress a memory block * * SYNOPSIS * result = IFFLib_DecompressBlock( source, destination, size, mode ) * A0 A1 D0 D1 * * ULONG IFFLib_DecompressBlock( APTR, APTR, ULONG, ULONG ) * * FUNCTION * Decompress the memory block using the appropriate Decompression mode. * If the Decompressed data would become longer than the unDecompressed, * an error is returned. * * INPUTS * source - Pointer to data to decompress * destination - Target address for decompression * size - Number of data bytes to decompress * mode - Compression mode. Currently, the following modes * are supported: * $$$ * * RESULTS * Length of uncompressed data or 0 if an error occurred. * * SEE ALSO * IFFLib_CompressBlock() * ***************************************************************************** DecompressBlockFunc: tst.l d1 ; Modus == 0 ? beq.b Mode_Copy subq.l #1,d1 ; Modus == 1 ? beq.b Mode_CmpByteRun1 moveq.l #0,d0 rts ***************************************************************************** ** Kopiermodus Mode_Copy: movem.l d0/a6,-(SP) movea.l ib_SysBase(a6),a6 JSRLIB CopyMem movem.l (SP)+,d0/a6 rts ***************************************************************************** ** CmpByteRun1 dekomprimieren Mode_CmpByteRun1: move.l d2,-(SP) 1$: moveq.l #0,d1 move.b (a0)+,d1 ; D1 : nächstes Kommando-Byte bmi.b 2$ ; crunched ---> .CopyLoop: move.b (a0)+,(a1)+ ; D1+1 Bytes normal kopieren subq.l #1,d0 ; DEC length counter dble d1,.CopyLoop bra.b 3$ ; ---> 2$: neg.b d1 bmi.b 3$ ; ~$80 (== $80) ist 'NOP' move.b (a0)+,d2 ; Zu repetierender Wert .RepLoop: move.b d2,(a1)+ subq.l #1,d0 ; DEC ColumnCounter dble d1,.RepLoop 3$: tst.l d0 ; Linie fertig ? (Braucht's das tst??) bgt.b 1$ ; noch nicht ---> Loop move.l (SP)+,d2 rts END