DEVICES.ASM 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ;
  2. ; Command & Conquer Red Alert(tm)
  3. ; Copyright 2025 Electronic Arts Inc.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 3 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ; $Header: g:/library/wwlib32/system/rcs/devices.asm 1.2 1994/04/28 12:41:41 jeff_wilson Exp $
  19. ;***************************************************************************
  20. ;** C O N F I D E N T I A L --- W E S T W O O D A S S O C I A T E S **
  21. ;***************************************************************************
  22. ;* *
  23. ;* Project Name : LIBRARY *
  24. ;* *
  25. ;* File Name : DEVICES.ASM *
  26. ;* *
  27. ;* Programmer : Christopher Yates *
  28. ;* *
  29. ;* Last Update : 12 December, 1990 [CY] *
  30. ;* *
  31. ;*-------------------------------------------------------------------------*
  32. ;* Functions: *
  33. ;* *
  34. ; VOID Get_Devices(VOID); *
  35. ; WORD Is_Device_Real(WORD drive); *
  36. ;* *
  37. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  38. ;----------------------------------------------------------------------------
  39. IDEAL
  40. P386
  41. MODEL USE32 FLAT
  42. GLOBAL Get_Devices :NEAR
  43. GLOBAL Is_Device_Real :NEAR
  44. GLOBAL MaxDevice :BYTE
  45. GLOBAL DefaultDrive :BYTE
  46. ; ----------------------------------------------------------------
  47. ;
  48. ; Here are prototypes for the routines defined within this module:
  49. ;
  50. ; VOID Get_Devices(VOID);
  51. ; WORD Is_Device_Real(WORD drive);
  52. ;
  53. ; ----------------------------------------------------------------
  54. CODESEG
  55. ;***********************************************************
  56. ;
  57. ; GET_DEVICES
  58. ;
  59. ; VOID Get_Devices(VOID);
  60. ;
  61. ; This routine establishes the default disk drive and the maximum drive
  62. ; available in the current system.
  63. ;
  64. ;*
  65. DOS equ 21h
  66. PROC Get_Devices C near
  67. USES eax,ebx,edx
  68. sub eax,eax
  69. mov ah,25 ; get current drive service
  70. int DOS ; drive returned in al
  71. mov [DefaultDrive],al ; save it
  72. mov dl,al
  73. mov ah,14 ; set current as current drive
  74. int DOS
  75. dec al ; al = max drives, make it n - 1
  76. xor ah,ah ; clear high byte
  77. mov edx,eax ; use dx to go backward to find out
  78. sub ebx,ebx
  79. ??back_loop:
  80. mov bl,dl ; find out about the drive in dl
  81. inc bl
  82. mov eax,0440Eh ; get the physical drive associated
  83. int DOS ; with this letter
  84. jnc short ??later ; if c clear, no error
  85. cmp al,0Fh ; was it invalid? (0Fh = invalid)
  86. jne short ??later ; yes, so LATER
  87. dec edx
  88. jmp ??back_loop ; try, try again
  89. ??later:
  90. mov eax,edx ; restore ax
  91. mov [MaxDevice],al ; save the max drive #
  92. ret
  93. ENDP Get_Devices
  94. ;***************************************************************
  95. ;***************************************************************
  96. ;
  97. ; IS_DEVICE_REAL
  98. ;
  99. ; WORD Is_Device_Real(WORD drive);
  100. ;
  101. ; This routine will tell whether or not a device is a true
  102. ; phisical one. Send it the drive # to check.
  103. ;
  104. ;*
  105. PROC Is_Device_Real C near
  106. USES ebx,edx
  107. ARG drive:WORD
  108. sub edx,edx
  109. mov dx,[drive]
  110. ??next_drive:
  111. push ebx
  112. mov bl,dl ; find out about the drive in dl
  113. inc bl
  114. mov eax,0440Eh ; get the physical drive associated
  115. int DOS ; with this letter
  116. pop ebx
  117. jnc short ??it_is_real ; jump if no error
  118. cmp al,01 ; 1 = invalid command,
  119. ; 0F = invalid device
  120. je short ??real ; 1? it is ok (RAM device)
  121. jmp short ??invalid ; 0Fh, it was not a device
  122. ??it_is_real:
  123. cmp al,0 ; was it a fixed device?
  124. je short ??real ; yes, it's ok
  125. dec al ; make it a drive #
  126. cmp al,dl ; is it a valid drive?
  127. je short ??real
  128. ??invalid: ; The device is invalid.
  129. mov eax,0
  130. jmp short ??out
  131. ??real: ; Return true, for valid device.
  132. mov eax,1
  133. ??out:
  134. ret
  135. ENDP Is_Device_Real
  136. ;***************************************************************
  137. END
  138.