/*
 * $Header: /smsa/bsd:include/dev/coord.h:bsd  1.4  $
 * $Source: /smsa/bsd:include/dev/coord.h: $
 *
 * Copyright (c) 1988 Acorn Computers Ltd., Cambridge, England
 */

#ifndef __dev_coord_h
#define __dev_coord_h

/* coord.h
 *
 * Small-scale <X,Y> coordinate pairs are held in a long with
 * X as LSB, Y as next-to-lsb. This means that incrementing a
 * pair increments the X-value; overflow is assumed never to
 * happen (reasonable when coordinates are all <= 144).  The
 * following 3 macros construct/deconstruct such a pair.
 */

#define MK_XY(x, y) ((x) | ((y) << 8))
#define GET_X(xy) ((xy) & 0xFF)
#define GET_Y(xy) (((xy) & 0xFF00) >> 8)

/* The following definition is for the stored form of a coordinate pair on
 * a little-endian machine (e.g. ARM, VAX) only.  Beware!
 */
typedef union
{
    struct { unsigned char x,y; } u;
    long xy;
} Coord, *CoordRef;

#endif/*__dev_coord_h*/

/* EOF coord.h */
