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

📄 hz.h

📁 可以用C在dos环境下不需要中文平台支持
💻 H
字号:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <graphics.h>
#include <conio.h>
#include <dos.h>
#include <math.h>

void outhzxy3(int x,int y,char *p,int size,int direction,int color)
{   int oldcolor;
    oldcolor=getcolor();
    setcolor(color);
    setfillstyle(SOLID_FILL,color);
    while(*p){
    if(((unsigned char)*p>=0xa1&&(unsigned char)*p<=0xfe)&&
	((unsigned char)*(p+1)>=0xa1&&(unsigned char)*(p+1)<=0xfe))
     {
       disp_hz3(x,y,*p,*(p+1),size,direction,color);
       p+=2;
       if(direction==HORIZ_DIR)
	 x+=size*16+2;
       if(direction==VERT_DIR)
	 y-=size*16+2;
       moveto(x,y);
      }
      else{
      char q[2];
      moveto(x,y);
      *q=*p;*(q+1)='\0';
      outtextxy(x,y+4,q);
      x+=8;p++;
      }
      }
      setcolor(oldcolor);
 }

int disp_hz3(int left,int top,unsigned char byte1,
	    unsigned char byte2,int size,int direction,int color)
  {
      FILE * cclibfile;
      unsigned char buf[32];
      long p;
      int i,j,x,y,radiumX,radiumY;
      unsigned char mark;

      cclibfile=fopen("CCLIB.DAT","rb");
      if(cclibfile==NULL) {
	 outtextxy(10,10,"Not find CCLIB.DOT!Press any key to exit...");
	 getch();
	 exit(1);
	 }
      if((byte1>=0xa1&&byte1<=0xfe)&&(byte2>=0xa1&&
	       byte2<=0xfe)){
      p=(byte1-0xa1)*0x5e+byte2-0xa1;
      p*=32;
      fseek(cclibfile,(long)p,SEEK_SET);
      fread(buf,sizeof(unsigned char),32,cclibfile);
      fclose(cclibfile);
      if((left+size*16-1)>getmaxx()||(top+size*16-1)>getmaxy())
	      return 0;
      if(size==1){
	 if(direction==HORIZ_DIR){
	     for(i=0,y=top;i<31;i+=2,y++)
		for(mark=0x80,j=0;mark>0;mark=mark>>1,j++){
		   if((buf[i]&mark)!=0)
		     putpixel(left+j,y,color);
		   if((buf[i+1]&mark)!=0)
		     putpixel(left+j+8,y,color);
		 }
	 }
	 if(direction==VERT_DIR){
	    for(i=0,x=left;i<31;i+=2,x++)
	       for(mark=0x80,j=0;mark>0;mark=mark>>1,j++){
		  if((buf[i]&mark)!=0)
		     putpixel(x,top-j,color);
		  if((buf[i+1]&mark)!=0)
		     putpixel(x,top-j-8,color);
	       }
	 }
      return 1;
      }
      if(size==2){
	 radiumX=size/2+1;
	 radiumY=size/2;
       }
       else{
	  radiumX=size/2+1;
	  radiumY=size/2+1;
       }
       if(direction==VERT_DIR){
	  for(i=0,x=left;i<31;i+=2,x+=size)
	      for(mark=0x80,j=0;mark>0;mark=mark>>1,j++){
		 if((buf[i]&mark)!=0)
		   bar(x+size/2,top-j*size-size/2,
		       x+size/2+radiumX,top-j*size-size/2+radiumY);
		 if((buf[i+1]&mark)!=0)
		   bar(x+size/2,top-(j+8)*size-size/2,
		       x+size/2+radiumX,top-(j+8)*size-size/2+radiumY);
		}
	     return 1;
	}
	if(direction==HORIZ_DIR){
	for(i=0,y=top;i<31;i+=2,y+=size)
	   for(mark=0x80,j=0;mark>0;mark=mark>>1,j++){
	      if((buf[i]&mark)!=0)
		   bar(left+j*size+size/2,y+size/2,
		       left+j*size+size/2+radiumX,y+size/2+radiumY);
	      if((buf[i+1]&mark)!=0)
		   bar(left+(j+8)*size+size/2,y+size/2,
		       left+(j+8)*size+size/2+radiumX,y+size/2+radiumY);
	    }
	    return 1;
	}
	}
	fclose(cclibfile);
	return 0;
 }

int outhzxy1(int x,int y,char *p,int color)
  {
   int oldcolor;
   oldcolor=getcolor();
   setcolor(color);
   while(*p)
      {
	if(((unsigned char)*p>=0xa1&&(unsigned char)*p<=0xfe)&&
	((unsigned char)*(p+1)>=0xa1&&(unsigned char)*(p+1)<=0xfe))
	  {
	    if((x+16-1)>getmaxx()||(y+16-1)>getmaxy())
	    return 0;
	    disp_hz1(x,y,*p,*(p+1),color);
	    p+=2;
	    x+=16+2;
	    moveto(x,y);
	   }
	 else{
	   char q[2];
	   moveto(x,y);
	   *q=*p;*(q+1)='\0';
	   settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
	   outtextxy(x,y+4,q);
	   x+=8+1;p++;
	      }
	}
    setcolor(oldcolor);
    return 1;
  }


int disp_hz1(int left,int top,unsigned char byte1,
	     unsigned char byte2,int color)
{
   FILE *cclibfile;
   unsigned char buf[32];
   unsigned char mark;
   long p;
   int x,y,i,j;
   int quma,weima;
   cclibfile=fopen("CCLIB.DAT","rb");
   if(cclibfile==NULL)
     {
      outtextxy(10,10,"Can't open CCLIB.DAT file! Press any key to halt ...");
      exit(1);
     }
   if((byte1>=0xa1&&byte1<=0xfe)&&(byte2>=0xa1&&byte2<=0xfe))
    {
   quma=byte1-0xa0;
   weima=byte2-0xa0;
   p=(quma-1)*94+weima-1;
   p*=32;
   fseek(cclibfile,(long)p,SEEK_SET);
   fread(buf,sizeof(unsigned char),32,cclibfile);
   fclose(cclibfile);
   for(i=0,y=top;i<31;i+=2,y++)
   for(mark=0x80,j=0;mark>0;mark=mark>>1,j++)
	{
	 if((buf[i]&mark)!=0)
	 putpixel(left+j,y,color);
	 if((buf[i+1]&mark)!=0)
	 putpixel(left+j+8,y,color);
	}
    }
   fclose(cclibfile);
   return 1;
}

⌨️ 快捷键说明

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