DOS 3.30 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
5.6 KiB

4 years ago
  1. TITLE MSCON - DOS 3.3
  2. ;----------------------------------------------------------------
  3. ; :
  4. ; C O N - CONSOLE DEVICE DRIVER :
  5. ; :
  6. ; :
  7. ; This file contains the Console Device Driver. The :
  8. ; console device driver sends characters to the moniter and :
  9. ; gets characters from the keyboard. :
  10. ; :
  11. ;----------------------------------------------------------------
  12. ;;Rev 3.30 Modification
  13. test=0
  14. INCLUDE MSGROUP.INC ;DEFINE CODE SEGMENT
  15. INCLUDE JUMPMAC.INC
  16. INCLUDE MSEQU.INC
  17. INCLUDE MSMACRO.INC
  18. EXTRN EXIT:NEAR ;MSBIO1
  19. EXTRN BUS$EXIT:NEAR ;MSBIO1
  20. ;DATA
  21. EXTRN PTRSAV:DWORD ;MSBIO1
  22. EXTRN FHAVEK09:BYTE ;MSDISK
  23. EXTRN ALTAH:BYTE ;MSDATA
  24. ;;End of Modification
  25. ;----------------------------------------------------------------
  26. ; :
  27. ; Console read routine :
  28. ; :
  29. ;----------------------------------------------------------------
  30. ;
  31. ASSUME DS:CODE ; THIS WAS SET BY THE CON DD ENTRY PT
  32. PUBLIC CON$READ
  33. CON$READ PROC NEAR
  34. ; if CX is zero, no characters
  35. jcxz CON$EXIT ; to be read -- just exit
  36. CON$LOOP:
  37. call CHRIN ; get char in AL
  38. stosb ; store char at ES:DI, specified buffer
  39. loop CON$LOOP ; if CX is non-zero more char to read
  40. CON$EXIT:
  41. Jump EXIT ; all done, successful return
  42. CON$READ ENDP
  43. ;----------------------------------------------------------------
  44. ; :
  45. ; Input single character into AL :
  46. ; :
  47. ;----------------------------------------------------------------
  48. CHRIN PROC NEAR
  49. ; set command to read character
  50. xor AX, AX ; and clear AL
  51. xchg AL,ALTAH ; get character & zero ALTAH
  52. or AL, AL ; see if buffer has a character
  53. jnz KEYRET ; if so - return this character
  54. ; if not - read single character
  55. int 16h ; call ROM-Bios keyboard routine
  56. ALT10:
  57. or AX,AX ; Check for non-key after BREAK
  58. jz CHRIN
  59. cmp AX,7200h ; Check for CTRL-PRTSC
  60. jnz ALT15
  61. mov AL,16 ; indicate prtsc
  62. ALT15:
  63. or AL,AL ; special case?
  64. jnz KEYRET ; no, return with character
  65. mov ALTAH, AH ; yes, store special key
  66. KEYRET:
  67. RET
  68. CHRIN ENDP
  69. ;----------------------------------------------------------------
  70. ; :
  71. ; Keyboard non destructive read, no wait :
  72. ; :
  73. ; If bit 10 is set by the DOS in the status word of the request :
  74. ; packet, and there is no character in the input buffer, the :
  75. ; driver issues a system WAIT request to the ROM. On return :
  76. ; from the ROM, it returns a 'char-not-found' to the DOS. :
  77. ; :
  78. ;----------------------------------------------------------------
  79. CONBUSJ:
  80. ASSUME DS:NOTHING
  81. JMP CONBUS
  82. ASSUME DS:CODE ; THIS WAS SET BY THE CON DD ENTRY PT
  83. PUBLIC CON$RDND
  84. CON$RDND:
  85. mov AL,[ALTAH] ; first see if there is a
  86. or AL,AL ; character in the buffer?
  87. jz RD1 ; with debugging code it is
  88. jmp RDEXIT ; too far for conditional jump
  89. RD1:
  90. ; set command to 'see if
  91. mov AH, 1 ; character available'
  92. int 16h ; call ROM-BIOS keyboard routine
  93. jz nochr ; with debugging code it is
  94. jmp gotchr ; to far for conditional jump
  95. nochr:
  96. cmp fHaveK09, 0
  97. jz CONBUSJ
  98. lds bx,[PTRSAV] ; get pointer to request header
  99. ASSUME DS:NOTHING
  100. test [bx].STATUS,0400H ; System WAIT enabled?
  101. jz CONBUSJ ; no, get out
  102. message ftestcon,<"System WAIT stage",cr,lf>
  103. mov AX, 4100h ; set command for Wait on External
  104. ; event and condition type to
  105. ; any external event
  106. xor BL,BL ; no timeout value
  107. int 15h ; call rom-bios sleep function
  108. message ftestcon,<"Out of wait. AX is ">
  109. mnum ftestcon,ax
  110. message ftestcon,<cr,lf>
  111. jmp CONBUS ; after wait exit to con busy
  112. ASSUME DS:CODE
  113. gotchr:
  114. or AX, AX ; check for null after break
  115. JNZ NOTBRK ; no, skip down
  116. ; note: AH is already zero, no need to set command
  117. int 16h ;SB ; yes, read the null
  118. Jump CON$RDND ; and get a real status
  119. NOTBRK:
  120. cmp AX, 7200H ; check for ctrl-prtsc
  121. jnz RDEXIT ; no
  122. mov AL, 16 ; yes, indicate ctrl-prtsc
  123. PUBLIC RDEXIT
  124. RDEXIT:
  125. lds BX, [PTRSAV] ; get pointer to request header
  126. ASSUME DS:NOTHING
  127. mov [BX].MEDIA, AL ; move character into req. header
  128. EXVEC:
  129. Jump EXIT ; all done -- successful return
  130. CONBUS:
  131. ASSUME DS:NOTHING
  132. Jump BUS$EXIT ; done -- con device is busy
  133. ;----------------------------------------------------------------
  134. ; :
  135. ; Keyboard flush routine :
  136. ; :
  137. ;----------------------------------------------------------------
  138. ASSUME DS:CODE ; THIS WAS SET BY THE CON DD ENTRY PT
  139. PUBLIC CON$FLSH
  140. CON$FLSH:
  141. call FLUSH
  142. Jump Exit
  143. PUBLIC FLUSH
  144. FLUSH:
  145. mov [ALTAH], 0 ; clear out holding buffer
  146. FlLoop:
  147. ;;Rev 3.30 Modification
  148. ; Is there a char there?
  149. mov AH, 1 ; command code for check status
  150. int 16h ; call rom-bios keyboard routine
  151. ; if z flag is set then no character
  152. jz FlDone ; is ready, buffer is empty -- get out
  153. xor AH, AH ; if zf is nof set, get character
  154. int 16h ; call rom-bios to get character
  155. jmp FlLoop ; repeat until buffer is empty
  156. FlDone:
  157. ret
  158. ;;Rev 3.30 Modification
  159. ;----------------------------------------------------------------
  160. ; :
  161. ; Console Write Routine :
  162. ; :
  163. ;----------------------------------------------------------------
  164. ASSUME DS:CODE ; THIS WAS SET BY THE CON DD ENTRY PT
  165. PUBLIC CON$WRIT
  166. CON$WRIT:
  167. jcxz EXVEC ; if CX is zero, get out
  168. CON$LP:
  169. mov AL,ES:[DI] ; get character
  170. inc DI ; point to next character
  171. int CHROUT ; Output character
  172. loop CON$LP ; repeat until all through
  173. Jump Exit
  174. ;-----------------------------------------------
  175. ;
  176. ; BREAK KEY HANDLING
  177. ;
  178. Public CBREAK
  179. CBREAK:
  180. mov CS:ALTAH, 3 ; indicate break key set
  181. Public INTRET
  182. INTRET:
  183. IRET
  184. CODE ENDS
  185. END