#include
void main()
{
printf("中国,我爱你!\n"); //程序体,printf是输出函数,包含在stdio.h头文件中。\n是换行符
}
tc太旧,该淘汰了
老早以前做过DOS游戏开发,汉子在TC中一般是"画"出来的,给你点资料吧
VGA13H模式下的汉子输出:
//han4 zi4 xian3 shi4
//320-200-->>W=20 (zi4) ; H=11 (zi4)
int couttextxy_int13h(char hzk16_file_path[40],int x,int y,
unsigned char far *string,char color)
{
register int i,j;
unsigned long int locate;
int k=0;
char l=0,buffer[32];
//load han4 zi4 ku4
FILE *fp;
char filename[40];
strcpy(filename,hzk16_file_path);
if((fp=fopen(filename,"rb"))==NULL)//rb--read BIN
printf("can not load ziku !");
//xian3 shi4 han4 zi4
if(fp==NULL) return 0;
while(string[k]!='\0')
{
locate=(string[k]-161)*94+string[k+1]-161;
fseek(fp,(long int)locate*32,SEEK_SET);
fread(buffer,32,sizeof(char),fp);
k+=2;
for(i=0;i<16;i++)
for(j=0;j<2;j++)
{
l=buffer[i*2+j];
if((l&0x80)!=0) fos_putpixel(x+j*8,y+i,color);
if((l&0x40)!=0) fos_putpixel(x+j*8+1,y+i,color);
if((l&0x20)!=0) fos_putpixel(x+j*8+2,y+i,color);
if((l&0x10)!=0) fos_putpixel(x+j*8+3,y+i,color);
if((l&0x08)!=0) fos_putpixel(x+j*8+4,y+i,color);
if((l&0x04)!=0) fos_putpixel(x+j*8+5,y+i,color);
if((l&0x02)!=0) fos_putpixel(x+j*8+6,y+i,color);
if((l&0x01)!=0) fos_putpixel(x+j*8+7,y+i,color);
}
x+=16;
}
return 1;
}
ChainX4模式下显示汉子
//han4 zi4 xian3 shi4
int couttextxy(char hzk16_file_path[40],int x,int y,
unsigned char far *string,char color)
{
register int i,j;
unsigned long int locate;
int k=0;
char l=0,buffer[32];
//load han4 zi4 ku4
FILE *fp;
char filename[40];
strcpy(filename,hzk16_file_path);
// fp=fopen(filename,"rb");
if((fp=fopen(filename,"rb"))==NULL)//rb--read BIN
printf("can not load ziku !");
//xian3 shi4 han4 zi4
if(fp==NULL) return 0;
while(string[k]!='\0')
{
locate=(string[k]-161)*94+string[k+1]-161;
fseek(fp,(long int)locate*32,SEEK_SET);
fread(buffer,32,sizeof(char),fp);
k+=2;
for(i=0;i<16;i++)
for(j=0;j<2;j++)
{
l=buffer[i*2+j];
if((l&0x80)!=0) fos_putpixel_x(x+j*8,y+i,color);
if((l&0x40)!=0) fos_putpixel_x(x+j*8+1,y+i,color);
if((l&0x20)!=0) fos_putpixel_x(x+j*8+2,y+i,color);
if((l&0x10)!=0) fos_putpixel_x(x+j*8+3,y+i,color);
if((l&0x08)!=0) fos_putpixel_x(x+j*8+4,y+i,color);
if((l&0x04)!=0) fos_putpixel_x(x+j*8+5,y+i,color);
if((l&0x02)!=0) fos_putpixel_x(x+j*8+6,y+i,color);
if((l&0x01)!=0) fos_putpixel_x(x+j*8+7,y+i,color);
}
x+=16;
}
fclose(fp);
return 1;
}
两种模式下的绘点函数分别是
/*put pixel function
write speed is high*/
/* #define NO_COLOR 0
#define SCR_H 200
#define SCR_W 320
char far *buffer=(char far *)(0x0a0000000L);
*/
void fos_putpixel(int x,int y,int color)
{
//*(x+y*320+buffer)=color;
*(buffer+(y<<8)+(y<<6)+x)=color;
}/**/
和
//put pixel in VGA_320*200*4
void fos_putpixel_x(unsigned int x,unsigned int y,
unsigned char color)
{
char far *addr;
//choose the plane to write to
outport(SC_INDEX,(0x0100<<(x&3))|MAP_MASK );
//caculate the adress
addr=(char *)MK_FP( act_segment,y*(SCR_WIDTH4)+x/4 );
*addr=color;
}/*fos_putpixel4*/
初学者的话建议你别再研究这么老的东西了,这些资料(尤其是上面的ChainX4,使用时需要改写VGA的四个寄存器)都是95年以前甚至8几年的,估计详细点的资料书都难找.
当然如果一定要研究的话,推荐你两本书<