home *** CD-ROM | disk | FTP | other *** search
/ MS DOS Archives 1 / MS-DOS_Archives_Volume_One_Walnut_Creek.iso / msdos / graphics / int_70h.arc / INT70H.DOC < prev   
Text File  |  1988-12-07  |  9KB  |  331 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.            ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
  8.            ├───┼───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┼───┤
  9.            ├───┤                                               ├───┤
  10.            ├───┤       ════╦════   ╔═╗    ║  ═════╦═════       ├───┤
  11.            ├───┤           ║       ║ ╚╗   ║       ║            ├───┤
  12.            ├───┤           ║       ║  ╚╗  ║       ║            ├───┤
  13.            ├───┤           ║       ║   ╚╗ ║       ║            ├───┤
  14.            ├───┤       ════╩════   ║    ╚═╝       ║            ├───┤
  15.            ├───┤                                               ├───┤
  16.            ├───┤         ╔══════╗   ╔═════╗   ║                ├───┤
  17.            ├───┤               ╔╝   ║  ╔╦═╣   ║                ├───┤
  18.            ├───┤             ╔═╝    ║ ╔╬╝ ║   ╠═══╗            ├───┤
  19.            ├───┤             ║      ╠═╩╝  ║   ║   ║            ├───┤
  20.            ├───┤             ║      ╚═════╝   ║   ║            ├───┤
  21.            ├───┤                                               ├───┤
  22.            ├───┼───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┼───┤
  23.            └───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
  24.  
  25.  
  26.                                       b y
  27.  
  28.  
  29.                             T e d   O ' C o n n o r
  30.  
  31.  
  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.  
  69.  
  70.  
  71.  
  72.  
  73.               The program INT 70h is a very simple driver for the
  74.          hercules graphics card (aka the HGC).  It is intended to ease
  75.          the use of the graphics while still allowing full use of the
  76.          card at machine language speed.  It even has its own language
  77.          for accessing the different functions.
  78.  
  79.  
  80.               There are only 8 commands in the INT 70h language:
  81.  
  82.                    0  Stop the interupt program
  83.  
  84.                    1  Turn graphics on
  85.  
  86.                    2  Turn text on
  87.  
  88.                    3  Draw a point
  89.  
  90.                    4  Draw a line
  91.  
  92.                    5  Set the active page
  93.  
  94.                    6  Clear the given page
  95.  
  96.                    7  Fill the given page
  97.  
  98.  
  99.               Since there are only 7 instructions, I use the four most
  100.          significant bits in a byte to specify a function in a command
  101.          byte.  The four least significant bits specify a page of
  102.          memory in some functions (the hercules graphics card has two
  103.          graphics/text pages).
  104.  
  105.               The language is a very simple one.  You set a byte in
  106.          memory to a value as specified above.  If it needs parameters
  107.          (i.e. screen coordinates for a point), you use the next few
  108.          WORDS of memory to specify them.  You use memory words (2
  109.          bytes) because a screen coordinate may be more than 255 which
  110.          is as large a value as a byte can handle.  One last important
  111.          note:
  112.  
  113.                         Always follow your program code by a
  114.                    byte value of 0 in the command byte
  115.                    position.  This tells the interrupt when
  116.                    to stop executing your code.
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.               This is an example of what your code should look like:
  140.  
  141.                ┌─────────────────────────────────────────────────────┐
  142.          (1)   │   DB   11h              ; turn on the graphics mode │
  143.                │                         ;     (page 1)              │
  144.          (2)   │   DB   51h              ; set active page           │
  145.          (3)   │   DB   42h              ; draw a line using XOR     │
  146.          (4)   │   DW   10, 20, 40, 80   ; from (10,20) to (40,80)   │
  147.                └─────────────────────────────────────────────────────┘
  148.  
  149.             line (1):   10h --->  turn on graphics
  150.                        + 1h --->  page 1 (you can use page 0 or 1)
  151.                        ----
  152.                         11h
  153.  
  154.             line (2):   50h --->  set active page (for plotting points
  155.                                                      and lines)
  156.                        + 1h --->  page 1 is active
  157.                        ----
  158.                         51h
  159.  
  160.             line (3):   40h --->  draw a line
  161.                        + 2h --->  use the XOR method
  162.                        ----
  163.                         42h
  164.  
  165.             line (4):   10, 20, 40, 80 --->  words (specified w/ DW
  166.                                                      instead of DB)
  167.  
  168.          So, this program would turn on the graphics page,  without
  169.          clearing it and plot a line using an exclusive or method.
  170.  
  171.  
  172.               To call this interrupt, you must do two things:
  173.  
  174.                    1)  put the address in the AX & BX registers
  175.  
  176.                    2)  use the instruction  INT  70h
  177.  
  178.          The address in AX & BX is the segment where the code is being
  179.          kept is put into AX and the offset within that segment is put
  180.          into BX.  This can be accomplished in one of two ways:
  181.  
  182.  
  183.  
  184.                    MOV  AX, SEG <codename>
  185.                    MOV  BX, OFFSET <codename>
  186.                    INT  70h
  187.  
  188.                            or
  189.  
  190.                    MOV  AX, DS
  191.                    LEA  BX, <codename>
  192.                    INT  70h
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.          Functions:
  212.                                        number of    purpose of
  213.               number  name             parameters   parameters
  214.               ────── ────────────────  ──────────   ─────────────
  215.                10h   Turn on graphics   0  *
  216.  
  217.                20h   Turn on text       0  *
  218.  
  219.                30h   Draw a point       2  ^        X & Y coordinates
  220.  
  221.                40h   Draw a line        4  ^        X&Y coordinates
  222.                                                     of both end point
  223.                50h   Set the active pg  0  *
  224.  
  225.                60h   Clear page         0  *
  226.  
  227.                70h   Fill page          1  *        value to fill with
  228.  
  229.  
  230.  
  231.          ^ -- this means that the type of plotting used is in the four
  232.               least significant bits:
  233.  
  234.                    1:   turn the points chosen on
  235.  
  236.                    2:   use exclusive or to plot the points
  237.                         (i.e. if the point is on, turn it
  238.                          off. if it is off, turn it on.)
  239.  
  240.                    3:   turn the points chosen off
  241.  
  242.  
  243.  
  244.          * -- this means that the page number for the function should
  245.               be in the four least significant bits
  246.  
  247.                    0:   page 0  (the page it usually is on when you
  248.                                  start)
  249.                    1:   page 1  (used by the CGA card)
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.               This is an example of a full MASM program using INT 70h:
  272.  
  273.  
  274.  
  275.  
  276.          CSEG      SEGMENT
  277.                    ORG  100h
  278.                    ASSUME CS:CSEG, DS:CSEG, SS:CSEG
  279.  
  280.          START:    MOV  AX, CS          ; this gets the segment value
  281.                    LEA  BX, Gr_code     ; this gets the offset
  282.                    INT  70h             ; call the graphics interupt
  283.  
  284.                    MOV  AH, 7           ; DOS fn to get a key
  285.                    INT  20h             ; call the DOS interupt
  286.  
  287.                    MOV  AX, CS          ; get the segment value
  288.                    LEA  BX, Reset       ; get the offset
  289.                    INT  70h             ; call the graphics interupt
  290.  
  291.                    INT  20h             ; end the program
  292.  
  293.  
  294.  
  295.          Gr_code   DB   11h             ; turn on graphics (page 1)
  296.                    DB   61h             ; clear page 1
  297.                    DB   51h             ; make page 1 the active page
  298.  
  299.                    DB   31h             ; put a point (using OR)
  300.                    DW   5, 5            ;   at (5, 5) on the screen
  301.  
  302.                    DB   42h             ; draw a line (using XOR)
  303.                    DW   10, 20, 40, 80  ;   from (10, 20) to (40, 80)
  304.  
  305.                    DB   32h             ; switch a point (using XOR)
  306.                    DW   6, 5            ;   at (6, 5)
  307.  
  308.                    DB   33h             ; turn off a point (mask using
  309.                                                               AND)
  310.                    DW   5, 5            ;   at (5, 5)
  311.  
  312.                    DB   0               ; signify end of code
  313.  
  314.          Reset     DB   20h            ; reset to text mode
  315.  
  316.                    DB   70h            ; fill page 0 with . . .
  317.                    DB   32, 7          ; spaces with normal attributes
  318.                    DB   0              ; signify end of code
  319.  
  320.  
  321.          CSEG      ENDS
  322.                    END  START
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.