Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. IDEAL
  2. MODEL small
  3. STACK 100h
  4. DATASEG
  5. Snake dw 32160, 32164, 32168, 32172, 32176, 32180
  6. SnakeLength dw 6
  7. Direction db 2
  8. Runs dw 0
  9. ; --------------------------
  10. ; Your variables here
  11. ; --------------------------
  12. CODESEG
  13.  
  14.  
  15.  
  16.  
  17.  
  18. proc DirectionTranslation ; Might need to change return method to Register, also maybe this proc is not needed
  19. cmp al, 17
  20. jb NoDirection
  21. jne SecondCheck
  22. cmp Direction, 3
  23. je NoDirection
  24. mov Direction, 1
  25. jmp EndProc
  26. SecondCheck:
  27. cmp al, 32
  28. ja NoDirection
  29. jne ThirdCheck
  30. cmp Direction, 2
  31. je NoDirection
  32. mov Direction, 4
  33. jmp EndProc
  34. ThirdCheck:
  35. cmp al, 31
  36. ja NoDirection
  37. jne FourthCheck
  38. cmp Direction, 1
  39. je NoDirection
  40. mov Direction, 3
  41. jmp EndProc
  42. FourthCheck:
  43. cmp al, 30
  44. jne NoDirection
  45. cmp Direction, 4
  46. je NoDirection
  47. mov Direction, 2
  48. jmp EndProc
  49. NoDirection:
  50. mov al, 5
  51. EndProc:
  52. ret
  53. endp DirectionTranslation
  54.  
  55. proc Delay
  56. mov dx, 1500
  57. DelayLoopOut:
  58. mov cx, 3000
  59. DelayLoopIn:
  60. loop DelayLoopIn
  61. dec dx
  62. cmp dx, 0
  63. ja DelayLoopOut
  64. ret
  65. endp Delay
  66.  
  67. proc UpdateSnake
  68. mov bx, SnakeLength
  69. shl bx, 1
  70. sub bx, 2
  71. add bx, offset Snake
  72. mov si, [bx]
  73. mov al, 0
  74. call PrintLimb
  75.  
  76. mov cx, SnakeLength
  77. sub cx, 1
  78. UpdateLoop:
  79. mov ax, [bx - 2]
  80. mov [bx], ax
  81. sub bx, 2
  82. loop UpdateLoop
  83.  
  84. cmp Direction, 1
  85. jne SecondUpdate
  86. sub [bx], 1280
  87. mov si, [bx]
  88. cmp es:si, 0
  89. je EndProc2
  90. jmp PlayerDead
  91. SecondUpdate:
  92. cmp Direction, 2
  93. jne ThirdUpdate
  94. sub [bx], 4
  95. mov si, [bx]
  96. cmp [byte ptr es:si], 0
  97. je EndProc2
  98. jmp PlayerDead
  99. ThirdUpdate:
  100. cmp Direction, 3
  101. jne FourthUpdate
  102. add [bx], 1280
  103. mov si, [bx]
  104. cmp es:si, 0
  105. je EndProc2
  106. jmp PlayerDead
  107. FourthUpdate:
  108. add [bx], 4
  109. mov si, [bx]
  110. cmp es:si, 0
  111. je EndProc2
  112. PlayerDead:
  113. mov dl, 1
  114. EndProc2:
  115. mov al, 4
  116. call PrintLimb
  117. mov si, [bx + 2]
  118. mov al, 3
  119. call PrintLimb
  120. ret
  121. endp UpdateSnake
  122.  
  123. proc PrintLimb
  124. push cx
  125. mov cx, 3
  126. mov dx, 3
  127. sub si, 321
  128. PrintLimbLoop:
  129. mov es:si, al
  130. inc si
  131. dec dx
  132. cmp dx, 0
  133. jne PrintLimbLoop
  134. mov dx, 3
  135. add si, 317
  136. loop PrintLimbLoop
  137. pop cx
  138. ret
  139. endp PrintLimb
  140.  
  141. proc PrintWalls
  142. mov cx, 199
  143. mov si, 0
  144. FirstSide:
  145. mov es:si, 5
  146. add si, 320
  147. loop FirstSide
  148. mov cx, 320
  149. inc si
  150. SecondSide:
  151. mov es:si, 5
  152. inc si
  153. loop SecondSide
  154. mov cx, 200
  155. sub si, 320
  156. ThirdSide:
  157. mov es:si, 5
  158. sub si, 320
  159. loop ThirdSide
  160. mov cx, 320
  161. dec si
  162. FourthSide:
  163. sub es:si, 5
  164. dec si
  165. loop FourthSide
  166. ret
  167. endp PrintWalls
  168.  
  169.  
  170. start:
  171. mov ax, @data
  172. mov ds, ax
  173. mov ax, 13h
  174. int 10h
  175. mov ax, 0A000h
  176. mov es, ax
  177. call PrintWalls
  178. mov cx, SnakeLength
  179. sub cx, 1
  180. mov bx, offset Snake
  181. mov si, [bx]
  182. mov al, 4
  183. call PrintLimb
  184. add bx, 2
  185. mov al, 3
  186. FirstPrint:
  187. mov si, [bx]
  188. call PrintLimb
  189. add bx, 2
  190. loop FirstPrint
  191. WaitForDirection:
  192. xor ah, ah
  193. int 16h
  194. mov al, ah
  195. call DirectionTranslation
  196. cmp al, 5
  197. je WaitForDirection
  198. GameLoop:
  199. in al, 64h
  200. cmp al, 10b
  201. je NoNewPress
  202. in al, 60h
  203. call DirectionTranslation
  204. NoNewPress:
  205. call Delay
  206. call UpdateSnake
  207. cmp dl, 1
  208. je GameOver
  209. jmp GameLoop
  210. GameOver:
  211.  
  212.  
  213. exit:
  214. mov ax, 4c00h
  215. int 21h
  216. END start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement