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/GetColorTab.S | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 Source/GetColorTab.S (limited to 'Source/GetColorTab.S') diff --git a/Source/GetColorTab.S b/Source/GetColorTab.S new file mode 100644 index 0000000..e7adcb6 --- /dev/null +++ b/Source/GetColorTab.S @@ -0,0 +1,94 @@ +** +** $Id: $ +** $Revision: $ +** +** $Filename: GetColorTab.S $ +** $Author: Christian A. Weber $ +** $Release: 19.1 $ +** $Date: 92/05/11 21:11:27 $ +** +** iff.library/IFFLib_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 IFFLib_GetColorTab + SECTION text,CODE + + INCLUDE "IFFLib.i" + + XREF FindChunkFunc + XDEF GetColorTabFunc + + +******* iff.library/IFFLib_GetColorTab ************************************** +* +* NAME +* IFFLib_GetColorTab -- find a CMAP and convert it to a ColorTable +* +* SYNOPSIS +* count = IFFLib_GetColorTab( ifffile, colortable ) +* D0 A1 A0 +* +* 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 +* ifffile - IFF file pointer, returned by IFFLib_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 +* IFFLib_FindChunk(), IFFLib_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 -- cgit v1.2.3