/* MED.h V 2.000 10.03.1990 -- by Teijo Kinnunen, 1990 */

struct Lohko {	/* one block (4 tracks) */
	UBYTE	numtracks;
	UBYTE	pad[3];
	UBYTE	music[3 * 64 * 4]; /* at least 768 */
};
#define FOURTRKSIZE (3 * 64 * 4)
#define ONETRKSIZE (3 * 64)

#define ALATEEMITAAN 0 /* Play commands (these are ancient from V1.12) */
#define SOITALOHKO 1
#define SOITAKAPPALE 2
#define OHJELMANLOPPU 3
#define SEIS 4
#define SOITANUOTTI 5
	/* Playing state */
#define ALASOITA 0		/* don't play */
#define SOITALOHKOA 1		/* playing block */
#define SOITAKAPPALETTA 2	/* playing song */
	/* Flags */
#define	LIPPU_SUODATINPAALLA	0x1	/* filter on */
#define	LIPPU_HYPPELYPAALLA	0x2	/* jumping on */
#define	LIPPU_HYPPELYTAHTIIN	0x4	/* every 8th */
#define	LIPPU_SOITTIMETMUKANA	0x8	/* instruments attached (MOD) */

struct Kappale111 { /* 1.11/1.12 */
	ULONG id; /* sisältää "MED\x02" versiolle 1.11 */
	char soitin[32][40];
	UBYTE soittimenvoimakkuus[32];
	UWORD stoisto[32];
	UWORD stoistonpit[32];
	UWORD lohkoja; /* montako lohkoa kappaleessa on */
	UBYTE soittojarjestys[100]; /* lohkojen soittoj... */
	UWORD kappaleen_pituus; /* montako soittojärjestystä */
	UWORD tempo; /* kappaleen tempo, jos ei ilmoitettu komennolla xFxx */
	UWORD liput;
	UWORD vaihtoja; /* 5 tai 6 */
	ULONG hyppysoitin; /* jokainen bitti on 1 soitin */
	UWORD rgb[8]; /* vain 4 nyt käytössä */
};

struct Kappale { /* The song structure for MED V2.00 */
	ULONG id;			/* contains "MED\x03" for V2.00 */
	char soitin[32][40];		/* names of the instruments */
	UBYTE soittimenvoimakkuus[32];	/* volumes */
	UWORD stoisto[32];		/* repeats */
	UWORD stoistonpit[32];		/* rep. lengths */
	UWORD lohkoja;			/* number of blocks in the song */
	UBYTE soittojarjestys[100];	/* the playing sequence */
	UWORD kappaleen_pituus;		/* length of the playing sequence */
	UWORD tempo;			/* initial tempo */
	BYTE  playtransp;		/* play transpose */
	UBYTE liput;			/* flags */
	UWORD vaihtoja;			/* sliding (5 or 6) */
	ULONG hyppysoitin;		/* jumping mask */
	UWORD rgb[8];			/* screen colors */
	UBYTE midikanava[32];		/* midi channels */
	UBYTE midipreset[32];		/* & presets */
};

struct ObjSong {	/* in object files */
	UBYTE vol[32];			/* offs = 0 */
	UWORD rep[32],replen[32];	/* offs = 32, offs = 96 */
	UWORD blocks;			/* offs = 160 */
	UBYTE playseq[100];		/* offs = 162 */
	UWORD songlen;			/* offs = 262 */
	BYTE  playtransp;		/* offs = 264 */
	UBYTE flags;			/* offs = 265 */
	UWORD slide;			/* offs = 266 */
	UBYTE midichan[32],midipres[32]; /* offs = 268, offs = 300 */
};

struct SoundTrackerIns { /* SoundTracker instrument */
	char sti_nimi[22];
	UWORD sti_pit;		/* length of the sample / 2 */
	UWORD sti_vol;		/* volume */
	UWORD sti_repeat;	/* repeat */
	UWORD sti_replen;	/* repeat length */
};

struct SoundTrackerKappale { /* old SoundTracker song */
	char st_nimi[20];
	struct SoundTrackerIns st_ins[15];
	UBYTE st_kappaleen_pit;	/* song length */
	UBYTE st_kummajainen; /* 0x78 (could anybody tell me what's this) ?? */
	UBYTE st_lohkojarj[128];
};

struct MEDSoftIntCmd {	/* a bit ancient too */
	UWORD msic_cmd;
	ULONG msic_data;
	UWORD msic_soitin;
	UBYTE msic_aani;
	UBYTE pad;
};

struct Soitin {	/* a small sample structure */
	ULONG	length;
	UWORD	type;
	/* Followed by digitized data */
};

#define	IFF5OCT	1	/* types */
#define	IFF3OCT	2

struct ST24Mod {
	char songname[20];
	struct {
		char name[22];
		UWORD length;
		UWORD volume;
		UWORD repeat;
		UWORD replen;
	} sample[31];
	UBYTE songlen;
	UBYTE I_dont_know_what_this_byte_is;
	UBYTE playseq[128];
	ULONG mk; /* contains M.K. ??? (ST songs are full of enigmas ;-) */
};
