home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / bits / bitblit / upfront.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-05-23  |  3.0 KB  |  92 lines

  1. /*
  2.  * name:         upfront
  3.  *
  4.  * description: pull layer lp to the front of the screen.
  5.  *
  6.  * synopsis:     upfront (lp)
  7.  *              struct layer    *lp;
  8.  *
  9.  * globals:      bottomlayer  (r/w)
  10.  *              toplayer      (r/w)
  11.  *
  12.  * calls:        screenswap  (screenswap.c)
  13.  *              rectxrect    (rectxrect.c)
  14.  *
  15.  * called by:    this is a top level routine.
  16.  *              dellayer   (dellayer.c)
  17.  *              newlayer   (newlayer.c)
  18.  */
  19. #include "layers.h"
  20.  
  21. extern struct layer *toplayer;
  22. extern struct layer *bottomlayer;
  23.  
  24. upfront (lp)
  25. struct layer  *lp;
  26. {
  27.    struct layer    *fr;                /* a layer in front of lp */
  28.    struct layer    *beh;               /* a layer behind lp */
  29.    struct obscured *op;
  30.    struct obscured *nop;
  31.  
  32.    if (lp -> ly_front == null)
  33.        return;                         /* lp is at the front already */
  34.    for (fr = lp -> ly_front; fr != null; fr = fr -> ly_front)
  35.                                       /* fr = each layer in front of lp */
  36.        for (op = lp -> ly_obs; op != null;) {
  37.         /* op = each obscured portion of lp */
  38.            nop = op;
  39.            op = op -> ob_next;
  40.            if (nop -> ob_obs == fr) {    /* fr obscures nop */
  41.               (void) screenswap (nop -> ob_bmap, &(nop -> ob_bmap -> bm_rect));
  42.             /*
  43.             * unlink nop from lp
  44.              */
  45.                if (nop -> ob_prev != null)
  46.                    nop -> ob_prev -> ob_next = nop -> ob_next;
  47.                else
  48.                    lp -> ly_obs = nop -> ob_next;
  49.                if (nop -> ob_next != null)
  50.                    nop -> ob_next -> ob_prev = nop -> ob_prev;
  51.                else
  52.                     lp -> ly_endobs = nop -> ob_prev;
  53.             /*
  54.             * link nop into end of fr
  55.              */
  56.                if (fr -> ly_endobs != null)
  57.                     fr -> ly_endobs -> ob_next = nop;
  58.                else
  59.                    fr -> ly_obs = nop;
  60.                nop -> ob_prev = fr -> ly_endobs;
  61.                nop -> ob_next = null;
  62.                fr -> ly_endobs = nop;
  63.            }
  64.        }
  65.  /*
  66.  * move lp to front of layer list by
  67.  * unlinking lp from layer list...
  68.  */
  69.    if (lp -> ly_back != null)
  70.        lp -> ly_back -> ly_front = lp -> ly_front;
  71.    else
  72.        bottomlayer = lp -> ly_front;
  73.    if (lp -> ly_front != null)
  74.        lp -> ly_front -> ly_back = lp -> ly_back;
  75.    else
  76.         toplayer = lp -> ly_back;
  77.  /*
  78.  * ...and linking lp in at head of list
  79.  */
  80.    toplayer -> ly_front = lp;
  81.    lp -> ly_front = null;
  82.    lp -> ly_back = toplayer;
  83.    toplayer = lp;
  84.    for (beh = bottomlayer; beh != lp; beh = beh -> ly_front)
  85.                                       /* beh = all other layers from back to
  86.                                          front */
  87.        for (op = beh -> ly_obs; op != null; op = op -> ob_next)
  88.                                        /* op = each obscured portion of beh */
  89.            if (rectxrect (&(lp -> ly_rect), &(op -> ob_rect)))
  90.                op -> ob_obs = lp;        /* mark op obscured by lp */
  91. }
  92.