home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 287_01 / gradprog.doc < prev    next >
Text File  |  1989-05-25  |  32KB  |  1,233 lines

  1.  
  2.  
  3.  
  4.  
  5.        
  6.                        GRAD Programmers' Reference Manual
  7.                                         
  8.                                 Table Of Content
  9.        
  10.        
  11.        1   Introduction . . . . . . . . . . . . . . . . . . . . . .    1
  12.        2   Basic Philosophy . . . . . . . . . . . . . . . . . . . .    2
  13.        3   calcaddr and plottype  . . . . . . . . . . . . . . . . .    3
  14.           3.1  calcaddr . . . . . . . . . . . . . . . . . . . . . .    3
  15.           3.2  plottype . . . . . . . . . . . . . . . . . . . . . .    3
  16.        4   Frame Table  . . . . . . . . . . . . . . . . . . . . . .    4
  17.        5   Font Table . . . . . . . . . . . . . . . . . . . . . . .    5
  18.        6   HorzLine, VertLine and Line  . . . . . . . . . . . . . .    6
  19.           6.1  HorzLine . . . . . . . . . . . . . . . . . . . . . .    6
  20.           6.2  VertLine . . . . . . . . . . . . . . . . . . . . . .    6
  21.           6.3  Line . . . . . . . . . . . . . . . . . . . . . . . .    7
  22.        7   Circle, Ellipse and Arc  . . . . . . . . . . . . . . . .    9
  23.           7.1  Circle . . . . . . . . . . . . . . . . . . . . . . .    9
  24.           7.2  Ellipse  . . . . . . . . . . . . . . . . . . . . . .   10
  25.           7.3  Arc  . . . . . . . . . . . . . . . . . . . . . . . .   11
  26.        8   Text Writing . . . . . . . . . . . . . . . . . . . . . .   12
  27.        9   Region Filling . . . . . . . . . . . . . . . . . . . . .   13
  28.        10  Block Copy, Save and Load  . . . . . . . . . . . . . . .   15
  29.        11  Writing Graphics Display Adapter Driver  . . . . . . . .   16
  30.        12  Writing Printer Driver . . . . . . . . . . . . . . . . .   17
  31.        13  Hints on Porting to Other C Compiler or Other Machine  .   18
  32.        
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                        GRAD Programmers' Reference Manual
  69.  
  70.        1   Introduction
  71.        
  72.             The source code of the GRAD library are coyrighted. However
  73.        you  are  free  to modify and re-distribute the source files for
  74.        non-commerical  use  and  you indiciate the files are originated 
  75.        from the GRAD library.
  76.             
  77.             If you find and bugs in the GRAD routines, please inform me.
  78.        Your help will be appreciated.
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.                                                                         1
  126.  
  127.  
  128.  
  129.                        GRAD Programmers' Reference Manual
  130.  
  131.        2   Basic Philosophy
  132.        
  133.             The idea of GRAD  system come to  me about 1  year ago (1986
  134.        summer). At that time, I want to write a program that can produce
  135.        high quality,  high speed full page  text and  graphics print out
  136.        suitable for report on a dot matrix printer.
  137.             
  138.             In order to  produce high  quality text  output,  bit mapped
  139.        character must be able to be loaded and included in the print out
  140.        as  graphics  data.  However printing a full  page  of bit mapped
  141.        graphics data on a dot matrix printer may take  5  to 15 minutes.
  142.        So  all normal  text  should be printed in  NLQ text  mode of the
  143.        printer instead of in graphics mode.
  144.             
  145.             Furthermore 2  types of graphics data may be included in the
  146.        print out.  First type is that the graphics  data  are already in
  147.        bit mapped format.  Another type is that the graphics data are in
  148.        high level command format  such  as circles,  lines and dots. The
  149.        advantages of second type are that the graphics data file size is
  150.        relatively small unless the drawing is very complicated. Further-
  151.        more and the drawings may be changed easily.
  152.             
  153.             Very  quickly,  I realized  that  this  program is  not that
  154.        simple.  As the first phase of implementation, a graphics library
  155.        is written which is the GRAD system. The sample program MPrint is
  156.        a simplified version of my original idea.
  157.             
  158.             
  159.             In GRAD,  you may divide the routines into different layers.
  160.        Layer  0  contains routines that directly deal with  the hardware
  161.        (including  memory).   Hence  layer   0   routines  are  hardware
  162.        dependent.  The  number  of routines in  this layer is kept  to a
  163.        minimum.   Layer  1  routines  accepts  physical  coordinates  as
  164.        parameters. No external GRAD functions are in this layer. Most of
  165.        this routines  are written in  assembly  language. GRAD functions
  166.        usually  spend most  of  them  in  this  layer of  codes. Layer 2
  167.        routines handles translation of  logical coordinates  to physical
  168.        coordinates and also clipping  of drawings under  current defined
  169.        window.  Most  of  these routines are  written in C.  Most of the
  170.        layer  2  routines call layer  1  routines to do actual drawings.
  171.        However there are some exception cases that layer 2 routines call
  172.        layer 0  routines directly.  But none of the routines  in layer 1
  173.        and layer 2 access hardware directly.
  174.             
  175.             There are also  some  functions  that  do  not  requires any
  176.        coordinates in the parameter  such as PlotType and ResetWin. They
  177.        are called system functions and do not belong  to any  one of the
  178.        above layers.
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.                                                                         2
  191.  
  192.  
  193.  
  194.                        GRAD Programmers' Reference Manual
  195.  
  196.        3   calcaddr and plottype
  197.        
  198.        3.1  calcaddr
  199.        
  200.             $calc and downln  are the two main  routines  in  the module
  201.        calcaddr. There are also some hardware dependent routines such as
  202.        settext  and setgraph  but they  would  not be discussed  in this
  203.        manual.
  204.             
  205.             $calc accepts x and y coordinates  in  register  AX  and BX.
  206.        Segment and offset values are returned in AX and BX respectively.
  207.        The  return  address a far address that  means the  segment value
  208.        should not be changed because the segment value may  be a logical
  209.        number only  and not a actual  segment number.  The  offset value
  210.        must be a even number and it must  be set  up in such  a way that
  211.        the  whole line  containing  the point  x,y  can  be  accessed by
  212.        changing the offset value only.
  213.             
  214.             downln accepts  the address of  a frame in  ES:BX and return
  215.        the address of the next line with  the same number of  words from
  216.        the beginning  of the line.  This is used to speed up drawings in
  217.        vertical direction such as VertLine.
  218.        
  219.        
  220.        3.2  plottype
  221.        
  222.             The module plottype contain routines  that  access the frame
  223.        memory using the address returned  by $calc and  downln. There is
  224.        nothing fancy so the comment in the module should be sufficient.
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.                                                                         3
  256.  
  257.  
  258.  
  259.                        GRAD Programmers' Reference Manual
  260.  
  261.        4   Frame Table
  262.        
  263.             In  the frame table,  it  contains  all information  about a
  264.        frame.  Information include starting address of  the frame, frame
  265.        width in byte,  horizontal and vertical size,  logical origin and
  266.        the window defined in  that frame.
  267.             
  268.             The  number of entries in  frame table controls  the maximum
  269.        number of frame that can be existed in GRAD system. The number of
  270.        entry in the  frame table is  control by the  value NFRAME during
  271.        compilation time. The default value of NFRAME is 10.
  272.             
  273.             The structure of  the frame table may be  changed  in future
  274.        version.  So do not make any assumption about  the relative order
  275.        of the variables inside the structure in your routines.
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.