注册 登录
编程论坛 C图形专区

关于TC中的画点函数

kunful 发布于 2011-06-21 19:33, 667 次点击
mempoint函数   求大侠注释   (我看不懂)。。。。。。。。。。。。。。。。。

/*mempoint(int x,int y,int color_code)*/
void mempoint(int x,int y,int color_code)
{
union mask{
char c[2];
int i;
}bit_mask;
int i,index,bit_position;
unsigned char t;
char xor;
char far *ptr=(char far*)0xB8000000;
bit_mask.i=0xFF3F;
if(y<0||y>319||x<0||x>199)return;
xor=color_code&128;
color_code=color_code&127;
bit_position=y%4;
color_code<<=2*(3-bit_position);
bit_mask.i=2*bit_position;
index=x*40+y/4;
if(x%2)index+=8192;
if(!xor){
t=*(ptr+index)&bit_mask.c[0];
t=*(ptr+index)|color_code;
}else{
t=*(ptr+index)|(char)0;
*(ptr+index)=t|color_code;
}

}
0 回复
1