home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / asmlib37.zip / GRAPHICS.DOC < prev    next >
Text File  |  1993-07-01  |  73KB  |  2,107 lines

  1.  
  2. ****************************** GRAPHICS *************************************
  3.  
  4. ASMLIB Graphics (C) Copyright 1991 - 1993 Douglas Herr
  5. All rights reserved
  6.  
  7. ASMLIB recognizes and automatically supports several graphics modes,
  8. including several which are not recognized by IBM's BIOS.  You should
  9. assume that all ASMLIB graphics subroutines write directly to the video
  10. hardware.  IMPORTANT: ALL ASMLIB GRAPHICS SUBROUTINES ASSUME DS:@DATA.
  11.  
  12. Locations on Graphics screens are defined by coordinate pairs such as (x,y).
  13. X-coordinates are the horizontal dimensions of the screen, and Y-coordinates
  14. are the vertical coordinates.  X = 0 is the at the left edge of the screen,
  15. and X = 719 is the right edge of a Hercules screen, while Y = 0 is the top
  16. edge of the screen and Y = 347 is the bottom (Hercules).  Thus, the
  17. coordinate specified by (719,0) is the extreme upper right corner of a
  18. Hercules screen.
  19.  
  20. BitBlock subroutines in ASMHUGE.LIB work with huge data blocks (larger
  21. than 64k).  This permits entire EGA, VGA or InColor screens to be saved
  22. in one block if sufficient RAM is available.
  23.  
  24.  
  25.  
  26. Graphics subroutines as powerful and flexible as ASMLIB's can be quite
  27. large.  If you have licenced ASMLIB source code, you can use several
  28. pre-defined conditional assembly directives to eliminate code from
  29. ASMLIB object files if you do not want or need to support all graphics
  30. modes:
  31.  
  32.         NOHERC      eliminates all Hercules and InColor code
  33.         NOINCOLOR   eliminates code for the InColor card
  34.                (InColor works with Hercules monochrome code in 2 colors)
  35.         NO256       eliminates code for the three 256-color modes
  36.         NOCGA       eliminates code for CGA graphics modes
  37.         NOMCGA      elimiates code for MCGA mode 11h
  38.         NOLPATTERN  elimiates code for non-solid lines (in DRAWLINE.ASM)
  39.  
  40. for example, if you want line drawing programs to use only EGA/VGA-type
  41. 16-color modes, assemble DRAWLINE.ASM like this:
  42.  
  43.          C:\MASM\>masm /dnoherc /dnocga /dno256 /dnomcga drawline;
  44.  
  45. this reduces the size of drawline.obj significantly and speeds its
  46. operation somewhat.
  47.  
  48. If you want to support only 16-color EGA/VGA-type modes, you may also use
  49. the EVGA*.LIB libraries to eliminate much of the code and data required
  50. for monochrome, InColor, CGA and 256-color modes.  The EVGA*.LIB libraries
  51. can eliminate several thousand bytes from your executable files.
  52.  
  53. Example:
  54.  
  55. LINK /NOE mycode.obj,,,EVGA86M+ASMLIB;
  56.  
  57. When using the EVGA* libraries, the EVGA* library must appear before
  58. ASMLIB on the command line so that LINK uses the subroutines in the EVGA
  59. library instead of the general subroutines in ASMLIB.  You must also use
  60. LINK's /NOE switch.
  61.  
  62. The EVGA* libraries are provided with standard ASMLIB registration:
  63.  
  64. EVGA86T.LIB      for all PCs, tiny model
  65. EVGA86S.LIB      for all PCs, small model
  66. EVGA86M.LIB      for all PCs, medium model
  67. EVGA86H.LIB      for all PCs, huge model
  68. EVGA286T.LIB     for 286 or better PCs, tiny model
  69. EVGA286S.LIB     for 286 or better PCs, small model
  70. EVGA286M.LIB     for 286 or better PCs, medium model
  71. EVGA286H.LIB     for 286 or better PCs, huge model
  72.  
  73.  
  74. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  75.  
  76. Graphics modes and pages supported are:
  77.  
  78. Mode           Maximum x   Maximum y   Colors  Pages (1)  Equipment
  79.                 ("xmax")    ("ymax")
  80.  
  81. HGraph           719          347       2         0, 1    HGC, HGC+ (2)
  82. HGraph           719          347      16         0, 1    InColor  (2)
  83. 04h, 05h         319          199       4         0       CGA, EGA, MCGA, VGA
  84. 06h              639          199       2         0       CGA, EGA, MCGA, VGA
  85. 0Dh              319          199       16        0 - 7   EGA, VGA  (3)
  86. 0Eh              639          199       16        0 - 3   EGA, VGA  (3)
  87. 0Fh              639          349       4         0       EGA, VGA  (4)
  88. 10h              639          349       16        0, 1    EGA, VGA  (3,5)
  89. 11h              639          479       2         0       MCGA, VGA
  90. 12h              639          479       16        0       VGA
  91. 13h              319          199       256       0       MCGA, VGA
  92. 40h              639          399       2         0       ATT 6300
  93. 6Ah              799          599       16        0       VESA  (6)
  94. XMode16      up to 799     up to 599    16        0       Super EGA/VGA
  95. VGA13X      319 or 359    199 to 479    256       (7)     VGA
  96. SVGA16      799 or 1023   599 or 767    16        0       Super VGA (8)
  97. SVGA256     639 to 1023   399 to 767    256       0       Super VGA (8)
  98.  
  99. (1) page numbering begins with page 0.  Several modes have sufficient
  100.     memory available for additional page(s).
  101. (2) page 1 available after calling Use64k
  102. (3) EGA pages assumes 256k EGA memory
  103. (4) monochrome monitor only
  104. (5) EGA with 128k or more memory
  105. (6) VESA6A is supported by many Super VGA cards with multi-frequency
  106.     monitors
  107. (7) VGA13X pages available range from 0 to 3.  See VGA13X in MODE.DOC.
  108. (8) requires VGAKIT-compatible Super VGA and multi-frequency monitor.  See
  109.     WhichVGA in SYSTEM.DOC and SVGA16 and SVGA256 in MODE.DOC.
  110.  
  111. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  112.  
  113. BEZIER:        draw a Bezier curve on the screen
  114. Source:        bezier.asm (drawline.asm)
  115.  
  116. 80x87 or emulator required
  117.  
  118. Call with:     DS:[BX] pointing to curve coordinate data
  119.                CX = number of points on curve (0 < CX < 32768)
  120.                 a larger number of points on the curve will result in
  121.                 slower operation and a smoother curve.  In many cases
  122.                 CX > 50 will not improve the appearance of the curve.
  123.  
  124.                 Four coordinates are required: two curve endpoints and
  125.                 two control points.  The curve endpoints (x0, y0) and
  126.                 (x3, y3) are similar to DrawLine's coordinates; if you
  127.                 call bezier with CX = 1, you will see only a straight
  128.                 line between the endpoints.  The "control points" act
  129.                 like magnets, pulling the curve away from a straight line.
  130.                 At each endpoint, the curve is tangent to a line drawn
  131.                 between the endpoint and the adjacent control point
  132.                 ("adjacent" control point meaning adjacent in the data
  133.                 structure).
  134.  
  135. Returns:       nothing
  136. Uses:          all 80x87 registers
  137. Supports:      all ASMLIB graphics modes; drawmode 0 not recommended
  138. Example:
  139.  
  140. extrn  bezier:proc
  141.  
  142. .data
  143. extrn  drawmode:byte
  144. bz     dw 50,50            ; first endpoint:       (x0, y0)
  145.        dw 100,0            ; first control point:  (x1, y1)
  146.        dw 200,0            ; second control point: (x2, y2)
  147.        dw 250,175          ; second endpoint:      (x3, y3)
  148.                            ; note that both control points in this
  149.                            ; example pull the curve toward the top of the
  150.                            ; screen
  151.  
  152. .code
  153. ; program fragment assumes DS:@data, 80x87 is installed
  154. ; and that the screen is in graphics mode
  155.        .
  156.        .
  157.        mov     drawmode,1  ; use foreground color
  158.        lea     bx,bz       ; point to bezier curve data
  159.        mov     cx,100      ; should be adequate
  160.        call    bezier
  161.  
  162.  
  163.  
  164. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  165.  
  166. BITBLOCKBYTES: calculate bytes required to save a bit block
  167. Source:        bbbytes.asm ($graph.asm)
  168.  
  169. Call with:     DS:[BX] pointing to x- and y-coordinate data (see example)
  170. Returns:       DX:AX = bytes required to save the bit block
  171.                small or medium model:
  172.                   if CF = 0, bytes required is less than 64k segment
  173.                      => no problem
  174.                   if CF = 1, bit block is too big for a 64k segment
  175.                      small or medium model BitBlock subroutines will
  176.                      not work properly
  177. Uses:          AX, DX, flags
  178. Supports:      all ASMLIB graphics modes; call BitBlockBytes while
  179.                the system is in the mode you intend to use.  Otherwise,
  180.                an incorrect byte size may be returned, leading to either
  181.                wasted memory or memory allocation errors.
  182. Example:
  183.  
  184. include asm.inc
  185.  
  186. extrn   bitblockbytes:proc
  187.  
  188. .data
  189. x0      dw 100,43         ; first corner at (100,43)
  190. x1      dw 175,143        ; second corner at (175,143)
  191.  
  192. .code
  193. ; program fragment assumes DS:@data
  194.         .
  195.         .
  196.         .
  197.         lea    bx,x0          ; DS:[BX] points to bit block corner data
  198.         call   bitblockbytes  ; returns AX = byte size of buffer required
  199.         jc     too_big        ; bit block is too big if CF = 1 (small or med)
  200.  
  201. ; note that when the huge model is used, memory greater than 64k must be
  202. ; allocated with DOS function 48h.  See STARTUP.ASM to release unused
  203. ; memory to allow DOS memory allocation.
  204.  
  205.  
  206. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  207.  
  208. BITPLANEBYTES: calculate bytes to save one plane of a bit block
  209.                alternate entry to BitBlockBytes; calculates bytes
  210.                required to save one plane of multi-plane modes
  211. Source:        bbbytes.asm ($graph.asm)
  212. Call with:     DS:[BX] pointing to x- and y-coordinate data
  213. Returns:       DX:AX = bytes required to save the bit plane
  214.                small or medium model:
  215.                   if CF = 0, bytes required is less than 64k
  216.                      => no problem
  217.                   if CF = 1, bit plane is too big for a 64k segment
  218.                      small or medium model BitPlane subroutines will
  219.                      not work properly
  220. Uses:          AX, DX, flags
  221. Supports:      all ASMLIB graphics modes; call BitPlaneBytes while
  222.                the system is in the mode you intend to use.  If the
  223.                system is is not in a multi-plane mode, BitPlaneBytes
  224.                will give you the same results as BitBlockBytes.
  225.                Graphics modes with multiple planes are mode 0Fh (2 planes)
  226.                and all 16-color modes (4 planes).
  227. Example:
  228.  
  229. include asm.inc
  230.  
  231. extrn   bitplanebytes:proc
  232.  
  233. .data
  234. x0      dw 100,43         ; first corner at (100,43)
  235. x1      dw 175,143        ; second corner at (175,143)
  236.  
  237. .code
  238. ; program fragment assumes DS:@data
  239.         .
  240.         .
  241.         .
  242.         lea    bx,x0          ; DS:[BX] points to bit block corner data
  243.         call   bitplanebytes  ; returns AX = byte size of buffer required
  244.         jc     too_big        ; unlikely
  245.  
  246.  
  247. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  248.  
  249. BUFFERDIM:     change logical buffer dimensions
  250.                does not change number of pixels displayed on screen;
  251.                used with ScreenOrigin.
  252. Source:        buffdim.asm ($graph.asm)
  253.  
  254. Call with:     DS:[BX] pointing to new buffer dimensions
  255.                Note that the logical buffer dimensions should be
  256.                greater than the dimensions displayed on the screen
  257.                The logical buffer dimensions must not create a plane size
  258.                greater than 64k; a logical pixel width of 800 + logical height
  259.                of 600 works out to 60,000 bytes per plane.
  260.  
  261.                If anything is displayed on the screen before changing
  262.                logical dimensions, it will be unreadable after calling
  263.                BufferDim if your logical x-dimension is not the same as
  264.                the screen's physical x-width.
  265.  
  266.                BufferDim does no error checking; you must determine if
  267.                the computer has an EGA or VGA (see GetCRT in SYSTEM.DOC)
  268.                and you must verify that the logical dimensions are greater
  269.                than the screen dimensions.
  270.  
  271.                Using BufferDim disables ASMLIB's multiple graphics pages
  272.                capabilities.
  273.  
  274. Returns:       nothing
  275. Uses:          nothing; all registers and flags are saved
  276. Supports:      EGA/VGA-type 16-color graphics modes
  277. Example:       see next page
  278.  
  279.  
  280.  
  281. (BufferDim example)
  282.  
  283. ; The computer has a 256k EGA card & EGA-only monitor 
  284. ; and I want to display an image that is 800 pixels wide
  285. ; and 600 pixels high.
  286. ; I'll use EGA mode 10h, switch to logical dimensions of 800x600,
  287. ; put the image in the video buffer & use ScreenOrigin to view
  288. ; various parts of the image
  289.  
  290. include asm.inc
  291.  
  292. public  mysub
  293. extrn   bufferdim:proc, screenorigin:proc
  294. extrn   loadpcx:proc
  295.  
  296. .data
  297. dim     dw 800,600              ; I want 800 logical x
  298.                                 ;  & 600 logical y
  299. xy      dw 0,0                  ; screen origin always starts at (0,0)
  300. fname   db '800x600.pcx',0      ; a .PCX file with an 800 x 600 image
  301.  
  302. .code
  303. mysub   proc
  304. ; set up 640x350 16-color mode
  305.         mov    ax,10h           ; use BIOS to set mode
  306.         int    10h
  307.         lea    bx,dim           ; point to logical buffer dimensions
  308.         call   bufferdim        ; set up 800x600 logical dimensions
  309.                                 ; NOTE: only one page available
  310.  
  311. ; program loads image to video buffer
  312.         lea    dx,fname         ; point to filename
  313.         call   loadpcx          ; get image
  314.  
  315. ; default screen origin: (0,0) of buffer is at (0,0) of screen
  316. ; change portion of buffer displayed to logical (100,100)
  317. ; at (0,0) of screen
  318.         lea    bx,xy
  319.         mov    word ptr [bx],100
  320.         mov    word ptr 2[bx],100
  321.         call   screenorigin
  322.  
  323.  
  324. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  325.  
  326. CIRCLEASPECT:  modifies aspect ratio of circle
  327. Source:        drawcirc.asm ($graph.asm)
  328.  
  329. Call with:     AH = numerator of aspect ratio
  330.                AL = denominator of aspect ratio
  331.                AH <> 0, AL <> 0
  332.  
  333.                CircleAspect is used with DrawCircle to draw an ellipse.
  334.                An aspect ratio less than one makes a flat ellipse and an
  335.                aspect ratio greater than one makes a tall ellipse.
  336.                Aspect ratios greater than 5 or less than 1/5 may cause
  337.                unpredictable results.
  338.  
  339. Returns:       nothing
  340. Uses:          nothing; all registers and flags are saved
  341. Supports:      all ASMLIB graphics modes
  342. Example:       see DrawCircle
  343.  
  344.  
  345.  
  346. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  347.  
  348. DEFGMODE:      restore ASMLIB's internal flags to use system graphics
  349.                mode (see ForceGMode)
  350. Source:        defgmode.asm
  351.  
  352. Call with:     no parameters
  353. Returns:       nothing
  354. Uses:          nothing
  355. Supports:      all ASMLIB graphics modes
  356. Example:       see ForceGMode
  357.  
  358.  
  359.  
  360. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  361.  
  362. DRAWCIRCLE:    draw a circle
  363. Source:        drawcirc.asm ($graph.asm, $putdot.asm)
  364.  
  365. Call with:     DS:[BX] pointing to circle center coordinates and x-radius
  366.                Drawmodes supported are:
  367.                 4 = AND the foreground color with the screen
  368.                 3 = OR the foreground color with the screen
  369.                 1, 2 = use foreground color
  370.                 0 = XOR circle with existing screen
  371.                -1, -2 = use background color
  372.                -3 = OR the background color with the screen
  373.                -4 = AND the background color with the screen
  374.                See DrawMode for more information
  375.                See also CircleAspect
  376. Returns:       nothing
  377. Uses:          nothing
  378. Supports:      all ASMLIB graphics modes
  379. Example:
  380.  
  381. include asm.inc
  382. extrn   drawcircle:proc, circleaspect:proc
  383.  
  384. .data
  385. xcenter dw 100              ; DrawCircle data must be words
  386. ycenter dw 100              ; the circle is centered at (100,100)
  387. xradius dw 50               ; x-dimension radius in pixels (>0)
  388.  
  389. .code
  390. ; program fragment assumes DS:@data
  391.         .
  392.         .
  393.         .
  394.         mov   ah,5
  395.         mov   al,1          ; a tall ellipse
  396.         call  circleaspect
  397.  
  398.         lea   bx,xcenter    ; DS:[BX] points to circle data
  399.         call  drawcircle    ; draw the circle
  400.  
  401.  
  402. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  403.  
  404. DRAWBOX:       draw a rectangle on a graphics screen
  405. Source:        drawbox.asm ($graph.asm, $vert.asm, $horiz.asm, several others)
  406.  
  407. Call with:     DS:[BX] pointing to box corner data
  408.                Drawmodes supported are:
  409.                 4 = AND the foreground color with the screen; color modes
  410.                 3 = OR the foreground color with the screen
  411.                 1, 2 = use foreground color: all modes
  412.                 0 = XOR foreground color with existing pixels
  413.                -1, -2 = use background color: all modes
  414.                -3 = OR the background color with the screen
  415.                -4 = AND the background color with the screen; color modes
  416.                See DrawMode for more information; see also LinePattern
  417. Returns:       nothing
  418. Uses:          nothing
  419. Supports:      all ASMLIB graphics modes
  420. Example:
  421.  
  422. include asm.inc
  423.  
  424. extrn   drawbox:proc
  425.  
  426. .data
  427. x0      dw 25,10            ; first corner at (25,10); data is word size
  428. x1      dw 301,97           ; opposite corner at (301,97)
  429.  
  430. .code
  431. ; program fragment assumes DS:@data
  432.         .
  433.         .
  434.         lea   bx,x0         ; DS:[BX] points to box corner data
  435.         call  drawbox
  436.  
  437.  
  438. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  439.  
  440. DRAWLINE:      draw a line on a graphics screen
  441. Source:        drawline.asm ($graph.asm, $vert.asm, $horiz.asm,
  442.                              $loslope.asm, $hislope.asm, many others)
  443.  
  444. Call with:     DS:[BX] pointing to line endpoint data
  445.                Drawmodes supported are:
  446.                 4 = AND the foreground color with the screen; color modes
  447.                 3 = OR the foreground color with the screen
  448.                 1, 2 = use foreground color: all modes
  449.                 0 = XOR foreground color with existing pixels
  450.                -1, -2 = use background color: all modes
  451.                -3 = OR the background color with the screen
  452.                -4 = AND the background color with the screen; color modes
  453.                See DrawMode for more information; see also LinePattern
  454. Returns:       nothing
  455. Uses:          nothing
  456. Supports:      all ASMLIB graphics modes
  457. Example:
  458.  
  459. include asm.inc
  460.  
  461. extrn   drawline:proc
  462.  
  463. .data
  464. x0      dw 25,10            ; first endpoint at (25,10); data is word size
  465. x1      dw 301,97           ; other end of line at (301,97)
  466.  
  467. .code
  468. ; program fragment assumes DS:@data
  469.         .
  470.         .
  471.         lea   bx,x0         ; DS:[BX] points to line coordinate data
  472.         call  drawline
  473.  
  474.  
  475. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  476.  
  477. DRAWMODE:      control ASMLIB graphics drawing mode
  478. Source:        $graph.asm
  479.  
  480.                DrawMode is a public byte in DGROUP used to control the
  481.                operation of many ASMLIB subroutines.  ASMLIB's default
  482.                drawmode is 1.
  483.  
  484.                Typically, drawmodes have the following effects:
  485.                 2 = use foreground color only; text is printed without
  486.                     background, foreground only of line patterns or
  487.                     fill patterns is used
  488.                 1 = use foreground and background; text is printed with
  489.                     background, line patterns and fill patterns update
  490.                     both foreground and background
  491.                 0 = foreground color is XORed with the existing screen
  492.                     (not supported in 256-color or CGA 4-color modes)
  493.                -1 = characters or fill pattern drawn with foreground
  494.                     and background reversed
  495.                -2 = character or line drawn with background color only
  496.  
  497. Supports:      all ASMLIB graphics modes
  498. Example:
  499.  
  500. include asm.inc
  501.  
  502. .data
  503. extrn   drawmode:byte
  504.  
  505. .code
  506. ; program fragment assumes DS:@data
  507.         .
  508.         .
  509.         mov     drawmode,2      ; print text with foreground color only
  510.  
  511.  
  512. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  513.  
  514. FILLAREA:      fills an irregular area on a graphics screen
  515. Source:        fillarea.asm ($graph.asm, $horiz.asm, $getdot.asm,
  516.                              several others)
  517.  
  518. Call with:     DS:[BX] pointing to seed pixel coordinates
  519.  
  520.                Fills many irregularly-shaped areas with color and/or
  521.                pattern, beginning at (x,y).  FillArea may not work
  522.                properly with regions which have concave boundaries
  523.                crossing horizontal lines.  The area's boundary is
  524.                defined by a solid line of non-zero pixels.
  525.                DrawModes supported are:
  526.                 2 = fill with foreground color only (if fill pattern
  527.                     has been defined): 16-color modes
  528.                 1 = fill with foreground (and background, if fillpattern
  529.                     defined): all modes
  530.                See also FillPattern.
  531. Returns:       nothing
  532. Uses:          nothing
  533. Supports:      all ASMLIB graphics modes
  534. Example:
  535.  
  536. include asm.inc
  537.  
  538. extrn   fillarea:proc
  539.  
  540. .data
  541. x       dw 10,15         ; start fill operation at x=10, y=15
  542.  
  543. .code
  544. ; program fragment assumes DS:@data
  545.         .
  546.         .
  547.         lea    bx,x
  548.         call   fillpattern
  549.  
  550.  
  551. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  552.  
  553. FILLBOX:       draw a filled rectangle on a graphics screen
  554. Source:        fillbox.asm ($graph.asm, $horiz.asm, several others)
  555.  
  556. Call with:     DS:[BX] pointing to box corner data
  557.                Drawmodes supported are:
  558.                 4 = AND the box with the pre-existing screen
  559.                 3 = OR the foreground color with the screen
  560.                 1, 2 = use foreground color
  561.                 0 = XOR foreground color with existing pixels
  562.                -1, -2 = use background color
  563.                -3 = OR the background color with the screen
  564.                -4 = AND the background color with pre-existing screen
  565.                See DrawMode for more information; also see FillPattern.
  566. Returns:       nothing
  567. Uses:          nothing
  568. Supports:      all ASMLIB graphics modes
  569. Example:
  570.  
  571. include asm.inc
  572.  
  573. extrn   fillbox:proc
  574.  
  575. .data
  576. x0      dw 25,10            ; first corner at (25,10); data is word size
  577. x1      dw 301,97           ; opposite corner at (301,97)
  578.  
  579. .code
  580. ; program fragment assumes DS:@data
  581.         .
  582.         .
  583.         lea   bx,x0         ; DS:[BX] points to box corner data
  584.         call  fillbox
  585.  
  586.  
  587. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  588.  
  589. FILLPATTERN:   define an optional pattern for FillArea & FillBox
  590. Source:        fpattern.asm
  591.  
  592. Call with:     DS:[BX] pointing to ASCIIZ pattern string.
  593.                Up to 8 characters in the string will be used.
  594.                The pattern must be re-defined before each call to a line
  595.                drawing subroutine (FillArea, FillBox).
  596. Returns:       nothing
  597. Uses:          nothing
  598. Supports:      all ASMLIB graphics modes except 256-color modes
  599. Example:
  600.  
  601. include asm.inc
  602.  
  603. extrn   fillbox:proc
  604. extrn   fillpattern:proc
  605.  
  606. .data
  607. x0      dw 25,10            ; first corner at (25,10); data is word size
  608. x1      dw 301,97           ; opposite corner at (301,97)
  609. pattern db 8 dup(10101010b),0
  610.  
  611. .code
  612. ; program fragment assumes DS:@data
  613.         .
  614.         .
  615.         lea   bx,pattern    ; DS:[BX] points to pattern string
  616.         call  fillpattern   ; define the pattern
  617.         sub   bx,8          ; DS:[BX] points to box corner data
  618.         call  fillbox       ; draw a patterned box
  619.  
  620.  
  621. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  622.  
  623. FORCEGMODE:    force ASMLIB to use one particular graphics mode
  624.                this is handy for two-monitor systems
  625. Source:        defgmode.asm
  626.  
  627. Call with:     AL = graphics mode to use
  628.                forcegmode does not change the actual screen mode; what
  629.                it does is to force ASMLIB's central graphics control
  630.                to ignore the system mode.  Call defgmode to restore
  631.                ASMLIB's internal flags to the default state.
  632. Returns:       nothing
  633. Uses:          nothing
  634. Supports:      all ASMLIB graphics modes (256-color modes not tested)
  635. Example:
  636.  
  637. include asm.inc
  638.  
  639. extrn   modecolor:proc, modemono:proc
  640. extrn   forcegmode:proc, gcolor:proc, defgmode:proc
  641.  
  642. .data
  643. gtext   db 'Graphics mode',0
  644. gpos    dd 0                   ; 2 words of zeros to position text
  645. ttext   db 'Text mode',0
  646.  
  647. .code
  648. ; program fragment assumes DS:@data
  649. ; I want text on the monochrome screen and 16-color graphics on the EGA
  650.         call   modecolor       ; switch to color monitor
  651.         mov    ax,10h          ; set up graphics mode
  652.         int    10h
  653.         mov    al,10h          ; tell ASMLIB to use mode 10h
  654.                                ; use AL = 13h for VGA 256-color modes
  655.                                ; use AL = 8 for Hercules (including InColor)
  656.         call   forcegmode      ; best to do this after the mode change
  657.         call   modemono        ; switch back to the monochrome monitor
  658.         mov    ax,010Ch        ; blue background, red foreground
  659.         call   gcolor
  660.         lea    si,gtext        ; point to graphics message
  661.         lea    dx,gpos         ; positioned at upper left corner
  662.         call   gprint          ; prints on EGA in graphics mode
  663.  
  664.         lea    si,ttext        ; point to text message
  665.         xor    dx,dx           ; upper left corner of text screen
  666.         mov    ah,7            ; normal color
  667.         call   tprint          ; display message on monochrome monitor
  668.         .
  669.         .
  670. ; sometime later, all done with this setup
  671.         call   defgmode        ; clear ASMLIB's internal graphics flags
  672.  
  673.  
  674. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  675.  
  676. GBASESEG:      change ASMLIB graphics base segment
  677. Source:        gbaseseg.asm ($graph.asm)
  678.  
  679. Call with:     AX = base segment address for alternate buffer
  680.                if AX = 0, default base segment is restored
  681.                GBaseSeg may be used to create and update off-screen graph
  682.                images, thus simulating multiple screen pages.
  683. Returns:       nothing
  684. Uses:          nothing
  685. Supports:      mode 04h, 05h, HGraph (monochrome only), 40h, 11h, 13h
  686.  
  687.                buffer size requirements:
  688.  
  689.                 mode 04h, 05h    16384 bytes
  690.                 HGraph, 40h      32768 bytes
  691.                 mode 11h         38400 bytes
  692.                 mode 13h         64000 bytes
  693.  
  694.                 GBaseSeg may also work with planar or bank-switched
  695.                 modes in a windowing multi-tasking environment, such
  696.                 as DesqView.  Feedback, please!!
  697.                 You must call GBaseseg AFTER switching the system to graphics
  698.                 mode, or it will not work; you must also call GBaseSeg with
  699.                 AX = 0 before changing from one graphics mode to another, or
  700.                 the default base segment may get messed up.
  701. Example:
  702.  
  703. .model medium
  704.  
  705. public myprog
  706. extrn  gbaseseg:proc, drawbox:proc
  707.  
  708. .data
  709. boxdata dw 0,0,319,199
  710.  
  711. .fardata
  712. screen1 db 64000 dup (0)     ; second screen for mode 13h
  713.  
  714. .code
  715. myprog proc
  716. ; program fragment assumes DS:@DATA
  717. ; mode 13h, 320x200x256 colors
  718.        mov     ax,13h
  719.        int     10h
  720. ; use alternate buffer
  721.        mov     ax,seg screen1
  722.        call    gbaseseg
  723.        lea     bx,linedata
  724.        call    drawbox
  725.  
  726. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  727.  
  728. GCENTER:       centers a string on a graphics screen
  729. Source:        gcenter.asm (gprint.asm, $graph.asm, strlen.asm, f8x14.asm)
  730.  
  731. GCENTERX:      centers a double-width string on a graphics screen
  732. Source:        gcenterx.asm (gprintx.asm, $graph.asm, strlen.asm, f8x14.asm)
  733.  
  734. Call with:     DS:[SI] pointing to the string to print
  735.                DS:[DX] pointing to x- and y-coordinates
  736.                the x-coordinate is a placeholder; GCenter calculates the
  737.                correct x value before calling GPrint.
  738.  
  739.                Colors, drawmodes and character sizes are the same as
  740.                for GPrint or GPrintX.
  741. Returns:       x = calculated x-coordinate
  742. Uses:          nothing; all registers and flags are saved.
  743. Supports:      all ASMLIB graphics modes
  744. Example:
  745.  
  746. include asm.inc
  747.  
  748. extrn   gcenter:proc
  749.  
  750. .data
  751. x       dw ?
  752. y       dw 2               ; print graph title 2 pixels down from the top
  753. title   db 'Graph title',0
  754.  
  755. .code
  756. ; program fragment assumes DS:@data
  757.         .
  758.         .
  759.         lea    si,title    ; DS:[SI] points to string
  760.         lea    dx,x        ; point to coordinates
  761.         call   gcenter     ; print the string, centered horizontally
  762.  
  763.  
  764. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  765.  
  766. GCLEAR:        clears the active portion of a graphics screen
  767.                uses background color
  768. Source:        gclear.asm ($graph.asm, $horiz.asm, others)
  769.  
  770. Call with:     no parameters
  771. Returns:       nothing
  772. Uses:          nothing
  773. Supports:      all ASMLIB graphics modes
  774. Example:
  775.  
  776. include asm.inc
  777.  
  778. extrn   gclear:proc
  779.  
  780. .code
  781.         .
  782.         .
  783.         .
  784.         call  gclear
  785.  
  786. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  787.  
  788. GCOLOR:        update color used by ASMLIB graphics
  789. Source:        gcolor.asm ($graph.asm)
  790.  
  791. Call with:     AL = foreground color
  792.                AH = background color
  793.  
  794.                for 4-color modes, colors may be 0-3
  795.                for 16-color modes, colors may be 0-15
  796.                for 256-color modes, colors may be 0-255
  797.  
  798. Returns:       nothing
  799. Uses:          nothing
  800. Supports:      all color graphics modes and mode 0Fh
  801.                GColor is ignored by 2-color modes
  802. Example:
  803.  
  804. include asm.inc
  805.  
  806. extrn   gcolor:proc
  807.  
  808. .code
  809.         .
  810.         .
  811.         .
  812.         mov   ah,bcolor      ; background color
  813.         mov   al,fcolor      ; foreground color
  814.         call  gcolor
  815.  
  816.  
  817. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  818.  
  819. GCOPY:         copies one page of graphics memory to another
  820. Source:        gcopy.asm ($graph.asm)
  821.  
  822. Call with:     BH = frompage
  823.                BL = topage
  824. Returns:       CF = error flag
  825.                 if CF = 0, no error
  826.                 if CF = 1, bad page number or frompage = topage
  827. Uses:          AX, CF
  828. Supports:      Hercules and InColor (with Use64k)
  829.                EGA/VGA modes 0Dh, 0Eh, 0Fh, 10h
  830.                VGA13X [0,1,2]
  831. Example:
  832.  
  833. include asm.inc
  834.  
  835. extrn   gcopy:proc
  836.  
  837. .code
  838.         .
  839.         .
  840.         .
  841.         mov   bx,0001h       ; copy from page 0 to page 1
  842.         call  gcopy
  843.         jc    bad_page       ; uh oh, pages not supported
  844.  
  845.  
  846. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  847.  
  848. GCURSOR:       simulate text-mode cursor on graphics screen
  849. GUCURSOR:      simulate underscore cursor on graphics screen
  850. Source:        gcursor.asm ($graph.asm)
  851.  
  852. Call with:     DS:[DX] pointing to x- and y-coordinate word data
  853.                x and y are the coordinates of the UPPER LEFT corner of
  854.                a character block.  Note that text characters are
  855.                8 x-pixels wide and from 8 to 16 y-pixels high.
  856.  
  857.                GCursor and GUCursor maintain the simulated cursor while
  858.                the keyboard type-ahead buffer is empty.  GCursor shape
  859.                is an underscore when INSERT is off and a larger block
  860.                when INSERT is on.  GUCursor is an underscore regardless
  861.                of the state of the INSERT toggle.
  862. Returns:       nothing
  863. Uses:          AX, CX
  864. Supports:      all ASMLIB graphics modes
  865. Example:
  866.  
  867. include asm.inc
  868.  
  869. extrn   gcursor:proc, getkey:proc
  870.  
  871. .data
  872. x       dw 10,20        ; put the cursor in the character block at (10,20)
  873.  
  874. .code
  875. ; program fragment assumes DS:@data
  876.         .
  877.         .
  878.         .
  879.         lea   dx,x
  880.         call  gcursor
  881.         call  getkey    ; retrieve the key that was pressed
  882.  
  883.  
  884. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  885.  
  886. GETBITBLOCK:   saves a portion of a graphics screen in memory
  887. Source:        bitblock.asm ($graph.asm, bb02.asm, bb04.asm, bb06.asm,
  888.                              bb08.asm, bb10.asm, bb12.asm, bb14.asm,
  889.                              lowES2hi.asm, lowDS2hi.asm)
  890.  
  891. Call with:     ES:[DI] pointing to memory buffer for the bit block
  892.                DS:[BX] pointing to x & y coordinate data
  893.  
  894.                Note that a bit block copied from a 4-plane mode may
  895.                only be restored to a 4-plane mode; likewise, a bit
  896.                block saved from a 2-color mode should be restored to
  897.                a 2-color mode or to a single bit plane of a 16-color
  898.                mode.
  899. Returns:       nothing
  900. Uses:          nothing
  901. Supports:      all ASMLIB graphics modes
  902.                memory models: small medium, huge
  903.  
  904.  
  905.     If you do not intend to support all ASMLIB graphics modes, you can
  906.     call mode-specific BitBlock subroutines to reduce .EXE size.
  907.     These subroutines use the same calling parameters as GetBitBlock
  908.     and PutBitBlock:
  909.  
  910.  
  911.     getbb02: mode 04h, 05h, 11h, 40h, HGraph (mono and InColor)
  912.     getbb06: mode 0Dh, 0Eh, 0Fh, 10h, 12h, SVGA16(0), XMODE16
  913.     getbb08: mode 13h
  914.     getbb10: VGA13X
  915.     getbb12: SVGA16
  916.     getbb14: SVGA256
  917.  
  918.  
  919.     putbb02: mode 04h, 05h, 11h, 40h, HGraph (mono only)
  920.     putbb04: HGraph (InColor only)
  921.     putbb06: mode 0Dh, 0Eh, 0Fh, 10h, 12h, SVGA16(0), XMODE16
  922.     putbb08: mode 13h
  923.     putbb10: VGA13X
  924.     putbb12: SVGA16
  925.     putbb14: SVGA256
  926.  
  927. Example on next page
  928.  
  929.  
  930. ; example of GetBitBlock use
  931.  
  932. include asm.inc
  933.  
  934. extrn   bitblockbytes:proc, getbitblock:proc, putbitblock:proc
  935. extrn   halloc:proc
  936.  
  937. .data
  938. ptr     dw ?                ; use this to save pointer to bit block
  939. x0      dw 100,43,175,143   ; save from (100,43) to (175,143)
  940.  
  941. .code
  942. ; program fragment assumes DS:@data
  943.         .
  944.         .
  945.         lea   bx,x0         ; point to block corners
  946.         call  bitblockbytes ; calculate byte requirement
  947.         jc    too_big       ; error control
  948.         call  halloc        ; this example allocate the buffer from heap
  949.                             ; can't do this w/ huge bit blocks
  950.         jc    no_memory     ; more error control
  951.         mov   ptr,bx        ; save near address of bit block
  952.         push  ds
  953.         pop   es            ; ES = DS
  954.         mov   di,bx         ; ES:[DI] points to buffer
  955.         lea   bx,x0         ; DS:[BX] points to coordinate data
  956.         call  getbitblock
  957.         .
  958.         .
  959.  
  960. ; later . . .
  961.         lea   bx,x0         ; put the bit block back where you found it
  962.         push  ds
  963.         pop   es            ; ES = DS
  964.         mov   di,ptr        ; ES:[DI] points to buffer
  965.         call  putbitblock
  966.  
  967. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  968.  
  969. GETBITPLANE:   saves one plane of a bit block in memory
  970. Source:        small & medium: bitplane.asm ($graph.asm, bb02.asm, bb04.asm
  971.                                bb06.asm, bb08.asm, bb10.asm, bb12.asm,
  972.                                bb14.asm)
  973.                huge: same as small & medium, + lowES2hi.asm & lowDS2hi.asm
  974.  
  975. Call with:     ES:[DI] pointing to memory buffer for the bit block
  976.                DS:[BX] pointing to x & y coordinate data
  977.                AL = plane number to save
  978.                valid plane numbers are 0 - 3 in 16-color modes
  979.                                        0 & 2 in EGA monochrome mode
  980.  
  981.                In 16-color modes, EGA/VGA and InColor planes are:
  982.                 0 = blue, 1 = green, 2 = red, 3 = gray (or intensity)
  983.                In EGA monochrome mode, plane 0 = normal, plane 2 = blink
  984.                 or intensity
  985.                The actual colors each plane represents may change
  986.                depending on the values in the pallete registers.
  987.  
  988. Supports:      all 16-color modes plus EGA monochrome
  989.                other modes: GetBitPlane works like GetBitBlock
  990.                memory models: small, medium, huge
  991.  
  992.  
  993. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  994.  
  995. GETVIEW:       returns a pointer to the current view coordinates for
  996.                the active page
  997. Source:        getview.asm ($graph.asm)
  998.  
  999. Call with:     no parameters
  1000.                most ASMLIB subroutines, except the GPrint series, Gload,
  1001.                GCopy and GSave, limit their activity to the view region.
  1002.                You may use the returned pointer to change the active
  1003.                portion of the screen; be careful not to exceed the maximum
  1004.                x1 and y1 values permitted by the current mode.  Also, x0
  1005.                must always be less than x1 and y0 must always be less than
  1006.                y1.
  1007.                ASMLIB's defaults are:
  1008.                 x0 = 0
  1009.                 y0 = 0
  1010.                 x1 = xmax
  1011.                 y1 = ymax
  1012.  
  1013.                See also ResetView
  1014.  
  1015. Returns:       ES:[BX] pointing to the current view coordinates
  1016. Uses:          ES, BX; all other registers and flags are saved
  1017. Supports:      all ASMLIB graphics modes and pages
  1018. Example:
  1019.  
  1020. include asm.inc
  1021.  
  1022. extrn   getview:proc
  1023.  
  1024. x0 EQU word ptr ES:[BX]
  1025. y0 EQU word ptr ES:2[BX]
  1026. x1 EQU word ptr ES:4[BX]
  1027. y1 EQU word ptr ES:6[BX]
  1028.  
  1029. .code
  1030.         .
  1031.         .
  1032.         .
  1033.         call   getview
  1034.  
  1035.  
  1036. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1037.  
  1038. GETDOT:        determine pixel value on graphics screen
  1039. Source:        getdot.asm ($graph.asm, $getdot.asm, others)
  1040.  
  1041. Call with:     DS:[BX] pointing to pixel coordinate data
  1042. Returns:       if CF = 0, AX = pixel value
  1043.                if CF = 1, pixel coordinates outside active view area
  1044. Uses:          AX, CF
  1045. Supports:      all ASMLIB graphics modes
  1046. Example:
  1047.  
  1048. include asm.inc
  1049.  
  1050. extrn   getdot:proc
  1051.  
  1052. .data
  1053. x       dw 10,10             ; pixel at (10,10)
  1054.  
  1055. .code
  1056. ; program fragment assumes DS:@data
  1057.         .
  1058.         .
  1059.         .
  1060.         lea    bx,x          ; point to pixel coordinates
  1061.         call   getdot        ; get pixel value
  1062.         jc     out_of_bounds ; oops
  1063.  
  1064.  
  1065.  
  1066. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1067.  
  1068. GLOAD:         loads a graphics screen saved as a disk file by GSave
  1069. Source:        gsave.asm ($graph.asm, $gbytes.asm, $reset.asm)
  1070.  
  1071. Call with:     DS:[DX] pointing to the name of the file to load
  1072.                the filename must be an ASCIIZ string
  1073. Returns:       AX = MS-DOS error code
  1074. Uses:          AX, BX, CX, flags
  1075. Supports:      all ASMLIB graphics modes
  1076. Example:
  1077.  
  1078. include asm.inc
  1079.  
  1080. extrn   gload:proc
  1081.  
  1082. .data
  1083. filename db 'graph.bin',0
  1084.  
  1085. .code
  1086. ; program fragment assumes DS:@data
  1087.         .
  1088.         .
  1089.         lea   dx,filename
  1090.         call  gload
  1091.  
  1092.  
  1093. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1094.  
  1095. GLOADEMS:      loads a graphics screen saved in EMS memory by GSaveEMS
  1096. Source:        gloadems.asm ($graph.asm, ems.asm, $gbytes.asm, $emspage.asm
  1097.                              banks.asm, $reset.asm, emputget.asm, $plane.asm,
  1098.                              $gloadx.asm, $plane.asm)
  1099.  
  1100. Call with:     BX = EMS handle
  1101.                assumes DS:@data
  1102. Returns:       if CF = 0, no error
  1103.                if CF = 1, AH = EMS error code
  1104. Uses:          AX, flags
  1105. Supports:      all ASMLIB graphics modes
  1106. Example:
  1107.  
  1108. include asm.inc
  1109.  
  1110. public  testems
  1111.  
  1112. extrn   mode43:proc, getkey:proc, isems:proc, gsaveems:proc, gloadems:proc
  1113.  
  1114. .data
  1115. handle  dw 0
  1116.  
  1117. .code
  1118. testems proc
  1119.         mov     ax,12h          ; VGA 16-color mode
  1120.         int     10h
  1121.         .
  1122.         .
  1123.         .
  1124. ; program draws screen
  1125.         .
  1126.         .
  1127.         call    isems
  1128.         jc      no_ems
  1129.         call    gsaveems
  1130.         jc      no_ems
  1131.         mov     handle,bx
  1132.         .
  1133.         .
  1134. ; some time later ...
  1135.         mov     bx,handle
  1136.         call    gloadems
  1137.         jc      kill_ems
  1138.         call    getkey
  1139. kill_ems:
  1140.         mov     dx,handle
  1141.         mov     ah,45h          ; EMS function: de-allocate block
  1142.         int     67h
  1143.  
  1144. no_ems: call    mode43
  1145.         ret
  1146. testems endp
  1147.         end
  1148.  
  1149.  
  1150. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1151.  
  1152. GLOADXMS:      loads a graphics screen saved in XMS memory by GSaveXMS
  1153. Source:        gloadxms.asm ($graph.asm, xms.asm, $gbytes.asm, $gloadx.asm,
  1154.                              banks.asm, $reset.asm, xmputget.asm, $plane.asm)
  1155.  
  1156. Call with:     BX = XMS handle
  1157.                assumes DS:@data
  1158. Returns:       if CF = 0, no error
  1159.                if CF = 1, AH = XMS error code
  1160. Uses:          AX, flags
  1161. Supports:      all ASMLIB graphics modes
  1162. Example:
  1163.  
  1164. include asm.inc
  1165.  
  1166. public  testxms
  1167.  
  1168. extrn   mode43:proc, getkey:proc, isxms:proc, gsavexms:proc, gloadxms:proc
  1169. extrn   freexms:proc
  1170.  
  1171. .data
  1172. handle  dw 0
  1173.  
  1174. .code
  1175. testxms proc
  1176.         mov     ax,12h          ; VGA 16-color mode
  1177.         int     10h
  1178.         .
  1179.         .
  1180.         .
  1181. ; program draws screen
  1182.         .
  1183.         .
  1184.         call    isxms
  1185.         jc      no_xms
  1186.         call    gsavexms
  1187.         jc      no_xms
  1188.         mov     handle,bx
  1189.         .
  1190.         .
  1191. ; some time later ...
  1192.         mov     bx,handle
  1193.         call    gloadxms
  1194.         jc      kill_xms
  1195.         call    getkey
  1196. kill_xms:
  1197.         mov     bx,handle
  1198.         call    freexms
  1199.  
  1200. no_xms: call    mode43
  1201.         ret
  1202. testxms endp
  1203.         end
  1204.  
  1205.  
  1206. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1207.  
  1208. GPAGE:         changes active and displayed graphics page
  1209.                GPage changes ASMLIB's default graphics page and displays
  1210.                the page.  See also UseGPage and ShowGPage.
  1211. Source:        gpage1.asm ($graph.asm, $herc.asm, gpage.asm)
  1212.  
  1213. Call with:     BL = page number.  See table at start of this GRAPHICS.DOC
  1214.                file.
  1215. Returns:       if CF = 0, no problem
  1216.                if CF = 1, bad page number requested
  1217. Uses:          CF
  1218. Supports:      EGA, VGA, Hercules, InColor: modes with more than one page
  1219. Example:
  1220.  
  1221. include asm.inc
  1222.  
  1223. extrn   gpage:proc
  1224.  
  1225. .code
  1226.         .
  1227.         .
  1228.         mov    bl,1          ; use and show page 1
  1229.         call   gpage
  1230.         jc     oops          ; uh oh, wrong mode
  1231.  
  1232. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1233.  
  1234. GPRINT:        prints ASCIIZ string on a graphics screen
  1235. Source:        gprint.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1236.                            $gp06.asm, $gp08.asm, $gp10.asm, others)
  1237.  
  1238. Call with:     DS:[SI] pointing to the ASCIIZ string
  1239.                DS:[DX] pointing to x- and y-coordinate data
  1240.                drawmodes supported by GPrint are:
  1241.                 2 = foreground only; background pixels left alone
  1242.                 1 = foreground and background pixels updated with
  1243.                     current gcolor
  1244.                 0 = foreground color is XORed with the existing screen
  1245.                -1 = like drawmode 1, but foreground and background reversed
  1246.                -2 = like drawmode 2, but uses background color
  1247.                Any pixel position may be specified; does not wrap around
  1248.                from right side of screen to left.  Default character size
  1249.                is 8x8 for CGA modes and modes 0Dh, 0Eh and 13h, 8x14 for
  1250.                others.
  1251.                High ASCII characters are undefined in 8x8 pixel modes
  1252.                unless you call SmallText sometime earlier in the program.
  1253. Returns:       nothing
  1254. Uses:          CX; all other registers and flags are saved
  1255. Supports:      all ASMLIB graphics modes
  1256.                not all drawmodes supported with CGA modes 04h and 05h
  1257. Example:
  1258.  
  1259. include asm.inc
  1260.  
  1261. extrn   gprint:proc
  1262.  
  1263. .data
  1264. string  db 'print this, if you will',0
  1265. gpos    dw 0,0                          ; print at upper left corner
  1266.  
  1267. .code
  1268. ; program fragment assumes DS:@data
  1269.         .
  1270.         .
  1271.         .
  1272.         lea   si,string
  1273.         lea   dx,gpos
  1274.         call  gprint
  1275.  
  1276. additional GPRINT information on next page
  1277.  
  1278. GPRINT will work with user-defined fonts up to 16 pixel rows high in all
  1279. modes with ymax > 200.  GPRINT reads a public data area in DGROUP to
  1280. determine the SEGMENT:OFFSET address of the font data, the number of pixel
  1281. rows per character and the byte increment between sucessive character
  1282. definitions.  Characters must be 8 pixels wide.
  1283.  
  1284. FONTDATA.ASM has the required font data:
  1285.  
  1286. public  f14seg
  1287. f14seg  dw SEG f8x14    ; segment address of user-loaded font (8x14 default)
  1288.         dw OFFSET f8x14 ; offset address of user-loaded font (8x14 default)
  1289.         db 14           ; byte size of character
  1290.         db 14           ; bytes from start of one char to start of next
  1291.  
  1292. Example:
  1293.  
  1294. include asm.inc
  1295.  
  1296. .data
  1297. extrn   f14seg:word
  1298.  
  1299. fname   db 'c:\ramfont\italics.fnt',0   ; 8x14 characters
  1300. fbuffer db 4096 dup (0)                 ; all RAMFont fonts are 4096 bytes
  1301. ; the fonts supplied by Hercules with the Graphics Card Plus and InColor
  1302. ; card are a variety of sizes, but in each font file the byte increment
  1303. ; is always 16 bytes
  1304.  
  1305. .code
  1306.         .
  1307.         .
  1308.         mov     ax,@data
  1309.         mov     ds,ax
  1310.         lea     dx,fname
  1311.         mov     ax,3D00h        ; open file for read
  1312.         int     21h
  1313.         mov     bx,ax           ; copy file handle to BX
  1314.         lea     dx,fbuffer      ; DS:[DX] points to buffer
  1315.         mov     cx,4096
  1316.         mov     ah,3Fh          ; read file
  1317.         int     21h
  1318.         mov     ah,3Eh          ; close file
  1319.         int     21h
  1320.         mov     f14seg,ds      ; update segment address of new font
  1321.         mov     f14seg+2,dx    ; update offset address of new font
  1322.         mov     f14seg+4,(16 shl 8) OR 14
  1323.                                 ; 14-pixel row character
  1324.                                 ; 16 bytes between character definitions
  1325.  
  1326. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1327.  
  1328. GPRINTDOWN:    prints ASCIIZ string vertically on graph screen
  1329. GPRINTUP:      prints ASCIIZ string vertically on graph screen
  1330. Source:        gprint.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1331.                            $gp06.asm, $gp08.asm, $gp10.asm, others)
  1332.  
  1333. Call with:     same as GPrint
  1334.                rotates each character 90 degrees and prints from top
  1335.                downward or from bottom upward.  Character size 8x8.
  1336.  
  1337.                Returned data and registers used same as GPrint
  1338. Example:       see GPrint.
  1339.  
  1340.  
  1341. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1342.  
  1343. GPRINTX:       print string on a graphics screen, double width
  1344. GPRINT2X:      print string on a graphics screen, double size
  1345. GPRINTDOWNX:   print string vertically on graph screen, 2x width
  1346. GPRINTDOWN2X:  print string vertically on graph screen, 2x size
  1347. GPRINTUPX:     print string vertically on graph screen, 2x width
  1348. GPRINTUP2X:    print string vertically on graph screen, 2x size
  1349. Source:        gprintx.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1350.                             $gp06.asm, $gp08.asm, $gp10.asm, others)
  1351.  
  1352.  
  1353.                Variations of GPrint and GPrintDOWN/GPrintUP;
  1354.                GPrintx, GPrintDOWNx and GPrintUPx print characters
  1355.                which are twice as wide as normal; 2x subroutines
  1356.                print the characters twice as wide and twice as high
  1357.                as normal.
  1358.  
  1359.                Parameters, supported modes and drawmodes are same as
  1360.                GPrint.  GPrintx and GPrint2x also work with user-defined
  1361.                fonts.  See GPrint.
  1362. Example:       see GPrint.
  1363.  
  1364.  
  1365. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1366.  
  1367. GPUTCHR:       print a single character on graphics screen
  1368. Source:        gputchr.asm (gprint.asm)
  1369.  
  1370. Call with:     DS:[DX] pointing to (x,y) coordinate data
  1371.                AL = character to print
  1372. Returns:       nothing
  1373. Uses:          CX
  1374. Supports:      all ASMLIB graphics modes
  1375. Example:
  1376.  
  1377. include asm.inc
  1378.  
  1379. public  mycode
  1380. extrn   gputchr:proc
  1381.  
  1382. .data
  1383. xy      dw 10,10        ; (x,y) coordinates for character
  1384.  
  1385. .code
  1386. mycode  proc
  1387. ; program fragment assumes screen in graphics mode
  1388.         .
  1389.         .
  1390.         .
  1391.         lea     dx,xy   ; DS:[DX] points to coordinate data
  1392.         mov     al,'A'
  1393.         call    gputchr
  1394.         .
  1395.         .
  1396.         .
  1397.         ret
  1398. mycode  endp
  1399.         end
  1400.  
  1401.  
  1402.  
  1403. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1404.  
  1405. GSAVE:         saves a graphics screen as a disk file
  1406.                does not compress image
  1407. Source:        gsave.asm ($graph.asm, $gbytes.asm, $reset.asm)
  1408.  
  1409. Call with:     DS:[DX] pointing to ASCIIZ filename
  1410.                disk space requirements vary depending on graphics mode:
  1411.  
  1412.                  HGraph  (mono)       32,768 bytes
  1413.                  HGraph  (InColor)   131,072 bytes
  1414.                  VGA13X(0)            64,000 bytes
  1415.                  VGA13X(1)            76,800 bytes
  1416.                  VGA13X(2)           128,000 bytes
  1417.                  VGA13X(3)           172,800 bytes
  1418.                  XMode16  varies; up to 240,000 bytes
  1419.                  VESA6Ah, SVGA16(0)  240,000 bytes
  1420.                  SVGA16(1)           393,216 bytes
  1421.                  SVGA256(0)          256,000 bytes
  1422.                  SVGA256(1)          307,200 bytes
  1423.                  SVGA256(2)          480,000 bytes
  1424.                  SVGA256(3)          786,432 bytes
  1425.                  04h/05h/06h          16,384 bytes
  1426.                  40h                  32,768 bytes
  1427.                  0Dh                  32,000 bytes
  1428.                  0Eh                  64,000 bytes
  1429.                  0Fh                  56,000 bytes
  1430.                  10h                 112,000 bytes
  1431.                  11h                  38,400 bytes
  1432.                  12h                 153,600 bytes
  1433.                  13h                  64,000 bytes
  1434.  
  1435. Returns:       if AX <> 0, AX = MS-DOS error code
  1436.                if AX = 0, no error
  1437. Uses:          AX, flags
  1438. Supports:      all ASMLIB graphics modes
  1439. Example:
  1440.  
  1441. include asm.inc
  1442.  
  1443. extrn   gsave:proc
  1444.  
  1445. .data
  1446. filename db 'graph.bin',0
  1447.  
  1448. .code
  1449. ; program fragment assumes DS:@data
  1450.         .
  1451.         .
  1452.         .
  1453.         lea   dx,filename         ; point to ASCIIZ filename
  1454.         call  gsave               ; save graph
  1455.         or    ax,ax               ; was there a problem?
  1456.         jnz   oops                ; do some error control if so
  1457.  
  1458. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1459.  
  1460. GSAVEEMS:      copies the graphics screen buffer to EMS memory; does not
  1461.                compress the image
  1462. Source:        gsaveems.asm ($graph.asm, ems.asm, $gbytes.asm, $emspage.asm
  1463.                              banks.asm, $reset.asm, emputget.asm, $plane.asm
  1464.                              $gsavex.asm)
  1465.  
  1466. Call with:     no parameters; you should use IsEMS before calling this
  1467.                subroutine to determine if EMS memory is installed.  Memory
  1468.                required is tha same as for GSave, above.
  1469. Returns:       if CF = 0, BX = EMS handle
  1470.                if CF = 1, AH = EMS error code
  1471. Uses:          AX, BX, flags
  1472. Supports:      all ASMLIB graphics modes
  1473. Example:
  1474.  
  1475. include asm.inc
  1476.  
  1477. public  testems
  1478. extrn   mode43:proc, getkey:proc, isems:proc, gsaveems:proc, gloadems:proc
  1479.  
  1480. .data
  1481. handle  dw 0
  1482.  
  1483. .code
  1484. testems proc
  1485.         mov     ax,12h          ; VGA 16-color mode
  1486.         int     10h
  1487.         .
  1488.         .
  1489. ; program draws screen
  1490.         .
  1491.         call    isems
  1492.         jc      no_ems
  1493.         call    gsaveems
  1494.         jc      no_ems
  1495.         mov     handle,bx
  1496.         .
  1497.         .
  1498. ; some time later ...
  1499.         mov     bx,handle
  1500.         call    gloadems
  1501.         jc      kill_ems
  1502.         call    getkey
  1503. kill_ems:
  1504.         mov     dx,handle
  1505.         mov     ah,45h          ; EMS function: de-allocate block
  1506.         int     67h
  1507.  
  1508. no_ems: call    mode43
  1509.         ret
  1510. testems endp
  1511.         end
  1512.  
  1513. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1514.  
  1515. GSAVEXMS:      copies the graphics screen buffer to XMS memory; does not
  1516.                compress the image
  1517. Source:        gsavexms.asm ($graph.asm, xms.asm, $gbytes.asm, $gsavex.asm,
  1518.                              banks.asm, $reset.asm, xmputget.asm, $plane.asm)
  1519.  
  1520. Call with:     no parameters; you must use IsXMS before calling this
  1521.                subroutine to determine if XMS memory is installed.  Memory
  1522.                required is tha same as for GSave, above.
  1523. Returns:       if CF = 0, BX = XMS handle
  1524.                if CF = 1, AH = XMS error code
  1525. Uses:          AX, BX, flags
  1526. Supports:      all ASMLIB graphics modes
  1527. Example:
  1528.  
  1529. include asm.inc
  1530.  
  1531. public  testxms
  1532. extrn   mode43:proc, getkey:proc, isxms:proc, gsaveems:proc, gloadxms:proc
  1533. extrn   freexms:proc
  1534.  
  1535. .data
  1536. handle  dw 0
  1537.  
  1538. .code
  1539. testxms proc
  1540.         mov     ax,12h          ; VGA 16-color mode
  1541.         int     10h
  1542.         .
  1543.         .
  1544. ; program draws screen
  1545.         .
  1546.         call    isxms
  1547.         jc      no_xms
  1548.         call    gsavexms
  1549.         jc      no_xms
  1550.         mov     handle,bx
  1551.         .
  1552.         .
  1553. ; some time later ...
  1554.         mov     bx,handle
  1555.         call    gloadxms
  1556.         jc      kill_xms
  1557.         call    getkey
  1558. kill_xms:
  1559.         mov     bx,handle
  1560.         call    freexms
  1561.  
  1562. no_xms: call    mode43
  1563.         ret
  1564. testxms endp
  1565.         end
  1566.  
  1567. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1568.  
  1569. LINEPATTERN:   defines an optional pattern for DrawLine and DrawBox
  1570. Source:        lpattern.asm ($graph.asm)
  1571.  
  1572. Call with:     DS:[BX] pointing to an ASCIIZ string of up to 8 characters.
  1573.                The bit patterns in each character are used to make dashed
  1574.                or dotted lines. For drawmodes > 0, each pixel in the line
  1575.                is updated with the foreground color if the corresponding
  1576.                bit in the bit pattern is 1.  If the bit in the bit pattern
  1577.                is 0, the corresponding pixel in the line is treated as a
  1578.                background pixel.  LinePattern must be called before each
  1579.                call to a subroutine in drawline.obj if you want the line
  1580.                pattern to be used.
  1581.  
  1582.                drawmodes supported are:
  1583.                (monochrome modes)
  1584.                 2 = update foreground pixels only
  1585.                 1 = update foreground and background pixels
  1586.                 0 = XOR the foreground color with the existing image
  1587.                -1 = like drawmode 1, but foreground and background colors
  1588.                     are reversed
  1589.                -2 = like drawmode 2, but foreground and background colors
  1590.                     are reversed
  1591.                (color modes)
  1592.                same as monochrome, plus:
  1593.                 3 = OR the foreground pixels with the pre-existing screen
  1594.                -3 = OR the background pixels with the pre-existing screen
  1595.                 4 = AND the foreground pixels with the pre-existing screen
  1596.                -4 = AND the background pixels with the pre-existing screen
  1597.  
  1598. Returns:       nothing
  1599. Uses:          nothing
  1600. Supports:      all ASMLIB graphics modes
  1601. Example:
  1602.  
  1603. include asm.inc
  1604.  
  1605. extrn   linepattern:proc, drawline:proc
  1606.  
  1607. .data
  1608. x0      dw 25,10,301,97          ; line endpoints at (25,10) & (301,97)
  1609. pattern db 4 dup(32,64),0        ; 8 bytes past x0
  1610.  
  1611. .code
  1612. ; program fragment assumes DS:@data
  1613.         .
  1614.         .
  1615.         lea   bx,pattern         ; DS:[BX] points to bit pattern
  1616.         call  linepattern        ; let drawline know what pattern to use
  1617.         sub   bx,8               ; point to line endpoint data
  1618.         call  drawline           ; draw a patterned line
  1619.  
  1620. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1621.  
  1622. LOADPCX:       reads a .PCX-format file from disk and unpacks to screen
  1623. Source:        loadpcx.asm ($graph.asm, allocdos.asm, color16.asm,
  1624.                             fopen.asm, fseek.asm, fget.asm, fgetchr.asm,
  1625.                             $plane.asm, $reset.asm)
  1626.  
  1627. Call with:     DS:[DX] pointing to ASCIIZ filename of .PCX file
  1628.                LoadPCX assumes that the video system is in an appropriate
  1629.                mode for the image; see PCXInfo (GRAPHICS.DOC).
  1630.                The dimensions of the image in the .PCX file need not
  1631.                match the screen dimensions exactly; any 16-color image
  1632.                may be loaded to a 16-color screen (up to 800 x 600); if
  1633.                the image is too large for the video buffer, either the
  1634.                upper left portion of the image is unpacked, or you may
  1635.                re-size the video buffer (see BufferDim) to fit the image.
  1636.                Any 2-color ("monochrome") image may be loaded to any
  1637.                monochrome screen.
  1638.  
  1639.                256-color PCX files intended for the standard 320x200
  1640.                mode 13h may be loaded to the non-standard VGA13X modes.
  1641.                In VGA13X modes with 400 or 480 vertical pixel rows,
  1642.                a 320x200 image is stretched to fit image proportions.
  1643. Returns:       if CF = 0, no error
  1644.                if CF = 1, AX = DOS error code
  1645. Uses:          AX, flags
  1646. Supports:      All ASMLIB graphics modes EXCEPT:
  1647.                   InColor (palette not working right)
  1648.                   mode 04h, 05h (no palette)
  1649.                   mode 0Fh (EGA monochrome)
  1650. Example:       see PCXInfo and BufferDim         
  1651.                
  1652.  
  1653.  
  1654. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1655.  
  1656. PUTBITBLOCK:   restores bit block saved by GetBitBlock
  1657. PUTBITPLANE:   restores bit plane saved by GetBitPlane
  1658. Source:        same as GetBitBlock or GetBitPlane
  1659.  
  1660. Call with:     DS:[BX] pointing to upper left corner coordinates
  1661.                ES:[DI] pointing to buffer with stored bit block
  1662.                 PutBitPlane: AL = plane number
  1663.                 valid plane numbers for 16-color modes are 0 - 3
  1664.                                     for EGA mode 11h       0 & 2
  1665.  
  1666.                Drawmodes supported are:
  1667.                 mode 13h, VGA13x, SVGA256:
  1668.                  1 = replace existing screen area with bit block
  1669.                  2 = replace existing screen with non-zero pixels
  1670.                      in bit block
  1671.  
  1672.                 HGraph (InColor):
  1673.                  4 = AND the bit block with the existing screen
  1674.                  3 = OR the bit block with the existing screen
  1675.                  1,2 = replace existing screen area with bit block
  1676.                  0 = XOR the bit block with the existing image
  1677.                 -1,-2 = replace existing screen area with inverse bit block
  1678.  
  1679.                 16-color EGA/VGA-type modes and mode 0Fh:
  1680.                  same as InColor, plus:
  1681.                 -3 = OR the inverse bit block with the existing screen
  1682.                 -4 = AND the inverse bit block with the existing screen
  1683.  
  1684.                 mode 04h, 05h, 06h, 40h, HGraph (mono), 11h:
  1685.                  4, 1, 0, -1 same as InColor
  1686.                  2, 3 = combine non-zero pixels in the bit block with the
  1687.                         pre-existing image
  1688.                 -2 = combine non-zero pixel in the inverse bit block with
  1689.                      the pre-existing screen image
  1690.  
  1691.                Most PutBitBlock code ignores View limits (see GetView)
  1692.                but BB08.ASM, BB10.ASM and BB14.ASM (for 256-color modes)
  1693.                may be re-assembled with the /DCLIPPING command-line
  1694.                option to clip PutBitBlock operations at View boundaries.
  1695.  
  1696. Returns:       nothing
  1697. Uses:          nothing
  1698. Supports:      all ASMLIB graphics modes
  1699. Example:       see GetBitBlock
  1700.  
  1701.  
  1702. bit block formats explained on following pages
  1703.  
  1704.  
  1705. ; BIT BLOCK FORMATS
  1706.  
  1707. ; mode 04h, 05h, 06h Hercules monochrome, 11h, and bit planes
  1708. ;
  1709. ; the first word in the buffer is the number of pixel rows (vertical)
  1710. ; in the bit block; the second word is the number of bytes per screen row;
  1711. ; the fifth byte is a bit mask for the last byte of each pixel row.
  1712. ; The bit mask = 0FFh for byte-aligned bit blocks.
  1713.  
  1714. bblock  dw 15,5              ; 15 rows, 5 bytes per row
  1715.         db 11111110b         ; bit mask for right end of pixel row
  1716.                              ; bit block data follows:
  1717.                              ;  15 rows, 5 bytes per row
  1718.         db 00000000b,10000000b,00000000b,10000000b,00000010b
  1719.         db 00000001b,11000000b,00000001b,11000000b,00000110b
  1720.         db 00000011b,11100000b,00000011b,11100000b,00001100b
  1721.         db 00000111b,01110000b,00000111b,01110000b,00011000b
  1722.         db 00001110b,00111000b,00001110b,00111000b,00110000b
  1723.         db 00011100b,00011100b,00011100b,00011100b,01100000b
  1724.         db 00000001b,11000000b,00000001b,11000000b,11000000b
  1725.         db 00000001b,11000000b,00000001b,11000000b,01100000b
  1726.         db 00000001b,11000000b,00000001b,11000000b,00110000b
  1727.         db 00000001b,11000000b,00000001b,11000000b,00011000b
  1728.         db 00000001b,11000000b,00000001b,11000000b,00001100b
  1729.         db 00000001b,11000000b,00000001b,11000000b,00000110b
  1730.         db 00000001b,11000000b,00000001b,11000000b,00000010b
  1731.         db 00000001b,11000000b,00000001b,11000000b,00000000b
  1732.         db 00000001b,11000000b,00000001b,11000000b,00000000b
  1733.  
  1734. ; 16-color modes: 0Dh, 0Eh, 10h, 12h, 6Ah, xmode16, InColor:
  1735. ; same as above, except there are 4 planes of bit block data
  1736. ; i. e., 4 groups of 15-row, 5-byte data; plane 3 is the first
  1737. ; block, followed by planes 2, 1, and 0.
  1738.  
  1739. ; EGA monochrome mode: 0Fh
  1740. ; similar to 16-color modes, but there are only 2 groups of bit
  1741. ; block data instead of 4
  1742.  
  1743.  
  1744. ; 256-color modes on next page
  1745.  
  1746.  
  1747. ; BIT BLOCK FORMATS
  1748.  
  1749. ; mode 13h: no bit mask in the bit block header
  1750.  
  1751. red     equ 12                    ; bright red
  1752. blue    equ 1                     ; blue
  1753.  
  1754. bblock  dw 12,5                   ; 12 rows, 5 bytes per row
  1755.         db red, red, blue,red, red
  1756.         db red, blue,red, blue,red
  1757.         db blue,red, red, red, blue
  1758.         db red, red, blue,red, red
  1759.         db red, blue,red, blue,red
  1760.         db blue,red, red, red, blue
  1761.         db red, red, blue,red, red
  1762.         db red, blue,red, blue,red
  1763.         db blue,red, red, red, blue
  1764.         db red, red, blue,red, red
  1765.         db red, blue,red, blue,red
  1766.         db blue,red, red, red, blue
  1767.  
  1768. ; vga13x: no bit mask in the bit block header, x & y
  1769. ; orienation of data is reversed for speed
  1770. ; this example is the same pattern shown for mode 13h, above
  1771.  
  1772. red     equ 12                    ; bright red
  1773. blue    equ 1                     ; blue
  1774.  
  1775. bblock  dw 12,5                   ; 12 rows, 5 bytes per row
  1776.         db red, red, blue,red, red, blue,red, red, blue,red, red, blue
  1777.         db red, blue,red, red, blue,red, red, blue,red, red, blue,red
  1778.         db blue,red, red, blue,red, red, blue,red, red, blue,red, red
  1779.         db red, blue,red, red, blue,red, red, blue,red, red, blue,red
  1780.         db red, red, blue,red, red, blue,red, red, blue,red, red, blue
  1781.  
  1782.  
  1783. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1784.  
  1785. PUTDOT:        change a pixel on a graphics screen
  1786. Source:        putdot.asm ($graph.asm, $putdot.asm, others)
  1787.  
  1788. Call with:     DS:[BX] pointing to x & y coordinates
  1789.                Drawmodes supported are:
  1790.                (monochrome)
  1791.                 1 = set pixel
  1792.                 0 = toggle pixel
  1793.                -1 = erase pixel
  1794.  
  1795.                (color modes)
  1796.                 3 = OR foreground color with pre-existing pixel
  1797.                 1, 2 = replace pixel with foreground color
  1798.                 0 = XOR foreground color with pre-existing pixel
  1799.                -1, -2 = replace pixel with background color
  1800.                -3 = OR background color with pre-existing pixel
  1801. Returns:       if CF = 0, no error
  1802.                if CF = 1, pixel coordinates outside active view area
  1803. Uses:          CF; all other registers and flags are saved
  1804. Supports:      all ASMLIB graphics modes
  1805. Example:
  1806.  
  1807. include asm.inc
  1808.  
  1809. extrn   putdot:proc
  1810.  
  1811. .data
  1812. extrn   drawmode:byte
  1813. x       dw 100,117            ; pixel at x = 100, y = 117
  1814.  
  1815. .code
  1816. ; program fragment assumes DS:@data
  1817.         .
  1818.         .
  1819.         .
  1820.         mov   drawmode,1      ; use foreground color
  1821.         lea   bx,x            ; point to pixel coordinates
  1822.         call  putdot
  1823.  
  1824.  
  1825.  
  1826. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1827.  
  1828. PCXINFO:       read vital information from .PCX-format graphics file
  1829. Source:        pcxinfo.asm
  1830.  
  1831. Call with:     DS:[DX] pointing to ASCIIZ name of .PCX file
  1832. Returns:       DS:[BX] pointing to PCX information data structure:
  1833.  
  1834.                pcx_info struc
  1835.                horiz    dw 0
  1836.                vert     dw 0
  1837.                colors   dw 0
  1838.                planes   db 0
  1839.                xpixels  dw 0
  1840.                ypixels  dw 0
  1841.                pcx_info ends
  1842.  
  1843.                horiz and vert are screen dimensions
  1844.                colors: 16 for EGA/VGA 16-color modes, 256 for 256-color modes
  1845.                planes: number of pit planes encoded
  1846.                        4 for 16-color modes, 1 for monochrome, CGA or mode 13h
  1847.                xpixels: horizontal image size
  1848.                ypixels: vertical image size
  1849.  
  1850.  
  1851.  
  1852. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1853.  
  1854. RESETVIEW:     restores default view area on active graphics page and
  1855.                returns a pointer to the view data
  1856. Source:        view.asm ($graph.asm)
  1857.  
  1858. Call with:     no parameters
  1859.                ResetView restores the default full screen view area.
  1860.                The far pointer returned points to ASMLIB's data area in
  1861.                $graph.obj for the active graphics page's view coordinates.
  1862. Returns:       ES:[BX] pointing to the active page's view data.
  1863. Uses:          ES, BX; all other registers and flags are saved
  1864. Supports:      all ASMLIB graphics modes
  1865. Example:
  1866.  
  1867. include asm.inc
  1868.  
  1869. extrn   resetview:proc
  1870.  
  1871. x0 EQU word ptr ES:[BX]
  1872. y0 EQU word ptr ES:2[BX]
  1873. x1 EQU word ptr ES:4[BX]
  1874. y1 EQU word ptr ES:6[BX]
  1875.  
  1876. .code
  1877.         .
  1878.         .
  1879.         .
  1880.         call  resetview
  1881.  
  1882.  
  1883.  
  1884. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1885.  
  1886. SCREENORIGIN:  control position of re-sized video buffer on screen
  1887.                see also BufferDim in GRAPHICS.DOC
  1888. Source:        scrnorig.asm
  1889.  
  1890. Call with:     DS:[BX] pointing to upper-left coordinates of logical
  1891.                video buffer to be displayed at upper-left corner of screen.
  1892. Returns:       nothing
  1893. Uses:          nothing
  1894. Supports:      EGA/VGA 16-color modes re-sized with BufferDim
  1895. Example:       see BufferDim
  1896.  
  1897.  
  1898. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1899.  
  1900. SHOWGPAGE:     change graphics page displayed on screen
  1901.                See also UseGPage and GPage.
  1902. Source:        gpage1.asm ($graph.asm, $herc.asm)
  1903.  
  1904. Call with:     BL = page number
  1905. Returns:       Carry Flag = error code
  1906.                if CF = 0, no error
  1907.                if CF = 1, bad page number
  1908. Uses:          CF
  1909. Supports:      HGraph (mono and InColor), modes 0Dh, 0Eh, 0Fh, 10h, VGA13X
  1910. Example:
  1911.  
  1912. include asm.inc
  1913.  
  1914. extrn   showgpage:proc
  1915.  
  1916. .code
  1917.         .
  1918.         .
  1919.         .
  1920.         mov   bl,1           ; show page 1
  1921.         call  showgpage
  1922.         jc    no_page_1      ; no page 1 for this mode
  1923.  
  1924. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1925.  
  1926. SHOWGPLANE:    show one or more planes of multi-plane EGA/VGA screen
  1927. Source:        gplane.asm ($graph.asm)
  1928.  
  1929. Call with:     AL = plane mask
  1930.                Bits set in the plane mask correspond to the plane displayed.
  1931.                ASMLIB's default mask is 00001111b, enabling all 4 planes.
  1932. Returns:       CF = error flag
  1933.                if CF = 0, no error
  1934.                if CF = 1, bad plane mask or graphics mode
  1935. Uses:          CF
  1936. Supports:      EGA & VGA 16-color modes, including VESA 6Ah, xmode16
  1937.                    and SVGA16
  1938.                EGA monochrome: planes 0 and 2
  1939.                    (mask = 00000101b for both planes)
  1940.                Hercules InColor
  1941. Example:
  1942.  
  1943. include asm.inc
  1944.  
  1945. extrn   showgplane:proc
  1946.  
  1947. .code
  1948.         .
  1949.         .
  1950.         .
  1951.         mov   al,00000101b      ; show planes 0 and 2
  1952.         call  showgplane
  1953.         jc    error             ; error control
  1954.  
  1955.  
  1956.  
  1957. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1958.  
  1959. SMALLTEXT:     change GPrint, GPrintX and GPrint2X default to 8x8 characters
  1960.                in Hercules and modes 10h, 11h, 12h; makes 8x8-size
  1961.                high ASCII characters available to GPrint in all modes
  1962. Source:        smalltxt.asm (f8x8.asm, $graph.asm)
  1963.  
  1964. STDTEXT:       restore GPrint default characters (see GPrint)
  1965. Source:        stdtext.asm (f8x14.asm, fontdata.asm)
  1966.  
  1967. Call with:     no parameters
  1968. Returns:       nothing
  1969. Uses:          nothing; all registers and flags are saved
  1970. Example:
  1971.  
  1972. include asm.inc
  1973.  
  1974. extrn   smalltext:proc, stdtext:proc
  1975.  
  1976. .code
  1977.         .
  1978.         .
  1979.         .
  1980. ; make GPrint use the small 8x8 characters
  1981. ; make sure high ASCII characters are available
  1982.         call   smalltext
  1983.         .
  1984.         .
  1985.  
  1986. ; sometime later, I want to use larger 8x14 characters
  1987.         call   stdtext
  1988.  
  1989.  
  1990. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1991.  
  1992. UC2SYS:        convert user-defined coordinates to system coordinates
  1993. Source:        uc2sys.asm ($graph.asm)
  1994.  
  1995. Call with:     DS:[BX] pointing to (x0,y0,x1,y1) coordinates in
  1996.                user-defined format
  1997.                assumes DS:@data
  1998. Returns:       DS:[BX] pointing to (x0,y0,x1,y1) coordinates in system
  1999.                format
  2000.                UCINIT and UC2SYS allow the programmer to define a
  2001.                graph coordinate system to fit the data, and converts
  2002.                the system's y-orientation from top-to-bottom to the more
  2003.                familiar bottom-to-top
  2004.                US2SYS maintains a separate data area for converted
  2005.                coordinates; the input coordinates are not changed
  2006. Uses:          BX
  2007. Supports:      all ASMLIB graphics modes; user-defined coordinates
  2008.                from -32767 to +32767; see also UCINIT
  2009. Example:       see UCINIT
  2010.  
  2011.  
  2012. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2013.  
  2014. UCINIT:        specify user-defined coordinates
  2015. Source:        uc2sys.asm ($graph.asm)
  2016.  
  2017. Call with:     DS:[BX] pointing to desired xmin, ymin, xmax, ymax
  2018.                coordinates (xmax-xmin < 32767, ymax-ymin < 32767)
  2019.                assumes DS:@data
  2020.                ASMLIB's default user coordinates are (0,0,1000,1000)
  2021. Returns:       nothing
  2022. Uses:          nothing
  2023. Example:
  2024.  
  2025. ; I'm plotting a graph on the screen with x-axis data from 1983 to 2007
  2026. ; and y-axis data from -72 to 140
  2027. ; I'll leave some space on each side for titles, etc.
  2028.  
  2029. extrn   ucinit:proc, uc2sys:proc
  2030. extrn   drawbox:proc
  2031.  
  2032. .data
  2033. x0      dw 1975    ; xmin
  2034. y0      dw -80     ; ymin
  2035. x1      dw 2014    ; xmax
  2036. y1      dw 148     ; ymax
  2037.  
  2038. .code
  2039. ; program fragment assumes DS:@data
  2040.         .
  2041.         .
  2042.         .
  2043. ; establish coordinates
  2044.         lea     bx,x0
  2045.         call    ucinit
  2046.  
  2047. ; draw a box arouund the graph
  2048.         mov     x0,1983
  2049.         mov     y0,-72
  2050.         mov     x1,2007
  2051.         mov     y1,140
  2052.         lea     bx,x0
  2053.         call    uc2sys
  2054.         call    drawbox
  2055.  
  2056. ; SEE ALSO BARGRAPH.ASM EXAMPLE PROGRAM
  2057.  
  2058.  
  2059. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2060.  
  2061. USEGPAGE:      changes active graphics page used by ASMLIB
  2062.                does not change page displayed (see GPage and ShowGPage)
  2063. Source:        gpage.asm ($graph.asm, $herc.asm)
  2064.  
  2065. Call with:     BL = page number
  2066. Returns:       if CF = 0, no error
  2067.                if CF = 1, bad page number
  2068. Uses:          CF
  2069. Supports:      HGraph (mono and InColor) with Use64k
  2070.                EGA and VGA: modes with more than one page
  2071. Example:
  2072.  
  2073. include asm.inc
  2074.  
  2075. extrn   usegpage:proc
  2076.  
  2077. .code
  2078.         .
  2079.         .
  2080.         mov   bl,1
  2081.         call  usegpage
  2082.         jc    oops
  2083.  
  2084.  
  2085.  
  2086. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2087.  
  2088. VIEWLIMIT:     determine current mode's maximum dimensions
  2089. Source:        view.asm ($graph.asm)
  2090.  
  2091. Call with:     no parameters
  2092. Returns:       ES:[BX] pointing to xmax
  2093.                ES:2[BX] pointing to ymax
  2094. Uses:          ES, BX
  2095. Supports:      all ASMLIB graphics modes
  2096. Example:
  2097.  
  2098. include asm.inc
  2099.  
  2100. extrn   viewlimit:proc
  2101.  
  2102. .code
  2103.         .
  2104.         .
  2105.         call  viewlimit
  2106.  
  2107.