2 Copyright 2009 Haiku, Inc. All rights reserved.
3 Distributed under the terms of the MIT license.
10 #include "accelerant.h"
18 Mach64_ShowCursor(bool bShow
)
20 // Turn cursor on/off.
22 OUTREGM(GEN_TEST_CNTL
, bShow
? HWCURSOR_ENABLE
: 0, HWCURSOR_ENABLE
);
27 Mach64_SetCursorPosition(int x
, int y
)
29 SharedInfo
& si
= *gInfo
.sharedInfo
;
31 // xOffset & yOffset are used for displaying partial cursors on screen edges.
46 OUTREG(CUR_OFFSET
, (si
.cursorOffset
>> 3) + (yOffset
<< 1));
47 OUTREG(CUR_HORZ_VERT_OFF
, (yOffset
<< 16) | xOffset
);
48 OUTREG(CUR_HORZ_VERT_POSN
, (y
<< 16) | x
);
53 Mach64_LoadCursorImage(int width
, int height
, uint8
* andMask
, uint8
* xorMask
)
55 SharedInfo
& si
= *gInfo
.sharedInfo
;
57 if (andMask
== NULL
|| xorMask
== NULL
)
60 uint16
* fbCursor
= (uint16
*)((addr_t
)si
.videoMemAddr
+ si
.cursorOffset
);
62 // Initialize the hardware cursor as completely transparent.
64 memset(fbCursor
, 0xaa, CURSOR_BYTES
);
66 // Now load the AND & XOR masks for the cursor image into the cursor
67 // buffer. Note that a particular bit in these masks will have the
68 // following effect upon the corresponding cursor pixel:
72 // 1 0 Screen color (for transparency)
73 // 1 1 Reverse screen color to black or white
75 for (int row
= 0; row
< height
; row
++) {
76 for (int colByte
= 0; colByte
< width
/ 8; colByte
++) {
77 // Convert the 8 bit AND and XOR masks into a 16 bit mask containing
78 // pairs of the bits from the AND and XOR maks.
80 uint8 andBits
= *andMask
++;
81 uint8 xorBits
= *xorMask
++;
82 uint16 cursorBits
= 0;
84 for (int j
= 0; j
< 8; j
++) {
86 cursorBits
|= ((andBits
& 0x01) << 1);
87 cursorBits
|= (xorBits
& 0x01);
92 fbCursor
[row
* 8 + colByte
] = cursorBits
;
96 // Set the cursor colors which are white background and black foreground.