📄 video.cpp
字号:
if( pParms->dN) // The line has a diagonal component (we'll refresh the bounding rect)
N_plus_1 = 2 + ((pParms->cPels * pParms->dN) / pParms->dM);
else
N_plus_1 = 1;
switch(pParms->iDir) {
case 0:
bounds.left = pParms->xStart;
bounds.top = pParms->yStart;
bounds.right = pParms->xStart + pParms->cPels + 1;
bounds.bottom = bounds.top + N_plus_1;
break;
case 1:
bounds.left = pParms->xStart;
bounds.top = pParms->yStart;
bounds.bottom = pParms->yStart + pParms->cPels + 1;
bounds.right = bounds.left + N_plus_1;
break;
case 2:
bounds.right = pParms->xStart + 1;
bounds.top = pParms->yStart;
bounds.bottom = pParms->yStart + pParms->cPels + 1;
bounds.left = bounds.right - N_plus_1;
break;
case 3:
bounds.right = pParms->xStart + 1;
bounds.top = pParms->yStart;
bounds.left = pParms->xStart - pParms->cPels;
bounds.bottom = bounds.top + N_plus_1;
break;
case 4:
bounds.right = pParms->xStart + 1;
bounds.bottom = pParms->yStart + 1;
bounds.left = pParms->xStart - pParms->cPels;
bounds.top = bounds.bottom - N_plus_1;
break;
case 5:
bounds.right = pParms->xStart + 1;
bounds.bottom = pParms->yStart + 1;
bounds.top = pParms->yStart - pParms->cPels;
bounds.left = bounds.right - N_plus_1;
break;
case 6:
bounds.left = pParms->xStart;
bounds.bottom = pParms->yStart + 1;
bounds.top = pParms->yStart - pParms->cPels;
bounds.right = bounds.left + N_plus_1;
break;
case 7:
bounds.left = pParms->xStart;
bounds.bottom = pParms->yStart + 1;
bounds.right = pParms->xStart + pParms->cPels + 1;
bounds.top = bounds.bottom - N_plus_1;
break;
default:
DEBUGMSG(GPE_ZONE_ERROR,(TEXT("Invalid direction: %d\r\n"),pParms->iDir));
return E_INVALIDARG;
}
DispDrvrDirtyRectDump((LPRECT)&bounds);
return code;
}
SCODE SA2Video::Line(GPELineParms *pLineParms,EGPEPhase phase)
{
if(phase == gpeSingle || phase == gpePrepare)
{
if((pLineParms->pDst != m_pPrimarySurface) || (DispDrvrPhysicalFrameBuffer != NULL))
pLineParms->pLine = EmulatedLine;
else
pLineParms->pLine = (SCODE (GPE::*)(struct GPELineParms *))WrappedEmulatedLine;
}
return S_OK;
}
#undef SWAP
#define SWAP(type,a,b) { type tmp; tmp=a; a=b; b=tmp; }
SCODE SA2Video::WrappedEmulatedBlt(GPEBltParms *pParms)
{
SCODE code = EmulatedBlt(pParms); // Draw to the backup framebuffer
if(FAILED(code))
return code;
// Now, calculate the dirty-rect to refresh to the actual hardware
RECT bounds;
bounds.left = pParms->prclDst->left;
bounds.top = pParms->prclDst->top;
bounds.right = pParms->prclDst->right;
bounds.bottom = pParms->prclDst->bottom;
if(bounds.left > bounds.right) {
SWAP(int,bounds.left,bounds.right)
}
if( bounds.top > bounds.bottom) {
SWAP(int,bounds.top,bounds.bottom)
}
DispDrvrDirtyRectDump((LPRECT)&bounds);
return code;
}
SCODE SA2Video::BltPrepare(GPEBltParms *pBltParms)
{
DEBUGMSG(GPE_ZONE_LINE,(TEXT("SA2Video::BltPrepare\r\n")));
if((pBltParms->pDst != m_pPrimarySurface) || (DispDrvrPhysicalFrameBuffer != NULL))
pBltParms->pBlt = EmulatedBlt;
else
pBltParms->pBlt = (SCODE (GPE::*)(struct GPEBltParms *))WrappedEmulatedBlt;
return S_OK;
}
// This function would be used to undo the setting of clip registers etc
SCODE SA2Video::BltComplete(GPEBltParms *pBltParms)
{
return S_OK;
}
int SA2Video::InVBlank(void)
{
return 0;
}
SCODE SA2Video::SetPalette(const PALETTEENTRY *source,unsigned short firstEntry,unsigned short numEntries)
{
if (bpp==8)
{
if (firstEntry < 0 || firstEntry + numEntries > 256) {
return E_INVALIDARG;
}
DispDrvrSetPalette(source,firstEntry,numEntries);
}
return S_OK;
}
void RegisterDDHALAPI()
{
; // No DDHAL support in wrapper
}
ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
return BitMasks;
}
ULONG SA2Video::DrvEscape(SURFOBJ *pso, ULONG iEsc, ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
int RetVal = 0; // default return value: "not supported"
DWORD EscapeFunction;
GXDeviceInfo *pgxoi;
switch (iEsc) {
case QUERYESCSUPPORT:
EscapeFunction = *(DWORD *)pvIn;
if ((EscapeFunction == CONTRASTCOMMAND) ||
(EscapeFunction == GETVFRAMEPHYSICAL) ||
(EscapeFunction == GETVFRAMELEN) ||
(EscapeFunction == DISPLAYPAGE) ||
(EscapeFunction == GETPALETTERAMPHYSICAL) ||
(EscapeFunction == VERTICALBLANKINTERRUPT) ||
(EscapeFunction == OS_SCREENACCESS) ||
(EscapeFunction == SCROLL) ||
(EscapeFunction == GETGXINFO))
RetVal = 1;
break;
// Handle the contrast adjust methods.
case CONTRASTCOMMAND:
ContrastCmd(cjIn, pvIn, cjOut, pvOut);
RetVal = 1;
break;
// Provide the mapped virtual address of the frame buffer ram
// for direct frame buffer manipulation.
case GETVFRAMEPHYSICAL:
if (cjIn < NUM_FRAME_BUFFERS)
{
// This works as long as the frame buffers are in a contiguous region.
*(DWORD *)pvOut = (ULONG)FRAME_BUFFER_0_BASE_VIRTUAL + cjIn * (DispDrvr_cdwStride * DispDrvr_cyScreen * 4);
RetVal = 1;
} else
{
*(DWORD *)pvOut = NULL;
}
break;
// Provide the length of the frame buffer in bytes
case GETVFRAMELEN:
*(DWORD *)pvOut = (ULONG)DispDrvr_cdwStride * DispDrvr_cyScreen * 4;
RetVal = 1;
break;
// Instruct the driver to display a given page of video ram
// The application can implement page flipping by calling
// DISPLAYPAGE with alternating frame buffer IDs.
case DISPLAYPAGE:
DisplayPageBuffer(cjIn);
RetVal = 1;
break;
// Provide the mapped virtual address of the palette ram
// for direct palette buffer manipulation.
case GETPALETTERAMPHYSICAL:
*(DWORD *)pvOut = (ULONG)PALETTE_BUFFER_BASE_VIRTUAL;
RetVal = 1;
break;
case VERTICALBLANKINTERRUPT:
//fnVerticalBlankInterrupt = cjIn;
RetVal = 1;
break;
// Enable or disable the OS from writing to the frame buffer
// The graphics application will want to disable OS screen access
// so that GUI elements like the clock will not be drawn to the screen
// while displaying other pages of video memory. Currently, the OS draws
// to the active frame buffer - it's not restricted to frame buffer 0.
case OS_SCREENACCESS:
if (cjIn)
{
bAllowOSFrameBufferUpdates = TRUE;
}
else
{
bAllowOSFrameBufferUpdates = FALSE;
}
case SCROLL:
ScrollBuffer(cjIn);
break;
case GETGXINFO:
// Fill out the GAPI data structure. Assumes 16bpp, with RGB565 format.
// Must change cBPP and ffFormat fields to accomodate other formats.
// All of the button data that follows must be filled out to match the specific OEM device.
// The data that is used to fill out the data structure here is copied from
// the Microsoft example. Lubbock has no such buttons to map at this time.
if ((cjOut >= sizeof(GXDeviceInfo)) && (pvOut != NULL) )
{
if (((GXDeviceInfo *) pvOut)->idVersion == kidVersion100)
{
pgxoi = (GXDeviceInfo *) pvOut;
pgxoi->idVersion = kidVersion100;
pgxoi->pvFrameBuffer = (void *) FRAME_BUFFER_0_BASE_VIRTUAL;
pgxoi->cbStride = DispDrvr_cdwStride * 4;
pgxoi->cxWidth = DispDrvr_cxScreen;
pgxoi->cyHeight = DispDrvr_cyScreen;
pgxoi->cBPP = 16;
pgxoi->ffFormat= kfDirect565;
pgxoi->vkButtonUpPortrait = VK_UP;
pgxoi->vkButtonUpLandscape = 0xC3;
pgxoi->ptButtonUp.x = -50;
pgxoi->ptButtonUp.y = 0;
pgxoi->vkButtonDownPortrait = VK_DOWN;
pgxoi->vkButtonDownLandscape = 0xC4;
pgxoi->ptButtonDown.x = -50;
pgxoi->ptButtonDown.y = 30;
pgxoi->vkButtonLeftPortrait = 0xC2;
pgxoi->vkButtonLeftLandscape = VK_DOWN;
pgxoi->ptButtonLeft.x = 25;
pgxoi->ptButtonLeft.y = 400;
pgxoi->vkButtonRightPortrait = 0xC3;
pgxoi->vkButtonRightLandscape = VK_UP;
pgxoi->ptButtonRight.x = 90;
pgxoi->ptButtonRight.y = 410;
pgxoi->vkButtonAPortrait = 0xC4;
pgxoi->vkButtonALandscape = 0xC2;
pgxoi->ptButtonA.x = 150;
pgxoi->ptButtonA.y = 410;
pgxoi->vkButtonBPortrait = 0xC5;
pgxoi->vkButtonBLandscape = 0xC5;
pgxoi->ptButtonB.x = 220;
pgxoi->ptButtonB.y = 400;
pgxoi->vkButtonCPortrait = VK_ESCAPE;
pgxoi->vkButtonCLandscape = VK_ESCAPE;
pgxoi->ptButtonC.x = -50;
pgxoi->ptButtonC.y = 100;
pgxoi->vkButtonStartPortrait = VK_F23;
pgxoi->vkButtonStartLandscape = VK_F23;
pgxoi->ptButtonStart.x = -50;
pgxoi->ptButtonStart.y = 15;
pgxoi->pvReserved1 = (void *) 0;
pgxoi->pvReserved2 = (void *) 0;
RetVal = 1;
} else
{
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = -1;
}
} else {
SetLastError (ERROR_INVALID_PARAMETER);
RetVal = -1;
}
break;
default:
RetVal = 0;
break;
}
return RetVal;
}
void SA2Video::ContrastCmd(ULONG cjIn, PVOID pvIn, ULONG cjOut, PVOID pvOut)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -