;/* All changes must be reflected in ravescope.h */

		IFND	RAVESCOPE
RAVESCOPE	SET	1

RAVE_ID:	EQU	$BAD5EED5				* Current rave/host ID

		incdir	include:
		include	graphics/gfx.i
		include	graphics/rastport.i
		include exec/types.i
		include	exec/ports.i
		incdir	""
		include	include/monoscope.i

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*												*
*		Global RaveScope constants							*
*												*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

rs_VERSION:	equ	102

SUCCESS:	equ	1
FAIL:		equ	0
INFOHGT:	equ	37

SCREEN:		equ	0
DISPLAYID:	equ	1
INVERT:		equ	2
WINLEFT:	equ	3
WINTOP:		equ	4
WINWIDTH:	equ	5
WINHEIGHT:	equ	6
SCRWIDTH:	equ	7
SCRHEIGHT:	equ	8
WRAPACCURACY:	equ	9
TRADACCURACY:	equ	10
ALTACCURACY:	equ	11
WRAPMODE:	equ	12
TRADMODE:	equ	13
ALTMODE:	equ	14
STROBO:		equ	15
VERSION:	equ	16
NUMARGS:	equ	17

PLY_NONE:	equ	0
PLY_HIP:	equ	1
PLY_HOST:	equ	2
PLY_CHK_INT:	equ	150;				/* Player check interval (frames) */

PROJECT:	equ	0;				/* Offsets to the menu titles */
SETTINGS:	equ	3;
PLAYERS:	equ	11;

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*												*
*		Structure for messages sent to/from the RaveScope				*
*												*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

	    STRUCTURE	RaveMsg,0;			/* The message used by the Ravescope/hosts */
	       STRUCT	rmsg_oMsg,MN_SIZE;		/* Standard msg struct (struct Message) */
		ULONG	rmsg_oData;			/* Message data */
		UWORD	rmsg_oType;			/* Message class */
		 BOOL	rmsg_oResult;			/* See below for result codes */
		LABEL	rmsg_SIZEOF;

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*		Message result codes

RMSG_SUCCESS:	equ	1;				/* The recieved msg's request could be fulfilled */
RMSG_FAILURE:	equ	0;				/* The recieved msg's request could NOT be fulfilled */


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*		Message types

		BITDEF	RMSG,FROMRAVE,14;		/* Message is from the RaveScope */
		BITDEF	RMSG,FROMHOST,15;		/* Message is from a host */
		BITDEF	RMSG,FROMDISP,13;		/* Message is from the RaveScope display */
		BITDEF	RMSG,TORAVE,12;			/* Message is to the RaveScope */
		BITDEF	RMSG,TOHOST,11;			/* Message is to a host */
		BITDEF	RMSG,TODISP,10;			/* Message is to the rave display */

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*		Message that can be sent from the RaveScope main to the host and the display

RMSG_RAVEQUIT:	equ	RMSGF_FROMRAVE+0;		/* The RaveScope wants to quit. */
RMSG_RAVEBUSY:	equ	RMSGF_FROMRAVE+1;		/* The RaveScope is busy, sent when a stopflag has been set (and no stopflags was set before this) */
RMSG_RAVEREADY:	equ	RMSGF_FROMRAVE+2;		/* The RaveScope is ready, sent when a stopflags has been cleared (which resulted in all stopflags being cleared) */


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*		Message that can be sent from the RaveScope main to the host

RMSG_LEAVERAVE	equ	RMSGF_FROMRAVE!RMSGF_TOHOST+0;	/* The RaveScope has been requested by another player. */
RMSG_GRABRAVE:	equ	RMSGF_FROMRAVE!RMSGF_TOHOST+1;	/* The RaveScope wants to grab us. */


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*		Message that can be sent from the RaveScope main to the display

RMSG_ADDPORTS:	equ	RMSGF_FROMRAVE!RMSGF_TODISP+0;	/* Create message ports (dbuff-related) */
RMSG_DELPORTS:	equ	RMSGF_FROMRAVE!RMSGF_TODISP+1;	/* Delete message ports (dbuff-related) */
RMSG_POKESTICK:	equ	RMSGF_FROMRAVE!RMSGF_TODISP+2;	/* Poke display-task with a stick */


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
*
*		Message that can be sent from the RaveScope main to itself
*

RMSG_GRABHOST:	equ	RMSGF_FROMRAVE!RMSGF_TORAVE+0;	/* Grab host with name in data-field */

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*	Message that can be sent from the host to the RaveScope

RMSG_NEWHOST:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+0;	/* Ask the RaveScope to grab host */
RMSG_PLYHALTED:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+1;	/* The host's player is halted */
RMSG_PLYACTIVE:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+2;	/* The host's player is active */
RMSG_HOSTBUSY:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+3;	/* The host is busy */
RMSG_HOSTREADY:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+4;	/* The host is ready */
RMSG_HOSTQUIT:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+5;	/* Host wants to quit */
RMSG_CLOSESCOPE	equ	RMSGF_FROMHOST!RMSGF_TORAVE+6;	/* Ask the RaveScope to close the scope */
RMSG_OPENSCOPE:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+7;	/* Ask the RaveScope to open the scope */
RMSG_KILLRAVE:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+8;	/* Force the RaveScope to quit */
RMSG_DOICONIFY:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+9;	/* Ask the RaveScope to iconify itself */
RMSG_DEICONIFY:	equ	RMSGF_FROMHOST!RMSGF_TORAVE+10;	/* Ask the RaveScope to de-iconify itself */
RMSG_SAVECONFIG equ	RMSGF_FROMHOST!RMSGF_TORAVE+11;	/* Ask the RaveScope to save current config */

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*	Message that can be sent from the display to the RaveScope

RMSG_HIPHALTED:	equ	RMSGF_FROMDISP!RMSGF_TORAVE+0;	/* Hippoplayer stopped playing */
RMSG_HIPACTIVE:	equ	RMSGF_FROMDISP!RMSGF_TORAVE+1;	/* Hippoplayer started playing */
RMSG_LOSTHIP:	equ	RMSGF_FROMDISP!RMSGF_TORAVE+2;	/* Hippoplayer wants to quit */

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*												*
*		The RaveScope structure								*
*												*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

	   STRUCTURE	RaveScope,0

	       STRUCT	rs_orport,MP_SIZE;		/* For use by the hosts */

	   * ID and version *

		ULONG	rs_oID;				/* BAD5EED5, must be filled in */
		ULONG	rs_oVersion;			/* 101 for the second release (1.1) */
	       STRUCT	rs_oReserved1,40;		/* 40 reserved bytes */

	   * Volatile pointers *

		 APTR	rs_oHost;
		 APTR	rs_ohport;
		 APTR	rs_oScope;
		 APTR	rs_oTask1Ptr;
		 APTR	rs_oScreen;
		 APTR	rs_oWindow;
		 APTR	rs_oDestBM;			/* Dest BitMap for scope */
		 APTR	rs_oHeadPtr;			/* Ptr to channel structures */
	       STRUCT	rs_oReserved2,40;		/* 40 reserved bytes */

	   * Volatile variables *

		ULONG	rs_oWidth;
		ULONG	rs_oHeight;
		ULONG	rs_oScpWidth;
		ULONG	rs_oScpHeight;
		 LONG	rs_oTradAcc;
		 LONG	rs_oAltrAcc;
		 WORD	rs_oWrapAcc;
                 BOOL	rs_oBusy;			/* Set while initing */
		UWORD	rs_oBMWidth;			/* Width of display bitmap */
		 BYTE	rs_oWrapOn;
		 BYTE	rs_oTradOn;
		 BYTE	rs_oAltrOn;			/* Init the modes (on/off) */
		 BYTE	rs_oOnTop;
		 BYTE	rs_oPlayer;			/* Player grabbed (0=none) */
		 BYTE	rs_oPad_byte1
	       STRUCT	rs_oReserved3,40;		/* 40 reserved bytes */

	   * Pointer declarations *

		 APTR	rs_oRaveReq;
	       STRUCT	rs_oScrBfrs,2*4;
	       STRUCT	rs_oScrBfrPorts,2*4;
		 APTR	rs_odport;			/* Display task's message port */
		 APTR	rs_orportd;			/* RaveScopes msgport for displaytask */
		 APTR	rs_oIconPort;			/* Msgport to use when iconified */
		 APTR	rs_oMainTask;
		 APTR	rs_oRDArgs;
		 APTR	rs_oMenu;			/* The Ravescope menu */
		 APTR	rs_oDynMenu;			/* Pointer to dynamic NewMenu struct */
		 APTR	rs_oAppIcon;			/* Ptr to the appicon structure */
		 APTR	rs_oChunkyBuffer;		/* Ptr to the chunky buffer (when using colours) */
		 APTR   rs_oVisualInfo;			/* Visual info */
		 APTR	rs_oScopeDest;			/* Display scope here */
		 APTR	rs_oGet4Upd_f;			/* Ptr to ms_Get4Update() */
		 APTR	rs_oGet4Disp_f;			/* Ptr to ms_Get4Display() */
		 APTR	rs_oMakeRoom_f;			/* Ptr to chan expansion routine */
		 APTR	rs_oObtainCfg_f;		/* Ptr to rs_ObtainCfg() */
		 APTR	rs_oResetCfg_f;			/* Ptr to rs_ResetCfg() */
		 APTR	rs_oReadCfg_f;			/* Ptr to rs_ReadCfg() */
		 APTR	rs_oMousePtr;
		 APTR	rs_oErrMsg;			/* Error message */
	       STRUCT	rs_oReserved4,40;		/* 40 reserved bytes */

	   * Structures *

	       STRUCT	rs_oChanHead,scph_SIZEOF;	/* ScopeHeader structure */
	       STRUCT	rs_oChannels,4*scpc_SIZEOF;	/* 4 ScopeChannel structs */
	       STRUCT	rs_oEmptyBM,bm_SIZEOF;
	       STRUCT	rs_oRectangle,ra_SIZEOF;
	       STRUCT	rs_oTempRP,rp_SIZEOF;		/* Temporary rastport for WritePixelArray8 */
	       STRUCT	rs_oTempBM,bm_SIZEOF;		/* Temporary bitmap str for WritePixelArray8 */
	       STRUCT	rs_oReserved5,40;		/* 40 reserved bytes */

	   * Other variables *

		ULONG	rs_oDisplayID;
		ULONG	rs_oActFlag;			/* The activate flag */
		 LONG	rs_oErrCode;			/* RaveScope return code */
	       STRUCT	rs_oReserved6,40;		/* 40 reserved bytes */

		UWORD	rs_oToggle;
		UWORD	rs_oAvailPlys;			/* Number of players currently available */
		 WORD	rs_oWantedSTop;
		 WORD	rs_oWantedSLft;
		 WORD	rs_oWantedSWdt;
		 WORD	rs_oWantedSHgt;
		 WORD	rs_oWantedWWdt;
		 WORD 	rs_oWantedWHgt;
		 WORD	rs_oWantedWTop;
		 WORD	rs_oWantedWLft;
		 BOOL	rs_oLev3Added;
		 BOOL	rs_oUseWin;			/* Use window? */
		 BOOL	rs_oSafe2Wrt;
		 BOOL	rs_oSafe2Chg;
		 BOOL	rs_oShiftToggle;
		 BOOL	rs_oCfgParsed;			/* Config parsed? */
	       STRUCT	rs_oStroboDel,2;		/* Strobo delays */
	       STRUCT	rs_oReserved7,40;		/* 40 reserved bytes */

		UBYTE	rs_oKillWin;			/* Events >0 will kill the window */
		UBYTE	rs_oStroboNum;			/* Strobo number (0/1) */
		UBYTE	rs_oStopFlags;			/* See below for stopflags */
		UBYTE	rs_oStroboCtr;			/* Strobo count down */
		UBYTE	rs_oUseCols;			/* Use colours? */
		UBYTE	rs_oUsingCols;			/* Using colours? */
		UBYTE	rs_oShowTemplate;		/* Show template on exit? */
		UBYTE	rs_oInvert;			/* Invert display? */
		UBYTE	rs_oFromWB;			/* Started from wb? (if no, printf will execute) */
		UBYTE	rs_oScopeCleared;		/* Set when scope is cleared */
		 BYTE	rs_orport_SigBit;		/* RavePort's signal bit */
		 BYTE	rs_orport_added;		/* Set when rport has been AddPort()ed */
		 BYTE	rs_oMenuStripSet;		/* Set if SetMenuStrip() has been called */
		 BYTE	rs_oStroboOn;			/* Strobo on/off */
		 BYTE	rs_oHipOpenCount;		/* Keeps track of our changes to hip's opencount */
		 BYTE	rs_oPadByte;
	       STRUCT	rs_oReserved8,40;		/* 40 reserved bytes */
		LABEL	rs_SIZEOF;


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*	STOPFLAGS: The host/display must check all these flags, and if any of them are set,
*	Wait() until they are all cleared.
*
		BITDEF	RSSF,RAVEBUSY,0;		/* The RaveScope is busy */
		BITDEF	RSSF,HOSTBUSY,1;		/* The host is busy */
		BITDEF	RSSF,PLYHALTED,2;		/* The host's player is not playing. */


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*												*
*		The RaveScopeCfg structure							*
*												*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

	    STRUCTURE	RaveScopeCfg,0;			/* 120 bytes config data */
		ULONG	cfg_oID;			/* Config ID */
		ULONG	cfg_oDisplayID;			/* Ravescope's display mode */
		UWORD	cfg_oWrapAcc;			/* Wrapped accuracy */
		UWORD	cfg_oTradAcc;			/* Traditional accuracy */
		UWORD	cfg_oAltrAcc;			/* Alternative accuracy */
		 WORD	cfg_oSLeft;			/* Ravescreen's left pos */
		 WORD	cfg_oSTop;			/* Ravescreen's top pos */
		 WORD	cfg_oSWidth;			/* Ravescreen's width */
		 WORD	cfg_oSHeight;			/* Ravescreen's height */
		 WORD	cfg_oWLeft;			/* Ravewindow's left pos */
		 WORD	cfg_oWTop;			/* Ravewindow's top pos */
		 WORD	cfg_oWWidth;			/* Ravewindow's width */
		 WORD	cfg_oWHeight;			/* Ravewindow's height */
		 WORD	cfg_oALeft;			/* Ravewin's alternative left pos */
		 WORD	cfg_oATop;			/* Ravewin's alternative top pos */
		 WORD	cfg_oAWidth;			/* Ravewin's alternative width */
		 WORD	cfg_oAHeight;			/* Ravewin's alternative height */
		UBYTE	cfg_oUseWin;			/* Use win at startup or not? */
		UBYTE	cfg_oUseCols;			/* Use colours? */
	       STRUCT	cfg_oReserved,72;		/* 72 reserved bytes */
		 BYTE	cfg_oStroboOn;			/* Strobo on/off */
	       STRUCT	cfg_oStroboDel,2;		/* Strobo delays */
		 BYTE	cfg_oScreen;			/* Open directly on screen? */
		 BYTE	cfg_oInvert;			/* Invert colours? */
		 BYTE	cfg_oWrap;			/* Wrapped mode on? */
		 BYTE	cfg_oTrad;			/* Traditional mode on? */
		 BYTE	cfg_oAltr;			/* Alternative mode on? */
	       STRUCT	cfg_oPubScrName,100;		/* 100 bytes name of pubscreen to open on (UBYTE[100]) */
		LABEL	cfg_SIZEOF;


*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*	The RaveHost structure
*

	    STRUCTURE	RaveHost,0
	       STRUCT	rh_oMsgPort,MP_SIZE;		/* Host's msgport (struct MsgPort) */
	       STRUCT	rh_oChanHdrs,scph_SIZEOF*3;	/* 3 channel headers (struct ScopeHeader[3]) */
	       STRUCT	rs_oReserve1,40;		/* 40 reserved bytes */

		ULONG	rh_oID;				/* $BAD5EED5 (filled in) (ULONG) */
		 APTR	rh_oRaveBase;			/* Ptr to RaveScope globals (struct RaveScope *) */
		 APTR	rh_oOldScph;			/* Last scopeheader to be updated (struct ScopeHeader *) */
		 APTR	rh_oThisTask;			/* Ptr to this task (struct Task *) */
		 FPTR	rh_oGet4Upd_f;			/* Ptr to ms_Get4Update() (APTR) */
		 FPTR	rh_oMakeRoom_f;			/* Ptr to chan expansion routine (APTR) */
		 APTR	rh_oFileReq;			/* Ptr to reqtools (struct rtFileRequester *) */
		 APTR	rh_oSysBase;			/* exec.library base (struct ExecBase *) */
		 APTR	rh_oDOSBase;			/* dos.library base (struct Library *) */
		 APTR	rh_oIntuiBase;			/* intuition.library base (struct Library *) */
		 APTR	rh_oRTBase;			/* reqtools.library base (struct Library *) */
		 APTR	rh_oHostName;			/* Ptr to name of this host (STRPTR) */
		 APTR	rh_oCfgPtr;			/* Ptr to the configuration data (struct HostConfig *) */
		 APTR	rh_oCfgName;			/* Ptr to full path (w/name) to host's config (STRPTR) */
		 APTR	rh_oError;			/* Ptr to errormessage (UBYTE *) */
		ULONG	rh_oCfgSize;			/* Size of allocated/loaded config (ULONG) */
		ULONG	rh_oSigMask;			/* Signal mask, for use by the host (ULONG) */
	       STRUCT	rs_oReserve2,40;		/* 40 reserved bytes */

		UBYTE	rh_oFromWB;			/* Set if starting ravescope from hostfuncs */
		 BYTE	rh_oSignal;			/* The messageport's signalbit (BYTE) */
		 BYTE	rh_oPopup;			/* 1/4: Popup when started? (BYTE) */
		 BYTE	rh_oActivate;			/* 2/4: Activate on popup? (BYTE) */
		 BYTE	rh_oUnused;			/* 3/4: Used to be popup => steal (BYTE) */
		 BYTE	rh_oQuitEqKill;			/* 4/4: Quit => kill the ravescope? (BYTE) */
		 BYTE	rh_oPlaying;			/* Set when the host's player is playing (BYTE) */
		 BYTE	rh_oFreeRHStr;			/* Set if the RaveHost struct must be freed (BYTE) */
		 BYTE	rh_oMsgPortOk;			/* Set when the msgport is created (BYTE) */
		 BYTE	rh_oHostQuit;			/* Set when we are about to quit (BYTE) */
	       STRUCT	rs_oReserve3,40;		/* 40 reserved bytes */
	    ALIGNLONG	*+-
		LABEL	rh_SIZEOF

*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*
*	The HostConfig structure
*

	    STRUCTURE	HostConfig,0
		ULONG	hcfg_oID;			/* Config ID (ULONG) */
	       STRUCT	hcfg_oRaveCfg,cfg_SIZEOF;	/* The RaveScope's config details (struct RaveScopeCfg) */
		 BYTE	hcfg_oPopup;			/* 1/4: Popup flag (BYTE) */
		 BYTE	hcfg_oActivate;			/* 2/4: Activate flag (BYTE) */
		 BYTE	hcfg_oUnused;			/* 3/4: Used to be Popup => steal (BYTE) */
		 BYTE	hcfg_oQuitEqKill;		/* 4/4: Quit => kill? (BYTE) */
	       STRUCT	hcfg_oReserved20,20;		/* 20 reserved bytes (BYTE[20]) */
	       STRUCT	hcfg_oRaveName,500;		/* 500 bytes path to ravescope exe (UBYTE[500]) */
		LABEL	hcfg_SIZEOF;			/* Size of config */




		 ENDC   ; RAVESCOPE

