⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s3c2440disp.cpp

📁 该2440 BSP是由三星公司提供的wince5.0的BSP移植到到wince6.0下的
💻 CPP
📖 第 1 页 / 共 4 页
字号:
            else if(index < 6400)
            {
                ptr[index + 16] = 0x07e0;
            }
            else if(index < 9600)
            {
                ptr[index + 16] = 0x001f;
            }
            else
            {
                ptr[index + 16] = 0xffff;
            }
        }

        // Set Board Control Register (BCR) for Sharp LCD mode
        //set_BCRVal (BCR_LCD_LQ039Q2DS01_16BPP | BCR_LCD_POWER_ON | BCR_BACKLIGHT_ON, NOMASK, INPOWERHANDLER);

        //
        // The SA1111DB card used by the SA11X0BD platform provides a bit to 
        // allow us to choose between MQ200 and SA_LCD.  By default we assume 
        // the display will be a MQ200 (so we can have a generic MQ200 driver) 
        // and only override it if we want to use the LCD driver.  It's wrapped 
        // in a conditional so other SA-based systems can use this library.
        //
	// if (m_bClearAlternateVideoBCR != 0)
  	// {
    	//        set_BCRVal (0, 0x2, INPOWERHANDLER);
      //  }

        // Program GPIO register to enable GPIO lines 2 - 9 for use by the LCD controller
        // disable LCD controller
        // clear LCD Status Register
        // enable LCD controller


        // Restore the screen
        if (NULL != pVideoMemory)
        {
            // Swap the buffers.
            BYTE * pTempBuffer = (BYTE*)m_pPrimarySurface->Buffer();

	     m_pPrimarySurface->Init(m_nScreenWidth, m_nScreenHeight, pVideoMemory, m_cbScanLineLength, m_pMode->format);

            pVideoMemory = pTempBuffer;

            // Actually copy the bits.
            memcpy(m_pPrimarySurface->Buffer(), pVideoMemory, m_FrameBufferSize);

            delete [] pVideoMemory;
            pVideoMemory = NULL;
        }
        else
        {
            memset ((void*)m_pPrimarySurface->Buffer(), 0x0, m_FrameBufferSize);
        }
        
        DynRotate(m_iRotate);

        m_CursorDisabled = FALSE;
        //CursorOn();
        m_CursorVisible = TRUE;
    }
}

//APR added func override
SCODE S3C2440DISP::GetModeInfoEx(GPEModeEx *pModeEx, int modeNo)
{
	RETAILMSG(DBGLCD, (TEXT("In S3C2440DISP::GetModeInfoEx\r\n")));
	if (modeNo != 0)
    	{
        	return    E_INVALIDARG;
    	}

    	*pModeEx = *m_pModeEx;

    	return S_OK;
}

ULONG *APIENTRY DrvGetMasks(DHPDEV dhpdev)
{
	RETAILMSG(DBGLCD, (TEXT("DrvGetMasks\r\n")));
	if (gGPE == NULL)
        	return(BitMasks[0]);

    	int nBPP = ((S3C2440DISP *)gGPE)->GetBpp()/8 - 1;
    	switch (((S3C2440DISP *)gGPE)->GetBpp())
    	{
//        case 8:
        case 16:
        case 24:
        case 32:
	  {
           return(BitMasks[nBPP]);            	
        }
				
    	}

    	return(BitMasks[0]);
	
	//return gBitMasks;
}

//
// GetBpp
//
// Return the Bpp of the current monitor
//
int S3C2440DISP::GetBpp(void)
{
    return m_pMode->Bpp;
}

//------------------------------------------------------------------------------
//
//   GetGameXInfo
//
//   fill out GAPI information for DrvEscape call
//
int S3C2440DISP::GetGameXInfo(
    ULONG iEsc, ULONG cjIn, VOID *pvIn, ULONG cjOut, VOID *pvOut
) {
    int rc = 0;  

    RETAILMSG(1, (L"+GetGameXInfo \r\n"));

    // GAPI only support P8, RGB444, RGB555, RGB565, and RGB888
    if (
        pvOut != NULL && cjOut >= sizeof(GXDeviceInfo) && (
            m_pMode->Bpp == 8 || m_pMode->Bpp == 12 ||
            m_pMode->Bpp == 16 || m_pMode->Bpp == 24 ||
            m_pMode->Bpp == 32
        )) 
    {
       if(((GXDeviceInfo*)pvOut)->idVersion == kidVersion100)
       {  
        GXDeviceInfo *pInfo = (GXDeviceInfo*)pvOut;
        pInfo->idVersion = kidVersion100;
        
              pInfo->pvFrameBuffer = (UCHAR*)m_pPrimarySurface->Buffer();
              pInfo->cbStride = m_pPrimarySurface->Stride();
              pInfo->cxWidth  = m_pPrimarySurface->Width();
              pInfo->cyHeight = m_pPrimarySurface->Height();
             
              switch (m_pMode->Bpp) {
              case 8:
                 pInfo->cBPP = 8;
                 pInfo->ffFormat |= kfPalette;
                 break;
              case 12:
                 pInfo->cBPP = 12;
                 pInfo->ffFormat |= kfDirect | kfDirect444;
                 break;
              case 16:
                 pInfo->cBPP = 16;
                 pInfo->ffFormat |= kfDirect | kfDirect565;
                 break;
              case 24:
                 pInfo->cBPP = 24;
                 pInfo->ffFormat |= kfDirect | kfDirect888;
              case 32:
                 pInfo->cBPP = 32;
                 pInfo->ffFormat |= kfDirect | kfDirect888;
              default:
                 goto cleanUp;
               }
            RETAILMSG(1,(TEXT("Stride=%d, Width=%d, Height=%d, FrmaeBuffer=%x \r\n"),pInfo->cbStride,pInfo->cxWidth,pInfo->cyHeight,pInfo->pvFrameBuffer));
#ifdef ROTATE  
           if (m_iRotate == DMDO_90 || m_iRotate == DMDO_270 )
                    pInfo->ffFormat |= kfLandscape;  // Rotated
#endif //ROTATE & ROTATE

        // todo: get keys from registry
        pInfo->vkButtonUpPortrait = VK_UP;
        pInfo->vkButtonUpLandscape = VK_LEFT;
        pInfo->ptButtonUp.x = 88;
        pInfo->ptButtonUp.y = 250;
        pInfo->vkButtonDownPortrait = VK_DOWN;
        pInfo->vkButtonDownLandscape = VK_RIGHT;
        pInfo->ptButtonDown.x = 88;
        pInfo->ptButtonDown.y = 270;
        pInfo->vkButtonLeftPortrait = VK_LEFT;
        pInfo->vkButtonLeftLandscape = VK_DOWN;
        pInfo->ptButtonLeft.x = 78;
        pInfo->ptButtonLeft.y = 260;
        pInfo->vkButtonRightPortrait = VK_RIGHT;
        pInfo->vkButtonRightLandscape = VK_UP;
        pInfo->ptButtonRight.x = 98;
        pInfo->ptButtonRight.y = 260;

#if 1       // default to Smartphone settings for now
        pInfo->vkButtonAPortrait = VK_F1;   // Softkey 1
        pInfo->vkButtonALandscape = VK_F1;
        pInfo->ptButtonA.x = 10;
        pInfo->ptButtonA.y = 240;
        pInfo->vkButtonBPortrait = VK_F2;   // Softkey 2
        pInfo->vkButtonBLandscape = VK_F2;
        pInfo->ptButtonB.x = 166;
        pInfo->ptButtonB.y = 240;
        pInfo->vkButtonCPortrait = VK_F8;   // Asterisk on keypad
        pInfo->vkButtonCLandscape = VK_F8;
        pInfo->ptButtonC.x = 10;
        pInfo->ptButtonC.y = 320;
#else
        //  Added For GAPI to map Literal A, B, C
        pInfo->vkButtonAPortrait = VK_APP_LAUNCH1;
        pInfo->vkButtonALandscape = VK_APP_LAUNCH1;
        pInfo->ptButtonA.x = 10;
        pInfo->ptButtonA.y = 240;
        pInfo->vkButtonBPortrait = VK_APP_LAUNCH4;
        pInfo->vkButtonBLandscape = VK_APP_LAUNCH4;
        pInfo->ptButtonB.x = 166;
        pInfo->ptButtonB.y = 240;
        pInfo->vkButtonCPortrait = VK_APP_LAUNCH2;   // Asterisk on keypad
        pInfo->vkButtonCLandscape = VK_APP_LAUNCH2;
        pInfo->ptButtonC.x = 10;
        pInfo->ptButtonC.y = 320;
#endif
        pInfo->vkButtonStartPortrait  = '\r';
        pInfo->vkButtonStartLandscape = '\r';
        pInfo->ptButtonStart.x = 88;
        pInfo->ptButtonStart.y = 260;
        pInfo->pvReserved1 = (void *) 0;
        pInfo->pvReserved2 = (void *) 0;
        RETAILMSG(1, (L"-GetGameXInfo \r\n"));
        rc = 1;
    	}
    }
    else {
        SetLastError (ERROR_INVALID_PARAMETER);
        rc = -1;
    }

cleanUp:
    RETAILMSG(DBGLCD, (L"GetGameXInfo(rc = %d\r\n", rc));
    return rc;
}

int S3C2440DISP::GetRotateModeFromReg()
{
    HKEY hKey;

    if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\GDI\\ROTATION"), 0, 0, &hKey))
    {
        DWORD dwSize, dwAngle, dwType = REG_DWORD;
        dwSize = sizeof(DWORD);
        if (ERROR_SUCCESS == RegQueryValueEx(hKey,
                                             TEXT("ANGLE"),
                                             NULL,
                                             &dwType,
                                             (LPBYTE)&dwAngle,
                                             &dwSize))
        {
            switch (dwAngle)
            {
            case 0:
                return DMDO_0;

            case 90:
                return DMDO_90;

            case 180:
                return DMDO_180;

            case 270:
                return DMDO_270;

            default:
                return DMDO_0;
            }
        }

        RegCloseKey(hKey);
    }

    return DMDO_0;
}

void S3C2440DISP::SetRotateParams()
{
    switch(m_iRotate)
    {
    case DMDO_90:
    case DMDO_270:
        m_pMode->height = m_nScreenWidthSave;
        m_pMode->width = m_nScreenHeightSave;
        break;

    case DMDO_0:
    case DMDO_180:
    default:
        m_pMode->width = m_nScreenWidthSave;
        m_pMode->height = m_nScreenHeightSave;
        break;
    }
    return;
}

LONG S3C2440DISP::DynRotate(int angle)
{
    int curRot, oldAngle;
    int ang2idxArr[5]={0,1,2,2,3};
    int angArr[4]={0,1,2,4};

    oldAngle = m_iRotate;
    m_iRotate = angle;

    curRot = ang2idxArr[angle] - ang2idxArr[oldAngle];
    if(curRot < 0)
        curRot += 4;

    //RotateCursorShape(angArr[curRot]);

    SetRotateParams();

	m_nScreenWidth = m_pMode->width;
	m_nScreenHeight = m_pMode->height;
	m_pPrimarySurface->SetRotation(m_nScreenWidth, m_nScreenHeight, angle);

	return DISP_CHANGE_SUCCESSFUL;
}

SCODE S3C2440DISP::RotateCursorShape(int angle)
{
#if 0 	//{
    if (angle == 0)
        return S_OK;

    BYTE *pByte, *pCursor;
    ULONG ulBase, ulIndex;
    BYTE srcAnd[128],srcXor[128], dstAnd[128], dstXor[128]; /* 128 = 4 x 32 */
    BYTE  jMask,jAnd,jXor,bitMask;
    int x, y, cx = 32, cy = 32, tx;

    pCursor = pByte = m_pLAW + m_nCursorMemory + 1024;

    memset(srcAnd, 0x00, sizeof(srcAnd));
    memset(srcXor, 0x00, sizeof(srcXor));
    memset(dstAnd, 0x00, sizeof(dstAnd));
    memset(dstXor, 0x00, sizeof(dstXor));

    //Save the original pointer shape into local memory shapeRow[]
    for (y=0; y<cy; y++)
    {
        srcAnd[y*4+0] = pByte[0x0];
        srcXor[y*4+0] = pByte[0x1];
        srcAnd[y*4+1] = pByte[0x2];
        srcXor[y*4+1] = pByte[0x3];
        srcAnd[y*4+2] = pByte[0x8];
        srcXor[y*4+2] = pByte[0x9];
        srcAnd[y*4+3] = pByte[0xA];
        srcXor[y*4+3] = pByte[0xB];

        pByte+=16;
    }

//    pShape = shapeSrcRow;
    switch (angle)
    {
    case DMDO_90:
        for (y = 0; y < cy; y++)
        {        
            jMask = 0x80 >> (y&7);
            for (x = 0; x < cx; x++)
            {
                ulBase  = (31 - x) * 4;
                ulIndex = (ulBase + y / 8);

                bitMask = 0x80 >> (x&7);
                jAnd = srcAnd[y*4 + (x/8)];
                jXor = srcXor[y*4 + (x/8)];

                if (jAnd & bitMask)
                {
                    dstAnd[ulIndex] |= jMask;
                }
                if (jXor & bitMask)
                {
                    dstXor[ulIndex] |= jMask;
                }
            }
        }

        tx = m_nXHot;
        m_nXHot = m_nYHot;
        m_nYHot = 31 - tx;
        break;

    case DMDO_180:
        for (y = 0; y < cy; y++)
        {
            ulBase = (31 - y) * 4;
            for (x = 0; x < cx; x++)
            {
                jAnd  = srcAnd[y*4 + x/8];
                jXor  = srcXor[y*4 + x/8];
                bitMask  = 0x80 >> (x & 7);
                jMask = 0x01 << (x & 7);

                ulIndex = (ulBase + (32 - x - 1) / 8);
                if (jAnd & bitMask)
                {
                    dstAnd[ulIndex] |= jMask;
                }
                if (jXor & bitMask)
                {
                    dstXor[ulIndex] |= jMask;
                }
            }
        }

        m_nXHot = 31 - m_nXHot;
        m_nYHot = 31 - m_nYHot;
        break;

    case DMDO_270:
         for (y = 0; y < cy; y++)
        {
            jMask  = 0x01 << (y & 7);

            // Write available bits into shapeRow
            for (x = 0; x < cx; x++)
            {
                jAnd  = srcAnd[y*4 + x/8];
                jXor  = srcXor[y*4 + x/8];
                bitMask = 0x80 >> (x & 7);            // Starting here achieves byte swapping

                ulBase = x * 4;
                ulIndex = (ulBase + (31 - y) / 8);

                if (jAnd & bitMask)
                    dstAnd[ulIndex] |= jMask;
                if (jXor & bitMask)
                    dstXor[ulIndex] |= jMask;
            }
        }
        tx = m_nXHot;
        m_nXHot = 31 - m_nYHot;
        m_nYHot = tx;
        break;
    }

    for (y=0; y<cy; y++)
    {
        pCursor[0x0] = dstAnd[y*4+0];
        pCursor[0x1] = dstXor[y*4+0];
        pCursor[0x2] = dstAnd[y*4+1];
        pCursor[0x3] = dstXor[y*4+1];
        pCursor[0x8] = dstAnd[y*4+2];
        pCursor[0x9] = dstXor[y*4+2];
        pCursor[0xa] = dstAnd[y*4+3];
        pCursor[0xb] = dstXor[y*4+3];
        pCursor += 16;
    }
#endif	//}
    return S_OK;
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -