Advertisement
Guest User

Untitled

a guest
Dec 20th, 2011
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. TITLE The New DOS
  2.  
  3. .386p
  4. .model small,Flat,StdCALL
  5. .stack 100h
  6. OPTION CaseMap:None
  7. .MMX
  8. .XMM
  9.  
  10.  
  11. ; Set the window variable framework
  12. WINDESC STRUCT
  13. upperRow BYTE ?
  14. leftCol BYTE ?
  15. lowerRow BYTE ?
  16. rightCol BYTE ?
  17. foreColor BYTE ?
  18. backColor BYTE ?
  19. WINDESC ENDS
  20.  
  21. ; Not really sure about this one
  22. exit MACRO
  23. mov ax, 4C00h
  24. int 21h
  25. ENDM
  26.  
  27. ;set variables
  28. .data
  29. application WINDESC <05h, 05h, 15h, 45h, 07h, 10h>
  30. msgNoMouseDriver db "no mouse driver",13,10,"$"
  31. msgPressAnyKey db "press any key to exit",13,10,"$"
  32. ;==============================================================================
  33.  
  34. ;-------------------------------------------------------------------
  35. ; With MASM the mouse driver functions are called with the function
  36. ; number in AX, and depending on the function, the return values may
  37. ; be in AX, BX, CX, or DX.
  38. ;-------------------------------------------------------------------
  39.  
  40. ;----------------------------------------------------------------------
  41. ; Check for a mouse driver. Use the DOS Get Interrupt Vector function
  42. ; to get the interrupt 33h vector. If the segment address is zero then
  43. ; the mouse driver is not installed.
  44. ;----------------------------------------------------------------------
  45.  
  46. .code
  47.  
  48. ;mouse driver
  49. mouse proc
  50.  
  51. mov ax,3533h
  52. int 21h
  53. mov ax, es
  54. .IF ax == 0
  55. mov ah, 9
  56. mov dx, OFFSET msgNoMouseDriver
  57. int 21h
  58. jmp myExit
  59. .ENDIF
  60.  
  61. ;-------------------------------------------------------------------------
  62. ; Attempt to reset the mouse driver by calling the Mouse Reset And Status
  63. ; function. If the reset fails, indicated by the function returning zero,
  64. ; then the mouse driver is not installed.
  65. ;-------------------------------------------------------------------------
  66.  
  67. xor ax, ax
  68. int 33h
  69. .IF ax == 0
  70. mov ah, 9
  71. mov dx, OFFSET msgNoMouseDriver
  72. int 21h
  73. jmp myExit
  74. .ENDIF
  75.  
  76. ;------------------------------------------------------------------
  77. ; Show the mouse cursor by calling the Mouse Show Cursor function.
  78. ;------------------------------------------------------------------
  79.  
  80. mov ax, 1
  81. int 33h
  82.  
  83. ;-----------------------------------------------------------------------
  84. ; Loop, calling the Mouse Get Button Status And Mouse Position function
  85. ; until the user presses the left mouse button with the mouse cursor
  86. ; at character coordinate 0,0 (the first character at the upper-left
  87. ; corner of screen). The function returns the button status in BX, the
  88. ; horizontal cursor coordinate in CX, and the vertical cursor coordinate
  89. ; in DX. The button status for the left mouse button is returned in
  90. ; bit 0 of BX, and the status for the right mouse button in bit 1, with
  91. ; the bit set if the button is pressed or cleared if the button is
  92. ; released. The cursor coordinates are returned as mouse-driver virtual-
  93. ; screen coordinates, where the virtual screen for most of the display
  94. ; modes is 640x200. For the 80x25 character (AKA "text") modes you
  95. ; convert the virtual-screen coordinates to character coordinates by
  96. ; simply dividing the virtual-screen coordinates by 8.
  97. ;-----------------------------------------------------------------------
  98.  
  99. @@:
  100. mov ax, 3
  101. int 33h
  102. .IF bx & 1 ; left mouse button is pressed
  103. shr cx, 3
  104. shr dx, 3
  105. .IF cx || dx ; mouse cursor not over character 0,0 so keep looping
  106. jmp @B
  107. .ENDIF
  108. .ELSE
  109. jmp @B ; left mouse button not pressed so keep looping
  110. .ENDIF
  111.  
  112. myExit:
  113.  
  114. mov ah, 9
  115. mov dx, OFFSET msgPressAnyKey
  116. int 21h
  117.  
  118. xor ah, ah
  119. int 16h
  120.  
  121. ret
  122. ;.exit
  123. ;end
  124. mouse endp
  125.  
  126. ;setting the cursor position
  127. curpos PROC
  128. push bp
  129. mov bp, sp
  130. push ax
  131. push bx
  132. push dx
  133.  
  134. mov ax, 0200h
  135. mov bh, 0
  136. mov dx, [bp+4]
  137. ; interrupt
  138. int 10h
  139.  
  140. pop dx
  141. pop bx
  142. pop ax
  143. pop bp
  144. ret 2
  145. curpos ENDP
  146.  
  147.  
  148. ;still unused
  149. putchar PROC
  150. push bp
  151. mov bp, sp
  152. push ax
  153. push bx
  154. push cx
  155. push dx
  156.  
  157.  
  158. pop dx
  159. pop cx
  160. pop bx
  161. pop ax
  162. pop bp
  163. ret 2
  164. putchar ENDP
  165.  
  166.  
  167. getchar PROC
  168. mov ah,00h
  169. int 16h
  170. ret
  171. getchar ENDP
  172.  
  173. ;window construction
  174. makewin PROC
  175. push bp
  176. mov bp, sp
  177. push ax
  178. push bx
  179. push cx
  180. push dx
  181. push si
  182.  
  183. mov si, [bp+4]
  184.  
  185. mov ax, 0600h
  186. mov bh, (WINDESC PTR[si]) .backColor
  187. mov ch, (WINDESC PTR[si]) .upperRow
  188. mov cl, (WINDESC PTR[si]) .leftCol
  189. mov dh, (WINDESC PTR[si]) .lowerRow
  190. mov dl, (WINDESC PTR[si]) .rightCol
  191. ;interrupt
  192. int 10h
  193.  
  194. push cx
  195. call curpos
  196.  
  197. pop si
  198. pop dx
  199. pop cx
  200. pop bx
  201. pop ax
  202. pop bp
  203. ret 2
  204. ; jmp short main
  205. makewin ENDP
  206.  
  207. main PROC
  208. mov ax, @data
  209. mov ds, ax
  210.  
  211. mov ax, OFFSET application
  212. push ax
  213. call makewin
  214. call getchar
  215. exit
  216. main ENDP
  217.  
  218. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement