** ** $Id: FindChunk.S,v 21.1 92/05/15 03:21:10 chris Exp $ ** $Revision: 21.1 $ ** ** $Filename: FindChunk.S $ ** $Author: chris $ ** $Date: 92/05/15 03:21:10 $ ** ** iff.library/IFFL_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 IFFL_FindChunk SECTION text,CODE INCLUDE "IffLib.i" XDEF FindChunkFunc ******* iff.library/IFFL_FindChunk ****************************************** * * NAME * IFFL_FindChunk -- find an IFF-chunk * * SYNOPSIS * chunk = IFFL_FindChunk( iff, chunkname ) * D0 A1 D0 * * APTR IFFL_FindChunk( IFFL_HANDLE, ULONG ) * * FUNCTION * Find a specific chunk in an IFF file * * INPUTS * iff - IFF file handle, from IFFL_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 by ANIM 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 * IFFL_GetBMHD(), IFFL_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