Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.30 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.  
  124.  
  125. curpos PROC
  126. push bp
  127. mov bp, sp
  128. push ax
  129. push bx
  130. push dx
  131.  
  132. mov ax, 0200h
  133. mov bh, 0
  134. mov dx, [bp+4]
  135. ; interrupt
  136. int 10h
  137.  
  138. pop dx
  139. pop bx
  140. pop ax
  141. pop bp
  142. ret 2
  143. curpos ENDP
  144.  
  145.  
  146. ;still unused
  147. putchar PROC
  148. push bp
  149. mov bp, sp
  150. push ax
  151. push bx
  152. push cx
  153. push dx
  154.  
  155.  
  156. pop dx
  157. pop cx
  158. pop bx
  159. pop ax
  160. pop bp
  161. ret 2
  162. putchar ENDP
  163.  
  164.  
  165. getchar PROC
  166. mov ah,00h
  167. int 16h
  168. ret
  169. getchar ENDP
  170.  
  171. ;window construction
  172. makewin PROC
  173. push bp
  174. mov bp, sp
  175. push ax
  176. push bx
  177. push cx
  178. push dx
  179. push si
  180.  
  181. mov si, [bp+4]
  182.  
  183. mov ax, 0600h
  184. mov bh, (WINDESC PTR[si]) .backColor
  185. mov ch, (WINDESC PTR[si]) .upperRow
  186. mov cl, (WINDESC PTR[si]) .leftCol
  187. mov dh, (WINDESC PTR[si]) .lowerRow
  188. mov dl, (WINDESC PTR[si]) .rightCol
  189. ;interrupt
  190. int 10h
  191.  
  192. push cx
  193. call curpos
  194.  
  195. pop si
  196. pop dx
  197. pop cx
  198. pop bx
  199. pop ax
  200. pop bp
  201. ret 2
  202. ; jmp short main
  203. makewin ENDP
  204.  
  205. main PROC
  206. mov ax, @data
  207. mov ds, ax
  208.  
  209. mov ax, OFFSET application
  210. push ax
  211. call makewin
  212. call curpos
  213. call mouse
  214. call getchar
  215. exit
  216. main ENDP
  217.  
  218. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement