I need help witing altitude to FS2002 over WideFS. I Start with an altitude in feet then convert to meters, of course. I then break up the units and the fractional parts. Using a union (uAlt) I individually determine their hex values and write them to a temporary buffer. That temporary buffer then gets sent to FS. When it does its thing it sends the plane to 10000 feet and locks up. Any ideas? (see code below)
//***************bAltWrite2FS***************
//will eventually have a void parameter and grab info from shared
//memory
bool fs02if::bAltWrite2FS( double dAlt )
{
DWORD dwResult;
int i, j, tmpVal;
char chTmpBuffer[8] = {'0', '0', '0', '0', '0', '0', '0', '0' };
bool bTmp;
//TODO: get shared memory data
//Note: dAlt is in meters
uAlt.iVal = (int)floor( dAlt ); //get the units
for( i=0; i <= 4 ; i++ )
{
chTmpBuffer[i+4] = uAlt.chVal; //copy units to temp buffer
}
tmpVal = (int)floor( ( dAlt - uAlt.iVal ) * 100 ); //get dec (precision 2)
uAlt.iVal = tmpVal; //assign to union
for( j = 0; j <= 4 ; j++ )
{
chTmpBuffer = uAlt.chVal; //copy decimal to temp buffer
}
//8 byte swap
b8ByteSwap( chTmpBuffer );
// Write the true heading to MSFS
bTmp = FSUIPC_Write(0x0570, 8, chTmpBuffer, &dwResult) &&
FSUIPC_Process(&dwResult); // Process the request(s)
return bTmp;
}