From: "STEVEN S. FALLS" Newsgroups: comp.os.msdos.djgpp Subject: Help, Can anyone help optomize this already fast line routine Date: Sun, 16 Nov 1997 00:42:17 -0800 Organization: EarthLink Network, Inc. Lines: 132 Message-ID: <346EB1E8.504A7CBF@earthlink.net> Reply-To: ELN/broadview AT earthlink DOT net NNTP-Posting-Host: 153.37.31.22 Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------073B5545556899EF7FF1DDB7" To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk --------------073B5545556899EF7FF1DDB7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, My name is Ardy and I have an aready fast line agrothym that needs to go faster. I need to find a way to posibly optomize the pixel addressing part. Thanks, -Ardy #define ABS(x)(((x) >= 0) ? (x) : (-(x))) unsigned int *YTbl; void Set YTbl(void) { YTbl=new unsigned int [200]; for(int a=0;a<200;a++) YTbl[a]=a*320; } void Line(int x1,int y1,int x2,int y2,unsigned char color){ long XDelta,YDelta,a,M,Y,X; XDelta=((x2-x1)<<8);YDelta=((y2-y1)<<8); if(ABS(XDelta)>=ABS(YDelta)) { M=(YDelta<<8)/XDelta; Y=(y1<<8); if(XDelta>=0) { for(a=x1;a<=x2;a++) { RamPg[YTbl[(Y>>8)]+a]=color; Y+=M; } }else { for(a=x1;a>=x2;a--) { RamPg[YTbl[(Y>>8)]+a]=color; Y-=M; } } return; } else { M=(XDelta<<8)/YDelta; X=(x1<<8); if(YDelta>=0) { for(a=y1;a<=y2;a++) { RamPg[YTbl[a]+(X>>8)]=color; X+=M; } }else { for(a=y1;a>=y2;a--) { RamPg[YTbl[a]+(X>>8)]=color; X-=M; } } } return; } --------------073B5545556899EF7FF1DDB7 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi,
     My name is Ardy and I have an aready fast line agrothym that needs to go faster. I need  to find a way to posibly optomize the pixel addressing part.
                                            Thanks,
                                                -Ardy

#define ABS(x)(((x) >= 0) ? (x) : (-(x)))
unsigned int *YTbl;
void Set YTbl(void) {
    YTbl=new unsigned int [200];
   for(int a=0;a<200;a++) YTbl[a]=a*320;
}
void Line(int x1,int y1,int x2,int y2,unsigned char color){
   long XDelta,YDelta,a,M,Y,X;
   XDelta=((x2-x1)<<8);YDelta=((y2-y1)<<8);
   if(ABS(XDelta)>=ABS(YDelta)) {
      M=(YDelta<<8)/XDelta;
      Y=(y1<<8);
      if(XDelta>=0) {
         for(a=x1;a<=x2;a++) {
            RamPg[YTbl[(Y>>8)]+a]=color;
            Y+=M;
         }
      }else {
         for(a=x1;a>=x2;a--) {
            RamPg[YTbl[(Y>>8)]+a]=color;
            Y-=M;
         }
      }
      return;
   } else {
      M=(XDelta<<8)/YDelta;
      X=(x1<<8);
      if(YDelta>=0) {
         for(a=y1;a<=y2;a++) {
            RamPg[YTbl[a]+(X>>8)]=color;
            X+=M;
         }
      }else {
         for(a=y1;a>=y2;a--) {
            RamPg[YTbl[a]+(X>>8)]=color;
            X-=M;
         }
      }
   }
   return;
}
 
 

  --------------073B5545556899EF7FF1DDB7--