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

📄 cputs.c

📁 这是老早前学生时代用TurboC++3.0写的dos程序
💻 C
字号:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include <graphics.h>

#define CHINESE_X 16
#define CHINESE_Y 16
#define ASC_X 8
#define ASC_Y 8
#define DISTENCE_X 1
#define DISTENCE_Y 2
#define MAXX 640
#define MAXY 480

int chputs(int,int,char *,int,FILE *);
void printchinese(int,int,char *,int);
void getchinese(FILE *,unsigned char,unsigned char,char *);

void printchinese(int startx,int starty,char *ch_motel,int color)
     {
       char *p;
       int x=startx,y=starty;
       register int i;

       for(p=ch_motel;p-ch_motel<32;){
	  for(i=0;i<2;i++,p++)
	     {
	       if(*p&0x0080) putpixel(x,y,color); x++;
	       if(*p&0x0040) putpixel(x,y,color); x++;
	       if(*p&0x0020) putpixel(x,y,color); x++;
	       if(*p&0x0010) putpixel(x,y,color); x++;
	       if(*p&0x0008) putpixel(x,y,color); x++;
	       if(*p&0x0004) putpixel(x,y,color); x++;
	       if(*p&0x0002) putpixel(x,y,color); x++;
	       if(*p&0x0001) putpixel(x,y,color); x++;
	     }
	   x=startx;
	   y++;
       }
    }
void getcword(FILE *zk,unsigned char quma,unsigned char weima,char *ch_motel)
     {
       fseek(zk,(long)((quma-0xa1)*94+weima-0xa1)*32,SEEK_SET);
       fread(ch_motel,sizeof(char),32,zk);
       return;
     }
int chputs(int startx,int starty,char *chinese,int color,FILE *zk)
     {
	 char *c,ch_motel[32];
	 static char cc[2]={0,0};
	 int x=startx,y=starty,bkcolor;

	   for(c=chinese; *c ; c++)
	      {
		if( !isascii( (int)*c ) )
		  {
		      if( !isascii( (int)*(c+1) ) && *(c+1) )
			{
			  getcword(zk,*c,*(c+1),ch_motel);
			  printchinese(x,y,ch_motel,color);
			  c++;
			  if(x+16+DISTENCE_X>=MAXX )
			    {
			      if(y+16+DISTENCE_Y>=MAXY) return 0;
			      x=startx;  y+=16;
			    }
			  x+=16+DISTENCE_X;
			}
		      else {
			     cc[0]=*c;
			     settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
			     settextjustify(LEFT_TEXT,TOP_TEXT);
			     bkcolor=getcolor();
			     setcolor(color);
			     moveto(x,y+8);
			     outtext(cc);
			     if(x+8+DISTENCE_X>=MAXX)
			       {
				 if(y+16+DISTENCE_Y>=MAXY) return 0;
				 x=startx; y+=16;
			       }
			     setcolor(bkcolor);
			     x+=8+DISTENCE_X;
			   }
	      }
	    else {
		  cc[0]=*c;
		  settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
		  settextjustify(LEFT_TEXT,TOP_TEXT);
		  bkcolor=getcolor();
		  setcolor(color);
		  moveto(x,y+8);
		  outtext(cc);
		 if(x+8+DISTENCE_X>=MAXX)
		   {
		     if(y+16+DISTENCE_Y>=MAXY) return 0;
		     x=startx; y+=16;
		   }
		 setcolor(bkcolor);
		 x+=8+DISTENCE_X;
		}
	  }
       return 1;
     }

⌨️ 快捷键说明

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