#include "accel.h"
#include "virge.h"
void
Virge_ShowCursor(bool bShow)
{
WriteCrtcReg(0x45, bShow ? 0x01 : 0x00, 0x01);
}
void
Virge_SetCursorPosition(int x, int y)
{
uint8 xOffset = 0;
uint8 yOffset = 0;
if (x < 0) {
xOffset = (( -x) & 0xfe);
x = 0;
}
if (y < 0) {
yOffset = (( -y) & 0xfe);
y = 0;
}
WriteCrtcReg( 0x4e, xOffset );
WriteCrtcReg( 0x4f, yOffset );
WriteCrtcReg( 0x47, (x & 0xff) );
WriteCrtcReg( 0x46, (x & 0x0700) >> 8 );
WriteCrtcReg( 0x49, (y & 0xff) );
WriteCrtcReg( 0x48, (y & 0x0700) >> 8 );
}
bool
Virge_LoadCursorImage(int width, int height, uint8* andMask, uint8* xorMask)
{
SharedInfo& si = *gInfo.sharedInfo;
if (andMask == NULL || xorMask == NULL)
return false;
uint16* fbCursor16 = (uint16*)((addr_t)si.videoMemAddr + si.cursorOffset);
for (int i = 0; i < CURSOR_BYTES; i += 4) {
*fbCursor16++ = ~0;
*fbCursor16++ = 0;
}
uint8* fbCursor = (uint8*)((addr_t)si.videoMemAddr + si.cursorOffset);
for (int row = 0; row < height; row++) {
for (int colByte = 0; colByte < width / 8; colByte++) {
fbCursor[row * 16 + colByte] = *andMask++;
fbCursor[row * 16 + colByte + 2] = *xorMask++;
}
}
WriteCrtcReg(0x4d, (0xff & si.cursorOffset / 1024));
WriteCrtcReg(0x4c, (0x0f00 & si.cursorOffset / 1024) >> 8);
ReadCrtcReg(0x45);
WriteCrtcReg(0x4a, 0);
WriteCrtcReg(0x4a, 0);
WriteCrtcReg(0x4a, 0);
ReadCrtcReg(0x45);
WriteCrtcReg(0x4b, ~0);
WriteCrtcReg(0x4b, ~0);
WriteCrtcReg(0x4b, ~0);
return true;
}