Commit c9bf5034 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

changed cdiEncodeParam/cdiDecodeParam

parent 548d9b4a
void cdiDecodeParam(int param, int *pnum, int *pcat, int *pdis)
{
int iparam;
iparam = param;
if ( param < 0 ) iparam = -iparam;
*pdis = iparam / 1000000;
iparam = iparam - *pdis*1000000;
*pcat = iparam / 1000;
*pnum = iparam - *pcat*1000;
if ( param < 0 ) *pnum = -(*pnum);
unsigned int *uparam = (unsigned int *) &param;
unsigned int upnum;
*pdis = 0xff & *uparam;
*pcat = 0xff & *uparam >> 8;
upnum = 0xffff & *uparam >> 16;
if ( upnum > 0x7fff ) upnum = 0x8000 - upnum;
*pnum = upnum;
}
int cdiEncodeParam(int pnum, int pcat, int pdis)
{
int param;
int inum;
unsigned int uparam, upnum;
if ( pcat < 0 || pcat > 255 ) pcat = 255;
if ( pdis < 0 || pdis > 255 ) pdis = 255;
inum = pnum;
if ( pnum < 0 ) inum = -pnum;
param = pdis*1000000 + pcat*1000 + inum;
if ( pnum < 0 ) param = -param;
upnum = pnum;
if ( pnum < 0 ) upnum = 0x8000 - pnum;
uparam = upnum << 16 | pcat << 8 | pdis;
return (param);
return ((int)uparam);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment