summaryrefslogtreecommitdiff
path: root/Source/FindChunk.S
blob: 2ddea63cc799e59d41feca30276f3b2f04e452e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
**
**	$Id: $
**	$Revision: $
**
**	$Filename: FindChunk.S $
**	$Author: Christian A. Weber $
**	$Release: 19.1 $
**	$Date: 92/05/11 21:11:27 $
**
**	iff.library/IFFLib_FindChunk
**
**	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_FindChunk
		SECTION	text,CODE

		INCLUDE	"IffLib.i"

		XDEF	FindChunkFunc


******* iff.library/IFFLib_FindChunk ****************************************
*
*   NAME
*	IFFLib_FindChunk -- find an IFF-chunk
*
*   SYNOPSIS
*	chunk = IFFLib_FindChunk( ifffile, chunkname )
*	 D0                       A1       D0
*
*	APTR IFFLib_FindChunk( IFFFILE, ULONG )
*
*   FUNCTION
*	Find a specific chunk in an IFF file
*
*   INPUTS
*	ifffile - pointer to a FORM, normally the result of OpenIFF()
*	chunkname - 4 characters packed ASCII ('BODY', 'VHDR' ...)
*	            if chunkname is 0, FindChunk() returns a pointer to the
*	            first byte after the end of the current FORM. This can
*	            be used byANIM readers for jumping from FORM to FORM.
*
*   RESULTS
*	Pointer to the beginning of the chunk (that means to the chunk
*	name itself, followed by the chunk size); zero if chunk not found
*
*   BUGS
*	none known
*
*   SEE ALSO
*	IFFLib_GetBMHD(), IFFLib_GetColorTab()
*
*****************************************************************************

FindChunkFunc:	movea.l	4(a1),a0	; FORM-Länge
		addq.l	#8,a1		; FORM.... überspringen
		adda.l	a1,a0		; A0 zeigt jetzt ans Ende
		addq.l	#4,a1		; FORM-Typ überspringen
		tst.l	d0		; Chunk-ID == 0 ?
		bne.s	1$		; nein --->
		movea.l	a0,a1		; Sonst Ende des FORMs
		bra.s	99$		; zurückgeben

1$:		cmp.l	(a1),d0		; Chunk gefunden ?
		beq.s	99$		; ja!
		move.l	4(a1),d1	; Länge dieses Chunks
		addq.l	#1,d1		; auf WORD ...
		bclr	#0,d1		; ... aufrunden
		lea	8(a1,d1.l),a1	; Name & Länge dazu und zu A1 dazu
		cmpa.l	a0,a1		; FORM-Ende erreicht ?
		bcs.s	1$		; noch nicht --->
		suba.l	a1,a1		; Code für "nicht gefunden"
99$:
		move.l	a1,d0		; Resultat nach D0, set/reset Z-Flag
		rts

		END