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

📄 osdtest.c

📁 GM5621原代码
💻 C
📖 第 1 页 / 共 3 页
字号:
    {
        num =  ((FONT_X < 9)? FONT_Y       : (FONT_X < 17)? 2 * FONT_Y : 3 * FONT_Y);
    }
    else // TBL4BPP
    {
        num =  ((FONT_X == 12)? 3*FONT_Y : 4*FONT_Y);
    }

    gm_Print( "Number of bytes per font: %d", (WORD)num*2);
    return num*2;
}

static void CreateFont( BYTE bpp, WORD addr )
{
    BYTE *ccfAddr = (BYTE*)addr;
    WORD size = BYTES_PER_FONT(bpp);
//    WORD fontx = FONT_X;
    WORD fonty = FONT_Y;
    WORD bytes_line = size/FONT_Y;

    if ( bpp == 1 )
    {
        while (fonty--) 
        {
            BYTE bline = bytes_line;
//            BYTE pat = 0;
            while (bline--)
            {
                *ccfAddr++ =  0xFF;
            }
        }
    }

    else if ( bpp == 2 )
    {
        while (fonty--)
        {
            BYTE bline = bytes_line;
//            BYTE pat = 0;
            while (bline--)
            {
                *ccfAddr++ =  0x12;
                *ccfAddr++ =  0x34;
            }
        }
    }
    else if ( bpp == 4 )
    {
        while (fonty--)
        {
            BYTE bline = bytes_line/4;
//            BYTE pat = 0;
            while (bline--)
            {
                *ccfAddr++ =  0x12;
                *ccfAddr++ =  0x34;
                *ccfAddr++ =  0x56;
                *ccfAddr++ =  0x78;
            }
        }
    }
}


void TestOsdHwFeatures( BYTE fontX, BYTE fontY )
{

    if ( fontX == 20 )
    {
        // Toggle the second rectangle which is placed at 0th line.
        // OSD rectangles disturbed when enabling the rectangle placed at top
        BYTE status = gm_ReadRegByte(OSD_ENABLES);

        if ( status & OSD_REC2_EN )
        {
            HideOsd();
        }
        else
        {
            ShowOsd();
        }
        return;
    }

	gm_WriteRegByte( CCF_TESTREG, gm_ReadRegByte(CCF_TESTREG/*0x82ae*/) | (BIT5|BIT6) ); // 4bpp fix as suggested by hw team

	gm_WriteRegByte(OSD_ENABLES, GL_OSD_EN);
	gm_WriteRegByte(OSD_CONTROL, 0x0);
	updateHost();


    /////////////////////////////////////////
    //      OSD Rectangle 1
    /////////////////////////////////////////

    RectangleID = 0;

    OSD_SIZE_X      = 15;
    OSD_SIZE_Y      = 10;
    FONT_X          = fontX;
    FONT_Y          = fontY;
    AddrCCF         = 4096+2000; //300
    AddrFont1BPP    = 4396+2000; //320
    AddrFontX1BPP   = 4716+2000; //320
    AddrFont2BPP    = 5036+2000; //640
    AddrFont4BPP    = 5676+2000; //1280
    AddrAttr        = 6956+2000; //

    // Load 256 colors
    LoadColor(0,   	    16, ClutPage1);
    LoadColor(1*16, 	16, ClutPage2);
    LoadColor(2*16,     16, ClutPage1);
    LoadColor(3*16, 	16, ClutPage2);
    LoadColor(4*16,     16, ClutPage1);
    LoadColor(5*16, 	16, ClutPage2);
    LoadColor(6*16,     16, ClutPage1);
    LoadColor(7*16, 	16, ClutPage2);
    LoadColor(8*16,     16, ClutPage1);
    LoadColor(9*16, 	16, ClutPage2);
    LoadColor(10*16,    16, ClutPage1);
    LoadColor(11*16,    16, ClutPage2);
    LoadColor(12*16,    16, ClutPage1);
    LoadColor(13*16,    16, ClutPage2);
    LoadColor(14*16,    16, ClutPage1);
    LoadColor(15*16,    16, ClutPage2);

    // Load Attributes
    LoadAttribs(0,   4, AttrData1bpp);
    LoadAttribs(64,  4, AttrData1bpp);
    LoadAttribs(128, 4, AttrData2bpp);
    LoadAttribs(192, 4, AttrData4bpp);

    // Create space character
    //          bpp, addr
    FillCCF (AddrFont1BPP,  0, BYTES_PER_FONT(1));
    FillCCF (AddrFontX1BPP, 0, BYTES_PER_FONT(1));
    FillCCF (AddrFont2BPP,  0, BYTES_PER_FONT(2));
    FillCCF (AddrFont4BPP , 0, BYTES_PER_FONT(4));

    // Load sample patterns : bpp, addr
    CreateFont( 1, AddrFont1BPP +BYTES_PER_FONT(1) );
    CreateFont( 1, AddrFontX1BPP+BYTES_PER_FONT(1) );
    CreateFont( 2, AddrFont2BPP +BYTES_PER_FONT(2) );
    CreateFont( 4, AddrFont4BPP +BYTES_PER_FONT(4) );

/*
    LoadCCF ( AddrFont1BPP +BYTES_PER_FONT(1), Icon1BPP, 1*BYTES_PER_FONT(1) ); // 1bpp icon at index 1
    LoadCCF ( AddrFontX1BPP+BYTES_PER_FONT(1), Icon1BPP, 1*BYTES_PER_FONT(1) ); // 1xbpp icon at index1
    LoadCCF ( AddrFont2BPP +BYTES_PER_FONT(2), Icon2BPP, 1*BYTES_PER_FONT(2) ); // 2bpp icon at index 1
    LoadCCF ( AddrFont4BPP +BYTES_PER_FONT(4), Icon4BPP, 1*BYTES_PER_FONT(4) ); // 4bpp icon at index 1
*/
    // show blank OSD
    RectSetup ();
    PositionOsd (500, 500, 0);
    FillCCF (AddrCCF, 0, OSD_SIZE_X*OSD_SIZE_Y);

    ShowOsd();

#if 0
    // set color windows - idWindow, color, xPixel, yPixel, width, height
    SetColorWin(0, 3, 32, 20, 20, 24); // color window on 1bpp icon
    SetColorWin(1, 3, 96, 20, 20, 24); // color window on 2bpp icon
    SetColorWin(2, 3, 32, 68, 20, 24); // color window on 1xbpp icon
    SetColorWin(3, 3, 96, 68, 20, 24); // color window on 4bpp icon
#endif


#if 0
    // Display 1bpp icon - x,y,charidx, attrib, bpp
    PutChar (1, 1, 1, 0, 0 );
    PutChar (2, 1, 2, 0, 0 );
    PutChar (3, 1, 3, 0, 0 );
    PutChar (1, 2, 4, 0, 0 );
    PutChar (2, 2, 5, 0, 0 );
    PutChar (3, 2, 6, 0, 0 );
#endif


#if 0
    // Display 2bpp icon - x,y,charidx, attrib, bpp
    PutChar (5, 1, 1, 0, 2 );
    PutChar (6, 1, 2, 0, 2 );
    PutChar (7, 1, 3, 0, 2 );
    PutChar (5, 2, 4, 0, 2 );
    PutChar (6, 2, 5, 0, 2 );
    PutChar (7, 2, 6, 0, 2 );
#endif


#if 0
    // Display 1xbpp icon - x,y,charidx, attrib, bpp
    PutChar (1, 5, 1, 0, 1 );
    PutChar (2, 5, 2, 0, 1 );
    PutChar (3, 5, 3, 0, 1 );
    PutChar (1, 6, 4, 0, 1 );
    PutChar (2, 6, 5, 0, 1 );
    PutChar (3, 6, 6, 0, 1 );
#endif
    PutChar (1, 0, 1, 0, 1 );
    PutChar (3, 0, 1, 0, 1 );
    PutChar (5, 0, 1, 0, 1 );
    PutChar (7, 0, 1, 0, 1 );
    PutChar (9, 0, 1, 0, 1 );
    PutChar (11,0, 1, 0, 1 );
    PutChar (13,0, 1, 0, 1 );

    PutChar (0, 1, 1, 0, 1 );
    PutChar (0, 3, 1, 0, 1 );
    PutChar (0, 5, 1, 0, 1 );
    PutChar (0, 7, 1, 0, 1 );
    PutChar (0, 9, 1, 0, 1 );

#if 0
    // Display 4bpp icon - x,y,charidx, attrib, bpp
//    PutChar (5, 5, 1, 0, 3 );
//    PutChar (6, 5, 2, 0, 3 );
//    PutChar (7, 5, 3, 0, 3 );
//    PutChar (5, 6, 4, 0, 3 );
//    PutChar (6, 6, 5, 0, 3 );
//    PutChar (7, 6, 6, 0, 3 );

//      PutChar (5, 5, 1, 0, 3 );
//      PutChar (6, 5, 2, 0, 3 );
//      PutChar (7, 5, 4, 0, 3 );
/*
    PutChar (5, 4, 1, 0, 3 );
    PutChar (7, 4, 1, 0, 3 );
    PutChar (8, 4, 1, 0, 3 );
    PutChar (9, 4, 1, 0, 3 );
    PutChar (10, 4, 1, 0, 3 );
    PutChar (11, 4, 1, 0, 3 );
    PutChar (12, 4, 1, 0, 3 );
    PutChar (13, 4, 1, 0, 3 );
    PutChar (14, 4, 1, 0, 3 );

    PutChar (5, 5, 1, 0, 3 );
    PutChar (6, 5, 1, 0, 3 );
*/
    { 
        BYTE row = 1;

    PutChar (1, row, 1, 0, 3 );

/*  PutChar (1, row, 1, 0, 3 );
    PutChar (2, row, 1, 0, 3 );
    PutChar (3, row, 1, 0, 3 );
    PutChar (4, row, 1, 0, 3 );
    PutChar (5, row, 1, 0, 3 );
    PutChar (6, row, 1, 0, 3 );
    PutChar (7, row, 1, 0, 3 );
    PutChar (8, row, 1, 0, 3 );
 */
//   PutChar (9, row, 1, 0, 3 );

    PutChar (10, row, 1, 0, 3 );
    PutChar (11, row, 1, 0, 3 );
    PutChar (12, row, 1, 0, 3 );

    }

#endif

    /////////////////////////////////////////
    //      OSD Rectangle 2
    /////////////////////////////////////////

    RectangleID = 1;

//    AddrCCF         = 0x1B00;
    RectSetup ();
    PositionOsd (100, 0, 0);
//    FillCCF (AddrCCF, 0, OSD_SIZE_X*OSD_SIZE_Y);
    ShowOsd();
return;
#if 0
    // Display 1bpp icon - x,y,charidx, attrib, bpp
    PutChar (1, 1, 1, 0, 0 );
    PutChar (2, 1, 2, 0, 0 );
    PutChar (3, 1, 3, 0, 0 );
    PutChar (1, 2, 4, 0, 0 );
    PutChar (2, 2, 5, 0, 0 );
    PutChar (3, 2, 6, 0, 0 );


    // Display 2bpp icon - x,y,charidx, attrib, bpp
    PutChar (5, 1, 1, 0, 2 );
    PutChar (6, 1, 2, 0, 2 );
    PutChar (7, 1, 3, 0, 2 );
    PutChar (5, 2, 4, 0, 2 );
    PutChar (6, 2, 5, 0, 2 );
    PutChar (7, 2, 6, 0, 2 );

    // Display 1xbpp icon - x,y,charidx, attrib, bpp
    PutChar (1, 4, 1, 1, 1 );
    PutChar (2, 4, 2, 1, 1 );
    PutChar (3, 4, 3, 1, 1 );
    PutChar (1, 5, 4, 1, 1 );
    PutChar (2, 5, 5, 1, 1 );
    PutChar (3, 5, 6, 1, 1 );

    // Display 4bpp icon - x,y,charidx, attrib, bpp
    PutChar (5, 4, 1, 0, 3 );
    PutChar (6, 4, 2, 0, 3 );
    PutChar (7, 4, 3, 0, 3 );
    PutChar (5, 5, 4, 0, 3 );
    PutChar (6, 5, 5, 0, 3 );
    PutChar (7, 5, 6, 0, 3 );

    ShowOsd();

    // set color windows - idWindow, color, xPixel, yPixel, width, height
    SetColorWin(0, 1, 32, 20, 20, 24); // color window on 1bpp icon
    SetColorWin(1, 1, 96, 20, 20, 24); // color window on 2bpp icon
    SetColorWin(2, 1, 32, 68, 20, 24); // color window on 1xbpp icon
    SetColorWin(3, 1, 96, 68, 20, 24); // color window on 4bpp icon
#endif
}

void TestOsdHwFeatures1( BYTE row, BYTE col, BYTE bpp )
{
    switch(bpp)
    {
    case 0:
        {
            //x,y,charidx, attrib, bpp
            PutChar (col, row, 1, 0, 0 );
            break;
        }
    case 1:
        {
            //x,y,charidx, attrib, bpp
            PutChar (col, row, 1, 0, 1 );
            break;
        }
    case 2:
        {
            //x,y,charidx, attrib, bpp
            PutChar (col, row, 1, 0, 2 );
            break;
        }
    case 3:
        {
            //x,y,charidx, attrib, bpp
            PutChar (col, row, 1, 0, 3 );
            break;
        }
    case 4:
        {
            //x,y,charidx, attrib, bpp
            PutChar (col, row, 0, 0, 0 );
            break;
        }
    }
}
#else    //	DEBUG_MSG && RUN_OSD_TEST

void TestOsdHwFeatures( BYTE fontX, BYTE fontY )
{
		fontX = fontX;
      fontY = fontY;
}
void TestOsdHwFeatures1( BYTE row, BYTE col, BYTE bpp )
{
		row = row;
      col = col;
      bpp = bpp;
}
#endif	//	DEBUG_MSG && RUN_OSD_TEST

⌨️ 快捷键说明

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