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

static long holdrand = 1L;

void p_srand(USHORT iSeed)
{
	holdrand = (long)iSeed;
}

USHORT p_rand()
{
	return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
}

UCHAR p_rand_char()
{
	return (UCHAR)p_rand();
}

void p_rand_array(PXCHAR pDst, UCHAR iLen)
{
	while (iLen)
	{
		USHORT2PXCHAR(p_rand(), pDst);
		pDst += 2;
		iLen -= 2;
	}
}

USHORT p_randseed_from_mac()
{
	return PXCHAR2USHORT(Local_pMacAddress) + PXCHAR2USHORT((PXCHAR)(Local_pMacAddress+2)) + PXCHAR2USHORT((PXCHAR)(Local_pMacAddress+4));
}

