📄 s3c2443disp.cpp
字号:
}
// do emulated line
retval = EmulatedLine (lineParameters);
// se if cursor was forced off because of overlap with line bouneds and turn back on
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
return retval;
}
SCODE S3C2443DISP::Line(GPELineParms *lineParameters, EGPEPhase phase)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::Line\r\n")));
if (phase == gpeSingle || phase == gpePrepare)
{
#ifdef DO_DISPPERF
DispPerfStart(ROP_LINE);
#endif
if ((lineParameters->pDst != m_pPrimarySurface))
{
lineParameters->pLine = EmulatedLine;
}
else
{
lineParameters->pLine = (SCODE (GPE::*)(struct GPELineParms *)) WrappedEmulatedLine;
}
}
else if (phase == gpeComplete)
{
#ifdef DO_DISPPERF
DispPerfEnd(0);
#endif
}
return S_OK;
}
SCODE S3C2443DISP::BltPrepare(GPEBltParms *blitParameters)
{
RECTL rectl;
int iSwapTmp;
BOOL bRotate = FALSE;
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::BltPrepare\r\n")));
#ifdef DO_DISPPERF
DispPerfStart(blitParameters->rop4);
#endif
// default to base EmulatedBlt routine
blitParameters->pBlt = EmulatedBlt;
// see if we need to deal with cursor
// check for destination overlap with cursor and turn off cursor if overlaps
if (blitParameters->pDst == m_pPrimarySurface) // only care if dest is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (blitParameters->prclDst != NULL) // make sure there is a valid prclDst
{
rectl = *blitParameters->prclDst; // if so, use it
// There is no guarantee of a well ordered rect in blitParamters
// due to flipping and mirroring.
if(rectl.top > rectl.bottom)
{
iSwapTmp = rectl.top;
rectl.top = rectl.bottom;
rectl.bottom = iSwapTmp;
}
if(rectl.left > rectl.right)
{
iSwapTmp = rectl.left;
rectl.left = rectl.right;
rectl.right = iSwapTmp;
}
}
else
{
rectl = m_CursorRect; // if not, use the Cursor rect - this forces the cursor to be turned off in this case
}
if (m_CursorRect.top <= rectl.bottom && m_CursorRect.bottom >= rectl.top &&
m_CursorRect.left <= rectl.right && m_CursorRect.right >= rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
if (m_iRotate )
{
bRotate = TRUE;
}
}
// check for source overlap with cursor and turn off cursor if overlaps
if (blitParameters->pSrc == m_pPrimarySurface) // only care if source is main display surface
{
if (m_CursorVisible && !m_CursorDisabled)
{
if (blitParameters->prclSrc != NULL) // make sure there is a valid prclSrc
{
rectl = *blitParameters->prclSrc; // if so, use it
}
else
{
rectl = m_CursorRect; // if not, use the CUrsor rect - this forces the cursor to be turned off in this case
}
if (m_CursorRect.top < rectl.bottom && m_CursorRect.bottom > rectl.top &&
m_CursorRect.left < rectl.right && m_CursorRect.right > rectl.left)
{
CursorOff();
m_CursorForcedOff = TRUE;
}
}
if (m_iRotate) //if rotated
{
bRotate = TRUE;
}
}
if (bRotate)
{
blitParameters->pBlt = (SCODE (GPE::*)(GPEBltParms *))EmulatedBltRotate;
}
EmulatedBltSelect02(blitParameters);
EmulatedBltSelect08(blitParameters);
EmulatedBltSelect16(blitParameters);
return S_OK;
}
SCODE S3C2443DISP::BltComplete(GPEBltParms *blitParameters)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::BltComplete\r\n")));
// see if cursor was forced off because of overlap with source or destination and turn back on
if (m_CursorForcedOff)
{
m_CursorForcedOff = FALSE;
CursorOn();
}
#ifdef DO_DISPPERF
DispPerfEnd(0);
#endif
return S_OK;
}
INT S3C2443DISP::InVBlank(void)
{
static BOOL value = FALSE;
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::InVBlank\r\n")));
value = !value;
return value;
}
SCODE S3C2443DISP::SetPalette(const PALETTEENTRY *source, USHORT firstEntry, USHORT numEntries)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::SetPalette\r\n")));
if (firstEntry < 0 || firstEntry + numEntries > 256 || source == NULL)
{
return E_INVALIDARG;
}
return S_OK;
}
int
S3C2443DISP::GetGameXInfo(
ULONG iEsc,
ULONG cjIn,
PVOID pvIn,
ULONG cjOut,
PVOID pvOut
)
{
int RetVal = 0; // Default not supported
GXDeviceInfo * pgxoi;
// 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 = 1;
}
else
{
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = -1;
}
}
else
{
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = -1;
}
return(RetVal);
}
VIDEO_POWER_STATE
PmToVideoPowerState(CEDEVICE_POWER_STATE pmDx)
{
VIDEO_POWER_STATE vps;
RETAILMSG(0,(_T("++PmToVideoPowerState\r\n")));
switch(pmDx) {
case D0: // turn the display on
vps = VideoPowerOn;
break;
case D1: // if asked for a state we don't support, go to the next lower one
case D2:
case D3:
case D4:
vps = VideoPowerOff;
break;
default:
RETAILMSG(0 , (L"PmToVideoPowerState: mapping unknown PM state %d to VideoPowerOn\r\n", pmDx));
vps = VideoPowerOn;
break;
}
return vps;
}
// this routine maps video power states to PM power states.
CEDEVICE_POWER_STATE
VideoToPmPowerState(VIDEO_POWER_STATE vps)
{
CEDEVICE_POWER_STATE pmDx;
RETAILMSG(0,(_T("++VideoToPmPowerState\r\n")));
switch(vps)
{
case VideoPowerOn:
pmDx = D0;
break;
case VideoPowerStandBy:
pmDx = D1;
break;
case VideoPowerSuspend:
pmDx = (CEDEVICE_POWER_STATE)D2;
break;
case VideoPowerOff:
pmDx = (CEDEVICE_POWER_STATE)D4;
break;
default:
pmDx = D0;
RETAILMSG(0, (L"VideoToPmPowerState: mapping unknown video state %d to pm state %d\r\n",
vps, pmDx));
break;
}
return pmDx;
}
#define ESC_SUCCESS 0x00000001
#define ESC_FAILED 0xFFFFFFFF
#define ESC_NOT_SUPPORTED 0x00000000
ULONG
S3C2443DISP::DrvEscape(
SURFOBJ * pso,
ULONG iEsc,
ULONG cjIn,
void * pvIn,
ULONG cjOut,
void * pvOut
)
{
ULONG Result = 0;
if (iEsc == QUERYESCSUPPORT)
{
if (*(DWORD*)pvIn == GETGXINFO
|| *(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
)
{
// The escape is supported.
return 1;
}
else
{
// The escape isn't supported.
return 0;
}
}
else if (iEsc == DRVESC_GETSCREENROTATION)
{
*(int *)pvOut = ((DMDO_0 | DMDO_90 | DMDO_180 | DMDO_270) << 8) | ((BYTE)m_iRotate);
return DISP_CHANGE_SUCCESSFUL;
}
else if (iEsc == DRVESC_SETSCREENROTATION)
{
if ((cjIn == DMDO_0) ||
(cjIn == DMDO_90) ||
(cjIn == DMDO_180) ||
(cjIn == DMDO_270) )
{
return DynRotate(cjIn);
}
return DISP_CHANGE_BADMODE;
}
else if (iEsc == GETGXINFO)
{
return GetGameXInfo(iEsc, cjIn, pvIn, cjOut, pvOut);
}
else if (iEsc == SETPOWERMANAGEMENT)
{
if ((cjIn >= sizeof (VIDEO_POWER_MANAGEMENT)) && (pvIn != NULL))
{
PVIDEO_POWER_MANAGEMENT pvpm = (PVIDEO_POWER_MANAGEMENT)pvIn;
if (pvpm->Length >= sizeof (VIDEO_POWER_MANAGEMENT))
{
switch (pvpm->PowerState)
{
case VideoPowerStandBy:
case VideoPowerOn:
SetDisplayPower(VideoPowerOn);
Result = ESC_SUCCESS;
break;
case VideoPowerOff:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -