home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / CMAPCOPY.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  1.5 KB  |  66 lines

  1. /*
  2.     cmapcopy.c    5/03/90
  3.  
  4.     % Function that copies a cmap into another.
  5.     By Ted.
  6.  
  7.     OWL 1.2
  8.     Copyright (c) 1988, by Oakland Group, Inc.
  9.     ALL RIGHTS RESERVED.
  10.  
  11.     Revision History:
  12.     -----------------
  13. */
  14.  
  15. #include "oakhead.h"
  16. #include "disppriv.h"
  17. #include "cmapdecl.h"
  18. /* -------------------------------------------------------------------------- */
  19.  
  20. void cmap_Copy(cmap_type dcmap, cmap_type scmap, byte attr)
  21. /*
  22.     Copy from source to destination cmap, filling in with blanks and attr
  23.     if the destination cmap is not filled by the source cmap.
  24. */
  25. {
  26.     int row, len, tlen;
  27.     char *cbuf, *scbuf;
  28.     byte *abuf, *sabuf;
  29.  
  30.     len = omin(scmap->ncols, dcmap->ncols);
  31.     tlen = dcmap->ncols - len;
  32.  
  33.     cbuf = dcmap->charbuf;
  34.     abuf = dcmap->attrbuf;
  35.     scbuf = scmap->charbuf;
  36.     sabuf = scmap->attrbuf;
  37.  
  38.     /* Copy stuff */
  39.     for (row = 0; row < dcmap->nrows; row++) {
  40.         /* Clear out bottom if we grew taller */
  41.         if (row >= scmap->nrows) {
  42.             memset((VOID *) cbuf, ' ',  (dcmap->nrows - row) * dcmap->ncols);
  43.             memset((VOID *) abuf, attr, (dcmap->nrows - row) * dcmap->ncols);
  44.             break;
  45.         }
  46.         /* Copy line */
  47.         memmove((VOID *) cbuf, (VOID *) scbuf, len);
  48.         memmove((VOID *) abuf, (VOID *) sabuf, len);
  49.  
  50.         cbuf += len;
  51.         abuf += len;
  52.         scbuf += scmap->ncols;
  53.         sabuf += scmap->ncols;
  54.  
  55.         /* Clear out ends if we grew wider */
  56.         if (tlen > 0) {
  57.             memset((VOID *) cbuf, ' ',  tlen);
  58.             memset((VOID *) abuf, attr, tlen);
  59.             cbuf += tlen;
  60.             abuf += tlen;
  61.         }
  62.     }
  63. }
  64. /* -------------------------------------------------------------------------- */
  65.  
  66.