ohad12345

my assembly project v2

Jul 6th, 2020
742
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. IDEAL
  2. MODEL small
  3. STACK 100h
  4. DATASEG
  5. line dw 360
  6. halfline dw 0
  7. row dw 200
  8. halfrow dw 0
  9. helper dw 0
  10. randomchiter db 0
  11. cunter db 0
  12. less db 0
  13. more db 0
  14. x dw 0
  15. y dw 0
  16. ;------green
  17. green_brhight_color db 10
  18. green_color db 2
  19. green_width_place dw 160
  20. green_Length_place dw 100
  21. ;------yello
  22. ylow_brhight_color db 15
  23. ylow_color db 14
  24. ylow_width_place dw 0
  25. ylow_Length_place dw 100
  26. ;-----blue
  27. blue_brhight_color db 9
  28. blue_color db 1
  29. blue_width_place dw 160
  30. blue_Length_place dw 0
  31. ;---------red
  32. red_brhight_color db 12
  33. red_color db 4
  34. red_width_place dw 0
  35. red_Length_place dw 0
  36.  
  37.  
  38. array db 500 dup(8)
  39. scoremessage db 'your game was like --$'
  40. playagain db 'do you want to     play again: press green$'
  41. Erormessage db 'that note is not possible in this game... but he probbly exsit in maincrft.       do what do you  want, I dont care.... $'
  42. score db ''
  43.  
  44.  
  45. ; --------------------------
  46. ; Your variables here
  47. ; --------------------------
  48. CODESEG
  49. Startcode:
  50. ; ---------- שולח נתונים לפונקציית יוצר הריבועים, (ירוק) שולח נתונים לביפר
  51. proc green
  52.     push bx
  53.     mov al, [byte ptr green_brhight_color]
  54.     mov bl, 0
  55.     mov cx, [green_width_place]
  56.     mov dx, [green_Length_place]
  57.     call Square
  58.     mov [less], 05ah ;ערכי הסאונד הפחות חשובים של הריבוע הירוק
  59.     mov [more], 0Dh ;ערכי הסאונד היותר חשובים של הריבוע הירוק
  60.     call Beep
  61.     call regular_green
  62.     pop bx
  63.     RET
  64. endp green
  65. proc regular_green
  66.     push bx
  67.     mov al, [byte ptr green_color]
  68.     mov bl, 0
  69.     mov cx, [green_width_place]
  70.     mov dx, [green_Length_place]
  71.     call Square
  72.     pop bx
  73.     RET
  74. endp regular_green
  75. ;---------------------------------------------------------
  76. proc yello
  77.     push bx
  78.     mov al, [byte ptr ylow_brhight_color]
  79.     mov bl, 0
  80.     mov cx, [ylow_width_place]
  81.     mov dx, [ylow_Length_place]
  82.     call Square
  83.     mov [less], 20h ;ערכי הסאונד הפחות חשובים של צהוב
  84.     mov [more], 0eh ;ערכי הסאונוד היותר חשובים של צהוב
  85.     call Beep
  86.     call regular_yello
  87.     pop bx
  88.     RET
  89. endp yello
  90. proc regular_yello
  91.     push bx
  92.     mov al, [byte ptr ylow_color]
  93.     mov bl, 0
  94.     mov cx, [ylow_width_place]
  95.     mov dx, [ylow_Length_place]
  96.     call Square
  97.     pop bx
  98.     RET
  99. endp regular_yello
  100. ;-----------------------------------------------------
  101. proc blue
  102.     push bx
  103.     mov al, [byte ptr blue_brhight_color]
  104.     mov bl, 0
  105.     mov cx, [blue_width_place]
  106.     mov dx, [blue_Length_place]
  107.     call Square
  108.     mov [less], 0d9h ;ער הסאונוד הפחות חשובים של חכול
  109.     mov [more], 0fh ; ערכי הסאונוד היותר חשובים של כחול
  110.     call Beep
  111.     call regular_blue
  112.     pop bx
  113.     RET
  114. endp blue
  115. proc regular_blue
  116.     push bx
  117.     mov al, [byte ptr blue_color]
  118.     mov bl, 0
  119.     mov cx, [blue_width_place]
  120.     mov dx, [blue_Length_place]
  121.     call Square
  122.     pop bx
  123.     RET
  124. endp regular_blue
  125. ;---------------------------------------------------------
  126.  
  127. proc red
  128.     push bx
  129.     mov al, [byte ptr red_brhight_color]
  130.     mov bl, 0
  131.     mov cx, [red_width_place]
  132.     mov dx, [red_Length_place]
  133.     call Square
  134.     mov [less], 0D1h ;ערכי הסונד הפחות חשובים של אדום
  135.     mov [more], 11h ; ערכי הסאונד היותר חשובים של אדום
  136.     call Beep
  137.     call regular_red
  138.     pop bx
  139.     RET
  140. endp red
  141. proc regular_red
  142.     push bx
  143.     mov al, [byte ptr red_color]
  144.     mov bl, 0
  145.     mov cx, [red_width_place]
  146.     mov dx, [red_Length_place]
  147.     call Square
  148.     pop bx
  149.     RET
  150. endp regular_red
  151. ;-------------------------------------------------------------
  152. proc Beep
  153.     in al, 61h
  154.     or al, 00000011b
  155.     out 61h, al
  156.     mov al, 0B6h
  157.     out 43h, al
  158.     mov al, [less]
  159.     out 42h, al
  160.     mov al, [more]
  161.     out 42h, al
  162.     call dilay
  163.     in al, 61h
  164.     and al, 11111100b
  165.     out 61h, al
  166.     RET
  167. endp Beep
  168. ;-----------------------------------------------------------------------
  169. proc Square
  170.     mov [x], cx
  171.     mov [y], dx
  172.     add [x], 158
  173.     add [y], 98
  174.     mov ah, 0ch
  175. Squarelop:
  176. Squareinloop:
  177.     int 10h
  178.     inc cx
  179.     cmp cx, [x]
  180.     jne Squareinloop
  181.     inc dx
  182.     sub cx, 158
  183.     cmp dx, [y]
  184.     jne Squarelop
  185. call Dilay
  186.     ret
  187. endp Square
  188. ;---------------
  189. proc Dilay
  190.     push cx
  191.     mov cx, 3000
  192. dilayloop:
  193.     push cx
  194.     mov cx, 100
  195.     dilayloop2:
  196. loop dilayloop2
  197.     pop cx
  198. loop dilayloop
  199.     pop cx
  200. RET
  201. endp Dilay
  202. ;--------------------
  203. proc random
  204.     mov ax, 40h  
  205.     mov es, ax
  206.     mov al, [byte ptr es:06Ch]
  207.     and al, 0011b
  208.     call saver
  209. RET
  210. endp random
  211.  
  212. ;----------------------------
  213. proc whcing
  214.      push bx
  215.      mov bx, offset array
  216. whcingonly:
  217.      cmp [byte ptr ds:bx], 0
  218.      je gcall
  219.      
  220.      cmp [byte ptr ds:bx], 1
  221.      je ycall
  222.      
  223.      cmp [byte ptr ds:bx], 2
  224.      je bcall
  225.      
  226.      cmp [byte ptr ds:bx], 3
  227.      je rcall
  228.      
  229.      cmp [byte ptr ds:bx], 8
  230.      je exitwhcingonly
  231.      
  232. rcall:
  233.      call red
  234.      jmp goon3
  235. bcall:
  236.      call blue
  237.      jmp goon3
  238. ycall:
  239.      call yello
  240.      jmp goon3
  241. gcall:
  242.      call green
  243.      jmp goon3
  244.      
  245. goon3:   
  246.      inc bx
  247.      jmp whcingonly
  248. exitwhcingonly:
  249.      pop bx  
  250. RET
  251. endp whcing
  252. ;--------------
  253. proc saver
  254.      mov bx, offset array
  255.      add  bl, [cunter]
  256.      mov [byte ptr bx], al
  257.      call whcing
  258. ret
  259. endp saver
  260. ;-------------
  261. proc thestart
  262.      xor cx, cx
  263.      xor ax, ax
  264.      mov cl, [cunter]
  265.      inc cx
  266.      mov bx, offset array
  267.      mov al, 8
  268. deliting:
  269.      mov [bx], al
  270.      inc bx
  271. loop deliting
  272. afterloop:
  273.      mov bx, 0
  274.      mov cx, 0
  275.      mov [cunter], 0
  276.      jmp start
  277. RET
  278. endp thestart
  279. ;-------------------------------------------------------------------------------------------------------------------
  280. start:
  281.     mov ax, @data
  282.     mov ds, ax
  283.     mov ax, 13h
  284.     int 10h
  285.     mov [cunter], 0
  286.     call regular_red
  287.     call regular_blue
  288.     call regular_green
  289.     call regular_yello
  290.     mov [cunter], 0
  291.     call dilay
  292. mainloop:
  293.     call dilay
  294.     call random
  295.     mov bx, offset array
  296. activloop:
  297.     cmp [byte ptr bx], 8
  298.     je Endactiv
  299.      
  300.     mov ah,0Ch
  301.     mov al,07h
  302.     int 21h
  303.    
  304.     cmp al, 115
  305.     je gtest
  306.      
  307.     cmp al, 97
  308.     je ytest
  309.      
  310.     cmp al, 119
  311.     je btest
  312.      
  313.     cmp al, 113
  314.     je rtest
  315.    
  316.     cmp al, 114
  317.     jne Erormesseg
  318.    
  319.     jmp restsrt
  320.    
  321. Erormesseg:
  322.     mov dx, offset Erormessage
  323.     mov ah, 9h
  324.     int 21h
  325.     jmp activloop
  326.        
  327.      
  328. rtest:
  329.     call red
  330.     cmp [byte ptr bx], 3
  331.     jne bay2   
  332.     jmp goon4
  333. btest:
  334.     call blue
  335.     cmp [byte ptr bx], 2
  336.     jne bay2   
  337.     jmp goon4
  338. ytest:
  339.     call yello
  340.     cmp [byte ptr bx], 1
  341.     jne bay2
  342.     jmp goon4
  343. gtest:
  344.     call green
  345.     cmp [byte ptr bx], 0
  346.     jne bay2
  347.      
  348. goon4:     
  349.     inc bx
  350.     jmp activloop
  351.    
  352. Endactiv:  
  353.     call dilay
  354.     call dilay
  355.     inc [cunter]
  356.     cmp al, [randomchiter]
  357.     je dilaer
  358.     jmp mainloop
  359. dilaer:
  360.     call dilay
  361.     call dilay
  362.     call dilay
  363.     jmp mainloop
  364. bay2:
  365.     mov [less], 0f9h
  366.     mov [more], 0fh
  367.     call Beep
  368.     call Beep  
  369.     call Beep
  370.     call Beep
  371.     mov dx, offset scoremessage
  372.     mov ah, 9h
  373.     int 21h
  374.     call dilay
  375.     call dilay
  376.     call dilay
  377.     call dilay
  378.     call dilay
  379.     call dilay
  380.     call dilay
  381.     call dilay
  382.     call whcing
  383.     call dilay
  384.      mov dx, offset playagain
  385.     mov ah, 9h
  386.     int 21h
  387.     mov ah,0Ch
  388.     mov al,07h
  389.     int 21h
  390.     cmp al, 115
  391.     je restsrt
  392.     jmp exit
  393. restsrt:
  394.     call thestart  
  395.  
  396.    
  397. exit:
  398.      mov ah,0
  399.      mov al,2
  400.      int 10h
  401.     mov ax, 4c00h
  402.     int 21h
  403. END start
RAW Paste Data