From 36c824864c02f0a3f62c8a1d365d1670835c8c96 Mon Sep 17 00:00:00 2001 From: "Christian A. Weber" Date: Tue, 12 May 1992 22:26:12 +0000 Subject: Initial revision --- Source/FindChunk.S | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 Source/FindChunk.S (limited to 'Source/FindChunk.S') 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 -- cgit v1.2.3