Subversion Repositories Kolibri OS

Rev

Rev 5153 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5153 IgorA 1
;PUTPIXEL -> RGBPIXEL
2
 
3
locals
4
	n dd ?
5
	d_x dd ?
6
	d_y dd ?
7
	sx dd ? ;ширина буфера в пикселях
8
	pp_inc_1 dd ?
9
	pp_inc_2 dd ?
10
	a dd ? ;register int
11
if TGL_FEATURE_RENDER_BITS eq 24
12
	r dd ? ;register unsigned int
13
	g dd ?
14
	b dd ?
15
end if
16
if INTERP_Z eq 1
17
	pz dd ? ;register unsigned short *
18
	zinc dd ?
19
	z dd ? ;register int
20
	zz dd ?
21
end if
22
endl
23
pushad
24
 
25
	mov eax,[p1]
26
	mov ebx,[p2]
27
	mov ecx,[ebx+offs_zbup_y]
28
	cmp [eax+offs_zbup_y], ecx ;if (p1.y > p2.y)
29
	jg @f
30
	jl .end_0 ;if (p1.y != p2.y)
31
	mov ecx,[ebx+offs_zbup_x]
32
	cmp [eax+offs_zbup_x], ecx ;if (p1.x > p2.x)
33
	jle .end_0 ;if (p1.x <= p2.x)
34
	@@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x))
35
		mov [p1],ebx
36
		mov [p2],eax
37
	.end_0:
38
 
39
	mov eax,[zb]
40
	mov edx,[eax+offs_zbuf_xsize]
41
	mov [sx],edx
42
	mov ecx,[p1]
43
	mov edi,[eax+offs_zbuf_linesize]
44
	imul edi,[ecx+offs_zbup_y]
45
	mov edx,[ecx+offs_zbup_x]
46
	imul edx,PSZB
47
	add edi,edx
48
	add edi,[eax+offs_zbuf_pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB)
49
if INTERP_Z eq 1
50
	mov edx,[ecx+offs_zbup_y]
51
	imul edx,[sx]
52
	add edx,[ecx+offs_zbup_x]
5159 IgorA 53
	shl edx,1
5153 IgorA 54
	add edx,[eax+offs_zbuf_zbuf]
55
	mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
56
	mov edx,[ecx+offs_zbup_z]
57
	mov [z],edx ;z = p1.z
58
end if
59
 
60
	mov ebx,[p2]
61
	mov eax,[ebx+offs_zbup_x]
62
	sub eax,[ecx+offs_zbup_x]
63
	mov [d_x],eax ;d_x = p2.x - p1.x
64
	mov eax,[ebx+offs_zbup_y]
65
	sub eax,[ecx+offs_zbup_y]
66
	mov [d_y],eax ;d_y = p2.y - p1.y
67
if TGL_FEATURE_RENDER_BITS eq 24
68
	; for 24 bits, we store the colors in different variables
69
	mov eax,[ebx+offs_zbup_r]
70
	shr eax,8
71
	mov [r],eax ;r = p2.r >> 8
72
	mov eax,[ebx+offs_zbup_g]
73
	shr eax,8
74
	mov [g],eax ;g = p2.g >> 8
75
	mov eax,[ebx+offs_zbup_b]
76
	shr eax,8
77
	mov [b],eax ;b = p2.b >> 8
78
end if
79
 
80
macro RGBPIXEL
81
{
82
if TGL_FEATURE_RENDER_BITS eq 24
83
	mov eax,[r]
84
	mov byte[edi],al
85
	mov eax,[g]
86
	mov byte[edi+1],al
87
	mov eax,[b]
88
	mov byte[edi+2],al
89
;;;	else
90
;;;	mov eax,[color]
91
;;;	mov [edi],eax
92
end if
93
}
94
 
95
macro PUTPIXEL
96
{
97
if INTERP_Z eq 1
98
local .end_0
99
	mov eax,[z]
100
	shr eax, ZB_POINT_Z_FRAC_BITS
101
	mov [zz],eax
5159 IgorA 102
	mov ebx,[pz]
103
	cmp ax,word[ebx]
5153 IgorA 104
	jl .end_0
105
		RGBPIXEL
106
		mov eax,dword[zz]
5159 IgorA 107
		mov ebx,[pz]
108
		mov word[ebx],ax
5153 IgorA 109
	.end_0:
5159 IgorA 110
else
5153 IgorA 111
	RGBPIXEL
5159 IgorA 112
end if
5153 IgorA 113
}
114
 
115
macro DRAWLINE d_x,d_y,inc_1,inc_2
116
{
5159 IgorA 117
local .mz_0
118
local .mz_1
119
local .mz_2
120
 
5153 IgorA 121
	mov eax,d_x
122
	mov [n],eax
123
if INTERP_Z eq 1
124
	mov ebx,[p1]
125
	mov eax,[p2]
126
	mov eax,[eax+offs_zbup_z]
5159 IgorA 127
	cmp eax,[ebx+offs_zbup_z]
128
	jg .mz_0
129
	je .mz_1
130
		;if(p2.z
131
		sub eax,[ebx+offs_zbup_z]
132
		neg eax
133
		inc eax
134
		xor edx,edx
135
		div dword[n]
136
		neg eax
137
		inc eax
138
		jmp .mz_2
139
	.mz_0:
5153 IgorA 140
	sub eax,[ebx+offs_zbup_z]
141
	xor edx,edx
142
	div dword[n]
5159 IgorA 143
	jmp .mz_2
144
	.mz_1:
145
		xor eax,eax
146
	.mz_2:
5153 IgorA 147
	mov [zinc],eax ;zinc=(p2.z-p1.z)/n
148
end if
149
	shl dword d_y,1
150
	mov eax, d_y
151
	sub eax, d_x
152
	mov [a],eax ;a=2*d_y-d_x
153
	shl dword d_x,1
154
	mov eax, d_y
155
	sub d_x,eax
156
	mov eax,inc_1
157
	imul eax,PSZB
158
	mov [pp_inc_1],eax ;pp_inc_1 = inc_1*PSZB
159
	mov eax,inc_2
160
	imul eax,PSZB
161
	mov [pp_inc_2],eax ;pp_inc_2 = inc_2*PSZB
162
 
163
local .do_cycle
164
local .els_0
165
local .end_0
166
 
167
align 4
168
.do_cycle:
169
 
170
	PUTPIXEL
171
if INTERP_Z eq 1
172
	mov eax,[zinc]
173
	add [z],eax
174
end if
175
 
176
	cmp dword[a],0
177
	jle .els_0
178
	add edi,[pp_inc_1]
179
if INTERP_Z eq 1
180
	mov eax,inc_1
5159 IgorA 181
	shl eax,1
5153 IgorA 182
	add [pz],eax
183
end if
184
	mov eax,d_x
185
	sub [a],eax
186
	jmp .end_0
187
 
188
.els_0:
189
	add edi,[pp_inc_2]
190
if INTERP_Z eq 1
191
	mov eax,inc_2
5159 IgorA 192
	shl eax,1
5153 IgorA 193
	add [pz],eax
194
end if
195
	mov eax,d_y
196
	add [a],eax
197
 
198
.end_0:
199
	dec dword[n]
200
	cmp dword[n],0
201
	jge .do_cycle
202
}
203
 
204
; fin macro
205
 
206
	mov eax,[d_x]
207
	cmp eax,0
208
	jne .els_0
209
	cmp dword[d_y],0
210
	jne .els_0
211
		;if (d_x==0 && d_y==0)
212
		PUTPIXEL
213
		jmp .end_2
214
	.els_0:
215
	cmp eax,0
216
	jle .els_3
217
		;if (d_x > 0)
218
		mov esi,[sx]
219
		inc esi
220
		cmp eax,[d_y]
221
		jl .els_2
222
			;if (d_x >= d_y)
223
			DRAWLINE [d_x], [d_y], esi, 1
224
			jmp .end_2
225
		.els_2:
226
			DRAWLINE [d_y], [d_x], esi, [sx]
227
			jmp .end_2
228
	.els_3:
229
		xor eax,eax
230
		sub eax,[d_x]
231
		mov [d_x],eax
232
		mov esi,[sx]
233
		dec esi
234
		cmp eax,[d_y]
235
		jl .els_4
236
			;if (d_x >= d_y)
237
			DRAWLINE [d_x], [d_y], esi, -1
238
			jmp .end_2
239
		.els_4:
240
			DRAWLINE [d_y], [d_x], esi, [sx]
241
	.end_2:
242
 
243
popad
244
	ret
245
endp
246
 
247
restore INTERP_Z
248
 
249
; internal defines
250
purge DRAWLINE
251
purge PUTPIXEL
252
purge RGBPIXEL