📄 s3c6400_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
S3C6400Disp::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("S3C6400Disp::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
S3C6400Disp::MovePointer(INT xPosition, INT yPosition)
{
DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("S3C6400Disp::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
S3C6400Disp::WaitForNotBusy(void)
{
//DISPDRV_MSG((_T("[DISPDRV] S3C6400Disp::WaitForNotBusy()\n\r")));
return;
}
int
S3C6400Disp::IsBusy(void)
{
//DISPDRV_MSG((_T("[DISPDRV] S3C6400Disp::IsBusy()\n\r")));
return 0;
}
void
S3C6400Disp::GetPhysicalVideoMemory(unsigned long *physicalMemoryBase, unsigned long *videoMemorySize)
{
DISPDRV_MSG((_T("[DISPDRV] S3C6400Disp::GetPhysicalVideoMemory()\n\r")));
*physicalMemoryBase = m_VideoMemoryPhysicalBase;
*videoMemorySize = m_VideoMemorySize;
}
void
S3C6400Disp::GetVirtualVideoMemory(unsigned long *virtualMemoryBase, unsigned long *videoMemorySize)
{
DISPDRV_MSG((_T("[DISPDRV] S3C6400Disp::GetVirtualVideoMemory()\n\r")));
*virtualMemoryBase = m_VideoMemoryVirtualBase;
*videoMemorySize = m_VideoMemorySize;
}
int
S3C6400Disp::InDisplay(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6400Disp::InDisplay\r\n")));
if (m_VideoPowerState == VideoPowerOff)
{
// To Avoid System Hang in SystemIdle State
// When Application access to DDraw API in SystemIdle State
// System Hangs... (Maybe Display Driver in VideoPowerOff state)
DISPDRV_INF((_T("[DISPDRV:INF] InDisplay() : Skipped in 'VideoPowerOff State'\n\r")));
return FALSE;
}
else
{
//EnterCriticalSection(&m_csDevice); // Not so Critical
if (DevGetVerticalStatus() == DISP_V_ACTIVE)
{
return TRUE;
}
else
{
return FALSE;
}
//LeaveCriticalSection(&m_csDevice); // Not so Critical
}
}
int
S3C6400Disp::InVBlank(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6400Disp::InVBlank\r\n")));
if (m_VideoPowerState == VideoPowerOff)
{
// To Avoid System Hang in SystemIdle State
// When Application access to DDraw API in SystemIdle State
// System Hangs... (Maybe Display Driver in VideoPowerOff state)
DISPDRV_INF((_T("[DISPDRV:INF] InVBlank() : Skipped in 'VideoPowerOff State'\n\r")));
return TRUE;
}
else
{
//EnterCriticalSection(&m_csDevice); // Not so Critical
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;
}
//LeaveCriticalSection(&m_csDevice); // Not so Critical
}
}
SCODE
S3C6400Disp::SetPalette(const PALETTEENTRY *source, USHORT firstEntry, USHORT numEntries)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C6400Disp::SetPalette\r\n")));
if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
{
return E_INVALIDARG;
}
return S_OK;
}
int
S3C6400Disp::GetGameXInfo(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = 0; // Default not supported
GXDeviceInfo * pgxoi;
DISPDRV_MSG((_T("[DISPDRV] ++S3C6400Disp::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_pPrimarySurface->Width();
pgxoi->cyHeight = 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;
}
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] --S3C6400Disp::GetGameXInfo()\n\r")));
return(RetVal);
}
int
S3C6400Disp::GetRawFrameBuffer(ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = ESC_SUCCESS; // Default not supported
RawFrameBufferInfo *pRawFB;
DISPDRV_MSG((_T("[DISPDRV] ++S3C6400Disp::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;
pRawFB->cxStride = sizeof(DWORD);
}
else
{
pRawFB->wFormat= RAW_FORMAT_565;
pRawFB->cxStride = sizeof(WORD);
}
pRawFB->cyStride = m_pPrimarySurface->Stride();
pRawFB->cxPixels = m_pPrimarySurface->Width();
pRawFB->cyPixels = m_pPrimarySurface->Height();
pRawFB->pFramePointer = (void *)m_pPrimarySurface->Buffer();
DISPDRV_INF((_T("[DISPDRV:INF] GetRawFrameBuffer() : Stride=%d, xPixel=%d, yPixel=%d, FramePointer=0x%08x\r\n"), pRawFB->cyStride, pRawFB->cxPixels, pRawFB->cyPixels, pRawFB->pFramePointer));
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] --S3C6400Disp::GetRawFrameBuffer()\n\r")));
return(RetVal);
}
ULONG
S3C6400Disp::DrvEscape(SURFOBJ * pso, ULONG iEsc, ULONG cjIn, void *pvIn, ULONG cjOut, void *pvOut)
{
ULONG Result = 0;
//DISPDRV_MSG((_T("[DISPDRV] --S3C6400Disp::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_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")));
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
return DISP_CHANGE_SUCCESSFUL;
}
else if (iEsc == DRVESC_SETSCREENROTATION)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : DRVESC_SETSCREENROTATION\n\r")));
if ((cjIn == DMDO_0) ||
(cjIn == DMDO_90) ||
(cjIn == DMDO_180) ||
(cjIn == DMDO_270) )
{
return DynRotate(cjIn);
}
return DISP_CHANGE_BADMODE;
}
else if (iEsc == GETGXINFO)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : GETGXINFO\n\r")));
return GetGameXInfo(iEsc, cjIn, pvIn, cjOut, pvOut);
}
else if (iEsc == GETRAWFRAMEBUFFER)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : GETRAWFRAMEBUFFER\n\r")));
return GetRawFrameBuffer(iEsc, cjIn, pvIn, cjOut, pvOut);
}
else if (iEsc == SETPOWERMANAGEMENT)
{
DISPDRV_MSG((_T("[DISPDRV] DrvEscape() : SETPOWERMANAGEMENT\n\r")));
if ((cjIn >= sizeof (VIDEO_POWER_MANAGEMENT)) && (pvIn != NULL))
{
PVIDEO_POWER_MANAGEMENT pvpm = (PVIDEO_POWER_MANAGEMENT)pvIn;
if (pvpm->Length >= sizeof (VIDEO_POWER_MANAGEMENT))
{
#if 1
switch((VIDEO_POWER_STATE)(pvpm->PowerState))
{
case VideoPowerOn:
DISPDRV_INF((_T("[DISPDRV] DrvEscape() : SETPOWERMANAGEMENT(VideoPowerOn)\n\r")));
break;
case VideoPowerStandBy:
DISPDRV_INF((_T("[DISPDRV] DrvEscape() : SETPOWERMANAGEMENT(VideoPowerStandBy)\n\r")));
break;
case VideoPowerSuspend:
DISPDRV_INF((_T("[DISPDRV] DrvEscape() : SETPOWERMANAGEMENT(VideoPowerSuspend)\n\r")));
break;
case VideoPowerOff:
DISPDRV_INF((_T("[DISPDRV] DrvEscape() : SETPOWERMANAGEMENT(VideoPowerOff)\n\r")));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -