Subversion Repositories Kolibri OS

Rev

Rev 551 | Rev 2205 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 551 Rev 625
Line 23... Line 23...
23
SCREEN_X equ 320
23
SCREEN_X equ 320
24
SCREEN_Y equ 200
24
SCREEN_Y equ 200
Line 25... Line 25...
25
 
25
 
26
include 'lang.inc'
26
include 'lang.inc'
-
 
27
include '..\..\..\macros.inc'
27
include '..\..\..\macros.inc'
28
;purge mov
28
include 'ascl.inc'
29
include 'ascl.inc'
Line 29... Line 30...
29
include 'ascgl.inc'
30
include 'ascgl.inc'
-
 
31
 
-
 
32
START:
-
 
33
init_sin_cos:
-
 
34
	finit
-
 
35
	fldz
-
 
36
	xor edi,edi
-
 
37
	mov ecx,512
-
 
38
isc_make:
-
 
39
	fld st0
-
 
40
	fsincos
-
 
41
	fmul [fixed_point_const]
-
 
42
	fistp word [cos_table+edi]
-
 
43
	fmul [fixed_point_const]
-
 
44
	fistp word [sin_table+edi]
-
 
45
 
-
 
46
	fadd [inc_angle]
-
 
47
 
-
 
48
	add edi,2
-
 
49
	loop isc_make
30
 
50
	fstp st0
31
START:
-
 
Line 32... Line 51...
32
    call draw_window
51
red:
33
   	call init_sin_cos
52
    call draw_window
34
 
53
 
Line 74... Line 93...
74
	add [angle_y],3
93
	add [angle_y],3
75
	add [angle_z],1
94
	add [angle_z],1
Line 76... Line 95...
76
 
95
 
Line 77... Line -...
77
     jmp still
-
 
78
 
-
 
79
red:
-
 
80
     call draw_window
96
     jmp still
81
     jmp still
97
 
82
key:
98
key:
83
     mov eax,2
99
     mov eax,2
84
     mcall
100
     mcall
Line 122... Line 138...
122
df_draw:
138
df_draw:
123
	push ecx
139
	push ecx
124
	mov ecx,3
140
	mov ecx,3
125
	mov edi,@@tx1 ;bp
141
	mov edi,@@tx1 ;bp
126
df_get_point:
142
df_get_point:
127
	xor bh,bh
-
 
128
	mov bl,byte [esi]
143
	movzx	ebx, byte [esi]
129
	shl bx,2
-
 
130
	mov ax,word [object_translated+bx]
144
	movzx	eax, word [object_translated + ebx*4]
131
	mov word [edi],ax
145
	stosd
132
	mov ax,word [object_translated+bx+2]
146
	movzx	eax, word [object_translated + ebx*4 + 2]
133
	mov word [edi+2],ax
147
	stosd
134
	inc esi
148
	inc esi
135
	add edi,4
-
 
136
	dec ecx
149
	dec ecx
137
	jnz df_get_point
150
	jnz df_get_point
Line 138... Line 151...
138
 
151
 
139
	mov ax,[@@ty1]
152
	mov eax,[@@ty1]
140
	sub ax,[@@ty3]
153
	sub eax,[@@ty3]
141
	mov bx,[@@tx2]
154
	mov ebx,[@@tx2]
142
	sub bx,[@@tx1]
155
	sub ebx,[@@tx1]
143
	imul bx
-
 
144
	shl edx,16
-
 
145
	mov dx,ax
156
	imul ebx
146
	push edx
157
	push eax
147
	mov ax,[@@tx1]
158
	mov eax,[@@tx1]
148
	sub ax,[@@tx3]
159
	sub eax,[@@tx3]
149
	mov bx,[@@ty2]
160
	mov ebx,[@@ty2]
150
	sub bx,[@@ty1]
161
	sub ebx,[@@ty1]
151
	imul bx
-
 
152
	shl edx,16
-
 
153
	mov dx,ax
162
	imul ebx
154
	pop ebx
163
	pop ebx
155
	sub ebx,edx
-
 
156
	or ebx,ebx
164
	sub ebx,eax
Line 157... Line -...
157
	jge df_next
-
 
158
 
165
	jge df_next
Line 159... Line 166...
159
	xor ah,ah
166
 
Line 160... Line 167...
160
	mov al,byte [si]
167
	movzx	eax, byte [esi]
161
	
168
	
162
 mov  [@@xcol],ax
169
	mov  	[@@xcol], eax
163
 
170
 
164
	call filled_triangle
171
	call filled_triangle
165
df_next:
172
df_next:
166
	inc si
173
	inc esi
Line 176... Line 183...
176
 
183
 
177
;outscrbuf
184
;outscrbuf
178
 mov ebx,scrbuf
185
 mov ebx,scrbuf
179
 mov ecx,SCREEN_X*65536+SCREEN_Y
186
 mov ecx,SCREEN_X*65536+SCREEN_Y
180
 mov edx,5*65536+22
187
 mov edx,5*65536+22
181
 mov ax,7
188
 mov eax,7
Line 182... Line 189...
182
 mcall
189
 mcall
183
 
190
 
184
;White background
191
;White background
Line 194... Line 201...
194
; Mikolaj Felix 14/5/2001
201
; Mikolaj Felix 14/5/2001
195
; mfelix@polbox.com
202
; mfelix@polbox.com
Line 196... Line 203...
196
 
203
 
Line -... Line 204...
-
 
204
;filled trangle procedure
197
;filled trangle procedure
205
 
198
 
206
align 4
199
@@tx1  dw 0
207
@@tx1  dd 0
200
@@ty1  dw 0
208
@@ty1  dd 0
201
@@tx2  dw 0
209
@@tx2  dd 0
202
@@ty2  dw 0
210
@@ty2  dd 0
203
@@tx3  dw 0
211
@@tx3  dd 0
204
@@ty3  dw 0
212
@@ty3  dd 0
205
@@xcol dw 0
213
@@xcol dd 0
206
 
214
 
207
@@dx12 dw 0
215
@@dx12 dd 0
Line 208... Line 216...
208
@@dx13 dw 0
216
@@dx13 dd 0
Line 209... Line 217...
209
@@dx23 dw 0
217
@@dx23 dd 0
210
 
218
 
211
filled_triangle:
219
filled_triangle:
212
 
220
 
213
 mov ax,[@@xcol]  ;trnsforming color
221
 mov eax,[@@xcol]  ;trnsforming color
Line 232... Line 240...
232
 shl eax,8 ;puck colors
240
 shl eax,8 ;puck colors
233
 mov al,bl
241
 mov al,bl
234
 shl eax,8
242
 shl eax,8
235
 mov al,dl
243
 mov al,dl
236
 mov dword [@@rgb],eax
244
 mov dword [@@rgb],eax
237
 mov eax,0 ; for 16 bit instructions
-
 
Line 238... Line 245...
238
 
245
 
239
	mov ax,[@@ty1]
246
	mov eax,[@@ty1]
240
	cmp ax,[@@ty3]
247
	cmp eax,[@@ty3]
Line 241... Line 248...
241
	jb ft_check1
248
	jb ft_check1
242
 
249
 
Line 243... Line 250...
243
	xchg ax,[@@ty3]
250
	xchg eax,[@@ty3]
244
	mov [@@ty1],ax
251
	mov [@@ty1],eax
245
 
252
 
246
	mov ax,[@@tx1]
253
	mov eax,[@@tx1]
247
	xchg ax,[@@tx3]
254
	xchg eax,[@@tx3]
248
	mov [@@tx1],ax
255
	mov [@@tx1],eax
249
ft_check1:
256
ft_check1:
Line 250... Line 257...
250
	mov ax,[@@ty2]
257
	mov eax,[@@ty2]
251
	cmp ax,[@@ty3]
258
	cmp eax,[@@ty3]
Line 252... Line 259...
252
	jb ft_check2
259
	jb ft_check2
253
 
260
 
254
	xchg ax,[@@ty3]
261
	xchg eax,[@@ty3]
255
	mov [@@ty2],ax
262
	mov [@@ty2],eax
256
 
263
 
257
	mov ax,[@@tx2]
264
	mov eax,[@@tx2]
258
	xchg ax,[@@tx3]
265
	xchg eax,[@@tx3]
Line 259... Line 266...
259
	mov [@@tx2],ax
266
	mov [@@tx2],eax
260
ft_check2:
267
ft_check2:
Line 261... Line 268...
261
	mov ax,[@@ty1]
268
	mov eax,[@@ty1]
262
	cmp ax,[@@ty2]
269
	cmp eax,[@@ty2]
263
	jb ft_check3
270
	jb ft_check3
264
 
271
 
Line 265... Line 272...
265
	xchg ax,[@@ty2]
272
	xchg eax,[@@ty2]
266
	mov [@@ty1],ax
273
	mov [@@ty1],eax
267
 
274
 
Line 268... Line 275...
268
	mov ax,[@@tx1]
275
	mov eax,[@@tx1]
269
	xchg ax,[@@tx2]
276
	xchg eax,[@@tx2]
270
	mov [@@tx1],ax
277
	mov [@@tx1],eax
271
ft_check3:
278
ft_check3:
272
 
279
 
273
	mov bx,[@@ty2]
280
	mov ebx,[@@ty2]
274
	sub bx,[@@ty1]
281
	sub ebx,[@@ty1]
275
	jnz ft_dx12_make
282
	jnz ft_dx12_make
276
 
283
 
277
	mov [@@dx12],word 0
284
	mov [@@dx12],dword 0
Line 278... Line 285...
278
	jmp ft_dx12_done
285
	jmp ft_dx12_done
279
ft_dx12_make:
286
ft_dx12_make:
280
	mov ax,[@@tx2]
287
	mov eax,[@@tx2]
Line 281... Line 288...
281
	sub ax,[@@tx1]
288
	sub eax,[@@tx1]
282
	shl ax,7
289
	shl eax,7
283
	cwd
290
	cdq
284
	idiv bx
291
	idiv ebx
285
	mov [@@dx12],ax			; dx12 = (x2-x1)/(y2-y1)
292
	mov [@@dx12],eax			; dx12 = (x2-x1)/(y2-y1)
286
ft_dx12_done:
293
ft_dx12_done:
287
 
294
 
288
	mov bx,[@@ty3]
295
	mov ebx,[@@ty3]
289
	sub bx,[@@ty1]
296
	sub ebx,[@@ty1]
290
	jnz ft_dx13_make
297
	jnz ft_dx13_make
Line 291... Line 298...
291
 
298
 
292
	mov [@@dx13],word 0
299
	mov [@@dx13],dword 0
293
	jmp ft_dx13_done
300
	jmp ft_dx13_done
Line 294... Line 301...
294
ft_dx13_make:
301
ft_dx13_make:
295
	mov ax,[@@tx3]
302
	mov eax,[@@tx3]
296
	sub ax,[@@tx1]
303
	sub eax,[@@tx1]
297
	shl ax,7
304
	shl eax,7
298
	cwd
305
	cdq
299
	idiv bx
306
	idiv ebx
300
	mov [@@dx13],ax			; dx13 = (x3-x1)/(y3-y1)
307
	mov [@@dx13],eax			; dx13 = (x3-x1)/(y3-y1)
301
ft_dx13_done:
308
ft_dx13_done:
302
 
309
 
303
	mov bx,[@@ty3]
310
	mov ebx,[@@ty3]
Line 304... Line 311...
304
	sub bx,[@@ty2]
311
	sub ebx,[@@ty2]
305
	jnz ft_dx23_make
312
	jnz ft_dx23_make
306
 
313
 
Line 307... Line 314...
307
	mov [@@dx23],word 0
314
	mov [@@dx23],dword 0
308
	jmp ft_dx23_done
315
	jmp ft_dx23_done
Line 309... Line 316...
309
ft_dx23_make:
316
ft_dx23_make:
Line 310... Line 317...
310
	mov ax,[@@tx3]
317
	mov eax,[@@tx3]
311
	sub ax,[@@tx2]
318
	sub eax,[@@tx2]
312
	shl ax,7
319
	shl eax,7
313
	cwd
320
	cdq
314
	idiv bx
321
	idiv ebx
315
	mov [@@dx23],ax			; dx23 = (x3-x2)/(y3-y2)
322
	mov [@@dx23],eax			; dx23 = (x3-x2)/(y3-y2)
316
ft_dx23_done:
323
ft_dx23_done:
317
 
324
 
318
	mov ax,[@@tx1]
325
	mov eax,[@@tx1]
319
	shl ax,7
326
	shl eax,7
Line 320... Line 327...
320
	mov bx,ax
327
	mov ebx,eax
Line 321... Line 328...
321
 
328
 
322
	mov cx,[@@ty1]
329
	mov ecx,[@@ty1]
323
ft_loop1:
330
ft_loop1:
324
 
331
 
325
 pushad
332
 pushad
Line 326... Line 333...
326
 
333
 
327
	mov [@@ly],cx
334
	mov [@@ly],ecx
328
	mov dx,bx
335
	mov edx,ebx
329
	shr dx,7
336
	shr edx,7
Line 330... Line 337...
330
	mov [@@lx2],dx
337
	mov [@@lx2],edx
Line 331... Line 338...
331
	mov dx,ax
338
	mov edx,eax
332
	shr dx,7
339
	shr edx,7
333
	mov [@@lx1],dx
340
	mov [@@lx1],edx
334
	mov ax,[@@xcol]
341
	mov eax,[@@xcol]
335
 mov [@@lcol],ax
342
 mov [@@lcol],eax
336
 call horizontal_line
343
 call horizontal_line
337
 
344
 
338
 popad
345
 popad
339
 
346
 
340
	add ax,[@@dx13]
347
	add eax,[@@dx13]
Line 341... Line 348...
341
	add bx,[@@dx12]
348
	add ebx,[@@dx12]
Line 342... Line 349...
342
	inc cx
349
	inc ecx
343
	cmp cx,[@@ty2]
350
	cmp ecx,[@@ty2]
344
	jb ft_loop1
351
	jb ft_loop1
345
 
352
 
346
	
353
	
Line 347... Line 354...
347
	mov bx,[@@tx2]
354
	mov ebx,[@@tx2]
Line 348... Line 355...
348
	shl bx,7
355
	shl ebx,7
Line -... Line 356...
-
 
356
	mov ecx,[@@ty2]
349
	mov cx,[@@ty2]
357
ft_loop2:
350
ft_loop2:
358
 
351
 
359
 pushad
352
 pushad
360
 
Line 353... Line 361...
353
 
361
	mov [@@ly],ecx
Line 354... Line 362...
354
	mov [@@ly],cx
362
	mov edx,ebx
Line 355... Line -...
355
	mov dx,bx
-
 
356
	shr dx,7
363
	shr edx,7
357
	mov [@@lx2],dx
364
	mov [@@lx2],edx
358
	mov dx,ax
365
	mov edx,eax
359
	shr dx,7
366
	shr edx,7
360
	mov [@@lx1],dx
367
	mov [@@lx1],edx
361
 mov ax,[@@xcol]
-
 
362
 mov [@@lcol],ax
368
 mov eax,[@@xcol]
363
	call horizontal_line
369
 mov [@@lcol],eax
364
 
370
	call horizontal_line
365
 popad
371
 
366
 
-
 
367
	add ax,[@@dx13]
-
 
368
	add bx,[@@dx23]
372
 popad
369
	inc ecx
373
 
370
	cmp cx,[@@ty3]
374
	add eax,[@@dx13]
371
	jb ft_loop2
375
	add ebx,[@@dx23]
372
 
376
	inc ecx
373
	ret
377
	cmp ecx,[@@ty3]
374
 
-
 
375
;horizontal line subproc
378
	jb ft_loop2
376
 
379
 
377
@@lx1  dw 0
380
	ret
378
@@lx2  dw 0
-
 
379
@@ly   dw 0
-
 
380
@@lcol dw 0
381
 
381
 
-
 
382
@@rgb  dd 0
-
 
383
 
-
 
384
horizontal_line:
382
;horizontal line subproc
385
 
383
 
386
 mov ecx,0
384
align 4
Line 387... Line 385...
387
 mov cx,[@@lx1]
385
@@lx1  dd 0
388
 cmp cx,[@@lx2]
386
@@lx2  dd 0
Line 454... Line 452...
454
 
452
 
455
 push edi
453
 push edi
456
	mov edi,@@sin_x
454
	mov edi,@@sin_x
457
	mov edx,3
455
	mov edx,3
458
rp_sin_cos:
456
rp_sin_cos:
459
	mov bx,word [esi]
457
	mov ebx, [esi]
460
	and bx,511
-
 
461
	shl bx,1
458
	and ebx,511
462
	mov ax,word [sin_table+bx]
459
	mov ax,word [sin_table+ebx*2]
463
	mov word [edi],ax
460
	mov word [edi],ax
464
	mov ax,word [cos_table+bx]
461
	mov ax,word [cos_table+ebx*2]
Line 465... Line 462...
465
	mov word [edi+2],ax
462
	mov word [edi+2],ax
466
 
463
 
467
	add esi,2
464
	add esi,2
Line 589... Line 586...
589
y_n:
586
y_n:
590
 mov [mx],ax
587
 mov [mx],ax
591
 mov [my],bx
588
 mov [my],bx
592
 popad
589
 popad
Line 593... Line -...
593
 
-
 
594
 mov ebx,0  ;?
590
 
595
	mov bx,word [esi+4]
591
	movzx ebx,word [esi+4]
596
 mov ax,[my]
592
 mov ax,[my]
597
 cmp ax,0
593
 cmp ax,0
598
 jng no_m
594
 jng no_m
599
 shl ax,3
595
 shl ax,3
600
 add bx,ax
596
 add bx,ax
601
no_m:
597
no_m:
Line 602... Line -...
602
 add bx,256  ; Z factor (zoom)
-
 
603
 
598
 add bx,256  ; Z factor (zoom)
604
 mov eax,0  ;?
599
 
605
	mov ax,word [esi]
600
 	movsx eax,word [esi]
606
	shl ax,8
601
	shl eax,8
607
	cwd
602
	cdq
608
	idiv bx; bx
603
	idiv ebx
Line 609... Line -...
609
	add ax,(SCREEN_X/2) ;160         ;X factor (center X)
-
 
610
	stosw
604
	add eax,(SCREEN_X/2) ;160         ;X factor (center X)
611
 
605
	stosw
612
 mov eax,0  ;?
606
 
613
	mov ax,word [esi+2]
607
	movsx eax,word [esi+2]
614
	shl ax,8
608
	shl eax,8
615
	cwd
609
	cdq
Line 616... Line 610...
616
	idiv bx
610
	idiv ebx
617
	add ax,(SCREEN_Y/2) ;100         ;Y factor (center Y)
611
	add eax,(SCREEN_Y/2) ;100         ;Y factor (center Y)
618
	stosw
612
	stosw
619
 
613
 
Line 620... Line -...
620
	add esi,6
-
 
621
	dec ecx
-
 
622
	jnz translate_points
-
 
623
	ret
-
 
624
 
-
 
625
init_sin_cos:
-
 
626
	finit
-
 
627
	fldz
-
 
628
	fstp [temp]
-
 
629
	xor edi,edi
-
 
630
	mov ecx,512
-
 
631
isc_make:
-
 
632
	fld [temp]
-
 
633
	fld st0
-
 
634
	fld st0
-
 
635
	fsin
-
 
636
	fmul [fixed_point_const]
-
 
637
	fistp word [sin_table+edi]
-
 
638
	fcos
-
 
639
	fmul [fixed_point_const]
-
 
640
	fistp word [cos_table+edi]
-
 
641
 
-
 
642
	fadd [inc_angle]
-
 
643
	fstp [temp]
-
 
644
 
-
 
645
	add edi,2
-
 
646
	loop isc_make
614
	add esi,6
647
	ret
615
	dec ecx
Line 648... Line 616...
648
 
616
	jnz translate_points
649
temp dd 0
617
	ret