home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 21 / CD_ASCQ_21_040595.iso / dos / prg / c / xlib612 / docs / ascii / ascii.doc
Text File  |  1993-10-29  |  103KB  |  5,911 lines

  1. INTRODUCTION     1 
  2.  
  3. EDITORS NOTE     1 
  4.  
  5. CONTACTING THE AUTHORS     1 
  6.  
  7. DISCLAIMER     1 
  8.  
  9. ABOUT XLIB     1 
  10.  
  11. GENERAL FEATURES     2 
  12.  
  13. MODULES COMPRISING XLIB     2 
  14.  
  15. GLOBAL DEFINES     3 
  16.  
  17. MODULE XMAIN     4 
  18.  
  19. SOURCES     4 
  20.  
  21. C HEADER FILE     4 
  22.  
  23. EXPORTED VARIABLES     4 
  24.  
  25. EXPORTED FUNCTIONS     7 
  26.  
  27. x_set_mode     7 
  28.  
  29. x_select_default_plane     7 
  30.  
  31. x_set_splitscreen     8 
  32.  
  33. x_set_doublebuffer     9 
  34.  
  35. x_hide_splitscreen     10 
  36.  
  37. x_show_splitscreen     11 
  38.  
  39. x_adjust_splitscreen     11 
  40.  
  41. x_set_start_addr     11 
  42.  
  43. x_page_flip     12 
  44.  
  45. x_text_mode     12 
  46.  
  47. x_set_cliprect     12 
  48.  
  49. MODULE XPOINT     13 
  50.  
  51. SOURCES     13 
  52.  
  53. C HEADER FILE     13 
  54.  
  55. EXPORTED FUNCTIONS     14 
  56.  
  57. x_put_pix     14 
  58.  
  59. x_get_pix     14 
  60.  
  61. MODULE XRECT     15 
  62.  
  63. SOURCES     15 
  64.  
  65. C HEADER FILE     15 
  66.  
  67. EXPORTED FUNCTIONS     16 
  68.  
  69. x_rect_pattern     16 
  70.  
  71. x_rect_pattern_clipped     17 
  72.  
  73. x_rect_fill     17 
  74.  
  75. x_rect_fill_clipped     18 
  76.  
  77. x_cp_vid_rect     19 
  78.  
  79. x_shift_rect     20 
  80.  
  81. MODULE XPAL     21 
  82.  
  83. SOURCES     21 
  84.  
  85. C HEADER FILE     21 
  86.  
  87. EXPORTED FUNCTIONS     22 
  88.  
  89. x_get_pal_raw     22 
  90.  
  91. x_get_pal_struc     22 
  92.  
  93. x_put_pal_raw     22 
  94.  
  95. x_put_pal_struc     23 
  96.  
  97. x_set_rgb     23 
  98.  
  99. x_rot_pal_struc     23 
  100.  
  101. x_rot_pal_raw     23 
  102.  
  103. x_put_contrast_pal_struc     24 
  104.  
  105. x_transpose_pal_struc     24 
  106.  
  107. x_cpcontrast_pal_struc     24 
  108.  
  109. MODULE XLINE     25 
  110.  
  111. SOURCES     25 
  112.  
  113. C HEADER FILE     25 
  114.  
  115. EXPORTED FUNCTIONS     26 
  116.  
  117. x_line     26 
  118.  
  119. MODULE XTEXT     27 
  120.  
  121. SOURCES     27 
  122.  
  123. C HEADER FILE     27 
  124.  
  125. MACROS     27 
  126.  
  127. EXPORTED VARIABLES     27 
  128.  
  129. EXPORTED FUNCTIONS     28 
  130.  
  131. x_text_init     28 
  132.  
  133. x_set_font     28 
  134.  
  135. x_register_userfont     28 
  136.  
  137. x_put_char     29 
  138.  
  139. x_printf      29 
  140.  
  141. x_bgprintf     30 
  142.  
  143. x_get_char_width     30 
  144.  
  145. MODULE XPBITMAP     31 
  146.  
  147. SOURCES     31 
  148.  
  149. C HEADER FILE     31 
  150.  
  151. EXPORTED FUNCTIONS     32 
  152.  
  153. x_put_masked_pbm     32 
  154.  
  155. x_put_pbm     32 
  156.  
  157. x_get_pbm     33 
  158.  
  159. MODULE XPBMCLIP     34 
  160.  
  161. SOURCES     34 
  162.  
  163. C HEADER FILE     34 
  164.  
  165. EXPORTED FUNCTIONS     34 
  166.  
  167. x_put_masked_pbm_clipx     35 
  168.  
  169. x_put_masked_pbm_clipy     35 
  170.  
  171. x_put_masked_pbm_clipxy     36 
  172.  
  173. x_put_pbm_clipx     36 
  174.  
  175. x_put_pbm_clipy     37 
  176.  
  177. x_put_pbm_clipxy     37 
  178.  
  179. MODULE  XCBITMAP     38 
  180.  
  181. SOURCES     38 
  182.  
  183. C HEADER FILE     38 
  184.  
  185. EXPORTED FUNCTIONS     39 
  186.  
  187. x_compile_bitmap     39 
  188.  
  189. x_sizeof_cbitmap     39 
  190.  
  191. x_put_cbitmap     39 
  192.  
  193. MODULE XCOMPPBM     40 
  194.  
  195. SOURCES     40 
  196.  
  197. C HEADER FILE     40 
  198.  
  199. EXPORTED FUNCTIONS     41 
  200.  
  201. x_compile_pbm     41 
  202.  
  203. x_sizeof_cpbm     41 
  204.  
  205. MODULE XVBITMAP     42 
  206.  
  207. SOURCES     43 
  208.  
  209. C HEADER FILE     43 
  210.  
  211. EXPORTED FUNCTIONS     44 
  212.  
  213. x_make_vbm     44 
  214.  
  215. x_put_masked_vbm     44 
  216.  
  217. x_put_masked_vbm_clipx     45 
  218.  
  219. x_put_masked_vbm_clipy     45 
  220.  
  221. x_put_masked_vbm_clipxy     46 
  222.  
  223. MODULE  XMOUSE     47 
  224.  
  225. MS Mouse Driver Functions     47 
  226.  
  227. SOURCES     48 
  228.  
  229. C HEADER FILE     48 
  230.  
  231. EXPORTED VARIABLES     48 
  232.  
  233. EXPORTED FUNCTIONS     49 
  234.  
  235. x_mouse_init     49 
  236.  
  237. x_define_mouse_cursor     49 
  238.  
  239. x_show_mouse     50 
  240.  
  241. x_hide_mouse     50 
  242.  
  243. x_mouse_remove     50 
  244.  
  245. x_position_mouse     50 
  246.  
  247. x_mouse_window     50 
  248.  
  249. x_update_mouse     51 
  250.  
  251. MODULE XBMTOOLS     52 
  252.  
  253. SOURCES     52 
  254.  
  255. C HEADER FILE     52 
  256.  
  257. MACROS     53 
  258.  
  259. EXPORT FUNCTIONS     54 
  260.  
  261. x_pbm_to_bm     54 
  262.  
  263. x_bm_to_pbm     54 
  264.  
  265. MODULE  XCLIPPBM     55 
  266.  
  267. SOURCES     55 
  268.  
  269. C HEADER FILE     55 
  270.  
  271. EXPORTED VARIABLES     55 
  272.  
  273. EXPORTED FUNCTIONS     56 
  274.  
  275. x_clip_pbm     56 
  276.  
  277. x_clip_masked_pbm     56 
  278.  
  279. MODULE  XCIRCLE     57 
  280.  
  281. SOURCES     57 
  282.  
  283. C HEADER FILE     57 
  284.  
  285. EXPORTED FUNCTIONS     58 
  286.  
  287. x_circle     58 
  288.  
  289. x_filled_circle     58 
  290.  
  291. MODULE XDETECT     59 
  292.  
  293. SOURCES     59 
  294.  
  295. C HEADER FILE     59 
  296.  
  297. EXPORTED MACROS     59 
  298.  
  299. EXPORTED VARIABLES     60 
  300.  
  301. EXPORTED FUNCTIONS     61 
  302.  
  303. x_graphics_card     61 
  304.  
  305. x_processor     61 
  306.  
  307. x_coprocessor     61 
  308.  
  309. x_mousedriver     61 
  310.  
  311. MODULE XFILEIO     62 
  312.  
  313. SOURCES     62 
  314.  
  315. C HEADER FILE     62 
  316.  
  317. EXPORTED MACROS     62 
  318.  
  319. EXPORTED FUNCTIONS     63 
  320.  
  321. f_open     63 
  322.  
  323. f_close     63 
  324.  
  325. f_read     63 
  326.  
  327. f_readfar     64 
  328.  
  329. f_write     64 
  330.  
  331. f_writefar     64 
  332.  
  333. f_seek     65 
  334.  
  335. f_filelength     65 
  336.  
  337. f_tell     65 
  338.  
  339. MODULE XRLETOOL     66 
  340.  
  341. SOURCES     66 
  342.  
  343. C HEADER FILE     66 
  344.  
  345. EXPORTED FUNCTIONS     67 
  346.  
  347. x_buff_RLDecode     67 
  348.  
  349. x_buff_RLEncode     67 
  350.  
  351. x_buff_RLE_size     67 
  352.  
  353. x_file_RLEncode     68 
  354.  
  355. x_file_RLDecode     68 
  356.  
  357. MODULE XPOLYGON     69 
  358.  
  359. SOURCES     69 
  360.  
  361. C HEADER FILE     69 
  362.  
  363. TYPE DEFS     69 
  364.  
  365. EXPORTED FUNCTIONS     70 
  366.  
  367. x_triangle     70 
  368.  
  369. x_polygon     71 
  370.  
  371. MODULE XBEZIER     71 
  372.  
  373. SOURCES     72 
  374.  
  375. C HEADER FILE     72 
  376.  
  377. EXPORTED FUNCTIONS     73 
  378.  
  379. x_bezier     73 
  380.  
  381. MODULE XFILL     74 
  382.  
  383. SOURCES     74 
  384.  
  385. C HEADER FILE     74 
  386.  
  387. EXPORTED FUNCTIONS     75 
  388.  
  389. x_flood_fill     75 
  390.  
  391. x_boundry_fill     75 
  392.  
  393. MODULE XVSYNC     76 
  394.  
  395. SOURCES     76 
  396.  
  397. C HEADER FILE     76 
  398.  
  399. EXPORTED VARIABLES     77 
  400.  
  401. EXPORTED FUNCTIONS     78 
  402.  
  403. x_install_vsync_handler     78 
  404.  
  405. x_remove_vsync_handler     78 
  406.  
  407. x_set_user_vsync_handler     78 
  408.  
  409. x_wait_start_addr     79 
  410.  
  411. MODULE XCBITM32     79 
  412.  
  413. SOURCES     80 
  414.  
  415. C HEADER FILE     80 
  416.  
  417. EXPORTED FUNCTIONS     81 
  418.  
  419. x_compile_bitmap_32     81 
  420.  
  421. x_sizeof_cpbm     81 
  422.  
  423. REFERENCE SECTION     82 
  424.  
  425. REFERENCES     82 
  426.  
  427. WHAT IS MODE X ?     82 
  428.  
  429. WHAT IS A SPLIT SCREEN ?     82 
  430.  
  431. WHAT IS RLE?     83 
  432.  
  433. WHAT IS DOUBLE BUFFERING ?     84 
  434.  
  435. WHAT IS TRIPLE BUFFERING?     84 
  436.  
  437. WHAT IS A BEZIER CURVE?     84 
  438.  
  439. The Care and Feeding of Compiled Masked Blits     85 
  440.  
  441. Blits and Pieces     87 
  442.  
  443. Wheel Have to See About That     88 
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  XLIB
  456.  
  457. The "Mode X" graphics library.
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523. Written by:  Themie Gouthas.
  524.  
  525. Additional code contributed by: Matthew MacKenzie and Tore Jahn
  526. Bastiansen.
  527.  
  528. Manual edited by: J. Donavan Stanley.
  529.  
  530.  
  531.  
  532.  
  533.  
  534. INTRODUCTION
  535.  
  536.  
  537.  
  538. EDITORS NOTE:
  539.  
  540.  
  541.  
  542. "Do not trust this excuse for a manual when in doubt go to the
  543. code."  Those words were written by Themie Gouthas in each
  544. manual accompanying an XLIB release.  I have undertaken this
  545. project to provide you the end user with a high-quality,
  546. accurate manual to use.  I have gone to the code, checked and
  547. cross-checked everything and consulted the authors to ensure
  548. everything is correct. Just the same I'm only human, so if you
  549. spot any errors please let me know.
  550.  
  551.  
  552.  
  553. Throughout this manual function names are in bold italics,
  554. variables are in regular italics.  This only holds true for
  555. those of you who are reading the non-ASCII version of this
  556. document.  If your favorite word processor isn't included in
  557. this release of the manual let me know and I will make very
  558. effort to support it. I also plan on making a printed, 3-ring
  559. bound versions available for a small fee (Enough to cover the
  560. cost of materials and postage) if enough people are interested. 
  561.  
  562.  
  563.  
  564.  
  565.  
  566. CONTACTING THE AUTHORS:
  567.  
  568.     Themie Gouthas -   Internet:  egg@dstos3.dsto.goc.au   or 
  569. teg@bart.dsto.gov.au
  570.  
  571.     Matthew MacKenzie -  Internet:  matm@eng.umd.edu
  572.  
  573.     Tore Bastiansen - Internet:  toreba@ifi.uio.no
  574.  
  575.     Donavan Stanley (The editor) - Internet: 
  576. bbooth@vax.cns.muskingnum.edu (This is a
  577.  
  578.                                      friend who will relay your message to me.)
  579.  
  580.                        BBS:   The Last Byte BBS (614) 432-3564.
  581.  
  582.  
  583.  
  584.  
  585.  
  586. DISCLAIMER
  587.  
  588.  
  589.  
  590. This library is distributed AS IS.  The authors specifically
  591. disclaim any responsibility for any loss of profit or any
  592. incidental, consequential or other damages.  The authors reserve
  593. ALL rights to the code contained in XLIB.
  594.  
  595.  
  596.  
  597.  
  598.  
  599. ABOUT XLIB
  600.  
  601.  
  602.  
  603. XLIB  is a "user supported freeware" graphics library
  604. specifically designed with game programming in mind. It has been
  605. released to the public for the benefit of all and is the result
  606. of MANY hours of or work. 
  607.  
  608.  
  609.  
  610. All users must comply with the following guidelines:
  611.  
  612. Leave the code in the public domain.
  613.  
  614. Do not distribute any modified or incomplete versions of this
  615. library.
  616.  
  617.  
  618.  
  619. New contributions and comments are welcome. There will be more
  620. releases as the code evolves.
  621.  
  622.  
  623.  
  624. GENERAL FEATURES
  625.  
  626.  
  627.  
  628.     Support for a number of 256 color tweaked graphics mode
  629. resolutions   
  630.  
  631.     320x200 320x240 360x200 360x240 376x282 320x400 320x480 360x400
  632. 360x480 
  633.  
  634.     360x360 376x308 376x564
  635.  
  636.  
  637.  
  638.     Virtual screens larger than the physical screen (memory 
  639. permitting) that can be panned at     
  640.  
  641.     pixel resolution in all directions
  642.  
  643.  
  644.  
  645.     A split screen capability for status displays etc.
  646.  
  647.  
  648.  
  649.     Text functions supporting 8x8 and 8x14 ROM fonts and user
  650. defined fonts
  651.  
  652.  
  653.  
  654.     Support for page flipping
  655.  
  656.  
  657.  
  658.     Graphics primitives such as line and rectangle drawing
  659. functions.
  660.  
  661.  
  662.  
  663.     Bit block manipulation functions
  664.  
  665.  
  666.  
  667.  
  668.  
  669. Please note that some of the resolutions best suit monitors with
  670. adjustable vertical height.
  671.  
  672.  
  673.  
  674.  
  675.  
  676. MODULES COMPRISING XLIB   
  677.  
  678.  
  679.  
  680.     XMAIN             Main module containing mode setting code and basic
  681. functions   
  682.  
  683.     XPOINT            Pixel functions   
  684.  
  685.     XRECT             Filled rectangle and VRAM to VRAM block move
  686. functions   
  687.  
  688.     XPAL             Palette functions   
  689.  
  690.     XLINE             Line functions   
  691.  
  692.     XTEXT             Text and font functions   
  693.  
  694.     XPRINTF           Printf style string output   
  695.  
  696.     XPBITMAP          Planar bitmap functions   
  697.  
  698.     XPBMCLIP          Clipped planar bitmap functions   
  699.  
  700.     XCBITMAP         Compiled bitmap functions using linear bitmaps.  
  701.  
  702.     XCOMPPBM        Compiled bitmap functions using planar bitmaps.
  703.  
  704.     XVBITMAP         Video bitmap functions   
  705.  
  706.     XMAKEVBM      Support module for video bitmaps   
  707.  
  708.     XMOUSE            Mouse functions
  709.  
  710.     XBMTOOLS          Bitmap format conversion tools
  711.  
  712.     XCLIPPBM        Clipped planar bitmap functions. (Uses blits.)   
  713.  
  714.     XCIRCLE        Circle Drawing functions.
  715.  
  716.     XDETECT           Hardware detection module   
  717.  
  718.     XFILEIO           File I/O functions   
  719.  
  720.     XRLETOOL          RLE encoding/decoding functions   
  721.  
  722.     XPOLYGON        Convex polygon and triangle functions.
  723.  
  724.     XBEZIER           Bezier curve drawing 
  725.  
  726.     XFILL            General purpose flood fill routines.
  727.  
  728.     XVSYNC        Simulated vertical retrace Interrupt module.
  729.  
  730.     XCBITM32        32 Bit compiled bitmaps.
  731.  
  732.  
  733.  
  734.  
  735.  
  736. GLOBAL DEFINES (xlib.inc)
  737.  
  738.  
  739.  
  740.     Types:
  741.  
  742.         BYTE unsigned char 
  743.  
  744.         WORD unsigned int
  745.  
  746.  
  747.  
  748.  
  749.  
  750.     Available X mode resolutions:
  751.  
  752.         X_MODE_320x200  0 
  753.  
  754.         X_MODE_320x240  1 
  755.  
  756.         X_MODE_360x200  2 
  757.  
  758.         X_MODE_360x240  3 
  759.  
  760.         X_MODE_360x282  4 
  761.  
  762.         X_MODE_320x400  5 
  763.  
  764.         X_MODE_320x480  6 
  765.  
  766.         X_MODE_360x400  7 
  767.  
  768.         X_MODE_360x480  8 
  769.  
  770.         X_MODE_360x360  9 
  771.  
  772.         X_MODE_376x308  10 
  773.  
  774.         X_MODE_376x564  11
  775.  
  776.  
  777.  
  778.  
  779.  
  780.     Palette rotation direction:
  781.  
  782.         BACKWARD 0 
  783.  
  784.         FORWARD    1
  785.  
  786.  
  787.  
  788.  
  789.  
  790.     Function return values:
  791.  
  792.         X_MODE_INVALID   -1 
  793.  
  794.         ERROR                          1 
  795.  
  796.         OK                             0 MODULE XMAIN
  797.  
  798.  
  799.  
  800.  
  801.  
  802. The Xmain module is the base module of the XLIB library. It
  803. contains the essential functions that initialize and customize
  804. the graphic environment.
  805.  
  806.  
  807.  
  808.  
  809.  
  810. SOURCES
  811.  
  812.     xmain.asm 
  813.  
  814.     xmain.inc 
  815.  
  816.     xlib.inc 
  817.  
  818.     model.inc
  819.  
  820.  
  821.  
  822.  
  823.  
  824. C HEADER FILE
  825.  
  826.     xlib.h
  827.  
  828.  
  829.  
  830.  
  831.  
  832. EXPORTED VARIABLES
  833.  
  834.  
  835.  
  836. NOTE: All variables are read only unless otherwise specified. If
  837. you modify  them manually, the results may be unpredictable.
  838.  
  839.  
  840.  
  841. InGraphics BYTE- Flag indicating that the xlib graphics system
  842. is active. Set by function
  843.  
  844. x_set_mode.
  845.  
  846.  
  847.  
  848. CurrXMode WORD - If the xlib graphics system is active, contains
  849. the id of the x mode. Set by function x_set_mode.  See also:
  850. defines (i.e. X_MODE_320x200 ... )
  851.  
  852.  
  853.  
  854. ScrnPhysicalByteWidth WORD - Physical screen width in bytes. Set
  855. by function x_set_mode
  856.  
  857.  
  858.  
  859. ScrnPhysicalPixelWidth WORD - Physical screen width in pixels.
  860. Set by function x_set_mode
  861.  
  862.  
  863.  
  864. ScrnPhysicalHeight WORD - Physical screen height in pixels. Set
  865. by function x_set_mode.
  866.  
  867.  
  868.  
  869. ScrnLogicalByteWidth WORD - Virtual screen width in bytes. Set
  870. by function x_set_mode.
  871.  
  872.  
  873.  
  874. ScrnLogicalPixelWidth WORD - Virtual screen width in pixels. Set
  875. by function x_set_mode.
  876.  
  877.  
  878.  
  879. ScrnLogicalHeight WORD - Virtual screen height in pixels. Set
  880. initially by function x_set_mode but is updated by functions
  881. x_set_splitscrn and x_set_doublebuffer.
  882.  
  883.  
  884.  
  885. MaxScrollX  WORD - Max. X pixel position of physical screen
  886. within virtual screen. Set by function x_set_mode.
  887.  
  888. MaxScrollY WORD - Max. Y pixel position of physical screen
  889. within virtual screen. Set initially by function x_set_mode but
  890. is updated by functions x_set_splitscrn and x_set_doublebuffer.
  891.  
  892.  
  893.  
  894. ErrorValue WORD - Contains error value. General use variable to
  895. communicate the error status from several functions. The value
  896. in this variable usually is only valid for the last function
  897. called that sets it.
  898.  
  899.  
  900.  
  901. SplitScrnOffs WORD - Offset in video ram of split screen. Set by
  902. function x_set_splitscrn. The value is only valid if a split
  903. screen is active. See also: global variable SplitScrnActive.
  904.  
  905.  
  906.  
  907. SplitScrnScanLine WORD - Screen Scan Line the Split Screen
  908. starts at  initially when set by function x_set_splitscrn. The
  909. value is only valid if a split screen is active. See also:
  910. global variable SplitScrnActive. This variable is not updated by
  911. x_hide_splitscrn or x_adjust_splitscrn.
  912.  
  913.  
  914.  
  915. SplitScrnVisibleHeight WORD - The number of rows of the initial
  916. split screen which are currently displayed. Modified by
  917. x_hide_splitscrn, x_adjust_splitscrn and x_show_splitscrn.
  918.  
  919.  
  920.  
  921. Page0_Offs WORD - Offset in video ram of main virtual screen.
  922. Initially set by function x_set_mode but is updated by functions
  923. x_set_splitscrn and x_set_doublebuffer.
  924.  
  925.  
  926.  
  927. Page1_Offs WORD - Offset in video ram of second virtual screen.
  928. Set by and only is valid after a call to x_set_doublebuffer  or
  929. x_triple_buffer.
  930.  
  931.  
  932.  
  933. Page2_Offs WORD - Offset in video ram of the third virtual
  934. screen. Set by and is only valid after a call to x_triple_buffer.
  935.  
  936.  
  937.  
  938. WaitingPageOffs WORD - Offset in video ram of the page waiting
  939. to be invisible. Initially set by x_triple_buffer but is updated
  940. by x_page_flip. This variable is only used while triple
  941. buffering is active.
  942.  
  943.  
  944.  
  945. HiddenPageOffs WORD - Offset of hidden page. Initially set by
  946. function x_set_doublebuffer but is updated by x_page_flip. This
  947. variable  is only used while double (or triple ) buffering is on.
  948.  
  949.  
  950.  
  951. VisiblePageOffs WORD - Offset of visible page. Initially set by
  952. function  x_set_doublebuffer but is updated by x_page_flip. This
  953. variable is only used while double (or triple) buffering is on.
  954.  
  955.  
  956.  
  957. NonVisual_Offs WORD - Offset of first byte of non-visual ram,
  958. the ram that is available for bitmap storage etc. Set initially
  959. by function x_set_mode but is updated by functions
  960. x_set_splitscrn and x_set_doublebuffer.
  961.  
  962.  
  963.  
  964. VisiblePageIdx WORD - Index number of current visible page.
  965. Initially set by function x_set_doublebuffer but is updated by
  966. x_page_flip. This variable is only used while double( or triple)
  967. buffering is on.
  968.  
  969.  
  970.  
  971. DoubleBufferActive WORD - Indicates whether double-buffering is
  972. on. Set by function x_set_doublebuffer.
  973.  
  974.  
  975.  
  976. TripleBufferActive WORD - Indicates whether triple-buffering is
  977. active. Set by function x_triple_buffer.
  978.  
  979.  
  980.  
  981. TopClip, BottomClip, LeftClip RightClip WORD - Defines the
  982. clipping rectangle for linear and Video clipped bitmap put
  983. functions. Set either manually or by x_set_cliprect. 
  984.  
  985. Note: X coordinates are in bytes as all clip functions clip to
  986. byte boundaries.
  987.  
  988.  
  989.  
  990. PhysicalStartPixelX WORD - X pixel Offset of physical (visible)
  991. screen relative to the upper left hand corner (0,0) of the
  992. virtual screen.
  993.  
  994.  
  995.  
  996. PhysicalStartByteX WORD - X byte Offset of physical (visible)
  997. screen relative to the upper left hand corner (0,0) of the
  998. virtual screen.
  999.  
  1000.  
  1001.  
  1002. PhysicalStartY  WORD - Y pixel Offset of physical (visible)
  1003. screen relative to the upper left hand corner (0,0) of the
  1004. virtual screen.
  1005.  
  1006.  
  1007.  
  1008. StartAddressFlag WORD - This flag is set if there is a new start
  1009. address waiting to be set by the vsync handler.
  1010.  
  1011.  
  1012.  
  1013. WaitingStartLow, WaitingStartHigh, WaitingPelPan WORD - These
  1014. are used by the vsync handler only. Do not modify!
  1015.  
  1016.  
  1017.  
  1018. VsyncPaletteCount WORD - The start index of the video DAC
  1019. register to be updated during the next vsync.  Set by the
  1020. palette functions.
  1021.  
  1022.  
  1023.  
  1024. VsyncPaletteCount WORD - The number of palette entries to be
  1025. outed during the next vsync. Set by the palette functions.
  1026.  
  1027.  
  1028.  
  1029. VsyncPaletteBuffer BYTE[768] - A buffer containing values for
  1030. the next update of the DAC. EXPORTED FUNCTIONS
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036. x_set_mode
  1037.  
  1038. C Prototype:  extern WORD x_set_mode(WORD mode, WORD
  1039. WidthInPixels);
  1040.  
  1041.  
  1042.  
  1043. mode - The required mode as defined by the "Available X Mode
  1044. resolutions" set of defines in the xlib.h header file.     
  1045.  
  1046.  
  1047.  
  1048. WidthInPixels - The required virtual screen width.     
  1049.  
  1050.  
  1051.  
  1052. Returns: The actual width in pixels of the allocated virtual
  1053. screen
  1054.  
  1055.  
  1056.  
  1057. This function initializes the graphics system, setting the
  1058. appropriate screen resolution and allocating a virtual screen.
  1059. The virtual screen allocated may not necessarily be of the same
  1060. size as specified in the WidthInPixels parameter as it is
  1061. rounded down to the nearest multiple of 4.
  1062.  
  1063.  
  1064.  
  1065. The function returns the actual width of the allocated virtual
  1066. screen  in pixels if a valid mode was selected otherwise returns
  1067.  X_MODE_INVALID.
  1068.  
  1069.  
  1070.  
  1071. Saves virtual screen pixel width in ScrnLogicalPixelWidth. Saves
  1072. virtual screen byte width in ScrnLogicalByteWidth. Physical
  1073. screen dimensions are set in ScrnPhysicalPixelWidth. 
  1074. ScrnPhysicalByteWidth and ScrnPhysicalHeight. Other global
  1075. variables set are CurrXMode, MaxScrollX, MaxScrollY, InGraphics.
  1076. The variable SplitScrnScanLine is also initialized  to zero.
  1077.  
  1078.  
  1079.  
  1080. See also: "Available X Mode resolutions." and "What is Mode X?"
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086. x_select_default_plane
  1087.  
  1088. C Prototype:  void x_select_default_plane(BYTE plane);
  1089.  
  1090.  
  1091.  
  1092. plane - The plane number you wish to work with.
  1093.  
  1094.  
  1095.  
  1096. Enables default Read/Write access to a specified plane
  1097.  
  1098.  
  1099.  
  1100. x_set_splitscreen
  1101.  
  1102. C Prototype:  extern void x_set_splitscreen(WORD line);
  1103.  
  1104.  
  1105.  
  1106. line - The starting scan line of the required split screen.
  1107.  
  1108.  
  1109.  
  1110. This function activates Mode X split screen and sets starting
  1111. scan  line. The split screen resides on the bottom half of the
  1112. screen and has a starting address of A000:0000 in video RAM.
  1113.  
  1114.  
  1115.  
  1116. It also updates Page0_Offs to reflect the existence of the split
  1117. screen region MainScrnOffset is set to the offset of the first
  1118. pixel beyond the split screen region. Other variable set are
  1119. Page1_Offs which is set to the same value as Page0_Offs (See
  1120. call sequence below), ScrnLogicalHeight, ScrnPhysicalHeight,
  1121. SplitScrnScanLine and MaxScrollY.
  1122.  
  1123.  
  1124.  
  1125. This function cannot be called after double buffering has been
  1126. activated, it will return an error. To configure your graphics
  1127. environment the sequence of graphics calls is as follows
  1128. although either or both steps b and c may be omitted:    
  1129.  
  1130.     a) x_set_mode    
  1131.  
  1132.     b) x_set_splitscreen    
  1133.  
  1134.     c) x_set_doublebuffer  
  1135.  
  1136. Thus when you call this function successfully, double buffering
  1137. is not active so Page1_Offs is set to the same address as
  1138. Page0_Offs.
  1139.  
  1140.  
  1141.  
  1142. WARNING: If you use one of the high resolution modes (376x564 as
  1143. an extreme example) you may not have enough video ram for split
  1144. screen and double buffering options since VGA video RAM is
  1145. restricted to 64K.
  1146.  
  1147.  
  1148.  
  1149. See Also: "What is a Split Screen?" and "What is double
  1150. buffering?" x_set_doublebuffer
  1151.  
  1152. C Prototype: extern WORD x_set_doublebuffer(WORD PageHeight);
  1153.  
  1154.  
  1155.  
  1156. PageHeight - The height of the two double buffering virtual
  1157. screens.  
  1158.  
  1159.  
  1160.  
  1161. Returns: The closest possible height to the requested page
  1162. height.
  1163.  
  1164.  
  1165.  
  1166. This function sets up two double buffering virtual pages.
  1167. ErrorValue is set according to the success or failure of this
  1168. command.
  1169.  
  1170.  
  1171.  
  1172. Other variables set are:
  1173.  
  1174.     Page1_Offs - Offset of second virtual page    
  1175.  
  1176.  
  1177.  
  1178.     NonVisual_Offs - Offset of first non visible video ram byte    
  1179.  
  1180.  
  1181.  
  1182.     DoubleBufferActive - Flag    
  1183.  
  1184.  
  1185.  
  1186.     PageAddrTable - Table of Double buffering pages start offsets  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.     ScrnLogicalHeight - Logical height of the double buffering
  1192. pages    
  1193.  
  1194.  
  1195.  
  1196.     MaxScrollY - Max. vertical start address of physical screen
  1197. within the virtual screen
  1198.  
  1199.  
  1200.  
  1201. WARNING: If you use one of the high resolution modes (376x564 as
  1202. an extreme example) you may not have enough video ram for split
  1203. screen and double buffering options since VGA video RAM is
  1204. restricted to 64K.
  1205.  
  1206.  
  1207.  
  1208. See Also: "What is double buffering?" 
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214. x_triple_buffer
  1215.  
  1216. C Prototype: void x_triple_buffer( WORD PageHeight );
  1217.  
  1218.  
  1219.  
  1220. PageHeight - The desired height of the virtual screen.
  1221.  
  1222.  
  1223.  
  1224. This function behaves like x_double_buffer but when used with
  1225. x_install_vsync_handler you can draw immediately after a page
  1226. flip.  When x_page_flip is called, VisiblePageOffs is set to the
  1227. page that will be displayed during the next vysnc.  Until then,
  1228. WaitingPageOffs will be displayed. You can draw to
  1229. HiddenPageOffs.
  1230.  
  1231.  
  1232.  
  1233. See also: "What is triple buffering?" 
  1234.  
  1235.  
  1236.  
  1237. x_hide_splitscreen
  1238.  
  1239. C Prototype: extern void x_hide_splitscreen(void);
  1240.  
  1241.  
  1242.  
  1243. This function hides an existing split screen by setting its
  1244. starting scan line to the last physical screen scan line.
  1245. ScreenPhysicalHeight is adjusted but the SplitScreenScanLine is
  1246. not altered as it is required for restoring the split screen at
  1247. a later stage.
  1248.  
  1249.  
  1250.  
  1251. WARNING: Only to be used if SplitScrnLine has been previously
  1252. called
  1253.  
  1254.  
  1255.  
  1256. Disabled for modes 5-11 (320x400-376x564). The memory for the
  1257. initial split screen is reserved and the size limitations of
  1258. these modes means any change in the split screen scan line will
  1259. encroach on the split screen ram 
  1260.  
  1261.  
  1262.  
  1263. See Also: "What is a split screen?" x_show_splitscreen
  1264.  
  1265. C Prototype: extern void x_show_splitscreen(void);
  1266.  
  1267.  
  1268.  
  1269. Restores split screen start scan line to the initial split
  1270. screen starting scan line as set by SplitScrnScanLine. 
  1271. ScreenPhysicalHeight is adjusted.
  1272.  
  1273.  
  1274.  
  1275. WARNING:  Only to be used if SplitScrnLine has been previously
  1276. called.
  1277.  
  1278.  
  1279.  
  1280. Disabled for modes 5-11 (320x400-376x564). The memory for the
  1281. initial split screen is reserved and the size limitations of
  1282. these modes means any change in the split screen scan line will
  1283. encroach on the split screen ram
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289. x_adjust_splitscreen
  1290.  
  1291. C Prototype: extern void x_adjust_splitscreen(WORD line);
  1292.  
  1293.  
  1294.  
  1295. line - The scan line at which the split screen is to start.
  1296.  
  1297.  
  1298.  
  1299. Sets the split screen start scan line to a new scan line. Valid
  1300. scan lines are between the initial split screen starting scan
  1301. line and the last physical screen scan line.
  1302. ScreenPhysicalHeight is also adjusted.
  1303.  
  1304.  
  1305.  
  1306. WARNING: Only to be used if SplitScrnLine has been previously
  1307. called.
  1308.  
  1309.  
  1310.  
  1311. Disabled for modes 5-11 (320x400-376x564). The memory for the
  1312. initial split screen is reserved and the size limitations of
  1313. these modes means any change in the split screen scan line will
  1314. encroach on the split screen ram
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320. x_set_start_addr
  1321.  
  1322. C Prototype: extern void x_set_start_addr(WORD X,WORD Y);
  1323.  
  1324.  
  1325.  
  1326. X, Y - coordinates of top left corner of physical screen within
  1327. current virtual screen.
  1328.  
  1329.  
  1330.  
  1331. Set Mode X non split screen physical start address within
  1332. current virtual  page. 
  1333.  
  1334.  
  1335.  
  1336. WARNING: X must not exceed (Logical screen width - Physical
  1337. screen width)  i.e. MaxScrollX, and Y must not exceed (Logical
  1338. screen height -  Physical screen height) i.e. MaxScrollY.
  1339.  
  1340.  
  1341.  
  1342. x_page_flip
  1343.  
  1344. C Prototype: extern void x_page_flip(WORD X,WORD Y);
  1345.  
  1346.  
  1347.  
  1348. X,Y - coordinates of top left corner of physical screen within
  1349. the hidden virtual screen if double buffering is active, or the
  1350. current virtual screen otherwise.
  1351.  
  1352.  
  1353.  
  1354. Sets the physical screen start address within currently hidden
  1355. virtual page and then flips pages. If double buffering is not
  1356. active then this function is functionally equivalent to
  1357. x_set_start_addr.
  1358.  
  1359.  
  1360.  
  1361. WARNING: X must not exceed (Logical screen width - Physical
  1362. screen width)  i.e. MaxScrollX, and Y must not exceed (Logical
  1363. screen height -  Physical screen height) i.e. MaxScrollY.
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369. x_text_mode
  1370.  
  1371. C Prototype: extern void x_text_mode(void);
  1372.  
  1373.  
  1374.  
  1375. Disables graphics mode.
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381. x_set_cliprect
  1382.  
  1383. C Prototype: extern void x_set_cliprect(WORD left,WORD top,WORD
  1384. right, WORD bottom);
  1385.  
  1386.  
  1387.  
  1388. left, top - X and Y coordinates of the upper left corner of the
  1389. clipping area.
  1390.  
  1391.  
  1392.  
  1393. right, bottom - X and Y coordinates of the lower right corner of
  1394. the clipping area.
  1395.  
  1396.  
  1397.  
  1398. Defines the clipping rectangle for clipping versions of planar
  1399. and video bitmap puts.
  1400.  
  1401.  
  1402.  
  1403. NOTE: Compiled bitmaps cannot be clipped.
  1404.  
  1405. MODULE XPOINT
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411. Point functions all MODE X 256 Color resolutions
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417. SOURCES
  1418.  
  1419.     xpoint.asm 
  1420.  
  1421.     xpoint.inc 
  1422.  
  1423.     xlib.inc 
  1424.  
  1425.     model.inc
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431. C HEADER FILE
  1432.  
  1433.     xpoint.h
  1434.  
  1435.  
  1436.  
  1437. EXPORTED FUNCTIONS
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443. x_put_pix
  1444.  
  1445. C Prototype: extern void x_put_pix(WORD X,WORD Y,WORD
  1446. PageOffset, WORD Color);
  1447.  
  1448.  
  1449.  
  1450. X, Y  - Coordinates to draw the pixel at.
  1451.  
  1452.  
  1453.  
  1454. PageOffset - Virtual page offset to draw on.
  1455.  
  1456.  
  1457.  
  1458. Color - The color to use.
  1459.  
  1460.  
  1461.  
  1462. Draw a point of specified color.
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468. x_get_pix
  1469.  
  1470. C Prototype: extern WORD x_get_pix(WORD X, WORD Y, WORD
  1471. PageBase);
  1472.  
  1473.  
  1474.  
  1475. X, Y  - Coordinates of  the pixel to get.
  1476.  
  1477.  
  1478.  
  1479. PageOffset - Virtual page offset the pixel is located on.
  1480.  
  1481.  
  1482.  
  1483. Returns: The color value of the pixel.
  1484.  
  1485.  
  1486.  
  1487. Read a pixel from the given coordinates within the given virtual
  1488. page.
  1489.  
  1490. MODULE XRECT
  1491.  
  1492.  
  1493.  
  1494. Screen rectangle display and manipulation functions
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500. SOURCES
  1501.  
  1502.     xrect.asm 
  1503.  
  1504.     xrect.inc 
  1505.  
  1506.     xlib.inc 
  1507.  
  1508.     model.inc
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514. C HEADER FILE
  1515.  
  1516.     xrect.h
  1517.  
  1518.  
  1519.  
  1520. EXPORTED FUNCTIONS
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526. x_rect_pattern
  1527.  
  1528. C Prototype: extern void x_rect_pattern(WORD StartX, WORD
  1529. StartY, WORD EndX, 
  1530.  
  1531.                               WORD EndY, WORD PageBase,BYTE far *Pattern);
  1532.  
  1533.  
  1534.  
  1535. StartX, StartY - Coordinates of upper left hand corner of the
  1536. rectangle.  
  1537.  
  1538.  
  1539.  
  1540. EndX, EndY  - Coordinates of lower right hand corner of  the
  1541. rectangle.  
  1542.  
  1543.  
  1544.  
  1545. PageBase  - Offset of the virtual screen.  
  1546.  
  1547.  
  1548.  
  1549. Pattern - Pointer to the user defined pattern (16 bytes). 
  1550.  
  1551.  
  1552.  
  1553. Mode X rectangle 4x4 pattern fill routine.
  1554.  
  1555.  
  1556.  
  1557. Upper left corner of pattern is always aligned to a multiple of
  1558. 4 row and column. Works on all VGAs. Uses approach of copying
  1559. the pattern to off-screen display memory, then loading the
  1560. latches with the pattern for each scan line and filling each
  1561. scan line four pixels at a time. Fills up to but not including
  1562. the column at EndX and the row at EndY. No clipping is performed.
  1563.  
  1564.  
  1565.  
  1566. WARNING: The VGA memory locations PATTERN_BUFFER (A000:FFFc) to
  1567. A000:FFFF are reserved for the pattern buffer
  1568.  
  1569.  
  1570.  
  1571. See Also: Doctor Dobbs Journal references. x_rect_pattern_clipped
  1572.  
  1573. C Prototype: extern void x_rect_pattern_clipped(WORD StartX,
  1574. WORD StartY, WORD EndX, 
  1575.  
  1576.                                          WORD EndY, WORD PageBase,
  1577.  
  1578.                                 BYTE far *Pattern);
  1579.  
  1580.  
  1581.  
  1582. StartX, StartY - Coordinates of upper left hand corner of the
  1583. rectangle.  
  1584.  
  1585.  
  1586.  
  1587. EndX, EndY  - Coordinates of lower right hand corner of  the
  1588. rectangle.  
  1589.  
  1590.  
  1591.  
  1592. PageBase  - Offset of the virtual screen.  
  1593.  
  1594.  
  1595.  
  1596. Pattern - Pointer to the user defined pattern (16 bytes). 
  1597.  
  1598.  
  1599.  
  1600. Mode X rectangle 4x4 pattern fill routine.
  1601.  
  1602.  
  1603.  
  1604. Upper left corner of pattern is always aligned to a multiple of
  1605. 4 row and column. Works on all VGAs. Uses approach of copying
  1606. the pattern to off-screen display memory, then loading the
  1607. latches with the pattern for each scan line and filling each
  1608. scan line four pixels at a time. Fills up to but not including
  1609. the column at EndX and the row at EndY. Clipping is performed.
  1610.  
  1611.  
  1612.  
  1613. WARNING: The VGA memory locations PATTERN_BUFFER (A000:FFFc) to
  1614. A000:FFFF are reserved for the pattern buffer
  1615.  
  1616.  
  1617.  
  1618. See Also: Doctor Dobbs Journal references.
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624. x_rect_fill
  1625.  
  1626. C Prototype: extern void x_rect_fill(WORD StartX, WORD StartY,
  1627. WORD EndX,
  1628.  
  1629.                            WORD EndY,  WORD PageBase, WORD color);
  1630.  
  1631.  
  1632.  
  1633. StartX, StartY - Coordinates of upper left hand corner of the
  1634. rectangle.
  1635.  
  1636.  
  1637.  
  1638. EndX, EndY - Coordinates of lower right hand corner of the
  1639. rectangle.  
  1640.  
  1641.  
  1642.  
  1643. PageBase - Offset of  the virtual screen.
  1644.  
  1645.  
  1646.  
  1647. Color -color to use for fill
  1648.  
  1649.  
  1650.  
  1651. Mode X rectangle solid color fill routine.  
  1652.  
  1653.  
  1654.  
  1655. Based on code originally published in DDJ Magazine by M. Abrash
  1656.  
  1657.  
  1658.  
  1659. See Also: Doctor Dobbs Journal references. x_rect_fill_clipped
  1660.  
  1661. C Prototype: extern void x_rect_fill_clipped(WORD StartX, WORD
  1662. StartY, WORD EndX,
  1663.  
  1664.                                    WORD EndY,  WORD PageBase, WORD color);
  1665.  
  1666.  
  1667.  
  1668. StartX, StartY - Coordinates of upper left hand corner of the
  1669. rectangle.
  1670.  
  1671.  
  1672.  
  1673. EndX, EndY - Coordinates of lower right hand corner of the
  1674. rectangle.  
  1675.  
  1676.  
  1677.  
  1678. PageBase - Offset of  the virtual screen.
  1679.  
  1680.  
  1681.  
  1682. Color - The color to use for fill.
  1683.  
  1684.  
  1685.  
  1686. Mode X rectangle solid color fill (With clipping) routine.
  1687.  
  1688.  
  1689.  
  1690. Based on code originally published in DDJ Magazine by M. Abrash
  1691.  
  1692.  
  1693.  
  1694. See Also: Doctor Dobbs Journal references.
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700. x_cp_vid_rect 
  1701.  
  1702. C Prototype: extern void x_cp_vid_rect(WORD SourceStartX, WORD
  1703. SourceStartY, 
  1704.  
  1705.                          WORD SourceEndX, WORD SourceEndY,
  1706.  
  1707.                                 WORD DestStartX, WORD DestStartY,
  1708.  
  1709.                                         WORD SourcePageBase, WORD
  1710. DestPageBase, 
  1711.  
  1712.                                         WORD SourceBitmapWidth, WORD
  1713. DestBitmapWidth);
  1714.  
  1715.  
  1716.  
  1717. StartX, StartY- Coordinates of  the upper left hand corner of
  1718. the source rectangle.
  1719.  
  1720.  
  1721.  
  1722. EndX, EndY - Coordinates of  the lower right hand corner of the
  1723. source rectangle.
  1724.  
  1725.  
  1726.  
  1727. DestStartX, DestStartY - Coordinates of the rectangle's
  1728. destination.
  1729.  
  1730.  
  1731.  
  1732. SourcePageBase  - Source rectangle page offset.  
  1733.  
  1734.  
  1735.  
  1736. DestPageBase - Destination rectangle's page offset.
  1737.  
  1738.  
  1739.  
  1740. SourceBitmapWidth - The width of bitmap within the source
  1741. virtual screen containing the source rectangle  
  1742.  
  1743.  
  1744.  
  1745. DestBitmapWidth  - The width of bitmap within the dest. virtual
  1746. screen containing the destination rectangle
  1747.  
  1748.  
  1749.  
  1750. Mode X display memory to display memory copy routine. Left edge
  1751. of source rectangle modulo 4 must equal left edge of destination
  1752. rectangle modulo 4. Works on all VGAs. Uses approach of reading
  1753. 4 pixels at a time from the source into the latches, then
  1754. writing the latches to the destination. Copies up to but not
  1755. including the column at SrcEndX and the row at SrcEndY. 
  1756.  
  1757. No clipping is performed. Results are not guaranteed if the
  1758. source and  destination overlap.
  1759.  
  1760.  
  1761.  
  1762. Based on code originally published in DDJ Magazine by M. Abrash
  1763.  
  1764.  
  1765.  
  1766. See Also: Doctor Dobbs Journal references. x_shift_rect
  1767.  
  1768. C Prototype:  extern void x_shift_rect (WORD SrcLeft, WORD
  1769. SrcTop, WORD SrcRight,
  1770.  
  1771.                        WORD SrcBottom, WORD DestLeft, WORD DestTop,
  1772.  
  1773.                        WORD ScreenOffs);
  1774.  
  1775.  
  1776.  
  1777. SrcLeft, SrcTop - Coordinates of the upper left hand corner of
  1778. the rectangle.
  1779.  
  1780.  
  1781.  
  1782. SrcRight, SrcBottom - Coordinates of the lower right hand corner
  1783. of the rectangle.
  1784.  
  1785.  
  1786.  
  1787. DestLeft, DestTop - Coordinates of the upper left corner of the
  1788. destination.  
  1789.  
  1790.  
  1791.  
  1792. ScreenOffs  -  Offset of the virtual screen.
  1793.  
  1794.  
  1795.  
  1796. This function copies a rectangle of VRAM onto another area of 
  1797. VRAM,  even if the destination overlaps with the source. It is
  1798. designed for scrolling text up and down, and for moving large
  1799. areas of screens around in tiling systems.  It rounds all
  1800. horizontal coordinates to the nearest byte (4-column chunk) for
  1801. the sake of speed. This means that it can NOT perform smooth
  1802. horizontal scrolling. For that, either scroll the whole screen
  1803. (minus the split screen), or copy smaller areas through system
  1804. memory using the functions in the XPBITMAP module.
  1805.  
  1806.  
  1807.  
  1808. SrcRight is rounded up, and the left edges are rounded down, to
  1809. ensure that the pixels pointed to by the arguments are inside
  1810. the rectangle. That is, SrcRight is treated as (SrcRight+3) >>
  1811. 2,  and SrcLeft as SrcLeft >> 2.
  1812.  
  1813.  
  1814.  
  1815. NOTE: The width of the rectangle in bytes (width in pixels / 4) 
  1816. cannot exceed 255. MODULE XPAL
  1817.  
  1818.  
  1819.  
  1820. Palette functions for VGA 256 color modes.
  1821.  
  1822.  
  1823.  
  1824. All the functions in this module operate on two variations of
  1825. the palette buffer, the raw and annotated buffers.
  1826.  
  1827.  
  1828.  
  1829. All those functions ending in "raw" operate on the following
  1830. palette structure: BYTE:r0,g0,b0,r1,g1,b1,...rn,gn,bn   No
  1831. reference to the starting color index or number of colors stored
  1832.  is contained in the structure.
  1833.  
  1834.  
  1835.  
  1836. All those functions ending in "struc" operate on the following
  1837. palette structure:
  1838.  
  1839. BYTE:c,BYTE:n,BYTE:r0,g0,b0,r1,g1,b1,...rn,gn,bn  where c is the
  1840. starting color and n is the number of colors stored
  1841.  
  1842.  
  1843.  
  1844. WARNING: There is no validity checking in these functions. The
  1845. onus is on the user to supply valid parameters to the functions.
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851. SOURCES
  1852.  
  1853.     xpal.asm 
  1854.  
  1855.     xpal.inc 
  1856.  
  1857.     xlib.inc 
  1858.  
  1859.     model.inc
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865. C HEADER FILE
  1866.  
  1867.     xpal.h
  1868.  
  1869.  
  1870.  
  1871. EXPORTED FUNCTIONS
  1872.  
  1873.  
  1874.  
  1875. x_get_pal_raw 
  1876.  
  1877. C Prototype: extern void x_get_pal_raw(BYTE far * pal,WORD
  1878. num_clrs, WORD index);
  1879.  
  1880.  
  1881.  
  1882. pal - Pointer to a buffer to receive the raw palette.
  1883.  
  1884.  
  1885.  
  1886. num_clrs - The number of colors to get.
  1887.  
  1888.  
  1889.  
  1890. index - Starting color number to get.
  1891.  
  1892.  
  1893.  
  1894. Read DAC palette into raw buffer with interrupts disabled  i.e.
  1895. BYTE r1,g1,b1,r1,g2,b2...rn,gn,bn
  1896.  
  1897.  
  1898.  
  1899. WARNING: Memory for the palette buffers must all be
  1900. pre-allocated.
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906. x_get_pal_struc
  1907.  
  1908. C Prototype: extern void x_get_pal_struc(BYTE far *pal, WORD
  1909. num_clrs, WORD index);
  1910.  
  1911.  
  1912.  
  1913. pal - Pointer to a buffer to receive the palette structure.
  1914.  
  1915.  
  1916.  
  1917. num_clrs - The number of colors to get.
  1918.  
  1919.  
  1920.  
  1921. index - The starting color number to get.
  1922.  
  1923.  
  1924.  
  1925. Read DAC palette into annotated type buffer with interrupts
  1926. disabled  i.e. BYTE colors to skip, BYTE colors to set,
  1927. r1,g1,b1,r1,g2,b2...rn,gn,bn
  1928.  
  1929.  
  1930.  
  1931. WARNING: Memory for the palette buffers must all be
  1932. pre-allocated.
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938. x_put_pal_raw
  1939.  
  1940. C Prototype: extern void x_put_pal_raw(BYTE far *pal, WORD
  1941. num_clrs,  WORD index);
  1942.  
  1943.  
  1944.  
  1945. pal - Pointer to a buffer containing the raw palette.
  1946.  
  1947.  
  1948.  
  1949. num_clrs - The number of colors to put.
  1950.  
  1951.  
  1952.  
  1953. index - Starting color number to put.
  1954.  
  1955.  
  1956.  
  1957. Write DAC palette from raw buffer with interrupts disabled  i.e.
  1958. BYTE r1,g1,b1,r1,g2,b2...rn,gn,bn
  1959.  
  1960.  
  1961.  
  1962. x_put_pal_struc
  1963.  
  1964. C Prototype: extern void x_put_pal_struc(BYTE far * pal);
  1965.  
  1966.  
  1967.  
  1968. pal - Pointer to a buffer containing the palette structure.
  1969.  
  1970.  
  1971.  
  1972. Write DAC palette from annotated type buffer with interrupts
  1973. disabled  i.e. BYTE colors to skip, BYTE colors to set,
  1974. r1,g1,b1,r1,g2,b2...rn,gn,bn
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980. x_set_rgb 
  1981.  
  1982. C Prototype: extern x_set_rgb(BYTE color,BYTE red_c,BYTE
  1983. green_c, BYTE blue_c);
  1984.  
  1985.  
  1986.  
  1987. color - The color number to modify.
  1988.  
  1989.  
  1990.  
  1991. red_c - The red component for this color.
  1992.  
  1993.  
  1994.  
  1995. green_c - The green component for this color.
  1996.  
  1997.  
  1998.  
  1999. blue_c - The blue component for this color.
  2000.  
  2001.  
  2002.  
  2003. Set the RGB components of a VGA color
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009. x_rot_pal_struc
  2010.  
  2011. C Prototype: extern void x_rot_pal_struc(BYTE far * pal, WORD
  2012. direction);
  2013.  
  2014.  
  2015.  
  2016. pal - Pointer to the palette structure to rotate.
  2017.  
  2018.  
  2019.  
  2020. direction - The direction to rotate the palette.
  2021.  
  2022.  
  2023.  
  2024. Rotate annotated palette buffer entries. Direction 0 = backward,
  2025.  1 = forward.
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031. x_rot_pal_raw
  2032.  
  2033. C Prototype: extern x_rot_pal_raw(BYTE far * pal, WORD
  2034. direction, WORD num_colrs);
  2035.  
  2036.  
  2037.  
  2038. pal - Pointer to the raw palette buffer to rotate.
  2039.  
  2040.  
  2041.  
  2042. direction - The direction to rotate the palette.
  2043.  
  2044.  
  2045.  
  2046. num_colrs - The number of colors in the buffer.
  2047.  
  2048.  
  2049.  
  2050. Rotate a raw palette buffer. Direction 0 = backward,  1 =
  2051. forward. x_put_contrast_pal_struc
  2052.  
  2053. C Prototype: extern  void x_put_contrast_pal_struc(BYTE far *
  2054. pal, BYTE  intensity);
  2055.  
  2056.  
  2057.  
  2058. pal - A pointer to the palette structure to modify.
  2059.  
  2060.  
  2061.  
  2062. intensity - Number of units to decrement the palette.
  2063.  
  2064.  
  2065.  
  2066. Write DAC palette from annotated type buffer with specified
  2067. intensity  adjustment (i.e. palette entries are decremented
  2068. where possible by "intensity" units).
  2069.  
  2070. Designed for fading in or out a palette without using an
  2071. intermediate working palette buffer! 
  2072.  
  2073. (Slow but memory efficient ... OK for small  pal structs}
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079. x_transpose_pal_struc
  2080.  
  2081. C Prototype: extern void x_transpose_pal_struc(BYTE far * pal,
  2082. WORD StartColor);
  2083.  
  2084.  
  2085.  
  2086. pal - Pointer to the palette structure to modify.
  2087.  
  2088.  
  2089.  
  2090. StartColor - Starting color index.
  2091.  
  2092.  
  2093.  
  2094. Write DAC palette from annotated type buffer with interrupts
  2095. disabled  starting at a new palette index.
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101. x_cpcontrast_pal_struc
  2102.  
  2103. C Prototype: extern WORD x_cpcontrast_pal_struc(BYTE far
  2104. *src_pal,  BYTE far *dest_pal,
  2105.  
  2106.                              BYTE Intensity);
  2107.  
  2108.  
  2109.  
  2110. src_pal - Pointer to the source palette structure.
  2111.  
  2112.  
  2113.  
  2114. dest_pal - Pointer to the destination palette structure.
  2115.  
  2116.  
  2117.  
  2118. Intensity - Number of units to decrement the palette.
  2119.  
  2120.  
  2121.  
  2122. Copy one annotated palette buffer to another making the
  2123. intensity adjustment. Used in fading in and out fast and
  2124. smoothly. MODULE XLINE
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130. Line Drawing functions.
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136. SOURCES
  2137.  
  2138.     xline.asm 
  2139.  
  2140.     xline.inc 
  2141.  
  2142.     xlib.inc 
  2143.  
  2144.     model.inc
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150. C HEADER FILE
  2151.  
  2152.     xline.h
  2153.  
  2154.  
  2155.  
  2156. EXPORTED FUNCTIONS
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162. x_line
  2163.  
  2164. C Prototype: extern void x_line(WORD x0,WORD y0,WORD x1,WORD y1, 
  2165.  
  2166.                      WORD color,WORD PageBase);
  2167.  
  2168.  
  2169.  
  2170. x0 - Starting X coordinate.
  2171.  
  2172.  
  2173.  
  2174. y0 - Starting Y coordinate.
  2175.  
  2176.  
  2177.  
  2178. x1 - Ending X coordinate
  2179.  
  2180.  
  2181.  
  2182. y1 - Ending Y coordinate.
  2183.  
  2184.  
  2185.  
  2186. color - The color to use for the line.
  2187.  
  2188.  
  2189.  
  2190. PageBase - The page offset on which to draw the line.
  2191.  
  2192.  
  2193.  
  2194. Draw a line with the specified end points in the specified page.
  2195.  
  2196. No Clipping is performed. MODULE XTEXT
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202. Mode X text display functions.
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208. SOURCES
  2209.  
  2210.     xtext.asm 
  2211.  
  2212.     xtext.inc 
  2213.  
  2214.     xlib.inc 
  2215.  
  2216.     model.inc
  2217.  
  2218.     xprintf.c
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224. C HEADER FILE
  2225.  
  2226.     xtext.h
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232. MACROS
  2233.  
  2234.     FONT_8x8  0   
  2235.  
  2236.     FONT_8x15 1   
  2237.  
  2238.     FONT_USER 2
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244. EXPORTED VARIABLES
  2245.  
  2246.  
  2247.  
  2248. NOTE: All variables are read only. If you modify them the
  2249. results may be unpredictable.
  2250.  
  2251.  
  2252.  
  2253. CharHeight  BYTE - Height of current inbuilt character set.
  2254.  
  2255.  
  2256.  
  2257. CharWidth  BYTE - Width of current inbuilt character set.
  2258.  
  2259.  
  2260.  
  2261. FirstChar  BYTE - First character of current inbuilt character
  2262. set.
  2263.  
  2264.  
  2265.  
  2266. UserCharHeight  BYTE - Height of current user character set.
  2267.  
  2268.  
  2269.  
  2270. UserCharWidth  BYTE - Width of current user character set.
  2271.  
  2272.  
  2273.  
  2274. UserFirstCh  BYTE - First character of current user character
  2275. set.
  2276.  
  2277.  
  2278.  
  2279. EXPORTED FUNCTIONS
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285. x_text_init
  2286.  
  2287. C Prototype: extern WORD x_text_init( void);
  2288.  
  2289.  
  2290.  
  2291. Initializes the Mode X text driver and sets the default font
  2292. (VGA ROM 8x8)
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298. x_set_font
  2299.  
  2300. C Prototype: extern void x_set_font(WORD FontId);
  2301.  
  2302.  
  2303.  
  2304. FontId - The font number you wish to use (See below)
  2305.  
  2306.  
  2307.  
  2308. Select the working font where 0 = VGA ROM 8x8, 1 = VGA ROM 8x14 
  2309. 2 = User defined bitmapped font.
  2310.  
  2311.  
  2312.  
  2313. WARNING: A user font must be registered before setting FontID to
  2314. 2.
  2315.  
  2316.  
  2317.  
  2318. See Also:  Defines for this module.
  2319.  
  2320.  
  2321.  
  2322.  
  2323.  
  2324. x_register_userfont
  2325.  
  2326. C Prototype: extern void x_register_userfont( char far
  2327. *UserFontPtr);
  2328.  
  2329.  
  2330.  
  2331. UserFontPtr - A pointer to the user font structure.
  2332.  
  2333.  
  2334.  
  2335. Register a user font for later selection. Only one user font can
  2336. be registered at any given time. Registering a user font
  2337. deregisters the previous user font. User fonts may be at most 8
  2338. pixels wide.
  2339.  
  2340.  
  2341.  
  2342. USER FONT STRUCTURE
  2343.  
  2344.     Word:  ASCII code of first char in font  
  2345.  
  2346.     Byte:  Height of chars in font  
  2347.  
  2348.     Byte:  Width of chars in font  
  2349.  
  2350.     n*h*Byte: the font data where n = number of chars and h =
  2351. height of chars
  2352.  
  2353.  
  2354.  
  2355. WARNING: The onus is on the program to ensure that all
  2356. characters drawn whilst this font is active, are within the
  2357. range of characters defined.
  2358.  
  2359.  
  2360.  
  2361. x_char_put
  2362.  
  2363. C Prototype: extern void x_char_put(char ch,WORD X,WORD Y,WORD
  2364. PgOffs,  
  2365.  
  2366.                      WORD Color);
  2367.  
  2368.  
  2369.  
  2370. ch -  Char to draw  
  2371.  
  2372.  
  2373.  
  2374. x, y - Screen coordinates at which to draw ch  
  2375.  
  2376.  
  2377.  
  2378. ScrnOffs - Starting offset of page on which to draw  
  2379.  
  2380.  
  2381.  
  2382. Color  - Color of the text
  2383.  
  2384.  
  2385.  
  2386. Draw a text character at the specified location with the
  2387. specified color.
  2388.  
  2389.  
  2390.  
  2391. WARNING: InitTextDriver must be called before using this function
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397. x_printf 
  2398.  
  2399. C Prototype: void x_printf(int x, int y, unsigned ScrnOffs, int
  2400. color, char *ln,...);
  2401.  
  2402.  
  2403.  
  2404. x, y -  screen coordinates at which to draw ch  
  2405.  
  2406.  
  2407.  
  2408. ScrnOffs -  Starting offset of page on which to draw  
  2409.  
  2410.  
  2411.  
  2412. Color    -  Color of the text
  2413.  
  2414.  
  2415.  
  2416. ln - A pointer to a text string containing formating codes.
  2417.  
  2418.  
  2419.  
  2420. Parameters beyond Color conform to the standard printf
  2421. parameters.
  2422.  
  2423.  
  2424.  
  2425. Display formated text in the specified color. 
  2426.  
  2427.  
  2428.  
  2429. x_bgprintf
  2430.  
  2431. C Prototype: void x_bgprintf(int x, int y, unsigned ScrnOffs,
  2432. int fgcolor, int bgcolor, char *ln,...);
  2433.  
  2434.  
  2435.  
  2436. x, y -  Screen coordinates at which to draw ch.  
  2437.  
  2438.  
  2439.  
  2440. ScrnOffs -  Page offset on which to draw.  
  2441.  
  2442.  
  2443.  
  2444. fgcolor -  Color of the text foreground.  
  2445.  
  2446.  
  2447.  
  2448. bgcolor  -  Color of the text background.
  2449.  
  2450.  
  2451.  
  2452. ln - Pointer to a text string that contains formating commands
  2453. that conform to the printf commands.
  2454.  
  2455.  
  2456.  
  2457. Parameters beyond bgcolor conform to the standard printf
  2458. parameters.
  2459.  
  2460.  
  2461.  
  2462. Display formatted text in the specified foreground and
  2463. background colors.
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469. x_get_char_width
  2470.  
  2471. C Prototype: unsigned int x_get_char_width(char ch)
  2472.  
  2473.  
  2474.  
  2475. ch - Character to get the width of.
  2476.  
  2477.  
  2478.  
  2479. Returns: The width the requested character. MODULE XPBITMAP
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485. This module implements a set of functions to operate on planar
  2486. bitmaps.  Planar bitmaps as used by these functions have the
  2487. following structure:
  2488.  
  2489.  
  2490.  
  2491.     BYTE 0                     The bitmap width in bytes (4 pixel
  2492. groups) range 1..255  
  2493.  
  2494.     BYTE 1                     The bitmap height in rows range 1..255  
  2495.  
  2496.     BYTE 2..n1                 The plane 0 pixels width*height bytes  
  2497.  
  2498.     BYTE n1..n2        The plane 1 pixels width*height bytes  
  2499.  
  2500.     BYTE n2..n3                The plane 2 pixels width*height bytes  
  2501.  
  2502.     BYTE n3..n4                The plane 3 pixels width*height bytes
  2503.  
  2504.  
  2505.  
  2506. These functions provide the fastest possible bitmap blts from
  2507. system ram to video and further, the single bitmap is applicable
  2508. to all pixel alignments. The masked functions do not need
  2509. separate masks since all non zero pixels are considered to be
  2510. masking pixels,  hence if a pixel is 0 the  corresponding screen
  2511. destination pixel is left unchanged.
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517. SOURCES
  2518.  
  2519.     xpbitmap.asm 
  2520.  
  2521.     xpbitmap.inc 
  2522.  
  2523.     xlib.inc 
  2524.  
  2525.     model.inc
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531. C HEADER FILE
  2532.  
  2533.     xpbitmap.h
  2534.  
  2535.  
  2536.  
  2537. EXPORTED FUNCTIONS
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543. x_put_masked_pbm
  2544.  
  2545. C Prototype: extern void x_put_masked_pbm(WORD X, WORD Y, WORD
  2546. ScrnOffs, 
  2547.  
  2548.                            BYTE far * Bitmap);
  2549.  
  2550.  
  2551.  
  2552. x, y - Coordinates for the upper left corner of the bitmap.
  2553.  
  2554.  
  2555.  
  2556. ScrnOffs - Page offset to place the bitmap at.
  2557.  
  2558.  
  2559.  
  2560. Bitmap - Pointer to the planar bitmap structure.
  2561.  
  2562.  
  2563.  
  2564. Mask write a planar bitmap from system ram to video ram. All
  2565. zero source bitmap bytes indicate destination byte to be left
  2566. unchanged.
  2567.  
  2568.  
  2569.  
  2570. NOTE: Width is in bytes i.e. lots of 4 pixels
  2571.  
  2572.  
  2573.  
  2574. LIMITATIONS: No clipping is supported. Only supports bitmaps
  2575. with widths which are a multiple of  4 pixels
  2576.  
  2577.  
  2578.  
  2579. See Also: XBMTOOLS module for linear <-> planar bitmap
  2580. conversion functions.
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586. x_put_pbm
  2587.  
  2588. C Prototype: extern void x_put_pbm(WORD X, WORD Y, WORD
  2589. ScrnOffs, 
  2590.  
  2591.                      BYTE far *Bitmap);
  2592.  
  2593.  
  2594.  
  2595. x, y - Coordinates for the upper left corner of the bitmap.
  2596.  
  2597.  
  2598.  
  2599. ScrnOffs - Page offset to place the bitmap at.
  2600.  
  2601.  
  2602.  
  2603. Bitmap - Pointer to the planar bitmap structure.
  2604.  
  2605.  
  2606.  
  2607. Write a planar bitmap from system ram to video ram.
  2608.  
  2609.  
  2610.  
  2611. NOTE: Width is in bytes i.e. lots of 4 pixels
  2612.  
  2613.  
  2614.  
  2615. LIMITATIONS: No clipping is supported Only supports bitmaps with
  2616. widths which are a multiple of  4 pixels
  2617.  
  2618.  
  2619.  
  2620. See Also: XBMTOOLS module for linear <-> planar bitmap
  2621. conversion functions.
  2622.  
  2623. x_get_pbm
  2624.  
  2625. C Prototype: extern void x_get_pbm(WORD X, WORD Y,BYTE Bw,BYTE
  2626. Bh, 
  2627.  
  2628.                      WORD ScrnOffs, BYTE far * Bitmap);
  2629.  
  2630.  
  2631.  
  2632. X, Y - Coordinates of the upper left  corner of the bitmap.
  2633.  
  2634.  
  2635.  
  2636. Bw - Width of the bitmap to get.
  2637.  
  2638.  
  2639.  
  2640. Bh - Height of the bitmap to get.
  2641.  
  2642.  
  2643.  
  2644. ScrnOffs - Page offset to get the bitmap from.
  2645.  
  2646.  
  2647.  
  2648. Bitmap - Pointer to a buffer allocated for receiveing this
  2649. bitmap.
  2650.  
  2651.  
  2652.  
  2653. Read a planar bitmap to system ram from video ram.
  2654.  
  2655.  
  2656.  
  2657. NOTE: Width is in bytes in lots of 4 pixels
  2658.  
  2659.  
  2660.  
  2661. LIMITATIONS: No clipping is supported. Only supports bitmaps
  2662. with widths which are a multiple of 4 pixels
  2663.  
  2664.  
  2665.  
  2666. See Also: XBMTOOLS module for linear <-> planar bitmap
  2667. conversion functions. MODULE XPBMCLIP
  2668.  
  2669.  
  2670.  
  2671. This module implements a similar set of functions to operate on
  2672. planar bitmaps as XPBITMAP but incorporates clipping to a user
  2673. defined clipping rectangle (which is set by x_set_cliprect in
  2674. module XMAIN).
  2675.  
  2676.  
  2677.  
  2678. The planar bitmap format is identical to the above module
  2679.  
  2680.  
  2681.  
  2682. There are three variations of the functions in XPBITMAP in this
  2683. module identified by the three function name extensions: _clipx,
  2684. _clipy _clipxy.  Because speed is critical in games programming
  2685. you do not want to be checking for clipping if not necessary
  2686. thus for sprites that move only  horizontally you would use the
  2687. _clipx version of the put function, for sprites that move
  2688. vertically you would use the _clipy version and for sprites that
  2689. move both directions you would use the clipxy version. Keep in
  2690. mind also that the clipping components of these functions assume
  2691. that the clipping rectangle is equal to or larger than the size
  2692. of the bitmap i.e.. if a bitmap is top clipped, it is assumed
  2693. that the bitmap's bottom is not also clipped. Similarly with
  2694. horizontal clipping.
  2695.  
  2696.  
  2697.  
  2698. Note: Performance in decreasing order is as follows.
  2699. _clipy,_clipx,_clipxy with masked puts being slower than
  2700. unmasked puts.
  2701.  
  2702.  
  2703.  
  2704. Horizontal clipping is performed to byte boundaries (4 pixels)
  2705. rather than  pixels. This allows for the fastest implementation
  2706. of the functions. It is not such a handicap because for one,
  2707. your screen width a multiple of 4 pixels wide and for most
  2708. purposes it is the screen edges that form the  clipping
  2709. rectangle.
  2710.  
  2711.  
  2712.  
  2713. Following is an example of setting a clipping rectangle to the
  2714. logical  screen edges:
  2715.  
  2716.     x_set_cliprect(0,0,ScrnLogicalByteWidth,ScrnLogicalHeight)
  2717.  
  2718.  
  2719.  
  2720. NOTE: The functions now return a value; 1 if clipped image is
  2721. fully clipped (i.e. no portion of it      appears on the screen)
  2722. otherwise it returns 0
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728. SOURCES
  2729.  
  2730.     xpbmclip.asm 
  2731.  
  2732.     xpbmclip.inc 
  2733.  
  2734.     xlib.inc 
  2735.  
  2736.     model.inc
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742. C HEADER FILE
  2743.  
  2744.     xpbmclip.h
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.    EXPORTED FUNCTIONS
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756. x_put_masked_pbm_clipx
  2757.  
  2758. C Prototype: extern void x_put_masked_pbm_clipx(WORD X, WORD Y,
  2759. WORD ScrnOffs, 
  2760.  
  2761.                                 BYTE far * Bitmap);
  2762.  
  2763.  
  2764.  
  2765. x, y - Coordinates for the upper left corner of the bitmap.
  2766.  
  2767.  
  2768.  
  2769. ScrnOffs - Page offset to place the bitmap at.
  2770.  
  2771.  
  2772.  
  2773. Bitmap - A far pointer to the planar bitmap structure.
  2774.  
  2775.  
  2776.  
  2777. Mask write a planar bitmap from system ram to video ram.
  2778. Horizontal clipping is performed. All zero source bitmap bytes
  2779. indicate destination byte to be left unchanged.
  2780.  
  2781.  
  2782.  
  2783. NOTE: Width is in bytes i.e. lots of 4 pixels
  2784.  
  2785.  
  2786.  
  2787. LIMITATIONS: Only supports bitmaps with widths which are a
  2788. multiple of  4 pixels
  2789.  
  2790.  
  2791.  
  2792. See Also: XBMTOOLS module for linear <-> planar bitmap
  2793. conversion functions.
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799. x_put_masked_pbm_clipy
  2800.  
  2801. C Prototype: extern void x_put_masked_pbm_clipy(WORD X, WORD Y,
  2802. WORD ScrnOffs, 
  2803.  
  2804.                                 BYTE far * Bitmap);
  2805.  
  2806.  
  2807.  
  2808. x, y - Coordinates for the upper left corner of the bitmap.
  2809.  
  2810.  
  2811.  
  2812. ScrnOffs - Page offset to place the bitmap at.
  2813.  
  2814.  
  2815.  
  2816. Bitmap - A far pointer to the planar bitmap structure.
  2817.  
  2818.  
  2819.  
  2820. Mask write a planar bitmap from system ram to video ram.
  2821. Vertical clipping is performed. All zero source bitmap bytes
  2822. indicate destination byte to be left unchanged.
  2823.  
  2824.  
  2825.  
  2826. NOTE: Width is in bytes i.e. lots of 4 pixels
  2827.  
  2828.  
  2829.  
  2830. LIMITATIONS: Only supports bitmaps with widths which are a
  2831. multiple of  4 pixels
  2832.  
  2833.  
  2834.  
  2835. See Also: XBMTOOLS module for linear <-> planar bitmap
  2836. conversion functions.
  2837.  
  2838.  
  2839.  
  2840. x_put_masked_pbm_clipxy
  2841.  
  2842. C Prototype: extern void x_put_masked_pbm_clipxy(WORD X, WORD Y,
  2843. WORD ScrnOffs, 
  2844.  
  2845.                                  BYTE far * Bitmap);
  2846.  
  2847.  
  2848.  
  2849. x, y - Coordinates for the upper left corner of the bitmap.
  2850.  
  2851.  
  2852.  
  2853. ScrnOffs - Page offset to place the bitmap at.
  2854.  
  2855.  
  2856.  
  2857. Bitmap - A far pointer to the planar bitmap structure.
  2858.  
  2859.  
  2860.  
  2861. Mask write a planar bitmap from system ram to video ram. Both
  2862. horizontal and vertical clipping is performed. All zero source
  2863. bitmap bytes indicate destination byte to be left unchanged.
  2864.  
  2865.  
  2866.  
  2867. NOTE: Width is in bytes i.e. lots of 4 pixels
  2868.  
  2869.  
  2870.  
  2871. LIMITATIONS: Only supports bitmaps with widths which are a
  2872. multiple of  4 pixels
  2873.  
  2874.  
  2875.  
  2876. See Also: XBMTOOLS module for linear <-> planar bitmap
  2877. conversion functions.
  2878.  
  2879.  
  2880.  
  2881.  
  2882.  
  2883. x_put_pbm_clipx
  2884.  
  2885. C Prototype: extern void x_put_pbm_clipx(WORD X, WORD Y, WORD
  2886. ScrnOffs, 
  2887.  
  2888.                               BYTE far *Bitmap);
  2889.  
  2890.  
  2891.  
  2892. x, y - Coordinates for the upper left corner of the bitmap.
  2893.  
  2894.  
  2895.  
  2896. ScrnOffs - Page offset to place the bitmap at.
  2897.  
  2898.  
  2899.  
  2900. Bitmap - A far pointer to the planar bitmap structure.
  2901.  
  2902.  
  2903.  
  2904. Write a planar bitmap from system ram to video ram. Horizontal
  2905. clipping is performed.
  2906.  
  2907.  
  2908.  
  2909. NOTE: Width is in bytes i.e. lots of 4 pixels
  2910.  
  2911.  
  2912.  
  2913. LIMITATIONS: Only supports bitmaps with widths which are a
  2914. multiple of  4 pixels
  2915.  
  2916.  
  2917.  
  2918. See Also: XBMTOOLS module for linear <-> planar bitmap
  2919. conversion functions.
  2920.  
  2921. x_put_pbm_clipy
  2922.  
  2923. C Prototype: extern void x_put_pbm_clipy(WORD X, WORD Y, WORD
  2924. ScrnOffs, 
  2925.  
  2926.                               BYTE far *Bitmap);
  2927.  
  2928.  
  2929.  
  2930. x, y - Coordinates for the upper left corner of the bitmap.
  2931.  
  2932.  
  2933.  
  2934. ScrnOffs - Page offset to place the bitmap at.
  2935.  
  2936.  
  2937.  
  2938. Bitmap - A far pointer to the planar bitmap structure.
  2939.  
  2940.  
  2941.  
  2942. Write a planar bitmap from system ram to video ram. Vertical
  2943. clipping is performed.
  2944.  
  2945.  
  2946.  
  2947. NOTE: Width is in bytes i.e. lots of 4 pixels
  2948.  
  2949.  
  2950.  
  2951. LIMITATIONS: Only supports bitmaps with widths which are a
  2952. multiple of  4 pixels
  2953.  
  2954.  
  2955.  
  2956. See Also: XBMTOOLS module for linear <-> planar bitmap
  2957. conversion functions.
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963. x_put_pbm_clipxy
  2964.  
  2965. C Prototype: extern void x_put_pbm_clipxy(WORD X, WORD Y, WORD
  2966. ScrnOffs, 
  2967.  
  2968.                                 BYTE far *Bitmap);
  2969.  
  2970.  
  2971.  
  2972. x, y - Coordinates for the upper left corner of the bitmap.
  2973.  
  2974.  
  2975.  
  2976. ScrnOffs - Page offset to place the bitmap at.
  2977.  
  2978.  
  2979.  
  2980. Bitmap - A far pointer to the planar bitmap structure.
  2981.  
  2982.  
  2983.  
  2984. Write a planar bitmap from system ram to video ram. Both
  2985. horizontal and vertical clipping is performed.
  2986.  
  2987.  
  2988.  
  2989. NOTE: Width is in bytes i.e. lots of 4 pixels
  2990.  
  2991.  
  2992.  
  2993. LIMITATIONS: Only supports bitmaps with widths which are a
  2994. multiple of  4 pixels
  2995.  
  2996.  
  2997.  
  2998. See Also: XBMTOOLS module for linear <-> planar bitmap
  2999. conversion functions.
  3000.  
  3001. MODULE  XCBITMAP
  3002.  
  3003.  
  3004.  
  3005.  
  3006.  
  3007. Compiled bitmap functions. See "The care and feeding of compiled
  3008. masked blits." in the reference section for more details on
  3009. compiled bitmaps.
  3010.  
  3011.  
  3012.  
  3013.  
  3014.  
  3015. SOURCES
  3016.  
  3017.     xcbitmap.asm
  3018.  
  3019.     xcbitmap.inc
  3020.  
  3021.  
  3022.  
  3023.  
  3024.  
  3025. C HEADER FILE
  3026.  
  3027.     xcbitmap.h EXPORTED FUNCTIONS
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033. x_compile_bitmap
  3034.  
  3035. C Prototype:  int x_compile_bitmap( WORD lsw, char far *bitmap,
  3036. char far *output );
  3037.  
  3038.  
  3039.  
  3040. lsw - The logical screen width in bytes.
  3041.  
  3042.  
  3043.  
  3044. bitmap - A pointer to the source linear bitmap.
  3045.  
  3046.  
  3047.  
  3048. output - A pointer to a buffer set up to receive the compiled
  3049. bitmap.
  3050.  
  3051.  
  3052.  
  3053. Returns: The size of the compiled bitmap in bytes.
  3054.  
  3055.  
  3056.  
  3057. Compiles a linear bitmap to generate machine code to plot it at
  3058. any required screen coordinates FAST!
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064. x_sizeof_cbitmap
  3065.  
  3066. C Prototype:  int x_sizeof_cbitmap( WORD lsw, char far *bitmap );
  3067.  
  3068.  
  3069.  
  3070. lsw - The logical screen width in bytes.
  3071.  
  3072.  
  3073.  
  3074. bitmap - A pointer to the source linear bitmap.
  3075.  
  3076.  
  3077.  
  3078. Returns:  The space in bytes required to hold the compiled
  3079. bitmap.
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085. x_put_cbitmap
  3086.  
  3087. C Prototype:  void x_put_cbitmap( int X, int Y, unsigned int
  3088. PageOffset, char far *bitmap);
  3089.  
  3090.  
  3091.  
  3092. X, Y - The coordinates at which to place the compiled bitmaps.
  3093.  
  3094.  
  3095.  
  3096. PageOffset - The page offset on which to draw the bitmap.
  3097.  
  3098.  
  3099.  
  3100. bitmap - A pointer to the compiled bitmap.
  3101.  
  3102.  
  3103.  
  3104. Displays a bitmap generated by x_compile_bitmap.
  3105.  
  3106.  
  3107.  
  3108.  
  3109.  
  3110.  
  3111.  
  3112. MODULE XCOMPPBM
  3113.  
  3114.  
  3115.  
  3116.  
  3117.  
  3118. Identical to XCBITMAP except that the source bitmaps are the PBM
  3119. form rather than LBM.
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125. SOURCES
  3126.  
  3127.     xcompbm.asm
  3128.  
  3129.     xcompbm.inc
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135. C HEADER FILE
  3136.  
  3137.     xcompbm.h EXPORTED FUNCTIONS
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143. x_compile_pbm
  3144.  
  3145. C Prototype:  x_compile_pbm( WORD lsw, char far *bitmap, char
  3146. far *output );
  3147.  
  3148.  
  3149.  
  3150. lsw - The logical screen width in bytes.
  3151.  
  3152.  
  3153.  
  3154. bitmap - A pointer to the source planar bitmap.
  3155.  
  3156.  
  3157.  
  3158. output - A far pointer to a buffer set up to receive the
  3159. compiled bitmap.
  3160.  
  3161.  
  3162.  
  3163. Returns: The size of the compiled bitmap in bytes.
  3164.  
  3165.  
  3166.  
  3167. Compiles a planar bitmap to generate machine code to plot it at
  3168. any required screen coordinates FAST!
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174. x_sizeof_cpbm
  3175.  
  3176. C Prototype:  int x_sizeof_cpbm( WORD lsw, char far *bitmap );
  3177.  
  3178.  
  3179.  
  3180. lsw - The logical screen width in bytes.
  3181.  
  3182.  
  3183.  
  3184. bitmap - A far pointer to the source planar bitmap.
  3185.  
  3186.  
  3187.  
  3188. Returns:  The space in bytes required to hold the compiled
  3189. bitmap.
  3190.  
  3191.  
  3192.  
  3193. MODULE XVBITMAP
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199. The XVBITMAP module implements yet another type of bitmap to
  3200. complement planar and compiled bitmaps, VRAM based bitmaps. If a
  3201. 4 cylinder car is analogous to planar bitmaps, that is thrifty
  3202. on memory consumption but low performance and a V8 is analogous
  3203. to Compiled bitmaps, memory guzzlers that really fly, then VRAM
  3204. based bitmaps are the 6 cylinder modest performers with
  3205. acceptable memory consumption.
  3206.  
  3207.  
  3208.  
  3209. To summarize their selling points, VBM's are moderately fast
  3210. with fair memory consumption, and unlike compiled bitmaps, can
  3211. be clipped. The disadvantages are that they are limited by the
  3212. amount of free video ram and have a complex structure.
  3213.  
  3214.  
  3215.  
  3216. The VRAM bitmap format is rather complex consisting of
  3217. components stored in video ram and components in system ram
  3218. working together. This complexity necessitates the existence of
  3219. a creation function x_make_vbm which takes an input linear
  3220. bitmap and generates the equivalent VBM (VRAM Bit Map).
  3221.  
  3222.  
  3223.  
  3224. VBM structure:
  3225.  
  3226.           WORD  0   Size          Total size of this VBM structure
  3227. in bytes      
  3228.  
  3229.           WORD  1   ImageWidth    Width in bytes of the image (for
  3230. all alignments)      
  3231.  
  3232.           WORD  2   ImageHeight   Height in scan lines of the image
  3233.  
  3234.           WORD  3   Alignment 0  ImagePtr  Offset in VidRAM of this
  3235. aligned image  
  3236.  
  3237.           WORD  4               MaskPtr   Offset (within this structure's
  3238. DS) of alignment masks
  3239.  
  3240.     WORD  9   Alignment 3  ImagePtr  Offset in VidRAM of this
  3241. aligned image  
  3242.  
  3243.     WORD 10               MaskPtr   Offset (within this structure's DS)
  3244. of alignment masks
  3245.  
  3246.     BYTE   21 (WORD 11)  
  3247.  
  3248.                     Image masks for alignment 0 
  3249.  
  3250.     BYTE  21 + ImageWidth*ImageHeight       
  3251.  
  3252.                     (similarly for alignments 1 - 2 )
  3253.  
  3254.     BYTE  21 + 3*ImageWidth*ImageHeight + 1 
  3255.  
  3256.                     Image masks for alignment 3
  3257.  
  3258.     BYTE  21 + 4*(ImageWidth*ImageHeight)  
  3259.  
  3260.                     Similarly for alignments 2 and 3
  3261.  
  3262.     BYTE 21 + 4*(ImageWidth*ImageHeight)
  3263.  
  3264.                     (And don't forget the corresponding data in video ram)
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270. You can see for yourself the complexity of this bitmap format.
  3271. The image is stored in video ram in its 4 different alignments
  3272. with pointers to these alignments in the VBM. Similarly there
  3273. are 4 alignments of the corresponding masks within the VBM
  3274. itself (towards the end). The mask bytes contain the plane
  3275. settings for the corresponding video bytes so that one memory
  3276. move can move up to 4 pixels at a time (depending on the mask
  3277. settings) using the VGA's latches, theoretically giving you a 4x
  3278. speed improvement over conventional blits like the ones
  3279. implemented in "XPBITMAP". In actual fact its anywhere between 2
  3280. and 3 due to incurred overheads.  These bitmaps are more difficult to store in files than PBM'S
  3281. and CBM's but still possible with a bit of work, so do not
  3282. dismiss these as too difficult to use. Consider all the bitmap
  3283. formats carefully before deciding on which to use. There may
  3284. even be situations that a careful application of all three types
  3285. would be most effective i.e.. compiled bitmaps for Background
  3286. tiles and the main game character (which never need clipping),
  3287. VRAM based bitmaps for the most frequently occurring (opponent,
  3288. alien etc.) characters which get clipped as they come into and
  3289. leave your current location and planar bitmaps for smaller or
  3290. less frequently encountered characters.
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296. SOURCES
  3297.  
  3298.     xvbitmap.asm 
  3299.  
  3300.     xvbitmap.inc 
  3301.  
  3302.     xlib.inc model.inc    
  3303.  
  3304.     xmakevbm.c  
  3305.  
  3306.  
  3307.  
  3308.  
  3309.  
  3310. C HEADER FILE
  3311.  
  3312.     xvbitmap.h
  3313.  
  3314.  
  3315.  
  3316. EXPORTED FUNCTIONS
  3317.  
  3318.  
  3319.  
  3320.  
  3321.  
  3322. x_make_vbm
  3323.  
  3324. C Prototype: extern char far * x_make_vbm( char far *lbm, WORD
  3325. *VramStart);
  3326.  
  3327.  
  3328.  
  3329. lbm - A far pointer to the input linear bitmap   
  3330.  
  3331.  
  3332.  
  3333. VramStart - Pointer to variable containing Offset of first free
  3334. VRAM byte
  3335.  
  3336.  
  3337.  
  3338. Create the VBM from the given linear bitmap and place the image
  3339. alignments  in video ram starting at the offset in the variable
  3340. pointed to by VramStart. VramStart is then updated to point to
  3341. the next free VRAM byte (just after the last byte of the image
  3342. alignments). Usually you will point VramStart to NonVisual_Offs.
  3343.  
  3344.  
  3345.  
  3346.  
  3347.  
  3348. x_put_masked_vbm 
  3349.  
  3350. C Prototype: extern int x_put_masked_vbm( int X, int Y, WORD
  3351. ScrnOffs, 
  3352.  
  3353.                          BYTE far *VBitmap);
  3354.  
  3355.  
  3356.  
  3357. X, Y - Coordinates to draw the bitmap at.
  3358.  
  3359.  
  3360.  
  3361. ScrnOffs - The page offset to draw the bitmap at.
  3362.  
  3363.  
  3364.  
  3365. VBitmap - A far pointer to the video bitmap.
  3366.  
  3367.  
  3368.  
  3369. Returns: 1 if clipped image is fully clipped (i.e. no portion of
  3370. it appears on the screen) otherwise it returns 0. (Editors note:
  3371. since this function doesn't support clipping the return value
  3372. should be 0 at all times.)
  3373.  
  3374.  
  3375.  
  3376. Draw a VRAM based bitmap at (X,Y) relative to the screen with
  3377. starting  offset ScrnOffs.
  3378.  
  3379. x_put_masked_vbm_clipx
  3380.  
  3381. C Prototype: extern int x_put_masked_vbm_clipx(int X, int Y,
  3382. WORD ScrnOffs, 
  3383.  
  3384.                                   BYTE far *VBitmap);
  3385.  
  3386.  
  3387.  
  3388. X, Y - Coordinates to draw the bitmap at.
  3389.  
  3390.  
  3391.  
  3392. ScrnOffs - The page offset to draw the bitmap at.
  3393.  
  3394.  
  3395.  
  3396. VBitmap - A far pointer to the video bitmap.
  3397.  
  3398.  
  3399.  
  3400. Returns: 1 if clipped image is fully clipped otherwise it
  3401. returns 0.
  3402.  
  3403.  
  3404.  
  3405. Draw a VRAM based bitmap at (X,Y) relative to the screen with
  3406. starting  offset ScrnOffs. Horizontal clipping is performed.
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412. x_put_masked_vbm_clipy
  3413.  
  3414. C Prototype: extern int x_put_masked_vbm_clipy( int X, int Y,
  3415. WORD ScrnOffs, 
  3416.  
  3417.                                   BYTE far *VBitmap);
  3418.  
  3419.  
  3420.  
  3421. X, Y - Coordinates to draw the bitmap at.
  3422.  
  3423.  
  3424.  
  3425. ScrnOffs - The page offset to draw the bitmap at.
  3426.  
  3427.  
  3428.  
  3429. VBitmap - A far pointer to the video bitmap.
  3430.  
  3431.  
  3432.  
  3433. Returns: 1 if clipped image is fully clipped (i.e. no portion of
  3434. it appears on the screen) otherwise it returns 0
  3435.  
  3436.  
  3437.  
  3438. Draw a VRAM based bitmap at (X,Y) relative to the screen with
  3439. starting offset ScrnOffs.
  3440.  
  3441. Vertical clipping is performed.
  3442.  
  3443. x_put_masked_vbm_clipxy
  3444.  
  3445. C Prototype: extern int x_put_masked_vbm_clipxy( int X, int Y,
  3446. WORD ScrnOffs, 
  3447.  
  3448.                                     BYTE far *VBitmap);
  3449.  
  3450.  
  3451.  
  3452. X, Y - Coordinates to draw the bitmap at.
  3453.  
  3454.  
  3455.  
  3456. ScrnOffs - The page offset to draw the bitmap at.
  3457.  
  3458.  
  3459.  
  3460. VBitmap - A far pointer to the video bitmap.
  3461.  
  3462.  
  3463.  
  3464. Returns: 1 if clipped image is fully clipped (i.e. no portion of
  3465. it appears on the screen) otherwise it returns 0
  3466.  
  3467.  
  3468.  
  3469. Draw a VRAM based bitmap at (X,Y) relative to the screen with
  3470. starting  offset ScrnOffs.
  3471.  
  3472. Both horizontal and vertical clipping is performed.
  3473.  
  3474.  
  3475.  
  3476.  
  3477.  
  3478. See XPBMCLIP for more details on the type of clipping used as it
  3479. is identical to XVBITMAP. MODULE  XMOUSE
  3480.  
  3481.  
  3482.  
  3483. The XMOUSE module implements very basic mouse handling
  3484. functions. The way in which it operates is by installing an
  3485. event handler function during initialization which subsequently
  3486. intercepts and processes mouse events and automatically updates
  3487. status variables such as mouse position and button pressed
  3488. status. 
  3489.  
  3490.  
  3491.  
  3492. It does not support the full functionality of:
  3493.  
  3494.     SPLIT SCREENS,  SCROLLED WINDOWS, or   VIRTUAL WINDOWS
  3495.  
  3496. This was done to primarily prevent unnecessary impedences to
  3497. performance, since the mouse handler function has the potential
  3498. to degrade performance. It also saves me a lot of coding which I
  3499. was too lazy to do.
  3500.  
  3501.  
  3502.  
  3503. Programs communicate with the mouse driver as with other
  3504. devices, through an interrupt vector namely 33h. On generating
  3505. an interrupt, the mouse driver expects a function number in AX
  3506. and possibly other parameters in other registers and returns
  3507. information via the registers. A brief description of the mouse
  3508. functions follows:
  3509.  
  3510.  
  3511.  
  3512. MS Mouse Driver Functions
  3513.  
  3514. Mouse Initialization                     0
  3515.  
  3516. Show Cursor                                  1
  3517.  
  3518. Hide Cursor                                  2
  3519.  
  3520. Get Mouse Position & Button Status  3
  3521.  
  3522. Set Mouse Cursor Position                4
  3523.  
  3524. Get Button Press Information             5
  3525.  
  3526. Get Button Release Information           6
  3527.  
  3528. Set Min/Max Horizontal Position          7
  3529.  
  3530. Set Min/Max Vertical Position            8
  3531.  
  3532. Define Graphics Cursor Block             9
  3533.  
  3534. Define Text Cursor                      10
  3535.  
  3536. Read Mouse Motion Counters              11
  3537.  
  3538. Define Event Handler                    12
  3539.  
  3540. Light Pen Emulation Mode ON             13
  3541.  
  3542. Light Pen Emulation Mode OFF            14
  3543.  
  3544. Set Mouse Mickey/Pixel Ratio            15
  3545.  
  3546. Conditional Hide Cursor                 16
  3547.  
  3548. Set Double-Speed Threshold              19
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554. In practice only a few of these functions are used and even
  3555. fewer when the mouse status is monitored by an event handler
  3556. function such as is used in this module. The most important thing to note when using the mouse module is
  3557. that the mouse event handler must be removed before exiting the
  3558. program. It is a good idea to have an exit function (see the C
  3559. atexit function) and include the line x_mouse_remove(); along
  3560. with any other pre-exit cleanup code.
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566. SOURCES
  3567.  
  3568.     xmouse.asm 
  3569.  
  3570.     xlib.inc 
  3571.  
  3572.     model.inc
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578. C HEADER FILE
  3579.  
  3580.     xmouse.h
  3581.  
  3582.  
  3583.  
  3584.  
  3585.  
  3586. EXPORTED VARIABLES
  3587.  
  3588.  
  3589.  
  3590. MouseInstalled  WORD - Indicates whether mouse handler installed
  3591.   
  3592.  
  3593.  
  3594.  
  3595. MouseHidden  WORD - Indicates whether mouse cursor is hidden 
  3596.  
  3597.  
  3598.  
  3599. MouseButtonStatus WORD - Holds the mouse button status   
  3600.  
  3601.  
  3602.  
  3603. MouseX  WORD - Current X position of mouse cursor   
  3604.  
  3605.  
  3606.  
  3607. MouseY  WORD - Current Y position of mouse cursor   
  3608.  
  3609.  
  3610.  
  3611. MouseFrozen  WORD - Disallows position updates if TRUE   
  3612.  
  3613.  
  3614.  
  3615. MouseColor  BYTE - The mouse cursors color
  3616.  
  3617.  
  3618.  
  3619. EXPORTED FUNCTIONS
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625. x_mouse_init
  3626.  
  3627. C Prototype:  int x_mouse_init()
  3628.  
  3629.  
  3630.  
  3631. Initialize the mouse driver functions and install the mouse
  3632. event handler function. This is the first function you must call
  3633. before using any of the mouse functions. This mouse code uses
  3634. the fastest possible techniques to save and restore mouse
  3635. backgrounds and to draw the mouse cursor.
  3636.  
  3637.  
  3638.  
  3639. WARNING: This function uses and updates NonVisual_Offset to
  3640. allocate video ram for the saved mouse background.
  3641.  
  3642.  
  3643.  
  3644. LIMITATIONS: No clipping is supported horizontally for the mouse
  3645. cursor. No validity checking is performed for NonVisual_Offs
  3646.  
  3647.  
  3648.  
  3649. **WARNING**  You must Hide or at least Freeze the mouse cursor
  3650. while drawing using any of the other XLIB modules since the
  3651. mouse handler may modify VGA register settings at any time. VGA
  3652. register settings are not preserved which will result in
  3653. unpredictable drawing behavior. If you know the drawing will
  3654. occur away from the mouse cursor set MouseFrozen to TRUE (1), do
  3655. your drawing then set it to FALSE (0). Alternatively call
  3656. x_hide_mouse,  perform your drawing and then call x_show_mouse.
  3657. Another alternative is to disable interrupts while drawing but
  3658. usually drawing takes up a lot of time and having interrupts
  3659. disabled for too long is not a good
  3660.  
  3661. idea.
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667. x_define_mouse_cursor
  3668.  
  3669. C Prototype:    void x_define_mouse_cursor( char far *MouseDef,
  3670. unsigned char MouseColor)
  3671.  
  3672.  
  3673.  
  3674. MouseDef - A far pointer to 14 characters containing a bitmask
  3675. for all the cursor's rows.
  3676.  
  3677.  
  3678.  
  3679. MouseColor - The color to use when drawing the mouse cursor.
  3680.  
  3681.  
  3682.  
  3683. Define a mouse cursor shape for use in subsequent cursor
  3684. redraws. XMOUSE has a hardwired mouse cursor size of 8 pixels
  3685. across by 14 pixels down.
  3686.  
  3687.  
  3688.  
  3689. WARNING: This function assumes MouseDef points to 14 bytes.
  3690.  
  3691.  
  3692.  
  3693. Note: Bit order is in reverse. i.e. bit 7 represents pixel 0,
  3694. bit 0 represents pixel 7 in each byte of MouseDef .
  3695.  
  3696.  
  3697.  
  3698. x_show_mouse
  3699.  
  3700. C Prototype:  void x_show_mouse();
  3701.  
  3702.  
  3703.  
  3704. Makes the cursor visible if it was previously hidden.  
  3705.  
  3706.  
  3707.  
  3708. See Also: x_hide_mouse.
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714. x_hide_mouse 
  3715.  
  3716. C Prototype:  void x_hide_mouse();
  3717.  
  3718.  
  3719.  
  3720. Makes the cursor hidden if it was previously visible.  
  3721.  
  3722.  
  3723.  
  3724. See Also: x_show_mouse.
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730. x_mouse_remove 
  3731.  
  3732. C Prototype:  void x_mouse_remove();
  3733.  
  3734.  
  3735.  
  3736. Stop mouse event handling and remove the mouse handler.
  3737.  
  3738.  
  3739.  
  3740. NOTE: This function MUST be called before quitting the program
  3741. if a mouse handler has been installed
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747. x_position_mouse
  3748.  
  3749. C Prototype:  void x_position_mouse( int x, int y);
  3750.  
  3751.  
  3752.  
  3753. x, y - Coordinates to move the mouse cursor to.
  3754.  
  3755.  
  3756.  
  3757. Positions the mouse cursor at the specified location
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763. x_mouse_window
  3764.  
  3765. C Prototype:  void x_mouse_window( int x0, int y0, int x1, int
  3766. y1);
  3767.  
  3768.  
  3769.  
  3770. x0, y0 - Coordinates of the upper left corner of the window.
  3771.  
  3772.  
  3773.  
  3774. x1, y1 - Coordinates of the lower right corner of the window.
  3775.  
  3776.  
  3777.  
  3778. Defines a mouse window.  The mouse cursor is unable to move from
  3779. this window. x_update_mouse
  3780.  
  3781. C Prototype:  void x_update_mouse();
  3782.  
  3783.  
  3784.  
  3785. Forces the mouse position to be updated and cursor to be
  3786. redrawn.  
  3787.  
  3788.  
  3789.  
  3790. Note: This function is useful when you have set MouseFrozen to
  3791. true.  
  3792.  
  3793. Allows the cursor position to be updated manually rather than
  3794. automatically by the installed handler. MODULE XBMTOOLS
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800. This module implements a set of functions to convert between
  3801. planar bitmaps and linear bitmaps.
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807. PLANAR BITMAPS
  3808.  
  3809.  
  3810.  
  3811. Planar bitmaps as used by these functions have the following
  3812. structure:
  3813.  
  3814.     BYTE 0                The bitmap width in bytes (4 pixel groups)
  3815. range 1..255  
  3816.  
  3817.     BYTE 1                      The bitmap height in rows range 1..255
  3818.  
  3819.  
  3820.     BYTE 2..n1                 The plane 0 pixels width*height bytes  
  3821.  
  3822.     BYTE n1..n2               The plane 1 pixels width*height bytes  
  3823.  
  3824.     BYTE n2..n3               The plane 2 pixels width*height bytes  
  3825.  
  3826.     BYTE n3..n4               The plane 3 pixels width*height bytes
  3827.  
  3828. as used by x_put_pbm, x_get_pbm, x_put_masked_pbm.
  3829.  
  3830.  
  3831.  
  3832.  
  3833.  
  3834. LINEAR BITMAPS
  3835.  
  3836.  
  3837.  
  3838. Linear bitmaps have the following structure:
  3839.  
  3840.     BYTE 0                     The bitmap width in pixels range 1..255
  3841.  
  3842.  
  3843.     BYTE 1                     The bitmap height in rows range 1..255  
  3844.  
  3845.     BYTE 2..n                  The width*height bytes of the bitmap
  3846.  
  3847.  
  3848.  
  3849.  
  3850.  
  3851. SOURCES
  3852.  
  3853.     xbmtools.asm 
  3854.  
  3855.     xpbmtools.inc 
  3856.  
  3857.     model.inc
  3858.  
  3859.  
  3860.  
  3861. C HEADER FILE
  3862.  
  3863.     xbmtools.h
  3864.  
  3865.  
  3866.  
  3867. MACROS
  3868.  
  3869.  
  3870.  
  3871.     BM_WIDTH_ERROR
  3872.  
  3873.  
  3874.  
  3875.     LBMHeight( lbitmap)         - Height of linear bitmap "lbitmap"
  3876.    
  3877.  
  3878.  
  3879.  
  3880.     LBMWidth( lbitmap )          - Width of linear bitmap 
  3881. "lbitmap"    
  3882.  
  3883.  
  3884.  
  3885.     PBMHeight( pbitmap )         - Height of planar bitmap
  3886. "pbitmap"    
  3887.  
  3888.  
  3889.  
  3890.     PBMWidth( pbitmap )          - Width of planar bitmap "pbitmap"
  3891.  
  3892.  
  3893.  
  3894.     LBMPutPix( x, y, lbitmap, color)  - Set the color of pixel (x,
  3895. y) color in linear bitmap
  3896.  
  3897.  
  3898.  
  3899.     LBMGetPix( x, y, lbitmap )        - Get the color of pixel (x,
  3900. y) in linear bitmap
  3901.  
  3902. EXPORT FUNCTIONS
  3903.  
  3904.  
  3905.  
  3906.  
  3907.  
  3908. x_pbm_to_bm
  3909.  
  3910. C Prototype:  extern int x_pbm_to_bm( char far * source_pbm,
  3911. char far * dest_bm);
  3912.  
  3913.  
  3914.  
  3915. source_pbm - A pointer to the source planar bitmap.
  3916.  
  3917.  
  3918.  
  3919. dest_bm - A pointer to a buffer set up to receive the linear
  3920. bitmap.
  3921.  
  3922.  
  3923.  
  3924. Returns: 0 on successful conversion.
  3925.  
  3926.  
  3927.  
  3928. This function converts a bitmap in the planar format to the
  3929. linear format as used by x_compile_bitmap.
  3930.  
  3931.  
  3932.  
  3933. WARNING: The source and destination bitmaps must be
  3934. pre-allocated.
  3935.  
  3936.  
  3937.  
  3938. NOTE: This function can only convert planar bitmaps that are
  3939. suitable. If the source planar bitmap's width (per plane) is >=
  3940. 256/4 it cannot be converted. In this situation an error code
  3941.  
  3942. BM_WIDTH_ERROR.
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948. x_bm_to_pbm 
  3949.  
  3950. C Prototype:  extern int x_bm_to_pbm( char far * source_lbm,
  3951. char far * dest_bm);
  3952.  
  3953.  
  3954.  
  3955. source_lbm  -  A pointer to the source linear bitmap.
  3956.  
  3957.  
  3958.  
  3959. dest_bm - A pointer to a buffer set up to receive the planar
  3960. bitmap.
  3961.  
  3962.  
  3963.  
  3964. Returns: 0 on successful conversion.
  3965.  
  3966.  
  3967.  
  3968. This function converts a bitmap in the linear format as used by 
  3969. x_compile_bitmap to the planar format.
  3970.  
  3971.  
  3972.  
  3973. WARNING: The source and destination bitmaps must be pre -
  3974. allocated
  3975.  
  3976.  
  3977.  
  3978. NOTE: This function can only convert linear bitmaps that are
  3979. suitable. If the source linear bitmap's width is not a multiple
  3980. of 4 it cannot be converted. In this situation an error code
  3981.  
  3982. BM_WIDTH_ERROR.  MODULE  XCLIPPBM
  3983.  
  3984.  
  3985.  
  3986.  
  3987.  
  3988. Note: VERY SIMILAR to XPBMCLIP. This module implements blits of
  3989. clipped planar bitmaps.  Blits are clipped to pixels, both
  3990. horizontally. This makes the unmasked blit function here
  3991. slightly slower than the equivalent functions in the XPBMCLIP
  3992. module.
  3993.  
  3994.  
  3995.  
  3996.  
  3997.  
  3998. SOURCES
  3999.  
  4000.     xclippbm.asm 
  4001.  
  4002.     xclippbm.inc 
  4003.  
  4004.     xlib.inc 
  4005.  
  4006.     model.inc
  4007.  
  4008.  
  4009.  
  4010.  
  4011.  
  4012. C HEADER FILE
  4013.  
  4014.     xclippbm.h
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020. EXPORTED VARIABLES
  4021.  
  4022.  
  4023.  
  4024.     TopBound - int  
  4025.  
  4026.  
  4027.  
  4028.     BottomBound - int  
  4029.  
  4030.  
  4031.  
  4032.     LeftBound - int  
  4033.  
  4034.  
  4035.  
  4036.     RightBound - int EXPORTED FUNCTIONS
  4037.  
  4038.  
  4039.  
  4040.  
  4041.  
  4042. x_clip_pbm
  4043.  
  4044. C Prototype: extern int x_clip_pbm (int X, int Y, int
  4045. ScreenOffs, char far * Bitmap);
  4046.  
  4047.  
  4048.  
  4049. X, Y - The coordinates to place the bitmap at.
  4050.  
  4051.  
  4052.  
  4053. ScreenOffset - The offset of the page on which to draw the
  4054. bitmap.
  4055.  
  4056.  
  4057.  
  4058. Bitmap - A far pointer to the planar bitmap.
  4059.  
  4060.  
  4061.  
  4062. Returns:  If the entire bitmap turns out to be outside the
  4063. bounding box, this function returns  a 1, otherwise it returns a
  4064. 0
  4065.  
  4066.  
  4067.  
  4068. Copies a planar bitmap from SRAM to VRAM, with clipping.  
  4069.  
  4070.  
  4071.  
  4072. .
  4073.  
  4074. x_clip_masked_pbm
  4075.  
  4076. C Prototype: extern int x_clip_masked_pbm (int X, int Y,  int
  4077. ScreenOffs, char far * Bitmap);
  4078.  
  4079.  
  4080.  
  4081. X, Y - The coordinates to place the bitmap at.
  4082.  
  4083.  
  4084.  
  4085. ScreenOffset - The offset of the page on which to draw the
  4086. bitmap.
  4087.  
  4088.  
  4089.  
  4090. Bitmap - A far pointer to the planar bitmap.
  4091.  
  4092.  
  4093.  
  4094. Returns:  If the entire bitmap turns out to be outside the
  4095. bounding box, this function returns a 1, otherwise it returns a 0
  4096.  
  4097.  
  4098.  
  4099. Copies a planar bitmap from SRAM to VRAM, with clipping, 0 bytes
  4100. in the bitmap are not copied.   MODULE  XCIRCLE
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106. Mode X circle functions
  4107.  
  4108.  
  4109.  
  4110. SOURCES
  4111.  
  4112.     xcircle.asm 
  4113.  
  4114.     xcircle.inc 
  4115.  
  4116.     xlib.inc 
  4117.  
  4118.     model.inc
  4119.  
  4120.  
  4121.  
  4122.  
  4123.  
  4124. C HEADER FILE
  4125.  
  4126.     xcircle.h EXPORTED FUNCTIONS
  4127.  
  4128.  
  4129.  
  4130.  
  4131.  
  4132. x_circle
  4133.  
  4134. C Prototype: extern void x_circle (WORD Left, WORD Top, WORD
  4135. Diameter, 
  4136.  
  4137.                          WORD Color, WORD ScreenOffs);
  4138.  
  4139.  
  4140.  
  4141. Left, Top - The coordinates of the upper left corner of the
  4142. circle, in pixels.
  4143.  
  4144.  
  4145.  
  4146. Diameter - The diameter of the circle.
  4147.  
  4148.  
  4149.  
  4150. Color - The color in which to draw the circle.
  4151.  
  4152.  
  4153.  
  4154. ScreenOffs - The page offset to draw the circle on.
  4155.  
  4156.  
  4157.  
  4158. Draws a circle with the given upper-left-hand corner and
  4159. diameter,  which are given in pixels.
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165. x_filled_circle
  4166.  
  4167. C Prototype: extern void x_filled_circle (WORD Left, WORD Top,
  4168. WORD Diameter, 
  4169.  
  4170.                           WORD Color, WORD ScreenOffs);
  4171.  
  4172.  
  4173.  
  4174. Left, Top - The coordinates of the upper left corner of the
  4175. circle, in pixels.
  4176.  
  4177.  
  4178.  
  4179. Diameter - The diameter of the circle.
  4180.  
  4181.  
  4182.  
  4183. Color - The color in which to draw the circle.
  4184.  
  4185.  
  4186.  
  4187. ScreenOffs - The page offset to draw the circle on.
  4188.  
  4189.  
  4190.  
  4191. Draws a filled circle with the given upper-left-hand corner and
  4192. diameter.
  4193.  
  4194. MODULE XDETECT  
  4195.  
  4196.  
  4197.  
  4198.  
  4199.  
  4200. This module implements a set of functions to detect the PC's
  4201. hardware configuration.
  4202.  
  4203.  
  4204.  
  4205.  
  4206.  
  4207. SOURCES
  4208.  
  4209.     xdetect.asm 
  4210.  
  4211.     xdetect.inc 
  4212.  
  4213.     model.inc
  4214.  
  4215.  
  4216.  
  4217.  
  4218.  
  4219. C HEADER FILE
  4220.  
  4221.     xdetect.h
  4222.  
  4223.  
  4224.  
  4225.  
  4226.  
  4227. EXPORTED MACROS
  4228.  
  4229.     I8086    0    
  4230.  
  4231.     I80186  1    
  4232.  
  4233.     I80286  2    
  4234.  
  4235.     I80386  3
  4236.  
  4237.  
  4238.  
  4239.     NoGraphics 0    
  4240.  
  4241.     MDA           1    
  4242.  
  4243.     CGA            2    
  4244.  
  4245.     EGAMono   3    
  4246.  
  4247.     EGAColor    4    
  4248.  
  4249.     VGAMono   5    
  4250.  
  4251.     VGAColor   6    
  4252.  
  4253.     MCGAMono   7    
  4254.  
  4255.     MCGAColor    8
  4256.  
  4257.  
  4258.  
  4259.     BUS_MOUSE     1    
  4260.  
  4261.     SERIAL_MOUSE  2    
  4262.  
  4263.     INPORT_MOUSE  3    
  4264.  
  4265.     PS2_MOUSE     4    
  4266.  
  4267.     HP_MOUSE      5
  4268.  
  4269.  
  4270.  
  4271. EXPORTED VARIABLES
  4272.  
  4273.  
  4274.  
  4275. MouseButtonCount  WORD - The number of buttons on the detected
  4276. mouse  
  4277.  
  4278.  
  4279.  
  4280. MouseVersion WORD - Mouse driver version
  4281.  
  4282.                 (High byte = Major version, Low byte = minor version)
  4283.  
  4284.  
  4285.  
  4286. MouseType BYTE - The mouse type  
  4287.  
  4288.  
  4289.  
  4290. MouseIRQ  BYTE - The IRQ number used by the mouse driver
  4291.  
  4292.  
  4293.  
  4294. EXPORTED FUNCTIONS
  4295.  
  4296.  
  4297.  
  4298.  
  4299.  
  4300. x_graphics_card
  4301.  
  4302. C Prototype: extern int x_graphics_card();
  4303.  
  4304.  
  4305.  
  4306. Returns: The type of graphics card installed. 
  4307.  
  4308.  
  4309.  
  4310. See the defines for this module.
  4311.  
  4312.  
  4313.  
  4314.  
  4315.  
  4316. x_processor
  4317.  
  4318. C Prototype: extern int x_processor();
  4319.  
  4320.  
  4321.  
  4322. Returns: The type of processor installed. 
  4323.  
  4324.  
  4325.  
  4326. Note: A 486 registers as a 386. 
  4327.  
  4328.  
  4329.  
  4330. See defines for this module.
  4331.  
  4332.  
  4333.  
  4334.  
  4335.  
  4336. x_coprocessor
  4337.  
  4338. C Prototype: extern int x_coprocessor();
  4339.  
  4340.  
  4341.  
  4342. Returns: 1 of a numeric co-processor is present, 0 if not. 
  4343.  
  4344.  
  4345.  
  4346. Note: The type is not detected but it's not really necessary as
  4347. the processor type usually determines the numeric coprocessor
  4348. type
  4349.  
  4350.  
  4351.  
  4352.  
  4353.  
  4354. x_mousedriver
  4355.  
  4356. C Prototype: extern int x_mousedriver();
  4357.  
  4358.  
  4359.  
  4360. Returns: 1 of a mouse driver is installed, 0 otherwise. 
  4361.  
  4362.  
  4363.  
  4364. If a mouse driver is detected the mouse related variables are
  4365. set accordingly.
  4366.  
  4367.  
  4368.  
  4369. MODULE XFILEIO
  4370.  
  4371.  
  4372.  
  4373.  
  4374.  
  4375. Handle based file I/O functions.
  4376.  
  4377. See any good DOS programming reference for more information on
  4378. int 21h DOS services.
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384. SOURCES
  4385.  
  4386.     xfileio.asm 
  4387.  
  4388.     xfileio.inc 
  4389.  
  4390.     model.inc
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396. C HEADER FILE
  4397.  
  4398.     xfileio.h
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404. EXPORTED MACROS
  4405.  
  4406.     File access modes
  4407.  
  4408.         F_RDONLY  - Read only.   
  4409.  
  4410.         F_WRONLY  - Write only.     
  4411.  
  4412.         F_RDWR - Read and write
  4413.  
  4414.  
  4415.  
  4416.     Seek codes
  4417.  
  4418.         SEEK_START - Bytes from the start of the file.
  4419.  
  4420.         SEEK_CURR - Bytes from the current position.
  4421.  
  4422.         SEEK_END - Bytes from the end of the file.
  4423.  
  4424.  
  4425.  
  4426.     File error value
  4427.  
  4428.         FILE_ERR EXPORTED FUNCTIONS
  4429.  
  4430.  
  4431.  
  4432.  
  4433.  
  4434. f_open
  4435.  
  4436. C Prototype: extern int f_open(char * filename, char access);
  4437.  
  4438.  
  4439.  
  4440. filename - A pointer to a string containing the full path and
  4441. filename you wish to open.
  4442.  
  4443.  
  4444.  
  4445. access -  A character that defines the access mode.
  4446.  
  4447.  
  4448.  
  4449. Returns: The file handle on success, FILE_ERR on failure.
  4450.  
  4451.  
  4452.  
  4453. Opens a file according to the access char.
  4454.  
  4455.  
  4456.  
  4457.  
  4458.  
  4459. f_close
  4460.  
  4461. C Prototype:  extern int f_close(int handle);
  4462.  
  4463.  
  4464.  
  4465. handle -  The handle of the file you wish to close.
  4466.  
  4467.  
  4468.  
  4469. Returns: 0 on success, FILE_ERR on failure.
  4470.  
  4471.  
  4472.  
  4473. Closes the file associated with the specified handle.
  4474.  
  4475.  
  4476.  
  4477.  
  4478.  
  4479. f_read 
  4480.  
  4481. C Prototype:  extern int f_read(int handle,char near * buffer,
  4482. int count);
  4483.  
  4484.  
  4485.  
  4486. handle - The handle of the file you wish to read from.
  4487.  
  4488.  
  4489.  
  4490. buffer - A near pointer to a buffer to receive the bytes from
  4491. the file.
  4492.  
  4493.  
  4494.  
  4495. count - The number of bytes to read from the file.
  4496.  
  4497.  
  4498.  
  4499. Returns: The number of bytes read on success, FILE_ERR on failure
  4500.  
  4501.  
  4502.  
  4503. Reads bytes from the a file into a near buffer
  4504.  
  4505.  
  4506.  
  4507. f_readfar 
  4508.  
  4509. C Prototype:  extern int f_readfar(int handle,char far * buffer,
  4510. int count);
  4511.  
  4512.  
  4513.  
  4514. handle - The handle of the file you wish to read from.
  4515.  
  4516.  
  4517.  
  4518. buffer - A far pointer to a buffer set up to receive the data.
  4519.  
  4520.  
  4521.  
  4522. count - The number of bytes to read.
  4523.  
  4524.  
  4525.  
  4526. Returns: The number of bytes read on success, FILE_ERR on failure
  4527.  
  4528.  
  4529.  
  4530. Reads a block of  bytes a file into a far buffer.
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536. f_write
  4537.  
  4538. C Prototype: extern int f_write(int handle, char near * buffer,
  4539. int count);
  4540.  
  4541.  
  4542.  
  4543. handle - The handle of the file you wish to write to.
  4544.  
  4545.  
  4546.  
  4547. buffer - A near pointer to a buffer containing the data to write.
  4548.  
  4549.  
  4550.  
  4551. count - The number of bytes to write.
  4552.  
  4553.  
  4554.  
  4555. Returns: The number of bytes written on success, FILE_ERR on
  4556. failure
  4557.  
  4558.  
  4559.  
  4560. Writes a block bytes to a file from a near buffer
  4561.  
  4562.  
  4563.  
  4564.  
  4565.  
  4566. f_writefar 
  4567.  
  4568. C Prototype: extern int f_write(int handle, char far * buffer,
  4569. int count);
  4570.  
  4571.  
  4572.  
  4573. handle - The handle of the file you wish to write to.
  4574.  
  4575.  
  4576.  
  4577. buffer - A far pointer to a buffer containing the data to write.
  4578.  
  4579.  
  4580.  
  4581. count - The number of bytes to write.
  4582.  
  4583.  
  4584.  
  4585. Returns: The number of bytes written on success, FILE_ERR on
  4586. failure
  4587.  
  4588.  
  4589.  
  4590. Writes a block of bytes to a file from a far buffer.
  4591.  
  4592.  
  4593.  
  4594.  
  4595.  
  4596.  
  4597.  
  4598.  
  4599.  
  4600. f_seek 
  4601.  
  4602. C Prototype: extern long int f_seek(int handle, long int
  4603. position,  char method_code)
  4604.  
  4605.  
  4606.  
  4607. handle - The handle of the file you are working with.
  4608.  
  4609.  
  4610.  
  4611. position - The position to move to.
  4612.  
  4613.  
  4614.  
  4615. method_code - The seek method you wish to use. (See the defines.)
  4616.  
  4617.  
  4618.  
  4619. Returns: The file pointer position on success, FILE_ERR on
  4620. failure.
  4621.  
  4622.  
  4623.  
  4624. Moves the file pointer.
  4625.  
  4626.  
  4627.  
  4628.  
  4629.  
  4630. f_filelength 
  4631.  
  4632. C Prototype: extern long int f_filelength(int handle)
  4633.  
  4634.  
  4635.  
  4636. handle - The handle of the file you are working with.
  4637.  
  4638.  
  4639.  
  4640. Returns: The length of the file on success, FILE_ERR on failure.
  4641.  
  4642.  
  4643.  
  4644.  
  4645.  
  4646. f_tell
  4647.  
  4648. C Prototype:  extern long int f_tell(int handle)
  4649.  
  4650.  
  4651.  
  4652. handle - The handle of the file you are working with.
  4653.  
  4654.  
  4655.  
  4656. Returns: The file pointer position on success, FILE_ERR on
  4657. failure MODULE XRLETOOL
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663. This module implements a number of functions comprising an RLE
  4664. encoding decoding system.
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670. SOURCES
  4671.  
  4672.     xrletool.asm 
  4673.  
  4674.     xrletool.inc 
  4675.  
  4676.     model.inc
  4677.  
  4678.  
  4679.  
  4680.  
  4681.  
  4682. C HEADER FILE
  4683.  
  4684.     xrletool.h
  4685.  
  4686.  
  4687.  
  4688. EXPORTED FUNCTIONS
  4689.  
  4690.  
  4691.  
  4692.  
  4693.  
  4694. x_buff_RLDecode
  4695.  
  4696. C prototype:  extern unsigned int x_buff_RLDecode(char far *
  4697. source_buff, char far *dest_buff);
  4698.  
  4699.  
  4700.  
  4701. source_buff   - A far pointer to the buffer to compress   
  4702.  
  4703.  
  4704.  
  4705. dest_buff   -  A far pointer to the destination buffer
  4706.  
  4707.  
  4708.  
  4709. Returns: The size of the resultant uncompressed data.
  4710.  
  4711.  
  4712.  
  4713. Expands an RLE compressed source buffer to a destination buffer. 
  4714.  
  4715.  
  4716.  
  4717. WARNING: The buffers must be pre-allocated.
  4718.  
  4719.  
  4720.  
  4721.  
  4722.  
  4723. x_buff_RLEncode
  4724.  
  4725. C prototype:  extern unsigned int x_buff_RLEncode( char far *
  4726. source_buff,  char far *dest_buff,
  4727.  
  4728.                                     unsigned int count);
  4729.  
  4730.  
  4731.  
  4732. source_buff   - A far pointer to the buffer to compress.
  4733.  
  4734.  
  4735.  
  4736. dest_buff   - A far pointer to the destination buffer.
  4737.  
  4738.  
  4739.  
  4740. count  - The size of the source data in bytes.
  4741.  
  4742.  
  4743.  
  4744. Returns: The size of the resultant compressed data.
  4745.  
  4746.  
  4747.  
  4748. RLE Compresses a source buffer to a destination buffer. 
  4749.  
  4750.  
  4751.  
  4752. WARNING: The buffers must be pre allocated.
  4753.  
  4754.  
  4755.  
  4756.  
  4757.  
  4758. x_buff_RLE_size 
  4759.  
  4760. C prototype: extern unsigned int x_buff_RLE_size( char far *
  4761. source_buff,  unsigned int count);
  4762.  
  4763.  
  4764.  
  4765. source_buff   - A far pointer to the uncompressed data buffer   
  4766.  
  4767.  
  4768.  
  4769. count  - The size of the source data in bytes
  4770.  
  4771.  
  4772.  
  4773. Returns: The size the input data would compress to.
  4774.  
  4775.  
  4776.  
  4777.  
  4778.  
  4779. x_file_RLEncode 
  4780.  
  4781. C prototype:  extern unsigned int x_file_RLEncode( int handle,
  4782. char far * source_buff,
  4783.  
  4784.                             unsigned int count);
  4785.  
  4786.  
  4787.  
  4788. source_buff   - A far pointer to the buffer to compress  
  4789.  
  4790.  
  4791.  
  4792. handle - The output file handle.
  4793.  
  4794.  
  4795.  
  4796. count  - The size of the source data in bytes
  4797.  
  4798.  
  4799.  
  4800. Returns:  The size of the resultant compressed data or 0 if it
  4801. fails.
  4802.  
  4803.  
  4804.  
  4805. RLE Compresses a source buffer to an output file. 
  4806.  
  4807.  
  4808.  
  4809.  
  4810.  
  4811. x_file_RLDecode
  4812.  
  4813. C prototype:  extern unsigned int x_buff_RLDecode( int handle, 
  4814. char far * dest_buff);
  4815.  
  4816.  
  4817.  
  4818. handle - Input file handle   
  4819.  
  4820.  
  4821.  
  4822. dest_buff  - A far pointer to the destination buffer
  4823.  
  4824.  
  4825.  
  4826. Returns: The size of the resultant uncompressed data.
  4827.  
  4828.  
  4829.  
  4830. Expands an RLE compresses file to a destination RAM buffer.   
  4831.  
  4832. MODULE XPOLYGON
  4833.  
  4834.  
  4835.  
  4836.  
  4837.  
  4838. This module implements general filled convex polygon and
  4839. triangle functions
  4840.  
  4841.  
  4842.  
  4843. SOURCES
  4844.  
  4845.     xpolygon.asm
  4846.  
  4847.     xpolygon.inc
  4848.  
  4849.  
  4850.  
  4851. C HEADER FILE
  4852.  
  4853.     xpolygon.h
  4854.  
  4855.  
  4856.  
  4857.  
  4858.  
  4859. TYPE DEFS
  4860.  
  4861.     typedef struct {    int X;    int Y;  } far VERTEX;
  4862.  
  4863.  
  4864.  
  4865. EXPORTED FUNCTIONS
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871. x_triangle
  4872.  
  4873. C Prototype:  void x_triangle( int x0, int y0, int x1, int y1,
  4874. int x2, int y2, WORD color, 
  4875.  
  4876.                 WORD PageBase);
  4877.  
  4878.  
  4879.  
  4880. x0, y0 -  The coordinates of point one of the triangle.
  4881.  
  4882.  
  4883.  
  4884. x1, y1 - The coordinates of point two of the triangle.
  4885.  
  4886.  
  4887.  
  4888. x2, y2  - The coordinates of the third (and final) point of the
  4889. triangle.
  4890.  
  4891.  
  4892.  
  4893. color - The color in which to draw the triangle in.
  4894.  
  4895.  
  4896.  
  4897. PageBase - The page offset on which to draw the triangle.
  4898.  
  4899.  
  4900.  
  4901. This function draws a filled triangle which is clipped to the
  4902. current clipping window defined by TopClip, BottomClip,
  4903. LeftClip, RightClip.  
  4904.  
  4905.  
  4906.  
  4907. Remember: The X clipping variable are in BYTES not PIXELS so you
  4908.  can only clip to 4 pixel byte boundaries.
  4909.  
  4910.  
  4911.  
  4912. x_polygon
  4913.  
  4914. C Prototype:  void x_polygon( VERTEX *vertices, int 
  4915. num_vertices, WORD color,
  4916.  
  4917.                 WORD PageBase);
  4918.  
  4919.  
  4920.  
  4921. vertices - A pointer to your vertex structure.
  4922.  
  4923.  
  4924.  
  4925. num_vertices - The number of vertices to plot.
  4926.  
  4927.  
  4928.  
  4929. color - The color in which to draw the polygon.
  4930.  
  4931.  
  4932.  
  4933. PageBase - The page offset on which to draw the polygon.
  4934.  
  4935.  
  4936.  
  4937. This function is similar to the triangle function but draws
  4938. convex polygons. The vertices are supplied in the form of a FAR 
  4939. pointer.
  4940.  
  4941.  
  4942.  
  4943. NOTE: A convex polygon is one such that if you draw a line from
  4944. any two vertices, every point on that line will be within the 
  4945. polygon.
  4946.  
  4947.  
  4948.  
  4949. This function works by splitting up a polygon into its component
  4950. triangles and calling the triangle routine above to draw each
  4951. one. Performance is respectable but a custom polygon routine
  4952. might be faster. MODULE XBEZIER
  4953.  
  4954.  
  4955.  
  4956. Bezier curve plotting function. See "What is a Bezier curve?"
  4957. for more details.
  4958.  
  4959.  
  4960.  
  4961.  
  4962.  
  4963. SOURCES
  4964.  
  4965.     xbezier.asm
  4966.  
  4967.     xlib.inc
  4968.  
  4969.  
  4970.  
  4971.  
  4972.  
  4973. C HEADER FILE
  4974.  
  4975.     xbezier.h EXPORTED FUNCTIONS
  4976.  
  4977.  
  4978.  
  4979.  
  4980.  
  4981. x_bezier
  4982.  
  4983. C Prototype: void x_bezier( int e1x, int e1y, int c1x, int c1y,
  4984. int c2x, int c2y,
  4985.  
  4986.                 int e2x, int e2y, int levels, char color, WORD PageBase);
  4987.  
  4988.  
  4989.  
  4990. e1x, e1y, e2x, e2y - The coordinates of the two endpoints.
  4991.  
  4992.  
  4993.  
  4994. c1x, c1y, c2x, c2y - The coordinates of the two control points.
  4995.  
  4996.  
  4997.  
  4998. levels - 
  4999.  
  5000.  
  5001.  
  5002. color - The color to draw with.
  5003.  
  5004.  
  5005.  
  5006. PageBase - The page offset on which to draw.
  5007.  
  5008.  
  5009.  
  5010. Plots a Bezier curve on the screen.
  5011.  
  5012.  
  5013.  
  5014. See also: "What is a Bezier curve?"
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024. MODULE XFILL
  5025.  
  5026.  
  5027.  
  5028. This module implements a couple of general purpose flood fill
  5029. functions.
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035. SOURCES
  5036.  
  5037.     xfill.asm
  5038.  
  5039.     xlib.inc
  5040.  
  5041.  
  5042.  
  5043. C HEADER FILE
  5044.  
  5045.     xfill.h EXPORTED FUNCTIONS
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051. x_flood_fill
  5052.  
  5053. C Prototype: int x_flood_fill( int x, int y, WORD offs, int
  5054. boundary, int color);
  5055.  
  5056.  
  5057.  
  5058. x, y - The starting coordinates.
  5059.  
  5060.  
  5061.  
  5062. offs - The page offset to draw on.
  5063.  
  5064.  
  5065.  
  5066. boundary -  Boundary color.
  5067.  
  5068.  
  5069.  
  5070. color - The color to use for the fill.
  5071.  
  5072.  
  5073.  
  5074. Returns: The number of pixels that were filled.
  5075.  
  5076.  
  5077.  
  5078. This function performs the familiar flood filling used by many
  5079. paint programs and, of course, the Borland BGI's flood fill
  5080. function.  The pixel at x, y  and all adjacent pixels of the
  5081. same color are filled with the new color.  Filling stops when
  5082. there are no more adjacent pixels of the original pixels color.
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088. x_boundry_fill
  5089.  
  5090. C Prototype: int x_boundry_fill( int x, int y, WORD offs, int
  5091. boundary, int color);
  5092.  
  5093.  
  5094.  
  5095. x, y - The starting coordinates.
  5096.  
  5097.  
  5098.  
  5099. offs - The page offset to draw on.
  5100.  
  5101.  
  5102.  
  5103. boundary -  Boundary color.
  5104.  
  5105.  
  5106.  
  5107. color - The color to use for the fill.
  5108.  
  5109.  
  5110.  
  5111. Returns: The number of pixels that were filled.
  5112.  
  5113.  
  5114.  
  5115. This function performs a variant of the flood fill described
  5116. above. The pixel at x, y  and all adjacent pixels of the same
  5117. color are filled with the new color.  Filling stops when the
  5118. area being filled is fully enclosed by pixels of the color
  5119. boundary.
  5120.  
  5121.  
  5122.  
  5123. MODULE XVSYNC
  5124.  
  5125.  
  5126.  
  5127. Inspired by REND386 v3.01 by Dave Stamps and Bernie Roehl
  5128.  
  5129.  
  5130.  
  5131. This module uses timer 0 to simulate a vertical retrace
  5132. interrupt.  It's designed to significantly reduce the idle
  5133. waiting time in XLIB.  Why simulate the VRT interrupt?  Simply
  5134. because a true VRT interrupt is not implemented on many VGA
  5135. cards.  Using a VRT interrupt as opposed to polling, can result
  5136. in huge performance improvements for your code and help make
  5137. animation much smoother than it would be using polling.
  5138.  
  5139.  
  5140.  
  5141. Normally XLIB waits for vsync when x_page_flip,
  5142. x_set_start_address or x_put_pal_??? is called. the waiting
  5143. period could be better utilized to do housekeeping calculations
  5144. or whatever.  The x_put_pal_??? functions also don't work very
  5145. smoothly in conjunction with other functions that wait for the
  5146. vertical retrace since each function introduces its own VRT
  5147. delay.
  5148.  
  5149.  
  5150.  
  5151. When using the vsync handler, the VRT delay is reduced to the
  5152. absolute minimum which can result in a huge performance boost
  5153. for your programs.
  5154.  
  5155.  
  5156.  
  5157. When using double buffering, you may still have to wait before
  5158. drawing, but you could do as much other work as possible, like
  5159. this:
  5160.  
  5161.  
  5162.  
  5163.     x_page_flip(...);
  5164.  
  5165.     /* animate the palette */
  5166.  
  5167.     /* do some collision detection and 3D calculations */
  5168.  
  5169.     /* read the joystick */
  5170.  
  5171.     x_wait_start_address();   /* Not needed with triple buffering.
  5172. */
  5173.  
  5174.     /* draw the next frame. */
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180. SOURCES
  5181.  
  5182.     xvsync.asm
  5183.  
  5184.     xmain.asm
  5185.  
  5186.     xvsync.inc
  5187.  
  5188.     xmain.inc
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194. C HEADER FILE
  5195.  
  5196.     xvsync.h
  5197.  
  5198. EXPORTED VARIABLES
  5199.  
  5200.  
  5201.  
  5202. VsyncPeriod WORD - Time in 1.193 between two vsyncs.
  5203.  
  5204.  
  5205.  
  5206. TicksPerSecond WORD - Number of vsyncs per second.
  5207.  
  5208.  
  5209.  
  5210. VsyncTimerInt   long  - Number of vsyncs since
  5211. x_install_vsync_handler was called. Nice for
  5212.  
  5213.                 game timing. EXPORTED FUNCTIONS
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219. x_install_vsync_handler
  5220.  
  5221. C Prototype: void x_install_vsync_handler( int VRTsToSkip);
  5222.  
  5223.  
  5224.  
  5225. VRTsToSkip - Defines the delay in VRT's between consecutive
  5226. physical start address changes,
  5227.  
  5228.         thus allowing you to limit the maximum frame rate for page
  5229. flips in animation
  5230.  
  5231.         systems. The frame rate is calculated as Vertical Refresh Rate
  5232. / VRTsToSkip.
  5233.  
  5234.         Thus in the 320x240 mode which refreshes at 60Hz a VRTsToSkip
  5235. value of 
  5236.  
  5237.         3 will result in a maximum page flipping rate of 20Hz (Frames
  5238. per second).
  5239.  
  5240.  
  5241.  
  5242. This function installs the vsync handler using timer 0.  It's
  5243. called about 100 microseconds before
  5244.  
  5245. every vertical retrace.
  5246.  
  5247.  
  5248.  
  5249. WARNING: Be sure to remove it before exiting your program.
  5250.  
  5251.         When used with a debugger, the system clock may speed up.
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257. x_remove_vsync_handler
  5258.  
  5259. C Prototype: void x_remove_vsync_handler( void );
  5260.  
  5261.  
  5262.  
  5263. This function removes the vsync handler.
  5264.  
  5265.  
  5266.  
  5267. You must call this function before exiting your program, or your
  5268. system will crash!
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274. x_set_user_vsync_handler
  5275.  
  5276. C Prototype: void x_set_user_vsync_handler( void far (*f)() );
  5277.  
  5278.  
  5279.  
  5280. f - A far pointer to a user function to be called once each
  5281. vertical retrace.
  5282.  
  5283.  
  5284.  
  5285. This function installs a user routine to be called once each
  5286. vertical retrace.  The user handler has its own stack of 256
  5287. bytes, so be careful with the stack checking option in BC.
  5288.  
  5289.  
  5290.  
  5291. WARNING: This installs an interrupt driven handler, beware of
  5292. the following:
  5293.  
  5294. Only 8086 registers are preserved.  If you're using 386 code,
  5295. save all the 386 registers.
  5296.  
  5297. Don't do any drawing.
  5298.  
  5299. Don't call any DOS functions.
  5300.  
  5301.  
  5302.  
  5303. You CAN update global variables if you're careful.  And it's
  5304. nice for palette animation.  You can even do fades while loading
  5305. from disk. You should usee this instead of installing your own
  5306. int 08h routine and chaining to the original. x_wait_start_addr
  5307.  
  5308. C Prototype: void x_wait_start_addr( void );
  5309.  
  5310.  
  5311.  
  5312. You must call this function before drawing after a call to
  5313. x_set_start_addr or x_page_flip when you are using the vsync
  5314. handler and not using triple buffering.
  5315.  
  5316.  
  5317.  
  5318.             
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.      MODULE XCBITM32
  5331.  
  5332.  
  5333.  
  5334. This module implements 32 bit compiling of linear bitmaps. 
  5335. There are no functions for plotting the compiled bitmaps in this
  5336. module, use x_put_cbitmap for that.
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342. SOURCES    
  5343.  
  5344.     xcbitm32.c
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350. C HEADER FILE
  5351.  
  5352.     xcbitm32.h
  5353.  
  5354. EXPORTED FUNCTIONS
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360. x_compile_bitmap_32
  5361.  
  5362. C Prototype:  x_compile_bitmap_32( WORD lsw, char far *bitmap,
  5363. char far *output );
  5364.  
  5365.  
  5366.  
  5367. lsw - The logical screen width in bytes.
  5368.  
  5369.  
  5370.  
  5371. bitmap - A pointer to the source linear bitmap.
  5372.  
  5373.  
  5374.  
  5375. output - A far pointer to a buffer set up to receive the
  5376. compiled bitmap.
  5377.  
  5378.  
  5379.  
  5380. Returns: The size of the compiled bitmap in bytes.
  5381.  
  5382.  
  5383.  
  5384. Compiles a linear bitmap to generate 386+ machine code to plot
  5385. it at any required screen coordinates FAST!
  5386.  
  5387.  
  5388.  
  5389.  
  5390.  
  5391. x_sizeof_cbitmap_32
  5392.  
  5393. C Prototype:  int x_sizeof_cbitmap32( WORD lsw, char far *bitmap
  5394. );
  5395.  
  5396.  
  5397.  
  5398. lsw - The logical screen width in bytes.
  5399.  
  5400.  
  5401.  
  5402. bitmap - A far pointer to the source linear bitmap.
  5403.  
  5404.  
  5405.  
  5406. Returns:  The space in bytes required to hold the compiled
  5407. bitmap.
  5408.  
  5409. REFERENCE SECTION
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415. REFERENCES
  5416.  
  5417. In my opinion Doctor Dobbs Journal is the best reference text
  5418. for VGA Mode X graphics:
  5419.  
  5420.     Issue 178 Jul. 1991 : First reference to Mode X Article
  5421. Abstract   : VGA's undocumented
  5422.  
  5423.                       Mode X supports page flipping,  makes off screen
  5424. memory available,
  5425.  
  5426.                     has square pixels,  and increases performance by as
  5427. much as 4 times.
  5428.  
  5429.  
  5430.  
  5431.     Issue 179 Aug. 1991 : Continuation Article Abstract. Michael
  5432. discusses latches and
  5433.  
  5434.                 VGA's  undocumented Mode X.
  5435.  
  5436.  
  5437.  
  5438.     Issue 181 Sept. 1991 : Continuation Article Abstract. Michael
  5439. puts the moves on
  5440.  
  5441.                 animation using VGA's 256 colors.
  5442.  
  5443.  
  5444.  
  5445.     Issue 184 Oct. 1991 : First of a continuing series covering 3-D
  5446. animation  using VGA's
  5447.  
  5448.                 Mode X. This series is still ongoing          
  5449.  
  5450.  
  5451.  
  5452.     (October 1992) Article Abstract. Michael moves into 3-D
  5453. animation, starting with basic
  5454.  
  5455.             polygon fills and page flips.
  5456.  
  5457.  
  5458.  
  5459.  
  5460.  
  5461. WHAT IS MODE X ?
  5462.  
  5463. Mode X is a derivative of the VGA's standard mode 13h (320x200
  5464. 256 color). It is a (family) of undocumented video modes that
  5465. are created by tweaking the VGA's registers. The beauty of mode
  5466. X is that it offers several benefits to the programmer: -
  5467. Multiple graphic pages where mode 13h doesn't allowing for page
  5468. flipping  (also known as double buffering) and storage of images
  5469. and data in offscreen video memory - A planar video ram
  5470. organization which although more difficult to program, allows
  5471. the VGA's plane-oriented hardware to be used to process pixels
  5472. in parallel, improving performance by up to 4 times over mode 13h
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478. WHAT IS A SPLIT SCREEN ?
  5479.  
  5480. A split screen is a hardware feature offered by the EGA and VGA
  5481. video cards. A split screen is a mode of graphics operation in
  5482. which the hardware splits the visual graphics screen
  5483. horizontally and treats both halves as individual screens each
  5484. starting at different locations in video RAM.
  5485.  
  5486. The bottom half (which is usually referred to as the split
  5487. screen) always starts at address A000:0000 but the top half's
  5488. starting address is user definable.
  5489.  
  5490. The most common application of split screens in games is the
  5491. status display in scrolling games. Split screens make this sort
  5492. of game simpler to program because when the top half window is
  5493. scrolled the programmer does not have to worry about redrawing
  5494. the bottom half. WHAT IS RLE?
  5495.  
  5496. RLE stands for RUN LENGTH ENCODING. It is a quick simple data
  5497. compression scheme which is commonly used for image data
  5498. compression or compression of any data. Although not the most
  5499. efficient system, it is fast, which is why it is used in image
  5500. storage systems like PCX. This implementation is more efficient
  5501. than the one used in PCX files because it uses 1 bit to identify
  5502. a Run Length byte as opposed to two in PCX files, but more on
  5503. this later.
  5504.  
  5505.  
  5506.  
  5507. This set of functions can be used to implement your own
  5508. compressed image file format or for example compress game maps
  5509. for various levels etc. The uses are limited by your imagination.
  5510.  
  5511. I opted for trading off PCX RLE compatibility for the improved
  5512. compression efficiency.
  5513.  
  5514.  
  5515.  
  5516. Here is how the data is un-compressed to give an idea of its
  5517. structure.
  5518.  
  5519.     STEP 1 read a byte from the RLE compressed source buffer.
  5520.  
  5521.  
  5522.  
  5523.     STEP 2 If has its high bit is set then the lower 7 bits
  5524. represent the number of times the next
  5525.  
  5526.                    byte is to be repeated in the destination buffer.
  5527. If the count (lower 7 bits) is zero
  5528.  
  5529.         then we have finished decoding goto STEP 5 else goto STEP 4
  5530.  
  5531.  
  5532.  
  5533.     STEP 3 Read a data from the source buffer and copy it directly
  5534. to the destination buffer.
  5535.  
  5536.         goto STEP 1
  5537.  
  5538.  
  5539.  
  5540.     STEP 4 Read a data byte from the source buffer and copy it to
  5541. the destination buffer the
  5542.  
  5543.         number of times specified by step 2. goto STEP 1
  5544.  
  5545.  
  5546.  
  5547.     STEP 5 Stop, decoding done.
  5548.  
  5549.  
  5550.  
  5551. If the byte does not have the high bit set then the byte itself
  5552. is transferred to the destination buffer.
  5553.  
  5554. Data bytes that have the high bit already set and are unique in
  5555. the input stream are represented as a Run Length of 1 (i.e. 81
  5556. which includes high bit) followed by the data byte.
  5557.  
  5558.  
  5559.  
  5560. If your original uncompressed data contains few consecutive
  5561. bytes and most have high bit set (i.e. have values > 127) then
  5562. your so called compressed data would require up to 2x the space
  5563. of the uncompressed data, so be aware that the compression ratio
  5564. is extremely variable depending on the type of data being
  5565. compressed.
  5566.  
  5567.  
  5568.  
  5569. Apologies for this poor attempt at a description, but you can
  5570. look up RLE in any good text. Alternatively, any text that
  5571. describes the PCX file structure in any depth should have a
  5572. section on RLE compression.
  5573.  
  5574.  
  5575.  
  5576.  
  5577.  
  5578. WHAT IS DOUBLE BUFFERING ?
  5579.  
  5580. Double buffering (also known as page flipping) is the technique
  5581. most often used to do animation. it requires hardware that is
  5582. capable of displaying multiple graphics pages (or at least 2).
  5583. Animation is achieved by drawing an image in the non visible
  5584. screen and then displaying the non visible screen. Once the page
  5585. has been flipped the process starts again. The next frame of the
  5586. animation is drawn on the non visible screen, the page is
  5587. flipped again etc.
  5588.  
  5589.  
  5590.  
  5591.  
  5592.  
  5593. WHAT IS TRIPLE BUFFERING?
  5594.  
  5595.  
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601. WHAT IS A BEZIER CURVE?
  5602.  
  5603. The Bezier curve was developedd by the French mathematician
  5604. Pierre Bezier for the design of automobiles.  This curve is
  5605. defined by four points: two end points and two control points. 
  5606. The curve begins at one end point, ends at the other end point,
  5607. and uses the two control points to determine the curvature of
  5608. the line.
  5609.  
  5610.  
  5611.  
  5612.  
  5613.  
  5614.  
  5615.  
  5616.  
  5617.  
  5618. The Care and Feeding of Compiled Masked Blits
  5619.  
  5620. by Matthew MacKenzie
  5621.  
  5622.  
  5623.  
  5624. The XCBITMAP module is small, containing only three procedures:  
  5625.  
  5626.     x_compile_bitmap - Compiles your bitmap into native code which
  5627. writes to the VGA
  5628.  
  5629.                 screen     in an X mode.  
  5630.  
  5631.  
  5632.  
  5633.     x_put_cbitmap - Converts X and Y coordinates into a location on
  5634. the screen, sets up the
  5635.  
  5636.                 necessary VGA registers, and executes the compiled bitmap as
  5637. a
  5638.  
  5639.                 subroutine.
  5640.  
  5641.  
  5642.  
  5643.     x_sizeof_cbitmap - Takes a planar bitmap and returns an integer
  5644. equal to the size of the
  5645.  
  5646.                 compiled bitmap which the planar bitmap would produce. It is
  5647.  
  5648.                 essentially a lobotomized version of x_compile_bitmap, with
  5649. all
  5650.  
  5651.                 the code generation replaced with a size counter.
  5652.  
  5653.  
  5654.  
  5655. x_compile_bitmap scans through a source bitmap and generates
  5656. 8086 instructions to plot every non-zero pixel. It is designed
  5657. to be used before the action begins rather than on-the-fly.  The
  5658. compiled bitmap contains no branches, and no reference to the
  5659. zero (transparent) pixels. Where two pixels are exactly four
  5660. columns apart they are plotted with a single 16-bit store, and
  5661. the VGA MAP_MASK register will be set at most four times. As a
  5662. result your bitmap may run several times faster than a
  5663. traditional memory-to-VGA masked blit routine. There is no way
  5664. to perform clipping on these bitmaps, or to plot a pixel of
  5665. color zero.
  5666.  
  5667.  
  5668.  
  5669. x_compile_bitmap works with bitmaps in the standard Xlib planar
  5670. bitmap format. On a time scale of 60 frames per second, it is
  5671. actually relatively slow. Since a compiled bitmap is relocatable
  5672. you may just want to have it saved to disk, and not include the
  5673. source bitmap in your program at all.    
  5674.  
  5675.  
  5676.  
  5677. The source bitmap format is an array of bytes, a little like
  5678. this:
  5679.  
  5680. char eye[] ={4, 7,  /* four byte columns across, seven rows tall
  5681. */
  5682.  
  5683.     0, 0, 0, 0, 9, 1, 1, 1, 9, 0, 0, 0, 0, 0, 0, 0,
  5684.  
  5685.        0, 0, 9, 9, 1, 1, 1, 4, 4, 9, 9, 0, 0, 0, 0, 0,
  5686.  
  5687.        0, 9, 9, 1, 2, 0, 0, 4, 4, 1, 9, 9, 0, 0, 0, 0,
  5688.  
  5689.        9, 9, 9, 1, 0, 0, 0, 0, 1, 1, 9, 9, 9, 0, 0, 0,
  5690.  
  5691.        0, 9, 9, 1, 2, 0, 0, 2, 1, 1, 9, 9, 0, 0, 0, 0,
  5692.  
  5693.        0, 0, 9, 9, 1, 1, 1, 1, 1, 9, 9, 0, 0, 0, 0, 0,
  5694.  
  5695.        0, 0, 0, 0, 9, 1, 1, 1, 9, 0, 0, 0, 0, 0, 0, 0};
  5696.  
  5697.  
  5698.  
  5699. This is actually a linear bitmap, which is the wrong format for
  5700. compilation, but is easier on human eyes. Use the module
  5701. XBMTOOLS to convert linear bitmaps into planar bitmaps, and
  5702. vice-versa.
  5703.  
  5704.   
  5705.  
  5706. To compile this image for a mode 360 pixels (90 byte columns)
  5707. across:
  5708.  
  5709.     char planar_eye[4*7 + 2]; 
  5710.  
  5711.     char far * EyeSize;
  5712.  
  5713.     (void) x_bm_to_pbm((char far *) eye, (char far *) planar_eye); 
  5714.  
  5715.     EyeSize = x_sizeof_cbitmap((far char *) planar_eye); 
  5716.  
  5717.     CompiledEye = farmalloc(EyeSize); 
  5718.  
  5719.     (void) x_compile_bitmap(90, (far char *) planar_eye,
  5720. CompiledEye);
  5721.  
  5722.  
  5723.  
  5724. Notice that both buffers must exist beforehand. Since
  5725. x_compile_bitmap returns the size of the compiled code, in
  5726. bytes, you can reallocate the bitmap immediately to the right
  5727. size if using x_sizeof_cbitmap seems inconvenient (reallocation
  5728. may even be faster, though using the function is cleaner). The
  5729. pointers are 32-bit because compiled bitmaps take so much space:
  5730. they are at one end of the speed-versus-memory spectrum. A good
  5731. rule of thumb is to allocate (3.5 * buffer-height *
  5732. buffer-width) + 25 bytes (rounding up), then pare your bitmap
  5733. down when you find out how much space you've actually used.
  5734.  
  5735.  
  5736.  
  5737. Since the compiled bitmap has to fit within one segment of
  5738. memory, it cannot contain more than about 19,000 pixels. This
  5739. will not be a limitation for most sane programmers. If you are
  5740. not a sane programmer try splitting your huge, unwieldy image up
  5741. into smaller parts. You can use the same gigantic bitmap if you
  5742. divide it into horizontal slices for compilation. For that
  5743. matter, dividing the source up that way will let you use a
  5744. source bitmap large than 64K, which is an even sicker idea.
  5745.  
  5746.  
  5747.  
  5748. Back to business. A bitmap is compiled for only one width of
  5749. screen. If you are using a logical screen larger than your
  5750. physical screen, call the bitmap compiler with the logical
  5751. width. The important thing is the number of bytes per line.
  5752. Notice that you do not have to be in a graphics mode to use this
  5753. routine.This allows you to develop and compile bitmaps
  5754. separately, with whatever utility programs you might cook up.
  5755.  
  5756.  
  5757.  
  5758. The final function is x_put_cbitmap.
  5759.  
  5760. To plot our eye at (99, 4), on the page which starts at location
  5761. 0: 
  5762.  
  5763.     x_put_cbitmap(99, 4, 0, CompiledEye);
  5764.  
  5765.  
  5766.  
  5767. This function depends on the global variable
  5768. ScrnLogicalByteWidth from the module XMAIN, which should be the
  5769. same number as the column parameter you used to compile your
  5770. bitmap.    
  5771.  
  5772.  
  5773.  
  5774. The XCBITMAP module supports memory-to-VGA blits only. XLIB also
  5775. includes non-masking routines which can quickly save and restore
  5776. the background screen behind your bitmap, using fast string
  5777. operations.
  5778.  
  5779.  
  5780.  
  5781. This module is part of the XLIB package, and is in the public
  5782. domain. If you write something which uses it, though, please
  5783. send me a copy as a courtesy  if for no other reason so I can
  5784. tilt my chair back and reflect that it may have been worth the
  5785. trouble after all.
  5786.  
  5787.  
  5788.  
  5789. The included program DEMO2.C demonstrates the performance
  5790. difference between planar bitmap
  5791.  
  5792.  masked blits and compiled bitmap blits. Blits and Pieces
  5793.  
  5794. by Matthew MacKenzie
  5795.  
  5796.  
  5797.  
  5798. The XCLIPPBM module contains clipping versions of two of the
  5799. three routines in the XPBITMAP module:  
  5800.  
  5801.  
  5802.  
  5803. x_clip_pbm - transfers a planar bitmap to the screen, clipping
  5804. off any part outside a bounding box.  
  5805.  
  5806. x_clip_masked_pbm - does the same thing, but transfers only
  5807. non-zero  pixels.
  5808.  
  5809.  
  5810.  
  5811. The planar bitmap format is described elsewhere.  Here we will
  5812. look at the clipping itself, since it is the only distinguishing
  5813. feature of this module.
  5814.  
  5815.  
  5816.  
  5817. The bounding box is made up of four integers, TopBound,
  5818. BottomBound, LeftBound, and RightBound. Unlike most global
  5819. variables in XLIB, these are meant to be written to. In fact,
  5820. they start out uninitialized.  Be sure to set them before you
  5821. try plotting any clipped bitmaps.
  5822.  
  5823. Note that these are not the same variables which are used in the
  5824. other clipping modules in XLIB.  This is because the two systems
  5825. are incompatible: the other modules clip horizontally to columns
  5826. while this one clips to pixels. As you might have guessed, those
  5827. functions and these were developed in different hemispheres of
  5828. the planet. If it's any consolation, this does give you two
  5829. independent bounding boxes to futz with, should the mood visit
  5830. you.
  5831.  
  5832.  
  5833.  
  5834. Bitmaps cannot go outside the perimeter of the bounding box, but
  5835. they can overlap it. If TopBound equals BottomBound, for
  5836. example, a horizontal slice of a bitmap may still be plotted. It
  5837. is safe to turn the box "inside out" to make sure nothing will
  5838. be plotted. This is the first thing each routine checks for.
  5839.  
  5840.  
  5841.  
  5842. To plot a bitmap, minus its zero pixels, minus anything outside
  5843. the bounding box:
  5844.  
  5845.  
  5846.  
  5847. x_clip_masked_pbm (int X, int Y, int ScreenOffs, char far *
  5848. Bitmap);
  5849.  
  5850.  
  5851.  
  5852. The arguments are in the same order as those for
  5853. x_put_masked_pbm in the module XPBITMAP.  The bounding box is
  5854. relative to the given ScreenOffs ). This lets you perform page
  5855. flipping without worrying about what screen you are clipping to
  5856. it's always the current screen. The bitmap itself, of course, is
  5857. not affected; clipping is performed on-the-fly. Both functions
  5858. return an integer which indicates whether any part of the bitmap
  5859. was inside the bounding box. If the entire bitmap was outside, a
  5860. 1 is returned; otherwise, a 0.
  5861.  
  5862.  
  5863.  
  5864. The third function in XPBITMAP, for which this module has no
  5865. equivalent, copies from video RAM to system RAM. The absence of
  5866. such a routine may seem at first like a disadvantage but this,
  5867. like so many things in this life, is an illusion.  You can use
  5868. the unclipped routine, and clip the bitmap when you want to plot
  5869. it back onto the screen. Wheel Have to See About That
  5870.  
  5871. by Matthew MacKenzie
  5872.  
  5873.  
  5874.  
  5875.  
  5876.  
  5877. The XCIRCLE module contains two functions, neither of which
  5878. should be a big mystery:
  5879.  
  5880.     x_circle, oddly enough, draws a circle.  
  5881.  
  5882.     x_filled_circle does too, only the circle is filled (in some
  5883. libraries this is called a disc).
  5884.  
  5885.  
  5886.  
  5887. The word `circle' here refers to a round thing which is as many
  5888. pixels tall as across. It only looks like a circle in 320x240
  5889. mode, the original mode X, and in 376x282 mode. In both
  5890. functions, the circle is specified by the coordinates of the
  5891. upper-left-hand corner of the smallest box which holds it, and
  5892. the diameter. Some circle functions have you specify a center
  5893. point; this system is kind of odd because a circle with an even
  5894. diameter does not have a particular pixel for a center. Every
  5895. circle, on the other hand, has a box with an upper-left corner.
  5896. No bounds are checked. A diameter of zero will draw nothing, and
  5897. a negative diameter will blow your VGA board into hundreds of
  5898. thousands of tiny little smoldering fragments. Neither function
  5899. supports clipping. The calculation of the circle is based on an
  5900. algorithm described by Michael P. Lindner in a letter to the
  5901. editor on page 8 of Dr. Dobb's Journal #169 (October 1990).  The
  5902. algorithm has been rearranged to allow drawing and moving the
  5903. plots in the eight octants to be performed in one step, so that
  5904. each pixel does not have to be loaded into the CPU twice. 
  5905. x_filled_circle does not take advantage of this optimization
  5906. because it handles different parts of each plot at different
  5907. times.
  5908.  
  5909.  
  5910.  
  5911.