📄 cursor.cpp
字号:
//-----------------------------------------------------------------------
//
// 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) 1999 Microsoft Corporation
//
// written by: ESG Solution Center Munich
//
// Module Name: cursor.cpp
//
// abstract: Windows CE display driver for C&T 69000
// cursor hardware acceleration functions
//
//-----------------------------------------------------------------------
#include "precomp.h"
//-----------------------------------------------------------------------
//
// CT69000::SetPointerShape
//
// GPE callback to set new cursor shape and turn off cursor.
// This function currently only supports windows type 1bpp cursors.
// Depending on the cursor size, a 32x32 or 64x64 mode will be choosen
//
//-----------------------------------------------------------------------
SCODE
CT69000::SetPointerShape( GPESurf *pMask, GPESurf *pColorSurf,
INT xHot, INT yHot, INT cX, INT cY)
{
PULONG pulCursorMemory;
INT x, y;
DEBUGMSG( CT69K_ZONE_CURSOR, (TEXT("CT69000::SetPointerShape\r\n")));
//
// this function assumes we always get called with 1bpp cursors
//
DisableCursor(); // ...
SetCursorColor( 0xffffff, 0); // default black & white
m_bCursorIs64x64=(cX>32 || cY>32);
if (m_bCursorIs64x64)
{
pulCursorMemory=(PULONG)(m_pCursorMemory+(cY*16));
y=64-cY;
} else
{
pulCursorMemory=(PULONG)(m_pCursorMemory+((cY>>1)*16));
y=16-(cY>>1);
}
// reset our and/xor plane in videomemory
while (y--)
{
*pulCursorMemory++=0xffffffff; // and plane
*pulCursorMemory++=0xffffffff;
*pulCursorMemory++=0; // xor plane
*pulCursorMemory++=0;
}
if (!(cY==0 || pMask==0))
{
INT iStride=pMask->Stride();
PULONG pulCursorANDMask; // pointer to AND/XOR plane in bitmap
PULONG pulCursorXORMask;
DEBUGMSG( CT69K_ZONE_CURSOR, (TEXT("set shape (%d,%d)\r\n"), cX, cY));
for (y=0;y<cY;y++)
{
x=0;
if (m_bCursorIs64x64)
pulCursorMemory=(PULONG)(m_pCursorMemory+(y*16));
else
pulCursorMemory=(PULONG)(m_pCursorMemory+((y>>1)*16)+(y&1)*4);
pulCursorANDMask=(PULONG)((PBYTE)pMask->Buffer()+(y*iStride));
pulCursorXORMask=(PULONG)((PBYTE)pulCursorANDMask+(cY*iStride));
while (x<cX)
{
if (x+32 > cX)
{
ULONG ulCursorANDMemory = 0xffffffff;
ULONG ulCursorXORMemory = 0;
INT cXTemp=cX;
ULONG ulMask=1;
while (x<cXTemp)
{
if ((*pulCursorANDMask & ulMask)==0)
{
ulCursorANDMemory &= ~ulMask;
}
if (*pulCursorXORMask & ulMask)
{
ulCursorXORMemory |= ulMask;
}
ulMask <<= 1;
x++;
}
pulCursorMemory[0] = ulCursorANDMemory;
pulCursorMemory[2] = ulCursorXORMemory;
} else
{
pulCursorMemory[0] = *pulCursorANDMask;
pulCursorMemory[2] = *pulCursorXORMask;
x+=32;
}
pulCursorMemory++; // go to next 32 bits in AND plane
pulCursorANDMask++;
pulCursorXORMask++;
}
if (m_bCursorIs64x64 &&
x<=32)
{
pulCursorMemory[0] = 0xffffffff;
pulCursorMemory[2] = 0;
}
}
}
// save for use in MovePointer
m_iHotX=xHot;
m_iHotY=yHot;
return S_OK;
}
//-----------------------------------------------------------------------
//
// CT69000::MovePointer
//
// GPE callback to move pointer to new position x,y and to make it visible
//
//-----------------------------------------------------------------------
SCODE
CT69000::MovePointer( INT x, INT y)
{
INT iNewX, iNewY;
static INT iLastX=-1;
if (x==-1)
{
DisableCursor();
return S_OK;
}
iNewX = x - m_iHotX;
if (iNewX<0) iNewX=0;
iNewY = y - m_iHotY;
if (iNewY<0) iNewY=0;
SetXR( CT69000_CURSOR1_XPOSITIONLOW, (UCHAR) iNewX);
SetXR( CT69000_CURSOR1_XPOSITIONHIGH,(UCHAR)(iNewX>>8));
SetXR( CT69000_CURSOR1_YPOSITIONLOW, (UCHAR) iNewY);
SetXR( CT69000_CURSOR1_YPOSITIONHIGH,(UCHAR)(iNewY>>8));
if (m_bCursorIs64x64)
EnableCursor64x64();
else
EnableCursor32x32();
#if CURSORDEBUG
//
// use cursor to turn on and off Blt acceleration by moving to (0,0)
//
if (x!=iLastX && x==0 && y<=100)
{
m_bBltEmulation=(m_bBltEmulation+1)%3;
RETAILMSG( CT69K_ZONE_ERROR,
(TEXT("Blt acceleration now (%d)\r\n"), m_bBltEmulation));
BYTE bColor[3]={ 0, 0x80, 0xff};
for (int i=0; i<100; i++)
{
memset( (LPBYTE)m_pPrimarySurface->Buffer()+
i*m_pPrimarySurface->Stride(),
bColor[m_bBltEmulation],
100);
}
}
#endif
#if DEBUG
//
// due to problems while in source level debugging,
// we can force a breakpoint in the dd by moving to the left margin
//
if (x!=iLastX && x==0 && y>=100)
{
DebugBreak();
}
#endif
iLastX=x;
return S_OK;
}
//-----------------------------------------------------------------------
//
// CT69000::SetCursorColor
//
// set foreground and background color of cursor in RAMDAC
//
//-----------------------------------------------------------------------
VOID
CT69000::SetCursorColor( ULONG ulForeground, ULONG ulBackground)
{
SetXRBit( CT69000_PPCONF0, 1); // select alternate cursor palette
if (m_bChip69030)
{
//
// chip bug! PC hangs if ports were accessed via memory port
//
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_WR_AD, (UCHAR)5);
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_DATA, (UCHAR) ulForeground);
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_DATA, (UCHAR)(ulForeground>>8));
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_DATA, (UCHAR)(ulForeground>>16));
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_WR_AD, (UCHAR)4);
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_DATA, (UCHAR) ulBackground);
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_DATA, (UCHAR)(ulBackground>>8));
WRITE_PORT_UCHAR( (PUCHAR) VGA_DAC_DATA, (UCHAR)(ulBackground>>16));
}
else
{
m_pCtrlRegister[CT69000_PALETTE_WRITEINDEX] = (UCHAR)5;
m_pCtrlRegister[CT69000_PALETTE_DATA] = (UCHAR) ulForeground;
m_pCtrlRegister[CT69000_PALETTE_DATA] = (UCHAR)(ulForeground>>8);
m_pCtrlRegister[CT69000_PALETTE_DATA] = (UCHAR)(ulForeground>>16);
m_pCtrlRegister[CT69000_PALETTE_WRITEINDEX] = (UCHAR)4;
m_pCtrlRegister[CT69000_PALETTE_DATA] = (UCHAR) ulBackground;
m_pCtrlRegister[CT69000_PALETTE_DATA] = (UCHAR)(ulBackground>>8);
m_pCtrlRegister[CT69000_PALETTE_DATA] = (UCHAR)(ulBackground>>16);
}
ClearXRBit( CT69000_PPCONF0, 1); // select standard palette
}
//-----------------------------------------------------------------------
//
// CT69000::DisableCursor
//
// turn off cursor
//
//-----------------------------------------------------------------------
VOID
CT69000::DisableCursor()
{
ClearXRBit( CT69000_PPCONF0, 0x10);
SetXR( CT69000_CURSOR1_CONTROL, 0);
}
//-----------------------------------------------------------------------
//
// CT69000::EnableCursor32x32
//
// set cursor to 32x32 mode
//
//-----------------------------------------------------------------------
VOID
CT69000::EnableCursor32x32()
{
SetXR( CT69000_CURSOR1_CONTROL, 0x11);
SetXRBit( CT69000_PPCONF0, 0x10);
}
//-----------------------------------------------------------------------
//
// CT69000::EnableCursor64x64
//
// set cursor to 64x64 mode
//
//-----------------------------------------------------------------------
VOID
CT69000::EnableCursor64x64()
{
SetXR( CT69000_CURSOR1_CONTROL, 0x15);
SetXRBit( CT69000_PPCONF0, 0x10);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -