/**
 **  $Filename: misc/DeliPlayer.h $
 **  $Release: 2.0 $
 **  $Revision: 2.10$
 **  $Date: 05/02/95$
 **
 **  Definitions and Macros for creating DeliTracker Playermodules
 **
 **  (C) Copyright 1991, 1992, 1993, 1994, 1995 Delirium Softdesign
 **      All Rights Reserved
 **
 ** Converted to C by Christian Buchner
 **
 **/

#ifndef	DELITRACKER_PLAYER_H
#define DELITRACKER_PLAYER_H

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

#ifndef EXEC_PORTS_H
#include <exec/ports.h>
#endif

#ifndef UTILITY_TAGITEM_H
#include <utility/tagitem.h>
#endif

#ifndef INTUITION_SCREENS_H
#include <intuition/screens.h>
#endif

/* --------------------------------------------------------------------------- */

#define DELIVERSION 17			/* Current Version of DeliTracker */
#define DELIREVISION 4			/* Current Revision of DeliTracker */

/* -------------- The declarations for the interface functions --------------- */

extern __asm APTR dt_GetListDataPos(register __d0 ULONG num);
extern __asm ULONG dt_GetListDataSize(register __d0 ULONG num);
extern __asm BOOL dt_LoadFile(void);
extern __asm void dt_CopyDir(void);
extern __asm void dt_CopyFile(void);
extern __asm void dt_CopyString(register __a0 STRPTR string);
extern __asm BOOL dt_AudioAlloc(void);
extern __asm void dt_AudioFree(void);
extern __asm void dt_StartInt(void);
extern __asm void dt_StopInt(void);
extern __asm void dt_SongEnd(void);
extern __asm void dt_CutSuffix(void);
extern __asm void dt_SetTimer(void);
extern __asm void dt_WaitAudioDMA(void);
extern __asm struct Screen *dt_LockScreen(void);
extern __asm void dt_UnlockScreen(void);
extern __asm void dt_NotePlayer(void);
extern __asm APTR dt_AllocListData(register __d0 ULONG size, register __d1 ULONG memflags);
extern __asm void dt_FreeListData(register __a1 APTR memblock);

/* ------------------------ Player Function Offsets -------------------------- */

struct DeliTrackerPlayer {
	ULONG RTS_code;
	UBYTE ID[8];
	struct TagItem *TagArray;
};

/* The TagItem ID's (ti_Tag values) for the player interface follow. */

#define DTP_Dummy	(TAG_USER + 0x4454)

#define DTP_InternalPlayer	(DTP_Dummy)			/* obsolete */
#define DTP_CustomPlayer	(DTP_Dummy + 1)		/* player is a customplayer */

#define DTP_RequestDTVersion	(DTP_Dummy + 2)	/* minimum DeliTracker version needed */
#define DTP_RequestKickVersion	(DTP_Dummy + 3)	/* minimum KickStart version needed */

#define DTP_PlayerVersion	(DTP_Dummy + 4)		/* actual player version & revision */
#define DTP_PlayerName		(DTP_Dummy + 5)		/* name of this player */
#define DTP_Creator			(DTP_Dummy + 6)		/* misc string */

#define DTP_Check1			(DTP_Dummy + 7)		/* Check Format before loading */
#define DTP_Check2			(DTP_Dummy + 8)		/* Check Format after file is loaded */
#define DTP_ExtLoad			(DTP_Dummy + 9)		/* Load additional files */
#define DTP_Interrupt		(DTP_Dummy + 10)	/* Interrupt routine */
#define DTP_Stop			(DTP_Dummy + 11)	/* Clear Patterncounter */
#define DTP_Config			(DTP_Dummy + 12)	/* Config Player */
#define DTP_UserConfig		(DTP_Dummy + 13)	/* User-Configroutine */
#define DTP_SubSongRange	(DTP_Dummy + 14)	/* Get min&max subsong number */

#define DTP_InitPlayer		(DTP_Dummy + 15)	/* Initialisize the Player */
#define DTP_EndPlayer		(DTP_Dummy + 16)	/* Player clean up */
#define DTP_InitSound		(DTP_Dummy + 17)	/* Soundinitialisation routine */
#define DTP_EndSound		(DTP_Dummy + 18)	/* End sound */
#define DTP_StartInt		(DTP_Dummy + 19)	/* Start interrupt */
#define DTP_StopInt			(DTP_Dummy + 20)	/* Stop interrupt */

#define DTP_Volume			(DTP_Dummy + 21)	/* Set Volume */
#define DTP_Balance			(DTP_Dummy + 22)	/* Set Balance */
#define DTP_Faster			(DTP_Dummy + 23)	/* Incease playspeed */
#define DTP_Slower			(DTP_Dummy + 24)	/* Decrease playspeed */
#define DTP_NextPatt		(DTP_Dummy + 25)	/* Jump to next pattern */
#define DTP_PrevPatt		(DTP_Dummy + 26)	/* Jump to previous pattern */
#define DTP_NextSong		(DTP_Dummy + 27)	/* Play next subsong */
#define DTP_PrevSong		(DTP_Dummy + 28)	/* Play previous subsong */

	/*--- functions in revision 14 or higher (distributed as Release 1.35) --- */

#define DTP_SubSongTest		(DTP_Dummy + 29)	/* Test, if given subsong is vaild */

	/*--- functions in revision 16 or higher (distributed as Release 2.01) --- */

#define DTP_NewSubSongRange	(DTP_Dummy + 30)	/* enhanced replacement for DTP_SubSongRange */

#define DTP_DeliBase		(DTP_Dummy + 31)	/* the address of a pointer where DT */
												/* stores a pointer to the DeliGlobals */

#define DTP_Flags			(DTP_Dummy + 32)	/* misc Flags (see below) */

#define DTP_CheckLen		(DTP_Dummy + 33)	/* Length of the Check Code */

#define DTP_Description		(DTP_Dummy + 34)	/* misc string */

#define DTP_Decrunch		(DTP_Dummy + 35)	/* pointer to Decrunch Code */
#define DTP_Convert			(DTP_Dummy + 36)	/* pointer to Converter Code */

#define DTP_NotePlayer		(DTP_Dummy + 37)	/* pointer to a NotePlayer Structure */
#define DTP_NoteStruct		(DTP_Dummy + 38)	/* the address of a pointer to the */
												/* NoteStruct Structure */
#define DTP_NoteInfo		(DTP_Dummy + 39)	/* a pointer where DT stores a pointer */
												/* to the current NoteStruct Structure */
#define DTP_NoteSignal		(DTP_Dummy + 40)	/* pointer to NoteSignal code */

#define DTP_Process			(DTP_Dummy + 41)	/* pointer to process entry code */
#define DTP_Priority		(DTP_Dummy + 42)	/* priority of the process */
#define DTP_StackSize		(DTP_Dummy + 43)	/* stack size of the process */
#define DTP_MsgPort			(DTP_Dummy + 44)	/* a pointer where DT stores a pointer */
												/* to a port to send its messages */

#define DTP_Appear			(DTP_Dummy + 45)	/* open your window, if you can */
#define DTP_Disappear		(DTP_Dummy + 46)	/* go dormant */

#define DTP_ModuleName		(DTP_Dummy + 47)	/* get the name of the current module */
#define DTP_FormatName		(DTP_Dummy + 48)	/* get the name of the module format */
#define DTP_AuthorName		(DTP_Dummy + 49)	/* not implemented yet */

	/*--- functions in revision 17 or higher (distributed as Release 2.07) --- */

#define DTP_InitNote		(DTP_Dummy + 50)	/* NoteStruct initialization */

#define DTP_PlayTime		(DTP_Dummy + 51)	/* not implemented yet */

/* end of player interface enumeration */


/* --- various flags --------------------------------------------------------- */

#define PLYB_CUSTOM 0		/* player is a customplayer */
#define PLYF_CUSTOM 1<<0
#define PLYB_SONGEND 1		/* player supports songend */
#define PLYF_SONGEND 1<<1

	/*--- flags defined in revision 17 or higher (distributed as Release 2.07) --- */

#define PLYB_ANYMEM 2		/* modules of this player don't require chipmem */
#define PLYF_ANYMEM 1<<2

/* --- DeliTracker message --------------------------------------------------- */

struct DeliMessage {
	struct Message Message;
	ULONG (*Function)(void);
	ULONG Result;
};

/* ---------------------------- Global Variables ------------------------------ */

struct DeliTrackerGlobals {

	/* ------ if you use dtg_AslBase, make sure that */
	/* ------ DTP_RequestDTVersion is at least 13 ! */

	struct Library *AslBase;				/* library base, don't CloseLibrary()!! */

	struct Library *DOSBase;				/* library base -"- */
	struct IntuitionBase *IntuitionBase;	/* library base -"- */
	struct GfxBase *GfxBase;				/* library base -"- */
	struct Library *GadToolsBase;			/* librarybase -"- (NULL for Kick 1.3 and below) */
	APTR ReservedLibraryBase;				/* reserved for future use */

	STRPTR	DirArrayPtr;	/* Ptr to the directory of the current module */
	STRPTR	FileArrayPtr;	/* Ptr to the filename of the current module */
	STRPTR	PathArrayPtr;	/* Ptr to PathArray (e.g used in LoadFile()) */

	APTR	ChkData;		/* pointer to the module to be checked */
	ULONG	ChkSize;		/* size of the module */

	UWORD	SndNum;		/* current sound number */
	UWORD	SndVol;		/* volume (ranging from 0 to 64) */
	UWORD	SndLBal;	/* left volume (ranging from 0 to 64) */
	UWORD	SndRBal;	/* right volume (ranging from 0 to 64) */
	UWORD	LED;		/* filter (0 if the LED is off) */
	UWORD	Timer;		/* timer-value for the CIA-Timers */

	APTR	dtg_GetListData;
	APTR	dtg_LoadFile;
	APTR	dtg_CopyDir;
	APTR	dtg_CopyFile;
	APTR	dtg_CopyString;
	APTR	dtg_AudioAlloc;
	APTR	dtg_AudioFree;
	APTR	dtg_StartInt;
	APTR	dtg_StopInt;
	APTR	dtg_SongEnd;		/* safe to call from interrupt code ! */
	APTR	dtg_CutSuffix;

	/* ------ extension in revision 14 */

	APTR	dtg_SetTimer;		/* safe to call from interrupt code ! */

	/* ------ extension in revision 15 */

	APTR	dtg_WaitAudioDMA;	/* safe to call from interrupt code ! */

	/* ------ extension in revision 16 */

	APTR	dtg_LockScreen;
	APTR	dtg_UnlockScreen;
	APTR	dtg_NotePlayer;		/* safe to call from interrupt code ! */
	APTR	dtg_AllocListData;
	APTR	dtg_FreeListData;

	APTR	dtg_Reserved1;		/* do not use !!! */
	APTR	dtg_Reserved2;		/* do not use !!! */
	APTR	dtg_Reserved3;		/* do not use !!! */
};

#endif
