home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / utils / graphic / viewers / general / amiga / he / iff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-24  |  4.8 KB  |  197 lines

  1. /*
  2.     This is a bunch of the IFF stuff from the ROM Kernal Manual.
  3. */
  4.  
  5. #define IFF_H    1
  6.  
  7. #include <stdio.h>
  8. #ifndef EXEC_TYPES_H
  9.     #include <exec/types.h>
  10. #endif
  11. #ifndef EXEC_MEMORY_H
  12.     #include <exec/memory.h>
  13. #endif
  14. #ifndef INTUITION_INTUITION_H
  15.     #include <intuition/intuition.h>
  16. #endif
  17. #ifndef INTUITION_SCREENS_H
  18.     #include <intuition/screens.h>
  19. #endif
  20. #ifndef DEVICES_AUDIO_H
  21.     #include <devices/audio.h>
  22. #endif
  23.  
  24. #define SEEK_SET 0
  25.  
  26.  
  27.  
  28. typedef struct
  29.     {
  30.         LONG  ckID;
  31.         LONG  cksize;
  32.         UBYTE *ckdata;
  33.     }
  34. Chunk;
  35.  
  36. typedef LONG ID;
  37.  
  38. #define MakeID(a,b,c,d)      ((LONG)(a)<<24 | (LONG)(b)<<16 | (c)<<8 | (d))
  39.  
  40.  
  41. #define ID_FORM        MakeID('F','O','R','M')        /* chunk types */
  42. #define ID_LIST        MakeID('L','I','S','T')
  43. #define ID_PROP        MakeID('P','R','O','P')
  44. #define ID_CAT        MakeID('C','A','T',' ')
  45.  
  46. #define ID_BMHD        MakeID('B','M','H','D')        /* sub-types     */
  47. #define ID_BODY        MakeID('B','O','D','Y')        /* for IFF ILBMs */
  48. #define ID_CMAP        MakeID('C','M','A','P')
  49. #define ID_GRAB        MakeID('G','R','A','B')
  50. #define ID_DEST        MakeID('D','E','S','T')
  51. #define ID_SPRT        MakeID('S','P','R','T')
  52. #define ID_CAMG        MakeID('C','A','M','G')
  53.  
  54. #define ID_VHDR        MakeID('V','H','D','R')        /* for sound samples */
  55. #define ID_BODY        MakeID('B','O','D','Y')
  56. #define ID_8SVX        MakeID('8','S','V','X')
  57.  
  58. typedef UBYTE Masking;                        /* more ILBM stuff */
  59.  
  60. #define mskNone                    0
  61. #define mskHasMask                1
  62. #define mskHasTransparentColor    2
  63. #define mskLasso                3
  64.  
  65. typedef UBYTE Compression;
  66.  
  67. #define cmpNone        0
  68. #define cmpByteRun1    1
  69.  
  70. typedef struct 
  71.     {
  72.         UWORD w,h;                /* width, height             */
  73.         WORD  x,y;                /* pixel display position         */
  74.         UBYTE nplanes;            /* number of bitplanes            */
  75.         Masking masking;    
  76.         Compression compression;
  77.         UBYTE pad1;                /* word-align next item         */
  78.         UWORD TransparentColor;        /* transparent color...         */
  79.         UBYTE xAspect, yAspect;        /* aspect ratio width:height     */
  80.         WORD pageWidth,pageHeight;        /* source page size, in pixels     */
  81.     }
  82. BitMapHeader;
  83.  
  84. typedef struct
  85.     {
  86.         UBYTE red, green, blue;
  87.     }
  88. ColorRegister;
  89.  
  90. typedef ColorRegister ColorMap[64];    
  91.                                         
  92. typedef struct 
  93.     {
  94.         unsigned pad1 :4, red :4, green :4, blue :4;
  95.     }
  96. Color4;
  97.  
  98. typedef struct
  99.     {
  100.         WORD x,y;
  101.     }
  102. Point2D;
  103.  
  104. typedef struct
  105.     {
  106.         UBYTE depth;                /* bitplanes in source image */
  107.         UBYTE pad1;
  108.         UWORD planePick;
  109.         UWORD planeOnOff;
  110.         UWORD planeMask;
  111.     }
  112. DestMerge;
  113.  
  114.  
  115.  
  116. #define LEFTA    0        /* these make it easier to keep track of which */
  117. #define LEFTB    2        /* sound channels you want to use.  CONTROL is */
  118. #define RIGHTA    1        /* the channel used for doing volume changes   */
  119. #define RIGHTB    3        /* and things like that.                         */
  120. #define CONTROL    4
  121.  
  122. typedef struct
  123.     {
  124.         ULONG oneShotHiSamples;
  125.         ULONG repeatHiSamples;
  126.         ULONG samplesPerHiCycle;
  127.         UWORD samplesPerSec;
  128.         UBYTE ctoctave;
  129.         UBYTE sCompression;
  130.         LONG volume;
  131.     }
  132. Voice8Header;
  133.  
  134.  
  135. struct ASound
  136.     {
  137.         Voice8Header vhead;
  138.         ULONG datasize;
  139.         BYTE *data;
  140.     };
  141.     
  142.     
  143. #define    NTSC_CLOCK        3579545L        /* sound clock speeds */
  144. #define PAL_CLOCK        3546895L
  145.  
  146.  
  147. /*
  148.     These variables are used to do sound stuff.  The channels are the
  149.     four audio channels IO requests plus one more to do starts, stops,
  150.     volume changes, things like that.
  151.     The whichsound[] array will always contain a pointer to the ASound
  152.     structure currently playing for that channel.  i.e. whichsound[0]
  153.     will point to the ASound playing on channels[0].  They are put in
  154.     the ifdef so that they are only included in iff_stuff.c, but not in
  155.     other programs that use this header file.  Here for reference mainly,
  156.     since user programs should have no need to fiddle with these things
  157.     directly.
  158. */
  159.  
  160. #ifdef IFF_STUFF_C
  161.     struct IOAudio *channels[5] = { NULL, NULL, NULL, NULL, NULL };
  162.     struct ASound *whichsound[4] = { NULL, NULL, NULL, NULL };
  163.     struct MsgPort *AudioPort = NULL;
  164.     BYTE alloc_all_channels[] = { 0x01,0x02,0x04,0x08 };
  165. #endif
  166.  
  167. typedef UWORD SpritePrecedence;
  168.  
  169. /* for viewmodes and the CAMG chunk type */
  170.  
  171. #define BADFLAGS    (SPRITES|VP_HIDE|GENLOCK_AUDIO|GENLOCK_VIDEO)
  172. #define FLAGMASK    (~BADFLAGS)
  173. #define CAMGMASK    (FLAGMASK & 0x0000FFFFL)
  174.  
  175.  
  176. BOOL GetBMHD(FILE *ifffile,BitMapHeader *header);
  177. ULONG PullID(UBYTE *data);
  178. BOOL GetViewModes(struct NewScreen *newscreen,FILE *ifffile);
  179. BOOL FindChunk(FILE *ifffile,ULONG chunktype,Chunk *chunk);
  180. SHORT GetColorMap(FILE *ifffile,UWORD *colortable);
  181. BOOL ReadPic(struct BitMap *bitmap,FILE *ifffile,BitMapHeader *header);
  182. BOOL LoadPicture(FILE *file, struct BitMap *bitmap);
  183.  
  184. BOOL OpenAudio();
  185. struct ASound *LoadSound(char *name);
  186. BOOL GetVoiceHeader(FILE *file,Voice8Header *vhead);
  187. void PlaySound(struct ASound *sound,SHORT loops,UWORD volume,SHORT channel);
  188. void FreeSound(struct ASound *sound);
  189. void WaitSounds(struct ASound *sound1,struct ASound *sound2,struct ASound *sound3,struct ASound *sound4);
  190. void WaitChannels(SHORT channelmask);
  191. void AbortAllSounds(void);
  192. void AbortSound(struct ASound *sound);
  193. void AbortChannel(int channel);
  194. void CloseAudio();
  195. void StartAudio();
  196. void StopAudio();
  197.