Bonjour !!
En fait je voudrais savoir comment peut on tracer une ligne droite avec TASM sans utiliser de routine toute faite, sans utiliser de int ( enfin le moins possible ....)
Merci d avance !!!!!
@++
Bonjour !!
En fait je voudrais savoir comment peut on tracer une ligne droite avec TASM sans utiliser de routine toute faite, sans utiliser de int ( enfin le moins possible ....)
Merci d avance !!!!!
@++
Tracer une ligne droite !
C'est plutôt vaste comme sujet ! Je suppose que c'est en mode graphique. Disons le 13h, c'est le plus simple.
Il te faut calculer l'adresse de départ : Start = Y * Largeur * OctetsParPixel + X * OctetsParPixel
En 13h, ça donne Start = Y * 320 + X
Tu stockes ça dans DI, et tu fixe ES à 0A000h (le segment vidéo)
Après, il faut savoir si tu veux une ligne droite, droite (horizontale ou vertical), ou bien une droite "oblique". Dans le deuxième cas, cherche l'algo de Bresenham.
Sinon, c'est simple. Précise s'il te plait.
A+
C trop cool tu soit la !!
Bientot je t enverrait directement mes question par mail !!!! :-)
Je cherche pour tracer une ligne horizontale ou verticale, mais si elle fait que 8 pixel c pas grave mais ca serait cool si t faisait la source ! :-)mais si t peu pas c pas grave...:-)
Pour l algo pour les ligne des oblique je sait ou le toruver ...
Merci d avance !!!
@++
Non, ne m'envoie pas tes questions par mail, je n'y répondrais pas. Le forum est là pour ça. Tout le monde a le droit d'en profiter.
Tu te foule pas beaucoup. C'est simple à faire...
Pour la ligne horizontale :
Ca devrait fonctionner.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 mov ax, 0A000h mov es, ax mov di, Y mov ax, di shl ax, 6 shl di, 8 add di, ax add di, X1 mov al, Color mov cx, X2 sub cx, X1 inc cx rep stosb
Pour le vertical, je te laisse chercher un peu, mince à la fin !
A+
Salut,
avec l'algo de Bresenhams:
http://graphics.cs.ucdavis.edu/Graph...-Algorithm.pdf
le code pour 320x200:
Les routines :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 ;linedraw [in] x1 dw 0 y1 dw 0 x2 dw 0 y2 dw 0 color dw 0 scr_off dw 0 scr_seg dw 0 ;linedraw locale y_unit dw 0 x_unit dw 0 xdiff dw 0 ydiff dw 0 error_term dw 0 mov scr_seg,0a000h mov scr_off,0 mov ax,Pos_x mov x1,ax mov ax,Pos_y mov y1,ax mov x2,320 mov y2,200 mov color,120 call linedraw
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 ;ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß ; SUBROUTINE ;ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ %OUT LINEDRAW linedraw proc near mov ax,scr_seg ;Get screen segment in ax mov es,ax mov ax,y1 ;Get y1 in ax... mov dx,320 ;Multiply by 320 mul dx add ax,x1 ;And add x1 to get pixel offset add ax,scr_off ;Add screen offset mov bx,ax ;Move offset to BX init_line: mov dx,color ;Put pixel color in dx mov error_term,0 ;Initialize error term mov ax,y2 ;Determine sign of y2-y1 sub ax,y1 jns ypos ;If positive, jump mov y_unit,-320 ;Else handle negative slope neg ax ;Get absolute value of YDIFF mov ydiff,ax ;And store it in memory jmp next ypos: mov y_unit,320 ;Handle positive slope mov ydiff,ax ;Store YDIFF in memory next: mov ax,x2 ;Determine sign of x2-x1 sub ax,x1 jns xpos ;If positive, jump mov x_unit,-1 ;Else handle negative case neg ax ;Get absolute value of XDIFF mov xdiff,ax ;And store it in memory jmp next2 xpos: mov x_unit,1 ; Handle positive case mov xdiff,ax ; Store XDIFF in memory next2: cmp ax,ydiff ; Compare XDIFF (in AX) and YDIFF jc yline ; IF XDIFF<YDIFF then count ; in Y dimension jmp xline ; Else count in X dimension ; xline: ; Slope less than one, so increment in x dimension mov cx,xdiff ;Get line length in cx for count inc cx xline1: mov es:[bx],dl ;Draw next point in line add bx,x_unit ;Point offset to next pixel in ;x direction mov ax,error_term ;Check to see if move required ;in Y direction? add ax,ydiff mov error_term,ax sub ax,xdiff jc xline2 ;If not, continue mov error_term,ax add bx,y_unit ;Else, move up or down one pixel xline2: loop xline1 ; Loop until count (in CX) complete jmp linedone ; yline: ; Count in y dimension mov cx,ydiff ;Get line length in cx inc cx yline1: mov es:[bx],dl ;Draw next point in line add bx,y_unit ;Point offset to next pixel ;in Y direction mov ax,error_term ;Check to see if move require ;in X direciton add ax,xdiff mov error_term,ax sub ax,ydiff jc yline2 ;If not, continue mov error_term,ax add bx,x_unit ;Else, move left or right ;one pixel yline2: loop yline1 ;Loop until count (in CX) complete linedone: ret linedraw endp
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager