/***************************************************************************
*	NAME:  VOCEND.C
**	COPYRIGHT:
**	"Copyright (c) 1992, by FORTE
**
**       "This software is furnished under a license and may be used,
**       copied, or disclosed only in accordance with the terms of such
**       license and with the inclusion of the above copyright notice.
**       This software or any other copies thereof may not be provided or
**       otherwise made available to any other person. No title to and
**       ownership of the software is hereby transfered."
****************************************************************************
*  CREATION DATE: 11/18/92
*--------------------------------------------------------------------------*
*     VERSION	DATE	   NAME		DESCRIPTION
*>	1.0	11/18/92		Original
***************************************************************************/

#include <dos.h>
#include <conio.h>

#include "forte.h"
#include "gf1proto.h"
#include "osproto.h"
#include "gf1hware.h"
#include "gf1os.h"

extern ULTRA_DATA _gf1_data;

void
UltraSetVoiceEnd(int voice,unsigned long end)
// int voice;					/* voice to start */
// unsigned long end;			/* end location in ultra DRAM */
{
unsigned long phys_end;
unsigned char data;

	ENTER_CRITICAL;

	/* Make sure was are talking to proper voice */
	outp(_gf1_data.voice_select,voice);

	outp(_gf1_data.reg_select,GET_CONTROL);
	data = inp(_gf1_data.data_hi);

	if (data & VC_DATA_TYPE)
		{
		phys_end   = convert_to_16bit(end);
		}
	else
		{
		phys_end = end;
		}

	/* Set end address of buffer */
	outp(_gf1_data.reg_select,SET_END_LOW);
	outpw(_gf1_data.data_low,ADDR_LOW(phys_end));
	outp(_gf1_data.reg_select,SET_END_HIGH);
	outpw(_gf1_data.data_low,ADDR_HIGH(phys_end));
	
	data &= ~(VC_IRQ_PENDING|VOICE_STOPPED|STOP_VOICE);

	outp(_gf1_data.reg_select,SET_CONTROL);
	outp(_gf1_data.data_hi,data);
	gf1_delay();

	outp(_gf1_data.reg_select,SET_CONTROL);
	outp(_gf1_data.data_hi,data);

	LEAVE_CRITICAL;
}

