#ifndef MISC_H
#define MISC_H


/**
 * Swap two bytes of a word.
 */
inline unsigned SwapShort(const unsigned &i)
{
  return ((i << 8) & 0xff00) |
         ((i >> 8) & 0x00ff);
}

/**
 * Swap byte order of a long.
 */
inline unsigned long  SwapLong(const unsigned long &i)
{
  return ((i << 24) & 0xff000000L) |
         ((i <<  8) & 0x00ff0000L) |
         ((i >>  8) & 0x0000ff00L) |
         ((i >> 24) & 0x000000ffL);
}

/**
 * Swap two integers a and b.
 *
 */
static inline void swap(int &a, int &b)
{
  int t=a;
  a=b; b=t;
}


extern void  SYS_SetSTDIOFocus(int focus);
extern char *ProgressBar(float v, float min, float max);
extern void  HexDump(void *mem, unsigned length);
extern void *loadfile(char *fn, unsigned *len);

#endif
