C: Decimal to BCO

From FSDeveloper Wiki
Jump to: navigation, search

C: Decimal to BCO

While the BCD conversion is useful for setting radios, it cannot be used for setting the Transponder. Instead, BCO must be used. Example below:


UINT32 Dec2Bco(int xpdr)
{
	int x = xpdr % 10;
	int x1 = (((xpdr / 10) % 10) * 16) + x;
	int x2 = (((xpdr / 100) % 10) * 256) + x1;
 	int x3 = ((xpdr / 1000) * 4096) + x2;
 	return UINT32(x3);
}

To use:

trigger_key_event(KEY_XPNDR_SET, Dec2Bco(7700));//Emergency! Mayday! Mayday!