Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ----------------------------------------------------------------------------------------
- ; Conway's life's game v0.2 19/04/2020
- ; ----------------------------------------------------------------------------------------
- use16
- ORG 0x7c00
- global _start
- _start:
- clc
- cld
- push cs
- pop ss
- push cs
- pop ds
- mov ax, 0x13
- int 0x10
- mov ax,0x2000
- mov es,ax
- xor di, di
- xor al,al
- mov cx, 64000
- rep stosb ; vide la memoire en 0x2000
- mov ax,0xa000
- mov es,ax
- mov di, 0x7c60 ; pointe milieu ecran 160,100
- mov al, 0xf ; couleur 0xf = blanc
- stosb ; affiche pixel en 160,100
- stosb ; affiche pixel en 161,100
- mov di, 0x7d9f
- stosb ; affiche pixel en 159,101
- stosb ; affiche pixel en 160,101
- mov di, 0x7ee0
- stosb ; affiche pixel en 160,102
- xor ax, ax ; appuyer une touche pour commencer
- int 0x16
- ; debut/ ///////////////////////////////////////////////////////////////////
- _cycle:
- mov di, 321 ; pointe l'ecran en 1,1
- _jmpLine:
- mov cx, 318 ; longueur d'une ligne
- _scanLine:
- sub di, 321 ; commence au pixel (x-1,y-1)
- xor dl, dl ; dl = nb de voisins
- mov bl, 3 ; 3 fois en horiz
- _rep2:
- mov bh, 3 ; 3 fois en vertical
- _rep3:
- mov al, bl
- mov ah, bh
- cmp ax, 0x0202 ; si c'est le pixel du milieu on ne le compte pas
- je _pasdevoisin
- mov al, [es:di] ; al = etat du pixel du voisin en cours
- cmp al, 0
- je _pasdevoisin
- inc dl ; 1 voisin de plus
- _pasdevoisin:
- inc di ; on passe au pixel a droite
- dec bh
- jnz _rep3
- add di, 317 ; on passe a la prochaine ligne de 3 pixels
- dec bl
- jnz _rep2
- sub di, 639 ; on repointe sur le pixel actuel
- ; apres calcul des voisins :
- mov dh, [es:di] ; etat du pixel en cours
- cmp dl, 3 ; nb de voisins = 3 ?
- je nait ; alors nait
- cmp dl, 2 ; nb de voisins = 2 ?
- je rien ; alors rien
- xor dh, dh ; sinon meurt
- jmp rien
- nait:
- mov dh,0xf
- rien:
- push es
- mov ax, 0x2000
- mov es, ax
- mov [es:di], dh ; affiche nouvel etat de la cellule en 0x2000
- pop es
- inc di ; on passe au pixel suivant
- loop _scanLine
- add di, 2 ; on passe à la ligne suivante
- cmp di, 64001 - 320 ; pas encore le bas de l ecran?
- jb _jmpLine
- push ds
- mov ax, 0x2000
- mov ds, ax
- xor di, di
- xor si, si
- mov cx, 64000
- rep movsb
- pop ds
- ; attendre rafraichissement ecran
- mov dx,03DAh
- wax_on:
- in al,dx
- test al,8
- jz wax_on
- wax_off:
- in al,dx
- test al,8
- jnz wax_off
- ; appuyer une touche pour sortir
- mov ax, 0x0100
- int 0x16
- jz _cycle
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement