Return TypeFunction nameArguments
voidWriteSerialSINT32(hzChain&,unsigned int&,int,)

Declared in file: hzCodec.h
Defined in file : hzCodec.cpp

Function Logic:

0:START 1:nValue<0 2:bNeg nValue 3:nValue<0x40 4:nLen byte byte hzChain::AddByte 5:nValue<0x1000 6:nLen byte byte hzChain::AddByte hzChain::AddByte 7:nValue<0x400000 8:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte 9:nValue<0x40000000 10:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 11:nLen byte byte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte hzChain::AddByte 12: No text

Function body:

void WriteSerialSINT32 (hzChain& Z, unsigned int& nLen, int nValue)
{
   bool    bNeg ;
   char    byte ;
   if (nValue < 0)
       { bNeg = true ; nValue *= -1; }
   if (nValue < 0x40)
   {
       nLen = 1;
       byte = bNeg ? 0x40:0;
       byte |= nValue ;
       Z.AddByte(byte) ;
   }
   else if (nValue < 0x1000)
   {
       nLen = 2;
       byte = bNeg ? 0x90:0x80;
       byte |= ((nValue & 0x0f00)>>8);
       Z.AddByte(byte) ;
       Z.AddByte(nValue & 0xff);
   }
   else if (nValue < 0x400000)
   {
       nLen = 3;
       byte = bNeg ? 0xB0:0xA0;
       byte |= ((nValue & 0x0f0000)>>16);
       Z.AddByte(byte) ;
       Z.AddByte((nValue & 0xff00)>>8);
       Z.AddByte(nValue & 0xff);
   }
   else if (nValue < 0x40000000)
   {
       nLen = 4;
       byte = bNeg ? 0xD0:0xC0;
       byte |= ((nValue & 0x0f000000)>>24);
       Z.AddByte(byte) ;
       Z.AddByte((nValue & 0xff0000)>>16);
       Z.AddByte((nValue & 0xff00)>>8);
       Z.AddByte(nValue & 0xff);
   }
   else
   {
       nLen = 5;
       byte = bNeg ? 0xF0:0xE0;
       byte |= ((nValue & 0x0f000000)>>24);
       Z.AddByte(0xC0);
       Z.AddByte((nValue & 0xff000000)>>24);
       Z.AddByte((nValue & 0xff0000)>>16);
       Z.AddByte((nValue & 0xff00)>>8);
       Z.AddByte(nValue & 0xff);
   }
}