Advertisement
Guest User

Untitled

a guest
Apr 19th, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. ; ----------------------------------------------------------------------------------------
  2. ; Conway's life's game v0.2 19/04/2020
  3. ; ----------------------------------------------------------------------------------------
  4. use16
  5.  
  6.  
  7. ORG 0x7c00
  8.  
  9. global _start
  10.  
  11. _start:
  12. clc
  13. cld
  14. push cs
  15. pop ss
  16. push cs
  17. pop ds
  18. mov ax, 0x13
  19. int 0x10
  20.  
  21. mov ax,0x2000
  22. mov es,ax
  23. xor di, di
  24. xor al,al
  25. mov cx, 64000
  26. rep stosb ; vide la memoire en 0x2000
  27.  
  28. mov ax,0xa000
  29. mov es,ax
  30.  
  31. mov di, 0x7c60 ; pointe milieu ecran 160,100
  32. mov al, 0xf ; couleur 0xf = blanc
  33. stosb ; affiche pixel en 160,100
  34. stosb ; affiche pixel en 161,100
  35. mov di, 0x7d9f
  36. stosb ; affiche pixel en 159,101
  37. stosb ; affiche pixel en 160,101
  38. mov di, 0x7ee0
  39. stosb ; affiche pixel en 160,102
  40.  
  41. xor ax, ax ; appuyer une touche pour commencer
  42. int 0x16
  43.  
  44. ; debut/ ///////////////////////////////////////////////////////////////////
  45.  
  46. _cycle:
  47. mov di, 321 ; pointe l'ecran en 1,1
  48. _jmpLine:
  49. mov cx, 318 ; longueur d'une ligne
  50. _scanLine:
  51. sub di, 321 ; commence au pixel (x-1,y-1)
  52. xor dl, dl ; dl = nb de voisins
  53. mov bl, 3 ; 3 fois en horiz
  54. _rep2:
  55. mov bh, 3 ; 3 fois en vertical
  56. _rep3:
  57. mov al, bl
  58. mov ah, bh
  59. cmp ax, 0x0202 ; si c'est le pixel du milieu on ne le compte pas
  60. je _pasdevoisin
  61. mov al, [es:di] ; al = etat du pixel du voisin en cours
  62. cmp al, 0
  63. je _pasdevoisin
  64. inc dl ; 1 voisin de plus
  65. _pasdevoisin:
  66. inc di ; on passe au pixel a droite
  67. dec bh
  68. jnz _rep3
  69. add di, 317 ; on passe a la prochaine ligne de 3 pixels
  70. dec bl
  71. jnz _rep2
  72. sub di, 639 ; on repointe sur le pixel actuel
  73.  
  74. ; apres calcul des voisins :
  75. mov dh, [es:di] ; etat du pixel en cours
  76. cmp dl, 3 ; nb de voisins = 3 ?
  77. je nait ; alors nait
  78. cmp dl, 2 ; nb de voisins = 2 ?
  79. je rien ; alors rien
  80. xor dh, dh ; sinon meurt
  81. jmp rien
  82. nait:
  83. mov dh,0xf
  84. rien:
  85.  
  86. push es
  87. mov ax, 0x2000
  88. mov es, ax
  89. mov [es:di], dh ; affiche nouvel etat de la cellule en 0x2000
  90. pop es
  91. inc di ; on passe au pixel suivant
  92.  
  93.  
  94. loop _scanLine
  95. add di, 2 ; on passe à la ligne suivante
  96. cmp di, 64001 - 320 ; pas encore le bas de l ecran?
  97. jb _jmpLine
  98.  
  99.  
  100. push ds
  101. mov ax, 0x2000
  102. mov ds, ax
  103. xor di, di
  104. xor si, si
  105. mov cx, 64000
  106. rep movsb
  107. pop ds
  108.  
  109. ; attendre rafraichissement ecran
  110. mov dx,03DAh
  111. wax_on:
  112. in al,dx
  113. test al,8
  114. jz wax_on
  115. wax_off:
  116. in al,dx
  117. test al,8
  118. jnz wax_off
  119.  
  120. ; appuyer une touche pour sortir
  121. mov ax, 0x0100
  122. int 0x16
  123. jz _cycle
  124. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement