📄 s3c6410_disp.cpp
字号:
ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_pMode->Bpp >> 3))];
for (x = m_CursorRect.left; x < m_CursorRect.right; x++)
{
// clip to displayable screen area (left/right)
if (x < 0)
{
continue;
}
if (x >= m_nScreenWidthSave)
{
break;
}
ptrLine[x * (m_pMode->Bpp >> 3)] = cbsLine[(x - m_CursorRect.left) * (m_pMode->Bpp >> 3)];
if (m_pMode->Bpp > 8)
{
ptrLine[x * (m_pMode->Bpp >> 3) + 1] = cbsLine[(x - m_CursorRect.left) * (m_pMode->Bpp >> 3) + 1];
if (m_pMode->Bpp > 16)
{
ptrLine[x * (m_pMode->Bpp >> 3) + 2] = cbsLine[(x - m_CursorRect.left) * (m_pMode->Bpp >> 3) + 2];
}
}
}
}
m_CursorRect = rSave;
m_CursorVisible = FALSE;
}
}
SCODE
S3C6410Disp::SetPointerShape(GPESurf *pMask, GPESurf *pColorSurf, INT xHot, INT yHot, INT cX, INT cY)
{
UCHAR *andPtr; // input pointer
UCHAR *xorPtr; // input pointer
UCHAR *andLine; // output pointer
UCHAR *xorLine; // output pointer
char bAnd;
char bXor;
int row;
int col;
int i;
int bitMask;
DEBUGMSG(GPE_ZONE_CURSOR,(TEXT("S3C6410Disp::SetPointerShape(0x%X, 0x%X, %d, %d, %d, %d)\r\n"),pMask, pColorSurf, xHot, yHot, cX, cY));
// turn current cursor off
CursorOff();
// release memory associated with old cursor
if (!pMask) // do we have a new cursor shape
{
m_CursorDisabled = TRUE; // no, so tag as disabled
}
else
{
m_CursorDisabled = FALSE; // yes, so tag as not disabled
// store size and hotspot for new cursor
m_CursorSize.x = cX;
m_CursorSize.y = cY;
m_CursorHotspot.x = xHot;
m_CursorHotspot.y = yHot;
andPtr = (UCHAR*)pMask->Buffer();
xorPtr = (UCHAR*)pMask->Buffer() + (cY * pMask->Stride());
// store OR and AND mask for new cursor
for (row = 0; row < cY; row++)
{
andLine = &m_CursorAndShape[cX * row];
xorLine = &m_CursorXorShape[cX * row];
for (col = 0; col < cX / 8; col++)
{
bAnd = andPtr[row * pMask->Stride() + col];
bXor = xorPtr[row * pMask->Stride() + col];
for (bitMask = 0x0080, i = 0; i < 8; bitMask >>= 1, i++)
{
andLine[(col * 8) + i] = bAnd & bitMask ? 0xFF : 0x00;
xorLine[(col * 8) + i] = bXor & bitMask ? 0xFF : 0x00;
}
}
}
}
return S_OK;
}
SCODE
S3C6410Disp::MovePointer(INT xPosition, INT yPosition)
{
DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("S3C6410Disp::MovePointer(%d, %d)\r\n"), xPosition, yPosition));
CursorOff();
if (xPosition != -1 || yPosition != -1)
{
// compute new cursor rect
m_CursorRect.left = xPosition - m_CursorHotspot.x;
m_CursorRect.right = m_CursorRect.left + m_CursorSize.x;
m_CursorRect.top = yPosition - m_CursorHotspot.y;
m_CursorRect.bottom = m_CursorRect.top + m_CursorSize.y;
CursorOn();
}
return S_OK;
}
void
S3C6410Disp::WaitForNotBusy(void)
{
//DISPDRV_MSG((_T("[DISPDRV] S3C6410Disp::WaitForNotBusy()\n\r")));
return;
}
int
S3C6410Disp::IsBusy(void)
{
//DISPDRV_MSG((_T("[DISPDRV] S3C6410Disp::IsBusy()\n\r")));
return 0;
}
void
S3C6410Disp::GetPhysicalVideoMemory(unsigned long *physicalMemoryBase, unsigned long *videoMemorySize)
{
DISPDRV_MSG((_T("[DISPDRV] S3C6410Disp::GetPhysicalVideoMemory()\n\r")));
*physicalMemoryBase = m_VideoMemoryPhysicalBase;
*videoMemorySize = m_VideoMemorySize;
}
void
S3C6410Disp::GetVirtualVideoMemory(unsigned long *virtualMemoryBase, unsigned long *videoMemorySize)
{
DISPDRV_MSG((_T("[DISPDRV] S3C6410Disp::GetVirtualVideoMemory()\n\r")));
*virtualMemoryBase = m_VideoMemoryVirtualBase;
*videoMemorySize = m_VideoMemorySize;
}
int
S3C6410Disp::InDisplay(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6410Disp::InDisplay\r\n")));
if (DevGetVerticalStatus() == DISP_V_ACTIVE)
{
return TRUE;
}
else
{
return FALSE;
}
}
int
S3C6410Disp::InVBlank(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6410Disp::InVBlank\r\n")));
switch(DevGetVerticalStatus())
{
case DISP_V_VSYNC:
case DISP_V_BACKPORCH:
return TRUE;
break;
case DISP_V_ACTIVE:
case DISP_V_FRONTPORCH:
default:
return FALSE;
break;
}
}
SCODE
S3C6410Disp::SetPalette(const PALETTEENTRY *source, USHORT firstEntry, USHORT numEntries)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6410Disp::SetPalette\r\n")));
if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
{
return E_INVALIDARG;
}
return S_OK;
}
int
S3C6410Disp::GetGameXInfo(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = 0; // Default not supported
GXDeviceInfo * pgxoi;
DISPDRV_MSG((_T("[DISPDRV] ++S3C6410Disp::GetGameXInfo()\n\r")));
// GAPI only support P8, RGB444, RGB555, RGB565, and RGB888
if ((cjOut >= sizeof(GXDeviceInfo)) && (pvOut != NULL)
&& (m_pMode->Bpp == 8 || m_pMode->Bpp == 16 || m_pMode->Bpp == 24 || m_pMode->Bpp == 32))
{
if (((GXDeviceInfo *) pvOut)->idVersion == kidVersion100)
{
pgxoi = (GXDeviceInfo *) pvOut;
pgxoi->idVersion = kidVersion100;
pgxoi->pvFrameBuffer = (void *)m_pPrimarySurface->Buffer();
pgxoi->cbStride = m_pPrimarySurface->Stride();
pgxoi->cxWidth = m_nScreenWidthSave;//m_pPrimarySurface->Width();
pgxoi->cyHeight = m_nScreenHeightSave;//m_pPrimarySurface->Height();
if (m_pMode->Bpp == 8)
{
pgxoi->cBPP = 8;
pgxoi->ffFormat = kfPalette;
}
else if (m_pMode->Bpp == 16)
{
pgxoi->cBPP = 16;
pgxoi->ffFormat= kfDirect | kfDirect565;
}
else if (m_pMode->Bpp == 24)
{
pgxoi->cBPP = 24;
pgxoi->ffFormat = kfDirect | kfDirect888;
}
else
{
pgxoi->cBPP = 32;
pgxoi->ffFormat = kfDirect | kfDirect888;
}
if (m_iRotate == DMDO_90 || m_iRotate == DMDO_270 )
pgxoi->ffFormat |= kfLandscape; // Rotated
pgxoi->vkButtonUpPortrait = VK_UP;
pgxoi->vkButtonUpLandscape = VK_LEFT;
pgxoi->vkButtonDownPortrait = VK_DOWN;
pgxoi->vkButtonDownLandscape = VK_RIGHT;
pgxoi->vkButtonLeftPortrait = VK_LEFT;
pgxoi->vkButtonLeftLandscape = VK_DOWN;
pgxoi->vkButtonRightPortrait = VK_RIGHT;
pgxoi->vkButtonRightLandscape = VK_UP;
pgxoi->vkButtonAPortrait = 0xC3; // far right button
pgxoi->vkButtonALandscape = 0xC5; // record button on side
pgxoi->vkButtonBPortrait = 0xC4; // second from right button
pgxoi->vkButtonBLandscape = 0xC1;
pgxoi->vkButtonCPortrait = 0xC5; // far left button
pgxoi->vkButtonCLandscape = 0xC2; // far left button
pgxoi->vkButtonStartPortrait = 134; // action button
pgxoi->vkButtonStartLandscape = 134;
pgxoi->ptButtonUp.x = 120;
pgxoi->ptButtonUp.y = 330;
pgxoi->ptButtonDown.x = 120;
pgxoi->ptButtonDown.y = 390;
pgxoi->ptButtonLeft.x = 90;
pgxoi->ptButtonLeft.y = 360;
pgxoi->ptButtonRight.x = 150;
pgxoi->ptButtonRight.y = 360;
pgxoi->ptButtonA.x = 180;
pgxoi->ptButtonA.y = 330;
pgxoi->ptButtonB.x = 210;
pgxoi->ptButtonB.y = 345;
pgxoi->ptButtonC.x = -50;
pgxoi->ptButtonC.y = 0;
pgxoi->ptButtonStart.x = 120;
pgxoi->ptButtonStart.y = 360;
pgxoi->pvReserved1 = (void *) 0;
pgxoi->pvReserved2 = (void *) 0;
RetVal = ESC_SUCCESS;
}
else
{
DISPDRV_ERR((_T("[DISPDRV:ERR] GetGameXInfo() : Invalid Parameter\n\r")));
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = ESC_FAILED;
}
}
else
{
DISPDRV_ERR((_T("[DISPDRV:ERR] GetGameXInfo() : Invalid Parameter\n\r")));
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = ESC_FAILED;
}
DISPDRV_MSG((_T("[DISPDRV] --S3C6410Disp::GetGameXInfo()\n\r")));
return(RetVal);
}
int
S3C6410Disp::GetRawFrameBuffer(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = ESC_SUCCESS; // Default not supported
RawFrameBufferInfo *pRawFB;
DISPDRV_MSG((_T("[DISPDRV] ++S3C6410Disp::GetRawFrameBuffer()\n\r")));
if ((cjOut >= sizeof(RawFrameBufferInfo)) && (pvOut != NULL))
{
pRawFB = (RawFrameBufferInfo *)pvOut;
pRawFB->wBPP = m_pMode->Bpp;
if (pRawFB->wBPP == gpe32Bpp)
{
pRawFB->wFormat= RAW_FORMAT_OTHER;
}
else
{
pRawFB->wFormat= RAW_FORMAT_565;
}
#if (LCD_TYPE == LCD_TYPE_LANDSCAPE)
// Application knows DMDO_0 means portrait internally DMDO_270:
// Now we return parameters for RAWFRAMEBUFFER,
// Logical Physical
// DMDO_0 DMDO_270
// DMDO_90 DMDO_0
// DMDO_180 DMDO_90
// DMDO_270 DMDO_180
// Set (Logical -> Physical) m_iRotate has Physical Values.
// Get (Physical -> Logical)
// case DMDO_0: // Logically Portrait DMDO_0, Physically Landscape DMDO_270
if (pRawFB->wBPP == gpe32Bpp)
{
pRawFB->cyStride = -(int) sizeof(DWORD);
}
else
{
pRawFB->cyStride = -(int) sizeof(WORD);
}
pRawFB->cxStride = m_pPrimarySurface->Stride();
pRawFB->pFramePointer = (void *)((DWORD)m_pPrimarySurface->Buffer() + m_pPrimarySurface->Width() * ABS(pRawFB->cyStride));
pRawFB->cxPixels = m_nScreenHeightSave;
pRawFB->cyPixels = m_nScreenWidthSave;
#elif (LCD_TYPE == LCD_TYPE_PORTRAIT)
if (pRawFB->wBPP == gpe32Bpp)
{
pRawFB->cxStride = sizeof(DWORD);
}
else
{
pRawFB->cxStride = sizeof(WORD);
}
pRawFB->cyStride = m_pPrimarySurface->Stride();
pRawFB->pFramePointer = (void *)m_pPrimarySurface->Buffer();
pRawFB->cxPixels = m_nScreenWidthSave;
pRawFB->cyPixels = m_nScreenHeightSave;
#else
#error LCD_TYPE_UNDEFINED_ERROR
#endif
RETAILMSG(TRUE, (_T("[DISPDRV:INF] GetRawFrameBuffer() : CxStride=%d, cyStride=%d, xPixel=%d, yPixel=%d, FramePointer=0x%08x, Rot:%d\r\n"), pRawFB->cxStride, pRawFB->cyStride, pRawFB->cxPixels, pRawFB->cyPixels, pRawFB->pFramePointer, m_iRotate));
RetVal = ESC_SUCCESS;
}
else
{
DISPDRV_ERR((_T("[DISPDRV:ERR] GetRawFrameBuffer() : Invalid Parameter\n\r")));
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = ESC_FAILED;
}
DISPDRV_MSG((_T("[DISPDRV] --S3C6410Disp::GetRawFrameBuffer()\n\r")));
return(RetVal);
}
ULONG
S3C6410Disp::DrvEscape(SURFOBJ * pso, ULONG iEsc, ULONG cjIn, void *pvIn, ULONG cjOut, void *pvOut)
{
ULONG Result = 0;
//DISPDRV_MSG((_T("[DISPDRV] --S3C6410Disp::DrvEscape(0x%08x)\n\r"), iEsc));
if (iEsc == QUERYESCSUPPORT)
{
if ((*(DWORD*)pvIn == GETGXINFO)
|| (*(DWORD*)pvIn == GETRAWFRAMEBUFFER)
|| (*(DWORD*)pvIn == DRVESC_GETSCREENROTATION)
|| (*(DWORD*)pvIn == DRVESC_SETSCREENROTATION)
|| (*(DWORD*)pvIn == SETPOWERMANAGEMENT)
|| (*(DWORD*)pvIn == GETPOWERMANAGEMENT)
|| (*(DWORD*)pvIn == IOCTL_POWER_CAPABILITIES)
|| (*(DWORD*)pvIn == IOCTL_POWER_QUERY)
|| (*(DWORD*)pvIn == IOCTL_POWER_SET)
|| (*(DWORD*)pvIn == IOCTL_POWER_GET)
|| (*(DWORD*)pvIn == DRVESC_OUTPUT_RGB)
|| (*(DWORD*)pvIn == DRVESC_OUTPUT_TV)
|| (*(DWORD*)pvIn == DRVESC_OUTPUT_SWITCH)
|| (*(DWORD*)pvIn == DRVESC_TV_DMA_DISABLE)
|| (*(DWORD*)pvIn == DRVESC_TV_DMA_PRIMARY)
|| (*(DWORD*)pvIn == DRVESC_TV_DMA_OVERLAY)
|| (*(DWORD*)pvIn == DRVESC_G2D_ACCEL)
|| (*(DWORD*)pvIn == DRVESC_G2D_PROFILE))
{
// The escape is supported.
return 1;
}
else
{
// The escape isn't supported.
#if DO_DISPPERF
return DispPerfQueryEsc(*(DWORD*)pvIn);;
#else
return 0;
#endif
}
}
else if (iEsc == DRVESC_GETSCREENROTATION)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : DRVESC_GETSCREENROTATION\n\r")));
#if(LCD_TYPE==LCD_TYPE_LANDSCAPE)
int iMappedRotate = DMDO_90; // default
switch (m_iRotate)
{
case DMDO_0: iMappedRotate = DMDO_90; break;
case DMDO_90: iMappedRotate = DMDO_180; break;
case DMDO_180: iMappedRotate = DMDO_270; break;
case DMDO_270: iMappedRotate = DMDO_0; break;
}
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)iMappedRotate);
return DISP_CHANGE_SUCCESSFUL;
#elif (LCD_TYPE==LCD_TYPE_PORTRAIT)
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
return DISP_CHANGE_SUCCESSFUL;
#else
#error LCD_TYPE_UNDEFINED_ERROR
#endif
}
else if (iEsc == DRVESC_SETSCREENROTATION)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : DRVESC_SETSCREENROTATION\n\r")));
#if(LCD_TYPE==LCD_TYPE_LANDSCAPE)
switch (cjIn)
{
case DMDO_0: return DynRotate(DMDO_270);
case DMDO_90: return DynRotate(DMDO_0);
case DMDO_180: return DynRotate(DMDO_90);
case DMDO_270: return DynRotate(DMDO_180);
}
return DISP_CHANGE_BADMODE;
#elif (LCD_TYPE==LCD_TYPE_PORTRAIT)
if ((cjIn == DMDO_0) || (cjIn == DMDO_90) || (cjIn == DMDO_180) || (cjIn == DMDO_270))
{
return DynRotate(cjIn);
}
return DISP_CHANGE_BADMODE;
#else
#error LCD_TYPE_UNDEFINED_ERROR
#endif
}
else if (iEsc == GETGXINFO)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : GETGXINFO\n\r")));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -