Rev 1782 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1781 | yogev_ezra | 1 | ; |
2 | ; application : Deus Caritas Est - app shows three models shading |
||
3 | ; compiler : FASM 1.65.13 |
||
4 | ; system : KolibriOS/MenuetOS |
||
5 | ; author : macgub |
||
6 | ; email : macgub3@wp.pl |
||
7 | ; web : www.menuet.xt.pl |
||
8 | ; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS. |
||
9 | ; Special greetings to all MenuetOS maniax in the world. |
||
10 | ; I hope because my intros Christian Belive will be near to each of You. |
||
11 | |||
12 | |||
13 | ; Some adjustments made by Madis Kalme |
||
14 | ; madis.kalme@mail.ee |
||
15 | ; I tried optimizing it a bit, but don't know if it was successful. The objects |
||
16 | ; can be: |
||
17 | ; 1) Read from a file (*.3DS standard) |
||
18 | ; 2) Written in manually (at the end of the code) |
||
19 | SIZE_X equ 250 |
||
20 | SIZE_Y equ 250 |
||
21 | TIMEOUT equ 4 |
||
22 | ROUND equ 10 |
||
23 | TEX_X equ 512 ; texture width |
||
24 | TEX_Y equ 512 ; height |
||
25 | TEX_SHIFT equ 9 ; texture widith shifting |
||
26 | TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} |
||
27 | FLUENTLY = 0 |
||
28 | SHIFTING = 1 |
||
29 | ;CATMULL_SHIFT equ 8 |
||
30 | NON = 0 |
||
31 | MMX = 1 |
||
32 | |||
33 | Ext = MMX ;Ext={ NON | MMX} |
||
34 | |||
35 | use32 |
||
36 | org 0x0 |
||
37 | db 'MENUET01' ; 8 byte id |
||
38 | dd 0x01 ; header version |
||
39 | dd START ; start of code |
||
40 | dd I_END ; size of image |
||
41 | dd I_END ; memory for app |
||
42 | dd I_END ; esp |
||
43 | dd 0x0 , 0x0 ; I_Param , I_Icon |
||
44 | |||
45 | START: ; start of execution |
||
46 | cld |
||
47 | ; call alloc_buffer_mem |
||
48 | call read_from_file |
||
49 | call init_triangles_normals |
||
50 | call init_point_normals |
||
51 | call init_envmap |
||
52 | call draw_window |
||
53 | |||
54 | |||
55 | still: |
||
56 | mov eax,23 ; wait here for event with timeout |
||
57 | mov ebx,TIMEOUT |
||
58 | cmp [speed_flag],1 |
||
59 | jne .skip |
||
60 | mov eax,11 |
||
61 | .skip: |
||
62 | int 0x40 |
||
63 | |||
64 | cmp eax,1 ; redraw request ? |
||
65 | je red |
||
66 | cmp eax,2 ; key in buffer ? |
||
67 | je key |
||
68 | cmp eax,3 ; button in buffer ? |
||
69 | je button |
||
70 | |||
71 | jmp noclose |
||
72 | |||
73 | red: ; redraw |
||
74 | call draw_window |
||
75 | jmp noclose |
||
76 | |||
77 | key: ; key |
||
78 | mov eax,2 ; just read it and ignore |
||
79 | int 0x40 |
||
80 | jmp noclose |
||
81 | |||
82 | button: ; button |
||
83 | mov eax,17 ; get id |
||
84 | int 0x40 |
||
85 | |||
86 | cmp ah,1 ; button id=1 ? |
||
87 | jne .ch_another |
||
88 | |||
89 | mov eax,-1 ; close this program |
||
90 | int 0x40 |
||
91 | .ch_another: |
||
92 | cmp ah,2 |
||
93 | jne .ch_another1 |
||
94 | inc [r_flag] |
||
95 | cmp [r_flag],3 |
||
96 | jne noclose |
||
97 | mov [r_flag],0 |
||
98 | .ch_another1: |
||
99 | cmp ah,3 |
||
100 | jne .ch_another2 |
||
101 | inc [dr_flag] |
||
102 | cmp [dr_flag],3 |
||
103 | jne noclose |
||
104 | mov [dr_flag],0 |
||
105 | .ch_another2: |
||
106 | cmp ah,4 ; toggle speed |
||
107 | jne @f |
||
108 | inc [speed_flag] |
||
109 | cmp [speed_flag],2 |
||
110 | jne noclose |
||
111 | mov [speed_flag],0 |
||
112 | @@: |
||
113 | cmp ah,5 |
||
114 | jne @f ;scale- |
||
115 | mov [scale],0.7 |
||
116 | fninit |
||
117 | fld [sscale] |
||
118 | fmul [scale] |
||
119 | fstp [sscale] |
||
120 | call read_from_file |
||
121 | mov ax,[vect_x] ;-- last change |
||
122 | mov bx,[vect_y] |
||
123 | mov cx,[vect_z] |
||
124 | call add_vector |
||
125 | ; call do_scale |
||
126 | @@: |
||
127 | cmp ah,6 |
||
128 | jne @f ; scale+ |
||
129 | mov [scale],1.3 |
||
130 | fninit |
||
131 | fld [sscale] |
||
132 | fmul [scale] |
||
133 | fstp [sscale] |
||
134 | call read_from_file |
||
135 | mov ax,[vect_x] |
||
136 | mov bx,[vect_y] |
||
137 | mov cx,[vect_z] |
||
138 | call add_vector |
||
139 | call init_triangles_normals |
||
140 | call init_point_normals |
||
141 | @@: |
||
142 | cmp ah,7 |
||
143 | jne @f |
||
144 | xor ax,ax ;add vector to object and rotary point |
||
145 | mov bx,-10 |
||
146 | xor cx,cx |
||
147 | call add_vector |
||
148 | sub [vect_y],10 |
||
149 | sub [yo],10 |
||
150 | @@: |
||
151 | cmp ah,8 |
||
152 | jne @f |
||
153 | xor ax,ax |
||
154 | xor bx,bx |
||
155 | mov cx,10 |
||
156 | call add_vector |
||
157 | add [vect_z],10 |
||
158 | add [zo],10 |
||
159 | @@: |
||
160 | cmp ah,9 |
||
161 | jne @f |
||
162 | mov ax,-10 |
||
163 | xor bx,bx |
||
164 | xor cx,cx |
||
165 | call add_vector |
||
166 | sub [vect_x],10 |
||
167 | sub [xo],10 |
||
168 | @@: |
||
169 | cmp ah,10 |
||
170 | jne @f |
||
171 | mov ax,10 |
||
172 | xor bx,bx |
||
173 | xor cx,cx |
||
174 | call add_vector |
||
175 | add [vect_x],10 |
||
176 | add [xo],10 |
||
177 | @@: |
||
178 | cmp ah,11 |
||
179 | jne @f |
||
180 | xor ax,ax |
||
181 | xor bx,bx |
||
182 | mov cx,-10 |
||
183 | call add_vector |
||
184 | sub [vect_z],10 |
||
185 | sub [zo],10 |
||
186 | @@: |
||
187 | cmp ah,12 |
||
188 | jne @f |
||
189 | xor ax,ax |
||
190 | mov bx,10 |
||
191 | xor cx,cx |
||
192 | call add_vector |
||
193 | add [vect_y],10 |
||
194 | add [yo],10 |
||
195 | @@: |
||
196 | cmp ah,13 ; change main color - |
||
197 | jne @f ; - lead color setting |
||
198 | cmp [max_color_r],245 |
||
199 | jge @f |
||
200 | add [max_color_r],10 |
||
201 | call init_envmap |
||
202 | @@: |
||
203 | cmp ah,14 |
||
204 | jne @f |
||
205 | cmp [max_color_g],245 |
||
206 | jge @f |
||
207 | add [max_color_g],10 |
||
208 | call init_envmap |
||
209 | @@: |
||
210 | cmp ah,15 |
||
211 | jne @f |
||
212 | cmp [max_color_b],245 |
||
213 | jge @f |
||
214 | add [max_color_b],10 |
||
215 | call init_envmap |
||
216 | @@: |
||
217 | cmp ah,16 ; change main color |
||
218 | jne @f |
||
219 | cmp [max_color_r],10 |
||
220 | jle @f |
||
221 | sub [max_color_r],10 |
||
222 | call init_envmap |
||
223 | @@: |
||
224 | cmp ah,17 |
||
225 | jne @f |
||
226 | cmp [max_color_g],10 |
||
227 | jle @f |
||
228 | sub [max_color_g],10 |
||
229 | call init_envmap |
||
230 | @@: |
||
231 | cmp ah,18 |
||
232 | jne @f |
||
233 | cmp [max_color_b],10 |
||
234 | jle @f |
||
235 | sub [max_color_b],10 |
||
236 | call init_envmap |
||
237 | @@: |
||
238 | cmp ah,19 |
||
239 | jne @f |
||
240 | inc [catmull_flag] |
||
241 | cmp [catmull_flag],2 |
||
242 | jne @f |
||
243 | mov [catmull_flag],0 |
||
244 | @@: |
||
245 | noclose: |
||
246 | |||
247 | call calculate_angle ; calculates sinus and cosinus |
||
248 | call copy_point_normals |
||
249 | ; copy normals and rotate the copy using sin/cosbeta - best way |
||
250 | call rotate_point_normals |
||
251 | call calculate_colors |
||
252 | call copy_points |
||
253 | call rotate_points |
||
254 | call translate_perspective_points; translate from 3d to 2d |
||
255 | call clrscr ; clear the screen |
||
256 | cmp [dr_flag],2 |
||
257 | je @f |
||
258 | cmp [catmull_flag],1 ;if env_mapping sort faces |
||
259 | je @f |
||
260 | @@: |
||
261 | call sort_triangles |
||
262 | @@: |
||
263 | call fill_Z_buffer |
||
264 | |||
265 | RDTSC |
||
266 | push eax |
||
267 | call draw_triangles ; draw all triangles from the list |
||
268 | |||
269 | RDTSC |
||
270 | sub eax,[esp] |
||
271 | sub eax,41 |
||
272 | ; lea esi,[debug_points] |
||
273 | ; lea edi,[debug_points+6] |
||
274 | ; lea ebx,[debug_vector1] |
||
275 | ; call make_vector |
||
276 | ; fninit |
||
277 | ; fld [sinbeta_one] |
||
278 | ; fimul [debug_dwd] |
||
279 | ; fistp [debug_dd] |
||
280 | ; movzx eax,[debug_dd] |
||
281 | |||
282 | |||
283 | mov ecx,10 |
||
284 | .dc: |
||
285 | xor edx,edx |
||
286 | mov edi,10 |
||
287 | div edi |
||
288 | add dl,30h |
||
289 | mov [STRdata+ecx-1],dl |
||
290 | loop .dc |
||
291 | pop eax |
||
292 | macro show |
||
293 | { |
||
294 | mov eax,7 ; put image |
||
295 | mov ebx,screen |
||
296 | mov ecx,SIZE_X shl 16 + SIZE_Y |
||
297 | mov edx,5 shl 16 + 20 |
||
298 | int 0x40 |
||
299 | } |
||
300 | show |
||
301 | mov eax,4 ; function 4 : write text to window |
||
302 | mov ebx,5*65536+23 ; [x start] *65536 + [y start] |
||
303 | mov ecx,-1 |
||
304 | mov edx,STRdata ; pointer to text beginning |
||
305 | mov esi,10 ; text length |
||
306 | int 40h |
||
307 | |||
308 | |||
309 | |||
310 | jmp still |
||
311 | |||
312 | ;-------------------------------------------------------------------------------- |
||
313 | ;-------------------------PROCEDURES--------------------------------------------- |
||
314 | ;-------------------------------------------------------------------------------- |
||
315 | include "../../3DS/TEX3.INC" |
||
316 | include "../../3DS/FLAT_CAT.INC" |
||
317 | include "../../3DS/GRD_CAT.INC" |
||
318 | include "../../3DS/3DMATH.INC" |
||
319 | include "../../3DS/GRD3.INC" |
||
320 | include "../../3DS/FLAT3.INC" |
||
321 | |||
322 | |||
323 | ;alloc_buffer_mem: |
||
324 | ; mov eax,68 |
||
325 | ; mov ebx,5 |
||
326 | ; mov ecx,SIZE_X*SIZE_Y*3 |
||
327 | ; int 0x40 |
||
328 | ; mov [screen],eax |
||
329 | ;ret |
||
330 | init_envmap: |
||
331 | |||
332 | .temp equ word [ebp-2] |
||
333 | push ebp |
||
334 | mov ebp,esp |
||
335 | sub esp,2 |
||
336 | mov edi,envmap |
||
337 | fninit |
||
338 | |||
339 | mov dx,-256 |
||
340 | .ie_ver: |
||
341 | mov cx,-256 |
||
342 | .ie_hor: |
||
343 | mov .temp,cx |
||
344 | fild .temp |
||
345 | fmul st,st0 |
||
346 | mov .temp,dx |
||
347 | fild .temp |
||
348 | fmul st,st0 |
||
349 | faddp |
||
350 | fsqrt |
||
351 | mov .temp,254 |
||
352 | fisubr .temp |
||
353 | fmul [env_const] |
||
354 | fistp .temp |
||
355 | mov ax,.temp |
||
356 | |||
357 | or ax,ax |
||
358 | jge .ie_ok1 |
||
359 | xor ax,ax |
||
360 | jmp .ie_ok2 |
||
361 | .ie_ok1: |
||
362 | cmp ax,254 |
||
363 | jle .ie_ok2 |
||
364 | mov ax,254 |
||
365 | .ie_ok2: |
||
366 | push dx |
||
367 | mov bx,ax |
||
368 | mul [max_color_b] |
||
369 | shr ax,8 |
||
370 | stosb |
||
371 | mov ax,bx |
||
372 | mul [max_color_g] |
||
373 | shr ax,8 |
||
374 | stosb |
||
375 | mov ax,bx |
||
376 | mul [max_color_r] |
||
377 | shr ax,8 |
||
378 | stosb |
||
379 | pop dx |
||
380 | |||
381 | inc cx |
||
382 | cmp cx,256 |
||
383 | jne .ie_hor |
||
384 | |||
385 | inc dx |
||
386 | cmp dx,256 |
||
387 | jne .ie_ver |
||
388 | |||
389 | mov esp,ebp |
||
390 | pop ebp |
||
391 | macro debug |
||
392 | { |
||
393 | mov edi,envmap |
||
394 | mov ecx,512*512*3/4 |
||
395 | mov eax,0xffffffff |
||
396 | rep stosd |
||
397 | } |
||
398 | ret |
||
399 | calculate_colors: |
||
400 | fninit |
||
401 | xor ebx,ebx |
||
402 | movzx ecx,[points_count_var] |
||
403 | lea ecx,[ecx*3] |
||
404 | add ecx,ecx |
||
405 | .cc_again: |
||
406 | mov esi,light_vector |
||
407 | lea edi,[point_normals_rotated+ebx*2] |
||
408 | call dot_product |
||
409 | fcom [dot_min] |
||
410 | fstsw ax |
||
411 | sahf |
||
412 | ja .cc_ok1 |
||
413 | ffree st |
||
414 | mov dword[points_color+ebx],0 |
||
415 | mov word[points_color+ebx+4],0 |
||
416 | add ebx,6 |
||
417 | cmp ebx,ecx |
||
418 | jne .cc_again |
||
419 | jmp .cc_done |
||
420 | .cc_ok1: |
||
421 | fcom [dot_max] |
||
422 | fstsw ax |
||
423 | sahf |
||
424 | jb .cc_ok2 |
||
425 | ffree st |
||
426 | mov dword[points_color+ebx],0 ; clear r,g,b |
||
427 | mov word[points_color+ebx+4],0 |
||
428 | add ebx,6 |
||
429 | cmp ebx,ecx |
||
430 | jne .cc_again |
||
431 | jmp .cc_done |
||
432 | .cc_ok2: |
||
433 | fld st |
||
434 | fld st |
||
435 | fimul [max_color_r] |
||
436 | fistp word[points_color+ebx] ;each color as word |
||
437 | fimul [max_color_g] |
||
438 | fistp word[points_color+ebx+2] |
||
439 | fimul [max_color_b] |
||
440 | fistp word[points_color+ebx+4] |
||
441 | add ebx,6 |
||
442 | cmp ebx,ecx |
||
443 | jne .cc_again |
||
444 | .cc_done: |
||
445 | ret |
||
446 | copy_point_normals: |
||
447 | movzx ecx,[points_count_var] |
||
448 | shl ecx,2 |
||
449 | inc ecx |
||
450 | mov esi,point_normals |
||
451 | mov edi,point_normals_rotated |
||
452 | rep movsd |
||
453 | ret |
||
454 | rotate_point_normals: |
||
455 | movzx ecx,[points_count_var] |
||
456 | mov ebx,point_normals_rotated |
||
457 | fninit ; for now only rotate around Z axle |
||
458 | .again_r: |
||
459 | cmp [r_flag],1 |
||
460 | je .z_rot |
||
461 | cmp [r_flag],2 |
||
462 | je .x_rot |
||
463 | |||
464 | .y_rot: |
||
465 | fld dword[ebx] ; x |
||
466 | fld [sinbeta] |
||
467 | fmul dword[ebx+8] ; z * sinbeta |
||
468 | fchs |
||
469 | fld [cosbeta] |
||
470 | fmul dword[ebx] ; x * cosbeta |
||
471 | faddp |
||
472 | fstp dword[ebx] ; new x |
||
473 | fmul [sinbeta] ; old x * sinbeta |
||
474 | fld [cosbeta] |
||
475 | fmul dword[ebx+8] ; z * cosbeta |
||
476 | faddp |
||
477 | fstp dword[ebx+8] ; new z |
||
478 | add ebx,12 |
||
479 | loop .y_rot |
||
480 | jmp .end_rot |
||
481 | .z_rot: |
||
482 | fld dword[ebx] ;x |
||
483 | fld [sinbeta] |
||
484 | fmul dword[ebx+4] ;y |
||
485 | fld [cosbeta] |
||
486 | fmul dword[ebx] ;x |
||
487 | faddp |
||
488 | fstp dword[ebx] ;new x |
||
489 | fmul [sinbeta] ; sinbeta * old x |
||
490 | fchs |
||
491 | fld [cosbeta] |
||
492 | fmul dword[ebx+4] ; cosbeta * y |
||
493 | faddp |
||
494 | fstp dword[ebx+4] ; new y |
||
495 | add ebx,12 |
||
496 | loop .z_rot |
||
497 | jmp .end_rot |
||
498 | .x_rot: |
||
499 | fld dword[ebx+4] ;y |
||
500 | fld [sinbeta] |
||
501 | fmul dword[ebx+8] ;z |
||
502 | fld [cosbeta] |
||
503 | fmul dword[ebx+4] ;y |
||
504 | faddp |
||
505 | fstp dword[ebx+4] ; new y |
||
506 | fmul [sinbeta] ; sinbeta * old y |
||
507 | fchs |
||
508 | fld [cosbeta] |
||
509 | fmul dword[ebx+8] |
||
510 | faddp |
||
511 | fstp dword[ebx+8] |
||
512 | add ebx,12 |
||
513 | loop .x_rot |
||
514 | .end_rot: |
||
515 | ret |
||
516 | init_triangles_normals: |
||
517 | mov ebx,triangles_normals |
||
518 | mov ebp,triangles |
||
519 | @@: |
||
520 | push ebx |
||
521 | mov ebx,vectors |
||
522 | movzx esi,word[ebp] ; first point index |
||
523 | lea esi,[esi*3] |
||
524 | lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
||
525 | movzx edi,word[ebp+2] ; second point index |
||
526 | lea edi,[edi*3] |
||
527 | lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
||
528 | call make_vector |
||
529 | add ebx,12 |
||
530 | mov esi,edi |
||
531 | movzx edi,word[ebp+4] ; third point index |
||
532 | lea edi,[edi*3] |
||
533 | lea edi,[points+edi*2] |
||
534 | call make_vector |
||
535 | mov edi,ebx ; edi - pointer to 2nd vector |
||
536 | mov esi,ebx |
||
537 | sub esi,12 ; esi - pointer to 1st vector |
||
538 | pop ebx |
||
539 | call cross_product |
||
540 | mov edi,ebx |
||
541 | call normalize_vector |
||
542 | add ebp,6 |
||
543 | add ebx,12 |
||
544 | cmp dword[ebp],-1 |
||
545 | jne @b |
||
546 | ret |
||
547 | |||
548 | init_point_normals: |
||
549 | .x equ dword [ebp-4] |
||
550 | .y equ dword [ebp-8] |
||
551 | .z equ dword [ebp-12] |
||
552 | .point_number equ word [ebp-26] |
||
553 | .hit_faces equ word [ebp-28] |
||
554 | |||
555 | fninit |
||
556 | mov ebp,esp |
||
557 | sub esp,28 |
||
558 | mov edi,point_normals |
||
559 | mov .point_number,0 |
||
560 | .ipn_loop: |
||
561 | mov .hit_faces,0 |
||
562 | mov .x,0 |
||
563 | mov .y,0 |
||
564 | mov .z,0 |
||
565 | mov esi,triangles |
||
566 | xor ecx,ecx ; ecx - triangle number |
||
567 | .ipn_check_face: |
||
568 | xor ebx,ebx ; ebx - 'position' in one triangle |
||
569 | .ipn_check_vertex: |
||
570 | movzx eax,word[esi+ebx] ; eax - point_number |
||
571 | cmp ax,.point_number |
||
572 | jne .ipn_next_vertex |
||
573 | push esi |
||
574 | mov esi,ecx |
||
575 | lea esi,[esi*3] |
||
576 | lea esi,[triangles_normals+esi*4] |
||
577 | ; shl esi,2 |
||
578 | ; add esi,triangles_normals |
||
579 | |||
580 | fld .x |
||
581 | fadd dword[esi+vec_x] |
||
582 | fstp .x |
||
583 | fld .y |
||
584 | fadd dword[esi+vec_y] |
||
585 | fstp .y |
||
586 | fld .z |
||
587 | fadd dword[esi+vec_z] |
||
588 | fstp .z |
||
589 | pop esi |
||
590 | inc .hit_faces |
||
591 | jmp .ipn_next_face |
||
592 | .ipn_next_vertex: |
||
593 | add ebx,2 |
||
594 | cmp ebx,6 |
||
595 | jne .ipn_check_vertex |
||
596 | .ipn_next_face: |
||
597 | add esi,6 |
||
598 | inc ecx |
||
599 | cmp cx,[triangles_count_var] |
||
600 | jne .ipn_check_face |
||
601 | |||
602 | fld .x |
||
603 | fidiv .hit_faces |
||
604 | fstp dword[edi+vec_x] |
||
605 | fld .y |
||
606 | fidiv .hit_faces |
||
607 | fstp dword[edi+vec_y] |
||
608 | fld .z |
||
609 | fidiv .hit_faces |
||
610 | fstp dword[edi+vec_z] |
||
611 | call normalize_vector |
||
612 | add edi,12 ;type vector 3d |
||
613 | inc .point_number |
||
614 | mov dx,.point_number |
||
615 | cmp dx,[points_count_var] |
||
616 | jne .ipn_loop |
||
617 | |||
618 | mov esp,ebp |
||
619 | ret |
||
620 | |||
621 | add_vector: |
||
622 | mov ebp,points |
||
623 | @@: |
||
624 | add word[ebp],ax |
||
625 | add word[ebp+2],bx |
||
626 | add word[ebp+4],cx |
||
627 | add ebp,6 |
||
628 | cmp dword[ebp],-1 |
||
629 | jne @b |
||
630 | ret |
||
631 | ;do_scale: |
||
632 | ; fninit |
||
633 | ; mov ebp,points |
||
634 | ; .next_sc: |
||
635 | ; fld1 |
||
636 | ; fsub [scale] |
||
637 | ; fld st |
||
638 | ; fimul [xo] |
||
639 | ; fld [scale] |
||
640 | ; fimul word[ebp] ;x |
||
641 | ; faddp |
||
642 | ; fistp word[ebp] |
||
643 | ; fld st |
||
644 | ; fimul [yo] |
||
645 | ; fld [scale] |
||
646 | ; fimul word[ebp+2] |
||
647 | ; faddp |
||
648 | ; fistp word[ebp+2] |
||
649 | ; fimul [zo] |
||
650 | ; fld [scale] |
||
651 | ; fimul word[ebp+4] |
||
652 | ; faddp |
||
653 | ; fistp word[ebp+4] |
||
654 | ; add ebp,6 |
||
655 | ; cmp dword[ebp],-1 |
||
656 | ; jne .next_sc |
||
657 | ;ret |
||
658 | sort_triangles: |
||
659 | mov esi,triangles |
||
660 | mov edi,triangles_with_z |
||
661 | mov ebp,points_rotated |
||
662 | |||
663 | make_triangle_with_z: ;makes list with triangles and z position |
||
664 | movzx eax,word[esi] |
||
665 | lea eax,[eax*3] |
||
666 | movzx ecx,word[ebp+eax*2+4] |
||
667 | |||
668 | movzx eax,word[esi+2] |
||
669 | lea eax,[eax*3] |
||
670 | add cx,word[ebp+eax*2+4] |
||
671 | |||
672 | movzx eax,word[esi+4] |
||
673 | lea eax,[eax*3] |
||
674 | add cx,word[ebp+eax*2+4] |
||
675 | |||
676 | mov ax,cx |
||
677 | ; cwd |
||
678 | ; idiv word[i3] |
||
679 | movsd ; store vertex coordinates |
||
680 | movsw |
||
681 | stosw ; middle vertex coordinate 'z' in triangles_with_z list |
||
682 | cmp dword[esi],-1 |
||
683 | jne make_triangle_with_z |
||
684 | movsd ; copy end mark |
||
685 | mov eax,4 |
||
686 | lea edx,[edi-8-trizdd] |
||
687 | mov [high],edx |
||
688 | call quicksort |
||
689 | mov eax,4 |
||
690 | mov edx,[high] |
||
691 | call insertsort |
||
692 | jmp end_sort |
||
693 | |||
694 | quicksort: |
||
695 | mov ecx,edx |
||
696 | sub ecx,eax |
||
697 | cmp ecx,32 |
||
698 | jc .exit |
||
699 | lea ecx,[eax+edx] |
||
700 | shr ecx,4 |
||
701 | lea ecx,[ecx*8-4]; i |
||
702 | mov ebx,[trizdd+eax]; trizdd[l] |
||
703 | mov esi,[trizdd+ecx]; trizdd[i] |
||
704 | mov edi,[trizdd+edx]; trizdd[h] |
||
705 | cmp ebx,esi |
||
706 | jg @f ; direction NB! you need to negate these to invert the order |
||
707 | if Ext=NON |
||
708 | mov [trizdd+eax],esi |
||
709 | mov [trizdd+ecx],ebx |
||
710 | mov ebx,[trizdd+eax-4] |
||
711 | mov esi,[trizdd+ecx-4] |
||
712 | mov [trizdd+eax-4],esi |
||
713 | mov [trizdd+ecx-4],ebx |
||
714 | mov ebx,[trizdd+eax] |
||
715 | mov esi,[trizdd+ecx] |
||
716 | else |
||
717 | movq mm0,[trizdq+eax-4] |
||
718 | movq mm1,[trizdq+ecx-4] |
||
719 | movq [trizdq+ecx-4],mm0 |
||
720 | movq [trizdq+eax-4],mm1 |
||
721 | xchg ebx,esi |
||
722 | end if |
||
723 | @@: |
||
724 | cmp ebx,edi |
||
725 | jg @f ; direction |
||
726 | if Ext=NON |
||
727 | mov [trizdd+eax],edi |
||
728 | mov [trizdd+edx],ebx |
||
729 | mov ebx,[trizdd+eax-4] |
||
730 | mov edi,[trizdd+edx-4] |
||
731 | mov [trizdd+eax-4],edi |
||
732 | mov [trizdd+edx-4],ebx |
||
733 | mov ebx,[trizdd+eax] |
||
734 | mov edi,[trizdd+edx] |
||
735 | else |
||
736 | movq mm0,[trizdq+eax-4] |
||
737 | movq mm1,[trizdq+edx-4] |
||
738 | movq [trizdq+edx-4],mm0 |
||
739 | movq [trizdq+eax-4],mm1 |
||
740 | xchg ebx,edi |
||
741 | end if |
||
742 | @@: |
||
743 | cmp esi,edi |
||
744 | jg @f ; direction |
||
745 | if Ext=NON |
||
746 | mov [trizdd+ecx],edi |
||
747 | mov [trizdd+edx],esi |
||
748 | mov esi,[trizdd+ecx-4] |
||
749 | mov edi,[trizdd+edx-4] |
||
750 | mov [trizdd+ecx-4],edi |
||
751 | mov [trizdd+edx-4],esi |
||
752 | else |
||
753 | movq mm0,[trizdq+ecx-4] |
||
754 | movq mm1,[trizdq+edx-4] |
||
755 | movq [trizdq+edx-4],mm0 |
||
756 | movq [trizdq+ecx-4],mm1 |
||
757 | ; xchg ebx,esi |
||
758 | end if |
||
759 | @@: |
||
760 | mov ebp,eax ; direction |
||
761 | add ebp,8 ; j |
||
762 | if Ext=NON |
||
763 | mov esi,[trizdd+ebp] |
||
764 | mov edi,[trizdd+ecx] |
||
765 | mov [trizdd+ebp],edi |
||
766 | mov [trizdd+ecx],esi |
||
767 | mov esi,[trizdd+ebp-4] |
||
768 | mov edi,[trizdd+ecx-4] |
||
769 | mov [trizdd+ecx-4],esi |
||
770 | mov [trizdd+ebp-4],edi |
||
771 | else |
||
772 | movq mm0,[trizdq+ebp-4] |
||
773 | movq mm1,[trizdq+ecx-4] |
||
774 | movq [trizdq+ecx-4],mm0 |
||
775 | movq [trizdq+ebp-4],mm1 |
||
776 | end if |
||
777 | mov ecx,edx ; i; direction |
||
778 | mov ebx,[trizdd+ebp]; trizdd[j] |
||
779 | .loop: |
||
780 | sub ecx,8 ; direction |
||
781 | cmp [trizdd+ecx],ebx |
||
782 | jl .loop ; direction |
||
783 | @@: |
||
784 | add ebp,8 ; direction |
||
785 | cmp [trizdd+ebp],ebx |
||
786 | jg @b ; direction |
||
787 | cmp ebp,ecx |
||
788 | jge @f ; direction |
||
789 | if Ext=NON |
||
790 | mov esi,[trizdd+ecx] |
||
791 | mov edi,[trizdd+ebp] |
||
792 | mov [trizdd+ebp],esi |
||
793 | mov [trizdd+ecx],edi |
||
794 | mov edi,[trizdd+ecx-4] |
||
795 | mov esi,[trizdd+ebp-4] |
||
796 | mov [trizdd+ebp-4],edi |
||
797 | mov [trizdd+ecx-4],esi |
||
798 | else |
||
799 | movq mm0,[trizdq+ecx-4] |
||
800 | movq mm1,[trizdq+ebp-4] |
||
801 | movq [trizdq+ebp-4],mm0 |
||
802 | movq [trizdq+ecx-4],mm1 |
||
803 | end if |
||
804 | jmp .loop |
||
805 | @@: |
||
806 | if Ext=NON |
||
807 | mov esi,[trizdd+ecx] |
||
808 | mov edi,[trizdd+eax+8] |
||
809 | mov [trizdd+eax+8],esi |
||
810 | mov [trizdd+ecx],edi |
||
811 | mov edi,[trizdd+ecx-4] |
||
812 | mov esi,[trizdd+eax+4] |
||
813 | mov [trizdd+eax+4],edi |
||
814 | mov [trizdd+ecx-4],esi |
||
815 | else |
||
816 | movq mm0,[trizdq+ecx-4] |
||
817 | movq mm1,[trizdq+eax+4]; dir |
||
818 | movq [trizdq+eax+4],mm0; dir |
||
819 | movq [trizdq+ecx-4],mm1 |
||
820 | end if |
||
821 | add ecx,8 |
||
822 | push ecx edx |
||
823 | mov edx,ebp |
||
824 | call quicksort |
||
825 | pop edx eax |
||
826 | call quicksort |
||
827 | .exit: |
||
828 | ret |
||
829 | insertsort: |
||
830 | mov esi,eax |
||
831 | .start: |
||
832 | add esi,8 |
||
833 | cmp esi,edx |
||
834 | ja .exit |
||
835 | mov ebx,[trizdd+esi] |
||
836 | if Ext=NON |
||
837 | mov ecx,[trizdd+esi-4] |
||
838 | else |
||
839 | movq mm1,[trizdq+esi-4] |
||
840 | end if |
||
841 | mov edi,esi |
||
842 | @@: |
||
843 | cmp edi,eax |
||
844 | jna @f |
||
845 | cmp [trizdd+edi-8],ebx |
||
846 | jg @f ; direction |
||
847 | if Ext=NON |
||
848 | mov ebp,[trizdd+edi-8] |
||
849 | mov [trizdd+edi],ebp |
||
850 | mov ebp,[trizdd+edi-12] |
||
851 | mov [trizdd+edi-4],ebp |
||
852 | else |
||
853 | movq mm0,[trizdq+edi-12] |
||
854 | movq [trizdq+edi-4],mm0 |
||
855 | end if |
||
856 | sub edi,8 |
||
857 | jmp @b |
||
858 | @@: |
||
859 | if Ext=NON |
||
860 | mov [trizdd+edi],ebx |
||
861 | mov [trizdd+edi-4],ecx |
||
862 | else |
||
863 | movq [trizdq+edi-4],mm1 |
||
864 | end if |
||
865 | jmp .start |
||
866 | .exit: |
||
867 | ret |
||
868 | end_sort: |
||
869 | ; translate triangles_with_z to sorted_triangles |
||
870 | mov esi,triangles_with_z |
||
871 | ; mov edi,sorted_triangles |
||
872 | mov edi,triangles |
||
873 | again_copy: |
||
874 | if Ext=NON |
||
875 | movsd |
||
876 | movsw |
||
877 | add esi,2 |
||
878 | else |
||
879 | movq mm0,[esi] |
||
880 | movq [edi],mm0 |
||
881 | add esi,8 |
||
882 | add edi,6 |
||
883 | end if |
||
884 | cmp dword[esi],-1 |
||
885 | jne again_copy |
||
886 | ; if Ext=MMX |
||
887 | ; emms |
||
888 | ; end if |
||
889 | movsd ; copy end mark too |
||
890 | ret |
||
891 | |||
892 | clrscr: |
||
893 | mov edi,screen |
||
894 | mov ecx,SIZE_X*SIZE_Y*3/4 |
||
895 | xor eax,eax |
||
896 | if Ext=NON |
||
897 | rep stosd |
||
898 | else |
||
899 | pxor mm0,mm0 |
||
900 | @@: |
||
901 | movq [edi+00],mm0 |
||
902 | movq [edi+08],mm0 |
||
903 | movq [edi+16],mm0 |
||
904 | movq [edi+24],mm0 |
||
905 | add edi,32 |
||
906 | sub ecx,8 |
||
907 | jnc @b |
||
908 | end if |
||
909 | ret |
||
910 | |||
911 | calculate_angle: |
||
912 | fninit |
||
913 | ; fldpi |
||
914 | ; fidiv [i180] |
||
915 | fld [piD180] |
||
916 | fimul [angle_counter] |
||
917 | fsincos |
||
918 | fstp [sinbeta] |
||
919 | fstp [cosbeta] |
||
920 | inc [angle_counter] |
||
921 | cmp [angle_counter],360 |
||
922 | jne end_calc_angle |
||
923 | mov [angle_counter],0 |
||
924 | end_calc_angle: |
||
925 | ret |
||
926 | |||
927 | rotate_points: |
||
928 | fninit |
||
929 | mov ebx,points_rotated |
||
930 | again_r: |
||
931 | cmp [r_flag],1 |
||
932 | je .z_rot |
||
933 | cmp [r_flag],2 |
||
934 | je .x_rot |
||
935 | .y_rot: |
||
936 | mov eax,[ebx+2] ;z |
||
937 | mov ax,word[ebx] ;x |
||
938 | sub eax,dword[xo] |
||
939 | mov dword[xsub],eax |
||
940 | fld [sinbeta] |
||
941 | fimul [zsub] |
||
942 | fchs |
||
943 | fld [cosbeta] |
||
944 | fimul [xsub] |
||
945 | faddp |
||
946 | fiadd [xo] |
||
947 | fistp word[ebx] ;x |
||
948 | fld [sinbeta] |
||
949 | fimul [xsub] |
||
950 | fld [cosbeta] |
||
951 | fimul [zsub] |
||
952 | faddp |
||
953 | fiadd [zo] |
||
954 | fistp word[ebx+4] ;z |
||
955 | jmp .end_rot |
||
956 | .z_rot: |
||
957 | mov ax,word[ebx] |
||
958 | sub ax,word[xo] ;need optimization |
||
959 | mov [xsub],ax |
||
960 | mov ax,word[ebx+2] |
||
961 | sub ax,word[yo] |
||
962 | mov [ysub],ax |
||
963 | fld [sinbeta] |
||
964 | fimul [ysub] |
||
965 | fld [cosbeta] |
||
966 | fimul [xsub] |
||
967 | faddp |
||
968 | fiadd [xo] |
||
969 | fistp word[ebx] |
||
970 | fld [cosbeta] |
||
971 | fimul [ysub] |
||
972 | fld [sinbeta] |
||
973 | fimul [xsub] |
||
974 | fchs |
||
975 | faddp |
||
976 | fiadd [yo] |
||
977 | fistp word[ebx+2] |
||
978 | jmp .end_rot |
||
979 | .x_rot: |
||
980 | mov ax,word[ebx+2] |
||
981 | sub ax,[yo] |
||
982 | mov [ysub],ax |
||
983 | mov ax,word[ebx+4] |
||
984 | sub ax,word[zo] |
||
985 | mov [zsub],ax |
||
986 | fld [sinbeta] |
||
987 | fimul [zsub] |
||
988 | fld [cosbeta] |
||
989 | fimul [ysub] |
||
990 | faddp |
||
991 | fiadd [yo] |
||
992 | fistp word[ebx+2];y |
||
993 | fld [cosbeta] |
||
994 | fimul [zsub] |
||
995 | fld [sinbeta] |
||
996 | fimul [ysub] |
||
997 | fchs |
||
998 | faddp |
||
999 | fiadd [zo] |
||
1000 | fistp word[ebx+4] |
||
1001 | .end_rot: |
||
1002 | add ebx,6 |
||
1003 | cmp dword[ebx],-1 |
||
1004 | jne again_r |
||
1005 | ret |
||
1006 | |||
1007 | draw_triangles: |
||
1008 | mov esi,triangles |
||
1009 | .again_dts: |
||
1010 | mov ebp,points_rotated |
||
1011 | if Ext=NON |
||
1012 | movzx eax,word[esi] |
||
1013 | mov [point_index1],ax |
||
1014 | lea eax,[eax*3] |
||
1015 | add eax,eax |
||
1016 | push ebp |
||
1017 | add ebp,eax |
||
1018 | mov eax,[ebp] |
||
1019 | mov dword[xx1],eax |
||
1020 | mov eax,[ebp+4] |
||
1021 | mov [zz1],ax |
||
1022 | pop ebp |
||
1023 | |||
1024 | |||
1025 | movzx eax,word[esi+2] |
||
1026 | mov [point_index2],ax |
||
1027 | lea eax,[eax*3] |
||
1028 | add eax,eax |
||
1029 | push ebp |
||
1030 | add ebp,eax |
||
1031 | mov eax,[ebp] |
||
1032 | mov dword[xx2],eax |
||
1033 | mov eax,[ebp+4] |
||
1034 | mov [zz2],ax |
||
1035 | pop ebp |
||
1036 | |||
1037 | |||
1038 | movzx eax,word[esi+4] ; xyz3 = [ebp+[esi+4]*6] |
||
1039 | mov [point_index3],ax |
||
1040 | lea eax,[eax*3] |
||
1041 | add eax,eax |
||
1042 | ; push ebp |
||
1043 | add ebp,eax |
||
1044 | mov eax,[ebp] |
||
1045 | mov dword[xx3],eax |
||
1046 | mov eax,[ebp+4] |
||
1047 | mov [zz3],ax |
||
1048 | else |
||
1049 | mov eax,dword[esi] ; don't know MMX |
||
1050 | mov dword[point_index1],eax |
||
1051 | ; shr eax,16 |
||
1052 | ; mov [point_index2],ax |
||
1053 | mov ax,word[esi+4] |
||
1054 | mov [point_index3],ax |
||
1055 | movq mm0,[esi] |
||
1056 | pmullw mm0,qword[const6] |
||
1057 | movd eax,mm0 |
||
1058 | psrlq mm0,16 |
||
1059 | movd ebx,mm0 |
||
1060 | psrlq mm0,16 |
||
1061 | movd ecx,mm0 |
||
1062 | and eax,0FFFFh |
||
1063 | and ebx,0FFFFh |
||
1064 | and ecx,0FFFFh |
||
1065 | movq mm0,[ebp+eax] |
||
1066 | movq mm1,[ebp+ebx] |
||
1067 | movq mm2,[ebp+ecx] |
||
1068 | movq qword[xx1],mm0 |
||
1069 | movq qword[xx2],mm1 |
||
1070 | movq qword[xx3],mm2 |
||
1071 | ; emms |
||
1072 | end if |
||
1073 | push esi |
||
1074 | ; culling |
||
1075 | fninit |
||
1076 | mov esi,point_index1 |
||
1077 | mov ecx,3 |
||
1078 | @@: |
||
1079 | movzx eax,word[esi] |
||
1080 | lea eax,[eax*3] |
||
1081 | shl eax,2 |
||
1082 | lea eax,[eax+point_normals_rotated] |
||
1083 | fld dword[eax+8] |
||
1084 | ftst |
||
1085 | fstsw ax |
||
1086 | sahf |
||
1087 | jb @f |
||
1088 | ffree st |
||
1089 | loop @b |
||
1090 | jmp .end_draw |
||
1091 | @@: |
||
1092 | ffree st ;is visable |
||
1093 | |||
1094 | cmp [dr_flag],0 ; draw type flag |
||
1095 | je .flat_draw |
||
1096 | cmp [dr_flag],2 |
||
1097 | je .env_mapping |
||
1098 | |||
1099 | movzx edi,[point_index3] |
||
1100 | lea edi,[edi*3] |
||
1101 | lea edi,[points_color+edi*2] |
||
1102 | cmp [catmull_flag],0 |
||
1103 | je @f |
||
1104 | push [zz3] |
||
1105 | @@: |
||
1106 | push word[edi] |
||
1107 | push word[edi+2] |
||
1108 | push word[edi+4] |
||
1109 | movzx edi,[point_index2] |
||
1110 | lea edi,[edi*3] |
||
1111 | lea edi,[points_color+edi*2] |
||
1112 | cmp [catmull_flag],0 |
||
1113 | je @f |
||
1114 | push [zz2] |
||
1115 | @@: |
||
1116 | push word[edi] |
||
1117 | push word[edi+2] |
||
1118 | push word[edi+4] |
||
1119 | movzx edi,[point_index1] |
||
1120 | lea edi,[edi*3] |
||
1121 | lea edi,[points_color+edi*2] |
||
1122 | cmp [catmull_flag],0 |
||
1123 | je @f |
||
1124 | push [zz1] |
||
1125 | @@: |
||
1126 | push word[edi] |
||
1127 | push word[edi+2] |
||
1128 | push word[edi+4] |
||
1129 | |||
1130 | ; movzx edi,[point_index3] ;gouraud shading according to light vector |
||
1131 | ; lea edi,[edi*3] |
||
1132 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1133 | ; mov esi,light_vector |
||
1134 | ; call dot_product |
||
1135 | ; fabs |
||
1136 | ; fimul [max_color_r] |
||
1137 | ; fistp [temp_col] |
||
1138 | ; and [temp_col],0x00ff |
||
1139 | ; push [temp_col] |
||
1140 | ; push [temp_col] |
||
1141 | ; push [temp_col] |
||
1142 | |||
1143 | ; movzx edi,[point_index2] |
||
1144 | ; lea edi,[edi*3] |
||
1145 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1146 | ; mov esi,light_vector |
||
1147 | ; call dot_product |
||
1148 | ; fabs |
||
1149 | ; fimul [max_color_r] |
||
1150 | ; fistp [temp_col] |
||
1151 | ; and [temp_col],0x00ff |
||
1152 | ; push [temp_col] |
||
1153 | ; push [temp_col] |
||
1154 | ; push [temp_col] |
||
1155 | |||
1156 | ; movzx edi,[point_index1] |
||
1157 | ; lea edi,[edi*3] |
||
1158 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1159 | ; mov esi,light_vector |
||
1160 | ; call dot_product |
||
1161 | ; fabs |
||
1162 | ; fimul [max_color_r] |
||
1163 | ; fistp [temp_col] |
||
1164 | ; and [temp_col],0x00ff |
||
1165 | ; push [temp_col] |
||
1166 | ; push [temp_col] |
||
1167 | ; push [temp_col] |
||
1168 | |||
1169 | ; xor edx,edx ; draw acording to position |
||
1170 | ; mov ax,[zz3] |
||
1171 | ; add ax,128 |
||
1172 | ; neg al |
||
1173 | ; and ax,0x00ff |
||
1174 | ; push ax |
||
1175 | ; neg al |
||
1176 | ; push ax |
||
1177 | ; mov dx,[yy3] |
||
1178 | ; and dx,0x00ff |
||
1179 | ; push dx |
||
1180 | ; mov ax,[zz2] |
||
1181 | ; add ax,128 |
||
1182 | ; neg al |
||
1183 | ; and ax,0x00ff |
||
1184 | ; push ax |
||
1185 | ; neg al |
||
1186 | ; push ax |
||
1187 | ; mov dx,[yy2] |
||
1188 | ; and dx,0x00ff |
||
1189 | ; push dx |
||
1190 | ; mov ax,[zz1] |
||
1191 | ; add ax,128 |
||
1192 | ; neg al |
||
1193 | ; and ax,0x00ff |
||
1194 | ; push ax |
||
1195 | ; neg al |
||
1196 | ; push ax |
||
1197 | ; mov dx,[yy1] |
||
1198 | ; and dx,0x00ff |
||
1199 | ; push dx |
||
1200 | mov eax,dword[xx1] |
||
1201 | ror eax,16 |
||
1202 | mov ebx,dword[xx2] |
||
1203 | ror ebx,16 |
||
1204 | mov ecx,dword[xx3] |
||
1205 | ror ecx,16 |
||
1206 | lea edi,[screen] |
||
1207 | cmp [catmull_flag],0 |
||
1208 | je @f |
||
1209 | lea esi,[Z_buffer] |
||
1210 | call gouraud_triangle_z |
||
1211 | jmp .end_draw |
||
1212 | @@: |
||
1213 | call gouraud_triangle |
||
1214 | jmp .end_draw |
||
1215 | .flat_draw: |
||
1216 | |||
1217 | movzx edi,[point_index3] |
||
1218 | lea edi,[edi*3] |
||
1219 | lea edi,[points_color+edi*2] |
||
1220 | movzx eax,word[edi] |
||
1221 | movzx ebx,word[edi+2] |
||
1222 | movzx ecx,word[edi+4] |
||
1223 | movzx edi,[point_index2] |
||
1224 | lea edi,[edi*3] |
||
1225 | lea edi,[points_color+edi*2] |
||
1226 | add ax,word[edi] |
||
1227 | add bx,word[edi+2] |
||
1228 | add cx,word[edi+4] |
||
1229 | movzx edi,[point_index1] |
||
1230 | lea edi,[edi*3] |
||
1231 | lea edi,[points_color+edi*2] |
||
1232 | add ax,word[edi] |
||
1233 | add bx,word[edi+2] |
||
1234 | add cx,word[edi+4] |
||
1235 | cwd |
||
1236 | idiv [i3] |
||
1237 | mov di,ax |
||
1238 | shl edi,16 |
||
1239 | mov ax,bx |
||
1240 | cwd |
||
1241 | idiv [i3] |
||
1242 | mov di,ax |
||
1243 | shl di,8 |
||
1244 | mov ax,cx |
||
1245 | cwd |
||
1246 | idiv [i3] |
||
1247 | mov edx,edi |
||
1248 | mov dl,al |
||
1249 | and edx,0x00ffffff |
||
1250 | |||
1251 | |||
1252 | ; mov ax,[zz1] ; z position depend draw |
||
1253 | ; add ax,[zz2] |
||
1254 | ; add ax,[zz3] |
||
1255 | ; cwd |
||
1256 | ; idiv [i3] ; = -((a+b+c)/3+130) |
||
1257 | ; add ax,130 |
||
1258 | ; neg al |
||
1259 | ; xor edx,edx |
||
1260 | ; mov ah,al ;set color according to z position |
||
1261 | ; shl eax,8 |
||
1262 | ; mov edx,eax |
||
1263 | |||
1264 | mov eax,dword[xx1] |
||
1265 | ror eax,16 |
||
1266 | mov ebx,dword[xx2] |
||
1267 | ror ebx,16 |
||
1268 | mov ecx,dword[xx3] |
||
1269 | ror ecx,16 |
||
1270 | ; mov edi,screen |
||
1271 | lea edi,[screen] |
||
1272 | cmp [catmull_flag],0 |
||
1273 | je @f |
||
1274 | lea esi,[Z_buffer] |
||
1275 | push word[zz3] |
||
1276 | push word[zz2] |
||
1277 | push word[zz1] |
||
1278 | call flat_triangle_z |
||
1279 | jmp .end_draw |
||
1280 | @@: |
||
1281 | call draw_triangle |
||
1282 | jmp .end_draw |
||
1283 | .env_mapping: |
||
1284 | ; fninit |
||
1285 | mov esi,point_index1 |
||
1286 | sub esp,12 |
||
1287 | mov edi,esp |
||
1288 | mov ecx,3 |
||
1289 | @@: |
||
1290 | movzx eax,word[esi] |
||
1291 | lea eax,[eax*3] |
||
1292 | shl eax,2 |
||
1293 | add eax,point_normals_rotated |
||
1294 | ; texture x=(rotated point normal -> x * 255)+255 |
||
1295 | fld dword[eax] |
||
1296 | fimul [correct_tex] |
||
1297 | fiadd [correct_tex] |
||
1298 | fistp word[edi] |
||
1299 | ; texture y=(rotated point normal -> y * 255)+255 |
||
1300 | fld dword[eax+4] |
||
1301 | fimul [correct_tex] |
||
1302 | fiadd [correct_tex] |
||
1303 | fistp word[edi+2] |
||
1304 | |||
1305 | add edi,4 |
||
1306 | add esi,2 |
||
1307 | loop @b |
||
1308 | |||
1309 | mov eax,dword[xx1] |
||
1310 | ror eax,16 |
||
1311 | mov ebx,dword[xx2] |
||
1312 | ror ebx,16 |
||
1313 | mov ecx,dword[xx3] |
||
1314 | ror ecx,16 |
||
1315 | mov edi,screen |
||
1316 | mov esi,envmap |
||
1317 | call tex_triangle |
||
1318 | |||
1319 | .end_draw: |
||
1320 | pop esi |
||
1321 | add esi,6 |
||
1322 | cmp dword[esi],-1 |
||
1323 | jne .again_dts |
||
1324 | ret |
||
1782 | yogev_ezra | 1325 | ;translate_points: |
1781 | yogev_ezra | 1326 | ; fninit |
1327 | ; mov ebx,points_rotated |
||
1328 | ; again_trans: |
||
1329 | ; fild word[ebx+4] ;z1 |
||
1330 | ; fmul [sq] |
||
1331 | ; fld st |
||
1332 | ; fiadd word[ebx] ;x1 |
||
1333 | ; fistp word[ebx] |
||
1334 | ; fchs |
||
1335 | ; fiadd word[ebx+2] ;y1 |
||
1336 | ; fistp word[ebx+2] ;y1 |
||
1337 | |||
1338 | ; add ebx,6 |
||
1339 | ; cmp dword[ebx],-1 |
||
1340 | ; jne again_trans |
||
1341 | ;ret |
||
1342 | translate_perspective_points: ;translate points from 3d to 2d using |
||
1343 | fninit ;perspective equations |
||
1344 | mov ebx,points_rotated |
||
1345 | .again_trans: |
||
1346 | fild word[ebx] |
||
1347 | fisub [xobs] |
||
1348 | fimul [zobs] |
||
1349 | fild word[ebx+4] |
||
1350 | fisub [zobs] |
||
1351 | fdivp |
||
1352 | fiadd [xobs] |
||
1353 | fistp word[ebx] |
||
1354 | fild word[ebx+2] |
||
1355 | fisub [yobs] |
||
1356 | fimul [zobs] |
||
1357 | fild word[ebx+4] |
||
1358 | fisub [zobs] |
||
1359 | fdivp |
||
1360 | fchs |
||
1361 | fiadd [yobs] |
||
1362 | fistp word[ebx+2] |
||
1363 | add ebx,6 |
||
1364 | cmp dword[ebx],-1 |
||
1365 | jne .again_trans |
||
1366 | ret |
||
1367 | |||
1368 | |||
1369 | copy_points: |
||
1370 | mov esi,points |
||
1371 | mov edi,points_rotated |
||
1372 | mov ecx,points_count*3+2 |
||
1373 | rep movsw |
||
1374 | ret |
||
1375 | |||
1376 | |||
1377 | |||
1378 | read_from_file: |
||
1379 | mov edi,triangles |
||
1380 | xor ebx,ebx |
||
1381 | xor ebp,ebp |
||
1382 | mov esi,SourceFile |
||
1383 | cmp [esi],word 4D4Dh |
||
1384 | jne .exit ;Must be legal .3DS file |
||
1385 | cmp dword[esi+2],EndFile-SourceFile |
||
1386 | jne .exit ;This must tell the length |
||
1387 | add esi,6 |
||
1388 | @@: |
||
1389 | cmp [esi],word 3D3Dh |
||
1390 | je @f |
||
1391 | add esi,[esi+2] |
||
1392 | jmp @b |
||
1393 | @@: |
||
1394 | add esi,6 |
||
1395 | .find4k: |
||
1396 | cmp [esi],word 4000h |
||
1397 | je @f |
||
1398 | add esi,[esi+2] |
||
1399 | cmp esi,EndFile |
||
1400 | jc .find4k |
||
1401 | jmp .exit |
||
1402 | @@: |
||
1403 | add esi,6 |
||
1404 | @@: |
||
1405 | cmp [esi],byte 0 |
||
1406 | je @f |
||
1407 | inc esi |
||
1408 | jmp @b |
||
1409 | @@: |
||
1410 | inc esi |
||
1411 | @@: |
||
1412 | cmp [esi],word 4100h |
||
1413 | je @f |
||
1414 | add esi,[esi+2] |
||
1415 | jmp @b |
||
1416 | @@: |
||
1417 | add esi,6 |
||
1418 | @@: |
||
1419 | cmp [esi],word 4110h |
||
1420 | je @f |
||
1421 | add esi,[esi+2] |
||
1422 | jmp @b |
||
1423 | @@: |
||
1424 | movzx ecx,word[esi+6] |
||
1425 | mov [points_count_var],cx |
||
1426 | mov edx,ecx |
||
1427 | add esi,8 |
||
1428 | @@: |
||
1429 | fld dword[esi+4] |
||
1430 | fmul [sscale] |
||
1431 | fadd [xoffset] |
||
1432 | fld dword[esi+8] |
||
1433 | fchs |
||
1434 | fmul [sscale] |
||
1435 | fadd [yoffset] |
||
1436 | fld dword[esi+0] |
||
1437 | fchs |
||
1438 | fmul [sscale] |
||
1439 | fistp word[points+ebx+4] |
||
1440 | fistp word[points+ebx+2] |
||
1441 | fistp word[points+ebx+0] |
||
1442 | add ebx,6 |
||
1443 | add esi,12 |
||
1444 | dec ecx |
||
1445 | jnz @b |
||
1446 | @@: |
||
1447 | mov dword[points+ebx],-1 |
||
1448 | @@: |
||
1449 | cmp [esi],word 4120h |
||
1450 | je @f |
||
1451 | add esi,[esi+2] |
||
1452 | jmp @b |
||
1453 | @@: |
||
1454 | movzx ecx,word[esi+6] |
||
1455 | mov [triangles_count_var],cx |
||
1456 | add esi,8 |
||
1457 | ;mov edi,triangles |
||
1458 | @@: |
||
1459 | movsd |
||
1460 | movsw |
||
1461 | add word[edi-6],bp |
||
1462 | add word[edi-4],bp |
||
1463 | add word[edi-2],bp |
||
1464 | add esi,2 |
||
1465 | dec ecx |
||
1466 | jnz @b |
||
1467 | add ebp,edx |
||
1468 | jmp .find4k |
||
1469 | |||
1470 | .exit: |
||
1471 | mov dword[edi],-1 |
||
1472 | ret |
||
1473 | |||
1474 | |||
1475 | ; ********************************************* |
||
1476 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
1477 | ; ********************************************* |
||
1478 | draw_window: |
||
1479 | mov eax,12 ; function 12:tell os about windowdraw |
||
1480 | mov ebx,1 ; 1, start of draw |
||
1481 | int 0x40 |
||
1482 | |||
1483 | ; DRAW WINDOW |
||
1484 | mov eax,0 ; function 0 : define and draw window |
||
1485 | mov ebx,100*65536+SIZE_X+80 ; [x start] *65536 + [x size] |
||
1486 | mov ecx,100*65536+SIZE_Y+30 ; [y start] *65536 + [y size] |
||
1487 | mov edx,0x02000000 ; color of work area RRGGBB,8->color gl |
||
1488 | mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
||
1489 | mov edi,0x005080d0 ; color of frames RRGGBB |
||
1490 | int 0x40 |
||
1491 | |||
1492 | ; WINDOW LABEL |
||
1493 | mov eax,4 ; function 4 : write text to window |
||
1494 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
1495 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1496 | mov edx,labelt ; pointer to text beginning |
||
1497 | mov esi,labellen-labelt ; text length |
||
1498 | int 0x40 |
||
1499 | |||
1500 | ; CLOSE BUTTON |
||
1501 | mov eax,8 ; function 8 : define and draw button |
||
1502 | mov ebx,(SIZE_X+80-19)*65536+12 ; [x start] *65536 + [x size] |
||
1503 | mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
||
1504 | mov edx,1 ; button id |
||
1505 | mov esi,0x6688dd ; button color RRGGBB |
||
1506 | int 0x40 |
||
1507 | |||
1508 | ; ROTARY BUTTON |
||
1509 | mov eax,8 ; function 8 : define and draw button |
||
1510 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
1511 | mov ecx,25*65536+12 ; [y start] *65536 + [y size] |
||
1512 | mov edx,2 ; button id |
||
1513 | mov esi,0x6688dd ; button color RRGGBB |
||
1514 | int 0x40 |
||
1515 | ; ROTARY LABEL |
||
1516 | mov eax,4 ; function 4 : write text to window |
||
1517 | mov ebx,(SIZE_X+12)*65536+28 ; [x start] *65536 + [y start] |
||
1518 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1519 | mov edx,labelrot ; pointer to text beginning |
||
1520 | mov esi,labelrotend-labelrot ; text length |
||
1521 | int 0x40 |
||
1522 | |||
1523 | ; DRAW MODE BUTTON |
||
1524 | mov eax,8 ; function 8 : define and draw button |
||
1525 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
1526 | mov ecx,(25+15)*65536+12 ; [y start] *65536 + [y size] |
||
1527 | mov edx,3 ; button id |
||
1528 | mov esi,0x6688dd ; button color RRGGBB |
||
1529 | int 0x40 |
||
1530 | ; DRAW MODE LABEL |
||
1531 | mov eax,4 ; function 4 : write text to window |
||
1532 | mov ebx,(SIZE_X+12)*65536+28+15 ; [x start] *65536 + [y start] |
||
1533 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1534 | mov edx,labeldrmod ; pointer to text beginning |
||
1535 | mov esi,labeldrmodend-labeldrmod ; text length |
||
1536 | int 0x40 |
||
1537 | |||
1538 | ; SPEED BUTTON |
||
1539 | mov eax,8 ; function 8 : define and draw button |
||
1540 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
1541 | mov ecx,(25+15*2)*65536+12 ; [y start] *65536 + [y size] |
||
1542 | mov edx,4 ; button id |
||
1543 | mov esi,0x6688dd ; button color RRGGBB |
||
1544 | int 0x40 |
||
1545 | ; SPEED MODE LABEL |
||
1546 | mov eax,4 ; function 4 : write text to window |
||
1547 | mov ebx,(SIZE_X+12)*65536+(28+15*2) ; [x start] *65536 + [y start] |
||
1548 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1549 | mov edx,labelspeedmod ; pointer to text beginning |
||
1550 | mov esi,labelspeedmodend-labelspeedmod ; text length |
||
1551 | int 0x40 |
||
1552 | |||
1553 | ; SCALE- BUTTON |
||
1554 | mov eax,8 ; function 8 : define and draw button |
||
1555 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
1556 | mov ecx,(25+15*3)*65536+12 ; [y start] *65536 + [y size] |
||
1557 | mov edx,5 ; button id |
||
1558 | mov esi,0x6688dd ; button color RRGGBB |
||
1559 | int 0x40 |
||
1560 | ; SCALE- MODE LABEL |
||
1561 | mov eax,4 ; function 4 : write text to window |
||
1562 | mov ebx,(SIZE_X+12)*65536+(28+15*3) ; [x start] *65536 + [y start] |
||
1563 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1564 | mov edx,labelzoomout ; pointer to text beginning |
||
1565 | mov esi,labelzoomoutend-labelzoomout ; text length |
||
1566 | int 0x40 |
||
1567 | |||
1568 | ; SCALE+ BUTTON |
||
1569 | mov eax,8 ; function 8 : define and draw button |
||
1570 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
1571 | mov ecx,(25+15*4)*65536+12 ; [y start] *65536 + [y size] |
||
1572 | mov edx,6 ; button id |
||
1573 | mov esi,0x6688dd ; button color RRGGBB |
||
1574 | int 0x40 |
||
1575 | ; SCALE+ MODE LABEL |
||
1576 | mov eax,4 ; function 4 : write text to window |
||
1577 | mov ebx,(SIZE_X+12)*65536+(28+15*4) ; [x start] *65536 + [y start] |
||
1578 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1579 | mov edx,labelzoomin ; pointer to text beginning |
||
1580 | mov esi,labelzoominend-labelzoomin ; text length |
||
1581 | int 0x40 |
||
1582 | ; ADD VECTOR LABEL |
||
1583 | mov eax,4 ; function 4 : write text to window |
||
1584 | mov ebx,(SIZE_X+12)*65536+(28+15*5) ; [x start] *65536 + [y start] |
||
1585 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1586 | mov edx,labelvector ; pointer to text beginning |
||
1587 | mov esi,labelvectorend-labelvector ; text length |
||
1588 | int 0x40 |
||
1589 | ; VECTOR Y- BUTTON |
||
1590 | mov eax,8 ; function 8 : define and draw button |
||
1591 | mov ebx,(SIZE_X+10+20)*65536+62-42 ; [x start] *65536 + [x size] |
||
1592 | mov ecx,(25+15*6)*65536+12 ; [y start] *65536 + [y size] |
||
1593 | mov edx,7 ; button id |
||
1594 | mov esi,0x6688dd ; button color RRGGBB |
||
1595 | int 0x40 |
||
1596 | ;VECTOR Y- LABEL |
||
1597 | mov eax,4 ; function 4 : write text to window |
||
1598 | mov ebx,(SIZE_X+12+20)*65536+(28+15*6) ; [x start] *65536 + [y start] |
||
1599 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1600 | mov edx,labelyminus ; pointer to text beginning |
||
1601 | mov esi,labelyminusend-labelyminus ; text length |
||
1602 | int 0x40 |
||
1603 | ; VECTOR Z+ BUTTON |
||
1604 | mov eax,8 ; function 8 : define and draw button |
||
1605 | mov ebx,(SIZE_X+10+41)*65536+62-41 ; [x start] *65536 + [x size] |
||
1606 | mov ecx,(25+15*6)*65536+12 ; [y start] *65536 + [y size] |
||
1607 | mov edx,8 ; button id |
||
1608 | mov esi,0x6688dd ; button color RRGGBB |
||
1609 | int 0x40 |
||
1610 | ;VECTOR Z+ LABEL |
||
1611 | mov eax,4 ; function 4 : write text to window |
||
1612 | mov ebx,(SIZE_X+12+41)*65536+(28+15*6) ; [x start] *65536 + [y start] |
||
1613 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1614 | mov edx,labelzplus ; pointer to text beginning |
||
1615 | mov esi,labelzplusend-labelzplus ; text length |
||
1616 | int 0x40 |
||
1617 | ; VECTOR x- BUTTON |
||
1618 | mov eax,8 ; function 8 : define and draw button |
||
1619 | mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
||
1620 | mov ecx,(25+15*7)*65536+12 ; [y start] *65536 + [y size] |
||
1621 | mov edx,9 ; button id |
||
1622 | mov esi,0x6688dd ; button color RRGGBB |
||
1623 | int 0x40 |
||
1624 | ;VECTOR x- LABEL |
||
1625 | mov eax,4 ; function 4 : write text to window |
||
1626 | mov ebx,(SIZE_X+12)*65536+(28+15*7) ; [x start] *65536 + [y start] |
||
1627 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1628 | mov edx,labelxminus ; pointer to text beginning |
||
1629 | mov esi,labelxminusend-labelxminus ; text length |
||
1630 | int 0x40 |
||
1631 | ; VECTOR x+ BUTTON |
||
1632 | mov eax,8 ; function 8 : define and draw button |
||
1633 | mov ebx,(SIZE_X+10+41)*65536+62-41 ; [x start] *65536 + [x size] |
||
1634 | mov ecx,(25+15*7)*65536+12 ; [y start] *65536 + [y size] |
||
1635 | mov edx,10 ; button id |
||
1636 | mov esi,0x6688dd ; button color RRGGBB |
||
1637 | int 0x40 |
||
1638 | ;VECTOR x+ LABEL |
||
1639 | mov eax,4 ; function 4 : write text to window |
||
1640 | mov ebx,(SIZE_X+12+41)*65536+(28+15*7) ; [x start] *65536 + [y start] |
||
1641 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1642 | mov edx,labelxplus ; pointer to text beginning |
||
1643 | mov esi,labelxplusend-labelxplus ; text length |
||
1644 | int 0x40 |
||
1645 | ; VECTOR z- BUTTON |
||
1646 | mov eax,8 ; function 8 : define and draw button |
||
1647 | mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
||
1648 | mov ecx,(25+15*8)*65536+12 ; [y start] *65536 + [y size] |
||
1649 | mov edx,11 ; button id |
||
1650 | mov esi,0x6688dd ; button color RRGGBB |
||
1651 | int 0x40 |
||
1652 | ;VECTOR z- LABEL |
||
1653 | mov eax,4 ; function 4 : write text to window |
||
1654 | mov ebx,(SIZE_X+12)*65536+(28+15*8) ; [x start] *65536 + [y start] |
||
1655 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1656 | mov edx,labelzminus ; pointer to text beginning |
||
1657 | mov esi,labelzminusend-labelzminus ; text length |
||
1658 | int 0x40 |
||
1659 | ;VECTOR Y+ BUTTON |
||
1660 | mov eax,8 ; function 8 : define and draw button |
||
1661 | mov ebx,(SIZE_X+10+20)*65536+62-42 ; [x start] *65536 + [x size] |
||
1662 | mov ecx,(25+15*8)*65536+12 ; [y start] *65536 + [y size] |
||
1663 | mov edx,12 ; button id |
||
1664 | mov esi,0x6688dd ; button color RRGGBB |
||
1665 | int 0x40 |
||
1666 | ;VECTOR Y+ LABEL |
||
1667 | mov eax,4 ; function 4 : write text to window |
||
1668 | mov ebx,(SIZE_X+12+20)*65536+(28+15*8) ; [x start] *65536 + [y start] |
||
1669 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1670 | mov edx,labelyplus ; pointer to text beginning |
||
1671 | mov esi,labelyplusend-labelyplus ; text length |
||
1672 | int 0x40 |
||
1673 | ; LEAD COLOR LABEL |
||
1674 | mov eax,4 ; function 4 : write text to window |
||
1675 | mov ebx,(SIZE_X+12)*65536+(28+15*9) ; [x start] *65536 + [y start] |
||
1676 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1677 | mov edx,labelmaincolor ; pointer to text beginning |
||
1678 | mov esi,labelmaincolorend-labelmaincolor ; text length |
||
1679 | int 0x40 |
||
1680 | |||
1681 | ;RED+ BUTTON |
||
1682 | mov eax,8 ; function 8 : define and draw button |
||
1683 | mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
||
1684 | mov ecx,(25+15*10)*65536+12 ; [y start] *65536 + [y size] |
||
1685 | mov edx,13 ; button id |
||
1686 | mov esi,0x6688dd ; button color RRGGBB |
||
1687 | int 0x40 |
||
1688 | ;RED+ LABEL |
||
1689 | mov eax,4 ; function 4 : write text to window |
||
1690 | mov ebx,(SIZE_X+12)*65536+(28+15*10) ; [x start] *65536 + [y start] |
||
1691 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1692 | mov edx,labelredplus ; pointer to text beginning |
||
1693 | mov esi,labelredplusend-labelredplus ; text length |
||
1694 | int 0x40 |
||
1695 | ;GREEN+ BUTTON |
||
1696 | mov eax,8 ; function 8 : define and draw button |
||
1697 | mov ebx,(SIZE_X+10+20)*65536+62-42 ; [x start] *65536 + [x size] |
||
1698 | mov ecx,(25+15*10)*65536+12 ; [y start] *65536 + [y size] |
||
1699 | mov edx,14 ; button id |
||
1700 | mov esi,0x6688dd ; button color RRGGBB |
||
1701 | int 0x40 |
||
1702 | ;GREEN+ LABEL |
||
1703 | mov eax,4 ; function 4 : write text to window |
||
1704 | mov ebx,(SIZE_X+12+20)*65536+(28+15*10) ; [x start] *65536 + [y start] |
||
1705 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1706 | mov edx,labelgreenplus ; pointer to text beginning |
||
1707 | mov esi,labelgreenplusend-labelgreenplus ; text length |
||
1708 | int 0x40 |
||
1709 | ;BLUE+ BUTTON |
||
1710 | mov eax,8 ; function 8 : define and draw button |
||
1711 | mov ebx,(SIZE_X+10+41)*65536+62-41 ; [x start] *65536 + [x size] |
||
1712 | mov ecx,(25+15*10)*65536+12 ; [y start] *65536 + [y size] |
||
1713 | mov edx,15 ; button id |
||
1714 | mov esi,0x6688dd ; button color RRGGBB |
||
1715 | int 0x40 |
||
1716 | ;BLUE+ LABEL |
||
1717 | mov eax,4 ; function 4 : write text to window |
||
1718 | mov ebx,(SIZE_X+12+41)*65536+(28+15*10) ; [x start] *65536 + [y start] |
||
1719 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1720 | mov edx,labelblueplus ; pointer to text beginning |
||
1721 | mov esi,labelblueplusend-labelblueplus ; text length |
||
1722 | int 0x40 |
||
1723 | ;RED- BUTTON |
||
1724 | mov eax,8 ; function 8 : define and draw button |
||
1725 | mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
||
1726 | mov ecx,(25+15*11)*65536+12 ; [y start] *65536 + [y size] |
||
1727 | mov edx,16 ; button id |
||
1728 | mov esi,0x6688dd ; button color RRGGBB |
||
1729 | int 0x40 |
||
1730 | ;RED- LABEL |
||
1731 | mov eax,4 ; function 4 : write text to window |
||
1732 | mov ebx,(SIZE_X+12)*65536+(28+15*11) ; [x start] *65536 + [y start] |
||
1733 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1734 | mov edx,labelredminus ; pointer to text beginning |
||
1735 | mov esi,labelredminusend-labelredminus ; text length |
||
1736 | int 0x40 |
||
1737 | ;GREEN- BUTTON |
||
1738 | mov eax,8 ; function 8 : define and draw button |
||
1739 | mov ebx,(SIZE_X+10+20)*65536+62-42 ; [x start] *65536 + [x size] |
||
1740 | mov ecx,(25+15*11)*65536+12 ; [y start] *65536 + [y size] |
||
1741 | mov edx,17 ; button id |
||
1742 | mov esi,0x6688dd ; button color RRGGBB |
||
1743 | int 0x40 |
||
1744 | ;GREEN- LABEL |
||
1745 | mov eax,4 ; function 4 : write text to window |
||
1746 | mov ebx,(SIZE_X+12+20)*65536+(28+15*11) ; [x start] *65536 + [y start] |
||
1747 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1748 | mov edx,labelgreenminus ; pointer to text beginning |
||
1749 | mov esi,labelgreenminusend-labelgreenminus ; text length |
||
1750 | int 0x40 |
||
1751 | ;BLUE- BUTTON |
||
1752 | mov eax,8 ; function 8 : define and draw button |
||
1753 | mov ebx,(SIZE_X+10+41)*65536+62-41 ; [x start] *65536 + [x size] |
||
1754 | mov ecx,(25+15*11)*65536+12 ; [y start] *65536 + [y size] |
||
1755 | mov edx,18 ; button id |
||
1756 | mov esi,0x6688dd ; button color RRGGBB |
||
1757 | int 0x40 |
||
1758 | ;BLUE- LABEL |
||
1759 | mov eax,4 ; function 4 : write text to window |
||
1760 | mov ebx,(SIZE_X+12+41)*65536+(28+15*11) ; [x start] *65536 + [y start] |
||
1761 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1762 | mov edx,labelblueminus ; pointer to text beginning |
||
1763 | mov esi,labelblueminusend-labelblueminus ; text length |
||
1764 | int 0x40 |
||
1765 | ; Catmull LABEL |
||
1766 | mov eax,4 ; function 4 : write text to window |
||
1767 | mov ebx,(SIZE_X+12)*65536+(28+15*12) ; [x start] *65536 + [y start] |
||
1768 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1769 | mov edx,labelcatmullmod ; pointer to text beginning |
||
1770 | mov esi,labelcatmullmodend-labelcatmullmod ; text length |
||
1771 | int 0x40 |
||
1772 | ; on/off BUTTON |
||
1773 | mov eax,8 ; function 8 : define and draw button |
||
1774 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
1775 | mov ecx,(25+15*13)*65536+12 ; [y start] *65536 + [y size] |
||
1776 | mov edx,19 ; button id |
||
1777 | mov esi,0x6688dd ; button color RRGGBB |
||
1778 | int 0x40 |
||
1779 | ; on/off LABEL |
||
1780 | mov eax,4 ; function 4 : write text to window |
||
1781 | mov ebx,(SIZE_X+12)*65536+(28+15*13) ; [x start] *65536 + [y start] |
||
1782 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1783 | mov edx,labelonoff ; pointer to text beginning |
||
1784 | mov esi,labelonoffend-labelonoff ; text length |
||
1785 | int 0x40 |
||
1786 | |||
1787 | |||
1788 | mov eax,12 ; function 12:tell os about windowdraw |
||
1789 | mov ebx,2 ; 2, end of draw |
||
1790 | int 0x40 |
||
1791 | |||
1792 | ret |
||
1793 | |||
1794 | |||
1795 | ; DATA AREA |
||
1796 | i3 dw 3 |
||
1797 | light_vector dd 0.0,0.0,-1.0 |
||
1798 | ; debug_vector dd 0.0,2.0,2.0 ;--debug |
||
1799 | ; debug_vector1 dd 0.0,0.0,0.0 |
||
1800 | ; debug_points dw 1,1,1,3,4,20 |
||
1801 | ; debug_dd dw ? |
||
1802 | ; debug_dwd dd 65535 |
||
1803 | ; debug_counter dw 0 |
||
1804 | dot_max dd 1.0 |
||
1805 | dot_min dd 0.0 |
||
1806 | env_const dd 1.2 |
||
1807 | correct_tex dw 255 |
||
1808 | max_color_r dw 255 |
||
1809 | max_color_g dw 25 |
||
1810 | max_color_b dw 35 |
||
1811 | xobs dw SIZE_X / 2 ;200 ;observer |
||
1812 | yobs dw SIZE_Y / 2 ;200 ;coordinates |
||
1813 | zobs dw -500 |
||
1814 | |||
1815 | |||
1816 | angle_counter dw 0 |
||
1817 | piD180 dd 0.017453292519943295769236907684886 |
||
1818 | ; sq dd 0.70710678118654752440084436210485 |
||
1819 | const6 dw 6,6,6,6 |
||
1820 | xo dw 130;87 |
||
1821 | zo dw 0 |
||
1822 | yo dw 100 |
||
1823 | xoffset dd 130.0 |
||
1824 | yoffset dd 150.0 |
||
1825 | sscale dd 6.0 ; real scale |
||
1826 | vect_x dw 0 |
||
1827 | vect_y dw 0 |
||
1828 | vect_z dw 0 |
||
1829 | |||
1830 | |||
1831 | r_flag db 0 |
||
1832 | dr_flag db 2 |
||
1833 | speed_flag db 0 |
||
1834 | catmull_flag db 0 |
||
1835 | SourceFile file '../../3DS/HRT.3DS' |
||
1836 | EndFile: |
||
1837 | labelrot: |
||
1838 | db 'rot. mode' |
||
1839 | labelrotend: |
||
1840 | labeldrmod: |
||
1841 | db 'shd. mode' |
||
1842 | labeldrmodend: |
||
1843 | labelspeedmod: |
||
1844 | db 'spd. mode' |
||
1845 | labelspeedmodend: |
||
1846 | labelzoomout: |
||
1847 | db 'zoom out' |
||
1848 | labelzoomoutend: |
||
1849 | labelzoomin: |
||
1850 | db 'zoom in' |
||
1851 | labelzoominend: |
||
1852 | labelvector: |
||
1853 | db 'add vector' |
||
1854 | labelvectorend: |
||
1855 | labelyminus: |
||
1856 | db 'y -' |
||
1857 | labelyminusend: |
||
1858 | labelzplus: |
||
1859 | db 'z +' |
||
1860 | labelzplusend: |
||
1861 | labelxminus: |
||
1862 | db 'x -' |
||
1863 | labelxminusend: |
||
1864 | labelxplus: |
||
1865 | db 'x +' |
||
1866 | labelxplusend: |
||
1867 | labelzminus: |
||
1868 | db 'z -' |
||
1869 | labelzminusend: |
||
1870 | labelyplus: |
||
1871 | db 'y +' |
||
1872 | labelyplusend: |
||
1873 | labelmaincolor: |
||
1874 | db 'main color' |
||
1875 | labelmaincolorend: |
||
1876 | labelredplus: |
||
1877 | db 'r +' |
||
1878 | labelredplusend: |
||
1879 | labelgreenplus: |
||
1880 | db 'g +' |
||
1881 | labelgreenplusend: |
||
1882 | labelblueplus: |
||
1883 | db 'b +' |
||
1884 | labelblueplusend: |
||
1885 | labelredminus: |
||
1886 | db 'r -' |
||
1887 | labelredminusend: |
||
1888 | labelgreenminus: |
||
1889 | db 'g -' |
||
1890 | labelgreenminusend: |
||
1891 | labelblueminus: |
||
1892 | db 'b -' |
||
1893 | labelblueminusend: |
||
1894 | labelcatmullmod: |
||
1895 | db 'catmull' |
||
1896 | labelcatmullmodend: |
||
1897 | labelonoff: |
||
1898 | db 'on/off' |
||
1899 | labelonoffend: |
||
1900 | labelt: |
||
1901 | db 'DEUS CARITAS EST' |
||
1902 | if Ext=MMX |
||
1903 | db ' (MMX)' |
||
1904 | end if |
||
1905 | labellen: |
||
1906 | STRdata db '-1 ' |
||
1907 | align 8 |
||
1908 | @col dd ? |
||
1909 | @y1 dw ? |
||
1910 | @x1 dw ?;+8 |
||
1911 | @y2 dw ? |
||
1912 | @x2 dw ? |
||
1913 | @y3 dw ? |
||
1914 | @x3 dw ?;+16 |
||
1915 | |||
1916 | @dx12 dd ? |
||
1917 | @dx13 dd ?;+24 |
||
1918 | @dx23 dd ? |
||
1919 | |||
1920 | sinbeta dd ?;+32 |
||
1921 | cosbeta dd ? |
||
1922 | |||
1923 | xsub dw ? |
||
1924 | zsub dw ?;+40 |
||
1925 | ysub dw ? |
||
1926 | |||
1927 | xx1 dw ? |
||
1928 | yy1 dw ? |
||
1929 | zz1 dw ?;+48 |
||
1930 | xx2 dw ? |
||
1931 | yy2 dw ? |
||
1932 | zz2 dw ? |
||
1933 | xx3 dw ?;+56 |
||
1934 | yy3 dw ? |
||
1935 | zz3 dw ? |
||
1936 | scale dd ? ; help scale variable |
||
1937 | ;screen dd ? ;pointer to screen buffer |
||
1938 | triangles_count_var dw ? |
||
1939 | points_count_var dw ? |
||
1940 | |||
1941 | |||
1942 | point_index1 dw ? ;-\ |
||
1943 | point_index2 dw ? ; } don't change order |
||
1944 | point_index3 dw ? ;-/ |
||
1945 | temp_col dw ? |
||
1946 | high dd ? |
||
1947 | align 8 |
||
1948 | buffer dq ? |
||
1949 | |||
1783 | yogev_ezra | 1950 | err_ dd ? |
1781 | yogev_ezra | 1951 | drr dd ? |
1952 | xx dd ? |
||
1953 | yy dd ? |
||
1954 | xst dd ? |
||
1955 | yst dd ? |
||
1956 | align 16 |
||
1957 | points: |
||
1958 | rw (EndFile-SourceFile)/12*3 |
||
1959 | points_count = ($-points)/6 |
||
1960 | triangles: |
||
1961 | rw (EndFile-SourceFile)/12*3 |
||
1962 | triangles_count = ($-triangles)/6 |
||
1963 | |||
1964 | align 16 |
||
1965 | points_rotated rw points_count*3 + 2 |
||
1966 | align 16 |
||
1967 | label trizdd dword |
||
1968 | label trizdq qword |
||
1969 | triangles_with_z rw triangles_count*4 + 2 ; triangles triple dw + z position |
||
1970 | align 16 |
||
1971 | triangles_normals rb triangles_count * 12 ; |
||
1972 | point_normals rb points_count * 12 ;one 3dvector - triple float dword x,y,z |
||
1973 | align 16 |
||
1974 | point_normals_rotated rb points_count * 12 |
||
1975 | align 16 |
||
1976 | vectors rb 24 |
||
1977 | points_color rb 6*points_count ; each color as word |
||
1978 | ; sorted_triangles rw triangles_count*3 + 2 |
||
1979 | ;align 16 |
||
1980 | screen rb SIZE_X * SIZE_Y * 3 ; screen buffer |
||
1981 | Z_buffer rb SIZE_X * SIZE_Y * 4 |
||
1982 | envmap rb 512*512*3 |
||
1983 | memStack rb 1000 ;memory area for stack |
||
1984 | I_END: |