(* ---------------------------------------------------------------------------

   IFF.def - Library Interface Module for the iff.library, V18.8, 31-Jul-90

   By Olivier Schraner, Roggenweg 6, 5036 Oberentfelden/AG, Switzerland
   For A+L's "M2Amiga" Modula-2 Compiler V3.3 

--------------------------------------------------------------------------- *)

DEFINITION MODULE IFF {"iff.library",18};

FROM SYSTEM   IMPORT ADDRESS,CAST;
FROM Graphics IMPORT BitMapPtr,ViewModeSet;
FROM Exec     IMPORT MemReqs,MemReqSet;

CONST
 badTask = -1;            (* IFFError() called by wrong task *)
 cantOpenFile = 16;       (* File not found *)
 readError = 17;          (* Error reading file *)
 noMem = 18;              (* Not enough memory *)
 notIFF = 19;             (* File is not an IFF file *)
 writeError = 20;         (* Error writing file *)
 noILBM = 24;             (* IFF file is not of type ILBM *)
 noBMHD = 25;             (* BMHD chunk not found *)
 noBODY = 26;             (* BODY chunk not found *)
 tooManyPlanes = 27;      (* Obsolete since V18.6 *)
 unknownCompression = 28; (* Unknown compression type *)
 noANHD = 29;             (* ANHD chunk not found *)
 noDLTA = 30;             (* DLTA chunk not found *)

 idFORM = CAST(LONGINT,"FORM") ;
 idPROP = CAST(LONGINT,"PROP") ;
 idLIST = CAST(LONGINT,"LIST") ;
 idCAT  = CAST(LONGINT,"CAT ")-ORD(" ") ;

 idANIM = CAST(LONGINT,"ANIM") ;
 idANHD = CAST(LONGINT,"ANHD") ;
 idILBM = CAST(LONGINT,"ILBM") ;
 idBMHD = CAST(LONGINT,"BMHD") ;
 idBODY = CAST(LONGINT,"BODY") ;
 idCAMG = CAST(LONGINT,"CAMG") ;
 idCLUT = CAST(LONGINT,"CLUT") ;
 idCMAP = CAST(LONGINT,"CMAP") ;
 idCRNG = CAST(LONGINT,"CRNG") ;
 idDLTA = CAST(LONGINT,"DLTA") ;
 idSHAM = CAST(LONGINT,"SHAM") ;

 id8SVX = CAST(LONGINT,"8SVX") ;
 idATAK = CAST(LONGINT,"ATAK") ;
 idNAME = CAST(LONGINT,"NAME") ;
 idRLSE = CAST(LONGINT,"RLSE") ;
 idVHDR = CAST(LONGINT,"VHDR") ;


TYPE
 UByte=[0..255];

 Chunk=RECORD
   ckID:LONGINT;
   ckSize:LONGINT;
(* ckData:ARRAY [1..ckSize] OF UByte; (variable size) *)
 END;
 ChunkPtr=POINTER TO Chunk;

 BitMapHeader=RECORD
   w:CARDINAL;
   h:CARDINAL;
   x:INTEGER;
   y:INTEGER;
   nPlanes:UByte;
   masking:UByte;
   compression:UByte;
   pad1:UByte;
   transparentColor:CARDINAL;
   xAspect:UByte;
   yAspect:UByte;
   pageWidth:INTEGER;
   pageHeight:INTEGER;
 END;
 BitMapHeaderPtr=POINTER TO BitMapHeader;

 AnimHeader=RECORD
   operation:UByte;
   mask:UByte;
   w:CARDINAL;
   h:CARDINAL;
   x:INTEGER;
   y:INTEGER;
   absTime:LONGCARD;
   relTime:LONGCARD;
   interleave:UByte;
   pad0:UByte;
   bits:LONGCARD;
   pad:ARRAY [0..15] OF UByte;
 END;
 AnimHeaderPtr=POINTER TO AnimHeader;

 CompressionFlags=(cmpByteRun1,cf1,cf2,cf3,cf4,cf5,cf6,thisIsHAM,cf8,cf9,
                   cf10,cf11,cf12,cf13,cf14,cf15,cf16,cf17,cf18,cf19,cf20,
                   cf21,cf22,cf23,cf24,cf25,cf26,cf27,cf28,cf29,cf30,cf31);
 CompressionFlagSet=SET OF CompressionFlags;



PROCEDURE OpenIFF(filename{8}:ADDRESS):ADDRESS; CODE -30;

PROCEDURE CloseIFF(ifffile{9}:ADDRESS); CODE -36;

PROCEDURE FindChunk(ifffile{9}:ADDRESS;
                    chunkname{0}:LONGINT):ADDRESS; CODE -42;

PROCEDURE GetBMHD(ifffile{9}:ADDRESS):BitMapHeaderPtr; CODE -48;

PROCEDURE GetColorTab(ifffile{9}:ADDRESS;
                      colortable{8}:ADDRESS):LONGINT; CODE -54;

PROCEDURE DecodePic(ifffile{9}:ADDRESS;
                    bitmap{8}:BitMapPtr):BOOLEAN; CODE -60;

PROCEDURE SaveBitMap(filename{8}:ADDRESS;
                     bitmap{9}:BitMapPtr;
                     colortable{10}:ADDRESS;
                     flags{0}:CompressionFlagSet):BOOLEAN; CODE -66;

PROCEDURE SaveClip(filename{8}:ADDRESS;
                   bitmap{9}:BitMapPtr;
                   coltab{10}:ADDRESS;
                   flags{0}:CompressionFlagSet;
                   xoff{1}:LONGINT;
                   yoff{2}:LONGINT;
                   width{3}:LONGINT;
                   height{4}:LONGINT):BOOLEAN; CODE -72;

PROCEDURE IFFError():LONGINT; CODE -78;

PROCEDURE GetViewModes(ifffile{9}:ADDRESS):ViewModeSet; CODE -84;

PROCEDURE NewOpenIFF(filename{8}:ADDRESS;type{0}:MemReqSet):ADDRESS; CODE -90;

PROCEDURE ModifyFrame(modForm{9}:ADDRESS;bm{8}:BitMapPtr):BOOLEAN; CODE -96;


END IFF.
