cursor.cpp
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C++ 代码 · 共 196 行
CPP
196 行
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995, 1996, 1997, 1998 Microsoft Corporation
Module Name:
Abstract:
MGDI driver (for IGS2010)
Functions:
Notes:
--*/
#include "precomp.h"
#define INITIAL_MASK 0x00008000
// disable cursor macro
#define DISABLE_CURSOR() (reg_CURSOR1_CONTROL = reg_CURSOR1_CONTROL & 0xFE)
// enable cursor
#define C64x64 0x15
#define ENABLE_CURSOR(c) {(reg_CURSOR1_CONTROL = reg_CURSOR1_CONTROL | (1));}
//
// SetPointerShape -
// inputs:
// outputs: none
//
SCODE IGS2010::SetPointerShape(
GPESurf *pMask,
GPESurf *pColorSurf,
int xHot,
int yHot,
int cx,
int cy )
{
DEBUGMSG( GPE_ZONE_CURSOR, (TEXT("IGS2010::SetPointerShape\r\n")));
ULONG shapeRow[4]; // buffer to contain AND word, XOR word, AND word...
int count, row, col;
ULONG *pAndOrDst;
ULONG bitMask;
int x;
ULONG *pWord;
DISABLE_CURSOR(); // disable cursor
SetCursorColors( 0x00ffffff, 0x00000000 ); // Set colors to black & white
// set the cursor pattern/offset
reg_CURSOR1_XPRESET = 0x00;
reg_CURSOR1_YPRESET = 0x00;
// assume we mapped into the first 1024 bytes of onboard RAM
reg_CURSOR1_ADDRLOW = 0;
reg_CURSOR1_ADDRHI = 0;
// assume cursor is located at zero entry PDL//??
pWord = (unsigned long *)(&m_pLAW[0*1024]);
// initialize entire 64 x 64 shape to transparent
m_nXHot = xHot;
m_nYHot = yHot; // we rely on MovePointer being called after this
for( row=0; row<64; row++ ) {
DEBUGMSG( GPE_ZONE_CURSOR, (TEXT("Setting pointer shape row %d\r\n"),row));
// Clear the row
for( count=0; count < 4; count++ ) {
shapeRow[count] = 0xAAAAAAAA;
}
if( row < cy ) { // active bits in the cursor shape passed in
// Write available bits into shapeRow
pAndOrDst = shapeRow;
bitMask = INITIAL_MASK;
for( col=0; col<cx; col++ ) {
if( !((((unsigned char *)pMask->Buffer())+row*pMask->Stride())[col/8] & ( 1 << ((col%8)) )) ) {
*pAndOrDst ^= bitMask;
}
bitMask >>= 1;
if( bitMask == INITIAL_MASK) {
pAndOrDst += 1;
}
if( !bitMask ) {
bitMask = 0x80000000;
}
if( ((((unsigned char *)pMask->Buffer())+(cy+row)*pMask->Stride())[col/8] & ( 1 << ((col%8)) )) ) {
*pAndOrDst ^= bitMask;
}
bitMask >>= 1;
if( bitMask == INITIAL_MASK) {
pAndOrDst += 1;
}
if( !bitMask ) {
bitMask = 0x80000000;
}
}
}
for( x=0; x<4; x++ ) {
*pWord++ = shapeRow[x];
}
}
DEBUGMSG( GPE_ZONE_CURSOR, (TEXT("Leaving IGS2010::SetPointerShape\r\n")));
return S_OK;
}
//
// MovePointer -
// inputs:
// outputs: none
//
SCODE IGS2010::MovePointer(
int x,
int y )
{
DEBUGMSG(GPE_ZONE_CURSOR,
(TEXT("IGS2010::MovePointer Moving cursor to %d,%d\r\n"),
x, y ));
int newx = x - m_nXHot; // Hot spot is currentl 32,32
int newy = y - m_nYHot;
int dx = 0;
int dy = 0;
if( newx < 0 ) {
dx = -newx;
newx = 0;
}
if( newy < 0 ) {
dy = -newy;
newy = 0;
}
if( x == -1 ) { // disable the cursor
DISABLE_CURSOR();
}
// set the cursor origin
reg_CURSOR1_XLOW = newx & 0x00FF;;
reg_CURSOR1_XHI = newx >> 8;
reg_CURSOR1_YLOW = newy & 0x00FF;;
reg_CURSOR1_YHI = newy >> 8;
if( x != -1 ) {
ENABLE_CURSOR(C64x64);
}
DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("Leaving IGS2010::MovePointer\r\n")));
return S_OK;
}
//
// SetCursorColors -
// inputs:
// outputs: none
//
void IGS2010::SetCursorColors(
unsigned long foreground, // 0x00bbggrr format
unsigned long background )
{
DEBUGMSG (GPE_ZONE_CURSOR, (TEXT("IGS2010::SetCursorColors\r\n")));
DISABLE_CURSOR();
// write cursor colors in RAMDAC
reg_CURSOR1_CONTROL = 0x06;
reg_DAC_WR_AD = (unsigned char)(1);
reg_DAC_DATA = (unsigned char)foreground;
reg_DAC_DATA = (unsigned char)(foreground>>8);
reg_DAC_DATA = (unsigned char)(foreground>>16);
reg_DAC_WR_AD = (unsigned char)(0);
reg_DAC_DATA = (unsigned char)background;
reg_DAC_DATA = (unsigned char)(background>>8);
reg_DAC_DATA = (unsigned char)(background>>16);
DEBUGMSG (GPE_ZONE_CURSOR, (TEXT("Leaving IGS2010::SetCursorColors\r\n")));
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?