#define DEFINE_CONV(name, input_type, output_type, convert) \ static void Convert_##name##(const char *buf_in, char *buf_out, wxUint32 len) \ {\ register input_type src; \ register const input_type *t_buf_in = (input_type *)buf_in; \ register output_type *t_buf_out = (output_type *)buf_out; \ \ while (len > 0) { \ src = *t_buf_in++; \ *t_buf_out++ = convert; \ len--; \ } \ } DEFINE_CONV(8_8_sign, wxUint8, wxUint8, (src ^ 0x80)) DEFINE_CONV(8_16, wxUint8, wxUint16, (((wxUint16)src) << 8)) DEFINE_CONV(8_16_swap, wxUint8, wxUint16, (src)) DEFINE_CONV(8_16_sign, wxUint8, wxUint16, (((wxUint16)(src ^ 0x80)) << 8)) DEFINE_CONV(8_16_sign_swap, wxUint8, wxUint16, (src ^ 0x80)) DEFINE_CONV(16_8, wxUint16, wxUint8, (wxUint8)(src >> 8)) DEFINE_CONV(16_8_sign, wxUint16, wxUint8, (wxUint8)((src >> 8) ^ 0x80)) DEFINE_CONV(16_swap_8, wxUint16, wxUint8, (wxUint8)(src & 0xff)) DEFINE_CONV(16_swap_8_sign, wxUint16, wxUint8, (wxUint8)((src & 0xff) ^ 0x80)) DEFINE_CONV(16_sign, wxUint16, wxUint16, (src ^ 0x8000)) DEFINE_CONV(16_swap, wxUint16, wxUint16, (((src & 0xff) << 8) | ((src >> 8) & 0xff))) DEFINE_CONV(16_swap_16_sign, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x8000)) DEFINE_CONV(16_sign_16_swap, wxUint16, wxUint16, ((((src & 0xff) << 8) | ((src >> 8) & 0xff)) ^ 0x80)) DEFINE_CONV(16_swap_16_sign_swap, wxUint16, wxUint16, (src ^ 0x80))