home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xibm.zip / ibm8514 / brcOutL.c < prev    next >
C/C++ Source or Header  |  1991-09-20  |  4KB  |  191 lines

  1. /*
  2.  * $Id: brcOutL.c,v 1.1 1991/09/20 19:10:24 mtranle Exp $
  3.  *
  4.  * Copyright IBM Corporation 1987,1990
  5.  *
  6.  * All Rights Reserved
  7.  *
  8.  * Permission to use, copy, modify, and distribute this software and its
  9.  * documentation for any purpose and without fee is hereby granted,
  10.  * provided that the above copyright notice appear in all copies and that 
  11.  * both that copyright notice and this permission notice appear in
  12.  * supporting documentation, and that the name of IBM not be
  13.  * used in advertising or publicity pertaining to distribution of the
  14.  * software without specific, written prior permission.
  15.  *
  16.  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17.  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  18.  * IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19.  * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20.  * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22.  * SOFTWARE.
  23.  *
  24. */
  25. /*
  26.  * PRPQ 5799-PFF (C) COPYRIGHT IBM CORPORATION 1987,1990
  27.  * LICENSED MATERIALS - PROPERTY OF IBM
  28.  * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
  29.  */
  30. /*
  31.  *  Hardware interface routines for IBM 8514/A adapter for
  32.  *  X.11 server(s) on IBM equipment.
  33.  *
  34.  */
  35.  
  36. /* SOLID AREA FILL OUTLINE
  37.  *
  38.  * This draws a strange line intended to be used as an outline for area fill
  39.  * IT SHOULD NOT BE USED FOR ANYTHING ELSE
  40.  * 
  41.  */
  42.  
  43. #include "X.h"
  44.  
  45. #include "OScompiler.h"
  46.  
  47. #include "x8514.h"
  48.  
  49. #include "ibmTrace.h"
  50.  
  51. extern int mergexlate[] ;
  52. extern int ibm8514cursorSemaphore ;
  53.  
  54. #define VERT    1
  55. #define HORIZ    2
  56. #define SLOP1    3
  57. #define SLOPN1    4
  58. #define YUCK    5
  59.  
  60. void
  61. ibm8514Outline( planes, x0, y0, x1, y1 )
  62.      unsigned long int planes ;
  63.      int x0, y0, x1, y1 ;
  64. {
  65.     int saved ;
  66.     int qd,k1,k2,dx,dy,adx,ady ;
  67.  
  68.     TRACE(("ibm8514OutLine(x0=%d, y0=%d, x1=%d, y1=%d)\n", x0,y0,x1,y1)) ;
  69.  
  70.     dx = x1 - x0 ;
  71.     adx = ABS( dx ) ;
  72.     dy = y1 - y0 ;
  73.     ady = ABS( dy ) ;
  74.  
  75.     saved = !ibm8514cursorSemaphore
  76.     && ibm8514CheckCursor( MIN( x0, x1 ), MIN( y0, y1 ), adx, ady ) ;
  77.  
  78.     ibm8514ATRNotBusy ;
  79.     ibm8514CheckQueue( 5 ) ;
  80.     SETFN1( FNCOLOR1, mergexlate[GXxor] ) ;
  81.     SETCOL1( 255 ) ;
  82.     PLNWENBL( planes ) ;
  83.     PLNRENBL( FILL_STAGE_RPLANE ) ;
  84.     SETET( 0 ) ;        /* bresenham error term.  See README file
  85.                    about this */
  86.  
  87.     if ( !dx )
  88.     qd = VERT ;
  89.     else if ( !dy )
  90.     qd = HORIZ ;
  91.     else if ( dx == dy )
  92.     qd = SLOPN1 ;
  93.     else if ( adx == ady )
  94.     qd = SLOP1 ;
  95.     else
  96.     qd = YUCK ;
  97.  
  98.     ibm8514CheckQueue( 6 ) ;    /* Max # of outw's in switch statement */
  99.     switch ( qd ) {
  100.       case VERT:
  101.     SETLX( ady ) ;        /* stepping along Y */
  102.     SETY0( ( dy > 0 ) ? y0 : y1 ) ;
  103.     SETX0( x0 ) ;
  104.     COMMAND( 0xA0DF ) ;
  105.     break ;
  106.       case HORIZ:
  107.     break ;
  108.       case SLOP1:
  109.     SETLX( adx ) ;
  110.     if ( dx > 0 ) {
  111.         SETX0( x1 ) ;
  112.         SETY0( y1 ) ;
  113.     }
  114.     else {
  115.         SETX0( x0 ) ;
  116.         SETY0( y0 ) ;
  117.     }
  118.     COMMAND( 0xA0BF ) ;
  119.     break ;
  120.       case SLOPN1:
  121.     SETLX( adx ) ;
  122.     if ( dx > 0 ) {
  123.         SETX0( x0 ) ;
  124.         SETY0( y0 ) ;
  125.     }
  126.     else {
  127.         SETX0( x1 ) ;
  128.         SETY0( y1 ) ;
  129.     }
  130.     COMMAND( 0xA0FF ) ;
  131.     break ;
  132.       case YUCK:        /* slope is not 0,1,-1,or infinite */
  133.     if ( adx >= ady ) {    /* STEPX */
  134.         k1 = 2 * ady ;
  135.         SETK1( k1 ) ;
  136.         k2 = k1 - 2 * adx ;
  137.         SETK2( k2 ) ;
  138.         SETLX( adx ) ;
  139.         if ( dy > 0 ) {
  140.         SETX0( x0 ) ;
  141.         SETY0( y0 ) ;
  142.         if ( dx > 0 )
  143.             COMMAND( 0xA0B7 ) ; /*QUAD1*/
  144.         else
  145.             COMMAND( 0xA097 ) ; /*QUAD 4*/
  146.         }
  147.         else {
  148.         SETX0( x1 ) ;
  149.         SETY0( y1 ) ;
  150.         if ( dx > 0 )
  151.             COMMAND( 0xA097 ) ; /*QUAD8*/
  152.         else
  153.             COMMAND( 0xA0B7 ) ; /*QUAD 5*/
  154.         }
  155.     }
  156.     else {            /* STEPY */
  157.         k1 = 2 * adx ;
  158.         SETK1( k1 ) ;
  159.         k2 = k1 - 2 * ady ;
  160.         SETK2( k2 ) ;
  161.         SETLX( ady ) ;
  162.         if ( dy > 0 ) {
  163.         SETX0( x0 ) ;
  164.         SETY0( y0 ) ;
  165.         if ( dx > 0 )
  166.             COMMAND( 0xA0F7 ) ; /*QUAD2*/
  167.         else
  168.             COMMAND( 0xA0D7 ) ; /*QUAD 3*/
  169.         }
  170.         else {
  171.         SETX0( x1 ) ;
  172.         SETY0( y1 ) ;
  173.         if ( dx > 0 )
  174.             COMMAND( 0xA0D7 ) ; /*QUAD7*/
  175.         else
  176.             COMMAND( 0xA0F7) ; /*QUAD 6*/
  177.         }
  178.     }
  179.     break ;
  180.     }                /* end switch */
  181.  
  182.     ibm8514ClearQueue( 3 ) ;
  183.     SETFN1( FNCOLOR1, FNREPLACE ) ;
  184.     PLNWENBL( ibm8514ALLPLANES ) ;
  185.     PLNRENBL( ibm8514ALLPLANES ) ;
  186.  
  187.     if ( saved )
  188.     ibm8514ReplaceCursor() ;
  189.     return ;
  190. }
  191.