/* proto.h */

/* prototypes for external functions
 */

/* $Author: Espie $
 * $Date: 91/05/16 15:06:02 $
 * $Revision: 1.41 $
 * $Log:	proto.h,v $
 * Revision 1.41  91/05/16  15:06:02  Espie
 * *** empty log message ***
 * 
 * Revision 1.40  91/05/12  19:54:50  Espie
 * Moved private protos to lprotos, minor changes.
 * 
 * Revision 1.39  91/05/12  15:58:59  Espie
 * *** empty log message ***
 * 
 * Revision 1.38  91/05/11  14:58:21  Espie
 * *** empty log message ***
 * 
 * Revision 1.37  91/05/09  17:37:48  Espie
 * Support for parameters and appwindow.
 * 
 * Revision 1.36  91/05/08  15:52:48  Espie
 * New prototypes for files.c, and set_volume.
 * 
 * Revision 1.35  91/05/07  12:13:01  Espie
 * *** empty log message ***
 * 
 * Revision 1.34  91/05/06  23:38:15  Espie
 * Cleaned up some prototypes, libraries.c.
 * 
 * Revision 1.33  91/05/06  15:14:37  Espie
 * *** empty log message ***
 * 
 * Revision 1.32  91/05/05  19:06:36  Espie
 * *** empty log message ***
 * 
 * Revision 1.31  91/05/05  15:39:03  Espie
 * Changed all audio_hard prototypes...
 * 
 * Revision 1.30  91/05/05  04:00:40  Espie
 * *** empty log message ***
 * 
 * Revision 1.29  91/05/03  02:48:46  Espie
 * *** empty log message ***
 * 
 * Revision 1.28  91/05/02  23:32:20  Espie
 * *** empty log message ***
 * 
 * Revision 1.27  91/05/02  11:22:09  Espie
 * New prototypes, still tidying up...
 * 
 * Revision 1.26  91/05/02  01:32:49  Espie
 * New prototypes almost everywhere.
 * 
 * Revision 1.25  91/04/30  16:50:39  Espie
 * Some minor interface details.
 * 
 * Revision 1.24  91/04/30  00:35:24  Espie
 * Stable version III.
 * 
 * Revision 1.23  91/04/30  00:24:03  Espie
 * Changed proto for unload_song().
 * 
 * Revision 1.22  91/04/29  23:54:21  Espie
 * Prototypes for the file requester functions.
 * 
 * Revision 1.21  91/04/29  15:06:27  Espie
 * Cleaned up interface for audio_hard/interrupt.c.
 * 
 * Revision 1.20  91/04/29  13:02:40  Espie
 * Cleaned up interface to the audio software.
 * 
 * Revision 1.19  91/04/29  03:53:25  Espie
 * New prototypes for inter.c and audio_soft.c
 * 
 * Revision 1.18  91/04/29  02:22:32  Espie
 * New prototypes for the blossoming interface.
 * 
 * Revision 1.17  91/04/28  22:53:55  Espie
 * New: init_periods().
 * 
 * Revision 1.16  91/04/27  20:49:18  Espie
 * Change in set_tempo.
 * 
 * Revision 1.15  91/04/27  16:46:14  Espie
 * New protos for enabling/disabling interrupts.
 * 
 * Revision 1.14  91/04/27  03:59:48  Espie
 * *** empty log message ***
 * 
 * Revision 1.13  91/04/27  00:24:07  Espie
 * Nothing important.
 * 
 * Revision 1.12  91/04/26  16:31:12  Espie
 * New prototypes for turn_on_dma()/audio_soft() functions.
 * 
 * Revision 1.11  91/04/24  15:27:34  Espie
 * New prototypes for audio_soft.
 * 
 * Revision 1.10  91/04/23  21:30:50  Espie
 * New prototypes for new functions.
 * 
 * Revision 1.9  91/04/21  12:11:54  Espie
 * Stable version, known as bunch II.
 * Also features ``right'' log description.
 * 
 * Revision 1.8  91/04/21  11:16:31  Espie
 * Prototypes for audio.c have been cleaned up.
 *
 * Revision 1.7  91/04/20  18:12:49  Espie
 *
 * Revision 1.6  91/04/19  13:20:24  Espie
 *
 * Revision 1.5  91/04/19  02:18:27  Espie
 *
 * Revision 1.4  91/04/18  20:23:17  Espie
 * no big change in this file.
 *
 * Revision 1.3  91/04/18  02:26:07  Espie
 * bunch I.
 *
 * Revision 1.2  91/04/18  02:18:42  Espie
 * New prototypes (temporary) for audio/player.
 *
 * Revision 1.1  91/04/17  18:52:20  Espie
 * Initial revision
 *
 */

/* my personal quirks */

#define FORWARD
#define LOCAL static
#define XT extern
#define forever while(TRUE)

/* necessary... */

#define exit _exit
#ifdef NDEBUG
#define mayPanic(message) Panic(NULL)
#else
#define mayPanic(message) Panic(message)
#endif
 
/***
 *
 *	audio_hard.c
 *
 ***/
 
XT void reset_audio(void);

XT void save_filter(void);
XT void restore_filter(void);

/***
 *
 * audio_soft.c
 *
 ***/
 
/* obtain_audio(pri) set up structures for accessing the audio hardware.
 * start_player() starts the player routine if possible.
 * stop_player() stops the player routine when appropriate.
 * 
 */
 	
XT ULONG obtain_audio(int priority);

XT void handle_audio(void);
XT void start_player(void);
XT void stop_player(void);
XT void song_available(BOOL really);

/***
 *
 *	interrupt.c
 *
 ***/


XT struct pub_play *obtain_player(void);
XT void stop_timer(void);
XT void start_timer(void);

XT void set_tempo(int tempo, int effect);
XT void set_mode(int mode);
XT void setup_song(struct song *s); 
XT void launch_play(int patt);


/***
 *
 *	load.c
 *
 ***/
 
XT struct song *load_song(char *arg);
XT int load_error(void);

#define OUT_OF_MEMORY (-1)
#define OUT_OF_CHIP (-2)
#define MISSING_SAMPLE 1
#define UNSUPPORTED 2
#define FORMAT_ERROR 3
#define NOTE_PROBLEM 4
#define NOT_A_MOD 5

/* always returns NULL, but useful that way
 */
XT struct song *unload_song(struct song *s);

/***
 *
 *	play.c
 *
 ***/

#ifndef LATTICE
#define __interrupt
#define __asm
#define __a1
#endif

XT void __interrupt __asm do_play(register __a1 struct play *p);

XT void init_player(struct play *play);

/***
 *
 * crit.c
 *
 ***/
 
XT int nobreak(void);

/***
 *
 *	periods.c
 *
 ***/

XT void init_periods(UWORD **period_table);
XT UBYTE find_note(UWORD period, UBYTE fine);

/* returns -1 if there is a problem */

XT BYTE normalize_finetune(UBYTE finetune);

/***
 *
 * interface.c
 *
 ***/
 
XT struct Window *init_interface(int xoffset, int yoffset);
XT void message_interface(struct IntuiMessage *msg);

XT void handle_interface(void);
XT BOOL did_abort(void);
XT void clear_abort(void);

XT void update_title(int pos, int len, char *title);
XT void new_title(int pos, int len, char *title);
XT void no_title(void);
XT void reset_tempo(void);

XT void temporary_title(char *message);
XT void restore_title(void);

XT void pref_volume(int volume);
XT void pref_speed(int speed);
XT void pref_mode(int mode);

/***
 *
 *	events.c 
 *
 ***/

XT struct pub_play *init_events(int pri, int xoffset, int yoffset);
 
XT void check_abort(void);
XT void wait_abort(void);

/* dump.c */


XT void try_change_song(void);
XT void add_some_songs(struct AppMessage *msg);
XT void handle_player(void);
XT BOOL safe_load_song(char *arg);
XT BOOL safe_unload_song(void);

/* requester.c */

XT char *get_name(char *banner);
XT BOOL init_requester(struct Window *w);
XT BOOL is_info(char *name);
/* libraries.c */

#define ARP 0
#define OS_20 1
#define NO_REQ 3

XT void open_libraries(void);
XT BOOL running_20(void);
XT int requester_type(void);
XT BOOL icon_around(void);
XT BOOL wb_around(void);

XT struct IntuitionBase *IntuitionBase;
XT struct GfxBase *GfxBase;
XT struct Library *AslBase, *ArpBase, *IconBase;

#ifdef SIZE_GADGET
XT struct Library *LayersBase;
#endif

/***
 *
 *		files.c
 *
 ***/
 
XT char *next_song(struct iterator **head, BOOL req);
XT struct iterator *setup_arguments(int argc, char **argv);
XT int do_get_arg(char *tooltype, int def);
XT int do_map_arg(char *tooltype, char **names, int def);
XT int get_arg(char **tools, char *tooltype, int def);
XT int map_arg(char **tools, char *tooltype, char **names, int def);
XT char **grab_tooltypes(struct iterator *it, char *arg);
XT void insert_args(struct iterator **head, struct AppMessage *msg);

/***
 *
 *		workbench.c
 *
 ***/
 
XT ULONG init_appwindow(struct Window *w);
XT void handle_app(void);
