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

📄 graphics.c

📁 bios中断编程 做出一个界面 可拖动 最大化最小化
💻 C
字号:
    # include <dos.h>

int hzk_p;
void open_hzk(void);
void get_hz(char incode[],char bytes[]);
void dishz(int x,int y,char cade[],int color);

mode(m)
int m;
{
 union REGS inregs,outregs;
 inregs.h.ah=0x00;
 inregs.h.al=m;
 int86(0x10,&inregs,&outregs);
}


dot(x,y,c)
unsigned int x,y;
unsigned char c;
{
 union REGS inregs,outregs;
 inregs.h.ah=0x0c;
 inregs.h.bh = 0;
 inregs.h.al=c;
 inregs.x.dx=y;
 inregs.x.cx=x;
 int86(0x10,&inregs,&outregs);
}

unsigned char read_dot(unsigned x,unsigned y)
     {
      union REGS inregs,outregs;
      inregs.x.dx=y;
      inregs.x.cx=x;
      inregs.h.bh = 0;
      inregs.h.ah=0x0d;
      int86(0x10,&inregs,&outregs);
      return(outregs.h.al);
      }


lin(int x1,int y1,int x2,int y2)
{
 int c=1;
 register int i;
 float k,tem;
 int len,lenx,leny,st,x,y;
 x=x1;
 y=y1;
 lenx=abs(x2-x1);
 leny=abs(y2-y1);
 len=(leny>lenx)?leny:lenx;
 if(leny>lenx)
 {
 st=(y2>=y1)?1:-1;
 k=(float)(x2-x1)/(float)(y2-y1);
 tem=x;
 for(i=1;i<=len;++i)
 {
 dot(x,y,c);
   y+=st;
   tem+=k;
   x=tem;
  }
 }
else
 {  st=(x2>=x1)?1:-1;
    k=(float)(y2-y1)/(float)(x2-x1);
    tem=y;
    for(i=1;i<=len;++i)
     {
       dot(x,y,c);
       x+=st;
       tem+=k;
       y=tem;
    }
  }
}


kuang(int x1,int y1,int x2,int y2)
{
  int c=1;
  int i,j,m,n;
  for(i=x1;i<=x2;i++)
   dot(i,y1,c);
  for(m=x2;m>=x1;m--)
   dot(m,y2,c);
  for(j=y1;j<=y2;j++)
   dot(x1,j,c);
  for(n=y2;n>=y1;n--)
   dot(x2,n,c);
}


void palette (int pnum)                      /*颜色适配器函数*/
{
  union REGS r;
  r.h.bh=1;
  r.h.bl=pnum;
  r.h.ah=11;
  int86(0x10,&r,&r);
}



void open_hzk()
{
  hzk_p=open("hzk16",O_BINARY|O_RDONLY);
    if(hzk_p==-1)
      {
	printf("The file HZK16 not exit!ENTER to system\n");
	getch();
	closegraph();
	exit(1);
      }
}

void get_hz(char incode[],char bytes[])
{
  unsigned char qh,wh;
  unsigned long offset;
  qh=incode[0]-0xa0;
  wh=incode[1]-0xa0;
  offset=(94*(qh-1)+(wh-1))*32L;
  lseek(hzk_p,offset,SEEK_SET);
  read(hzk_p,bytes,32);
}

void dishz(int x0,int y0,char code[],int color)
{ 
  unsigned char mask[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
  register int i,j,x,y,pos;
char mat[32];
get_hz(code,mat);
  y=y0;
  for(i=0;i<16;++i)
     {
      x=x0;
      pos=2*i;
      for(j=0;j<16;j++)
         {
          if((mask[j%8]&mat[pos+j/8])!=NULL)
          dot(x,y,color);
          ++x;
         }
      ++y;
      }
}


void hz(int x,int y,char *s)
{
  int driver=DETECT;
  int mode=0;
  open_hzk();
  while(*s!=NULL)
    {
      while(x<630&&(*s!=NULL))
        {
         dishz(x,y,s,RED);
         x+=20;
         s+=2;
        }
       x=20;y+=20;
    }  
  close(hzk_p);
  closegraph();  
} 

⌨️ 快捷键说明

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