Advertisement
palmerstone

final

Nov 28th, 2012
476
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GetText 10.98 KB | None | 0 0
  1. name "snake"
  2.  
  3. org     100h
  4.  
  5. jmp     start
  6.  
  7. s_size  equ     10
  8. x_coo db 0
  9. y_coo db 0
  10.  
  11. ar db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  12.    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  13.    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  14.    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  15.    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  16.    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  35.    db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  36.    
  37.  
  38. snake dw s_size dup(0)
  39.  
  40. tail    dw      ?
  41.  
  42. left    equ     4bh
  43. right   equ     4dh
  44. up      equ     48h
  45. down    equ     50h
  46.  
  47. cur_dir db      right
  48.  
  49. temps dw 0
  50. wait_time dw    0
  51. stopped db 0
  52.  
  53. start:
  54.  
  55.  
  56. mov     ah, 1
  57. mov     ch, 2bh
  58. mov     cl, 0bh
  59. int     10h
  60.  
  61.  
  62. ;mov x_coo, 10
  63. ;mov y_coo, 10
  64. ;call obstacle_hor
  65.  
  66. ;jmp game_loop
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. mov x_coo, 20
  74. mov y_coo, 5
  75. call obstacle_hor
  76.  
  77. mov x_coo, 20
  78. mov y_coo, 15
  79. call obstacle_hor
  80.  
  81. mov x_coo, 20
  82. mov y_coo, 25
  83. call obstacle_hor
  84.  
  85. mov x_coo, 20
  86. mov y_coo, 35
  87. call obstacle_hor
  88.  
  89. mov x_coo, 20
  90. mov y_coo, 45
  91. call obstacle_hor
  92.  
  93. mov x_coo, 7
  94. mov y_coo, 45
  95. call obstacle_hor
  96.  
  97. mov x_coo, 7
  98. mov y_coo, 55
  99. call obstacle_hor
  100.  
  101. mov x_coo, 7
  102. mov y_coo, 65
  103. call obstacle_hor
  104.  
  105. mov x_coo, 5
  106. mov y_coo, 15
  107. call obstacle_hor
  108.  
  109. mov x_coo, 8
  110. mov y_coo, 25
  111. call obstacle_hor
  112.  
  113. mov x_coo, 11
  114. mov y_coo, 35
  115. call obstacle_hor
  116.  
  117. mov x_coo, 14
  118. mov y_coo, 45
  119. call obstacle_hor
  120.  
  121. mov x_coo, 17
  122. mov y_coo, 55
  123. call obstacle_hor
  124.  
  125. mov x_coo, 20
  126. mov y_coo, 65
  127. call obstacle_hor
  128.  
  129. mov x_coo, 23
  130. mov y_coo, 75
  131. call obstacle_hor
  132.  
  133. mov x_coo, 2
  134. mov y_coo, 5
  135. call obstacle_ver
  136.  
  137. mov x_coo, 2
  138. mov y_coo, 10
  139. call obstacle_ver
  140.  
  141. mov x_coo, 2
  142. mov y_coo, 15
  143. call obstacle_ver
  144.  
  145. mov x_coo, 2
  146. mov y_coo, 20
  147. call obstacle_ver
  148.  
  149. mov x_coo, 2
  150. mov y_coo, 25
  151. call obstacle_ver
  152.  
  153. mov x_coo, 2
  154. mov y_coo, 30
  155. call obstacle_ver
  156.  
  157. mov x_coo, 2
  158. mov y_coo, 35
  159. call obstacle_ver
  160.  
  161. mov x_coo, 2
  162. mov y_coo, 40
  163. call obstacle_ver
  164.  
  165. mov x_coo, 2
  166. mov y_coo, 45
  167. call obstacle_ver
  168.  
  169. mov x_coo, 2
  170. mov y_coo, 50
  171. call obstacle_ver
  172.  
  173. mov x_coo, 2
  174. mov y_coo, 55
  175. call obstacle_ver
  176.  
  177. mov x_coo, 2
  178. mov y_coo, 60
  179. call obstacle_ver
  180.  
  181. mov x_coo, 2
  182. mov y_coo, 65
  183. call obstacle_ver
  184.  
  185. mov x_coo, 2
  186. mov y_coo, 70
  187. call obstacle_ver
  188.  
  189. mov x_coo, 2
  190. mov y_coo, 75
  191. call obstacle_ver
  192.  
  193. mov x_coo, 14
  194. mov y_coo, 5
  195. call obstacle_ver
  196.            
  197. mov x_coo, 14
  198. mov y_coo, 10
  199. call obstacle_ver
  200.  
  201. mov x_coo, 14
  202. mov y_coo, 15
  203. call obstacle_ver
  204.  
  205. mov x_coo, 14
  206. mov y_coo, 20
  207. call obstacle_ver
  208.  
  209. mov x_coo, 14
  210. mov y_coo, 25
  211. call obstacle_ver
  212.  
  213. mov x_coo, 14
  214. mov y_coo, 30
  215. call obstacle_ver
  216.  
  217. mov x_coo, 14
  218. mov y_coo, 35
  219. call obstacle_ver
  220.  
  221. mov x_coo, 14
  222. mov y_coo, 40
  223. call obstacle_ver
  224.  
  225. mov x_coo, 14
  226. mov y_coo, 45
  227. call obstacle_ver
  228.  
  229. mov x_coo, 14
  230. mov y_coo, 50
  231. call obstacle_ver
  232.  
  233. mov x_coo, 14
  234. mov y_coo, 55
  235. call obstacle_ver
  236.  
  237. mov x_coo, 14
  238. mov y_coo, 60
  239. call obstacle_ver
  240.  
  241. mov x_coo, 14
  242. mov y_coo, 65
  243. call obstacle_ver
  244.  
  245. mov x_coo, 14
  246. mov y_coo, 70
  247. call obstacle_ver
  248.  
  249. mov x_coo, 14
  250. mov y_coo, 75
  251. call obstacle_ver                    
  252.  
  253.  
  254. game_loop:
  255.  
  256. cmp stopped, 1
  257. je gtfo
  258.  
  259. mov     al, 0
  260. mov     ah, 05h
  261. int     10h
  262.  
  263. mov     dx, snake[0]
  264.  
  265. mov     ah, 02h
  266. int     10h
  267.  
  268. mov     al, '*'
  269. mov     ah, 09h
  270. mov     bl, 0eh
  271. mov     cx, 1
  272. int     10h
  273.  
  274. mov     ax, snake[s_size * 2 - 2]
  275. mov     tail, ax
  276.  
  277. call    move_snake
  278.  
  279.  
  280. mov     dx, tail
  281.  
  282. mov     ah, 02h
  283. int     10h
  284.  
  285. mov     al, ' '
  286. mov     ah, 09h
  287. mov     bl, 0eh
  288. mov     cx, 1  
  289. int     10h
  290.  
  291.  
  292.  
  293. check_for_key:
  294.  
  295. mov     ah, 01h
  296. int     16h
  297. jz      no_key
  298.  
  299. mov     ah, 00h
  300. int     16h
  301.  
  302. cmp     al, 1bh  
  303. je      stop_game
  304.  
  305. mov     cur_dir, ah
  306.  
  307. no_key:
  308.  
  309.  
  310.  
  311. mov     ah, 00h
  312. int     1ah
  313. cmp     dx, wait_time
  314. jb      check_for_key
  315. add     dx, 4
  316. mov     wait_time, dx
  317.  
  318.  
  319.  
  320. jmp     game_loop
  321.  
  322.  
  323. stop_game:
  324.  
  325. mov     ah, 1
  326. mov     ch, 0bh
  327. mov     cl, 0bh
  328. int     10h
  329.  
  330. ret
  331.  
  332.  
  333. move_snake proc near
  334.  
  335. mov     ax, 40h
  336. mov     es, ax
  337.  
  338.  
  339.   mov   di, s_size * 2 - 2
  340.  
  341.   mov   cx, s_size-1
  342. move_array:
  343.   mov   ax, snake[di-2]
  344.   mov   snake[di], ax
  345.   sub   di, 2
  346.   loop  move_array
  347.  
  348.  
  349. cmp     cur_dir, left
  350.   je    move_left
  351. cmp     cur_dir, right
  352.   je    move_right
  353. cmp     cur_dir, up
  354.   je    move_up
  355. cmp     cur_dir, down
  356.   je    move_down
  357.  
  358. jmp     stop_move    
  359.  
  360.  
  361. move_left:
  362.   mov   al, b.snake[0]
  363.   dec   al
  364.   mov   b.snake[0], al
  365.   cmp   al, -1
  366.   jne   stop_move      
  367.   mov   al, es:[4ah]  
  368.   dec   al
  369.   mov   b.snake[0], al  
  370.   jmp   stop_move
  371.  
  372. move_right:
  373.   mov   al, b.snake[0]
  374.   inc   al
  375.   mov   b.snake[0], al
  376.   cmp   al, es:[4ah]  
  377.   jb    stop_move
  378.   mov   b.snake[0], 0
  379.  
  380. move_up:
  381.   mov   al, b.snake[1]
  382.   dec   al
  383.   mov   b.snake[1], al
  384.   cmp   al, -1
  385.   jne   stop_move
  386.   mov   al, es:[84h]
  387.   mov   b.snake[1], al
  388.   jmp   stop_move
  389.  
  390. move_down:
  391.   mov   al, b.snake[1]
  392.   inc   al
  393.   mov   b.snake[1], al
  394.   cmp   al, es:[84h]
  395.   jbe   stop_move
  396.   mov   b.snake[1], 0
  397.   jmp   stop_move
  398.  
  399. stop_move:
  400.   push ax
  401.   push bx
  402.   push cx
  403.   push dx
  404.   push si
  405.   push di
  406.  
  407.   lea si, ar
  408.   lea di, snake
  409.   mov ax, [di]
  410.   mov temps, ax
  411.  
  412.   mov ah, 0
  413.   mov al, b.temps[1]
  414.   mov bh, 0
  415.   mov bl, b.temps[0]
  416.   mov dx, 80
  417.   mul dx
  418.   add ax, bx
  419.   add si, ax
  420.  
  421.   mov ch, 0
  422.   mov cl, [si]
  423.   cmp cl, 1
  424.  
  425.   jne nope1
  426.   mov stopped, 1
  427.  
  428.   nope1:
  429.  
  430.   pop di
  431.   pop si
  432.   pop dx
  433.   pop cx
  434.   pop bx
  435.   pop ax
  436.  
  437.    
  438.   ret
  439. move_snake endp
  440.  
  441. obstacle_hor proc
  442.   push ax
  443.   push bx
  444.   push cx
  445.   push dx
  446.   mov cx,10
  447.  
  448.   LOOP1:
  449.       cmp x_coo, 25
  450.       jge skip1
  451.       cmp y_coo, 80
  452.       jge skip1
  453.  
  454.  
  455.       mov dh,x_coo
  456.       mov dl,y_coo
  457.      
  458.      
  459.      
  460.       push ax
  461.       push bx
  462.       push cx
  463.       push dx
  464.       push si
  465.      
  466.      
  467.       lea si, ar
  468.       mov ah, 0
  469.       mov al, x_coo
  470.       mov dx, 80
  471.       mul dx
  472.       mov bh, 0
  473.       mov bl, y_coo
  474.       add ax, bx
  475.       add si, ax
  476.      
  477.       mov [si], 1
  478.      
  479.      
  480.       pop si
  481.       pop dx
  482.       pop cx
  483.       pop bx
  484.       pop ax
  485.      
  486.      
  487.      
  488.       mov ah,2
  489.       int 10h
  490.       push cx
  491.       mov     al, '#'
  492.       mov     ah, 09h
  493.       mov     bl, 0ah
  494.       mov     cx, 1  
  495.       int     10h
  496.      
  497.       inc y_coo
  498.       pop cx
  499.  
  500.  
  501.   loop LOOP1
  502.  
  503.   skip1:
  504.  
  505.   pop dx
  506.   pop cx
  507.   pop bx
  508.   pop ax
  509. ret    
  510. obstacle_hor endp
  511.  
  512. obstacle_ver proc
  513.   push ax
  514.   push bx
  515.   push cx
  516.   push dx
  517.   mov cx,10
  518.  
  519.   LOOP2:
  520.       cmp x_coo, 25
  521.       jge skip1
  522.       cmp y_coo, 80
  523.       jge skip2
  524.  
  525.  
  526.       mov dh,x_coo
  527.       mov dl,y_coo
  528.      
  529.      
  530.      
  531.      
  532.       push ax
  533.       push bx
  534.       push cx
  535.       push dx
  536.       push si
  537.      
  538.      
  539.       lea si, ar
  540.       mov ah, 0
  541.       mov al, x_coo
  542.       mov dx, 80
  543.       mul dx
  544.       mov bh, 0
  545.       mov bl, y_coo
  546.       add ax, bx
  547.       add si, ax
  548.      
  549.       mov [si], 1
  550.      
  551.      
  552.       pop si
  553.       pop dx
  554.       pop cx
  555.       pop bx
  556.       pop ax
  557.      
  558.      
  559.      
  560.      
  561.      
  562.       mov ah,2
  563.       int 10h
  564.       push cx
  565.       mov     al, '#'
  566.       mov     ah, 09h
  567.       mov     bl, 0ah
  568.       mov     cx, 1
  569.       int     10h
  570.      
  571.       inc x_coo
  572.       pop cx
  573.  
  574.  
  575.   loop LOOP2
  576.  
  577.   skip2:
  578.  
  579.   pop dx
  580.   pop cx
  581.   pop bx
  582.   pop ax
  583. ret    
  584. obstacle_ver endp
  585.  
  586. gtfo:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement