#include "p_apps.h"
#include "p_dsp.h"

#include "ringdata.h"

void LoadPcmRing()
{
	DSHORT iLen, iVal;

	// netmeeting ring
	iVal = _iRingLength;
//	if (iVal > MAX_PCMRING_SIZE)	iVal = MAX_PCMRING_SIZE;

//	iLen = (iVal*2)/5;
	iLen = 0;
	while (iVal)
	{
		iVal -= 5;
		iLen += 2;
	}
//	iLen = 6144;

	// first 2/5 is g7231 data
	SdramLoadData(_cData_RINGIN, (RING_G7231_SDRAM_HI<<8), iLen);
	// last 3/5 is g729 data
	iVal = _iRingLength - iLen;
//	iVal = 9216;
	SdramLoadData((PCCHAR)(_cData_RINGIN+iLen), (RING_G729_SDRAM_HI<<8), iVal);

//	SdramReadFlags();
	sdram_read(OPTIONS_SDRAM_HI, FLAGS_SDRAM_LO, FLAGS_MAX_DWORD);
	USHORT2PXCHAR(iVal, (PXCHAR)(Sdram_pDataCache+FLAGS_RING_SIZE));
	sdram_write(OPTIONS_SDRAM_HI, FLAGS_SDRAM_LO, FLAGS_MAX_DWORD);
//	SdramWriteFlags();
}

