#include "accelerant.h"
#include "3dfx.h"
#include <string.h>
void
TDFX_ShowCursor(bool bShow)
{
uint32 config = INREG32(VIDEO_PROC_CONFIG);
if (bShow)
config |= CURSOR_ENABLE;
else
config &= ~CURSOR_ENABLE;
TDFX_WaitForFifo(1);
OUTREG32(VIDEO_PROC_CONFIG, config);
}
void
TDFX_SetCursorPosition(int x, int y)
{
TDFX_WaitForFifo(1);
OUTREG32(HW_CURSOR_LOC, ((y + 63) << 16) | (x + 63));
}
bool
TDFX_LoadCursorImage(int width, int height, uint8* andMask, uint8* xorMask)
{
SharedInfo& si = *gInfo.sharedInfo;
if (andMask == NULL || xorMask == NULL)
return false;
uint64* fbCursor64 = (uint64*)((addr_t)si.videoMemAddr + si.cursorOffset);
for (int i = 0; i < CURSOR_BYTES; i += 16) {
*fbCursor64++ = ~0;
*fbCursor64++ = 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 + 8] = *xorMask++;
}
}
TDFX_WaitForFifo(2);
OUTREG32(HW_CURSOR_COLOR0, 0xffffff);
OUTREG32(HW_CURSOR_COLOR1, 0);
return true;
}