Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
Other authors:
Gerald Zajac 2007-2010
*/
#include "accelerant.h"
status_t
SetCursorShape(uint16 width, uint16 height, uint16 hot_x, uint16 hot_y,
uint8* andMask, uint8* xorMask)
{
if ((width != 16) || (height != 16)) {
return B_ERROR;
} else if ((hot_x >= width) || (hot_y >= height)) {
return B_ERROR;
} else {
SharedInfo& si = *gInfo.sharedInfo;
si.cursorHotX = hot_x;
si.cursorHotY = hot_y;
if ( ! TDFX_LoadCursorImage(width, height, andMask, xorMask))
return B_ERROR;
}
return B_OK;
}
void
MoveCursor(uint16 xPos, uint16 yPos)
{
int x = xPos;
int y = yPos;
SharedInfo& si = *gInfo.sharedInfo;
DisplayModeEx& dm = si.displayMode;
uint16 hds = dm.h_display_start;
uint16 vds = dm.v_display_start;
if (x >= dm.virtual_width)
x = dm.virtual_width - 1;
if (y >= dm.virtual_height)
y = dm.virtual_height - 1;
if (x >= (dm.timing.h_display + hds))
hds = x - dm.timing.h_display + 1;
else if (x < hds)
hds = x;
if (y >= (dm.timing.v_display + vds))
vds = y - dm.timing.v_display + 1;
else if (y < vds)
vds = y;
if (hds != dm.h_display_start || vds != dm.v_display_start)
MoveDisplay(hds, vds);
x -= (hds + si.cursorHotX);
y -= (vds + si.cursorHotY);
TDFX_SetCursorPosition(x, y);
}