Advertisement
Guest User

Untitled

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