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

📄 ldraw.cpp

📁 ldraw_DOS游戏开发包
💻 CPP
字号:
//////////////////////////////////////////////////////////////////////////
// The most important part in LinDraw
#include <stdio.h>
#include <ldraw.h>

void  lputBlock(short x,short y,char *b);
void  lputImage(short x,short y,char *b);
void  lputSpirit(short x,short y,char *spr);
void  lputSpirit(short x,short y,char *b,short hotX,short hotY);
short lgetImage(short x1,short y1,short x2,short y2,char *b);
void  lgetBlock(short x1,short y1,short x2,short y2,char *b);
void  lgetSize(short *len,short *wid,char *b);
void  lgetHotXY(short *hotx,short *hoty,char *p);
void  lsetHotXY(short hotx,short hoty,char *p);
void  lActiveDC(TGDC *dc);
void  lSaveDC(TGDC *dc);
//////////////////////////////////////////////////////////////////////////
short ldraw_error=0;
short Vdx1, Vdy1, Vdx2, Vdy2;
void lputBlock(short x,short y,char *b)
{ register short len, wid, j;  
  len=*(short*)b; b+=2; wid=*(short*)b; b+=2;
  for (j=0;j<wid;j++) 
   { lScanLine(x,y+j,len,b); 
     b+=len;
   }
}
void lputImage(short x,short y,char *b)
{ register short len, wid, j; 
  if (!b) return;
  len=*(short*)b; b+=2; wid=*(short*)b; b+=2;
  for (j=0;j<wid;j++) 
   { lScanLine2(x,y+j,len,b); 
     b+=len;
   }
}
void lputSpirit(short x,short y,char *spr)
{ short d1,d2; char *p=spr;
  long  size;
  d1=*(short*)p; p+=2; d2=*(short*)p; p+=2;
  size=d1; size*=(long)d2;
  p+=size; d1=*(short*)p; p+=2; d2=*(short*)p;
  lputImage(x-d1,y-d2,spr);
}
void lputSpirit(short x,short y,char *b,short hotX,short hotY)
{ lputImage(x-hotX,y-hotY,b);
}
short lgetImage(short x1,short y1,short x2,short y2,char *b)
{ short len=x2-x1+1, wid=y2-y1+1, j; char *sb=b;
  *(short*)b=len; b+=2; *(short*)b=wid; b+=2;
  for (j=0;j<wid;j++)
    { lGetLine(x1,y1+j,len,b); b+=len;
    }
  return b-sb;
}
void  lgetBlock(short x1,short y1,short x2,short y2,char *b) 
{ lgetImage(x1,y1,x2,y2,b); 
}
void  lgetSize(short *len,short *wid,char *b)
{ if (b) {
    *len=*(short*)b; b+=2; *wid=*(short*)b;
  } else *len=*wid=0;
}
void lgetHotXY(short *hotx,short *hoty,char *p)
{ short d1,d2; 
  long  size;
  if (p) {
    d1=*(short*)p; p+=2; d2=*(short*)p; p+=2;
    size=d1; size*=(long)d2;
    p+=size; d1=*(short*)p; p+=2; d2=*(short*)p;
    *hotx=d1, *hoty=d2;
  } else *hotx=*hoty=0;
}
void  lsetHotXY(short hotx,short hoty,char *p)
{ short d1,d2; 
  long  size;
  d1=*(short*)p; p+=2; d2=*(short*)p; p+=2;
  size=d1; size*=(long)d2;
  p+=size; *(short*)p=hotx; p+=2; *(short*)p=hoty;
}
void lActiveDC(TGDC *dc)
{ if (dc==NULL)
   { Vdx1=Vdy1=0; Vdx2=GModeData.LEN-1; Vdy2=GModeData.WID-1;
     ld_workColor=7; ld_workBColor=0; ld_x=ld_y=0;
   } 
  else
   { Vdx1=dc->x1; Vdy1=dc->y1; Vdx2=dc->x2; Vdy2=dc->y2;
     ld_workColor=dc->color; ld_workBColor=dc->bcolor;
     ld_x=dc->x; ld_y=dc->y;
   }
}
void lSaveDC(TGDC *dc)
{ dc->x1=Vdx1; dc->y1=Vdy1; dc->x2=Vdx2; dc->y2=Vdy2;
  dc->color=ld_workColor; dc->bcolor=ld_workBColor;
  dc->x=ld_x; dc->y=ld_y;
}

⌨️ 快捷键说明

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