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

📄 osd_midi.c

📁 Sunplus 8202S source code.
💻 C
📖 第 1 页 / 共 4 页
字号:
#ifdef SUPPORT_BIG5ANDGB_MIDI

BYTE MenuNumwidth[10] =
{
    16, 14, 16, 16, 16, 16, 16, 16, 16, 16, 
};
BYTE MenuABCwidth[26] =
{
    24, 20, 20, 20, 20, 20, 24, 24, 14, 18, 22, 20, 28, 24, 20, 20, 20, 22,
    18, 22, 24, 24, 28, 22, 24, 20, 
};
BYTE Menuabcwidth[26] =
{
    16, 16, 16, 16, 16, 16, 16, 18, 12, 14, 18, 12, 28, 20, 16, 16, 16, 16, 14,
    14, 18, 18, 24, 18, 18, 16, 
};

#else

BYTE MenuNumwidth[10] =
{
    13, 12, 15, 15, 16, 14, 15, 15, 15, 15, 
};
BYTE MenuABCwidth[26] =
{
    23, 20, 20, 20, 20, 20, 23, 23, 11, 17, 22, 19, 27, 24, 20, 20, 20, 22,
    18, 21, 23, 23, 27, 22, 23, 20, 
};
BYTE Menuabcwidth[26] =
{
    15, 16, 13, 16, 15, 15, 16, 17, 9, 12, 17, 16, 27, 19, 15, 15, 16, 13, 11,
    11, 18, 17, 23, 17, 17, 14, 
};

#endif


BYTE MenuFontcolor, MenuBgcolor, MenuFigureColor;

#define MENU_FONT_WIDTH (30)
#define MENU_OTHER_WIDTH (16)


//when change the OSD color of the Menu font base, call it
void MidiSetMenuFontColor(BYTE FontColor, BYTE BgColor, BYTE FigureColor)
{
    MenuFontcolor = FontColor;
    MenuBgcolor = BgColor;
    MenuFigureColor = FigureColor;
}

#endif 

#ifdef SUPPORT_GB_FONTBASE3
    /*********************************************************************
    //   ** function :search GB3 base font pointer; gb3font should be include in font3 base
    //   ** hzcode: GB code
    //   **FontBaseNo:for menu or lyric
     ***********************************************************************/
#define GB3_FONTBASE_FLAG   (0x10000000L) 
#define GB3_FONTBASE_NONFLAG (0x0fffffffL)//ouly use 28 bit for fontsize
#define GET_LONG_INT(p)         (((*((p)+3))<<24)|((*((p)+2))<<16)|((*((p)+1))<<8)|(*(p)))     
#define GET_SHORT_INT(p)    ((*((p)+1)<<8)|(*(p)))
#define GET_HZCODE(p)           ((UINT16)GET_SHORT_INT(p))
BYTE *midi_GetGB3Font(UINT16 hzcode,BYTE FontBaseNo)     
{
    BYTE * pfont3base =upGB3FontAddr;
    BYTE fontbase;
    BYTE *retpos;
    while ((*pfont3base)&&(upGB3FontEndPtr>pfont3base))
    {
        if ( GET_HZCODE(pfont3base)==hzcode)
        {
            fontbase = (((GET_LONG_INT(pfont3base+2))&(GB3_FONTBASE_FLAG))&&1); 
            if (!(fontbase^FontBaseNo))
            {
                retpos =pfont3base+6;
                return retpos;
            }else
            {
                pfont3base +=(GET_LONG_INT(pfont3base+2)&(GB3_FONTBASE_NONFLAG));
            }
        }else
        {
            pfont3base +=(GET_LONG_INT(pfont3base+2)&(GB3_FONTBASE_NONFLAG));
        }  
    }
    return 0;
}    
#endif

/********************************************************
    //Function :  Disp_Text_OSD Display the lyric on screen by OSD
    //int xx :the x position
    //int yy :the y position
    //char *Lyric:  the string of lyric
    //BYTE regNum OSD Number
    //int margin: uint --> pixel
    //uFontBase:  the font database NO.
    //Note   :  The Font size is 40*48 color 16
 ********************************************************/
#if 1
int Disp_Text_OSD(int xx, int yy, BYTE* Lyric, BYTE regNum, int margin,
    BYTE uFontBase, BYTE FontType,int endXEdge)
{
    int iRegionWidth = region[regNum].osd_w<<1; 
    BYTE* p = Lyric;
    UINT16 ch = 0;
    UINT16 x1, y1;
    UINT8 uFontWidth=0, uOtherWidth=0;
    BYTE Fontcolor=0, Bgcolor=0, FigureColor=0;  //,FontType
    BYTE* pabc_Width, * pABC_Width, * pNum_Width;
    BYTE FontHeight;
#ifdef SUPPORT_GB_FONTBASE3
    BYTE *gb3pos =0;
#endif
    if ((!endXEdge)||(endXEdge>(iRegionWidth -10)))
        endXEdge =iRegionWidth;
    printf("Disp_Text_OSD %s\n",Lyric);
    pabc_Width = pABC_Width = pNum_Width = (void *)(0);
    if (uFontBase == MIDI_LYRIC_FONTDEBASE)
    {
        uFontWidth = LYRIC_FONT_WIDTH ; 
        uOtherWidth = OTHER_FONT_WIDTH;
        FontHeight =LYRIC_FONT_HIGHT;

        Fontcolor = LyricFontcolor;
        Bgcolor = LyricBgcolor;
        FigureColor = LyricFigureColor;
        pabc_Width = abc_width;
        pABC_Width = ABC_width;
        pNum_Width = num_width;
    }
#ifdef MIDI_MENU_FONT
    else if (uFontBase == MIDI_MENU_FONTDEBASE)
    {
        uFontWidth = MENU_FONT_WIDTH ; //LYRIC_FONT_WIDTH;
        uOtherWidth = MENU_OTHER_WIDTH;//OTHER_FONT_WIDTH;
        FontHeight =30;

        Fontcolor = MenuFontcolor;
        Bgcolor = MenuBgcolor;
        FigureColor = MenuFigureColor;

        pabc_Width = Menuabcwidth;
        pABC_Width = MenuABCwidth;
        pNum_Width = MenuNumwidth;
	endXEdge -=10;
    }else
    {
        printf("error font base\n");
        return 0;
    }
#endif

    if (xx < 0)
        xx = 0;
    x1 = xx;
    y1 = yy;    
    while (*p == ' ')
        p++;

    //  osd_tog_region(regNum, OSD_ON);
    while (*p)
    {
        int iRes;
        BYTE c, c1;
        iRes = 0;
        c = *p;
        c1 = *(p + 1);
 #ifdef SUPPORT_GB_FONTBASE3
        
        if (((c  >= 0xA1 && c  < 0xD7 && c1 >= 0xA1 && c1 < 0xFF) ||
            (c  == 0xD7 && c1 >= 0xA1 && c1 < 0xFa))||
             (c  >= 0xD8 && c  < 0xF8 && c1 >= 0xA1 && c1 < 0xFF))
 #else
        if (c>0x80&&c1>0x80);
#endif
        {
            iRes = 2;
            p ++;
            if (iRegionWidth - x1 < 48) //
            {
                break;   //width is not enough break
        }
        }
 #ifdef SUPPORT_GB_FONTBASE3
        else if ((c > 0x80))//&&((c1>80)||(c1<80)))
        {
            UINT16 gbcode =(c<<8|c1);
            gb3pos =midi_GetGB3Font(gbcode,uFontBase);
            if (gb3pos)
            {
                iRes = 3;
                p ++;
                if (iRegionWidth - x1 < 48) //
                    break;   //width is not enough break
            }else
            {
                printf("search gb3base fail\n");
                p ++;
                iRes =0;
            }
        }    
#endif
        else if (((c >= 65) && (c <= 90)) ||     //A~Z
                 ((c >= 97) && (c <= 122)) ||    //a~z
                 ((c >= 192) && (c <= 223)) ||   //Europe characters
                 ((c >= 48) && (c <= 57)) || ((c >= 33) && (c <= 47)) //digit numbers //ouyang 2004.07.31
                 ||(c ==':'))      				//interpunction //ouyang 2004.07.31
        {
            c1 = c + 0x80;
            c = 0x03 + 0xa0;
            iRes = 2;
        }
        else
        {
            switch (c)
            {
            case ' ':
                iRes = 1;
                break;
            default:
                iRes = 0;
                break;
            }
        }

        if (iRes == 0)
            c = ' ';
        if (iRes == 2)
        {
            //          if (c!=0xa3)
            {
                if (((endXEdge - x1) < (uFontWidth))||((iRegionWidth - x1) < (uFontWidth)))  //LYRIC_FONT_WIDTH
                {
                    //xlluo add a mend here                 //2004-11-26
                        break;
                }
            }
            ch = (c << 8) | (c1);   
            osd_midi_DrawHZ_Mem(x1, y1, ch, Fontcolor, Bgcolor,
                FigureColor, FontType, regNum, uFontBase);  //fontcolor, bgcolor,
            if (c == 0xa3)
                    {
                        int xtemp;
                        if (c1 >= 0xe1 && c1 <= 0xfa)
                    x1 += pabc_Width[c1 - 0xe1];//+margin;
                        else if ((c1 >= 0xc1) && (c1 <= 0xda))
                    x1 += pABC_Width[c1 - 0xc1];//+margin;
                        else if ((c1 > 0xaf) && (c1 < 0xba))
                        {
                    x1 += pNum_Width[c1 - 0xb0] + margin;
                        }
                        else
                        {
                    x1 += uOtherWidth;  //OTHER_FONT_WIDTH
                        }
                        }
            else
                        {
                x1 += (uFontWidth) + margin;        //LYRIC_FONT_WIDTH
            }
        }
 #ifdef SUPPORT_GB_FONTBASE3
        else if (iRes == 3)
        {
            {
                if (((endXEdge - x1) < (uFontWidth))||((iRegionWidth - x1) < (uFontWidth)))  //LYRIC_FONT_WIDTH
                {
                    break;   //width is not enough break
                }
            }        
            draw_midi_bitmap_HZnew(gb3pos,x1, y1<<1, Fontcolor, Bgcolor,FigureColor, FontType, regNum);
            x1 += (uFontWidth) + margin;        //LYRIC_FONT_WIDTH
                        }    
#endif
        else
        {
            if (((endXEdge - x1) < (uOtherWidth))||((iRegionWidth - x1) < (uOtherWidth)))  // LYRIC_FONT_WIDTH
                break;   //width is not enough break
#if 0 //def SUPPORT_SANJING_WIDESAPCE                //xlluo for sj space 04-10-15
            Osd_Clear_Rect(x1,  yy, uOtherWidth+3,FontHeight,Bgcolor,regNum);
            x1 += uOtherWidth; //OTHER_FONT_WIDTH
#else
            if ((c == ' ') && (*(p - 1) != ' '))
            {
		if (uFontBase == MIDI_MENU_FONTDEBASE)   
		{     
			int wspace = uOtherWidth+3;
			if (((endXEdge - x1) < (uFontWidth))||((iRegionWidth - x1) < (uFontWidth)))
			wspace = endXEdge-x1;
			Osd_Clear_Rect(x1,  yy, wspace,FontHeight,Bgcolor,regNum);
			x1 += wspace-3; //OTHER_FONT_WIDTH
                    }else
		{
			Osd_Clear_Rect(x1,  yy, uOtherWidth+3,FontHeight,Bgcolor,regNum);
			x1 += uOtherWidth; //OTHER_FONT_WIDTH
		}
            }
#endif
        }
        p++;
    }
    osd_tog_region(regNum, OSD_ON);
    return x1;
}
#else
int Disp_Text_OSD(int xx, int yy, BYTE* Lyric, BYTE regNum, int margin,
    BYTE uFontBase, BYTE FontType,int endXEdge)
{
    int iRegionWidth = region[regNum].osd_w<<1; 
    BYTE* p = Lyric;
    UINT16 ch = 0;
    UINT16 x1, y1;
    UINT8 uFontWidth=0, uOtherWidth=0;
    BYTE Fontcolor=0, Bgcolor=0, FigureColor=0;  //,FontType
    BYTE* pabc_Width, * pABC_Width, * pNum_Width;
    BYTE FontHeight;
#ifdef SUPPORT_GB_FONTBASE3
    BYTE *gb3pos =0;
#endif
    if (!endXEdge)
        endXEdge =iRegionWidth;
    printf("Disp_Text_OSD %s\n",Lyric);
    pabc_Width = pABC_Width = pNum_Width = (void *)(0);
    if (uFontBase == MIDI_LYRIC_FONTDEBASE)
    {
        uFontWidth = LYRIC_FONT_WIDTH ; 
        uOtherWidth = OTHER_FONT_WIDTH;
        FontHeight =LYRIC_FONT_HIGHT;

        Fontcolor = LyricFontcolor;
        Bgcolor = LyricBgcolor;
        FigureColor = LyricFigureColor;
        pabc_Width = abc_width;
        pABC_Width = ABC_width;
        pNum_Width = num_width;
    }
#ifdef MIDI_MENU_FONT
    else if (uFontBase == MIDI_MENU_FONTDEBASE)
    {
        uFontWidth = MENU_FONT_WIDTH ; //LYRIC_FONT_WIDTH;
        uOtherWidth = MENU_OTHER_WIDTH;//OTHER_FONT_WIDTH;
        FontHeight =30;

        Fontcolor = MenuFontcolor;
        Bgcolor = MenuBgcolor;
        FigureColor = MenuFigureColor;

        pabc_Width = Menuabcwidth;
        pABC_Width = MenuABCwidth;
        pNum_Width = MenuNumwidth;
    }else
    {
        printf("error font base\n");
        return 0;
    }
#endif

    if (xx < 0)
        xx = 0;
    x1 = xx;
    y1 = yy;    
    while (*p == ' ')
        p++;

    //  osd_tog_region(regNum, OSD_ON);
    while (*p)
    {
        int iRes;
        BYTE c, c1;
        iRes = 0;
        c = *p;
        c1 = *(p + 1);
 #ifdef SUPPORT_GB_FONTBASE3
        
        if (((c  >= 0xA1 && c  < 0xD7 && c1 >= 0xA1 && c1 < 0xFF) ||
            (c  == 0xD7 && c1 >= 0xA1 && c1 < 0xFa))||
             (c  >= 0xD8 && c  < 0xF8 && c1 >= 0xA1 && c1 < 0xFF))
 #else
        if (c>0x80&&c1>0x80);
#endif
        {
            iRes = 2;
            p ++;
            if (iRegionWidth - x1 < 48) //
                break;   //width is not enough break
        }
 #ifdef SUPPORT_GB_FONTBASE3
        else if ((c > 0x80))//&&((c1>80)||(c1<80)))
        {
            UINT16 gbcode =(c<<8|c1);
            gb3pos =midi_GetGB3Font(gbcode,uFontBase);
            if (gb3pos)
                    {
                iRes = 3;
                p ++;
                if (iRegionWidth - x1 < 48) //
                    break;   //width is not enough break
            }else
            {
                printf("search gb3base fail\n");
                p ++;
                iRes =0;
            }
        }    
#endif
        else if (((c >= 65) && (c <= 90)) ||     //A~Z
                 ((c >= 97) && (c <= 122)) ||    //a~z
                 ((c >= 192) && (c <= 223)) ||   //Europe characters
                 ((c >= 48) && (c <= 57)) || ((c >= 33) && (c <= 47)) //digit numbers //ouyang 2004.07.31
                 ||(c ==':'))      				//interpunction //ouyang 2004.07.31
        {
            c1 = c + 0x80;
            c = 0x03 + 0xa0;
            iRes = 2;
        }
        else
        {
            switch (c)
            {
            case ' ':
                iRes = 1;
                break;
            default:
                iRes = 0;
                        break;
                    }    
                }

        if (iRes == 0)
            c = ' ';
        if (iRes == 2)
        {
            //          if (c!=0xa3)
            {
                if (((endXEdge - x1) < (uFontWidth))||((iRegionWidth - x1) < (uFontWidth)))  //LYRIC_FONT_WIDTH
                {
                    //                  ulLineTotalColumns[(cLineDisp^1)] = x1;
                 //   printf("ulLineTotalColumns ==%d\n", x1);
                    break;   //width is not enough break
                }
            }
            ch = (c << 8) | (c1);   
            osd_midi_DrawHZ_Mem(x1, y1, ch, Fontcolor, Bgcolor,
                FigureColor, FontType, regNum, uFontBase);  //fontcolor, bgcolor,

            if (c == 0xa3)
            {

⌨️ 快捷键说明

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