Guest User

Untitled

a guest
Apr 23rd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. .model small
  2. .stack 100h
  3.  
  4. .data
  5. mouseX dw ?
  6. mouseY dw ?
  7. button dw ?
  8.  
  9. myStr db "Vinnie is Great"
  10. myColor db 1111b
  11. strLength dw 15
  12. blank_mes db " "
  13. row db ?
  14. col db ?
  15.  
  16. key db ?
  17. .code
  18. main:
  19. call init
  20. call clearScreen
  21. call disableBlink
  22. call displayMouse
  23. call getButtonPress
  24. call exit
  25. Proc PrintLeft
  26. repeater:
  27. call PrintString
  28. call Delay
  29. call PrintBlank
  30. cmp col, 0
  31. jz finito
  32. dec col
  33. jmp repeater
  34. finito:
  35. RET
  36. ENDP PrintLeft
  37. Proc Print2Bottom
  38. repeat:
  39. call PrintString
  40. call Delay
  41. call PrintBlank
  42. cmp row, 25
  43. jz finished
  44. inc row
  45. jmp repeat
  46. finished:
  47. RET
  48. ENDP Print2Bottom
  49.  
  50. Proc PrintString
  51. ; Print a $ Terminated String
  52. push ax bx cx dx
  53.  
  54. mov ah, 13h
  55. mov al, 1
  56. mov bh, 0
  57. mov bl, myColor
  58. mov cx, strLength
  59. mov dh, row
  60. mov dl, col
  61. mov bp, OFFSET myStr
  62.  
  63. INT 10h
  64.  
  65. pop dx cx bx ax
  66. RET
  67. ENDP PrintString
  68.  
  69. ; === PROC WAIT ===
  70. PROC Delay
  71. push si di ; save SI and DI on Stack
  72.  
  73. mov si, 0FFFh ; load si with 1000
  74. reload_di:
  75. mov di, 0FFFFh ; load di with FFFF (64,000)
  76. dec_again:
  77. dec di ; DECrease DI by 1 (di=di-1;)
  78. jnz dec_again ; JUMP NOT ZERO (di!=0) to
  79. ; LABEL called dec_again
  80.  
  81.  
  82. dec si ; DECreases SI (si=si-1;)
  83. jnz reload_di ; JUMP NOT ZERO (si!=0) to
  84. ; LABEL called reload_di
  85.  
  86. pop di si ; restore SI and DI from Stack
  87.  
  88. RET
  89. ENDP Delay
  90.  
  91. ;===============
  92. PROC PrintBlank
  93. push ax bx cx dx bp
  94.  
  95. mov al, 1
  96. mov bh, 0
  97. mov bl, myColor
  98. mov cx, strLength
  99. mov dl, COL
  100. mov dh, ROW
  101. mov bp, offset blank_mes
  102. mov ah, 13h
  103. int 10h
  104.  
  105. pop bp dx cx bx ax
  106.  
  107. RET
  108. ENDP PrintBlank
  109. PROC init
  110. push ax
  111. mov ax, @DATA
  112. mov ds, ax
  113. mov es, ax
  114. pop ax
  115. RET
  116. ENDP init
  117.  
  118. PROC disableBlink
  119. push ax bx
  120.  
  121. mov ax, 1003h
  122. mov bl, 0
  123. int 10h
  124.  
  125. pop bx ax
  126. RET
  127. ENDP disableBlink
  128.  
  129. PROC displayMouse
  130. push ax
  131. mov ax,01h ; display mouse cursorm
  132. int 33H
  133. pop ax
  134. RET
  135. ENDP displayMouse
  136. PROC getMousePos
  137. push ax bx cx dx
  138. mov ax, 03h
  139. int 33h
  140.  
  141. shr cx, 3
  142. mov col, cl
  143. shr dx, 3
  144. mov row, dl
  145. mov button, bx
  146.  
  147. pop dx cx bx ax
  148. RET
  149. ENDP getMousePos
  150. PROC getKeyPress
  151. push ax
  152.  
  153. mov ah, 01
  154. int 16h
  155. jz done
  156.  
  157. mov ah, 8
  158. int 21h
  159. mov key, al
  160.  
  161. cmp KEY, 'r'
  162. jnz try_y
  163.  
  164. mov myColor, 40h
  165. jmp done
  166. try_y:
  167. cmp KEY, 'y'
  168. jnz try_w
  169.  
  170. mov myColor, 0E0h
  171. jmp done
  172. try_w:
  173. cmp KEY, 'w'
  174. jnz try_c
  175.  
  176. mov myColor, 0F0h
  177. jmp done
  178. try_c:
  179. cmp KEY, 'c'
  180. jnz try_x
  181.  
  182. call clearScreen
  183. jmp done
  184. try_x:
  185. cmp KEY, 'x'
  186. jnz done
  187. call exit
  188.  
  189. done:
  190. mov key, ?
  191. pop ax
  192. RET
  193. ENDP getKeyPress
  194.  
  195. PROC getButtonPress
  196. push ax
  197. loopa:
  198. call getMousePos
  199. call getKeyPress
  200.  
  201. cmp button, 00h
  202. je loopa
  203.  
  204. cmp button, 01h
  205. jnz try_2
  206.  
  207. call Print2Bottom ;Left Pressed. Do this.
  208. jmp loopa
  209. try_2:
  210. cmp button, 02h
  211. jnz try_3
  212.  
  213. call PrintLeft ;Right Pressed. Do something.
  214.  
  215. jmp loopa
  216.  
  217. try_3:
  218. cmp button, 03h
  219.  
  220. call exit ;Both Pressed. Do something.
  221. jmp loopa
  222.  
  223. pop ax
  224. RET
  225. ENDP getButtonPress
  226. PROC printStr
  227. push ax bx cx dx
  228.  
  229. mov ah, 13h
  230. mov al, 1
  231. mov bh, 0
  232. mov bl, myColor
  233. mov cx, strLength
  234. mov dh, row
  235. mov dl, col
  236. mov bp, OFFSET myStr
  237.  
  238. INT 10h
  239.  
  240. pop dx cx bx ax
  241. RET
  242. ENDP printStr
  243. PROC changeCol
  244. add myColor, 10h
  245. RET
  246. ENDP changeCol
  247.  
  248. PROC clearScreen
  249. push ax bx cx dx
  250.  
  251. mov bh, 07h
  252. mov al, 0
  253. mov cx, 0
  254. mov dx, 184fh
  255.  
  256. mov ah, 7h
  257. INT 10h
  258.  
  259. pop dx cx bx ax
  260. RET
  261. ENDP clearScreen
  262.  
  263. PROC exit
  264. push ax
  265.  
  266. mov ah, 4ch
  267. INT 21h
  268.  
  269. pop ax
  270. RET
  271. ENDP exit
  272.  
  273. end main;
Add Comment
Please, Sign In to add comment