BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / accelerants / 3dfx / 3dfx_cursor.cpp
blobc7c8cd610bbbff9f0cec4f7cb2536de2a7de0890
1 /*
2 Copyright 2010 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
5 Authors:
6 Gerald Zajac 2010
7 */
10 #include "accelerant.h"
11 #include "3dfx.h"
13 #include <string.h>
17 void
18 TDFX_ShowCursor(bool bShow)
20 // Turn cursor on/off.
22 uint32 config = INREG32(VIDEO_PROC_CONFIG);
23 if (bShow)
24 config |= CURSOR_ENABLE;
25 else
26 config &= ~CURSOR_ENABLE;
28 TDFX_WaitForFifo(1);
29 OUTREG32(VIDEO_PROC_CONFIG, config);
33 void
34 TDFX_SetCursorPosition(int x, int y)
36 TDFX_WaitForFifo(1);
37 OUTREG32(HW_CURSOR_LOC, ((y + 63) << 16) | (x + 63));
41 bool
42 TDFX_LoadCursorImage(int width, int height, uint8* andMask, uint8* xorMask)
44 SharedInfo& si = *gInfo.sharedInfo;
46 if (andMask == NULL || xorMask == NULL)
47 return false;
49 uint64* fbCursor64 = (uint64*)((addr_t)si.videoMemAddr + si.cursorOffset);
51 // Initialize the hardware cursor as completely transparent.
53 for (int i = 0; i < CURSOR_BYTES; i += 16) {
54 *fbCursor64++ = ~0; // and bits
55 *fbCursor64++ = 0; // xor bits
58 // Now load the AND & XOR masks for the cursor image into the cursor
59 // buffer. Note that a particular bit in these masks will have the
60 // following effect upon the corresponding cursor pixel:
61 // AND XOR Result
62 // 0 0 White pixel
63 // 0 1 Black pixel
64 // 1 0 Screen color (for transparency)
65 // 1 1 Reverse screen color to black or white
67 uint8* fbCursor = (uint8*)((addr_t)si.videoMemAddr + si.cursorOffset);
69 for (int row = 0; row < height; row++) {
70 for (int colByte = 0; colByte < width / 8; colByte++) {
71 fbCursor[row * 16 + colByte] = *andMask++;
72 fbCursor[row * 16 + colByte + 8] = *xorMask++;
76 // Set the cursor colors which are white background and black foreground.
78 TDFX_WaitForFifo(2);
79 OUTREG32(HW_CURSOR_COLOR0, 0xffffff);
80 OUTREG32(HW_CURSOR_COLOR1, 0);
82 return true;