f0ab104f070bc7f569404826fea1828ed985638cvboxsync/*
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Copyright (C) 2000 The XFree86 Project, Inc. All Rights Reserved.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync *
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Permission is hereby granted, free of charge, to any person obtaining a copy
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * of this software and associated documentation files (the "Software"), to
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * deal in the Software without restriction, including without limitation the
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * sell copies of the Software, and to permit persons to whom the Software is
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * furnished to do so, subject to the following conditions:
f0ab104f070bc7f569404826fea1828ed985638cvboxsync *
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * The above copyright notice and this permission notice shall be included in
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * all copies or substantial portions of the Software.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync *
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync *
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Except as contained in this notice, the name of the XFree86 Project shall
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * not be used in advertising or otherwise to promote the sale, use or other
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * dealings in this Software without prior written authorization from the
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * XFree86 Project.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync *
f0ab104f070bc7f569404826fea1828ed985638cvboxsync */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#ifndef _MICOORD_H_
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define _MICOORD_H_ 1
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#include "servermd.h"
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/* Macros which handle a coordinate in a single register */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/*
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * Most compilers will convert divisions by 65536 into shifts, if signed
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * shifts exist. If your machine does arithmetic shifts and your compiler
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * can't get it right, add to this line.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync/*
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * mips compiler - what a joke - it CSEs the 65536 constant into a reg
f0ab104f070bc7f569404826fea1828ed985638cvboxsync * forcing as to use div instead of shift. Let's be explicit.
f0ab104f070bc7f569404826fea1828ed985638cvboxsync */
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#if defined(mips) || \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync defined(sparc) || defined(__sparc64__) || \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync defined(__alpha) || defined(__alpha__) || \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync defined(__i386__) || defined(__i386) || defined(__ia64__) || \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync defined(__s390x__) || defined(__s390__) || \
f0ab104f070bc7f569404826fea1828ed985638cvboxsync defined(__amd64__) || defined(amd64) || defined(__amd64)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define GetHighWord(x) (((int) (x)) >> 16)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#else
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define GetHighWord(x) (((int) (x)) / 65536)
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#endif
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#if IMAGE_BYTE_ORDER == MSBFirst
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int) ((short) (i))))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define coordToInt(x,y) (((x) << 16) | ((y) & 0xffff))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define intToX(i) (GetHighWord(i))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define intToY(i) ((int) ((short) i))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#else
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define intToCoord(i,x,y) (((x) = (int) ((short) (i))), ((y) = GetHighWord(i)))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define coordToInt(x,y) (((y) << 16) | ((x) & 0xffff))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define intToX(i) ((int) ((short) (i)))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#define intToY(i) (GetHighWord(i))
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#endif
f0ab104f070bc7f569404826fea1828ed985638cvboxsync
f0ab104f070bc7f569404826fea1828ed985638cvboxsync#endif /* _MICOORD_H_ */