Initial commit.
[amiga/xmodule.git] / Hooks / OctaMed.h
1 /*
2 **      OctaMed.h
3 **
4 **      Copyright (C) 1994,95 Bernardo Innocenti
5 **
6 **      Use 4 chars wide TABs to read this source
7 **
8 **      Structure definition for MED/OctaMED file formats.
9 **  Based on Teijo Kinnunen's format description rev 2 (30.5.93)
10 */
11
12
13 struct MMD0sample
14 {
15         UWORD rep, replen;      /* offs: 0(s), 2(s) */
16         UBYTE midich;           /* offs: 4(s) */
17         UBYTE midipreset;       /* offs: 5(s) */
18         UBYTE svol;                     /* offs: 6(s) */
19         BYTE strans;            /* offs: 7(s) */
20 };
21
22
23 struct MMD0
24 {
25         ULONG   id;
26         ULONG   modlen;
27         struct MMD0song *song;
28         ULONG   reserved0;
29         struct MMD0Block **blockarr;
30         ULONG   reserved1;
31         struct InstrHdr **smplarr;
32         ULONG   reserved2;
33         struct MMD0exp *expdata;
34         ULONG   reserved3;
35         UWORD   pstate;                 /* some data for the player routine */
36         UWORD   pblock;
37         UWORD   pline;
38         UWORD   pseqnum;
39         WORD    actplayline;
40         UBYTE   counter;
41         UBYTE   extra_songs;    /* number of songs - 1 */
42 }; /* length = 52 bytes */
43
44
45
46 struct MMD0song
47 {
48         struct MMD0sample sample[63];
49         UWORD   numblocks;
50         UWORD   songlen;                /* NOTE: number of sections in MMD2 */
51         union {
52                 UBYTE   playseq[256];   /* MMD0/MMD1 only       */
53                 struct {                                /* MMD2 only            */
54                         struct PlaySeq  **playseqtable;
55                         UWORD   *sectiontable;  /* UWORD section numbers */
56                         UBYTE   *trackvols; /* UBYTE track volumes */
57                         UWORD   numtracks;  /* max. number of tracks in the song (also
58                                                                  * the number of entries in 'trackvols' table)
59                                                                  */
60                         UWORD   numpseqs;       /* number of PlaySeqs in 'playseqtable' */
61                         UBYTE   pad0[240];      /* reserved for future expansion                */
62                 };
63         };
64         UWORD   deftempo;
65         BYTE    playtransp;
66         UBYTE   flags;
67         UBYTE   flags2;
68         UBYTE   tempo2;
69         UBYTE   trkvol[16];             /* Unused in MMD2 */
70         UBYTE   mastervol;
71         UBYTE   numsamples;
72 }; /* length = 788 bytes */
73
74
75 struct PlaySeq {
76         char    name[32];               /* 31 chars + \0 */
77         ULONG   reserved[2];    /* for possible extensions */
78         UWORD   length;                 /* # of entries */
79         UWORD   seq[0];                 /* block numbers.. */
80 };
81
82
83 /* Flags for MMD0song->Flags */
84
85 #define FLAG_FILTERON   0x1             /* hardware low-pass filter */
86 #define FLAG_JUMPINGON  0x2             /* jumping.. */
87 #define FLAG_JUMP8TH    0x4             /* jump 8th.. */
88 #define FLAG_INSTRSATT  0x8             /* instruments are attached (sng+samples)
89                                                                    used only in saved MED-songs */
90 #define FLAG_VOLHEX             0x10    /* volumes are represented as hex */
91 #define FLAG_STSLIDE    0x20    /* no effects on 1st timing pulse (STS) */
92 #define FLAG_8CHANNEL   0x40    /* OctaMED 8 channel song, examine this bit
93                                                                    to find out which routine to use */
94
95 /* Flags for MMD0song->Flags2 */
96
97 #define FLAG2_BMASK             0x1F    /* (bits 0-4) BPM beat length (in lines)
98                                                                         0 = 1 line, $1F = 32 lines.0
99                                                                         (The rightmost slider in OctaMED Pro
100                                                                         BPM mode.) */
101 #define FLAG2_BPM               0x20    /* BPM mode on */
102
103
104
105 struct MMD0block
106 {
107         UBYTE   numtracks,
108                         lines;
109 };
110
111
112
113 struct MMD1block
114 {
115         UWORD   numtracks;
116         UWORD   lines;
117         struct BlockInfo *info;
118 };
119
120
121
122 struct BlockInfo
123 {
124         ULONG   *hlmask;
125         UBYTE   *blockname;
126         ULONG   blocknamelen;
127         ULONG   reserved[6];
128 };
129
130
131
132 struct InstrHdr {
133         ULONG   length;
134         WORD    type;
135         /* Followed by actual data */
136 };
137
138
139 /* Values for InstrHdr.type */
140
141 #define HYBRID          -2
142 #define SYNTHETIC       -1
143 #define SAMPLE          0       /* ordinary 1 octave sample */
144 #define IFF5OCT         1       /* 5 octaves    */
145 #define IFF3OCT         2       /* 3 octaves    */
146
147 /* The following ones are recognized by OctaMED Pro only */
148 #define IFF2OCT         3       /* 2 octaves    */
149 #define IFF4OCT         4       /* 4 octaves    */
150 #define IFF6OCT         5       /* 6 octaves    */
151 #define IFF7OCT         6       /* 7 octaves    */
152
153
154
155 struct SynthInstr {
156         ULONG   length;         /* length of this struct        */
157         WORD    type;           /* -1 or -2                                     */
158         UBYTE   defaultdecay;
159         UBYTE   reserved[3];
160         UWORD   rep;
161         UWORD   replen;
162         UWORD   voltbllen;
163         UWORD   wftbllen;
164         UBYTE   volspeed;
165         UBYTE   wfspeed;
166         UWORD   wforms;
167         UBYTE   voltbl[128];
168         UBYTE   wftbl[128];
169         struct SynthWF *wf[64];
170 };
171
172
173
174 struct InstrExt {
175         UBYTE   hold;                           /* hold/decay values of the instrument  */
176         UBYTE   decay;
177         UBYTE   suppress_midi_off;      /* 0 (FALSE) or not (TRUE)                              */
178         BYTE    finetune;                       /* instrument finetune (-8-+7)                  */
179         /* length = 4 bytes */
180
181         /* Below fields saved by >= V5 */
182         UBYTE default_pitch;
183         UBYTE instr_flags;
184         UWORD long_midi_preset;
185         /* length = 8 bytes */
186
187         /* Below fields saved by >= V5.02 */
188         UBYTE output_device;
189         UBYTE reserved;
190         /* length = 10 bytes */
191 };
192
193
194
195 struct MMDInstrInfo {
196         UBYTE   name[40];                       /* null-terminated instrument name.     */
197 };      /* length = 40 bytes */
198
199
200
201 struct MMD0exp {
202         struct MMD0 *nextmod;           /* Pointer to the next module (or zero).        */
203         struct InstrExt *exp_smp;
204         UWORD    s_ext_entries;         /* The size of InstrExt structure array
205                                                                  * (i.e. the number of InstrExt structures).
206                                                                  */
207         UWORD    s_ext_entrsz;          /* Size of each InstrExt structure.                     */
208         UBYTE   *annotxt;                       /* Pointer to the null-terminated annotation text.              */
209         ULONG    annolen;                       /* Length of 'annotxt', including the terminating \0.   */
210         struct MMDInstrInfo *iinfo;
211         UWORD    i_ext_entries;         /* Size of the MMDInstrInfo struct array
212                                                                  * (i.e. the number of MMDInstrInfo structures).
213                                                                  */
214         UWORD    i_ext_entrsz;          /* Size of each MMDInstrInfo struct                     */
215         ULONG    jumpmask;                      /* OBSOLETE                                                                     */
216         UWORD   *rgbtable;                      /* Pointer to eight UWORDs (screen colors)
217                                                                  * to be passed to LoadRGB4() routine.
218                                                                  */
219         UBYTE    channelsplit[4];       /* this longword is divided to four boolean bytes,
220                                                                  * controlling channel splitting in OctaMED 5 - 8 chnl
221                                                                  * modes. (A non-zero byte means that the channel is
222                                                                  * NOT splitted.) Currently only the following
223                                                                  * combinations should be used:
224                                                                  *
225                                                                  * 0x00000000 (8 channels (or normal 4 channel mode))
226                                                                  * 0x000000FF (7 channels)
227                                                                  * 0x0000FFFF (6 channels)
228                                                                  * 0x00FFFFFF (5 channels)
229                                                                  */
230         struct NotationInfo *n_info;/* pointer to NotationInfo structure (used only in
231                                                                  * OctaMED V2.0 and later). It contains some info for
232                                                                  * the notation editor.
233                                                                  */
234         UBYTE   *songname;                      /* song name of the current song (0-terminated).
235                                                                  * Each song of a multi-module can have a different
236                                                                  * name.
237                                                                  */
238
239         ULONG    songnamelen;           /* song name length (including the \0).         */
240         struct MMDDumpData *dumps;
241         ULONG    reserved2[7];          /* future expansion fields, that MUST be zero now.      */
242 };
243
244
245
246 struct NotationInfo
247 {
248         UBYTE   n_of_sharps;    /* number of sharps or flats (0 - 6).   */
249         UBYTE   flags;                  /* See below.                                                   */
250         WORD    trksel[5];              /* The number of the selected track,
251                                                          * for each display preset
252                                                          * (-1 = no track selected)
253                                                          */
254         UBYTE   trkshow[16];    /* tracks shown (five bits used in
255                                                          * each byte, bit #0 = preset 1, etc.)
256                                                          */
257         UBYTE   trkghost[16];   /* tracks ghosted (as in 'trkshow')             */
258         BYTE    notetr[63];             /* note transpose value for each
259                                                          * instrument (-24 - +24). If bit 6 is
260                                                          * negated, the instrument is hidden.
261                                                          */
262         UBYTE   pad;
263 };
264
265 /* flags for NotationInfo->flags */
266 #define NFLG_FLAT 1
267 #define NFLG_3_4  2
268
269
270 /* MIDI dump data (created using OctaMED Pro MIDI
271  * message editor).
272  */
273
274 struct MMDDumpData {
275         UWORD   numdumps;
276         UWORD   reserved[3];
277         /* Immediately after this struct, there are 'numdumps'
278          * pointers to MMDDump structures.
279          */
280 };
281
282 struct MMDDump {
283         ULONG   length;         /* length of the MIDI message dump.                     */
284         UBYTE   *data;          /* pointer to the actual MIDI dump data.        */
285         UWORD   ext_len;        /* MMDDump struct extension length.                     */
286
287         /*      (if ext_len >= 20, the following fields exist)  */
288         UBYTE   name[20];       /* name of the dump.                                            */
289 };
290
291
292
293 #define MMD0ROW 3                       /* Size of an MMD0 pattern row */
294 #define MMD1ROW 4                       /* Size of an MMD1/MMD2 pattern row */
295
296 #define ID_MMD0 0x4D4D4430
297 #define ID_MMD1 0x4D4D4431
298 #define ID_MMD2 0x4D4D4432