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