wrapbpp.cpp
来自「老外的一个开源项目」· C++ 代码 · 共 716 行 · 第 1/3 页
CPP
716 行
{ 0x66, 0x66, 0xcc, 0 }, /* 207 */ \
{ 0x99, 0x66, 0xff, 0 }, /* 208 */ \
{ 0xcc, 0x66, 0xff, 0 }, /* 209 */ \
{ 0xff, 0x66, 0xcc, 0 }, /* 210 */ \
{ 0x00, 0x99, 0xff, 0 }, /* 211 */ \
{ 0x33, 0x99, 0xff, 0 }, /* 212 */ \
{ 0x66, 0x99, 0xff, 0 }, /* 213 */ \
{ 0x99, 0x99, 0xff, 0 }, /* 214 */ \
{ 0xcc, 0x99, 0xff, 0 }, /* 215 */ \
{ 0xff, 0x99, 0xff, 0 }, /* 216 */ \
{ 0x00, 0xcc, 0xff, 0 }, /* 217 */ \
{ 0x33, 0xcc, 0xff, 0 }, /* 218 */ \
{ 0x66, 0xcc, 0xff, 0 }, /* 219 */ \
{ 0x99, 0xcc, 0xff, 0 }, /* 220 */ \
{ 0xcc, 0xcc, 0xff, 0 }, /* 221 */ \
{ 0xff, 0xcc, 0xff, 0 }, /* 222 */ \
{ 0x33, 0xff, 0xff, 0 }, /* 223 */ \
{ 0x66, 0xff, 0xcc, 0 }, /* 224 */ \
{ 0x99, 0xff, 0xff, 0 }, /* 225 */ \
{ 0xcc, 0xff, 0xff, 0 }, /* 226 */ \
{ 0xff, 0x66, 0x66, 0 }, /* 227 */ \
{ 0x66, 0xff, 0x66, 0 }, /* 228 */ \
{ 0xff, 0xff, 0x66, 0 }, /* 229 */ \
{ 0x66, 0x66, 0xff, 0 }, /* 230 */ \
{ 0xff, 0x66, 0xff, 0 }, /* 231 */ \
{ 0x66, 0xff, 0xff, 0 }, /* 232 */ \
{ 0xA5, 0x00, 0x21, 0 }, /* 233 R165 G0 B33 */ \
{ 0x5f, 0x5f, 0x5f, 0 }, /* 234 gray 95 */ \
{ 0x77, 0x77, 0x77, 0 }, /* 235 gray 119 */ \
{ 0x86, 0x86, 0x86, 0 }, /* 236 gray 134 */ \
{ 0x96, 0x96, 0x96, 0 }, /* 237 gray 150 */ \
{ 0xcb, 0xcb, 0xcb, 0 }, /* 238 gray 203 */ \
{ 0xb2, 0xb2, 0xb2, 0 }, /* 239 gray 178 */ \
{ 0xd7, 0xd7, 0xd7, 0 }, /* 240 gray 215 */ \
{ 0xdd, 0xdd, 0xdd, 0 }, /* 241 gray 221 */ \
{ 0xe3, 0xe3, 0xe3, 0 }, /* 242 gray 227 */ \
{ 0xea, 0xea, 0xea, 0 }, /* 243 gray 234 */ \
{ 0xf1, 0xf1, 0xf1, 0 }, /* 244 gray 241 */ \
{ 0xf8, 0xf8, 0xf8, 0 }, /* 245 gray 248 */ \
{ 0xff, 0xfb, 0xf0, 0 }, /* 246 Sys Reserved */ \
{ 0xa0, 0xa0, 0xa4, 0 }, /* 247 Sys Reserved */ \
{ 0x80, 0x80, 0x80, 0 }, /* 248 Sys Lt Gray gray 128 */ \
{ 0xff, 0x00, 0x00, 0 }, /* 249 Sys Red */ \
{ 0x00, 0xff, 0x00, 0 }, /* 250 Sys Green */ \
{ 0xff, 0xff, 0x00, 0 }, /* 251 Sys Yellow */ \
{ 0x00, 0x00, 0xff, 0 }, /* 252 Sys Blue */ \
{ 0xff, 0x00, 0xff, 0 }, /* 253 Sys Violet */ \
{ 0x00, 0xff, 0xff, 0 }, /* 254 Sys Cyan */ \
{ 0xff, 0xff, 0xff, 0 } /* 255 Sys White gray 255 */ \
};
ulong BitMasks8bpp[] = { 0xF800, 0x07E0, 0x001F };
INSTANTIATE_GPE_ZONES(0x3,"GDI Driver","unused1","unused2") /* Start with Errors, warnings, and temporary messages */
BOOL APIENTRY GPEEnableDriver( // This gets around problems exporting from .lib
ULONG iEngineVersion,
ULONG cj,
DRVENABLEDATA *pded,
PENGCALLBACKS pEngCallbacks);
BOOL APIENTRY DrvEnableDriver(
ULONG iEngineVersion,
ULONG cj,
DRVENABLEDATA *pded,
PENGCALLBACKS pEngCallbacks)
{
return GPEEnableDriver( iEngineVersion, cj, pded, pEngCallbacks );
}
static GPE *pGPE = (GPE *)NULL;
// Main entry point for a GPE-compliant driver
GPE *GetGPE(void)
{
if(!pGPE)
{
pGPE = new Wrapbpp();
}
return pGPE;
}
Wrapbpp::Wrapbpp(void)
{
DEBUGMSG(GPE_ZONE_INIT,(TEXT("Wrapbpp::Wrapbpp\r\n")));
DispDrvrInitialize();
//
// When this DispDrvrInitialize returns, DispDrvrPhysicalFrameBuffer contains
// the physical address of the screen if it is in 8bpp DIB format. - Alternatively it
// is NULL - in which case this is a "dirty-rect" driver
//
m_ModeInfo.modeId = 0;
m_ModeInfo.width = m_nScreenWidth = DispDrvr_cxScreen;
m_ModeInfo.height = m_nScreenHeight = DispDrvr_cyScreen;
m_ModeInfo.Bpp = (DispDrvr_cdwStride * 32)/DispDrvr_cxScreen;
m_ModeInfo.frequency = 60; // not too important
switch (m_ModeInfo.Bpp)
{
case 2:
m_ModeInfo.format = gpe2Bpp;
break;
case 8:
m_ModeInfo.format = gpe8Bpp;
break;
case 16:
m_ModeInfo.format = gpe16Bpp;
break;
default:
RETAILMSG(1, (TEXT("Wrapbpp::Wrapbpp: Error Bpp.\r\n")));
return;
break;
}
m_pMode = &m_ModeInfo;
if(DispDrvrPhysicalFrameBuffer == NULL)
{
// it is a "dirty-rect" driver - we create a system memory bitmap to represent
// the screen and refresh rectangles of this to the screen as they are altered
m_pPrimarySurface = new GPESurf(m_nScreenWidth,m_nScreenHeight,m_ModeInfo.format);
if (!m_pPrimarySurface)
{
RETAILMSG(1, (TEXT("Wrapbpp::Wrapbpp: Error allocating GPESurf.\r\n")));
return;
}
DispDrvrSetDibBuffer( m_pPrimarySurface->Buffer() );
}
else
{
unsigned long fbSize = DispDrvr_cyScreen * DispDrvr_cdwStride / 4;
m_pVirtualFrameBuffer = VirtualAlloc( 0, fbSize, MEM_RESERVE, PAGE_NOACCESS );
VirtualCopy( m_pVirtualFrameBuffer, DispDrvrPhysicalFrameBuffer, fbSize,
PAGE_READWRITE | PAGE_NOCACHE );
m_pPrimarySurface = new GPESurf( m_nScreenWidth, m_nScreenHeight, m_pVirtualFrameBuffer,
DispDrvr_cdwStride, m_ModeInfo.format);
}
}
SCODE Wrapbpp::SetMode( int modeId, HPALETTE *pPalette )
{
if(modeId != 0)
{
RETAILMSG(1, (L"Invalid mode, no palette for you.\r\n"));
return E_INVALIDARG;
}
if(pPalette)
{
switch (m_ModeInfo.Bpp)
{
case 2:
*pPalette = EngCreatePalette(
PAL_INDEXED,
PALETTE_SIZE_2BPP,
(ULONG*)_rgb2bpp,
0,
0,
0
);
break;
case 8:
case 16:
*pPalette = EngCreatePalette(
PAL_INDEXED,
PALETTE_SIZE_8BPP,
(ULONG*)_rgb8bpp,
0,
0,
0
);
break;
default:
return E_INVALIDARG;
break;
}
}
return S_OK; // Mode is inherently set
}
SCODE Wrapbpp::GetModeInfo
(
GPEMode *pMode,
int modeNumber
)
{
if(modeNumber != 0)
{
return E_INVALIDARG;
}
*pMode = m_ModeInfo;
return S_OK;
}
int Wrapbpp::NumModes(void)
{
return 1;
}
SCODE Wrapbpp::SetPointerShape(
GPESurf *pMask,
GPESurf *pColorSurf,
int xHot,
int yHot,
int cX,
int cY
)
{
return S_OK;
}
SCODE Wrapbpp::MovePointer( int x, int y )
{
DEBUGMSG(GPE_ZONE_HW,(TEXT("Moving cursor to %d,%d\r\n"), x, y ));
if( x == -1)
{
DispDrvrMoveCursor(DispDrvr_cxScreen,DispDrvr_cyScreen); // disable cursor
}
else
{
DispDrvrMoveCursor( x, y ); // disable cursor
}
return S_OK;
}
void Wrapbpp::WaitForNotBusy(void)
{
return;
}
int Wrapbpp::IsBusy(void)
{
return 0; // Never busy as there is no acceleration
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?