/* player.h */

/* data structure for the song, and such
 */

/* $Author: Espie $
 * $Date: 91/05/20 22:44:10 $
 * $Revision: 1.21 $
 * $Log:	player.h,v $
 * Revision 1.21  91/05/20  22:44:10  Espie
 * *** empty log message ***
 * 
 * Revision 1.20  91/05/12  16:01:27  Espie
 * *** empty log message ***
 *
 * Revision 1.19  91/05/06  15:14:30  Espie
 * *** empty log message ***
 *
 * Revision 1.18  91/05/05  19:06:04  Espie
 * Added some new private fields.
 *
 * Revision 1.17  91/05/05  15:38:42  Espie
 * Augmented private structure, still searching its self.
 *
 * Revision 1.16  91/05/02  01:29:08  Espie
 * Needs some more simplification.
 *
 * Revision 1.15  91/04/30  00:35:30  Espie
 * Stable version III.
 *
 * Revision 1.14  91/04/29  15:06:13  Espie
 * No real modification this time.
 *
 * Revision 1.13  91/04/28  22:53:18  Espie
 * tranpose added.
 *
 * Revision 1.12  91/04/28  20:36:29  Espie
 * New fields for finespeed.
 * Plus timerbase/effectbase.
 *
 * Revision 1.11  91/04/27  20:49:31  Espie
 * New t
 * timing speed.
 *
 * Revision 1.10  91/04/27  16:43:39  Espie
 * Added some new fields, and some comments.
 * Beginning the cleanup of that structure.
 *
 * Revision 1.9  91/04/27  03:59:55  Espie
 * New fields, needs some editing anyway.
 * ---> specify an interface for the player.
 *
 * Revision 1.8  91/04/27  00:24:20  Espie
 * See player.c, interrupt.c (new state variable, switch to a function variable,
 * i.e., case folding).
 *
 * Revision 1.7  91/04/26  16:31:30  Espie
 * New fields for timing management, not yet perfect.
 *
 * Revision 1.6  91/04/23  21:29:37  Espie
 * Some new commands for in the player
 *
 * Revision 1.5  91/04/21  20:05:29  Espie
 * Notes added.
 *
 * Revision 1.4  91/04/21  12:11:52  Espie
 * Stable version, known as bunch II.
 * Also features ``right'' log description.
 *
 * Revision 1.3  91/04/20  18:12:54  Espie
 *
 * Revision 1.2  91/04/19  13:20:08  Espie
 * New control structure for signalling tasks.
 *
 * Revision 1.1  91/04/19  02:20:36  Espie
 * Initial revision
 *
 */

#include "periods.h"

#define NUMBER_TRACKS 4
#define NUMBER_COMMANDS 16
#define LENGTH_SINE 32

typedef void (*COMMAND)(struct play *play, struct automaton *cst);

struct automaton {
        COMMAND pursue;                 /* what to do to continue the current note */
        struct sample_info *instr;      /* the current sample */
        int period;                                     /* the current period */
        int pergoal;                            /* the period to achieve */
        int volume;                                     /* the current volume */
        int rate;                                       /* parameters for effects, and fold values */
        int offset;                                     /* could use an union there... */
        int depth;
        int speed;
        UWORD *p_table;
        UBYTE channel, note;
        UBYTE arp1, arp2;
        BOOL newnote;                           /* have we played a new note (must set up replay) */
        };


struct priv_play
        {
                void (*state)(struct play *play);
                int volume;
                BOOL filter;
                struct automaton *track[NUMBER_TRACKS];
/* sine table for vibrato command */
                BYTE *sine_table;
                COMMAND *setup;
/* periods.c value */
                UWORD **period_table;
                UBYTE *channel_mask;


                struct block *block;

/* the particular event we're processing
 */
                struct event *e;

                UBYTE counter, speed;
                UWORD finespeed;
                BOOL replay, tempo_change, has_ended;

/* used for the change patterns command
 * (code: -1 ==> nothing.
 * else pattern, or position)
 */
                BYTE skip, fastskip;

/* used for the change speed command
 * code: -1 ==> nothing.
 */
                WORD newspeed;

                volatile UBYTE *latchlo, *latchhi;
                volatile UBYTE *control;

/* the timing values are finally private */
                UWORD maintimer, smalltimer, effecttimer;

/* measures the time already spent, for restarting dma after a delay,
 * which relatch normally does not provide.
 */
                int spent;

/* the last value we put into the latch,
 *      the current elapsed time since last timer restart.
 */
                int latched, current;

/* some values we keep a private copy of
 */

                UBYTE pattern, position;


/* audio_hard values */
                ULONG mask;
                UBYTE saved_filter;



        };
