 /*
  * UAE - The Un*x Amiga Emulator
  *
  * MC68000 emulation - machine-dependent bits for generic hosts.
  *
  * Copyright 1996 Bernd Schmidt
  * Copyright 2005-2007 Richard Drummond
  */

/*
 * Machine-dependent structure for holding the 68k CCR flags
 */
struct flag_struct {
    unsigned int c;
    unsigned int z;
    unsigned int n;
    unsigned int v;
    unsigned int x;
};

extern struct flag_struct regflags;

#define ZFLG (regflags.z)
#define NFLG (regflags.n)
#define CFLG (regflags.c)
#define VFLG (regflags.v)
#define XFLG (regflags.x)

STATIC_INLINE int cctrue(int cc)
{
    switch (cc) {
	case 0:  return 1;								/*				T  */
	case 1:  return 0;								/*				F  */
     case 2: return !CFLG && !ZFLG;          /* HI */
     case 3: return CFLG || ZFLG;            /* LS */
     case 4: return !CFLG;                   /* CC */
     case 5: return CFLG;                    /* CS */
     case 6: return !ZFLG;                   /* NE */
     case 7: return ZFLG;                    /* EQ */
     case 8: return !VFLG;                   /* VC */
     case 9: return VFLG;                    /* VS */
     case 10:return !NFLG;                   /* PL */
     case 11:return NFLG;                    /* MI */
     case 12:return NFLG == VFLG;            /* GE */
     case 13:return NFLG != VFLG;            /* LT */
     case 14:return !ZFLG && (NFLG == VFLG); /* GT */
     case 15:return ZFLG || (NFLG != VFLG);  /* LE */
    }
    abort ();
    return 0;
}
