** ** $Id: GetColorTab.S,v 21.1 92/05/15 03:22:16 chris Exp $ ** $Revision: 21.1 $ ** ** $Filename: GetColorTab.S $ ** $Author: chris $ ** $Date: 92/05/15 03:22:16 $ ** ** iff.library/IFFL_GetColorTab ** ** 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_GetColorTab SECTION text,CODE INCLUDE "IFFLib.i" XREF FindChunkFunc XDEF GetColorTabFunc ******* iff.library/IFFL_GetColorTab **************************************** * * NAME * IFFL_GetColorTab -- find a CMAP and convert it to a ColorTable * * SYNOPSIS * count = IFFL_GetColorTab( iff, colortable ) * D0 A1 A0 * * LONG IFFFL_GetColorTab( IFF_HANDLE, UWORD * ) * * FUNCTION * Searches the CMAP chunk of an IFF file and converts it, if it's * there, to an Amiga color table structure. This colortable can * directly be used as a parameter for the LoadRGB4() function. * * INPUTS * iff - IFF file handle, from IFFL_OpenIFF() * colortable - Pointer to a block of memory which must be large * enough to hold the colortable (2 bytes per color). * Must be WORD aligned. * * RESULT * Number of colors actually found, or zero if the file has no * CMAP chunk * * SEE ALSO * IFFL_FindChunk(), IFFL_GetBMHD() * ***************************************************************************** GetColorTabFunc: movem.l d2-d5/a2,-(SP) movea.l a0,a2 ; Ziel-Adresse move.l #'CMAP',d0 bsr FindChunkFunc ;; tst.l d0 beq.s 99$ ; nicht gefunden ---> movea.l d0,a0 addq.l #4,a0 ; Chunk-Namen überlesen move.l (a0)+,d4 ; Chunk-size divs #3,d4 ; Anzahl Farben ext.l d4 ; für D0 move.l d4,d0 ; Resultat: Anzahl Farben moveq #256-$f0,d5 ; Color-Maske $f0 neg.b d5 ; Toebes-Optimierlung bra.s 1$ ; Für dbf .Loop: move.b (a0)+,d1 ; rot and.w d5,d1 ; Nur Bits 7-4 benützen move.b (a0)+,d2 ; grün and.w d5,d2 ; Nur Bits 7-4 benützen move.b (a0)+,d3 ; blau and.w d5,d3 ; Nur Bits 7-4 benützen lsl.w #4,d1 ; rot << 4 lsr.w #4,d3 ; blau >> 4 or.w d2,d1 or.w d3,d1 move.w d1,(a2)+ ; in Farbtabelle eintragen 1$: dbf d4,.Loop 99$: movem.l (SP)+,d2-d5/a2 rts END