babyos―― 简易图形库(三)

2014-11-24 08:38:15 · 作者: · 浏览: 3
{
if (*(p_hzk + (x & 8 1 : 0)) & test_bit)
set_pixel(left+x, top+y);
if ((test_bit >>= 1) == 0)
test_bit = 1 << 7;
}
p_hzk += 2;
}
return TRUE;
}
/* 实现一个简陋的打印字符串程序 */
static BOOL draw_string16(char* str, s32 left, s32 top)
{
char* p = str;
char hzk[3];
s32 cur_x, cur_y;
hzk[2] = '\0';
cur_x = left;
cur_y = top;
while (*p != '\0')
{
if ((*p & 0x80) == 0)
{
draw_asc16(*p, cur_x, cur_y);
cur_x += 8;
p++;
}
else
{
hzk[0] = *p++;
hzk[1] = *p++;
draw_hzk16(hzk, cur_x, cur_y);
cur_x += 16;
}
}
return TRUE;
}
BOOL draw_asc(char ch, int left, int top)
{
return draw_asc16(ch, left, top);
}
BOOL draw_hzk(char ch[3], int left, int top)
{
return draw_hzk16(ch, left, top);
}
BOOL draw_string(char *str, int left, int top)
{
return draw_string16(str, left, top);
}
3.绘制logo的函数放到logo.c中
[cpp]
/*************************************************************************
> File: logo.c
> Describe: 显示那个可爱的小篆字体的LOGO
> Author: 孤舟钓客
> Mail: guzhoudiaoke@126.com
> Time: 2013年01月03日 星期四 17时05分11秒
************************************************************************/
#include
#include
#include
static u8* p_logo_base = (u8*)(LOGO_ADDR);
static u32 logo_cx = (u32)(LOGO_CX);
static u32 logo_cy = (u32)(LOGO_CY);
BOOL draw_logo(s32 left, s32 top)
{
u32 y, x;
u8* p_logo = p_logo_base;
for (y = 0; y < logo_cy; y++)
{
for (x = 0; x < logo_cx; x++)
{
if (p_logo[x] != 0xff)
set_pixel(left+x, top+y);
}
p_logo += logo_cx;
}
return TRUE;
}