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

📄 hzk16.h

📁 c游戏编程从入门到精通_全部源代码和文档
💻 H
字号:
unsigned char bit[8]={128,64,32,16,8,4,2,1};

void GetHzBit(char ch0,char ch1,char *bitdata)
{
FILE *stream;
long fpos;
fpos=32L*(((unsigned char)ch0-161)*94+((unsigned char)ch1-161));
if((stream=fopen("hzk16","rb"))==NULL){
printf("Open hzk16 error!\n");
exit(0);
}
fseek(stream, fpos, SEEK_SET);
fread( bitdata, 32, 1, stream);
fclose(stream);
}

void WriteHz(char ch0,char ch1,int x,int y,int color)
{
register int i,j,k;
unsigned vpos;
char bitdata[32];
GetHzBit(ch0,ch1,bitdata);
for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[2*i]&bit[j])
Plot_Pixel_Fast(x+j,i+y,color);
if(bitdata[2*i+1]&bit[j])
Plot_Pixel_Fast(x+8+j,i+y,color);
}
}
void WriteHzStr(char *str,int x,int y,int color)
{
int num,i,j,xx;
unsigned char s0,s1;
num=strlen(str);
xx=x;
for(i=0;i<num;i+=2){
WriteHz(str[i],str[i+1],xx,y,color);
xx+=16;
}
}

void Words_Step(char *str,int x,int y,int color,int speed)
{
int num,i,j,xx;
unsigned char s0,s1;
num=strlen(str);
xx=x;
for(i=0;i<num;i+=2){
WriteHz(str[i],str[i+1],xx,y,color);
Delay(speed);
xx+=16;
}
}

void Hzk_Array(char *bitdata,int x,int y,int color)
{
register int i,j,k;
unsigned vpos;
for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[2*i]&bit[j])
Plot_Pixel_Fast(x+j,i+y,color);
if(bitdata[2*i+1]&bit[j])
Plot_Pixel_Fast(x+8+j,i+y,color);
}
}

void Hzks_Array(char *bitdata,int x,int y,int color,int num)
{
register int i,j,k;
unsigned vpos;
int index=0;
while(index<num)
{
for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[index*32+2*i]&bit[j])
Plot_Pixel_Fast(index*16+x+j,i+y,color);
if(bitdata[index*32+2*i+1]&bit[j])
Plot_Pixel_Fast(index*16+x+8+j,i+y,color);
}
index++;
}
}

char *bitdata;

void Hzk_Array2(char *str,int x,int y,int color,int num)
{
register int i,j,k;
unsigned vpos;
int offset=0;

while(((bitdata[offset*34]!=str[0])||(bitdata[offset*34+1]!=str[1]))&&offset<num)
{
offset++;
}
if(offset!=num)
{
for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[offset*34+2+2*i]&bit[j])
Plot_Pixel_Fast(x+j,i+y,color);
if(bitdata[offset*34+2+2*i+1]&bit[j])
Plot_Pixel_Fast(x+8+j,i+y,color);
}
}
else
	printf("this chinese word can not be found");
}

void Hzks_Array2(char *str,int x,int y,int color,int num)
{
int i=0;
char now[2];
do
{
	now[0]=str[i];
	now[1]=str[i+1];
	Hzk_Array2(now,x+i*8,y,YELLOW,2);
	i=i+2;
}while(str[i]!='\x0');
}


void Hzk_File_Out(char *file,int x,int y,int color,int offset)
{
register int i,j,k;
unsigned vpos;
char bitdata[32];
FILE *out;

if((out=fopen(file,"rb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
fseek(out,32*offset,SEEK_SET);
fread( bitdata, 32, 1, out);
fclose(out);

for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[2*i]&bit[j])
	Plot_Pixel_Fast(x+j,i+y,color);
if(bitdata[2*i+1]&bit[j])
	Plot_Pixel_Fast(x+8+j,i+y,color);
}
}

void Hzks_File_Out(char *file,int x,int y,int color,int num,int offset)
{
register int i,j,k;
unsigned vpos;
int index=0;
char *bitdata;
FILE *out;
bitdata=malloc(sizeof(char)*32*num);

if((out=fopen(file,"rb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
fseek(out,32*offset,SEEK_SET);
fread( bitdata, 32*num, 1, out);
fclose(out);
while(index<num)
{
for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[index*32+2*i]&bit[j])
Plot_Pixel_Fast(index*16+x+j,i+y,color);
if(bitdata[index*32+2*i+1]&bit[j])
Plot_Pixel_Fast(index*16+x+8+j,i+y,color);
}
index++;
}
}

void Hzk_File(char ch0,char ch1,char *file)
{
FILE *in,*out;
long fpos;
char *bitdata;
fpos=32L*(((unsigned char)ch0-161)*94+((unsigned char)ch1-161));
if((in=fopen("hzk16","rb"))==NULL){
printf("Open hzk16 error!\n");
exit(0);
}
if((out=fopen(file,"wb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
fseek(in, fpos, SEEK_SET);
fread( bitdata, 32, 1, in);
fwrite(bitdata,32,1,out);
fclose(in);
fclose(out);
}

void Hzks_File(char *str,char *file)
{
FILE *in,*out;
char ch0,ch1;
long fpos;
char *bitdata;
int i=0;
if((in=fopen("hzk16","rb"))==NULL){
printf("Open hzk16 error!\n");
exit(0);
}
if((out=fopen(file,"wb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
while(str[i]!='\x0')
{
ch0=str[i];
ch1=str[i+1];
fpos=32L*(((unsigned char)ch0-161)*94+((unsigned char)ch1-161));

fseek(in, fpos, SEEK_SET);
fread( bitdata, 32, 1, in);
fwrite(bitdata,32,1,out);
i=i+2;
}
fclose(in);
fclose(out);
}

void Hzk_File_Out2(char *file,int x,int y,int color,char *str)
{
register int i,j,k;
unsigned vpos;
char bitdata[32];
FILE *out;
char str1[2];
int offset=0,flag=1;
if((out=fopen(file,"rb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
do
{
fseek(out,34*offset,SEEK_SET);
flag=fread(str1,2,1,out);
offset++;
}while(((str1[0]!=str[0])||(str1[1]!=str[1]))&&flag!=0);
if(flag!=0)
	fread( bitdata, 32, 1, out);
else
	printf("this chinese word can not be found");
fclose(out);

for(i=0;i<16;i++)
for(j=0;j<8;j++){
if(bitdata[2*i]&bit[j])
	Plot_Pixel_Fast(x+j,i+y,color);
if(bitdata[2*i+1]&bit[j])
	Plot_Pixel_Fast(x+8+j,i+y,color);
}
}

void Hzks_File_Out2(char *file,int x,int y,int color,char *str)
{
int i=0;
char now[2];
do
{
	now[0]=str[i];
	now[1]=str[i+1];
	Hzk_File_Out2(file,x+i*8,y,YELLOW,now);
	i=i+2;
}while(str[i]!='\x0');
}

void Hzk_File2(char ch0,char ch1,char *file)
{
FILE *in,*out;
long fpos;
char *bitdata;
char now[2];
now[0]=ch0;
now[1]=ch1;
fpos=32L*(((unsigned char)ch0-161)*94+((unsigned char)ch1-161));
if((in=fopen("hzk16","rb"))==NULL){
printf("Open hzk16 error!\n");
exit(0);
}
if((out=fopen(file,"wb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
fseek(in, fpos, SEEK_SET);
fread( bitdata, 32, 1, in);
fwrite(now,2,1,out);
fwrite(bitdata,32,1,out);
fclose(in);
fclose(out);
}

void Hzks_File2(char *str,char *file)
{
FILE *in,*out;
char ch0,ch1;
long fpos;
char *bitdata;
char now[2];
int i=0;
if((in=fopen("hzk16","rb"))==NULL){
printf("Open hzk16 error!\n");
exit(0);
}
if((out=fopen(file,"wb"))==NULL){
printf("Open %s error!\n",file);
exit(0);
}
while(str[i]!='\x0')
{
now[0]=str[i];
now[1]=str[i+1];
ch0=str[i];
ch1=str[i+1];
fpos=32L*(((unsigned char)ch0-161)*94+((unsigned char)ch1-161));

fseek(in, fpos, SEEK_SET);
fread( bitdata, 32, 1, in);
fwrite(now,2,1,out);
fwrite(bitdata,32,1,out);
i=i+2;
}
fclose(in);
fclose(out);
}

⌨️ 快捷键说明

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