summaryrefslogtreecommitdiff
path: root/Source/FindChunk.S
diff options
context:
space:
mode:
authorChristian A. Weber <chris@gna.ch>1992-05-12 22:26:12 +0000
committerChristian A. Weber <chris@gna.ch>1992-05-12 22:26:12 +0000
commit36c824864c02f0a3f62c8a1d365d1670835c8c96 (patch)
treef3f433e4af522925d4c91f56865d38efaf83a456 /Source/FindChunk.S
downloadiff-library-36c824864c02f0a3f62c8a1d365d1670835c8c96.tar.gz
iff-library-36c824864c02f0a3f62c8a1d365d1670835c8c96.tar.bz2
iff-library-36c824864c02f0a3f62c8a1d365d1670835c8c96.zip
Initial revision
Diffstat (limited to 'Source/FindChunk.S')
-rw-r--r--Source/FindChunk.S83
1 files changed, 83 insertions, 0 deletions
diff --git a/Source/FindChunk.S b/Source/FindChunk.S
new file mode 100644
index 0000000..2ddea63
--- /dev/null
+++ b/Source/FindChunk.S
@@ -0,0 +1,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