comparison include/ptform.h @ 10:55420dceb8e0

Initial entry of mikmod into the CVS tree.
author darius
date Fri, 23 Jan 1998 16:05:11 +0000
parents
children
comparison
equal deleted inserted replaced
9:990c9dadb348 10:55420dceb8e0
1 /*
2 --> The Protracker Enums
3 -> For MikMod 3.0
4 */
5
6 #ifndef _PTFORM_H_
7 #define _PTFORM_H_
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13
14 extern UWORD mytab[12],logtab[104];
15 extern UBYTE VibratoTable[32],avibtab[128];
16 extern SBYTE PanbrelloTable[256];
17 extern ULONG lintab[768];
18
19
20 /**************************************************************************
21 ****** Unitrack stuff: ****************************************************
22 **************************************************************************/
23
24 // The UniTrack stuff is generally for internal use only, but would be
25 // required in making a tracker or a module player tha scrolls pattern
26 // data.
27
28 // prototypes:
29
30 extern void UniSetRow(UBYTE *t);
31 extern UBYTE UniGetByte(void);
32 extern UBYTE *UniFindRow(UBYTE *t,UWORD row);
33 extern void UniReset(void);
34 extern void UniWrite(UBYTE data);
35 extern void UniNewline(void);
36 extern UBYTE *UniDup(void);
37 extern void UniSkipOpcode(UBYTE op);
38 extern BOOL UniInit(void);
39 extern void UniCleanup(void);
40 extern UWORD TrkLen(UBYTE *t);
41 extern BOOL MyCmp(UBYTE *a, UBYTE *b, UWORD l);
42 extern void UniInstrument(UBYTE ins);
43 extern void UniNote(UBYTE note);
44 extern void UniPTEffect(UBYTE eff, UBYTE dat);
45 extern void UniVolEffect(UWORD eff, UBYTE dat);
46
47
48 // Enumaerated UniMod Commands
49
50 enum
51 { UNI_NOTE = 1,
52 UNI_INSTRUMENT,
53 UNI_PTEFFECT0,
54 UNI_PTEFFECT1,
55 UNI_PTEFFECT2,
56 UNI_PTEFFECT3,
57 UNI_PTEFFECT4,
58 UNI_PTEFFECT5,
59 UNI_PTEFFECT6,
60 UNI_PTEFFECT7,
61 UNI_PTEFFECT8,
62 UNI_PTEFFECT9,
63 UNI_PTEFFECTA,
64 UNI_PTEFFECTB,
65 UNI_PTEFFECTC,
66 UNI_PTEFFECTD,
67 UNI_PTEFFECTE,
68 UNI_PTEFFECTF,
69 UNI_S3MEFFECTA,
70 UNI_S3MEFFECTD,
71 UNI_S3MEFFECTE,
72 UNI_S3MEFFECTF,
73 UNI_S3MEFFECTI,
74 UNI_S3MEFFECTQ,
75 UNI_S3MEFFECTR,
76 UNI_S3MEFFECTT,
77 UNI_S3MEFFECTU,
78 UNI_KEYOFF,
79 UNI_KEYFADE,
80 UNI_VOLEFFECTS,
81 UNI_XMEFFECT4,
82 UNI_XMEFFECTA,
83 UNI_XMEFFECTE1,
84 UNI_XMEFFECTE2,
85 UNI_XMEFFECTEA,
86 UNI_XMEFFECTEB,
87 UNI_XMEFFECTG,
88 UNI_XMEFFECTH,
89 UNI_XMEFFECTL,
90 UNI_XMEFFECTP,
91 UNI_XMEFFECTX1,
92 UNI_XMEFFECTX2,
93 UNI_ITEFFECTG, // Porta to Note .. no kick=0;
94 UNI_ITEFFECTH, // IT specific Vibrato
95 UNI_ITEFFECTI, // IT tremor (xy not incremeneted)
96 UNI_ITEFFECTM, // Set Channel Volume
97 UNI_ITEFFECTN, // Slide / Fineslide Channel Volume
98 UNI_ITEFFECTP, // Slide / Fineslide Channel Panning
99 UNI_ITEFFECTU, // IT fine vibrato
100 UNI_ITEFFECTW, // Slide / Fineslide Global volume
101 UNI_ITEFFECTY, // The Satanic Panbrello
102 UNI_ITEFFECTS0,
103 UNI_LAST
104 };
105
106
107 // IT / S3M Extended SS effects:
108
109 enum
110 { SS_GLISSANDO = 1,
111 SS_FINETUNE,
112 SS_VIBWAVE,
113 SS_TREMWAVE,
114 SS_PANWAVE,
115 SS_FRAMEDELAY,
116 SS_S7EFFECTS,
117 SS_PANNING,
118 SS_SURROUND,
119 SS_HIOFFSET,
120 SS_PATLOOP,
121 SS_NOTECUT,
122 SS_NOTEDELAY,
123 SS_PATDELAY
124 };
125
126
127 // IT Volume column effects
128
129 enum
130 { VOL_VOLUME = 1,
131 VOL_PANNING,
132 VOL_VOLSLIDE,
133 VOL_PITCHSLIDEDN,
134 VOL_PITCHSLIDEUP,
135 VOL_PORTAMENTO,
136 VOL_VIBRATO
137 };
138
139
140 /**************************************************************************
141 ****** Instrument stuff: **************************************************
142 **************************************************************************/
143
144
145 // Instrument format flags
146 #define IF_OWNPAN 1
147 #define IF_PITCHPAN 2
148
149 // Envelope flags:
150
151 #define EF_ON 1
152 #define EF_SUSTAIN 2
153 #define EF_LOOP 4
154 #define EF_VOLENV 8
155
156 // New Note Action Flags
157
158 #define NNA_CUT 0
159 #define NNA_CONTINUE 1
160 #define NNA_OFF 2
161 #define NNA_FADE 3
162
163 #define DCT_OFF 0
164 #define DCT_NOTE 1
165 #define DCT_SAMPLE 2
166 #define DCT_INST 3
167
168 #define DCA_CUT 0
169 #define DCA_OFF 1
170 #define DCA_FADE 2
171
172 #define KEY_KICK 0
173 #define KEY_OFF 1
174 #define KEY_FADE 2
175 #define KEY_KILL 3
176
177 #define AV_IT 1 // IT vs. XM vibrato info
178
179
180 typedef struct ENVPT
181 { SWORD pos;
182 SWORD val;
183 } ENVPT;
184
185
186 typedef struct INSTRUMENT
187 {
188 UBYTE flags;
189
190 UBYTE samplenumber[120];
191 UBYTE samplenote[120];
192
193 UBYTE nnatype;
194 UBYTE dca; // duplicate check action
195 UBYTE dct; // duplicate check type
196 UBYTE globvol;
197 UWORD panning; // instrument-based panning var
198
199 UBYTE pitpansep; // pitch pan separation (0 to 255)
200 UBYTE pitpancenter; // pitch pan center (0 to 119)
201 UBYTE rvolvar; // random volume varations (0 - 100%)
202 UBYTE rpanvar; // random panning varations (0 - 100%)
203
204 UWORD volfade;
205
206 UBYTE volflg; // bit 0: on 1: sustain 2: loop
207 UBYTE volpts;
208 UBYTE volsusbeg;
209 UBYTE volsusend;
210 UBYTE volbeg;
211 UBYTE volend;
212 ENVPT volenv[32];
213
214 UBYTE panflg; // bit 0: on 1: sustain 2: loop
215 UBYTE panpts;
216 UBYTE pansusbeg;
217 UBYTE pansusend;
218 UBYTE panbeg;
219 UBYTE panend;
220 ENVPT panenv[32];
221
222 UBYTE pitflg; // bit 0: on 1: sustain 2: loop
223 UBYTE pitpts;
224 UBYTE pitsusbeg;
225 UBYTE pitsusend;
226 UBYTE pitbeg;
227 UBYTE pitend;
228 ENVPT pitenv[32];
229
230 // UBYTE vibtype;
231 // UBYTE vibsweep;
232 // UBYTE vibdepth;
233 // UBYTE vibrate;
234
235 CHAR *insname;
236
237 } INSTRUMENT;
238
239
240
241 /**************************************************************************
242 ****** Player stuff: ******************************************************
243 **************************************************************************/
244
245 typedef struct ENVPR
246 { UBYTE flg; // envelope flag
247 UBYTE pts; // number of envelope points
248 UBYTE susbeg; // envelope sustain index begin
249 UBYTE susend; // envelope sustain index end
250 UBYTE beg; // envelope loop begin
251 UBYTE end; // envelope loop end
252 SWORD p; // current envelope counter
253 UWORD a; // envelope index a
254 UWORD b; // envelope index b
255 ENVPT *env; // envelope points
256 } ENVPR;
257
258
259
260 // Struct MP_VOICE - Used by NNA only player (audio control. AUDTMP is
261 // used for full effects control).
262 typedef struct MP_VOICE
263 { INSTRUMENT *i;
264 SAMPLE *s;
265 UBYTE sample; // which instrument number
266
267 SWORD volume; // output volume (vol + sampcol + instvol)
268 UWORD panning; // panning position
269 SBYTE chanvol; // channel's "global" volume
270 UWORD fadevol; // fading volume rate
271 UWORD period; // period to play the sample at
272
273 UBYTE volflg; // volume envelope settings
274 UBYTE panflg; // panning envelope settings
275 UBYTE pitflg; // pitch envelope settings
276
277 UBYTE keyoff; // if true = fade out and stuff
278 UBYTE kick; // if true = sample has to be restarted
279 UBYTE note; // the audible note (as heard, direct rep of period)
280 UBYTE nna; // New note action type + master/slave flags
281 SWORD handle; // which sample-handle
282 SLONG start; // The start byte index in the sample
283
284
285 // ----------------------------------
286 // Below here is info NOT in MP_CONTROL!!
287 // ----------------------------------
288
289 ENVPR venv;
290 ENVPR penv;
291 ENVPR cenv;
292
293 UWORD avibpos; // autovibrato pos
294 UWORD aswppos; // autovibrato sweep pos
295
296 ULONG totalvol; // total volume of channel (before global mixings)
297
298 BOOL mflag;
299 SWORD masterchn;
300 struct MP_CONTROL *master;// index of "master" effects channel
301 } MP_VOICE;
302
303
304 typedef struct MP_CONTROL
305 { INSTRUMENT *i;
306 SAMPLE *s;
307 UBYTE sample; // which sample number
308 UBYTE note; // the audible note (as heard, direct rep of period)
309 SWORD outvolume; // output volume (vol + sampcol + instvol)
310 SBYTE chanvol; // channel's "global" volume
311 UWORD fadevol; // fading volume rate
312 UWORD panning; // panning position
313 UBYTE kick; // if true = sample has to be restarted
314 UBYTE muted; // if set, channel not played
315 UWORD period; // period to play the sample at
316 UBYTE nna; // New note action type + master/slave flags
317
318 UBYTE volflg; // volume envelope settings
319 UBYTE panflg; // panning envelope settings
320 UBYTE pitflg; // pitch envelope settings
321
322 UBYTE keyoff; // if true = fade out and stuff
323 SWORD handle; // which sample-handle
324 UBYTE notedelay; // (used for note delay)
325 SLONG start; // The starting byte index in the sample
326
327 struct MP_VOICE *slave;// Audio Slave of current effects control channel
328 UBYTE slavechn; // Audio Slave of current effects control channel
329 UBYTE anote; // the note that indexes the audible (note seen in tracker)
330 SWORD ownper;
331 SWORD ownvol;
332 UBYTE dca; // duplicate check action
333 UBYTE dct; // duplicate check type
334 UBYTE *row; // row currently playing on this channel
335 SBYTE retrig; // retrig value (0 means don't retrig)
336 ULONG speed; // what finetune to use
337 SWORD volume; // amiga volume (0 t/m 64) to play the sample at
338
339 SBYTE tmpvolume; // tmp volume
340 UWORD tmpperiod; // tmp period
341 UWORD wantedperiod; // period to slide to (with effect 3 or 5)
342 UBYTE pansspd; // panslide speed
343 UWORD slidespeed; //
344 UWORD portspeed; // noteslide speed (toneportamento)
345
346 UBYTE s3mtremor; // s3m tremor (effect I) counter
347 UBYTE s3mtronof; // s3m tremor ontime/offtime
348 UBYTE s3mvolslide; // last used volslide
349 UBYTE s3mrtgspeed; // last used retrig speed
350 UBYTE s3mrtgslide; // last used retrig slide
351
352 UBYTE glissando; // glissando (0 means off)
353 UBYTE wavecontrol; //
354
355 SBYTE vibpos; // current vibrato position
356 UBYTE vibspd; // "" speed
357 UBYTE vibdepth; // "" depth
358
359 SBYTE trmpos; // current tremolo position
360 UBYTE trmspd; // "" speed
361 UBYTE trmdepth; // "" depth
362
363 UBYTE fslideupspd;
364 UBYTE fslidednspd;
365 UBYTE fportupspd; // fx E1 (extra fine portamento up) data
366 UBYTE fportdnspd; // fx E2 (extra fine portamento dn) data
367 UBYTE ffportupspd; // fx X1 (extra fine portamento up) data
368 UBYTE ffportdnspd; // fx X2 (extra fine portamento dn) data
369
370 ULONG hioffset; // last used high order of sample offset
371 UWORD soffset; // last used low order of sample-offset (effect 9)
372
373 UBYTE sseffect; // last used Sxx effect
374 UBYTE ssdata; // last used Sxx data info
375 UBYTE chanvolslide; // last used channel volume slide
376
377 UBYTE panbwave; // current panbrello waveform
378 UBYTE panbpos; // current panbrello position
379 SBYTE panbspd; // "" speed
380 UBYTE panbdepth; // "" depth
381
382 UWORD newsamp; // set to 1 upon a sample / inst change
383 UBYTE voleffect; // Volume Column Effect Memory as used by Impulse Tracker
384 UBYTE voldata; // Volume Column Data Memory
385 } MP_CONTROL;
386
387
388 /******************************************************
389 ******** MikMod UniMod type: **************************
390 *******************************************************/
391
392 // UniMod flags
393 #define UF_XMPERIODS 1 // XM periods / finetuning
394 #define UF_LINEAR 2 // LINEAR periods (UF_XMPERIODS must be set as well)
395 #define UF_INST 4 // Instruments are used
396 #define UF_NNA 8 // New Note Actions used (set numvoices rather than numchn)
397
398
399 typedef struct UNIMOD
400 {
401 // This section of elements are all file-storage related.
402 // all of this information can be found in the UNIMOD disk format.
403 // For further details about there variables, see the MikMod Docs.
404
405 UWORD flags; // See UniMod Flags above
406 UBYTE numchn; // number of module channels
407 UBYTE numvoices; // max # voices used for full NNA playback
408 UWORD numpos; // number of positions in this song
409 UWORD numpat; // number of patterns in this song
410 UWORD numtrk; // number of tracks
411 UWORD numins; // number of instruments
412 UWORD numsmp; // number of samples
413 UWORD reppos; // restart position
414 UBYTE initspeed; // initial song speed
415 UBYTE inittempo; // initial song tempo
416 UBYTE initvolume; // initial global volume (0 - 128)
417 UWORD panning[64]; // 64 panning positions
418 UBYTE chanvol[64]; // 64 channel positions
419 CHAR *songname; // name of the song
420 CHAR *composer; // name of the composer
421 CHAR *comment; // module comments
422 UBYTE **tracks; // array of numtrk pointers to tracks
423 UWORD *patterns; // array of Patterns [pointers to tracks for each channel].
424 UWORD *pattrows; // array of number of rows for each pattern
425 UWORD *positions; // all positions
426 INSTRUMENT *instruments; // all instruments
427 SAMPLE *samples; // all samples
428
429 // following are the player-instance variables. They are in no way file
430 // storage related - they are for internal replay use only.
431
432 // All following variables can be modified at any time.
433
434 CHAR *modtype; // string type of module loaded
435 UBYTE bpm; // current beats-per-minute speed
436 UWORD sngspd; // current song speed
437 SWORD volume; // song volume (0-128) (or user volume)
438 BOOL extspd; // extended speed flag (default enabled)
439 BOOL panflag; // panning flag (default enabled)
440 BOOL loop; // loop module ? (default disabled)
441 BOOL forbid; // if true, no player update!
442
443 // The following variables are considered useful for reading, and should
444 // should not be directly modified by the end user.
445
446 MP_CONTROL *control; // Effects Channel information (pf->numchn alloc'ed)
447 MP_VOICE *voice; // Audio Voice information (md_numchn alloc'ed)
448 UWORD numrow; // number of rows on current pattern
449 UWORD vbtick; // tick counter (counts from 0 to sngspd)
450 UWORD patpos; // current row number
451 SWORD sngpos; // current song position. This should not
452 // be modified directly. Use MikMod_NextPosition,
453 // MikMod_PrevPosition, and MikMod_SetPosition.
454
455 // The following variables should not be modified, and have information
456 // that is pretty useless outside the internal player, so just ignore :)
457
458 UBYTE globalslide; // global volume slide rate
459 UWORD pat_reppos; // patternloop position
460 UWORD pat_repcnt; // times to loop
461 UWORD patbrk; // position where to start a new pattern
462 UBYTE patdly; // patterndelay counter (command memory)
463 UBYTE patdly2; // patterndelay counter (real one)
464 SWORD posjmp; // flag to indicate a position jump is needed...
465 // changed since 1.00: now also indicates the
466 // direction the position has to jump to:
467 // 0: Don't do anything
468 // 1: Jump back 1 position
469 // 2: Restart on current position
470 // 3: Jump forward 1 position
471
472 } UNIMOD;
473
474
475 /***************************************************
476 ****** Loader stuff: *******************************
477 ****************************************************/
478
479 // loader structure:
480
481 typedef struct MLOADER
482 { struct MLOADER *next;
483 CHAR *type;
484 CHAR *version;
485 BOOL (*Init)(void);
486 BOOL (*Test)(void);
487 BOOL (*Load)(void);
488 void (*Cleanup)(void);
489 CHAR *(*LoadTitle)(void);
490 } MLOADER;
491
492 // public loader variables:
493
494 extern FILE *modfp;
495 extern UWORD finetune[16];
496 extern UNIMOD of; // static unimod loading space
497 extern UWORD npertab[60]; // used by the original MOD loaders
498
499 // main loader prototypes:
500
501 void ML_InfoLoader(void);
502 void ML_RegisterLoader(MLOADER *ldr);
503 UNIMOD *MikMod_LoadSongFP(FILE *fp, int maxchan);
504 UNIMOD *MikMod_LoadSong(CHAR *filename, int maxchan);
505 void MikMod_FreeSong(UNIMOD *mf);
506
507
508 // other loader prototypes: (used by the loader modules)
509
510 BOOL InitTracks(void);
511 void AddTrack(UBYTE *tr);
512 BOOL ReadComment(UWORD len);
513 BOOL AllocPositions(int total);
514 BOOL AllocPatterns(void);
515 BOOL AllocTracks(void);
516 BOOL AllocInstruments(void);
517 BOOL AllocSamples(void);
518 CHAR *DupStr(CHAR *s, UWORD len);
519
520
521 // Declare external loaders:
522
523 extern MLOADER load_uni; // Internal UniMod Loader (Current version of UniMod only)
524 extern MLOADER load_mod; // Standard 31-instrument Module loader (Protracker, StarTracker, FastTracker, etc)
525 extern MLOADER load_m15; // 15-instrument (SoundTracker and Ultimate SoundTracker)
526 extern MLOADER load_mtm; // Multi-Tracker Module (by Renaissance)
527 extern MLOADER load_s3m; // ScreamTracker 3 (by Future Crew)
528 extern MLOADER load_stm; // ScreamTracker 2 (by Future Crew)
529 extern MLOADER load_ult; // UltraTracker
530 extern MLOADER load_xm; // FastTracker 2 (by Trition)
531 extern MLOADER load_it; // Impulse Tracker (by Jeffrey Lim)
532 extern MLOADER load_669; // 669 and Extended-669 (by Tran / Renaissance)
533 extern MLOADER load_dsm; // DSIK internal module format
534 extern MLOADER load_med; // MMD0 and MMD1 Amiga MED modules (by OctaMED)
535 extern MLOADER load_far; // Farandole Composer Module
536
537 // used to convert c4spd to linear XM periods (IT loader).
538 extern UWORD getlinearperiod(UBYTE note, ULONG fine);
539 extern ULONG getfrequency(UBYTE flags, ULONG period);
540
541
542 #define MP_HandleTick Player_HandleTick
543 #define ML_LoadFN(x,y) MikMod_LoadSong(x,y)
544 #define ML_LoadFP(x,y) MikMod_LoadSongFP(x,y)
545 #define MP_PlayStart(x) Player_Start(x)
546 #define MP_PlayStop Player_Stop
547
548
549 // MikMod Player Prototypes:
550 // ===========================================================
551 // This batch of prototypes affects the currently ACTIVE module
552 // set with MikMod_PlayStart)
553
554 extern void Player_Start(UNIMOD *mf);
555 extern BOOL Player_Active(void);
556 extern void Player_Stop(void);
557 extern void Player_TogglePause(void);
558 extern void Player_NextPosition(void);
559 extern void Player_PrevPosition(void);
560 extern void Player_SetPosition(UWORD pos);
561 extern void Player_Mute(SLONG arg1, ...);
562 extern void Player_UnMute(SLONG arg1, ...);
563 extern void Player_ToggleMute(SLONG arg1, ...);
564 extern BOOL Player_Muted(int chan);
565 extern void Player_HandleTick(void);
566 extern void Player_SetVolume(int volume);
567 extern UNIMOD *Player_GetUnimod(void);
568
569 extern BOOL Player_Init(UNIMOD *mf); // internal use only [by loader]
570 extern void Player_Exit(UNIMOD *mf); // internal use only [by loader]
571
572 // This batch of prototypes adheres closely to the old MikMod 2.10
573 // naming, and affects ANY specified module (need not be active,
574 // only loaded and initialized)
575
576 extern BOOL MP_Playing(UNIMOD *mf);
577 extern void MP_TogglePause(UNIMOD *mf);
578 extern void MP_NextPosition(UNIMOD *mf);
579 extern void MP_PrevPosition(UNIMOD *mf);
580 extern void MP_SetPosition(UNIMOD *mf, UWORD pos);
581 extern void MP_Mute(UNIMOD *mf, SLONG arg1, ...);
582 extern void MP_UnMute(UNIMOD *mf, SLONG arg1, ...);
583 extern void MP_ToggleMute(UNIMOD *mf, SLONG arg1, ...);
584 extern BOOL MP_Muted(UNIMOD *mf, int chan);
585
586 #ifdef __cplusplus
587 }
588 #endif
589
590 #endif
591