📄 hztolib.c
字号:
/*********************************************
* INPUT.C *
* copyright by djzhang &mqchen *
* xj inc. 1997.8.26 *
*
* mqchen changed for TMS320F2812
* 2004.9.10
*********************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <assert.h>
#define MAXHZ 350
static num=0;
void main()
{
FILE *fp;
int fph;
FILE *ftxt;
char by[32];
unsigned char tmp[2];
unsigned int *asciitab;
int i,j,flag=0;
unsigned int c1,c2,cc;
unsigned long int l,l1,l2;
fp=fopen("fonts.h","w+");
fph=open("asc16",O_RDONLY|O_BINARY);
fprintf(fp,"\n ");
fprintf(fp,"\n struct ASC16{ ");
fprintf(fp,"\n unsigned char buf[16]; ");
fprintf(fp,"\n }; ");
fprintf(fp,"\n struct ASC16 asc16[128]={ ");
fprintf(fp,"\n");
for(i=0;i<128;i++) {
l=i * 16;
lseek(fph,l,SEEK_SET);
read(fph,by,16);
fprintf(fp," ");
for(j=0;j<16;j++) {
fprintf(fp,"0x%02x,",(unsigned char)by[j]);
}
if(i>'!' && i < 'z'){
fprintf(fp," /* %c */",(unsigned char) i );
}
fprintf(fp,"\n");
}
fseek(fp,-3,SEEK_CUR);
fprintf(fp,"\n }; \n");
close(fph);
asciitab=(unsigned int *)malloc(sizeof(unsigned int)*MAXHZ);
asciitab[0]=0xffff;
fph=open("hzk16",O_RDONLY|O_BINARY);
ftxt=fopen("hz16.txt","rb");
while(!feof(ftxt)) {
fread(tmp,sizeof(char),2,ftxt);
while((unsigned char)tmp[0] < 0xa1) {
if( feof(ftxt) ) { flag = 1; break; }
fseek(ftxt,-1,SEEK_CUR);
fread(tmp,sizeof(char),2,ftxt);
}
if(flag) break;
for(i=0;i<MAXHZ;i++) {
c1=tmp[0]*256+tmp[1];
if(c1<asciitab[i]) {
c2 = asciitab[i];
asciitab[i] = c1;
num++;
while(asciitab[i]!=0xffff) {
cc = asciitab[i+1] ;
asciitab[i+1]=c2;
c2 = cc;
i++;
}
break;
}
else if(c1 == asciitab[i]) break;
}
}
fprintf(fp,"\n # define HZ_NUM %d",num+8);
fprintf(fp,"\n ");
fprintf(fp,"\n struct HZ16{ ");
fprintf(fp,"\n unsigned int id; ");
fprintf(fp,"\n unsigned char buf[32]; ");
fprintf(fp,"\n }; ");
fprintf(fp,"\n struct HZ16 hz16[HZ_NUM]={ ");
fprintf(fp,"\n /* ");
fprintf(fp,"\n // this block used by program input.exe");
fprintf(fp,"\n // please don't modify here !!!");
fprintf(fp,"\n */ ");
i=0;
while(asciitab[i]!=0xffff) {
tmp[0] = (char)((asciitab[i] & 0xff00) >> 8);
tmp[1] = (char)(asciitab[i] & 0xff);
fprintf(fp,"\n 0x%02x",asciitab[i]);
l1=(unsigned long) ((asciitab[i]>>8)-0xa1)*94;
l2=(unsigned long) asciitab[i]&0xff;
l2=l2-0xa1;
l=(l1+l2)*32;
i++;
lseek(fph,l,SEEK_SET);
read(fph,by,32);
for(j=0;j<32;j++)
fprintf(fp,",0x%02x",(unsigned char)by[j]);
fprintf(fp,",");
fprintf(fp, " \t /* %c%c */", tmp[0],tmp[1]);
}
fprintf(fp,"\n }; \n");
close(fph);
fclose(fp);
fclose(ftxt);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -