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

📄 osd1.c

📁 Sunplus 8202S source code.
💻 C
📖 第 1 页 / 共 5 页
字号:

Creator: zhaoyanhua 
Date: 2003-8-18 11:46
****************************************/
void MoveString2Buf(BYTE xStart, BYTE yStart,BYTE * str, BYTE fontColor, BYTE bkColor)
{
    BYTE    c;
    BYTE    *pFont;
    UINT32  *pTopLine, *pBtmLine;
    int     cc;
    UINT32  iStrLoc;
    int     iRegionWidth;
    UINT32  *buf;

    cc = xStart*16;//pixels.
    iRegionWidth = region[SETUP_REGION].osd_w;

    // initialize buffer start
    //pTopLine = (UINT32 *)get_osdbuf_region_ptr(SETUP_REGION, 0);
    //pBtmLine = (UINT32 *)get_osdbuf_region_ptr(SETUP_REGION, 1);
     buf= (UINT32 *)(SDRAM_BASE + P_BIDIR_LUMA*1024 + (yStart*SETUP_BTN_HEIGHT+4)*iRegionWidth+ xStart);     

    //process each charactor until string ending('\0')
    iStrLoc = 0;
    while ((c = ((BYTE *)str)[iStrLoc]) != '\0')
    {
        int     i, j, k;
        int     iFontWidth, iFontHigh;
        UINT32  pos;
        
        
        iStrLoc++;
        
        if (c == '\r') {                    //prefix characher: to use font_table2
            if ( (c = ((BYTE *)str)[iStrLoc])=='\0' ) break;
            iStrLoc++;
            if ((pFont = get_font_entry(1,c))==NULL) continue;
        } else {
            //get current char entry
            pFont = get_font_entry(0,c);
        }
        
        //start to process
        pos = 2;
        
        //get font information
        iFontWidth = (int)pFont[0];
        iFontHigh  = (int)pFont[1];
        
        //start this character
        for (j=0; j<iFontHigh; j++) {
            UINT32 *pp;
            int     yy;
            int     iDispLoc;

            yy  = j;
            iDispLoc = yy*(iRegionWidth/4) + (cc/8);
            
            //draw top line
            for (i=0; i<iFontWidth/8; i++) {
                unsigned pat;
                unsigned curByte;
                UINT32 pixel8;
                
                pat = pFont[++pos];
                curByte = ((pat&0xc0)>>6) | ((pat&0x30)>>2) | ((pat&0x0c)<<2) | ((pat&0x03)<<6);
                pixel8 = 0;
                for (k=0; k<8; k++) {       // for every-bit of pattern
                    if ( (1<<k) & curByte ) {          
                        pixel8 = pixel8 | (fontColor<<(k*4));
                    } else {
                        pixel8 = pixel8 | (bkColor<<(k*4));
                    }
                }
              //pp[iDispLoc+i] = pixel8;
               buf[iDispLoc+i] = pixel8;
            }
        }
        cc+=iFontWidth; 
    }
    
    timeout_osd[SETUP_REGION] = 0;
    osd_tog_region(SETUP_REGION, OSD_ON);   
}


extern BYTE setupItemNum[3];
//
// Bytes/Line = 37*16*4/8 = 296
//
/****************************************
FUNC:  
        draw the data to the SCREEN from 
        BUFFER
        
        BUF: P_BIDIR_LUMA

        EFFECT MODE: h_window .
    INPUT: 
        xStart:
        xEnd  :  unit is char.
        
Creator :zhaoyanhua 
Date:    2003-8-18 11:51        
*****************************************/
void MoveBuf2OSD(UINT16 xStart, UINT16 xEnd)
{
    UINT32  *buf;
    UINT32  *pTopLine, *pBtmLine;
    BYTE    i,step;
    UINT32  j, k;   
    UINT16  ButtonHight;//one BUTTON HIGHT.
    
    osd_tog_region(SETUP_REGION, OSD_ON);  


    buf = (UINT32 *)(SDRAM_BASE + P_BIDIR_LUMA*1024 );    
    //buf = (UINT32 *)(osd_temp_buf);
    
    //initialize buffer start    
    pTopLine = (UINT32 *)get_osdbuf_region_ptr(SETUP_REGION,0);
    pBtmLine = (UINT32 *)get_osdbuf_region_ptr(SETUP_REGION,1);

    //end=iLine;
    ButtonHight = 32;
    step=1;
    if(p_scan==0)
    {
       
       ButtonHight = 16;
       step=2;
    }
    else
    {
        ButtonHight = 32;
        step=1;
        
    }
    #if 0 //2 BUTTON cocurrently display.
    int m;
    printf("setupItemNum=%d\n",setupItemNum[1]);
    for (i = 0; i<ButtonHight; i++)//for (i = 0; i<32/2; i++)
    {
        delay_1ms(10);
        for (m =0; m < (setupItemNum[1]-1); m+=2)  
        {
           //NOTE:  
           //      xStart*16        : pixels
           //      xStart*16*4      : bits, one pixel 4 bits.
           //      (xStart*16*4)/8  : bytes.
           //      ((xStart*16*4)/8)/4  : bytes. unit is 4 BYTES.   
            for(j = ((xStart*16*4)/8)/4; j < ((xEnd*16*4)/8)/4; j++)//for(j = ((12)*16*4)/(8*4) ; j < ((12)*16*4)/(8*4)+((15)*16*4)/(8*4) ;j++)
            {// for (j=0; j<76; j++) {
       
               k = step * (m*ButtonHight +i);
               //top area
               pTopLine[76*(m*ButtonHight +i)+j] = buf[76*k + j];
               //bottom area
               pBtmLine[76*(m*ButtonHight +i)+j] = buf[76*(k+1) + j];            
            
            }            
        }
    }
    #endif
    
    #if 1 //1 BUTTON
    int m;
       //printf("setupItemNum=%d\n",setupItemNum[1]);
    
    for (i = 0; i<ButtonHight; i++)//for (i = 0; i<32/2; i++)
    {
        delay_1ms(15);
        for (m =0; m < (setupItemNum[1]-1); m++)  
        {
            //NOTE:  
           //      xStart*16        : pixels
           //      xStart*16*4      : bits, one pixel 4 bits.
           //      (xStart*16*4)/8  : bytes.
           //      ((xStart*16*4)/8)/4  : bytes. unit is 4 BYTES.   
            for(j = ((xStart*16*4)/8)/4; j < ((xEnd*16*4)/8)/4; j++)//for(j = ((12)*16*4)/(8*4) ; j < ((12)*16*4)/(8*4)+((15)*16*4)/(8*4) ;j++)
            {// for (j=0; j<76; j++) 
                k = step * (m*ButtonHight +i);
               //top area
                pTopLine[76*(m*ButtonHight +i)+j] = buf[76*k + j];
                //bottom area
                pBtmLine[76*(m*ButtonHight +i)+j] = buf[76*(k+1) + j];            
            
            }            
        }
    }
    #endif

    
    #if 0//Roll display
    for (i=iStartLine; i<iEndLine; i++) 
    {
       // k = 24-iLine+step*i;
        k = step*i;
        //NOTE:  
           //      xStart*16        : pixels
           //      xStart*16*4      : bits, one pixel 4 bits.
           //      (xStart*16*4)/8  : bytes.
           //      ((xStart*16*4)/8)/4  : bytes. unit is 4 BYTES.   
        for(j = ((xStart*16*4)/8)/4; j < ((xEnd*16*4)/8)/4; j++)
        {// for (j=0; j<76; j++) {
            //top area
            pTopLine[76*i+j] = buf[76*k + j];
            //bottom area
            pBtmLine[76*i+j] = buf[76*(k+1) + j];
            
        }
    }
   #endif
    
    
}
#endif

//
// osd_DrawString
//

#ifdef SOFT_MENU//Modifed by ChenZhao on 2004-9-6 10:43 WP
void osd_DrawString(BYTE xStart, BYTE yStart, const BYTE *str, BYTE fontColor, BYTE bkColor)
{
    osd_DrawString_ori(xStart*8, (yStart*SETUP_BUTTON_HEIGHT), str, fontColor, bkColor);
}
#else
void osd_DrawString(BYTE xStart, BYTE yStart, const BYTE *str, BYTE fontColor, BYTE bkColor)
{
    osd_DrawString_ori(xStart, (yStart*SETUP_BTN_HEIGHT), str, fontColor, bkColor);
}
#endif//SOFT_MENU

#ifdef SETUPMENU_16Mb_NO_ICON
void osd_DrawSetupIconString(BYTE xStart, BYTE yStart, const BYTE *str, BYTE fontColor, BYTE bkColor)
{
    osd_DrawString_ori(xStart, yStart, str, fontColor, bkColor);
}
#endif//SETUPMENU_16Mb_NO_ICON

#ifdef SOFT_MENU//Modifed by ChenZhao on 2004-9-6 10:43 WP
	#include"osd_SFM.c"
	
#elif defined(USE_SMALL_FONT)
//libing for small font 2005-1-5 20:52
void
osd_DrawString_ori(BYTE xStart, UINT32 yStart, const BYTE *str, BYTE fontColor, BYTE bkColor)
{
//libing modify it for zhe smaller font 2004-11-3 13:53
    BYTE    c;
    BYTE    *pFont;
    UINT16  *pTopLine, *pBtmLine;
    int     cc;
    UINT32  iStrLoc;
    int     iRegionWidth;
    iRegionWidth = region[SETUP_REGION].osd_w;
    pTopLine = (UINT16 *)get_osdbuf_region_ptr(SETUP_REGION, 0);
    pBtmLine = (UINT16 *)get_osdbuf_region_ptr(SETUP_REGION, 1);
    cc = xStart*16; 
    iStrLoc = 0;
    while ((c = ((BYTE *)str)[iStrLoc]) != '\0')
    {
        int     i, j, k;
        int     iFontWidth, iFontHigh;
        UINT32  pos;
        UINT8   fourbit;
        iStrLoc++;
        
        if (c == '\r') {                   
            if ( (c = ((BYTE *)str)[iStrLoc])=='\0' ) break;
            iStrLoc++;
            if ((pFont = get_font_entry(1,c))==NULL) continue;
        } else {
            pFont = get_font_entry(0,c);
        }
        pos = 2;
        iFontWidth = (int)pFont[0];
        iFontHigh  = (int)pFont[1];
        fourbit=1;
        //if(p_scan==0)    iFontHigh>>=1;
        for (j=0; j<iFontHigh; j++) {
            UINT16 *pp;
            int     yy;
            int     iDispLoc;
            yy  = 4 + yStart + j;
            pp  = (yy&1) ? pBtmLine : pTopLine;
            if (p_scan==0) yy>>=1;     
            iDispLoc = yy*(iRegionWidth/2) + (cc/4);
            {            	
            for (i=0; i<iFontWidth/4; i++)
              {
                unsigned pat;
                unsigned curByte;
                UINT16 pixel4;
                if(fourbit)
                {                    
                    pat = (pFont[++pos])&0xf0;
                    fourbit=0;
                }
                else
                {                    
                    pat = (pFont[pos])<<4;
                    fourbit=1;
                }
                curByte = ((pat&0xc0)>>6) | ((pat&0x30)>>2);
                pixel4 = 0;//pTopLine[iDispLoc+i];
                for (k=0; k<4; k++) {       
                    if ((1<<k) & curByte)
                    {          
                        pixel4 = pixel4 | (fontColor<<(k*4));
                    } else {
                        pixel4 = pixel4 | (bkColor<<(k*4));
                    }

                }
                pp[iDispLoc+i] = pixel4;
             }
         }
    }   cc+=iFontWidth; 
    }
    timeout_osd[SETUP_REGION] = 0;
    osd_tog_region(SETUP_REGION, OSD_ON);  
}	
	
#else

void
osd_DrawString_ori(BYTE xStart, UINT32 yStart, const BYTE *str, BYTE fontColor, BYTE bkColor)
{
    BYTE    c;
    BYTE    *pFont;
    UINT32  *pTopLine, *pBtmLine;
    int     cc;
    UINT32  iStrLoc;
    int     iRegionWidth;

    iRegionWidth = region[SETUP_REGION].osd_w;

    // initialize buffer start
    pTopLine = (UINT32 *)get_osdbuf_region_ptr(SETUP_REGION, 0);
    pBtmLine = (UINT32 *)get_osdbuf_region_ptr(SETUP_REGION, 1);
    
    // initialize start position
    cc = xStart*16; //pixels

    //process each charactor until string ending('\0')
    iStrLoc = 0;
    while ((c = ((BYTE *)str)[iStrLoc]) != '\0')
    {
        int     i, j, k;
        int     iFontWidth, iFontHigh;
        UINT32  pos;
        
        iStrLoc++;
        
        if (c == '\r') {                    //prefix characher: to use font_table2
            if ( (c = ((BYTE *)str)[iStrLoc])=='\0' ) break;
            iStrLoc++;
            if ((pFont = get_font_entry(1,c))==NULL) continue;
        } else {
            //get current char entry
            pFont = get_font_entry(0,c);
        }
        
        //start to process
        pos = 2;
        
        //get font information
        iFontWidth = (int)pFont[0];
        iFontHigh  = (int)pFont[1];
        
        //start this character
        for (j=0; j<iFontHigh; j++) {
            UINT32 *pp;
            int     yy;
            int     iDispLoc;
//			#ifdef OP_UI//liwh add 2004-3-19 16:01
//			#include "menu_def.h"
//			yy  = 10 + yStart*(BUTTON_Y_DIFF) + j;
//			#else
            //yy  = 4 + yStart*SETUP_BTN_HEIGHT + j;
            yy  = 4 + yStart + j;
//            #endif
            //For every string line = 1 blank line(in pixel) + OSD_FONT_HEIGHT-line strings + 1 blank line
            pp  = (yy&1) ? pBtm

⌨️ 快捷键说明

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