📄 cursor.cpp
字号:
/*
* $Workfile: CURSOR.CPP $
* $Revision: 8 $
* $Date: 4/07/00 8:48a $
* $Modtime: 4/07/00 8:39a $
* $Author: Sarma $
*
* Copyright (c) 1998 National Semiconductor Corporation.
* All Rights Reserved.
*
* This software is the confidential and proprietary information of National
* Semiconductor Corporation. ("Confidential Information").
* You shall not disclose such Confidential Information and shall use it only
* in accordance with the terms of the license agreement you entered into
* with National Semiconductor Corporation.
* This code is supplied as is.
*
*/
/*
*$Log: /CE/Platform/Nsc/Drivers/Video/gxvideo/base/CURSOR.CPP $
*
* 8 4/07/00 8:48a Sarma
* Removed Cyrix Corporation from the legal/confidentail information.
*
* 7 4/06/00 4:12p Sarma
* gfxregister init not required and done in config.cpp
*
* 6 4/06/00 4:09p Sarma
* Removed personal messages.
*
* 5 4/06/00 10:35a Hari
* Removed Debug messages.
*
* 4 3/29/00 9:09a Sarma
* Added durango interface for rendering.
*
* 3 12/01/98 1:07p Sarma
* check the cursor w.r.t the current resolution set than looking always
* at 0.
*
* 2 11/12/98 3:24p Sarma
* Added Confidential copyright to files with VSS keywords for
* log/history.
*$History: CURSOR.CPP $
*
* ***************** Version 8 *****************
* User: Sarma Date: 4/07/00 Time: 8:48a
* Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
* Removed Cyrix Corporation from the legal/confidentail information.
*
* ***************** Version 7 *****************
* User: Sarma Date: 4/06/00 Time: 4:12p
* Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
* gfxregister init not required and done in config.cpp
*
* ***************** Version 6 *****************
* User: Sarma Date: 4/06/00 Time: 4:09p
* Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
* Removed personal messages.
*
* ***************** Version 5 *****************
* User: Hari Date: 4/06/00 Time: 10:35a
* Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
* Removed Debug messages.
*
* ***************** Version 4 *****************
* User: Sarma Date: 3/29/00 Time: 9:09a
* Updated in $/CE/Platform/Nsc/Drivers/Video/gxvideo/base
* Added durango interface for rendering.
*
* ***************** Version 3 *****************
* User: Sarma Date: 12/01/98 Time: 1:07p
* Updated in $/wince/v2.1/gxvideo
* check the cursor w.r.t the current resolution set than looking always
* at 0.
*
* ***************** Version 2 *****************
* User: Sarma Date: 11/12/98 Time: 3:24p
* Updated in $/wince/v2.1/gxvideo
* Added Confidential copyright to files with VSS keywords for
* log/history.
*/
#include "precomp.h"
#include "gpevga.h"
#ifdef DURANGO
#include "gfx_rtns.h"
#endif
SCODE GxVideo::SetPointerShape(
GPESurf *pMask,
GPESurf *pColorSurf,
int xHot,
int yHot,
int cx,
int cy )
{
int row, col;
unsigned long *pDWORD;
//Get any one as cursor pointer is the same
DISPLAYMODE *DpyParams = GetDisplayParams(m_resolution);
SetCursorColors( 0x000000FF ); // Set colors to black & white
pDWORD = (unsigned long *)(m_pLAW+DpyParams->curs_offset);
//CHECK IF WE GOT VALID CURSOR POINTER
if( !pMask )
{
// DEBUGMSG( GPE_ZONE_CURSOR, (TEXT("Turning Off cursor shape\n")));
for( row=0; row<64; row++ ) // Turn off cursor
{
*pDWORD++ = 0xFFFF0000; //Clear the ANDWord and XORWord
*pDWORD++ = 0xFFFF0000; //Clear the ANDWord and XORWord
}
}
else
{
//TAKE THE BYTE POINTER TO THE CURSOR MEMORY
unsigned char *pDest = (unsigned char *)pDWORD;
unsigned char *pSrcAnd, *pSrcXor;
unsigned long AndRowStride, XorRowStride;
unsigned char *CursorData;
unsigned long stride;
int cxBy16;
DEBUGMSG( 0, (TEXT("Setting cursor - transparent\n")));
CursorData = (unsigned char *)pMask->Buffer();
stride = pMask->Stride();
m_nXHot = xHot;
m_nYHot = yHot; // we rely on MovePointer being called after this
cxBy16 = cx >>4;
DEBUGMSG( 0, (TEXT("Stride = 0x%08x\n"),pMask->Stride()));
DEBUGMSG( 0, (TEXT("cx = 0x%08x, cy = 0x%08x %d %d\n"),cx,cy,xHot,yHot));
// FOR GXM CURSOR EACH PATTERN IS A 32x32 PIXEL ARRAY OF TWO BIT CODES.
// THE CODES AREA COMBIMNATION OF AND MASK AND XOR MASK FOR A PARTICULAR PIXEL.
for( row=0; row<32; row++ )
{
AndRowStride = row * stride;
XorRowStride = (cy+row) * stride;
if( row < cy )
{
// Write available bits into shapeRow
// THE CURSOER IN GXM HAS 16 BIT XOR & AND IN A DWORD, WHERE IN
// AND MASK FOR 16 PIXELS IN THE UPPER WORD AND THE XOR MASK 16
// PIXELS IN LOWER WORD. DWORD'S ARE ARRANGED WITH THE LEFTMOST
// PIXEL BLOCK BEING THE LEAST SIGNIFICANT AND THE RIGHTMOST PIXEL
// BLOCK BEING MOST SIGNIFICANT. PIXELS WITHIN WORDS ARE ARRANGED
// WITH THE LEFTMOST PIXELS BEING MOST SIGNIFICANT AND THE RIGHTMOST
// PIXELS BEING LEAST SIGNIFICANT.
//Init the AND & XOR pointers to the start byte of the data
pSrcAnd = CursorData + AndRowStride;
pSrcXor = CursorData + XorRowStride;
for( col=0; col<cxBy16; col++ ){
//
// The GX requires two bytes of XOR mask (MSB first)
// followed by two bytes of AND mask.
//
DEBUGMSG( 0, (TEXT("| %X %X, %X %X "),
*(pSrcXor+1),
*pSrcXor,
*(pSrcAnd+1),
*pSrcAnd));
*pDest++ = *(pSrcXor+1);
*pDest++ = *pSrcXor;
*pDest++ = *(pSrcAnd+1);
*pDest++ = *pSrcAnd;
//Increment the And & XOR pointer for next word
pSrcXor += 2;
pSrcAnd += 2;
}
DEBUGMSG( 0, (TEXT("|\n")));
}
}
}
DEBUGMSG( 0, (TEXT("Cursor shape set done\n")));
return S_OK;
}
SCODE GxVideo::MovePointer(
int x,
int y )
{
DEBUGMSG(GPE_ZONE_HW,(TEXT("Moving cursor to %d,%d\r\n"), x, y ));
//DEBUGMSG(1,(TEXT("x = 0x%08x, y = 0x%08x\r\n"), x, y));
int newx = x - m_nXHot; // Hot spot is currentl 32,32
int newy = y - m_nYHot;
//DEBUGMSG(1,(TEXT("newx = 0x%08x, newy = 0x%08x\r\n"), newx, newy));
int dx = 0;
int dy = 0;
if( newx < 0 )
{
dx = -newx;
newx = 0;
}
if( newy < 0 )
{
dy = -newy;
newy = 0;
}
//DEBUGMSG(1,(TEXT("dx = 0x%08x, dy = 0x%08x\r\n"), dx, dy));
unsigned long tmp;
Unlock();
tmp = READ_REG32(GXregisters, DC_CURSOR_X);
tmp &= 0xffff0000;
tmp |= ((dx << 11) & 0x0000f800);
tmp |= (newx & 0x000007fff);
WRITE_REG32(GXregisters, DC_CURSOR_X, tmp);
//DEBUGMSG(1,(TEXT("DC_CURSOR_X = 0x%08x\r\n"), tmp));
tmp = READ_REG32(GXregisters, DC_CURSOR_Y);
tmp &= 0xffff0000;
tmp |= ((dy << 11) & 0x0000f800);
tmp |= (newy & 0x000006fff);
WRITE_REG32(GXregisters, DC_CURSOR_Y, tmp);
//DEBUGMSG(1,(TEXT("DC_CURSOR_Y = 0x%08x\r\n"), tmp));
Lock();
return S_OK;
}
void GxVideo::SetCursorColors(
unsigned long color )
{
#ifdef DURANGO
gfx_set_cursor_colors(0, 0xffffffff);
#else
Unlock();
WRITE_REG32(GXregisters, DC_PAL_ADDRESS, 0x101);
WRITE_REG32(GXregisters, DC_PAL_DATA, 0x3ffff);
#if 0
{
unsigned long addr, data;
addr = 0x101;
WRITE_REG32(GXregisters, DC_PAL_ADDRESS, addr );
DEBUGMSG( 0, ( TEXT("PAL ADDR = %08X\r\n" ), addr ) );
data = READ_REG32(GXregisters, DC_PAL_DATA );
DEBUGMSG( 0, ( TEXT("PAL DATA = %08X\r\n" ), data ) );
}
#endif
WRITE_REG32(GXregisters, DC_PAL_ADDRESS, 0x100);
WRITE_REG32(GXregisters, DC_PAL_DATA, 0);
Lock();
#endif
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -