; ------- IFF PICTURE DECRUNCHER -------
; Programmed  by an  unknown coder  some 
; years  ago.  Load the  iff pic  to the
; source adress,  start the  program and
; then save the unpacked one ( ri / wi )
; When  exeption  raised  while  running
; check the loadaddress.
; Calculate the right size with: x * y *
; number of bitplanes / 8  , or watch A1
; for the endadress!     (Doctor Mabuse)
source=		$48000
dest=		$60000
; --------------------------------------
start:	move.l	#source,a0		; Load area
	add.l	#8,a0
	move.l	#dest,a1		; Save area
	add.l	#4,a0
	move.l	a0,bmhdchunk		; BMHD Chunk
	move.l	4(a0),d0
	add.l	d0,a0
	add.l	#8,a0
	move.l	a0,cmapchunk		; CMAP Chunk, the colours
; --------------------------------------
sea1:	move.l	4(a0),d0		; Search Body Chunk
	add.l	d0,a0
	add.l	#8,a0
	move.l	#'BODY',d1
	cmp.l	(a0),d1
	bne	sea1
; --------------------------------------
	move.l	a0,bodychunk		; BODY Chunk, the bitplanes
	add.l	#4,a0
	move.l	(a0),anzahl		; Number of Bytes
	add.l	#1,anzahl
	and.l	#$fffffffe,anzahl
	add.l	#4,a0			; First Data Byte in A0
	clr.l	d3
; --------------------------------------
sea3:	move.b	(a0)+,zaehler
	clr.l	d5
	move.b	zaehler,d5
	and.b	#$80,d5			; Check Code if packed or not
	bne	sea4
; ------------ Not packed --------------
	clr.l	d4
	move.b	zaehler,d4		; Number of not packed bytes
sea5:	move.b	(a0)+,(a1)+		; Copy not packed bytes
	add.l	#1,d3
	dbf	d4,sea5			; Counter
	sub.l	#1,a0
	bra	sea6
; --------------- Packed ---------------
sea4:	neg.b	zaehler
	clr.l	d0
	move.b	zaehler,d0		; Number of bytes to unpack
sea2:	move.b	(a0),(a1)+		; Copy 
	dbf	d0,sea2			; Counter
	add.l	#2,d3			; Next two bytes
; --------------------------------------
sea6:	move.l	anzahl,d1
	cmp.l	d3,d1			; Ready
	ble	sea99
	add.l	#1,a0
	bra	sea3
sea99:	rts				; Finish
even
; -------------- Pointer ---------------
bmhdchunk:	dc.l	0
cmapchunk:	dc.l	0
bodychunk:	dc.l	0
anzahl:		dc.l	0
anzahl1:	dc.l	0
zaehler:	dc.w	0
