?? gdi.c
字號:
dwTmp=__wGDIStartY+__dwRegionHeight/2;
_dwGDIHeaders[3]=( _dwGDIHeaders[3] | (((DWORD)__wGDIStartY)<<9) | ((DWORD)dwTmp) );
W99AV_WriteDRAMBurst(__dwRegionTAddr+2, &_dwGDIHeaders[2], 2);
W99AV_WriteDRAMBurst(__dwRegionBAddr+2, &_dwGDIHeaders[2], 2);
// Brian2.30
// Set pseudo header3 START_LINE [17:9], END_LINE [8:0]
_dwGDIHeaders[3] &= 0xFFFC0000;
dwTmp =__wGDIStartY + PSEUDO_REGION_START_LINE/2; // start_line
_dwGDIHeaders[2] = dwTmp + PSEUDO_REGION_HEIGHT/2; // end_line
_dwGDIHeaders[3] = _dwGDIHeaders[3] | (dwTmp<<9) | _dwGDIHeaders[2];
W99AV_WriteDRAMData(__dwRegionTAddr-1, _dwGDIHeaders[3]);
#else
dwTmp=__wGDIStartY+__RegionList[__bCurrentRegionId].wHeight/2;
_dwGDIHeaders[3]=( _dwGDIHeaders[3] | (((DWORD)__wGDIStartY)<<9) | ((DWORD)dwTmp) );
W99AV_WriteDRAMBurst(__RegionList[__bCurrentRegionId].dwTAddr+2, &_dwGDIHeaders[2], 2);
W99AV_WriteDRAMBurst(__RegionList[__bCurrentRegionId].dwBAddr+2, &_dwGDIHeaders[2], 2);
#endif
#endif //#ifndef NO_GDI
}
// *********************************************************************
// Function : GDI_SetMixRatio
// Description : This function sets the mix ratio of the current region
// Arguments : bMixRatio: the mix ratio, 0~63
// Return : none
// Side Effect :
// *********************************************************************
void GDI_SetMixRatio(BYTE bMixRatio)
{
#ifndef NO_GDI
if (__bCurrentRegionId >= NUMBER_OF_REGION)
return;
// CT908, MIX_RATIO is moved to Header3, bit [23:18]
#ifdef MINI_OSD_REGION // CT908S
W99AV_ReadDRAMData( __dwRegionTAddr+3, &_dwGDITemp );
#else
W99AV_ReadDRAMData( __RegionList[__bCurrentRegionId].dwTAddr+3, &_dwGDITemp );
#endif
_dwGDITemp = _dwGDITemp & 0xFF03FFFF;
_dwGDITemp = _dwGDITemp | ((DWORD)(bMixRatio) << 18);
#ifdef MINI_OSD_REGION // CT908S
W99AV_WriteDRAMBurst(__dwRegionTAddr+3, &_dwGDITemp, 1);
W99AV_WriteDRAMBurst(__dwRegionBAddr+3, &_dwGDITemp, 1);
#else
W99AV_WriteDRAMBurst(__RegionList[__bCurrentRegionId].dwTAddr+3, &_dwGDITemp, 1);
W99AV_WriteDRAMBurst(__RegionList[__bCurrentRegionId].dwBAddr+3, &_dwGDITemp, 1);
#endif
#endif //#ifndef NO_GDI
}
// *********************************************************************
// Function : GDI_DrawPixel
// Description : This function put a pixel in the current region
// Arguments : wX, wY: the position of the pixel
// bColor: the color index of the pixel.
// Return : none
// Side Effect :
// *********************************************************************
/*
void GDI_DrawPixel(WORD wX, WORD wY, BYTE bColor)
{
#ifndef NO_GDI
if (__bCurrentRegionId >= NUMBER_OF_REGION)
return;
if (wX >= __RegionList[__bCurrentRegionId].wWidth ||
wY >= __RegionList[__bCurrentRegionId].wHeight)
return; // the position is not in the area
switch (__RegionList[__bCurrentRegionId].bColorMode)
{
case 0: // 2-bit color, one BYTE contains 4 pixels
//_DrawPixel2(wX, wY, bColor);
break;
case 1: // 4-bit color, one BYTE contains 2 pixels
//_DrawPixel4(wX, wY, bColor);
break;
case 2: // 8-bit color, one BYTE contains 1 pixels
//_DrawPixel8(wX, wY, bColor);
break;
default:
break;
}
#endif //#ifndef NO_GDI
}
*/
#if IO == IO_PCI
void Swap(BYTE *bData)
{
BYTE bTemp;
bTemp = *bData;
*(bData) = *(bData+3);
*(bData+3) = bTemp;
bTemp = *(bData+2);
*(bData+2) = *(bData+1);
*(bData+1) = bTemp;
}
#endif //#if IO == IO_PCI
// *********************************************************************
// Function : GDI_ChangePALEntry
// Description : This function sets one palette entry
// Arguments : bIdx: the entry index
// dwRGB: the color value to set
// bMixEnable: TRUE/FALSE
// Return : none
// Side Effect :
// *********************************************************************
void GDI_ChangePALEntry(BYTE bIdx, DWORD dwRGB, BYTE bMixEnable)
{
#ifndef NO_GDI
// CT908, one palette entry uses one DWORD
// Brian.172r
// if the highest byte == 0x5A, the parameter is already in YCbCr format
if ((dwRGB & 0xFF000000 )== GDI_VALUE_YUV)
{
_dwGDITemp = (dwRGB & 0x000FFFFF); // it is YCbCr already
}
else
{
_dwGDITemp=COMUTL_RGB2YUV(dwRGB);
}
// enable the mix_en bit [19]
if (bMixEnable)
_dwGDITemp |= 0x80000;
else
_dwGDITemp &= 0xFFF7FFFF;
// set desired entry value
W99AV_WriteDRAMData(PAL_ADDR+bIdx, _dwGDITemp);
// enable W99AV_DRAM_NEW_LOAD_PAL flag in DRAM[0xAA]
W99AV_WriteDRAMData(W99AV_DRAM_NEW_LOAD_PAL, 0x10000);
#endif // #ifndef NO_GDI
}
// *********************************************************************
// Function : GDI_LoadPalette
// Description : This function loads the palette for the plane
// Arguments : bPaletteId: the palette ID.
//
// Return : none
// Side Effect :
// *********************************************************************
void GDI_LoadPalette(BYTE bPaletteId)
{
#ifndef NO_GDI
// Specify the start address of PAL_TABLE to DRAM[0x67]
//W99AV_WriteDRAMData(__PlaneList[bPlaneId].dwPalAddr_var, __PaletteList[bPaletteId].dwPalAddr );
W99AV_WriteDRAMData( W99AV_DRAM_FONTPAL_TBL_ADR, PAL_ADDR );
W99AV_WriteDRAMBurst( __PaletteList[bPaletteId].dwPalAddr+__PaletteList[bPaletteId].bStartNumber, __PaletteList[bPaletteId].pdwPalette+1, (WORD)(__PaletteList[bPaletteId].pdwPalette[0]));
// enable W99AV_DRAM_NEW_LOAD_PAL flag in DRAM[0xAA]
// each plane should have a seperate W99AV_DRAM_NEW_LOAD_PAL
// for now I just directly assign it
W99AV_WriteDRAMData(W99AV_DRAM_NEW_LOAD_PAL, 0x10000);
/*
//GDI_ChangePALEntry(1, 0xFFFFFF, FALSE);
GDI_ChangePALEntry(1, 0xE8E8E8, FALSE); // don't use pure white, the contrast will be too strong
GDI_ChangePALEntry(2, 0x7F7F00, FALSE);
GDI_ChangePALEntry(3, 0x007F00, FALSE);
//GDI_ChangePALEntry(4, 0x404040, FALSE); // anti-alias color
GDI_ChangePALEntry(4, 0x606060, FALSE); // anti-alias color
GDI_ChangePALEntry(5, 0xC0C0C0, FALSE); // anti-alias color
GDI_ChangePALEntry(6, 0x0000C0, TRUE);
GDI_ChangePALEntry(7, 0xE0E000, FALSE); // yellow
GDI_ChangePALEntry(8, 0x012FFF, TRUE);
GDI_ChangePALEntry(9, 0x909090, FALSE);
GDI_ChangePALEntry(10, 0xA0A0A0, FALSE);
//GDI_ChangePALEntry(11, 0x000000, FALSE);
GDI_ChangePALEntry(11, 0x404040, FALSE); // don't use pure black, the contrast will be too strong
//GDI_ChangePALEntry(12, 0xFF9C1D, TRUE); //orange color
GDI_ChangePALEntry(12, 0xFFFFFF, FALSE);
GDI_ChangePALEntry(13, 0xD8D8D8, FALSE);
GDI_ChangePALEntry(14, 0x010101, TRUE); // pure black
*/
#endif //#ifndef NO_GDI
}
// *********************************************************************
// Function : GDI_SetTextColor
// Description : This function selects the font of the current region
// Arguments : bFgBg: Specify where foreground or background is to set
// bColor: the color index
// Return : none
// Side Effect :
// *********************************************************************
void GDI_SetTextColor (BYTE bFgBg, BYTE bColor)
{
#ifndef NO_GDI
if (bFgBg == TEXT_BG_COLOR)
__bTextBgColor = bColor;
else if (bFgBg == TEXT_FG_COLOR)
__bTextFgColor = bColor;
else if (bFgBg == TEXT_SHADOW_COLOR_1)
__bShadowColor_1 = bColor;
else //if (FgBg == TEXT_SHADOW_COLOR_1)
__bShadowColor_2 = bColor;
#endif //#ifndef NO_GDI
}
#ifdef GDI_EMULATION
BYTE _GetFontBit2(WORD wIndex, BYTE bX, BYTE bY)
{
BYTE *pbFont;
//_bGDITemp = ((wIndex & 0xF000) >> 10); // get width ( >> 12 * 4)
wIndex = wIndex & 0x01FF; // get the index to table (bit 0~8)
// for variable size font, find the location of the char is a lousy job.
// Unless we still use fix width for the data storage.
_dwGDITemp2 = (DWORD)wIndex << 8; // each 2-bit font occupies 256 bytes.
pbFont = FontData +_dwGDITemp2;
//if (bIndex == 0)
// printf("index = %d\n", _dwGDITemp2);
_dwGDITemp2 = (((WORD)bY << 6) + (bX << 1)); // one data line occupies 64 bits
_bGDITemp = bX % 4;
_dwGDITemp2 = _dwGDITemp2 >> 3;
switch (_bGDITemp)
{
case 0: _dwGDIHeaders[3] = 0xC0;
wIndex = *(pbFont+_dwGDITemp2) & (BYTE)_dwGDIHeaders[3];
wIndex = wIndex >> 6;
break;
case 1: _dwGDIHeaders[3] = 0x30;
wIndex = *(pbFont+_dwGDITemp2) & (BYTE)_dwGDIHeaders[3];
wIndex = wIndex >> 4;
break;
case 2: _dwGDIHeaders[3] = 0x0C;
wIndex = *(pbFont+_dwGDITemp2) & (BYTE)_dwGDIHeaders[3];
wIndex = wIndex >> 2;
break;
case 3: _dwGDIHeaders[3] = 0x03;
wIndex = *(pbFont+_dwGDITemp2) & (BYTE)_dwGDIHeaders[3];
break;
}
return (BYTE)wIndex;
}
#endif //#ifdef GDI_EMULATION
// *********************************************************************
// Function : GDI_DrawString
// Description : This function output the text
// Arguments : none
// Global Var : __wGDIString[]: the array stores the char index
// __wGDIx, __wGDIy: the start oint(x, y)
// Return : none
// Side Effect :
// *********************************************************************
void GDI_DrawString(void) //WORD wX, WORD wY)
{
#ifndef NO_GDI
#ifndef GDI_EMULATION
GDI_DrawString_GXA();
#else
BYTE i, j, k, m, bWidth, bHeight, bTemp, bTemp1;
BYTE *pbFont, *pbBuffer;
WORD wCnt;
BYTE bMode, bStrLen;
GDI_DrawString_GXA();
return;
if (__wGDIString[0] > GDI_STRING_LENGTH)
{
return;
}
if (__bCurrentRegionId >= NUMBER_OF_REGION)
return;
if (__wGDIx >= __RegionList[__bCurrentRegionId].wWidth ||
__wGDIy >= __RegionList[__bCurrentRegionId].wHeight)
return; // the position is not in the area
// should also consider whether the end of the string is out of the region
//bStrLen = strlen(__bGDIString);
pbFont = FontData;
bHeight = GDI_GetStringHeight();
bMode = __RegionList[__bCurrentRegionId].bColorMode;
bStrLen = (BYTE)__wGDIString[0];
_dwGDITemp = ((DWORD)(__wGDIy/2)*__RegionList[__bCurrentRegionId].wWidth + __wGDIx);
// 256 color, one BYTE contains 1 pixel
bTemp = (BYTE)(_dwGDITemp% (1L << (4-bMode)));
_dwGDITemp = _dwGDITemp >> (4 - bMode) ; //Calculate which DRAM DWORD the pixel is located
for (i=0; i<bHeight; i++)
{
// check whether the line is in top or bottom field
// _dwGDIHeaders[0] contains the starting DWORD in DRAM for each line
if ((__wGDIy + i) % 2)
_dwGDIHeaders[0] = __RegionList[__bCurrentRegionId].dwBAddr+4+_dwGDITemp + ((DWORD)(i/2)*__RegionList[__bCurrentRegionId].wWidth>> (4 - bMode));
else
{
if (__wGDIy%2)
_dwGDIHeaders[0] = __RegionList[__bCurrentRegionId].dwTAddr+4+_dwGDITemp + ((DWORD)((i/2)+1)*__RegionList[__bCurrentRegionId].wWidth>> (4 - bMode));
else
_dwGDIHeaders[0] = __RegionList[__bCurrentRegionId].dwTAddr+4+_dwGDITemp + ((DWORD)(i/2)*__RegionList[__bCurrentRegionId].wWidth>> (4 - bMode));
}
wCnt = 0;
pbBuffer = __bPixelBuffer;
m=0;
if (bTemp) // the starting point is not on the DWORD bundary, so must read back the pixels (0, 1, 2) before it
{
W99AV_ReadDRAMData( _dwGDIHeaders[0], &_dwGDIHeaders[1] );
#if IO == IO_PCI
Swap((BYTE*)&_dwGDIHeaders[1]);
#endif
for (m=0; m<bTemp; m++)
{
switch (bMode)
{
case 0:
break;
case 1:
//_Get4Bits( ((BYTE *)&_dwGDIHeaders[1]) + m/2, wCnt%2, &bTemp1);
//_Put4Bits(pbBuffer, wCnt%2, bTemp1);
//if (wCnt%2)
// pbBuffer++;
break;
case 2:
*pbBuffer++ = *((BYTE*) (&_dwGDIHeaders[1]) + m);
break;
}
wCnt++;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -