📄 s3c2443disp.cpp
字号:
if (modeId != 0)
{
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("S3C2443DISP::SetMode Want mode %d, only have mode 0\r\n"),modeId));
return E_INVALIDARG;
}
if (palette)
{
switch (m_colorDepth)
{
case 8:
*palette = EngCreatePalette (PAL_INDEXED,
PALETTE_SIZE,
(ULONG*)_rgbIdentity,
0,
0,
0);
break;
case 16:
case 24:
case 32:
*palette = EngCreatePalette (PAL_BITFIELDS,
0,
NULL,
((1 << m_RedMaskSize) - 1) << m_RedMaskPosition,
((1 << m_GreenMaskSize) - 1) << m_GreenMaskPosition,
((1 << m_BlueMaskSize) - 1) << m_BlueMaskPosition);
break;
}
m_nSurfaceBitsAlign = (m_pMode->Bpp == 24) ? (128 * 3) : 128;
//Allocate our primary surface here
if(NULL == m_pPrimarySurface)
{
if(FAILED(AllocSurface((DDGPESurf **)&m_pPrimarySurface, m_nScreenWidth,
m_nScreenHeight, m_pMode->format, m_pModeEx->ePixelFormat,
GPE_REQUIRE_VIDEO_MEMORY)))
{
RETAILMSG (1, (L"Couldn't allocate primary surface\n"));
return E_INVALIDARG;
}
m_pVisibleSurface = (S3C2443Surf*)m_pPrimarySurface;
}
m_pPrimarySurface->SetRotation(m_nScreenWidth, m_nScreenHeight, m_iRotate);
}
DynRotate(m_iRotate);
return S_OK;
}
SCODE S3C2443DISP::GetModeInfo(GPEMode *mode, INT modeNumber)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::GetModeInfo\r\n")));
if (modeNumber != 0)
{
return E_INVALIDARG;
}
*mode = *m_pMode;
return S_OK;
}
//APR added func override
SCODE S3C2443DISP::GetModeInfoEx(GPEModeEx *pModeEx, int modeNo)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::GetModeInfoEx\r\n")));
if (modeNo != 0)
{
return E_INVALIDARG;
}
*pModeEx = *m_pModeEx;
return S_OK;
}
int S3C2443DISP::NumModes()
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::NumModes\r\n")));
return 1;
}
void S3C2443DISP::CursorOn (void)
{
UCHAR *ptrScreen = (UCHAR*)m_pPrimarySurface->Buffer();
UCHAR *ptrLine;
UCHAR *cbsLine;
int x, y;
if (!m_CursorForcedOff && !m_CursorDisabled && !m_CursorVisible)
{
RECTL cursorRectSave = m_CursorRect;
int iRotate;
RotateRectl(&m_CursorRect);
for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
{
if (y < 0)
{
continue;
}
if (y >= m_nScreenHeightSave)
{
break;
}
ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_colorDepth >> 3))];
for (x = m_CursorRect.left; x < m_CursorRect.right; x++)
{
if (x < 0)
{
continue;
}
if (x >= m_nScreenWidthSave)
{
break;
}
// x' = x - m_CursorRect.left; y' = y - m_CursorRect.top;
// Width = m_CursorSize.x; Height = m_CursorSize.y;
switch (m_iRotate)
{
case DMDO_0:
iRotate = (y - m_CursorRect.top)*m_CursorSize.x + x - m_CursorRect.left;
break;
case DMDO_90:
iRotate = (x - m_CursorRect.left)*m_CursorSize.x + m_CursorSize.y - 1 - (y - m_CursorRect.top);
break;
case DMDO_180:
iRotate = (m_CursorSize.y - 1 - (y - m_CursorRect.top))*m_CursorSize.x + m_CursorSize.x - 1 - (x - m_CursorRect.left);
break;
case DMDO_270:
iRotate = (m_CursorSize.x -1 - (x - m_CursorRect.left))*m_CursorSize.x + y - m_CursorRect.top;
break;
default:
iRotate = (y - m_CursorRect.top)*m_CursorSize.x + x - m_CursorRect.left;
break;
}
cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)] = ptrLine[x * (m_colorDepth >> 3)];
ptrLine[x * (m_colorDepth >> 3)] &= m_CursorAndShape[iRotate];
ptrLine[x * (m_colorDepth >> 3)] ^= m_CursorXorShape[iRotate];
if (m_colorDepth > 8)
{
cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1] = ptrLine[x * (m_colorDepth >> 3) + 1];
ptrLine[x * (m_colorDepth >> 3) + 1] &= m_CursorAndShape[iRotate];
ptrLine[x * (m_colorDepth >> 3) + 1] ^= m_CursorXorShape[iRotate];
if (m_colorDepth > 16)
{
cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2] = ptrLine[x * (m_colorDepth >> 3) + 2];
ptrLine[x * (m_colorDepth >> 3) + 2] &= m_CursorAndShape[iRotate];
ptrLine[x * (m_colorDepth >> 3) + 2] ^= m_CursorXorShape[iRotate];
}
}
}
}
m_CursorRect = cursorRectSave;
m_CursorVisible = TRUE;
}
}
void S3C2443DISP::CursorOff (void)
{
UCHAR *ptrScreen = (UCHAR*)m_pPrimarySurface->Buffer();
UCHAR *ptrLine;
UCHAR *cbsLine;
int x, y;
if (!m_CursorForcedOff && !m_CursorDisabled && m_CursorVisible)
{
RECTL rSave = m_CursorRect;
RotateRectl(&m_CursorRect);
for (y = m_CursorRect.top; y < m_CursorRect.bottom; y++)
{
// clip to displayable screen area (top/bottom)
if (y < 0)
{
continue;
}
if (y >= m_nScreenHeightSave)
{
break;
}
ptrLine = &ptrScreen[y * m_pPrimarySurface->Stride()];
cbsLine = &m_CursorBackingStore[(y - m_CursorRect.top) * (m_CursorSize.x * (m_colorDepth >> 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_colorDepth >> 3)] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3)];
if (m_colorDepth > 8)
{
ptrLine[x * (m_colorDepth >> 3) + 1] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 1];
if (m_colorDepth > 16)
{
ptrLine[x * (m_colorDepth >> 3) + 2] = cbsLine[(x - m_CursorRect.left) * (m_colorDepth >> 3) + 2];
}
}
}
}
m_CursorRect = rSave;
m_CursorVisible = FALSE;
}
}
SCODE S3C2443DISP::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("S3C2443DISP::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 S3C2443DISP::MovePointer(INT xPosition, INT yPosition)
{
DEBUGMSG(GPE_ZONE_CURSOR, (TEXT("S3C2443DISP::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 S3C2443DISP::WaitForNotBusy(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::WaitForNotBusy\r\n")));
return;
}
int S3C2443DISP::IsBusy(void)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::IsBusy\r\n")));
return 0;
}
void S3C2443DISP::GetPhysicalVideoMemory(unsigned long *physicalMemoryBase, unsigned long *videoMemorySize)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::GetPhysicalVideoMemory\r\n")));
*physicalMemoryBase = m_pvFlatFrameBuffer;
*videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
}
void
S3C2443DISP::GetVirtualVideoMemory(
unsigned long *virtualMemoryBase,
unsigned long *videoMemorySize
)
{
DEBUGMSG (GPE_ZONE_INIT, (TEXT("S3C2443DISP::GetVirtualVideoMemory\r\n")));
*virtualMemoryBase = m_VirtualFrameBuffer;
// *videoMemorySize = m_cbScanLineLength * m_cyPhysicalScreen;
*videoMemorySize = 0x100000;
}
SCODE
S3C2443DISP::WrappedEmulatedLine(
GPELineParms *lineParameters
)
{
SCODE retval;
RECT bounds;
int N_plus_1; // Minor length of bounding rect + 1
// calculate the bounding-rect to determine overlap with cursor
if (lineParameters->dN) // The line has a diagonal component (we'll refresh the bounding rect)
{
N_plus_1 = 2 + ((lineParameters->cPels * lineParameters->dN) / lineParameters->dM);
}
else
{
N_plus_1 = 1;
}
switch(lineParameters->iDir)
{
case 0:
bounds.left = lineParameters->xStart;
bounds.top = lineParameters->yStart;
bounds.right = lineParameters->xStart + lineParameters->cPels + 1;
bounds.bottom = bounds.top + N_plus_1;
break;
case 1:
bounds.left = lineParameters->xStart;
bounds.top = lineParameters->yStart;
bounds.bottom = lineParameters->yStart + lineParameters->cPels + 1;
bounds.right = bounds.left + N_plus_1;
break;
case 2:
bounds.right = lineParameters->xStart + 1;
bounds.top = lineParameters->yStart;
bounds.bottom = lineParameters->yStart + lineParameters->cPels + 1;
bounds.left = bounds.right - N_plus_1;
break;
case 3:
bounds.right = lineParameters->xStart + 1;
bounds.top = lineParameters->yStart;
bounds.left = lineParameters->xStart - lineParameters->cPels;
bounds.bottom = bounds.top + N_plus_1;
break;
case 4:
bounds.right = lineParameters->xStart + 1;
bounds.bottom = lineParameters->yStart + 1;
bounds.left = lineParameters->xStart - lineParameters->cPels;
bounds.top = bounds.bottom - N_plus_1;
break;
case 5:
bounds.right = lineParameters->xStart + 1;
bounds.bottom = lineParameters->yStart + 1;
bounds.top = lineParameters->yStart - lineParameters->cPels;
bounds.left = bounds.right - N_plus_1;
break;
case 6:
bounds.left = lineParameters->xStart;
bounds.bottom = lineParameters->yStart + 1;
bounds.top = lineParameters->yStart - lineParameters->cPels;
bounds.right = bounds.left + N_plus_1;
break;
case 7:
bounds.left = lineParameters->xStart;
bounds.bottom = lineParameters->yStart + 1;
bounds.right = lineParameters->xStart + lineParameters->cPels + 1;
bounds.top = bounds.bottom - N_plus_1;
break;
default:
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("Invalid direction: %d\r\n"), lineParameters->iDir));
return E_INVALIDARG;
}
// check for line overlap with cursor and turn off cursor if overlaps
if (m_CursorVisible && !m_CursorDisabled)
{
RotateRectl(&m_CursorRect);
if (m_CursorRect.top < bounds.bottom && m_CursorRect.bottom > bounds.top &&
m_CursorRect.left < bounds.right && m_CursorRect.right > bounds.left)
{
RotateRectlBack(&m_CursorRect);
CursorOff();
m_CursorForcedOff = TRUE;
}
else
RotateRectlBack(&m_CursorRect);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -