1: /*
   2:  * Copyright (c) 1980 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)update.c	5.1 (Berkeley) 4/26/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * update: the key output optimization routine of the whole editor.
  13:  * The input consists of two bit matrices (mold is what's on the screen,
  14:  * mnew is what we want to be on the screen) and the coordinates of
  15:  * the lower left corner on the screen where this matrix is.
  16:  * This routine does whatever is necessary to get the screen to look
  17:  * like mnew, assuming that it currently looks like mold.
  18:  *
  19:  * (If I could patent this process for bread and other food I
  20:  * would be a rich man.)
  21:  */
  22: 
  23: #include "bit.h"
  24: 
  25: update(mold, mnew, rows, cols, baser, basec)
  26: bitmat mold, mnew;
  27: int rows, cols, baser, basec;
  28: {
  29:     int irow;
  30:     register int i, j, k;
  31:     int r1, r2, c1, c2, nr1, nr2, nc1, nc2;
  32:     extern int QUIET;
  33: 
  34: #ifdef TRACE
  35:     if (trace)
  36:         fprintf(trace, "update(mold=%x, mnew=%x, rows=%d, cols=%d, baser=%d, basec=%d)\n", mold, mnew, rows, cols, baser, basec);
  37: #endif
  38: 
  39:     if (QUIET)
  40:         return;
  41:     aminmax(mold, rows, cols, &r1, &c1, &r2, &c2);
  42:     aminmax(mnew, rows, cols, &nr1, &nc1, &nr2, &nc2);
  43:     r1 = min(r1, nr1); r2 = max(r2, nr2);
  44:     c1 = min(c1, nc1); c2 = max(c2, nc2);
  45: 
  46:     dumpmat("mold:", mold, rows, cols);
  47:     dumpmat("mnew:", mnew, rows, cols);
  48: 
  49:     for (i=r1; i<=r2; i++) {
  50:         irow = baser + rows - i - 1;
  51:         if (emptyrow(mnew, rows, cols, i)) {
  52:             if (emptyrow(mold, rows, cols, i)) {
  53:                 continue;   /* identically blank. skip. */
  54:             }
  55:             /*
  56: 			 * Row i is to be cleared.  Look for some more
  57: 			 * rows to clear and do it all at once.
  58: 			 */
  59:             for (j=i+1; j<rows && emptyrow(mnew,rows,cols,j); j++)
  60:                 ;
  61:             areaclear(baser+rows-j, basec, irow, basec+cols-1);
  62:             i = j-1;    /* skip the others */
  63:         } else for (j=c1; j<=c2; j++) {
  64:             /*
  65: 			 * Result row is not all blank.  We look for stretches
  66: 			 * of bits that have to be changed (in either
  67: 			 * direction) and draw an exclusive or line over all
  68: 			 * the bits in each stretch.
  69: 			 */
  70:             if (mat(mold,rows,cols,i,j,1)!=mat(mnew,rows,cols,i,j,2)){
  71:                 for (k=j+1; k<cols && mat(mold,rows,cols,i,k,3)!=
  72:                     mat(mnew,rows,cols,i,k,4); k++)
  73:                     ;
  74:                 k--;
  75:                 setxor();
  76:                 line(basec+j, irow, basec+k, irow);
  77:                 j = k;  /* skip the others */
  78:             }
  79:         }
  80:     }
  81: }

Defined functions

update defined in line 25; never used

Defined variables

sccsid defined in line 8; never used
Last modified: 1987-02-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2463
Valid CSS Valid XHTML 1.0 Strict