#include "PalmType.h"
#include "p_util.h"

 void SdramLoadData(PCCHAR pLoadData, USHORT iPos, USHORT iLength)
{
	DCHAR iIndexHigh, iIndexLow/*, iLen*/;
	DSHORT iIndex, iCurLen;
	PCCHAR_D pData;

	iCurLen = iLength;
	iIndex = iPos;
	pData = pLoadData;

	iIndexHigh = P_HIBYTE(iIndex);
	iIndexLow = (UCHAR)iIndex;

	while (iCurLen >= SRAM_DMA_BYTE)
	{
//		p_memcpy_c2x((PXCHAR)Sdram_pDataCache, pData, (UCHAR)256);
//		pData += 256;
//		p_memcpy_c2x((PXCHAR)Sdram_pDataCache2, pData, (UCHAR)256);
//		pData += 256;
		p_wmemcpy_c2x((PXCHAR)Sdram_pDataCache, pData, 512);
		pData += 512;
		sdram_write(iIndexHigh, iIndexLow, SRAM_DMA_DWORD);
		iIndexLow += 2;
		iCurLen -= SRAM_DMA_BYTE;
	}

	if (iCurLen)
	{
		p_wmemcpy_c2x((PXCHAR)Sdram_pDataCache, pData, iCurLen);
		sdram_write(iIndexHigh, iIndexLow, SRAM_DMA_DWORD);
	}

/*
	if (iCurLen >= SRAM_DMA_HALF_BYTE)
	{
		p_memcpy_c2x((PXCHAR)Sdram_pDataCache, pData, (UCHAR)256);
		pData += 256;
		sdram_write(iIndexHigh, iIndexLow, SRAM_DMA_HALF_DWORD);
		iIndexLow ++;
		iCurLen -= SRAM_DMA_HALF_BYTE;
	}

	iLen = (UCHAR)iCurLen;
	if (iLen)
	{
		p_memcpy_c2x((PXCHAR)Sdram_pDataCache, pData, iLen);
		sdram_write(iIndexHigh, iIndexLow, SRAM_DMA_HALF_DWORD);
	}
	*/
}


