DEVTABLE.ASM 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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/devtable.asm 1.2 1994/04/28 12:41:29 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 : DEVTABLE.ASM *
  26. ;* *
  27. ;* Programmer : Christopher Yates *
  28. ;* *
  29. ;* Last Update : 12 December, 1990 [CY] *
  30. ;* *
  31. ;* Updated to 32bit protected mode JAW *
  32. ;* *
  33. ;*-------------------------------------------------------------------------*
  34. ;* Functions: *
  35. ;* *
  36. ; VOID Init_Device_Table(BYTE *table); *
  37. ; WORD Max_Device(VOID); *
  38. ;* *
  39. ;* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
  40. IDEAL
  41. P386
  42. MODEL USE32 FLAT
  43. LOCALS ??
  44. DOS equ 21h
  45. GLOBAL Max_Device :NEAR
  46. GLOBAL get_max_device :NEAR
  47. GLOBAL Init_Device_Table :NEAR
  48. CODESEG
  49. ; ----------------------------------------------------------------
  50. ;
  51. ; Here are prototypes for the routines defined within this module:
  52. ;
  53. ; VOID Init_Device_Table(BYTE *table);
  54. ; WORD Max_Device(VOID);
  55. ;
  56. ; ----------------------------------------------------------------
  57. ;----------------------------------------------------------------------------
  58. ;
  59. ; WORD Max_Device(VOID);
  60. ;
  61. PROC Max_Device C NEAR
  62. call get_max_device ; get max devices in ax
  63. ret
  64. ENDP Max_Device
  65. ;----------------------------------------------------------------------------
  66. ;----------------------------------------------------------------------------
  67. ;
  68. ;
  69. ; returns max devices in AX
  70. PROC get_max_device C NEAR
  71. USES ebx,edx
  72. mov ah,25 ; get current drive service
  73. int DOS ; drive returned in al
  74. mov dl,al
  75. mov ah,14 ; set current as current drive
  76. int DOS
  77. dec al ; al = max drives, make it n - 1
  78. xor ah,ah ; clear high byte
  79. sub edx,edx
  80. mov edx,eax ; use dx to go backward to find out
  81. ; if DOS is lying (down)
  82. ??back_loop:
  83. push ds
  84. push ebx
  85. mov bl,dl ; find out about the drive in dl
  86. inc bl
  87. mov eax,0440Eh ; get the physical drive associated
  88. int DOS ; with this letter
  89. pop ebx
  90. pop ds
  91. jnc short ??later ; if c clear, no error
  92. cmp al,0Fh ; was it invalid? (0Fh = invalid)
  93. jne short ??later ; yes, so LATER
  94. dec edx
  95. jmp ??back_loop ; try, try again
  96. ??later:
  97. mov eax,edx ; restore ax
  98. ret
  99. ENDP get_max_device
  100. ;----------------------------------------------------------------------------
  101. ;----------------------------------------------------------------------------
  102. ;
  103. ; VOID Init_Device_Table(BYTE *table);
  104. ;
  105. PROC Init_Device_Table C NEAR
  106. USES eax,ebx,edi,edx
  107. ARG table:DWORD ; Pointer to device table.
  108. LOCAL curr_drive:BYTE ; Copy of current drive number.
  109. mov edi,[table]
  110. call get_max_device ; get max devices in ax
  111. add edi,eax
  112. std
  113. mov [curr_drive],al ; save it
  114. ??next_drive:
  115. mov dl,[curr_drive] ; copy current drive #
  116. cmp dl,0FFh ; are we done?
  117. je short ??later ; if so, later
  118. dec [curr_drive] ; dec our local drive #
  119. push ds
  120. push ebx
  121. mov bl,dl ; find out about the drive in dl
  122. inc bl
  123. mov eax,0440Eh ; get the physical drive associated
  124. int DOS ; with this letter
  125. pop ebx
  126. pop ds
  127. jnc short ??it_is_real ; jump if no error
  128. cmp al,01 ; 1 = invalid command,
  129. ; 0F = invalid device
  130. je short ??set_as_current ; 1? it is ok (RAM device)
  131. jmp short ??invalid ; 0Fh, it was not a device
  132. ??it_is_real:
  133. cmp al,0 ; was it a fixed device?
  134. je short ??set_as_current ; yes, it's ok
  135. dec al ; make it a drive #
  136. cmp al,dl ; is it a valid drive?
  137. je short ??set_as_current
  138. ;
  139. ; Device was logical and not active, so clear the entry
  140. ;
  141. ??invalid:
  142. xor al,al
  143. stosb
  144. cmp [curr_drive],0 ; are we done checking?
  145. jge ??next_drive ; no, go to next
  146. jmp short ??later
  147. ??set_as_current:
  148. mov al,1
  149. stosb
  150. cmp dl,0 ; are we before the A drive (invalid)
  151. jl short ??later ; yes, we are done checking
  152. jmp ??next_drive ; keep processing
  153. ??later:
  154. cld
  155. ret
  156. ENDP Init_Device_Table
  157. ;----------------------------------------------------------------------------
  158. END
  159.