Diff for /np2/lio/gline.c between versions 1.9 and 1.14

version 1.9, 2004/02/21 20:48:52 version 1.14, 2005/02/07 14:46:12
Line 7 Line 7
   
   
 typedef struct {  typedef struct {
         BYTE    x1[2];          UINT8   x1[2];
         BYTE    y1[2];          UINT8   y1[2];
         BYTE    x2[2];          UINT8   x2[2];
         BYTE    y2[2];          UINT8   y2[2];
         BYTE    pal;          UINT8   pal;
         BYTE    type;          UINT8   type;
         BYTE    sw;          UINT8   sw;
         BYTE    style[2];          UINT8   style[2];
         BYTE    patleng;          UINT8   patleng;
         BYTE    off[2];          UINT8   off[2];
         BYTE    seg[2];          UINT8   seg[2];
 } GLINE;  } GLINE;
   
 typedef struct {  typedef struct {
Line 25  typedef struct { Line 25  typedef struct {
         int             y1;          int             y1;
         int             x2;          int             x2;
         int             y2;          int             y2;
         UINT16  pat;  
         UINT8   pal;          UINT8   pal;
 } LINEPT;  } LINEPT;
   
   
 static void gline(const _GLIO *lio, const LINEPT *lp) {  static void gline(const _GLIO *lio, const LINEPT *lp, UINT16 pat) {
   
         int             x1;          int             x1;
         int             y1;          int             y1;
Line 42  static void gline(const _GLIO *lio, cons Line 41  static void gline(const _GLIO *lio, cons
         int             height;          int             height;
         int             d1;          int             d1;
         int             d2;          int             d2;
         UINT16  pat;  
         UINT32  csrw;          UINT32  csrw;
         GDCVECT vect;          GDCVECT vect;
   
Line 129  static void gline(const _GLIO *lio, cons Line 127  static void gline(const _GLIO *lio, cons
                 d2 = 0 - d2;                  d2 = 0 - d2;
         }          }
         d1 = max(d1, d2) & 15;          d1 = max(d1, d2) & 15;
         pat = (UINT16)((lp->pat >> d1) | (lp->pat << (16 - d1)));          pat = (UINT16)((pat >> d1) | (pat << (16 - d1)));
   
         csrw = (y1 * 40) + (x1 >> 4) + ((x1 & 0xf) << 20);          csrw = (y1 * 40) + (x1 >> 4) + ((x1 & 0xf) << 20);
         if (lio->draw.flag & LIODRAW_UPPER) {          if (lio->draw.flag & LIODRAW_UPPER) {
Line 155  static void gline(const _GLIO *lio, cons Line 153  static void gline(const _GLIO *lio, cons
         }          }
 }  }
   
   static void glineb(const _GLIO *lio, const LINEPT *lp, UINT16 pat) {
   
           LINEPT  lpt;
   
           lpt = *lp;
           lpt.y2 = lp->y1;
           gline(lio, &lpt, pat);
           lpt.y2 = lp->y2;
   
           lpt.x2 = lp->x1;
           gline(lio, &lpt, pat);
           lpt.x2 = lp->x2;
   
           lpt.x1 = lp->x2;
           gline(lio, &lpt, pat);
           lpt.x1 = lp->x1;
   
           lpt.y1 = lp->y2;
           gline(lio, &lpt, pat);
           lpt.y1 = lp->y1;
   }
   
   
 // ----  // ----
   
 static void nor_linebox(const _GLIO *lio, SINT16 x1, SINT16 y1,  static void gbox(const _GLIO *lio, const LINEPT *lp, UINT8 *tile, UINT leng) {
                                                                                         SINT16 x2, SINT16 y2, REG8 pal) {  
           int             x1;
           int             y1;
           int             x2;
           int             y2;
           int             tmp;
           UINT32  csrw;
           GDCVECT vect;
           UINT    planes;
           UINT    adrs[4];
           UINT8   ope[4];
           UINT16  pat;
           UINT8   *tterm;
           UINT    r;
   
           x1 = lp->x1;
           y1 = lp->y1;
           x2 = lp->x2;
           y2 = lp->y2;
   
         lio_line(lio, x1, x2, y1, pal);          if (x1 > x2) {
         if (y1 != y2) {                  tmp = x1;
                 lio_line(lio, x1, x2, y2, pal);                  x1 = x2;
         }                  x2 = tmp;
         for (; y1<y2; y1++) {  
                 lio_pset(lio, x1, y1, pal);  
                 lio_pset(lio, x2, y1, pal);  
         }          }
 }          if (y1 > y2) {
                   tmp = y1;
                   y1 = y2;
                   y2 = tmp;
           }
           if ((x1 > lio->draw.x2) || (x2 < lio->draw.x1) ||
                   (y1 > lio->draw.y2) || (y2 < lio->draw.y1)) {
                   return;
           }
           x1 = max(x1, lio->draw.x1);
           y1 = max(y1, lio->draw.y1);
           x2 = min(x2, lio->draw.x2);
           y2 = min(y2, lio->draw.y2);
   
 static void nor_lineboxfill(const _GLIO *lio, SINT16 x1, SINT16 y1,          csrw = 0;
                                                                                         SINT16 x2, SINT16 y2, REG8 pal) {          if (lio->draw.flag & LIODRAW_UPPER) {
                   csrw += 16000 >> 1;
           }
           if (!(lio->draw.flag & LIODRAW_MONO)) {
                   planes = (lio->draw.flag & LIODRAW_4BPP)?4:3;
                   adrs[0] = csrw + 0x4000;
                   adrs[1] = csrw + 0x8000;
                   adrs[2] = csrw + 0xc000;
                   adrs[3] = csrw + 0x0000;
                   ope[0] = (lp->pal & 1)?GDCOPE_SET:GDCOPE_CLEAR;
                   ope[1] = (lp->pal & 2)?GDCOPE_SET:GDCOPE_CLEAR;
                   ope[2] = (lp->pal & 4)?GDCOPE_SET:GDCOPE_CLEAR;
                   ope[3] = (lp->pal & 8)?GDCOPE_SET:GDCOPE_CLEAR;
           }
           else {
                   planes = 1;
                   adrs[0] = csrw + (((lio->draw.flag + 1) & LIODRAW_PMASK) << 12);
                   ope[0] = (lp->pal)?GDCOPE_SET:GDCOPE_CLEAR;
           }
   
         for (; y1<=y2; y1++) {          if (leng == 0) {
                 lio_line(lio, x1, x2, y1, pal);                  tile = NULL;
                   tterm = NULL;
           }
           else {
                   tterm = tile + leng;
                   tmp = (x1 - lio->draw.x1) & 7;
                   do {
                           r = GDCPATREVERSE(*tile);
                           *tile = (UINT8)((r << tmp) | (r >> (8 - tmp)));
                   } while(++tile < tterm);
                   tile -= leng;
                   tmp = (y1 - lio->draw.y1) * planes;
                   tile += tmp % leng;
           }
   
           pat = 0xffff;
           while(y1 <= y2) {
                   gdcsub_setvectl(&vect, x1, y1, x2, y1);
                   csrw = (y1 * 40) + (x1 >> 4) + ((x1 & 0xf) << 20);
                   r = 0;
                   do {
                           if (tile) {
                                   pat = (*tile << 8) | *tile;
                                   if (++tile >= tterm) {
                                           tile -= leng;
                                   }
                           }
                           gdcsub_vectl(csrw + adrs[r], &vect, pat, ope[r]);
                   } while(++r < planes);
                   y1++;
         }          }
 }  }
   
   
   // ---- CLS
   
   REG8 lio_gcls(GLIO lio) {
   
           LINEPT  lp;
   
           lio_updatedraw(lio);
           lp.x1 = lio->draw.x1;
           lp.y1 = lio->draw.y1;
           lp.x2 = lio->draw.x2;
           lp.y2 = lio->draw.y2;
           lp.pal = lio->work.bgcolor;
           gbox(lio, &lp, NULL, 0);
           return(LIO_SUCCESS);
   }
   
   
 // ----  // ----
   
 REG8 lio_gline(GLIO lio) {  REG8 lio_gline(GLIO lio) {
   
         GLINE   dat;          GLINE   dat;
         LINEPT  lp;          LINEPT  lp;
         SINT16  x1;          UINT16  pat;
         SINT16  y1;          UINT    leng;
         SINT16  x2;  //      UINT    lengmin;
         SINT16  y2;          UINT8   tile[256];
   
         lio_updatedraw(lio);          lio_updatedraw(lio);
         i286_memstr_read(CPU_DS, CPU_BX, &dat, sizeof(dat));          MEML_READSTR(CPU_DS, CPU_BX, &dat, sizeof(dat));
         if (dat.pal == 0xff) {  
                 lp.pal = lio->work.fgcolor;  
         }  
         else {  
                 lp.pal = dat.pal;  
         }  
         if (lp.pal >= lio->draw.palmax) {  
                 return(LIO_ILLEGALFUNC);  
         }  
         lp.x1 = (SINT16)LOADINTELWORD(dat.x1);          lp.x1 = (SINT16)LOADINTELWORD(dat.x1);
         lp.y1 = (SINT16)LOADINTELWORD(dat.y1);          lp.y1 = (SINT16)LOADINTELWORD(dat.y1);
         lp.x2 = (SINT16)LOADINTELWORD(dat.x2);          lp.x2 = (SINT16)LOADINTELWORD(dat.x2);
         lp.y2 = (SINT16)LOADINTELWORD(dat.y2);          lp.y2 = (SINT16)LOADINTELWORD(dat.y2);
         TRACEOUT(("line %d %d %d %d", lp.x1, lp.y1, lp.x2, lp.y2));  
         if (dat.sw) {          TRACEOUT(("lio_gline %d,%d-%d,%d [%d]", lp.x1, lp.y1, lp.x2, lp.y2, dat.type));
                 lp.pat = (GDCPATREVERSE(dat.style[0]) << 8) +  
                                                                                         GDCPATREVERSE(dat.style[1]);  
         }  
         else {  
                 lp.pat = 0xffff;  
         }  
         if (dat.pal == 0xff) {          if (dat.pal == 0xff) {
                 dat.pal = lio->work.fgcolor;                  dat.pal = lio->work.fgcolor;
         }          }
         else if (dat.pal >= lio->draw.palmax) {          if (dat.pal >= lio->draw.palmax) {
                 return(5);                  goto gline_err;
         }          }
         x1 = (SINT16)LOADINTELWORD(dat.x1);          pat = 0xffff;
         y1 = (SINT16)LOADINTELWORD(dat.y1);          if (dat.type < 2) {
         x2 = (SINT16)LOADINTELWORD(dat.x2);                  if (dat.sw) {
         y2 = (SINT16)LOADINTELWORD(dat.y2);                          pat = (GDCPATREVERSE(dat.style[0]) << 8) +
         switch(dat.type) {                                                                                          GDCPATREVERSE(dat.style[1]);
                 case 0:                  }
                         gline(lio, &lp);                  lp.pal = dat.pal;
                         break;                  if (dat.type == 0) {
                           gline(lio, &lp, pat);
                 case 1:                  }
                         nor_linebox(lio, x1, y1, x2, y2, dat.pal);                  else {
                         break;                          glineb(lio, &lp, pat);
                   }
                 case 2:  
                         nor_lineboxfill(lio, x1, y1, x2, y2, dat.pal);  
                         break;  
   
                 default:  
                         return(5);  
         }          }
         return(0);          else if (dat.type == 2) {
                   leng = 0;
                   if (dat.sw == 2) {
                           leng = dat.patleng;
                           if (leng == 0) {
                                   goto gline_err;
                           }
                           MEML_READSTR(LOADINTELWORD(dat.seg), LOADINTELWORD(dat.off),
                                                                                                                                   tile, leng);
                   }
                   if (dat.sw != 1) {
                           lp.pal = dat.pal;
                           gbox(lio, &lp, tile, leng);
                   }
                   else {
                           lp.pal = dat.style[0];
                           gbox(lio, &lp, tile, leng);
                           lp.pal = dat.pal;
                           glineb(lio, &lp, 0xffff);
                   }
           }
           else {
                   goto gline_err;
           }
           return(LIO_SUCCESS);
   
   gline_err:
           return(LIO_ILLEGALFUNC);
 }  }
   

Removed from v.1.9  
changed lines
  Added in v.1.14


RetroPC.NET-CVS <cvs@retropc.net>