*****************************************************************************
;	Title:	Realtime Graphic Decruncher Source V1.0
;	Coder:	Prophet/Goldfire UK	(C) Thomas Szirtes 1991
;	Notes:
;	Make a0 - APTR to Crunched File in memory
;	     a1 - APTR to Drecrunch Memory Block
;
;	Uses BYTERUN1 Compression, which gives about 30% savings.
;	Can Decrunch a NTSC 5 Bitplane Picture in under a frame.
;	IFF Picture Files need to be run through my IFF Stripper
;	Pictures are outputed as an interleaved bitmap.
;	Please give due credit if you use this decruncher in a production.
*****************************************************************************

DecrunchILBM: 
	Move.l	(a0),d0		;Number of Bytes
	Lsr.l	#1,d0		;Divided by Two
	Add.l	#4,a0		;We are now at start of data
DecLoop
	Moveq.l	#0,d1		;Make sure of no nasties
	Move.b	(a0)+,d1	;Load next instuction
	Bpl	DecCopyByte	;Copy Bytes if 0-127
	Cmp.b	#128,d1
	Beq	DecOut		;Do nothing if 128
DecMulti			;if -127..-1
	Move.b	(a0)+,d2
	Neg.b	d1
DecMultiLoop
	Move.b	d2,(a1)+	;Copy the next byte n times		
	Dbf	d1,DecMultiLoop
DecBack
	Dbf	d0,DecLoop		
DecOut	Rts
DecCopyByte	
	Move.b	(a0)+,(a1)+	;Copy n bytes.
	Dbf	d1,DecCopyByte
	Bra.s	DecBack

