Subversion Repositories Kolibri OS

Rev

Rev 5159 | 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
	r dd ? ;register unsigned int
12
	g dd ?
13
	b dd ?
14
	rinc dd ? ;register unsigned int
15
	ginc dd ?
16
	binc dd ?
17
if INTERP_Z eq 1
18
	pz dd ? ;register unsigned short *
19
	zinc dd ?
20
	z dd ? ;register int
21
	zz dd ?
22
end if
23
endl
24
pushad
25
 
26
	mov eax,[p1]
27
	mov ebx,[p2]
8069 IgorA 28
	mov ecx,[ebx+ZBufferPoint.y]
29
	cmp [eax+ZBufferPoint.y], ecx ;if (p1.y > p2.y)
5153 IgorA 30
	jg @f
31
	jl .end_0 ;if (p1.y != p2.y)
8069 IgorA 32
	mov ecx,[ebx+ZBufferPoint.x]
33
	cmp [eax+ZBufferPoint.x], ecx ;if (p1.x > p2.x)
5153 IgorA 34
	jle .end_0 ;if (p1.x <= p2.x)
35
	@@: ;if (p1.y > p2.y || (p1.y == p2.y && p1.x > p2.x))
36
		mov [p1],ebx
37
		mov [p2],eax
38
	.end_0:
39
 
40
	mov eax,[zb]
8069 IgorA 41
	mov edx,[eax+ZBuffer.xsize]
5153 IgorA 42
	mov [sx],edx
43
	mov ecx,[p1]
8069 IgorA 44
	mov edi,[eax+ZBuffer.linesize]
45
	imul edi,[ecx+ZBufferPoint.y]
46
	mov edx,[ecx+ZBufferPoint.x]
5153 IgorA 47
	imul edx,PSZB
48
	add edi,edx
8069 IgorA 49
	add edi,[eax+ZBuffer.pbuf] ;edi = (zb.pbuf + zb.linesize*p1.y + p1.x*PSZB)
5153 IgorA 50
if INTERP_Z eq 1
8069 IgorA 51
	mov edx,[ecx+ZBufferPoint.y]
5153 IgorA 52
	imul edx,[sx]
8069 IgorA 53
	add edx,[ecx+ZBufferPoint.x]
5159 IgorA 54
	shl edx,1
8069 IgorA 55
	add edx,[eax+ZBuffer.zbuf]
5153 IgorA 56
	mov [pz],edx ;pz = zb.zbuf + (p1.y*sx + p1.x)
8069 IgorA 57
	mov edx,[ecx+ZBufferPoint.z]
5153 IgorA 58
	mov [z],edx ;z = p1.z
59
end if
60
 
61
	mov ebx,[p2]
8069 IgorA 62
	mov eax,[ebx+ZBufferPoint.x]
63
	sub eax,[ecx+ZBufferPoint.x]
5153 IgorA 64
	mov [d_x],eax ;d_x = p2.x - p1.x
8069 IgorA 65
	mov eax,[ebx+ZBufferPoint.y]
66
	sub eax,[ecx+ZBufferPoint.y]
5153 IgorA 67
	mov [d_y],eax ;d_y = p2.y - p1.y
68
 
8069 IgorA 69
	mov eax,[ecx+ZBufferPoint.r]
5153 IgorA 70
	shl eax,8
71
	mov [r],eax ;r = p1.r << 8
8069 IgorA 72
	mov eax,[ecx+ZBufferPoint.g]
5153 IgorA 73
	shl eax,8
74
	mov [g],eax ;g = p1.g << 8
8069 IgorA 75
	mov eax,[ecx+ZBufferPoint.b]
5153 IgorA 76
	shl eax,8
77
	mov [b],eax ;b = p1.b << 8
78
 
79
macro RGBPIXEL
80
{
81
if TGL_FEATURE_RENDER_BITS eq 24
82
	mov eax,[r]
83
	shr eax,16
84
	mov byte[edi],al
85
	mov eax,[g]
86
	shr eax,16
87
	mov byte[edi+1],al
88
	mov eax,[b]
89
	shr eax,16
90
	mov byte[edi+2],al
91
;;;	else
92
;*pp = RGB_TO_PIXEL(r >> 8,g >> 8,b >> 8)
93
end if
94
}
95
 
96
macro PUTPIXEL
97
{
98
if INTERP_Z eq 1
99
local .end_0
100
	mov eax,[z]
101
	shr eax, ZB_POINT_Z_FRAC_BITS
102
	mov [zz],eax
5159 IgorA 103
	mov ebx,[pz]
104
	cmp ax,word[ebx]
5153 IgorA 105
	jl .end_0
106
		RGBPIXEL
107
		mov eax,dword[zz]
5159 IgorA 108
		mov ebx,[pz]
109
		mov word[ebx],ax
5153 IgorA 110
	.end_0:
5159 IgorA 111
else
5153 IgorA 112
	RGBPIXEL
5159 IgorA 113
end if
5153 IgorA 114
}
115
 
116
macro DRAWLINE d_x,d_y,inc_1,inc_2
117
{
5159 IgorA 118
local .mz_0
119
local .mz_1
120
local .mz_2
121
local .mr_0
122
local .mr_1
123
local .mr_2
124
local .mg_0
125
local .mg_1
126
local .mg_2
127
local .mb_0
128
local .mb_1
129
local .mb_2
130
 
5153 IgorA 131
	mov eax,d_x
132
	mov [n],eax
133
 
134
	mov ebx,[p1]
135
	mov ecx,[p2]
136
if INTERP_Z eq 1
8069 IgorA 137
	mov eax,[ecx+ZBufferPoint.z]
138
	cmp eax,[ebx+ZBufferPoint.z]
5159 IgorA 139
	jg .mz_0
140
	je .mz_1
141
		;if(p2.z
8069 IgorA 142
		sub eax,[ebx+ZBufferPoint.z]
5159 IgorA 143
		neg eax
144
		inc eax
145
		xor edx,edx
146
		div dword[n]
147
		neg eax
148
		inc eax
149
		jmp .mz_2
150
	.mz_0:
8069 IgorA 151
	sub eax,[ebx+ZBufferPoint.z]
5153 IgorA 152
	xor edx,edx
153
	div dword[n]
5159 IgorA 154
	jmp .mz_2
155
	.mz_1:
156
		xor eax,eax
157
	.mz_2:
5153 IgorA 158
	mov [zinc],eax ;zinc=(p2.z-p1.z)/n
159
end if
160
 
161
	;ebx=&p1, ecx=&p2
8069 IgorA 162
	mov eax,[ecx+ZBufferPoint.r]
163
	cmp eax,[ebx+ZBufferPoint.r]
5159 IgorA 164
	jg .mr_0
165
	je .mr_1
166
		;if(p2.r
8069 IgorA 167
		sub eax,[ebx+ZBufferPoint.r]
5159 IgorA 168
		neg eax
169
		inc eax
170
		shl eax,8
171
		xor edx,edx
172
		div dword[n]
173
		neg eax
174
		inc eax
175
		jmp .mr_2
176
	.mr_0:
8069 IgorA 177
	sub eax,[ebx+ZBufferPoint.r]
5153 IgorA 178
	shl eax,8
179
	xor edx,edx
180
	div dword[n]
5159 IgorA 181
	jmp .mr_2
182
	.mr_1:
183
		xor eax,eax
184
	.mr_2:
5153 IgorA 185
	mov [rinc],eax ;rinc=((p2.r-p1.r)<<8)/n
186
 
8069 IgorA 187
	mov eax,[ecx+ZBufferPoint.g]
188
	cmp eax,[ebx+ZBufferPoint.g]
5159 IgorA 189
	jg .mg_0
190
	je .mg_1
191
		;if(p2.g
8069 IgorA 192
		sub eax,[ebx+ZBufferPoint.g]
5159 IgorA 193
		neg eax
194
		inc eax
195
		shl eax,8
196
		xor edx,edx
197
		div dword[n]
198
		neg eax
199
		inc eax
200
		jmp .mg_2
201
	.mg_0:
8069 IgorA 202
	sub eax,[ebx+ZBufferPoint.g]
5153 IgorA 203
	shl eax,8
204
	xor edx,edx
205
	div dword[n]
5159 IgorA 206
	jmp .mg_2
207
	.mg_1:
208
		xor eax,eax
209
	.mg_2:
5153 IgorA 210
	mov [ginc],eax ;ginc=((p2.g-p1.g)<<8)/n
211
 
8069 IgorA 212
	mov eax,[ecx+ZBufferPoint.b]
213
	cmp eax,[ebx+ZBufferPoint.b]
5159 IgorA 214
	jg .mb_0
215
	je .mb_1
216
		;if(p2.b
8069 IgorA 217
		sub eax,[ebx+ZBufferPoint.b]
5159 IgorA 218
		neg eax
219
		inc eax
220
		shl eax,8
221
		xor edx,edx
222
		div dword[n]
223
		neg eax
224
		inc eax
225
		jmp .mb_2
226
	.mb_0:
8069 IgorA 227
	sub eax,[ebx+ZBufferPoint.b]
5153 IgorA 228
	shl eax,8
229
	xor edx,edx
230
	div dword[n]
5159 IgorA 231
	jmp .mb_2
232
	.mb_1:
233
		xor eax,eax
234
	.mb_2:
5153 IgorA 235
	mov [binc],eax ;binc=((p2.b-p1.b)<<8)/n
236
 
237
	shl dword d_y,1
238
	mov eax, d_y
239
	sub eax, d_x
240
	mov [a],eax ;a=2*d_y-d_x
241
	shl dword d_x,1
242
	mov eax, d_y
243
	sub d_x,eax
244
	mov eax,inc_1
245
	imul eax,PSZB
246
	mov [pp_inc_1],eax ;pp_inc_1 = inc_1*PSZB
247
	mov eax,inc_2
248
	imul eax,PSZB
249
	mov [pp_inc_2],eax ;pp_inc_2 = inc_2*PSZB
250
 
251
local .do_cycle
252
local .els_0
253
local .end_0
254
 
255
align 4
256
.do_cycle:
257
 
258
	PUTPIXEL
259
if INTERP_Z eq 1
260
	mov eax,[zinc]
261
	add [z],eax
262
end if
263
	mov eax,[rinc]
264
	add [r],eax
265
	mov eax,[ginc]
266
	add [g],eax
267
	mov eax,[binc]
268
	add [b],eax
269
 
270
	cmp dword[a],0
271
	jle .els_0
272
	add edi,[pp_inc_1]
273
if INTERP_Z eq 1
274
	mov eax,inc_1
5159 IgorA 275
	shl eax,1
5153 IgorA 276
	add [pz],eax
277
end if
278
	mov eax,d_x
279
	sub [a],eax
280
	jmp .end_0
281
 
282
.els_0:
283
	add edi,[pp_inc_2]
284
if INTERP_Z eq 1
285
	mov eax,inc_2
5159 IgorA 286
	shl eax,1
5153 IgorA 287
	add [pz],eax
288
end if
289
	mov eax,d_y
290
	add [a],eax
291
 
292
.end_0:
293
	dec dword[n]
294
	cmp dword[n],0
295
	jge .do_cycle
296
}
297
 
298
; fin macro
299
 
300
	mov eax,[d_x]
301
	cmp eax,0
302
	jne .els_0
303
	cmp dword[d_y],0
304
	jne .els_0
305
		;if (d_x==0 && d_y==0)
306
		PUTPIXEL
307
		jmp .end_2
308
	.els_0:
309
	cmp eax,0
310
	jle .els_3
311
		;if (d_x > 0)
312
		mov esi,[sx]
313
		inc esi
314
		cmp eax,[d_y]
315
		jl .els_2
316
			;if (d_x >= d_y)
317
			DRAWLINE [d_x], [d_y], esi, 1
318
			jmp .end_2
319
		.els_2:
320
			DRAWLINE [d_y], [d_x], esi, [sx]
321
			jmp .end_2
322
	.els_3:
323
		xor eax,eax
324
		sub eax,[d_x]
325
		mov [d_x],eax
326
		mov esi,[sx]
327
		dec esi
328
		cmp eax,[d_y]
329
		jl .els_4
330
			;if (d_x >= d_y)
331
			DRAWLINE [d_x], [d_y], esi, -1
332
			jmp .end_2
333
		.els_4:
334
			DRAWLINE [d_y], [d_x], esi, [sx]
335
	.end_2:
336
 
337
popad
338
	ret
339
endp
340
 
341
restore INTERP_Z
342
 
343
; internal defines
344
purge DRAWLINE
345
purge PUTPIXEL
346
purge RGBPIXEL