home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / bluebook.zip / GRAPHICS.DOC < prev    next >
Text File  |  1986-05-08  |  14KB  |  352 lines

  1. GRAPHICS.DOC -- Graphic Plotting Procedures
  2. ===========================================
  3.  
  4.   From `BLUEBOOK of ASSEMBLY ROUTINES for the IBM PC & XT'
  5.         by Christopher L. Morgan
  6.         Copyright (C) 1984 by The Waite Group, Inc.
  7.  
  8.   Purpose: GRAPHICS.ASM contains routines to perform fundamental plotting jobs
  9.     on the IBM PC. These include point plotting, line drawing, character
  10.     drawing, and filling of areas.  GRAPHICS.DOC describes the routines.
  11.  
  12.    Contents:
  13.    ---------
  14.    CLS        --  Clear the screen
  15.    GET_COLOR    --  Get the color of a point on the med res color screen
  16.    GMSG_OUT    --  Plot a string
  17.    PAINT    --  Fill an area with specified color
  18.    RCHAR    --  Plot a raster character
  19.    SCHAR    --  Plot a stroke character
  20.    SET_BOX    --  Fill a rectangular box with specified color
  21.    SET_LIN    --  Draw a line
  22.    SET_PT    --  Plot a point
  23.    XOR_BOX    --  Fill a rectangular box using XOR
  24.    XOR_PT    --  Plot a point using XOR
  25.  _____________________________________________________________________________
  26.  
  27. Primitive Functions
  28. -------------------
  29.  
  30. CLS -- Clear the graphics screen.
  31.  
  32.   Function: This routine clears the color graphics screen.
  33.  
  34.   Input: None.
  35.  
  36.   Output: Just to the screen.
  37.  
  38.   Registers used: Unmodified; AX & CX are saved, then restored.
  39.  
  40.   Segments referenced: Upon entry, ES must point to screen RAM at B8000H.
  41.  
  42.   Routines called: None.
  43.  -----------------------------------------------------------------------------
  44. SET_PT -- Plot a point on the medium resolution color screen.
  45.  
  46.   Function: This routine plots a point on the medium resolution color graphics
  47.     screen. The pixel at the specified location is given a specified color,
  48.     over-writing the old color.
  49.  
  50.   Input: Upon entry:
  51.                 X-coordinate (0-319) of the point is in SI
  52.              Y-coordinate (0-199) of the point is in DI
  53.              color (0-3) is in DX.    
  54.  
  55.   Output: Just to the screen.
  56.  
  57.   Registers used: Unmodified; SI,DI, & DX are used for input.
  58.  
  59.   Segments referenced: Upon entry, ES must point to video RAM at B8000, and
  60.     DS must point to a data segment containing the following look-up table
  61.     of rotated color masks:
  62.  
  63.     CTABLE    DW    0003FH,0403FH,0803FH,0C03FH
  64.         DW    000CFH,010CFH,020CFH,030CFH
  65.         DW    000F3H,004F3H,008F3H,00CF3H
  66.         DW    000FCH,001FCH,002FCH,003FCH
  67.  
  68.   Routines called: None.
  69.  
  70.   Note: No bounds checking is performed.  Programmer must ensure the 
  71.     coordinates and color are in their proper ranges.
  72.  -----------------------------------------------------------------------------
  73. XOR_PT -- Plot a point using XOR onto the med res color screen.
  74.  
  75.   Function: This routine plots a point on the med res screen using the 
  76.     `exclusive or' operation. The pixel at the specified location is colored
  77.      with a color obtained by `exclusive oring' its original color with a
  78.      specified color.  This function is useful for making cursors.
  79.  
  80.   Input: Upon entry:
  81.                 X-coordinate (0-319) of the point is in SI
  82.              Y-coordinate (0-199) of the point is in DI
  83.              color (0-3) is in DX.    
  84.  
  85.   Output: Just to the screen.
  86.  
  87.   Registers used: Unmodified; SI,DI, & DX are used for input.
  88.  
  89.   Segments referenced: Upon entry, ES must point to video RAM at B8000, and
  90.     DS must point to a data segment containing the following look-up table
  91.     of rotated color masks:
  92.  
  93.     CTABLE    DW    0003FH,0403FH,0803FH,0C03FH
  94.         DW    000CFH,010CFH,020CFH,030CFH
  95.         DW    000F3H,004F3H,008F3H,00CF3H
  96.         DW    000FCH,001FCH,002FCH,003FCH
  97.  
  98.   Routines called: None.
  99.  
  100.   Note: No bounds checking is performed.  Programmer must ensure the 
  101.     coordinates and color are in their proper ranges.
  102.  
  103.  -----------------------------------------------------------------------------
  104. GET_COLOR  -- Get color of a point on med res screen.
  105.  
  106.   Function: This routine returns the color of a specified point on the med
  107.     res color screen.  The color is returned in AL.
  108.  
  109.   Input: Upon entry:
  110.                 X-coordinate (0-319) of the specified point is in SI
  111.              Y-coordinate (0-199) of the specified point is in DI.
  112.  
  113.   Output: Upon exit, AL contains the color (0-3) of the pixel at the 
  114.     specified location.
  115.  
  116.   Registers used: Only AX is modified.  SI & DI are used for input and AL is
  117.     used for output.
  118.  
  119.   Segments referenced: Upon entry, ES must point to the video RAM at B8000H.
  120.  
  121.   Routines called: None.
  122.  
  123.   Note: No bounds checking is performed.  Programmer must ensure the 
  124.     coordinates and color are in their proper ranges.
  125.  -----------------------------------------------------------------------------
  126. SET_BOX -- Fill a rectangular box.
  127.  
  128.   Function: This routine fills a rectangular box on the color graphics screen
  129.     with a specified color.
  130.  
  131.   Input: Upon entry:
  132.              X-coordinate of upper left corner is in X1
  133.              Y-coordinate of upper left corner is in Y1
  134.              X-coordinate of lower right corner is in X2
  135.              Y-coordinate of lower right corner is in Y2
  136.              Color of the rectangle is in bits 0 & 1 of COLOR.
  137.  
  138.   Output: Just to the screen.
  139.  
  140.   Registers used: Unmodified; SI, DI, DX, BX, CX, & AX are save & restored.
  141.  
  142.   Segments referenced: Upon entry, ES must point to video RAM at B8000, and
  143.     DS must point to a data segment containing the following look-up table
  144.     for color masks:
  145.  
  146.     XTABLE    DW    0FFC0H,0FFF0H,0FFFCH,0FFFFH
  147.         DW    03FC0H,03FF0H,03FFCH,03FFFH
  148.         DW    00FC0H,00FF0H,00FFCH,00FFFH
  149.         DW    003C0H,003F0H,003FCH,003FFH
  150.  
  151.   Routines called: None.
  152.  
  153.   Note: No bounds checking is performed.  Programmer must ensure the 
  154.     coordinates are in their proper range and order; i.e., the following
  155.     must be true:
  156.          0 <= X1 <= X2 <= 319
  157.          0 <= Y1 <= Y2 <= 199.
  158.  -----------------------------------------------------------------------------
  159. XOR_BOX -- Fill a rectangular box using XOR.
  160.  
  161.   Function: This routine fills a rectangular box in the color graphics screen
  162.     with a given color using the `exclusive or' operation. Each pixel in the
  163.     rectangle is colored with a color obtained by `exclusive oring' its 
  164.     original color with a specified color.  This function is useful for 
  165.     making cursors.
  166.  
  167.   Input: Upon entry:
  168.              X-coordinate of upper left corner is in X1
  169.              Y-coordinate of upper left corner is in Y1
  170.              X-coordinate of lower right corner is in X2
  171.              Y-coordinate of lower right corner is in Y2
  172.              Color of the rectangle is in bits 0 & 1 of COLOR.
  173.  
  174.   Output: Just to the screen.
  175.  
  176.   Registers used: Unmodified; SI, DI, DX, BX, CX, & AX are saved & restored.
  177.  
  178.   Segments referenced: Upon entry, ES must point to video RAM at B8000, and
  179.     DS must point to a data segment containing the following look-up table
  180.     for color masks:
  181.  
  182.     XTABLE    DW    0FFC0H,0FFF0H,0FFFCH,0FFFFH
  183.         DW    03FC0H,03FF0H,03FFCH,03FFFH
  184.         DW    00FC0H,00FF0H,00FFCH,00FFFH
  185.         DW    003C0H,003F0H,003FCH,003FFH
  186.  
  187.   Routines called: None.
  188.  
  189.   Note: No bounds checking is performed.  Programmer must ensure the 
  190.     coordinates are in their proper range and order; i.e., the following
  191.     must be true:
  192.          0 <= X1 <= X2 <= 319
  193.          0 <= Y1 <= Y2 <= 199.
  194.  -----------------------------------------------------------------------------
  195.     
  196. Second Level Functions (use Primitive Functions)
  197. ----------------------
  198.  
  199. SET_LIN -- Draw a line.
  200.  
  201.   Function: This routine draws a line from (X1,Y1) to (X2,Y2) in the specified
  202.     color.  It uses Bresenham's algorithm.
  203.  
  204.   Input: Upon entry:
  205.              X-coordinate of starting point is in X1
  206.              Y-coordinate of starting point is in Y1
  207.              X-coordinate of ending point is in X2
  208.              Y-coordinate of ending point is in Y2
  209.              Color of line is in COLOR.
  210.  
  211.   Output: Just to the screen.
  212.  
  213.   Registers used: Unmodified; BX, CX, DX, SI, DI, & AX are saved & restored.
  214.  
  215.   Segments referenced: Upon entry, ES must point to video RAM at B8000H, and
  216.     DS must point to a data segment used by the SET_PT plotting routine.
  217.  
  218.   Routines called: SET_PT.
  219.  
  220.   Note: No bounds checking is performed.  Programmer must ensure the 
  221.     coordinates are in their proper range; i.e., the following
  222.     must be true:
  223.          0 <= X1 & X2 <= 319
  224.          0 <= Y1 & Y2 <= 199
  225.                  0 <= COLOR <= 3.
  226.  -----------------------------------------------------------------------------
  227. SCHAR -- Plot a stroke character.
  228.  
  229.   Function: This routine plots a stroke character. It uses a stroke character
  230.     table in which each character is stored as a series of strokes.  The
  231.     programmer must create this stroke character table according to specific
  232.     rules. Each stroke is stored as three bytes.  The first byte contains a
  233.     code as follows:
  234.              1AH = end of strokes
  235.              `U' = pen Up, move to new current position,
  236.                  but don't draw
  237.              `D' = pen Down, draw a stroke from old to
  238.                  new current position.
  239.  
  240.     The second byte contains the local X-coordinate of the new current
  241.     position, and the third byte contains the local Y-coordinate of the new
  242.     current position. These local coordinates are relative to the upper left
  243.     corner of the character cell. At the beginning of the stroke table is an
  244.     address table for the locations of the strokes for each of the characters.
  245.  
  246.   Input: Upon entry:
  247.                      ASCII code character is in AL
  248.              X-coord of upper left corner of char cell is in X0
  249.              Y-coord of upper left corner of char cell is in Y0
  250.              Horizontal magnitude is in XMAGN
  251.              Vertical magnitude is in YMAGN
  252.              Color of character is in COLOR.
  253.  
  254.   Output: Just to the screen.
  255.  
  256.   Registers used: Unmodified; SI, CX, & AX are saved & restored.
  257.  
  258.   Segments referenced: Upon entry, ES must point to video RAM at B8000H, and
  259.     DS must point to the data segment used by the point and line-drawing
  260.     routines. This data segment must also contain the table of stroke chars.
  261.  
  262.   Routines called: SET_LIN.
  263.  
  264.   Note: No bounds checking is performed. Unpredictable results happen if the
  265.     horizontal or vertical magnitude is too large. A string of raster 
  266.     characters can be printed using the GMSG_OUT routine.
  267.  -----------------------------------------------------------------------------
  268. RCHAR  -- Plot a raster character.
  269.  
  270.   Function: This routine plots a raster character. It uses the raster
  271.     character table in the IBM BIOS ROM. Only ASCII codes 0 through 127
  272.     are supported.
  273.  
  274.   Input: Upon entry:
  275.                      ASCII code character is in AL
  276.              X-coord of upper left corner of char cell is in X0
  277.              Y-coord of upper left corner of char cell is in Y0
  278.              Horizontal magnitude is in XMAGN
  279.              Vertical magnitude is in YMAGN
  280.              Color of character is in COLOR.
  281.  
  282.   Output: Just to the screen
  283.  
  284.   Registers used: Unmodified; SI, DX, CX, & AX are saved & restored.
  285.  
  286.   Segments referenced: Upon entry, ES must point to video RAM at B8000H, and
  287.     DS must point to the data segment used by the box-fill routine.
  288.  
  289.   Routines called: SET_BOX.
  290.  
  291.   Note: No bounds checking is performed. Unpredictable results happen if the
  292.     horizontal or vertical magnitude is too large. A string of raster 
  293.     characters can be printed using the GMSG_OUT routine.
  294.  -----------------------------------------------------------------------------
  295. GMSG_OUT  -- Print a string on the graphics screen.
  296.  
  297.   Function: This routine prints a message on the graphics screen, using the
  298.     SCHAR or RCHAR routines. The message terminates in a zero. 
  299.  
  300.   Input: Upon entry:
  301.                      Address of message is in SI
  302.              X-coord of upper left corner of string is in XMSG
  303.              Y-coord of upper left corner of string is in YMSG
  304.              Horizontal magnitude of characters is in XMAGN
  305.              Vertical magnitude of characters is in YMAGN
  306.              Color of characters is in COLOR
  307.              Choice of fonts (0=stroke,1=raster) is in FONT.
  308.  
  309.   Output: Just to the screen
  310.  
  311.   Registers used: Unmodified.
  312.  
  313.   Segments referenced: Upon entry, ES must point to video RAM at B8000H, and
  314.     DS must point to the data segment used by the point-plotting, box-filling,
  315.     line-drawing, and stroke character routines.
  316.  
  317.   Routines called: RCHAR & SCHAR
  318.  
  319.   Note: No bounds checking is performed. Unpredictable results happen if the
  320.     horizontal or vertical magnitude is too large.
  321.  -----------------------------------------------------------------------------
  322. PAINT -- Fill an area on the screen with color.
  323.  
  324.   Function: This routine fills an area on the graphics screen with a specified
  325.     color. It begins `painting' at a `seed' position, filling a region bounded
  326.     by a `boundary' color.
  327.  
  328.   Input: Upon entry:
  329.              X-coordinate of seed is in SI
  330.              Y-coordinate of seed is in DI
  331.              Paint color is in the low byte of COLOR
  332.              Boundary color is in the high byte of COLOR.
  333.  
  334.   Output: Just to the screen.
  335.  
  336.   Registers used: Unmodified.
  337.  
  338.   Segments referenced: Upon entry, ES must point to video RAM at B8000H, and
  339.     DS must point to the data segment used by the point-plotting & get-color
  340.     routines.
  341.  
  342.   Routines called: SET_PT & GET_COLOR
  343.  
  344.   Note: The region must be completely surrounded by a boundary drawn in the
  345.     boundary color. Any paint color in the region can obstruct the filling
  346.     process, acting just like a boundary. This algorithm uses its own stack.
  347.     If the region is too complex, this stack will overflow.  There is no
  348.     check for stack overflow, but one could easily be added.
  349.  -----------------------------------------------------------------------------
  350.  _____________________________________________________________________________
  351. >>>>> Physical EOF GRAPHICS.DOC <<<<<
  352.