home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / dos / prg / midas / s3m.h < prev    next >
C/C++ Source or Header  |  1994-08-06  |  8KB  |  255 lines

  1. /*      S3M.INC
  2.  *
  3.  * Scream Tracker 3 Module Player, v1.10
  4.  *
  5.  * Copyright 1994 Petteri Kangaslampi and Jarno Paananen
  6.  *
  7.  * This file is part of the MIDAS Sound System, and may only be
  8.  * used, modified and distributed under the terms of the MIDAS
  9.  * Sound System license, LICENSE.TXT. By continuing to use,
  10.  * modify or distribute this file you indicate that you have
  11.  * read the license and understand and accept it fully.
  12. */
  13.  
  14.  
  15.  
  16. /****************************************************************************\
  17. *       struct s3mHeader
  18. *       ----------------
  19. * Description:  Scream Tracker 3 module file header
  20. \****************************************************************************/
  21.  
  22. typedef struct
  23. {
  24.     char        name[28];                /* song name */
  25.     uchar        num1A;                    /* 0x1A */
  26.     uchar        type;                    /* file type */
  27.     ushort        unused1;
  28.     ushort        songLength;             /* number of orders */
  29.     ushort        numInsts;                /* number of instruments */
  30.     ushort        numPatts;                /* number of patterns */
  31.     struct                                /* flags: */
  32.     {
  33.         int     st2Vibrato : 1;         /* Scream Tracker 2 vibrato */
  34.         int     st2Tempo : 1;            /* Scream Tracker 2 tempo */
  35.         int     ptSlides : 1;            /* ProTracker slides */
  36.         int     zeroVolOpt : 1;         /* 0-volume optimizations */
  37.         int     ptLimits : 1;            /* ProTracker limits */
  38.         int     filter : 1;             /* Enable filter / sfx */
  39.         int     unused : 10;
  40.     } flags;
  41.     ushort        trackerVer;             /* tracker version */
  42.     ushort        formatVer;                /* file format version */
  43.     char        SCRM[4];                /* "SCRM" */
  44.     uchar        masterVol;                /* master volume */
  45.     uchar        speed;                    /* initial speed */
  46.     uchar        tempo;                    /* initial tempo */
  47.     uchar        masterMult;             /* master multiplier (bits 0-3),
  48.                                            stereo (bit 4) */
  49.     uchar        unused2[12];
  50.     uchar        chanSettings[32];        /* channel settings */
  51.  
  52. } s3mHeader;
  53.  
  54.  
  55.  
  56. /****************************************************************************\
  57. *       struct s3mInstHdr
  58. *       -----------------
  59. * Description:  Scream Tracker 3 module instrument file header
  60. \****************************************************************************/
  61.  
  62. typedef struct
  63. {
  64.     uchar        type;                    /* instrument type */
  65.     char        dosName[12];            /* DOS filename (8+3) */
  66.     char        zero;                    /* 0 */
  67.     ushort        samplePtr;                /* paragraph ptr to sample data */
  68.     ulong        length;                 /* sample length */
  69.     ulong        loopStart;                /* sample loop start */
  70.     ulong        loopEnd;                /* sample loop end */
  71.     uchar        volume;                 /* volume */
  72.     uchar        disk;                    /* instrument disk number */
  73.     uchar        pack;                    /* sample packing info (0 = raw,
  74.                                            1 = DP30ADPCM1) */
  75.     uchar        flags;                    /* bit0 = loop, bit1 = stereo,
  76.                                            bit2 = 16-bit */
  77.     ulong        c2Rate;                 /* C2 sampling rate */
  78.     ulong        unused;
  79.     ushort        gusPos;                 /* position in GUS memory / 32 */
  80.     ushort        int512;
  81.     ulong        intLastUsed;
  82.     char        iname[28];              /* instrument name */
  83.     char        SCRS[4];                /* "SCRS" if sample */
  84. } s3mInstHdr;
  85.  
  86.  
  87.  
  88. /****************************************************************************\
  89. *       struct s3mChannel
  90. *       -----------------
  91. * Description:  Scream Tracker 3 module player internal channel structure
  92. \****************************************************************************/
  93.  
  94. typedef struct
  95. {
  96.     uchar   note;
  97.     uchar   inst;
  98.     uchar   vol;
  99.     uchar   cmd;
  100.     uchar   info;
  101.     uchar   flags;
  102.  
  103.     uchar   sample;
  104.     uchar   volume;
  105.  
  106.     ushort  period;
  107.     uchar   snote;
  108.     uchar   preinfo;
  109.     ushort  toperi;
  110.     uchar   notepsp;
  111.     uchar   retrigc;
  112.  
  113.     uchar   status;                    /* Includes bits like volume changed */
  114.  
  115.     uchar   vibcmd;
  116.     uchar   vibpos;
  117.  
  118.     uchar   volbar;
  119.  
  120.     uchar   trefl;
  121.     uchar   trecnt;
  122. } s3mChannel;
  123.  
  124.  
  125.  
  126. extern ModulePlayer mpS3M;              /* Scream Tracker 3 Module Player */
  127.  
  128.  
  129. #ifdef __cplusplus
  130. extern "C" {
  131. #endif
  132.  
  133.  
  134. /****************************************************************************\
  135. *
  136. * Function:     int s3mLoadModule(char *fileName, SoundDevice *SD,
  137. *                   mpModule **module);
  138. *
  139. * Description:  Loads a Scream Tracker 3 module into memory
  140. *
  141. * Input:        char *fileName          name of module file to be loaded
  142. *               SoundDevice *SD         Sound Device which will store the
  143. *                                       samples
  144. *               mpModule **module       pointer to variable which will store
  145. *                                       the module pointer.
  146. *
  147. * Returns:      MIDAS error code.
  148. *               Pointer to module structure is stored in *module.
  149. *
  150. \****************************************************************************/
  151.  
  152. int CALLING s3mLoadModule(char *fileName, SoundDevice *SD, mpModule **module);
  153.  
  154.  
  155.  
  156. /****************************************************************************\
  157. *
  158. * Function:     int s3mFreeModule(mpModule *module, SoundDevice *SD);
  159. *
  160. * Description:  Deallocates a Scream Tracker 3 module
  161. *
  162. * Input:        mpModule *module        module to be deallocated
  163. *               SoundDevice *SD         Sound Device that has stored the
  164. *                                       samples
  165. *
  166. * Returns:      MIDAS error code
  167. *
  168. \****************************************************************************/
  169.  
  170. int CALLING s3mFreeModule(mpModule *module, SoundDevice *SD);
  171.  
  172.  
  173.  
  174.  
  175. /****************************************************************************\
  176. *
  177. * Function:     int s3mDetectChannels(mpModule *s3m, ushort *numChns);
  178. *
  179. * Description:  Detects the number of channels in a Scream Tracker 3 module
  180. *
  181. * Input:        mpModule *s3m           pointer to module structure
  182. *               ushort *numChns         pointer to channel number variable
  183. *
  184. * Returns:      MIDAS error code.
  185. *               Number of channels in module stored in *numChns.
  186. *
  187. \****************************************************************************/
  188.  
  189. int CALLING s3mDetectChannels(mpModule *s3m, ushort *numChns);
  190.  
  191.  
  192.  
  193. /***************************************************************************\
  194. *
  195. * Function:     int s3mFindUsedInsts(mpModule *s3m, ushort *used);
  196. *
  197. * Description:  Finds which instruments are used in a Scream Tracker 3 module.
  198. *
  199. * Input:        mpModule *s3m           Pointer to module structure. At least
  200. *                                       the patterns must have been loaded
  201. *               uchar    *used          Pointer to instruments used array -
  202. *                                       one byte per instrument. Set to 1 if
  203. *                                       instrument is used, 0 if not.
  204. *
  205. * Returns:      MIDAS error code.
  206. *
  207. \***************************************************************************/
  208.  
  209. int CALLING s3mFindUsedInsts(mpModule *s3m, uchar *used);
  210.  
  211.  
  212.  
  213. int CALLING s3mIdentify(uchar *header, int *recognized);
  214. int CALLING s3mInit(SoundDevice *SD);
  215. int CALLING s3mClose(void);
  216. int CALLING s3mPlayModule(mpModule *module, ushort firstSDChannel,
  217.     ushort numSDChannels, ushort loopStart, ushort loopEnd);
  218. int CALLING s3mStopModule(void);
  219. int CALLING s3mSetInterrupt(void);
  220. int CALLING s3mRemoveInterrupt(void);
  221. int CALLING s3mPlay(void);
  222. int CALLING s3mSetPosition(ushort pos);
  223. int CALLING s3mGetInformation(mpInformation *info);
  224.  
  225.  
  226. #ifdef __cplusplus
  227. }
  228. #endif
  229.  
  230.  
  231. /****************************************************************************\
  232. *       enum s3mFunctIDs
  233. *       ----------------
  234. * Description:  ID numbers for Scream Tracker 3 Module Player functions
  235. \****************************************************************************/
  236.  
  237. enum s3mFunctIDs
  238. {
  239.     ID_s3mIdentify = ID_s3m,
  240.     ID_s3mInit,
  241.     ID_s3mClose,
  242.     ID_s3mLoadModule,
  243.     ID_s3mFreeModule,
  244.     ID_s3mPlayModule,
  245.     ID_s3mStopModule,
  246.     ID_s3mSetInterrupt,
  247.     ID_s3mRemoveInterrupt,
  248.     ID_s3mPlay,
  249.     ID_s3mSetPosition,
  250.     ID_s3mGetInformation,
  251.     ID_s3mDetectChannels,
  252.     ID_s3mFindUsedInsts
  253. };
  254.  
  255.