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

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Equipment Determination Unit (VEQUIP)
  5.    Version 0.11
  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.  jrt       12/28/93  Added GetCpuTypeStr, yanked GetConsoleInfo funcs.
  17.  
  18.  mep       04/15/93  Added GetCPUType
  19.  
  20.  lpg       03/15/93  Added Source Decumentation
  21.  
  22.  mep       02/11/93  Cleaned up code for beta release
  23.  
  24.  jrt       02/08/93  Sync with beta 0.12 release
  25.  
  26.  jrt       12/15/92  Updated to work in protected mode for BP 7.0
  27.  
  28.  jrt       12/07/92  Sync with beta 0.11 release
  29.  
  30.  lpg       11/30/92  Added New functions & Merged Beta 008 - 009
  31.  
  32.  jrt       11/25/92  brought GetConsoleInfo over from VCRT
  33.                      added Primary/AlternateConsoleIsColor functions
  34.  
  35.  lpg       11/24/92  Slightly modified (ASM)
  36.  
  37.  jrt       11/21/92  Sync with beta 0.08
  38.  
  39.  jrt       11/18/92  First logged revision.
  40.  
  41.  ────────────────────────────────────────────────────────────────────────────
  42.  
  43.  Notes:
  44.  
  45.    add funcs to report what I/O port serial ports are at
  46.    add funcs to report what i/o port par    ports are at
  47.  
  48.    check for presence of weitek coprocessor
  49.  
  50.    load SI with 0 before all INT $11 calls
  51.  
  52.  ════════════════════════════════════════════════════════════════════════════
  53. }
  54.  
  55. (*-
  56.  
  57. [TEXT]
  58.  
  59. <Overview>
  60.  
  61. This unit implements functions which return information about the
  62. equipment that is currently connected to the PC on which the unit
  63. is running.
  64.  
  65. The documentation for this unit will be enhanced in the next release.
  66.  
  67. <Interface>
  68.  
  69. -*)
  70.  
  71.  
  72. Unit VEquipu;
  73.  
  74. Interface
  75.  
  76. Uses
  77.  
  78.   DOS;
  79.  
  80. {────────────────────────────────────────────────────────────────────────────}
  81.  
  82. Const
  83.  
  84.   { Equipment Constants }
  85.  
  86.   ec8086  = 1;
  87.   ec80286 = 2;
  88.   ec80386 = 3;
  89.   ec80486 = 4;
  90. {────────────────────────────────────────────────────────────────────────────}
  91.  
  92. Function  BIOSNameByte                                       : BYTE;
  93.  
  94. Function  BIOSDate                                           : STRING;
  95.  
  96. Function  FloppyPresent                                      : BOOLEAN;
  97.  
  98. Function  MathChipPresent                                    : BOOLEAN;
  99.  
  100. Function  PointingDevicePresent                              : BOOLEAN;
  101.  
  102. Function  NumFloppies                                        : INTEGER;
  103.  
  104. Function  NumRS232Cards                                      : INTEGER;
  105.  
  106. Function  GamePortPresent                                    : BOOLEAN;
  107.  
  108. Function  SerialPrinterPresent                               : BOOLEAN;  {PCJr Only}
  109.  
  110. Function  InternalModemPresent                               : BOOLEAN;  {Non-PCjr}
  111.  
  112. Function  NumPrinters                                        : INTEGER;
  113.  
  114. Function  GetCPUType                                         : BYTE;
  115.  
  116. Function  GetCPUTypeStr                                      : STRING;
  117.  
  118. {────────────────────────────────────────────────────────────────────────────}
  119.  
  120.  
  121. IMPLEMENTATION
  122.  
  123. {────────────────────────────────────────────────────────────────────────────}
  124.  
  125. (*-
  126.  
  127. [FUNCTION]
  128.  
  129. Function BiosName                                            : BYTE;
  130.  
  131. [PARAMETERS]
  132.  
  133. (None)
  134.  
  135. [RETURNS]
  136.  
  137. The BIOS Name ID Byte
  138.  
  139. [DESCRIPTION]
  140.  
  141. Reads and Returns the System BIOS Name ID Byte.  These are as follows:
  142.   ...
  143.   ...
  144.   ...
  145.   ...
  146.  
  147. { gets the name of the motherboard bios }
  148.  
  149.  
  150. [SEE-ALSO]
  151.  
  152. [EXAMPLE]
  153.  
  154. -*)
  155.  
  156. Function BiosNameByte                                        : BYTE;
  157.  
  158. Assembler;
  159. ASM
  160.  
  161.   PUSH DS
  162.   MOV AX, $F000
  163.   MOV DS, AX
  164.   MOV SI, $FFFE
  165.  
  166.   MOV AL, byte PTR [DS:SI]
  167.  
  168.   POP DS
  169.  
  170. END;
  171.  
  172. {────────────────────────────────────────────────────────────────────────────}
  173.  
  174. (*-
  175.  
  176. [FUNCTION]
  177.  
  178. Function BIOSDate                                            : STRING;
  179.  
  180. [PARAMETERS]
  181.  
  182. (None)
  183.  
  184. [RETURNS]
  185.  
  186. The BIOS Date String
  187.  
  188. [DESCRIPTION]
  189.  
  190. Reads and Returns the BIOS Date String
  191.  
  192.   { gets the date of the motherboard bios }
  193.  
  194. [SEE-ALSO]
  195.  
  196. [EXAMPLE]
  197.  
  198. -*)
  199.  
  200. Function BIOSDate                                            : STRING;
  201.  
  202. Var
  203.  
  204.   R : REGISTERS;
  205.   S : STRING;
  206.  
  207. BEGIN
  208.  
  209.   Move( Mem[ $F000 : $FFF5 ], S[1], 8 );
  210.   S[ 0 ] := CHAR( 8 );
  211.   BIOSDate := S;
  212.  
  213. END;  { BIOSDate }
  214.  
  215. {────────────────────────────────────────────────────────────────────────────}
  216.  
  217. (*-
  218.  
  219. [FUNCTION]
  220.  
  221. Function FloppyPresent                                     : BOOLEAN;
  222.  
  223. [PARAMETERS]
  224.  
  225. (None)
  226.  
  227. [RETURNS]
  228.  
  229. Whether a Floppy Drive is Installed. (TRUE=Yes)
  230.  
  231. [DESCRIPTION]
  232.  
  233. Tests and Returns whether even a single Floppy Drive is Installed in
  234. the system.
  235.  
  236.   { returns TRUE if floppy drive is installed }
  237.  
  238. [SEE-ALSO]
  239.  
  240. [EXAMPLE]
  241.  
  242. -*)
  243.  
  244. Function FloppyPresent                                     : BOOLEAN;
  245.  
  246. Assembler;
  247. ASM
  248.  
  249.   INT $11          { 0000 0000 - 0000 0001 }
  250.   AND AL, $01
  251.  
  252. END;
  253.  
  254. {────────────────────────────────────────────────────────────────────────────}
  255.  
  256. (*-
  257.  
  258. [FUNCTION]
  259.  
  260. Function MathChipPresent                                       : BOOLEAN;
  261.  
  262. [PARAMETERS]
  263.  
  264. (None)
  265.  
  266. [RETURNS]
  267.  
  268. Whether a Math Co-Processor Chip is Installed (TRUE=Yes)
  269.  
  270. [DESCRIPTION]
  271.  
  272. Tests and Returns whether a Math CoProcessor Chip is installed in the
  273. system.
  274.  
  275.   { returns TRUE if Math Co-Processor exists }
  276.  
  277. [SEE-ALSO]
  278.  
  279. [EXAMPLE]
  280.  
  281. -*)
  282.  
  283. Function MathChipPresent                                       : BOOLEAN;
  284.  
  285. Assembler;
  286. ASM
  287.  
  288.   INT $11          { 0000 0000 - 0000 0010 }
  289.   AND AL, $02
  290.   SHR AL, 1
  291.  
  292. END;
  293.  
  294. {────────────────────────────────────────────────────────────────────────────}
  295.  
  296. (*-
  297.  
  298. [FUNCTION]
  299.  
  300. Function PointingDevicePresent                                : BOOLEAN;
  301.  
  302. [PARAMETERS]
  303.  
  304. (None)
  305.  
  306. [RETURNS]
  307.  
  308. Whether a Pointing Device Exists (TRUE=Yes)
  309.  
  310. [DESCRIPTION]
  311.  
  312. Tests and Returns whether any type of Pointing Device is attached to
  313. the system.  This includes a Mouse, Light Pen, etc.
  314.  
  315.   { returns TRUE if a pointing device is present }
  316.  
  317. [SEE-ALSO]
  318.  
  319. [EXAMPLE]
  320.  
  321. -*)
  322.  
  323. Function PointingDevicePresent                                : BOOLEAN;
  324.  
  325. Assembler;
  326. ASM
  327.  
  328.   INT  $11         { 0000 0000 - 0000 0100 }
  329.  
  330.   AND  AL, $04
  331.   SHR  AL, 1
  332.   SHR  AL, 1
  333.  
  334. END;
  335.  
  336. {────────────────────────────────────────────────────────────────────────────}
  337.  
  338. (*-
  339.  
  340. [FUNCTION]
  341.  
  342. Function NumFloppies                                         : INTEGER;
  343.  
  344. [PARAMETERS]
  345.  
  346. (None)
  347.  
  348. [RETURNS]
  349.  
  350. The Number of Floppy Drives Attached
  351.  
  352. [DESCRIPTION]
  353.  
  354. Tests and Returns the Number of Floppy Drives Attached to the System.
  355.  
  356.   { returns the number of installed floppies }
  357.  
  358. [SEE-ALSO]
  359.  
  360. [EXAMPLE]
  361.  
  362. -*)
  363.  
  364. Function NumFloppies                                         : INTEGER;
  365.  
  366. Assembler;
  367. ASM
  368.  
  369.   INT  $11                   { 0000 0000 - 1100 0000 }
  370.  
  371.   AND  AX, $00C0
  372.   MOV  CL, 6
  373.   SHR  AX, CL
  374.  
  375. END;  { NumFloppies }
  376.  
  377. {────────────────────────────────────────────────────────────────────────────}
  378.  
  379. (*-
  380.  
  381. [FUNCTION]
  382.  
  383. Function NumRS232Cards                                       : INTEGER;
  384.  
  385. [PARAMETERS]
  386.  
  387. (None)
  388.  
  389. [RETURNS]
  390.  
  391. The Number of RS-232 Cards Attached
  392.  
  393. [DESCRIPTION]
  394.  
  395. Attempts to Detect the Number of RS-232 Cards that are attached to the
  396. system.
  397.  
  398.   { returns the number of RS-232 ports }
  399.  
  400. [SEE-ALSO]
  401.  
  402. [EXAMPLE]
  403.  
  404. -*)
  405.  
  406. Function NumRS232Cards                                       : INTEGER;
  407.  
  408. Assembler;
  409. ASM
  410.  
  411.   INT  $11         { 0000 1110 - 0000 0000 }
  412.  
  413.   MOV  AL, AH
  414.   XOR  AH, AH
  415.   SHR  AL, 1
  416.  
  417. END;
  418.  
  419. {────────────────────────────────────────────────────────────────────────────}
  420.  
  421. (*-
  422.  
  423. [FUNCTION]
  424.  
  425. Function GamePortExists                                      : BOOLEAN;
  426.  
  427. [PARAMETERS]
  428.  
  429. (None)
  430.  
  431. [RETURNS]
  432.  
  433. Whether a Game Port Exits (TRUE=Yes)
  434.  
  435. [DESCRIPTION]
  436.  
  437. Tests and Returns whether a Game Port Present.
  438.  
  439.   { returns TRUE if a joystick port Present }
  440.  
  441. [SEE-ALSO]
  442.  
  443. [EXAMPLE]
  444.  
  445. -*)
  446.  
  447. Function GamePortPresent                                      : BOOLEAN;
  448.  
  449. Assembler;
  450. ASM
  451.  
  452.   INT  $11         { 0001 0000 - 0000 0000 }
  453.  
  454.   MOV  AL, AH
  455.   MOV  CL, 4
  456.   SHR  AL, CL
  457.  
  458. END;
  459.  
  460. {────────────────────────────────────────────────────────────────────────────}
  461.  
  462. (*-
  463.  
  464. [FUNCTION]
  465.  
  466. Function SerialPrinterPresent                                 : BOOLEAN;
  467.  
  468. [PARAMETERS]
  469.  
  470. (None)
  471.  
  472. [RETURNS]
  473.  
  474. Whether a Serial Printer Present (TRUE=Yes)
  475.  
  476. [DESCRIPTION]
  477.  
  478. Attempts to Detect and Report whether a Serial Printer is attached to the
  479. System and Active (ie. Turned On).
  480.  
  481. Test Valid for PCJr Systems Only.
  482.  
  483. [SEE-ALSO]
  484.  
  485. [EXAMPLE]
  486.  
  487. -*)
  488.  
  489. Function SerialPrinterPresent                                 : BOOLEAN;
  490.  
  491. Assembler;
  492. ASM
  493.  
  494.   INT  $11         { 0010 0000 - 0000 0000  - PCjr Only! }
  495.  
  496.   MOV  AL, AH
  497.   MOV  CL, 5
  498.   SHR  AL, CL
  499.  
  500. END;
  501.  
  502. {────────────────────────────────────────────────────────────────────────────}
  503.  
  504. (*-
  505.  
  506. [FUNCTION]
  507.  
  508. Function InternalModemPresent                                 : BOOLEAN;
  509.  
  510. [PARAMETERS]
  511.  
  512. (None)
  513.  
  514. [RETURNS]
  515.  
  516. Whether an Internal Modem Present (TRUE=Yes)
  517.  
  518. [DESCRIPTION]
  519.  
  520. Tests and Returns whether an Internal Modem Present.
  521.  
  522. Test Valid only for Non-PCjr Systems.
  523.  
  524. [SEE-ALSO]
  525.  
  526. [EXAMPLE]
  527.  
  528. -*)
  529.  
  530. Function InternalModemPresent                                 : BOOLEAN;
  531.  
  532. Assembler;
  533. ASM
  534.  
  535.   INT  $11         { 0010 0000 - 0000 0000   - Non-PCjr }
  536.  
  537.   MOV  AL, AH
  538.   MOV  CL, 5
  539.   SHR  AL, CL
  540.  
  541. END;
  542.  
  543. {────────────────────────────────────────────────────────────────────────────}
  544.  
  545. (*-
  546.  
  547. [FUNCTION]
  548.  
  549. Function NumPrinters                                         : INTEGER;
  550.  
  551. [PARAMETERS]
  552.  
  553. (None)
  554.  
  555. [RETURNS]
  556.  
  557. Number of Printers Attached
  558.  
  559. [DESCRIPTION]
  560.  
  561. Attempts to Detect and Report the Number of Printers Attached to the
  562. System and Active (ie. Turned On).
  563.  
  564.   { returns number of LPT ports }
  565.  
  566. [SEE-ALSO]
  567.  
  568. [EXAMPLE]
  569.  
  570. -*)
  571.  
  572. Function NumPrinters                                         : INTEGER;
  573.  
  574. Assembler;
  575. ASM
  576.  
  577.   INT  $11         { 1100 0000 - 0000 0000 }
  578.  
  579.   MOV  AL, AH
  580.   MOV  CL, 6
  581.   SHR  AL, CL
  582.  
  583.   XOR  AH, AH
  584.  
  585. END;
  586.  
  587. {────────────────────────────────────────────────────────────────────────────}
  588.  
  589. (*-
  590.  
  591. [FUNCTION]
  592.  
  593. Function  GetCPUType                                         : BYTE;
  594.  
  595. [PARAMETERS]
  596.  
  597. (None)
  598.  
  599. [RETURNS]
  600.  
  601. Type of microprocessor in system (1=8086, 2=80286, 3=80386, 4=80486)
  602.  
  603. [DESCRIPTION]
  604.  
  605. Finds the type of microprocessor being used with a system.
  606.  
  607. [SEE-ALSO]
  608.  
  609. [EXAMPLE]
  610.  
  611. -*)
  612.  
  613.   {────────────────────────────────────────────────────────────────────────
  614.  
  615.   Function given public domain from Salim Samaha.
  616.  
  617.   ────────────────────────────────────────────────────────────────────────}
  618.  
  619. Function  GetCPUType                                         : BYTE;
  620.  
  621. Assembler;
  622. ASM
  623.  
  624.   MOV   DX, ec8086
  625.   PUSH  SP
  626.   POP   AX
  627.   CMP   SP,AX
  628.   JNE   @OUT
  629.   MOV   DX, ec80286
  630.   PUSHF
  631.  
  632.   POP   AX
  633.   OR    AX,4000h
  634.   PUSH  AX
  635.   POPF
  636.   PUSHF
  637.   POP   AX
  638.   TEST  AX,4000h
  639.   JE    @OUT
  640.   MOV   DX, ec80386
  641.  
  642. {"DB 66h" indicates '386 extended instruction}
  643.  
  644.   DB 66h; MOV   BX, SP      {MOV EBX, ESP}
  645.   DB 66h, 83h,  0E4h, 0FCh  {AND ESP, FFFC}
  646.   DB 66h; PUSHF             {PUSHFD}
  647.   DB 66h; POP   AX          {POP EAX}
  648.   DB 66h; MOV   CX, AX      {MOV ECX, EAX}
  649.   DB 66h, 35h,  00h
  650.   DB 00h, 04h,  00          {XOR EAX, 00040000}
  651.   DB 66h; PUSH  AX          {PUSH EAX}
  652.  
  653.   DB 66h; POPF              {POPFD}
  654.   DB 66h; PUSHF             {PUSHFD}
  655.   DB 66h; POP   AX          {POP EAX}
  656.   DB 66h, 25h,  00h
  657.   DB 00h, 04h,  00h         {AND EAX, 00040000}
  658.   DB 66h, 81h,  0E1h, 00h
  659.   DB 00h, 04h,  00h         {AND ECX, 00040000}
  660.   DB 66h; CMP   AX, CX      {CMP EAX, ECX}
  661.   JE @Not486
  662.   MOV DX, ec80486
  663.  
  664.   @Not486:
  665.  
  666.   DB 66h; PUSH   CX         {PUSH EXC}
  667.   DB 66h; POPF              {POPFD}
  668.   DB 66h; MOV   SP, BX      {MOV ESP, EBX}
  669.  
  670.   @Out:
  671.  
  672.   MOV AX, DX
  673.  
  674. END;
  675.  
  676. {────────────────────────────────────────────────────────────────────────────}
  677.  
  678. (*-
  679.  
  680. [FUNCTION]
  681.  
  682. Function  GetCPUTypeStr                                       : STRING;
  683.  
  684. [PARAMETERS]
  685.  
  686. (None)
  687.  
  688. [RETURNS]
  689.  
  690. Type of microprocessor in system ('8086', '80286', '80386', '80486' )
  691.  
  692. [DESCRIPTION]
  693.  
  694. Finds the type of microprocessor being used with the system.
  695.  
  696. [SEE-ALSO]
  697.  
  698. [EXAMPLE]
  699.  
  700. -*)
  701.  
  702.  
  703. Function GetCPUTypeStr                                        : STRING;
  704.  
  705. BEGIN
  706.  
  707.   Case GetCPUType of
  708.  
  709.     ec8086  : GetCPUTypeStr := '8086';
  710.     ec80286 : GetCPUTypeStr := '80286';
  711.     ec80386 : GetCPUTypeStr := '80386';
  712.     ec80486 : GetCPUTypeStr := '80486';
  713.  
  714.   Else
  715.  
  716.     GetCPUTypeStr := 'Unknown';
  717.  
  718.   END;
  719.  
  720. END;
  721.  
  722.  
  723. {────────────────────────────────────────────────────────────────────────────}
  724.  
  725. {────────────────────────────────────────────────────────────────────────────}
  726. {────────────────────────────────────────────────────────────────────────────}
  727.  
  728. BEGIN
  729. END.
  730.