home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / visionix / vxmsu.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-12-28  |  34.4 KB  |  1,822 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Extended Memory Services Unit (VXMS)
  5.    Version 0.9
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9.  ────────────────────────────────────────────────────────────────────────────
  10.  
  11.  Revision history in reverse chronological order:
  12.  
  13.  Initials  Date      Comment
  14.  ────────  ────────  ────────────────────────────────────────────────────────
  15.  
  16.  mep       03/25/93  Merged with VMemLow XMS routines.
  17.  
  18.  lpg       03/15/93  Added Source Documentation
  19.  
  20.  mep       02/11/93  Cleaned up code for beta release
  21.  
  22.  jrt       02/08/93  Sync with beta 0.12 release
  23.  
  24.  lpg       12/27/92  Cleaned up Unit
  25.  
  26.  jrt       12/07/92  Sync with beta 0.11 release
  27.  
  28.  lpg       11/25/92  Debugged ASM Routines
  29.  
  30.  jrt       11/21/92  Sync with beta 0.08
  31.  
  32.  mep/lpg   11/18/92  First logged revision.
  33.  
  34.  ────────────────────────────────────────────────────────────────────────────
  35.  
  36. }
  37.  
  38. (*-
  39.  
  40. [TEXT]
  41.  
  42. <Overview>
  43.  
  44. This unit implements a function for all commands in the XMS
  45. specification.
  46.  
  47. The documentation for this unit will be enhanced in the next release.
  48.  
  49.  
  50.  
  51.  
  52. <Interface>
  53.  
  54. -*)
  55.  
  56. Unit
  57.  
  58.   VXMSu;
  59.  
  60. Interface
  61.  
  62. Uses
  63.  
  64.   VTypesu,
  65.   DOS;
  66.  
  67. {────────────────────────────────────────────────────────────────────────────}
  68.  
  69. Type
  70.  
  71.   TXMSError   = BYTE;
  72.  
  73.   TXMBHandle  = WORD;
  74.   TXMSHandleOfs  = LONGINT;
  75.  
  76.   TXMSHandle  = WORD;
  77.   PXMSHandle  = ^TXMSHandle;
  78.  
  79.   TXMSMoveData = RECORD
  80.     Count     : LONGINT;    { 32-bit, num bytes to trans }
  81.     Source    : TXMBHandle;
  82.     SourceOfs : TXMSHandleOfs;
  83.     Dest      : TXMBHandle;
  84.     DestOfs   : TXMSHandleOfs;
  85.   END;
  86.   PXMSMoveData = ^TXMSMoveData;
  87.  
  88. {────────────────────────────────────────────────────────────────────────────}
  89.  
  90. {----------}
  91. { XMS 2.0+ }
  92. {----------}
  93.  
  94. Function  VXMSErrorToStr(             Status       : BYTE       ) : STRING;
  95.  
  96. Function  VXMSInstalled                            : BOOLEAN;
  97.  
  98. Procedure VXMSGetHandleAddr;
  99.  
  100. Function  VXMSGetVersion                           : WORD;
  101.  
  102. Function  VXMMGetVersion                           : WORD;
  103.  
  104. Function  VHMAPresent                              : BOOLEAN;
  105.  
  106. Function  VHMANew                                  : TXMSError;
  107.  
  108. Function  VHMANewTSR(                 HMABytes     : WORD       ) : TXMSError;
  109.  
  110. Function  VHMADispose                              : TXMSError;
  111.  
  112. Function  VA20GlobalEnable                         : TXMSError;
  113.  
  114. Function  VA20GlobalDisable                        : TXMSError;
  115.  
  116. Function  VA20LocalEnable                          : TXMSError;
  117.  
  118. Function  VA20LocalDisable                         : TXMSError;
  119.  
  120. Function  VA20Query                                : TXMSError;
  121.  
  122. Function  VXMSGetFreeStat(        Var MaxBlock     : WORD;
  123.                                   Var TotalK       : WORD       ) : TXMSError;
  124.  
  125. Function  VXMSGetMaxBlock                          : WORD;
  126.  
  127. Function  VXMSGetTotalFreeK                        : WORD;
  128.  
  129. Function  VXMBNew(                    SizeInK      : WORD;
  130.                                   Var Handle       : TXMBHandle ) : TXMSError;
  131.  
  132. Function  VXMBDispose(                Handle       : TXMBHandle ) : TXMSError;
  133.  
  134. Function  VXMBMove(                   MoveData     : PXMSMoveData) : TXMSError;
  135.  
  136. Function  VXMBMoveBlock(              Count        : LONGINT;
  137.                                       Source       : TXMBHandle;
  138.                                       SourceOfs    : TXMSHandleOfs;
  139.                                       Dest         : TXMBHandle;
  140.                                       DestOfs      : TXMSHandleOfs ) : TXMSError;
  141.  
  142. Function  VXMBMoveMainToXMB(          Count        : WORD;
  143.                                       FromPtr      : POINTER;
  144.                                       ToHandle     : TXMBHandle;
  145.                                       ToOfs        : TXMSHandleOfs ) : TXMSError;
  146.  
  147. Function  VXMBMoveXMBToMain(          Count        : WORD;
  148.                                       ToPtr        : POINTER;
  149.                                       FromHandle   : TXMBHandle;
  150.                                       FromHandleOfs: TXMSHandleOfs ) : TXMSError;
  151.  
  152. Function  VXMBLock(                   Handle       : TXMBHandle ) : TXMSError;
  153.  
  154. Function  VXMBUnLock(                 Handle       : TXMBHandle ) : TXMSError;
  155.  
  156. Function  VXMBGetInfo(                Handle       : TXMBHandle;
  157.                                   Var LockCount    : BYTE;
  158.                                   Var FreeHandles  : BYTE;
  159.                                   Var SizeInK      : WORD       ) : TXMSError;
  160.  
  161. Function  VXMBResize(                 NewSizeK     : WORD;
  162.                                       Handle       : TXMBHandle ) : TXMSError;
  163.  
  164. Function  VUMBNew(                    SizeInPara   : WORD;
  165.                                   Var SegOfUMB     : WORD;
  166.                                   Var SizeAlloc    : WORD;
  167.                                   Var MaxAvail     : WORD       ) : TXMSError;
  168.  
  169. Function  VUMBDispose(                SegOfUMB     : WORD       ) : TXMSError;
  170.  
  171.  
  172. {────────────────────────────────────────────────────────────────────────────}
  173.  
  174. {---------}
  175. { XMS 3.0 }
  176. {---------}
  177.  
  178. Function  VUMBResize(                 SegOfUMB     : WORD;
  179.                                       NewSize      : WORD       ) : TXMSError;
  180.  
  181. Function  VXMSQueryFreeXM(        Var MaxBlock     : LONGINT;
  182.                                   Var HighByte     : LONGINT;
  183.                                   Var TotalK       : LONGINT    ) : TXMSError;
  184.  
  185. Function  VXMSNew(                    SizeInK      : LONGINT;
  186.                                   Var Handle       : TXMBHandle ) : TXMSError;
  187.  
  188. Function  VXMSGetInfo(                Handle       : TXMBHandle;
  189.                                   Var LockCount    : BYTE;
  190.                                   Var FreeHandles  : WORD;
  191.                                   Var SizeInK      : LONGINT    ) : TXMSError;
  192.  
  193. Function  VXMSReSize(                 Handle       : TXMBHandle;
  194.                                       NewSizeK     : LONGINT    ) : TXMSError;
  195.  
  196. {────────────────────────────────────────────────────────────────────────────}
  197.  
  198. Implementation
  199.  
  200. Var
  201.  
  202.   XMSAddr : POINTER;
  203.  
  204. {────────────────────────────────────────────────────────────────────────────}
  205.  
  206. (*-
  207.  
  208. [FUNCTION]
  209.  
  210. Function VXMSErrorToStr(                   Status    : BYTE       ) : STRING;
  211.  
  212. [PARAMETERS]
  213.  
  214. Status      XMS status code
  215.  
  216. [RETURNS]
  217.  
  218. XMS text error message.
  219.  
  220. [DESCRIPTION]
  221.  
  222. Takes the XMS error code value and converts it into a text message.
  223.  
  224. [SEE-ALSO]
  225.  
  226. [EXAMPLE]
  227.  
  228. -*)
  229.  
  230. Function VXMSErrorToStr(                   Status    : BYTE       ) : STRING;
  231.  
  232. Var
  233.  
  234.   S : STRING;
  235.  
  236. BEGIN
  237.  
  238.   S := '';
  239.  
  240.   Case Status Of
  241.  
  242.     $80 : S := 'Function not implemented';
  243.     $81 : S := 'VDISK device detected';
  244.     $82 : S := 'A20 error occured';
  245.     $8E : S := 'General driver error';
  246.     $8F : S := 'Unrecoverable driver error';
  247.     $90 : S := 'HMA does not exist';
  248.     $91 : S := 'HMA is already in use';
  249.     $92 : S := 'Size is smaller than /HMAMIN= parameter';
  250.     $93 : S := 'HMA is not allocated';
  251.     $94 : S := 'A20 line still enabled';
  252.     $A0 : S := 'All extended memory is allocated';
  253.     $A1 : S := 'All available handles are allocated';
  254.     $A2 : S := 'Invalid handle';
  255.     $A3 : S := 'Invalid source handle';
  256.     $A4 : S := 'Invalid source offset';
  257.     $A5 : S := 'Invalid destination handle';
  258.     $A6 : S := 'Invalid destination offset';
  259.     $A7 : S := 'Invalid length';
  260.     $A8 : S := 'Move has an invalid overlap';
  261.     $A9 : S := 'Parity error occurred';
  262.     $AA : S := 'Block is not locked';
  263.     $AB : S := 'Block is locked';
  264.     $AC : S := 'Block lock count overflowed';
  265.     $AD : S := 'Lock failure';
  266.     $B0 : S := 'Only a smaller UMB is available';
  267.     $B1 : S := 'No UMB is available';
  268.     $B2 : S := 'Invalid UMB segment number';
  269.  
  270.   End;
  271.  
  272.   VXMSErrorToStr := S;
  273.  
  274. END;
  275.  
  276. {────────────────────────────────────────────────────────────────────────────}
  277.  
  278. (*-
  279.  
  280. [FUNCTION]
  281.  
  282. Function VXMSInstalled                               : BOOLEAN;
  283.  
  284. [PARAMETERS]
  285.  
  286. (None)
  287.  
  288. [RETURNS]
  289.  
  290. Availability of XMS services.
  291.  
  292. [DESCRIPTION]
  293.  
  294. Determines whether extended memory services (XMS) are available.
  295.  
  296. [SEE-ALSO]
  297.  
  298. [EXAMPLE]
  299.  
  300. -*)
  301.  
  302. Function VXMSInstalled                               : BOOLEAN;
  303.  
  304. Assembler;
  305. ASM
  306.  
  307.   MOV  AX, $4300
  308.  
  309.   INT  $2F                   { Multiplexer Interrupt Identification }
  310.  
  311.   CMP  AL, $80
  312.   JNE  @@1
  313.  
  314.   MOV  AL, 1                 { XMS Installed = TRUE }
  315.   JMP  @@2
  316.  
  317.  @@1:
  318.   XOR  AL, AL                { XMS Installed = FALSE }
  319.  
  320.  @@2:
  321.  
  322. END;
  323.  
  324. {────────────────────────────────────────────────────────────────────────────}
  325.  
  326. (*-
  327.  
  328. [FUNCTION]
  329.  
  330. Procedure VXMSGetHandleAddr;
  331.  
  332. [PARAMETERS]
  333.  
  334. (None)
  335.  
  336. [RETURNS]
  337.  
  338. (None)
  339.  
  340. [DESCRIPTION]
  341.  
  342. This function gets the extended memory services address handle for future
  343. XMS function calls.
  344.  
  345. [SEE-ALSO]
  346.  
  347. [EXAMPLE]
  348.  
  349. -*)
  350.  
  351. Procedure VXMSGetHandleAddr;
  352.  
  353. Assembler;
  354. ASM
  355.  
  356.   MOV  AX, $4310
  357.  
  358.   INT  $2F
  359.  
  360.   {-----------------------------}
  361.   { ES:BX -> driver entry point }
  362.   {-----------------------------}
  363.  
  364.   MOV  word PTR [XMSAddr + 2], ES  {XMS Addr Seg}
  365.   MOV  word PTR [XMSAddr], BX      {XMS Addr Ofs}
  366.  
  367. END;
  368.  
  369. {────────────────────────────────────────────────────────────────────────────}
  370.  
  371. (*-
  372.  
  373. [FUNCTION]
  374.  
  375. Function VXMSGetVersion                              : WORD;
  376.  
  377. [PARAMETERS]
  378.  
  379. (None)
  380.  
  381. [RETURNS]
  382.  
  383. The XMS version number.
  384.  
  385. [DESCRIPTION]
  386.  
  387. Returns the extended memory services (XMS) version number.  The high-byte
  388. being the major version number, and the low-byte being the minor version
  389. number.
  390.  
  391. [SEE-ALSO]
  392.  
  393. [EXAMPLE]
  394.  
  395. -*)
  396.  
  397. Function VXMSGetVersion                              : WORD;
  398.  
  399. Assembler;
  400. ASM
  401.  
  402.   XOR  AH, AH
  403.   CALL [XMSAddr]
  404.  
  405. END;
  406.  
  407. {────────────────────────────────────────────────────────────────────────────}
  408.  
  409. (*-
  410.  
  411. [FUNCTION]
  412.  
  413. Function VXMMGetVersion                              : WORD;
  414.  
  415. [PARAMETERS]
  416.  
  417. (None)
  418.  
  419. [RETURNS]
  420.  
  421. The XMM version number.
  422.  
  423. [DESCRIPTION]
  424.  
  425. Returns the extended memory manager (XMM) version number.  The high-byte
  426. being the major version number, and the low-byte being the minor version
  427. number.
  428.  
  429. [SEE-ALSO]
  430.  
  431. [EXAMPLE]
  432.  
  433. -*)
  434.  
  435. Function VXMMGetVersion                              : WORD;
  436.  
  437. Assembler;
  438. ASM
  439.  
  440.   XOR  AH, AH
  441.   CALL [XMSAddr]
  442.   MOV  AX, BX
  443.  
  444. END;
  445.  
  446. {────────────────────────────────────────────────────────────────────────────}
  447.  
  448. (*-
  449.  
  450. [FUNCTION]
  451.  
  452. Function VHMAPresent                                 : BOOLEAN;
  453.  
  454. [PARAMETERS]
  455.  
  456. (None)
  457.  
  458. [RETURNS]
  459.  
  460. Availability of HMA support.
  461.  
  462. [DESCRIPTION]
  463.  
  464. Determines whether high memory address (HMA) support is available.
  465.  
  466. [SEE-ALSO]
  467.  
  468. [EXAMPLE]
  469.  
  470. -*)
  471.  
  472. Function VHMAPresent                                 : BOOLEAN;
  473.  
  474. Assembler;
  475. ASM
  476.  
  477.   XOR  AH, AH
  478.   CALL [XMSAddr]
  479.   MOV  AL, DL
  480.  
  481. END;
  482.  
  483. {────────────────────────────────────────────────────────────────────────────}
  484.  
  485. (*-
  486.  
  487. [FUNCTION]
  488.  
  489. Function VHMANew                                     : TXMSError;
  490.  
  491. [PARAMETERS]
  492.  
  493. (None)
  494.  
  495. [RETURNS]
  496.  
  497. HMA Error Code (0=Success)
  498.  
  499. [DESCRIPTION]
  500.  
  501. This function allocates memory in the high memory area (HMA).
  502.  
  503. This is a use only for non-TSR programs.  A TSR cannot use this routine
  504. to allocate HMA memory.  It should use the VHMANewTSR Routine.
  505.  
  506. [SEE-ALSO]
  507.  
  508. [EXAMPLE]
  509.  
  510. -*)
  511.  
  512. Function VHMANew                                     : TXMSError;
  513.  
  514. Assembler;
  515. ASM
  516.  
  517.   MOV  AH, 1
  518.   MOV  DX, $FFFF             {Non-TSR Applications Only}
  519.   CALL [XMSAddr]
  520.  
  521.   CMP  AL, 0
  522.   JNE  @@1
  523.  
  524.   MOV  AL, BL                {TXMSError = Error}
  525.   JMP  @@2
  526.  
  527.  @@1:
  528.   XOR  AL, AL                {TXMSError = No Error}
  529.  
  530.  @@2:
  531.  
  532. END;
  533.  
  534. {────────────────────────────────────────────────────────────────────────────}
  535.  
  536. (*-
  537.  
  538. [FUNCTION]
  539.  
  540. Function VHMANewTSR(                       HMABytes  : WORD       ) : TXMSError;
  541.  
  542. [PARAMETERS]
  543.  
  544. HMABytes    Number of bytes in HMA to allocate
  545.  
  546. [RETURNS]
  547.  
  548. HMA Error Code (0=Success)
  549.  
  550. [DESCRIPTION]
  551.  
  552. This is a special routine just for TSRs.  A TSR cannot use the normal HMA
  553. allocation functions, and neither should a normal program use this routine.
  554.  
  555. This function allocates memory in the high memory area (HMA).
  556.  
  557. [SEE-ALSO]
  558.  
  559. [EXAMPLE]
  560.  
  561. -*)
  562.  
  563. Function VHMANewTSR(                       HMABytes  : WORD       ) : TXMSError;
  564.  
  565. Assembler;
  566. ASM
  567.  
  568.   MOV  AH, 1
  569.   MOV  DX, HMABytes      {Bytes needed by driver or operating system}
  570.   CALL [XMSAddr]
  571.  
  572.   CMP  AL, 1
  573.   JE   @SUCCESS
  574.  
  575.   MOV  AL, BL            { TXMSError = Error }
  576.   JMP  @EXIT
  577.  
  578.  @SUCCESS:
  579.  
  580.   XOR  AL, AL            { TXMSError = No Error }
  581.  
  582.  @EXIT:
  583.  
  584. END;
  585.  
  586. {────────────────────────────────────────────────────────────────────────────}
  587.  
  588. (*-
  589.  
  590. [FUNCTION]
  591.  
  592. Function VHMADispose                                 : TXMSError;
  593.  
  594. [PARAMETERS]
  595.  
  596. (None)
  597.  
  598. [RETURNS]
  599.  
  600. HMA Error Code (0=Success)
  601.  
  602. [DESCRIPTION]
  603.  
  604. Frees memory associate with the high memory area.
  605.  
  606. [SEE-ALSO]
  607.  
  608. [EXAMPLE]
  609.  
  610. -*)
  611.  
  612. Function VHMADispose                                 : TXMSError;
  613.  
  614. Assembler;
  615. ASM
  616.  
  617.   MOV  AH, 2
  618.   CALL [XMSAddr]
  619.  
  620.   CMP  AL, 1
  621.   JE   @SUCCESS
  622.  
  623.   MOV  AL, BL            { TXMSError = Error }
  624.   JMP  @EXIT
  625.  
  626.  @SUCCESS:
  627.  
  628.   XOR  AL, AL            { TXMSError = No Error }
  629.  
  630.  @EXIT:
  631.  
  632. END;
  633.  
  634. {────────────────────────────────────────────────────────────────────────────}
  635.  
  636. (*-
  637.  
  638. [FUNCTION]
  639.  
  640. Function VA20GlobalEnable                            : TXMSError;
  641.  
  642. [PARAMETERS]
  643.  
  644. (None)
  645.  
  646. [RETURNS]
  647.  
  648. Whether the Global A20 memory line is enabled.
  649.  
  650. [DESCRIPTION]
  651.  
  652. Determines and reports whether the Global A20 memory line is enabled.
  653.  
  654. [SEE-ALSO]
  655.  
  656. [EXAMPLE]
  657.  
  658. -*)
  659.  
  660. Function VA20GlobalEnable                            : TXMSError;
  661.  
  662. Assembler;
  663. ASM
  664.  
  665.   MOV  AH, 3
  666.   CALL [XMSAddr]
  667.  
  668.   CMP  AL, 1
  669.   JE   @SUCCESS
  670.  
  671.   MOV  AL, BL            { TXMSError = Error }
  672.   JMP  @EXIT
  673.  
  674.  @SUCCESS:
  675.  
  676.   XOR  AL, AL            { TXMSError = No Error }
  677.  
  678.  @EXIT:
  679.  
  680. END;
  681.  
  682. {────────────────────────────────────────────────────────────────────────────}
  683.  
  684. (*-
  685.  
  686. [FUNCTION]
  687.  
  688. Function VA20GlobalDisable                           : TXMSError;
  689.  
  690. [PARAMETERS]
  691.  
  692. (None)
  693.  
  694. [RETURNS]
  695.  
  696. Whether the Global A20 memory line is disabled.
  697.  
  698. [DESCRIPTION]
  699.  
  700. Determines and reports whether the Global A20 memory line is disabled.
  701.  
  702. [SEE-ALSO]
  703.  
  704. [EXAMPLE]
  705.  
  706. -*)
  707.  
  708. Function VA20GlobalDisable                           : TXMSError;
  709.  
  710. Assembler;
  711. ASM
  712.  
  713.   MOV  AH, 4
  714.   CALL [XMSAddr]
  715.  
  716.   CMP  AL, 1
  717.   JE   @SUCCESS
  718.  
  719.   MOV  AL, BL            { TXMSError = Error }
  720.   JMP  @EXIT
  721.  
  722.  @SUCCESS:
  723.  
  724.   XOR  AL, AL            { TXMSError = No Error }
  725.  
  726.  @EXIT:
  727.  
  728. END;
  729.  
  730. {────────────────────────────────────────────────────────────────────────────}
  731.  
  732. (*-
  733.  
  734. [FUNCTION]
  735.  
  736. Function VA20LocalEnable                             : TXMSError;
  737.  
  738. [PARAMETERS]
  739.  
  740. (None)
  741.  
  742. [RETURNS]
  743.  
  744. Whether the Local A20 memory line is enabled.
  745.  
  746. [DESCRIPTION]
  747.  
  748. Determines and reports whether the Local A20 memory line is enabled.
  749.  
  750. [SEE-ALSO]
  751.  
  752. [EXAMPLE]
  753.  
  754. -*)
  755.  
  756. Function VA20LocalEnable                             : TXMSError;
  757.  
  758. Assembler;
  759. ASM
  760.  
  761.   MOV  AH, 5
  762.   CALL [XMSAddr]
  763.  
  764.   CMP  AL, 1
  765.   JE   @SUCCESS
  766.  
  767.   MOV  AL, BL            { TXMSError = Error }
  768.   JMP  @EXIT
  769.  
  770.  @SUCCESS:
  771.  
  772.   XOR  AL, AL            { TXMSError = No Error }
  773.  
  774.  @EXIT:
  775.  
  776. END;
  777.  
  778. {────────────────────────────────────────────────────────────────────────────}
  779.  
  780. (*-
  781.  
  782. [FUNCTION]
  783.  
  784. Function VA20LocalDisable                            : TXMSError;
  785.  
  786. [PARAMETERS]
  787.  
  788. (None)
  789.  
  790. [RETURNS]
  791.  
  792. Whether the Local A20 memory line is disabled.
  793.  
  794. [DESCRIPTION]
  795.  
  796. Determines and reports whether the Local A20 memory line is disabled.
  797.  
  798. [SEE-ALSO]
  799.  
  800. [EXAMPLE]
  801.  
  802. -*)
  803.  
  804. Function VA20LocalDisable                            : TXMSError;
  805.  
  806. Assembler;
  807. ASM
  808.  
  809.   MOV  AH, 6
  810.   CALL [XMSAddr]
  811.  
  812.   CMP  AL, 1
  813.   JE   @SUCCESS
  814.  
  815.   MOV  AL, BL            { TXMSError = Error }
  816.   JMP  @EXIT
  817.  
  818.  @SUCCESS:
  819.  
  820.   XOR  AL, AL            { TXMSError = No Error }
  821.  
  822.  @EXIT:
  823.  
  824. END;
  825.  
  826. {────────────────────────────────────────────────────────────────────────────}
  827.  
  828. (*-
  829.  
  830. [FUNCTION]
  831.  
  832. Function VA20Query                                   : TXMSError;
  833.  
  834. [PARAMETERS]
  835.  
  836. (None)
  837.  
  838. [RETURNS]
  839.  
  840. Whether the A20 memory line query is enabled.
  841.  
  842. [DESCRIPTION]
  843.  
  844. Determines and reports whether the A20 memory line query is enabled.
  845. Note that a query action is only true if function returns no error -
  846. this assumes line disabled if error.
  847.  
  848. [SEE-ALSO]
  849.  
  850. [EXAMPLE]
  851.  
  852. -*)
  853.  
  854. Function VA20Query                                   : TXMSError;
  855.  
  856. Assembler;
  857. ASM
  858.  
  859.   MOV  AH, 7
  860.   CALL [XMSAddr]
  861.  
  862.   CMP  AL, 1
  863.   JE   @SUCCESS
  864.  
  865.   MOV  AL, BL            { TXMSError = Disabled/Error   }
  866.   JMP  @EXIT
  867.  
  868.  @SUCCESS:
  869.  
  870.   XOR  AL, AL            { TXMSError = Enabled/No Error }
  871.  
  872.  @EXIT:
  873.  
  874. END;
  875.  
  876. {────────────────────────────────────────────────────────────────────────────}
  877.  
  878. (*-
  879.  
  880. [FUNCTION]
  881.  
  882. Function VXMSGetFreeStat(          Var MaxBlock      : WORD;
  883.                                    Var TotalK        : WORD       ) : TXMSError;
  884.  
  885. [PARAMETERS]
  886.  
  887. MaxBlock    VAR Returned Largest Available XMS Block
  888. TotalK      VAR Returned Total XMS Size in KiloBytes
  889.  
  890. [RETURNS]
  891.  
  892. Function : XMS Error Code (0=Success)
  893. (VAR     : [MaxBlock] Largest Available XMS Block)
  894. (VAR     : [TotalK] Total XMS Size in KiloBytes)
  895.  
  896. [DESCRIPTION]
  897.  
  898. Returns both the Largest Available Extended Memory Service (XMS) Block
  899. but also the Total Size of the XMS in KiloBytes.
  900.  
  901. [SEE-ALSO]
  902.  
  903. [EXAMPLE]
  904.  
  905. -*)
  906.  
  907. Function VXMSGetFreeStat(          Var MaxBlock      : WORD;
  908.                                    Var TotalK        : WORD       ) : TXMSError;
  909.  
  910. Assembler;
  911. ASM
  912.  
  913.   PUSH DS
  914.  
  915.   MOV  AH, 8
  916.   CALL [XMSAddr]
  917.  
  918.   MOV  DS, word PTR [MaxBlock+2]
  919.   MOV  SI, word PTR [MaxBlock  ]
  920.  
  921.   MOV  ES, word PTR [TotalK+2]
  922.   MOV  DI, word PTR [TotalK  ]
  923.  
  924.   MOV  word PTR DS:SI, AX    {MaxBlock}
  925.   MOV  word PTR ES:DI, DX    {TotalK}
  926.  
  927.   MOV  AL, BL                {TXMSError}
  928.  
  929.   CMP  AL, 0
  930.   JE   @@1
  931.  
  932.   MOV  word PTR DS:SI, 0     {Error, MaxBlock = 0}
  933.  
  934.  @@1:
  935.  
  936.   POP  DS
  937.  
  938. END;
  939.  
  940. {────────────────────────────────────────────────────────────────────────────}
  941.  
  942. (*-
  943.  
  944. [FUNCTION]
  945.  
  946. Function VXMSGetMaxBlock                             : WORD;
  947.  
  948. [PARAMETERS]
  949.  
  950. (None)
  951.  
  952. [RETURNS]
  953.  
  954. Largest XMS Block Available
  955.  
  956. [DESCRIPTION]
  957.  
  958. Returns the Largest Available Extended Memory Service (XMS) Block.
  959. Value is in KiloBytes.
  960.  
  961. [SEE-ALSO]
  962.  
  963. [EXAMPLE]
  964.  
  965. -*)
  966.  
  967. Function VXMSGetMaxBlock                             : WORD;
  968.  
  969. Assembler;
  970. ASM
  971.  
  972.   MOV  AH, 8
  973.   CALL [XMSAddr]
  974.                              {XMS Max Block [AX]}
  975. END;
  976.  
  977. {────────────────────────────────────────────────────────────────────────────}
  978.  
  979. (*-
  980.  
  981. [FUNCTION]
  982.  
  983. Function VXMSGetTotalFreeK                           : WORD;
  984.  
  985. [PARAMETERS]
  986.  
  987. (None)
  988.  
  989. [RETURNS]
  990.  
  991. Total Free K of XMS Memory
  992.  
  993. [DESCRIPTION]
  994.  
  995. Returns the Total Number of Free KiloBytes of Extended Memory Service (XMS)
  996. Memory.
  997.  
  998. [SEE-ALSO]
  999.  
  1000. [EXAMPLE]
  1001.  
  1002. -*)
  1003.  
  1004. Function VXMSGetTotalFreeK                           : WORD;
  1005.  
  1006. Assembler;
  1007.  
  1008. ASM
  1009.  
  1010.   MOV  AH, 8
  1011.   CALL [XMSAddr]
  1012.  
  1013.   CMP  AX, 0
  1014.   JNE  @@1
  1015.  
  1016.   XOR  AX, AX                {Error, TotalFreeK = 0}
  1017.  
  1018.  @@1:
  1019.   MOV  AX, DX                {No Error, XMS Total Free K}
  1020.  
  1021.  @@2:
  1022.  
  1023. END;
  1024.  
  1025. {────────────────────────────────────────────────────────────────────────────}
  1026.  
  1027. (*-
  1028.  
  1029. [FUNCTION]
  1030.  
  1031. Function VXMBNew(                      SizeInK       : WORD;
  1032.                                    Var Handle        : TXMBHandle ) : TXMSError;
  1033.  
  1034. [PARAMETERS]
  1035.  
  1036. SizeInK     Desired XMB Memory Allocation in KiloBytes
  1037. Handle      VAR Returned XMB Memory Handle
  1038.  
  1039. [RETURNS]
  1040.  
  1041. Function : XMB Error Code (0=Success)
  1042. (VAR     : [Handle] XMB Memory Handle)
  1043.  
  1044. [DESCRIPTION]
  1045.  
  1046. Allocates memory to an XMB Memory Handle
  1047.  
  1048. [SEE-ALSO]
  1049.  
  1050. [EXAMPLE]
  1051.  
  1052. -*)
  1053.  
  1054. Function VXMBNew(                      SizeInK       : WORD;
  1055.                                    Var Handle        : TXMBHandle ) : TXMSError;
  1056.  
  1057. Assembler;
  1058. ASM
  1059.  
  1060.   PUSH DS
  1061.  
  1062.   MOV  AH, 9
  1063.   MOV  DX, SizeInK
  1064.   CALL [XMSAddr]
  1065.  
  1066.   CMP  AX, 1
  1067.   JE   @SUCCESS
  1068.  
  1069.   MOV  AL, BL
  1070.   JMP  @EXIT
  1071.  
  1072.  @SUCCESS:
  1073.  
  1074.   XOR  AL, AL
  1075.   MOV  DS, word PTR [Handle + 2]
  1076.   MOV  SI, word PTR [Handle]
  1077.   MOV  word PTR DS:SI, DX
  1078.  
  1079.  @EXIT:
  1080.  
  1081.   POP  DS
  1082.  
  1083. END;
  1084.  
  1085. {────────────────────────────────────────────────────────────────────────────}
  1086.  
  1087. (*-
  1088.  
  1089. [FUNCTION]
  1090.  
  1091. Function VXMBDispose(                  Handle        : TXMBHandle ) : TXMSError;
  1092.  
  1093. [PARAMETERS]
  1094.  
  1095. Handle      Handle to XMB Memory
  1096.  
  1097. [RETURNS]
  1098.  
  1099. XMB Error Code (0=Success)
  1100.  
  1101. [DESCRIPTION]
  1102.  
  1103. Frees memory associated with a previous allocated XMB Handle.
  1104.  
  1105. [SEE-ALSO]
  1106.  
  1107. [EXAMPLE]
  1108.  
  1109. -*)
  1110.  
  1111. Function VXMBDispose(                  Handle        : TXMBHandle ) : TXMSError;
  1112.  
  1113. Assembler;
  1114. ASM
  1115.  
  1116.   MOV  AH, $0A
  1117.   MOV  DX, Handle
  1118.   CALL [XMSAddr]
  1119.  
  1120.   CMP  AX, 1
  1121.   JE   @SUCCESS
  1122.  
  1123.   MOV  AL, BL
  1124.   JMP  @EXIT
  1125.  
  1126.  @SUCCESS:
  1127.  
  1128.   XOR  AL, AL
  1129.  
  1130.  @EXIT:
  1131.  
  1132. END;
  1133.  
  1134. {────────────────────────────────────────────────────────────────────────────}
  1135.  
  1136. (*-
  1137.  
  1138. [FUNCTION]
  1139.  
  1140. Function VXMBMove(                     MoveData      : PXMSMoveData) : TXMSError;
  1141.  
  1142. [PARAMETERS]
  1143.  
  1144. MoveData    Pointer to XMB Move Data Structure
  1145.  
  1146. [RETURNS]
  1147.  
  1148. XMB Error Code (0=Succes)
  1149.  
  1150. [DESCRIPTION]
  1151.  
  1152. Takes the XMB Move Data Structure and Moves the Data Accordingly.
  1153.  
  1154. Use XMBMoveBlock to Load the XMB Move Data Structure.
  1155.  
  1156. [SEE-ALSO]
  1157.  
  1158. [EXAMPLE]
  1159.  
  1160. -*)
  1161.  
  1162. Function VXMBMove(                     MoveData      : PXMSMoveData) : TXMSError;
  1163.  
  1164. Assembler;
  1165. ASM
  1166.  
  1167.   PUSH DS
  1168.   POP  ES
  1169.  
  1170.   MOV  AX, word PTR[MoveData+2 ]
  1171.   MOV  DS, AX
  1172.   MOV  SI, word PTR[MoveData   ]
  1173.   MOV  AH, $0B
  1174.   CALL [ES:XMSAddr]
  1175.  
  1176.   CMP  AX, 1
  1177.   JE   @SUCCESS
  1178.  
  1179.   MOV  AL, BL
  1180.   JMP  @EXIT
  1181.  
  1182.  @SUCCESS:
  1183.  
  1184.   XOR  AL, AL
  1185.  
  1186.  @EXIT:
  1187.  
  1188.   PUSH ES
  1189.   POP  DS
  1190.  
  1191. END;
  1192.  
  1193. {────────────────────────────────────────────────────────────────────────────}
  1194.  
  1195. (*-
  1196.  
  1197. [FUNCTION]
  1198.  
  1199. Function VXMBMoveBlock(                Count         : LONGINT;
  1200.                                        Source        : TXMBHandle;
  1201.                                        SourceOfs     : TXMSHandleOfs;
  1202.                                        Dest          : TXMBHandle;
  1203.                                        DestOfs       : TXMSHandleOfs ) : TXMSError;
  1204.  
  1205. [PARAMETERS]
  1206.  
  1207. Count       Number of Bytes to Move
  1208. Source      Source Address/Handle of Move Data
  1209. SourceOfs   Source Address/Handle Offset of Move Data
  1210. Dest        Destination Address/Handle of Move Data
  1211. DestOfs     Destination Address/Handle Offset of Move Data
  1212.  
  1213. [RETURNS]
  1214.  
  1215. XMB Error Code (0=Success)
  1216.  
  1217. [DESCRIPTION]
  1218.  
  1219. Moves a Block of Memory from the Source Address/XMB Handle to the
  1220. Destination Address/XMB Handle.  It is NOT Intended as a means of
  1221. Moving Main Memory Data to Main Memory but rather a means of moving
  1222. Data to/from XMB Memory.
  1223.  
  1224. [SEE-ALSO]
  1225.  
  1226. [EXAMPLE]
  1227.  
  1228. -*)
  1229.  
  1230. Function VXMBMoveBlock(                Count         : LONGINT;
  1231.                                        Source        : TXMBHandle;
  1232.                                        SourceOfs     : TXMSHandleOfs;
  1233.                                        Dest          : TXMBHandle;
  1234.                                        DestOfs       : TXMSHandleOfs ) : TXMSError;
  1235.  
  1236. Var
  1237.  
  1238.   Struct : TXMSMoveData;
  1239.  
  1240. BEGIN
  1241.  
  1242.   Struct.Count     := Count;
  1243.   Struct.Source    := Source;
  1244.   Struct.SourceOfs := SourceOfs;
  1245.   Struct.Dest      := Dest;
  1246.   Struct.DestOfs   := DestOfs;
  1247.  
  1248.   VXMBMoveBlock := VXMBMove( @Struct );
  1249.  
  1250. END;
  1251.  
  1252. {────────────────────────────────────────────────────────────────────────────}
  1253.  
  1254. (*-
  1255.  
  1256. [FUNCTION]
  1257.  
  1258. Function VXMBMoveMainToXMB(            Count         : WORD;
  1259.                                        FromPtr       : POINTER;
  1260.                                        ToHandle      : TXMBHandle;
  1261.                                        ToOfs         : TXMSHandleOfs ) : TXMSError;
  1262.  
  1263. [PARAMETERS]
  1264.  
  1265. Count       Number of Bytes to Move To XMB
  1266. FromPtr     Pointer to Source of Moving Data
  1267. ToHandle    Destination XMB Handle
  1268. ToHandleOfs Destination XMB Offset
  1269.  
  1270. [RETURNS]
  1271.  
  1272. XMB Error Code (0=Success)
  1273.  
  1274. [DESCRIPTION]
  1275.  
  1276. Moves a Block of Data from Main Memory (below 640K) to XMB Memory.
  1277.  
  1278. [SEE-ALSO]
  1279.  
  1280. [EXAMPLE]
  1281.  
  1282. -*)
  1283.  
  1284. Function VXMBMoveMainToXMB(            Count         : WORD;
  1285.                                        FromPtr       : POINTER;
  1286.                                        ToHandle      : TXMBHandle;
  1287.                                        ToOfs         : TXMSHandleOfs ) : TXMSError;
  1288. BEGIN
  1289.  
  1290.   VXMBMoveMainToXMB := VXMBMoveBlock( Count,
  1291.                                       0,
  1292.                                       LONGINT( FromPtr ),
  1293.                                       ToHandle,
  1294.                                       ToOfs     );
  1295. END;
  1296.  
  1297. {────────────────────────────────────────────────────────────────────────────}
  1298.  
  1299. (*-
  1300.  
  1301. [FUNCTION]
  1302.  
  1303. Function VXMBMoveXMBToMain(            Count         : WORD;
  1304.                                        ToPtr         : POINTER;
  1305.                                        FromHandle    : TXMBHandle;
  1306.                                        FromHandleOfs : TXMSHandleOfs ) : TXMSError;
  1307.  
  1308. [PARAMETERS]
  1309.  
  1310. Count         Number of Bytes to Move From XMB
  1311. ToPtr         Pointer to Destination of Moved XMB Data
  1312. FromHandle    Source XMB Handle
  1313. FromHandleOfs Source XMB Handle Offset
  1314.  
  1315. [RETURNS]
  1316.  
  1317. XMB Error Code
  1318.  
  1319. [DESCRIPTION]
  1320.  
  1321. Moves a Block of Data from XMB Memory to Main Memory (below 640K).
  1322.  
  1323. [SEE-ALSO]
  1324.  
  1325. [EXAMPLE]
  1326.  
  1327. -*)
  1328.  
  1329. Function VXMBMoveXMBToMain(            Count         : WORD;
  1330.                                        ToPtr         : POINTER;
  1331.                                        FromHandle    : TXMBHandle;
  1332.                                        FromHandleOfs : TXMSHandleOfs ) : TXMSError;
  1333.  
  1334. BEGIN
  1335.  
  1336.   VXMBMoveXMBToMain := VXMBMoveBlock( Count,
  1337.                                       FromHandle,
  1338.                                       FromHandleOfs,
  1339.                                       0,
  1340.                                       LONGINT( ToPtr ) );
  1341. END;
  1342.  
  1343. {────────────────────────────────────────────────────────────────────────────}
  1344.  
  1345. (*-
  1346.  
  1347. [FUNCTION]
  1348.  
  1349. Function VXMBLock(                     Handle        : TXMBHandle ) : TXMSError;
  1350.  
  1351. [PARAMETERS]
  1352.  
  1353. Handle      XMB Handle to Lock
  1354.  
  1355. [RETURNS]
  1356.  
  1357. XMB Error Code (0=Success)
  1358.  
  1359. [DESCRIPTION]
  1360.  
  1361. [SEE-ALSO]
  1362.  
  1363. [EXAMPLE]
  1364.  
  1365. -*)
  1366.  
  1367. Function VXMBLock(                     Handle        : TXMBHandle ) : TXMSError;
  1368.  
  1369. Assembler;
  1370. ASM
  1371.  
  1372.   MOV  AH, $0C
  1373.   MOV  DX, Handle
  1374.   CALL [XMSAddr]
  1375.  
  1376.   CMP  AX, 1
  1377.   JE   @SUCCESS
  1378.  
  1379.   MOV  AL, BL
  1380.   JMP  @EXIT
  1381.  
  1382.  @SUCCESS:
  1383.  
  1384.   XOR  AL, AL
  1385. { DX = High word of 32-bit linear address of locked block }
  1386. { BX = Low word of 32-bit linear address of locked block }
  1387.  
  1388.  @EXIT:
  1389.  
  1390. END;
  1391.  
  1392. {────────────────────────────────────────────────────────────────────────────}
  1393.  
  1394. (*-
  1395.  
  1396. [FUNCTION]
  1397.  
  1398. Function VXMBUnLock(                   Handle        : TXMBHandle ) : TXMSError;
  1399.  
  1400. [PARAMETERS]
  1401.  
  1402. Handle      XMB Handle to UnLock
  1403.  
  1404. [RETURNS]
  1405.  
  1406. XMB Error Code (0=Success)
  1407.  
  1408. [DESCRIPTION]
  1409.  
  1410. [SEE-ALSO]
  1411.  
  1412. [EXAMPLE]
  1413.  
  1414. -*)
  1415.  
  1416. Function VXMBUnLock(                   Handle        : TXMBHandle ) : TXMSError;
  1417.  
  1418. Assembler;
  1419. ASM
  1420.  
  1421.   MOV  AH, $0D
  1422.   MOV  DX, Handle
  1423.   CALL [XMSAddr]
  1424.  
  1425.   CMP  AX, 1
  1426.   JE   @SUCCESS
  1427.  
  1428.   MOV  AL, BL
  1429.   JMP  @EXIT
  1430.  
  1431.  @SUCCESS:
  1432.  
  1433.   XOR  AL, AL
  1434.  
  1435.  @EXIT:
  1436.  
  1437. END;
  1438.  
  1439. {────────────────────────────────────────────────────────────────────────────}
  1440.  
  1441. (*-
  1442.  
  1443. [FUNCTION]
  1444.  
  1445. Function VXMBGetInfo(                  Handle        : TXMBHandle;
  1446.                                    Var LockCount     : BYTE;
  1447.                                    Var FreeHandles   : BYTE;
  1448.                                    Var SizeInK       : WORD       ) : TXMSError;
  1449.  
  1450. [PARAMETERS]
  1451.  
  1452. Handle      XMB Handle
  1453. LockCount   VAR Returned Number of XMB Locks
  1454. FreeHandles VAR Returned Number of Free XMB Handles
  1455. SizeInK     VAR Returned XMB Handle Memory Allocation
  1456.  
  1457. [RETURNS]
  1458.  
  1459. Function : XMB Error Code
  1460. (VAR     : [LockCount] Number of XMB Locks)
  1461. (VAR     : [FreeHandles] Number of Free XMB Handles)
  1462. (VAR     : [SizeInK] XMB Handle Memory Allocation)
  1463.  
  1464. [DESCRIPTION]
  1465.  
  1466. [SEE-ALSO]
  1467.  
  1468. [EXAMPLE]
  1469.  
  1470. -*)
  1471.  
  1472. Function VXMBGetInfo(                  Handle        : TXMBHandle;
  1473.                                    Var LockCount     : BYTE;
  1474.                                    Var FreeHandles   : BYTE;
  1475.                                    Var SizeInK       : WORD       ) : TXMSError;
  1476.  
  1477. Assembler;
  1478. ASM
  1479.  
  1480.   PUSH DS
  1481.  
  1482.   MOV  AH, $0E
  1483.   MOV  DX, Handle
  1484.   CALL [XMSAddr]
  1485.  
  1486.   CMP  AX, 1
  1487.   JE   @SUCCESS
  1488.  
  1489.   MOV  AL, BL
  1490.   JMP  @EXIT
  1491.  
  1492.  @SUCCESS:
  1493.  
  1494.   XOR  AL, AL
  1495.   MOV  DS, word PTR [LockCount+2]
  1496.   MOV  SI, word PTR [LockCount  ]
  1497.   MOV  ES, word PTR [FreeHandles+2]
  1498.   MOV  DI, word PTR [FreeHandles  ]
  1499.   MOV  byte PTR DS:SI, BH    {LockCount}
  1500.   MOV  byte PTR ES:DI, BL    {FreeHandles}
  1501.  
  1502.   MOV  DS, word PTR [SizeInK+2]
  1503.   MOV  SI, word PTR [SizeInK  ]
  1504.   MOV  word PTR DS:SI, DX    {SizeInK}
  1505.  
  1506.  @EXIT:
  1507.  
  1508.   POP  DS
  1509.  
  1510. END;
  1511.  
  1512. {────────────────────────────────────────────────────────────────────────────}
  1513.  
  1514. (*-
  1515.  
  1516. [FUNCTION]
  1517.  
  1518. Function VXMBReSize(                   NewSizeK      : WORD;
  1519.                                        Handle        : TXMBHandle ) : TXMSError;
  1520.  
  1521. [PARAMETERS]
  1522.  
  1523. NewSizeK    New XMB Allocation for XMB Handle
  1524. Handle      Pre-Allocated Handle to XMB Memory
  1525.  
  1526. [RETURNS]
  1527.  
  1528. XMB Error Code (0=Success)
  1529.  
  1530. [DESCRIPTION]
  1531.  
  1532. [SEE-ALSO]
  1533.  
  1534. [EXAMPLE]
  1535.  
  1536. -*)
  1537.  
  1538. Function VXMBReSize(                   NewSizeK      : WORD;
  1539.                                        Handle        : TXMBHandle ) : TXMSError;
  1540.  
  1541. Assembler;
  1542. ASM
  1543.  
  1544.   MOV  AH, $0F
  1545.   MOV  BX, NewSizeK
  1546.   MOV  DX, Handle
  1547.   CALL [XMSAddr]
  1548.  
  1549.   CMP  AX, 1
  1550.   JE   @SUCCESS
  1551.  
  1552.   MOV  AL, BL
  1553.   JMP  @EXIT
  1554.  
  1555.  @SUCCESS:
  1556.  
  1557.   XOR  AL, AL
  1558.  
  1559.  @EXIT:
  1560.  
  1561. END;
  1562.  
  1563. {────────────────────────────────────────────────────────────────────────────}
  1564.  
  1565. (*-
  1566.  
  1567. [FUNCTION]
  1568.  
  1569. Function VUMBNew(                      SizeInPara    : WORD;
  1570.                                    Var SegOfUMB      : WORD;
  1571.                                    Var SizeAlloc     : WORD;
  1572.                                    Var MaxAvail      : WORD       ) : TXMSError;
  1573.  
  1574. [PARAMETERS]
  1575.  
  1576. SizeInPara  Size of Desired UMB Allocation in Paragraphs
  1577. SegOfUMB    VAR Returned Segment of UMB
  1578. SizeAlloc   VAR Returned Size Allocation
  1579. MaxAvail    VAR Returned Maximum UMB Space Available
  1580.  
  1581. [RETURNS]
  1582.  
  1583. Function : UMB Error Code (0=Success)
  1584. (VAR     : [SegOfUMB] Segment of UMB)
  1585. (VAR     : [SizeAlloc] Size Allocation)
  1586. (VAR     : [MaxAvail] Maximum UMB Space Available)
  1587.  
  1588. [DESCRIPTION]
  1589.  
  1590. Allocates an Upper Memory Block (UMB) of a Specified Number of Paragraphs.
  1591. And Returns the Memory Allocation Information or an Error Code.  Note that
  1592. MaxAvail is valid only if allocation error - if no error, it will be set
  1593. to $FFFF.
  1594.  
  1595. [SEE-ALSO]
  1596.  
  1597. [EXAMPLE]
  1598.  
  1599. -*)
  1600.  
  1601. Function VUMBNew(                      SizeInPara    : WORD;
  1602.                                    Var SegOfUMB      : WORD;
  1603.                                    Var SizeAlloc     : WORD;
  1604.                                    Var MaxAvail      : WORD       ) : TXMSError;
  1605.  
  1606. Assembler;
  1607. ASM
  1608.  
  1609.   PUSH DS
  1610.  
  1611.   MOV  AH, $10
  1612.   MOV  DX, SizeInPara
  1613.   CALL [XMSAddr]
  1614.  
  1615.   CMP  AX, 1
  1616.   JE   @SUCCESS
  1617.  
  1618.   MOV  AL, BL
  1619.   MOV  DS, word PTR [MaxAvail+2]
  1620.   MOV  SI, word PTR [MaxAvail  ]
  1621.   MOV  word PTR DS:SI, DX    {MaxAvail}
  1622.   JMP  @EXIT
  1623.  
  1624.  @SUCCESS:
  1625.  
  1626.   XOR  AL, AL
  1627.   MOV  DS, word PTR [SegOfUMB+2]
  1628.   MOV  SI, word PTR [SegOfUMB  ]
  1629.   MOV  ES, word PTR [SizeAlloc+2]
  1630.   MOV  DI, word PTR [SizeAlloc  ]
  1631.   MOV  word PTR [DS:SI], BX  {SegOfUMB}
  1632.   MOV  word PTR [ES:DI], DX  {SizeAlloc}
  1633.  
  1634.  @EXIT:
  1635.  
  1636.   POP  DS
  1637.  
  1638. END;
  1639.  
  1640. {────────────────────────────────────────────────────────────────────────────}
  1641.  
  1642. (*-
  1643.  
  1644. [FUNCTION]
  1645.  
  1646. Function VUMBDispose(                  SegOfUMB      : WORD       ) : TXMSError;
  1647.  
  1648. [PARAMETERS]
  1649.  
  1650. SegOfUMB    Segment Address of UMB
  1651.  
  1652. [RETURNS]
  1653.  
  1654. UMB Error Code (0=Success)
  1655.  
  1656. [DESCRIPTION]
  1657.  
  1658. [SEE-ALSO]
  1659.  
  1660. [EXAMPLE]
  1661.  
  1662. -*)
  1663.  
  1664. Function VUMBDispose(                  SegOfUMB      : WORD       ) : TXMSError;
  1665.  
  1666. Assembler;
  1667. ASM
  1668.  
  1669.   MOV  AH, $11
  1670.   MOV  DX, SegOfUMB
  1671.   CALL [XMSAddr]
  1672.  
  1673.   CMP  AX, 1
  1674.   JE   @SUCCESS
  1675.  
  1676.   MOV  AL, BL
  1677.   JMP  @EXIT
  1678.  
  1679.  @SUCCESS:
  1680.  
  1681.   XOR  AL, AL
  1682.  
  1683.  @EXIT:
  1684.  
  1685. END;
  1686.  
  1687. {────────────────────────────────────────────────────────────────────────────}
  1688.  
  1689. Function VUMBResize(                   SegOfUMB      : WORD;
  1690.                                        NewSize       : WORD       ) : TXMSError;
  1691.  
  1692. Assembler;
  1693. ASM
  1694.  
  1695.   MOV  AH, $12
  1696.   MOV  DX, SegOfUMB
  1697.   MOV  BX, NewSize
  1698.   CALL [XMSAddr]
  1699.  
  1700.   CMP  AX, 1
  1701.   JE   @SUCCESS
  1702.  
  1703.   MOV  AL, BL
  1704.   JMP  @EXIT
  1705.  
  1706.  @SUCCESS:
  1707.  
  1708.   XOR  AL, AL
  1709.  
  1710.  @EXIT:
  1711.  
  1712. END;
  1713.  
  1714. {────────────────────────────────────────────────────────────────────────────}
  1715.  
  1716. Function VXMSQueryFreeXM(          Var MaxBlock      : LONGINT;
  1717.                                    Var HighByte      : LONGINT;
  1718.                                    Var TotalK        : LONGINT    ) : TXMSError;
  1719.  
  1720. Assembler;
  1721. ASM
  1722.  
  1723.   MOV  AH, $88
  1724.   CALL [XMSAddr]
  1725.  
  1726.   MOV  AL, BL
  1727.  
  1728. END;
  1729.  
  1730. {────────────────────────────────────────────────────────────────────────────}
  1731.  
  1732. Function VXMSNew(                      SizeInK       : LONGINT;
  1733.                                    Var Handle        : TXMBHandle ) : TXMSError;
  1734.  
  1735. Assembler;
  1736. ASM
  1737.  
  1738.   MOV  AH, $89
  1739.   CALL [XMSAddr]
  1740.  
  1741.   CMP  AX, 1
  1742.   JE   @SUCCESS
  1743.  
  1744.   MOV  AL, BL
  1745.   JMP  @EXIT
  1746.  
  1747.  @SUCCESS:
  1748.  
  1749.   XOR  AL, AL
  1750.  
  1751.  @EXIT:
  1752.  
  1753. END;
  1754.  
  1755. {────────────────────────────────────────────────────────────────────────────}
  1756.  
  1757. Function VXMSGetInfo(                  Handle        : TXMBHandle;
  1758.                                    Var LockCount     : BYTE;
  1759.                                    Var FreeHandles   : WORD;
  1760.                                    Var SizeInK       : LONGINT    ) : TXMSError;
  1761.  
  1762. Assembler;
  1763. ASM
  1764.  
  1765.   MOV  AH, $8E
  1766.   MOV  DX, Handle
  1767.   CALL [XMSAddr]
  1768.  
  1769.   CMP  AX, 1
  1770.   JE   @SUCCESS
  1771.  
  1772.   MOV  AL, BL
  1773.   JMP  @EXIT
  1774.  
  1775.  @SUCCESS:
  1776.  
  1777.   XOR  AL, AL
  1778.  
  1779.  @EXIT:
  1780.  
  1781. END;
  1782.  
  1783. {────────────────────────────────────────────────────────────────────────────}
  1784.  
  1785. Function VXMSResize(                  Handle         : TXMBHandle;
  1786.                                       NewSizeK       : LONGINT    ) : TXMSError;
  1787.  
  1788. Assembler;
  1789. ASM
  1790.  
  1791.   MOV  AH, $8F
  1792.   MOV  DX, Handle
  1793. { MOV  EBX, NewSizeK }
  1794.   CALL [XMSAddr]
  1795.  
  1796.   CMP  AX, 1
  1797.   JE   @SUCCESS
  1798.  
  1799.   MOV  AL, BL
  1800.   JMP  @EXIT
  1801.  
  1802.  @SUCCESS:
  1803.  
  1804.   XOR  AL, AL
  1805.  
  1806.  @EXIT:
  1807.  
  1808. END;
  1809.  
  1810. {────────────────────────────────────────────────────────────────────────────}
  1811. {────────────────────────────────────────────────────────────────────────────}
  1812. {────────────────────────────────────────────────────────────────────────────}
  1813.  
  1814. BEGIN
  1815.  
  1816.   If VXMSInstalled Then
  1817.     VXMSGetHandleAddr
  1818.   Else
  1819.     XMSAddr := NIL;
  1820.  
  1821. END.
  1822.