Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1245 | hidnplayr | 1 | |
1776 | yogev_ezra | 2 | ; compiler : FASM 1.67.11 |
3 | ; system : KolibriOS/MenuetOS |
||
1245 | hidnplayr | 4 | ; author : Macgub aka Maciej Guba |
5 | ; email : macgub3@wp.pl |
||
6 | ; web : www.menuet.xt.pl |
||
7 | ; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS. |
||
8 | ; Special greetings to all MenuetOS maniax in the world. |
||
9 | ; I hope because my intros Christian Belive will be near to each of You. |
||
10 | |||
11 | |||
12 | |||
13 | ; madis.kalme@mail.ee |
||
14 | ; I tried optimizing it a bit, but don't know if it was successful. The objects |
||
15 | ; can be: |
||
16 | ; 1) Read from a file (*.3DS standard) |
||
17 | ; 2) Written in manually (at the end of the code) |
||
18 | ;include 'proc32.inc' |
||
19 | |||
20 | |||
21 | SIZE_Y equ 512 ; ///// I want definitely |
||
22 | TIMEOUT equ 10 ; ------ say: |
||
23 | ROUND equ 10 ; \ @ @/ keep smiling every |
||
24 | TEX_X equ 512 ; texture width ; \ ./ / day. |
||
25 | TEX_Y equ 512 ; height ; \/ / |
||
26 | TEX_SHIFT equ 9 ; texture width shifting ; __||__ / |
||
27 | TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 ; /| | |
||
28 | TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ; / \ / |
||
29 | FLUENTLY = 0 ; / | | |
||
30 | SHIFTING = 1 ; ------ |
||
31 | CATMULL_SHIFT equ 8 ; | | |
||
32 | LIGHT_SIZE equ 22 ; | | |
||
33 | NON = 0 ; -/ \- |
||
34 | MMX = 1 |
||
35 | SSE = 2 |
||
36 | Ext = MMX ;Ext={ NON | MMX | SSE} |
||
37 | |||
38 | |||
39 | USE_LFN = 1 |
||
40 | |||
41 | |||
42 | org 0x0 |
||
43 | db 'MENUET01' ; 8 byte id |
||
44 | dd 0x01 ; header version |
||
45 | dd START ; start of code |
||
46 | dd I_END ; size of image |
||
47 | dd MEM_END ; memory for app |
||
48 | dd MEM_END ; esp |
||
49 | dd I_Param ; I_Param |
||
50 | dd 0x0 ; I_Icon |
||
51 | |||
52 | |||
53 | cld |
||
54 | call alloc_buffer_mem |
||
55 | call read_param |
||
56 | call read_from_disk ; read, if all is ok eax = 0 |
||
57 | cmp eax,0 |
||
58 | jne .gen |
||
59 | call read_tp_variables ; init points and triangles count variables |
||
60 | cmp eax,0 |
||
61 | je .gen |
||
62 | jmp .malloc |
||
63 | .gen: |
||
64 | if USE_LFN |
||
65 | mov [triangles_count_var],1000 |
||
66 | mov [points_count_var],1000 |
||
67 | call alloc_mem_for_tp |
||
68 | end if |
||
69 | call generate_object |
||
70 | jmp .opt |
||
71 | .malloc: |
||
72 | if USE_LFN |
||
73 | call alloc_mem_for_tp |
||
74 | end if |
||
75 | call read_from_file |
||
76 | .opt: |
||
77 | call optimize_object1 ; proc in file b_procs.asm |
||
78 | ; set point(0,0,0) in center and calc all coords |
||
79 | ; to be in <-1.0,1.0> |
||
80 | call normalize_all_light_vectors |
||
81 | call init_triangles_normals2 |
||
82 | call init_point_normals |
||
83 | ; call init_envmap2 |
||
84 | call init_envmap_cub |
||
85 | call generate_texture2 |
||
86 | call init_sincos_tab |
||
87 | |||
88 | |||
89 | mov edi,bumpmap |
||
90 | call calc_bumpmap |
||
91 | call calc_bumpmap_coords ; bump and texture mapping |
||
92 | call draw_window |
||
93 | |||
94 | |||
95 | |||
96 | |||
97 | |||
98 | mov ebx,TIMEOUT |
||
99 | cmp [speed_flag],1 |
||
100 | jne .skip |
||
101 | mov eax,11 |
||
102 | .skip: |
||
103 | int 0x40 |
||
104 | |||
105 | |||
106 | je red |
||
107 | cmp eax,2 ; key in buffer ? |
||
108 | je key |
||
109 | cmp eax,3 ; button in buffer ? |
||
110 | je button |
||
111 | |||
112 | |||
113 | |||
114 | |||
115 | call draw_window |
||
116 | |||
117 | |||
118 | |||
119 | |||
120 | mov eax,2 ; just read it and ignore |
||
121 | int 0x40 |
||
122 | jmp noclose |
||
123 | |||
124 | |||
125 | mov eax,17 ; get id |
||
126 | int 0x40 |
||
127 | |||
128 | |||
129 | jne @f |
||
130 | |||
131 | |||
132 | int 0x40 |
||
133 | @@: |
||
134 | cmp ah,30 |
||
135 | jge add_vec_buttons |
||
136 | call update_flags ; update flags and write labels of flags |
||
137 | |||
138 | |||
139 | cmp ah,3 ; ah = 3 -> shading model |
||
140 | jne .next_m6 |
||
141 | cmp [dr_flag],2 |
||
142 | jne @f |
||
143 | call init_envmap2 |
||
144 | ; call init_envmap_cub2 |
||
145 | @@: |
||
146 | cmp [dr_flag],4 |
||
147 | jne @f |
||
148 | call generate_texture2 |
||
149 | |||
150 | |||
151 | .next_m6: |
||
152 | ; ah = 5 -> scale- |
||
153 | cmp ah,5 |
||
154 | jne @f |
||
155 | mov [scale],0.7 |
||
156 | fninit |
||
157 | fld [rsscale] |
||
158 | fmul [scale] |
||
159 | fstp [rsscale] |
||
160 | |||
161 | |||
162 | cmp ah,6 ; ah = 6 -> scale+ |
||
163 | jne @f |
||
164 | mov [scale],1.3 |
||
165 | fninit |
||
166 | fld [rsscale] |
||
167 | fmul [scale] |
||
168 | fstp [rsscale] |
||
169 | |||
170 | |||
171 | cmp ah,9 ; lights random ; 'flat' 0 |
||
172 | jne .next_m5 ; 'grd ' 1 |
||
173 | call make_random_lights ; 'env ' 2 |
||
174 | call normalize_all_light_vectors ; 'bump' 3 |
||
175 | call do_color_buffer ; intit color_map ; 'tex ' 4 |
||
176 | cmp [emboss_flag],1 ; 'pos ' 5 |
||
177 | je @f ; 'dots' 6 |
||
178 | cmp [dr_flag],8 |
||
179 | jge @f |
||
180 | cmp [dr_flag],2 ; 'txgr' 7 |
||
181 | jl .next_m5 ; '2tex' 8 |
||
182 | cmp [dr_flag],3 ; 'btex' 9 |
||
183 | jg .next_m5 |
||
184 | @@: |
||
185 | call init_envmap2 ; update env map if shading model = environment or bump |
||
186 | .next_m5: |
||
187 | cmp ah,11 |
||
188 | je @f |
||
189 | cmp ah,12 |
||
190 | je @f |
||
191 | cmp ah,13 |
||
192 | jne .next_m4 |
||
193 | @@: |
||
194 | call mirror |
||
195 | .next_m4: |
||
196 | cmp ah,14 |
||
197 | jne @f |
||
198 | call exchange |
||
199 | @@: |
||
200 | cmp ah,15 |
||
201 | jne @f |
||
202 | cmp [emboss_flag],1 |
||
203 | call init_envmap2 |
||
204 | @@: |
||
205 | ; cmp ah,17 |
||
206 | ; jne .next_m |
||
207 | ; cmp [move_flag],2 |
||
208 | ; jne @f |
||
209 | ; call draw_window ; redraw other labels to navigation buttons |
||
210 | ; @@: |
||
211 | ; cmp [move_flag],0 |
||
212 | ; jne .next_m |
||
213 | ; call draw_window ; redraw other labels to navigation buttons |
||
214 | .next_m: |
||
215 | cmp ah,18 |
||
216 | jne .next_m2 |
||
217 | if USE_LFN |
||
1776 | yogev_ezra | 218 | mov [re_alloc_flag],1 ; reallocate memory |
219 | mov [triangles_count_var],1000 |
||
220 | mov [points_count_var],1000 |
||
221 | call alloc_mem_for_tp |
||
222 | mov [re_alloc_flag],0 |
||
223 | end if |
||
224 | mov bl,[generator_flag] |
||
1245 | hidnplayr | 225 | or bl,bl |
226 | jz .next_m2 |
||
227 | cmp bl,1 |
||
228 | jne @f |
||
229 | call generate_object |
||
230 | jmp .calc_norm |
||
231 | @@: |
||
232 | cmp bl,4 |
||
233 | jg @f |
||
234 | movzx ax,bl ; ax < - object number |
||
235 | call generate_object2 |
||
236 | jmp .calc_norm |
||
237 | @@: |
||
238 | call generate_object3 |
||
239 | .calc_norm: |
||
240 | call optimize_object1 |
||
241 | call init_triangles_normals2 |
||
242 | call init_point_normals |
||
243 | call calc_bumpmap_coords ; bump and texture mapping |
||
244 | |||
245 | |||
246 | cmp ah,19 |
||
247 | je @f |
||
248 | cmp ah,20 |
||
249 | jne .next_m3 |
||
250 | @@: |
||
251 | mov edi,bumpmap |
||
252 | call calc_bumpmap |
||
253 | .next_m3: |
||
1776 | yogev_ezra | 254 | cmp ah,21 ; re map bumps, texture coordinates |
255 | jne @f |
||
256 | call calc_bumpmap_coords |
||
257 | @@: |
||
258 | jmp noclose |
||
1245 | hidnplayr | 259 | |
260 | |||
261 | |||
262 | add_vec_buttons: ; can move: object, camera,.. list is open |
||
263 | ; |
||
264 | cmp ah,30 |
||
265 | jne .next |
||
266 | cmp [move_flag],1 |
||
267 | je @f |
||
268 | ; cmp [move_flag],2 |
||
269 | ; je .set_light1 |
||
270 | sub [vect_y],10 |
||
271 | jmp .next |
||
272 | @@: |
||
273 | sub [yobs],10 ; observator = camera position |
||
274 | jmp .next |
||
275 | |||
276 | |||
277 | ; .set_light1: ; r - |
||
278 | ; movzx ebx,[light_no_flag] ; * 22 |
||
279 | ; mov ecx,ebx |
||
280 | ; shl ebx,4 |
||
281 | ; shl ecx,1 |
||
282 | ; add ebx,ecx |
||
283 | ; shl ecx,1 |
||
284 | ; add ebx,ecx |
||
285 | ; add ebx,lights+6 ; 6 -> light vector size |
||
286 | ; |
||
287 | ; movzx ecx,[light_comp_flag] |
||
288 | ; lea ecx,[ecx*3} |
||
289 | ; add ebx,ecx ; ebx -> color to set |
||
290 | |||
291 | |||
292 | .next: |
||
293 | cmp ah,31 |
||
294 | jne .next1 |
||
295 | cmp [move_flag],1 |
||
296 | je @f |
||
297 | |||
298 | |||
299 | jmp .next1 |
||
300 | @@: |
||
301 | add [zobs],10 ; observator = camera position |
||
302 | .next1: |
||
303 | cmp ah,33 |
||
304 | jne .next2 |
||
305 | cmp [move_flag],1 |
||
306 | je @f |
||
307 | |||
308 | |||
309 | jmp .next2 |
||
310 | @@: |
||
311 | sub [xobs],10 ; observator = camera position |
||
312 | .next2: |
||
313 | cmp ah,32 |
||
314 | jne .next3 |
||
315 | cmp [move_flag],1 |
||
316 | je @f |
||
317 | |||
318 | |||
319 | jmp .next3 |
||
320 | @@: |
||
321 | add [xobs],10 ; observator = camera position |
||
322 | .next3: |
||
323 | cmp ah,34 |
||
324 | jne .next4 |
||
325 | cmp [move_flag],1 |
||
326 | je @f |
||
327 | |||
328 | |||
329 | jmp .next4 |
||
330 | @@: |
||
331 | sub [zobs],10 ; observator = camera position |
||
332 | .next4: |
||
333 | cmp ah,35 |
||
334 | jne .next5 |
||
335 | cmp [move_flag],1 |
||
336 | je @f |
||
337 | |||
338 | |||
339 | add [vect_y],10 |
||
340 | jmp .next5 |
||
341 | @@: |
||
342 | add [yobs],10 ; observator = camera position |
||
343 | .next5: |
||
344 | |||
345 | |||
346 | |||
347 | |||
348 | |||
349 | |||
350 | jne .no_x |
||
351 | inc [angle_x] |
||
352 | and [angle_x],0xff |
||
353 | mov [angle_z],0 |
||
354 | jmp .end_rot |
||
355 | |||
356 | |||
357 | cmp [r_flag],0 |
||
358 | jne .no_y |
||
359 | inc [angle_y] |
||
360 | and [angle_y],0xff |
||
361 | mov [angle_z],0 |
||
362 | jmp .end_rot |
||
363 | |||
364 | |||
365 | cmp [r_flag],1 |
||
366 | jne .end_rot |
||
367 | mov cx,[angle_x] |
||
368 | inc cx |
||
369 | and cx,0xff |
||
370 | mov [angle_z],0 |
||
371 | mov [angle_y],cx |
||
372 | mov [angle_x],cx |
||
373 | .end_rot: |
||
374 | |||
375 | |||
376 | mov edi,matrix |
||
377 | call make_rotation_matrix |
||
378 | ; RDTSC |
||
379 | ; push eax |
||
380 | mov esi,[points_normals_ptr] |
||
381 | mov edi,[points_normals_rot_ptr] |
||
382 | mov ebx,matrix |
||
383 | movzx ecx,[points_count_var] |
||
384 | call rotary |
||
385 | |||
386 | |||
387 | call add_scale_to_matrix |
||
388 | |||
389 | |||
390 | mov edi,[points_rotated_ptr] |
||
391 | mov ebx,matrix |
||
392 | movzx ecx,[points_count_var] |
||
393 | call rotary |
||
394 | |||
395 | |||
396 | ; pop ebx |
||
397 | ; sub eax,ebx |
||
398 | ; sub eax,41 |
||
399 | ; push eax |
||
400 | |||
401 | |||
402 | mov edi,[points_translated_ptr] |
||
403 | movzx ecx,[points_count_var] |
||
404 | call translate_points |
||
405 | |||
406 | |||
407 | ; jne @f |
||
408 | ; call calc_attenuation_light |
||
409 | ; @@: |
||
410 | cmp [fire_flag],0 |
||
411 | jne @f |
||
412 | call clrscr ; clear the screen |
||
413 | @@: |
||
414 | cmp [catmull_flag],1 ;non sort if Catmull = on |
||
415 | je .no_sort |
||
416 | call sort_triangles |
||
417 | .no_sort: |
||
418 | cmp [dr_flag],7 ; fill if 2tex and texgrd |
||
419 | jge @f |
||
420 | cmp [catmull_flag],0 ;non fill if Catmull = off |
||
421 | je .non_f |
||
422 | cmp [dr_flag],6 ; non fill if dots |
||
423 | je .non_f |
||
424 | @@: |
||
425 | call fill_Z_buffer ; make background |
||
426 | .non_f: |
||
427 | RDTSC |
||
428 | push eax |
||
429 | cmp [dr_flag],6 |
||
430 | jne @f |
||
431 | call draw_dots |
||
432 | jmp .blurrr |
||
433 | @@: |
||
434 | call draw_triangles ; draw all triangles from the list |
||
435 | .blurrr: |
||
436 | cmp [fire_flag],0 |
||
437 | jne @f |
||
438 | cmp [blur_flag],0 |
||
439 | je .no_blur ; no blur, no fire |
||
440 | movzx ecx,[blur_flag] |
||
441 | call blur_screen ; blur and fire |
||
442 | jmp .no_blur |
||
443 | @@: |
||
444 | cmp [emboss_flag],0 |
||
445 | jne .emb ; if emboss=true -> no fire |
||
446 | movzx ecx,[fire_flag] |
||
447 | call blur_screen ; blur and fire |
||
448 | .no_blur: ; no blur, no fire |
||
449 | cmp [emboss_flag],0 |
||
450 | je @f |
||
451 | .emb: |
||
452 | call do_emboss |
||
453 | |||
454 | |||
455 | |||
456 | |||
457 | |||
458 | sub eax,[esp] |
||
459 | sub eax,41 |
||
460 | ; pop eax |
||
461 | |||
462 | |||
463 | .dc: |
||
464 | xor edx,edx |
||
465 | mov edi,10 |
||
466 | div edi |
||
467 | add dl,30h |
||
468 | mov [STRdata+ecx-1],dl |
||
469 | loop .dc |
||
470 | pop eax |
||
471 | |||
472 | |||
473 | mov ebx,screen |
||
474 | mov ecx,SIZE_X shl 16 + SIZE_Y |
||
475 | mov edx,5 shl 16 + 20 |
||
476 | int 0x40 |
||
477 | |||
478 | |||
479 | |||
480 | mov ebx,5*65536+23 ; [x start] *65536 + [y start] |
||
481 | mov ecx,-1 |
||
482 | mov edx,STRdata ; pointer to text beginning |
||
483 | mov esi,10 ; text length |
||
484 | int 40h |
||
485 | |||
486 | |||
487 | |||
488 | |||
489 | |||
490 | |||
491 | ;-------------------------PROCEDURES--------------------------------------------- |
||
492 | ;-------------------------------------------------------------------------------- |
||
493 | include "TEX3.INC" |
||
1728 | clevermous | 494 | include "FLAT_CAT.INC" |
495 | include "TEX_CAT.INC" |
||
496 | include "BUMP_CAT.INC" |
||
497 | include "3DMATH.INC" |
||
498 | include "GRD3.INC" |
||
499 | include "FLAT3.INC" |
||
500 | include "BUMP3.INC" |
||
501 | include "B_PROCS.INC" |
||
502 | include "A_PROCS.INC" |
||
503 | include "GRD_CAT.INC" |
||
504 | include "BUMP_TEX.INC" |
||
505 | include "GRD_TEX.INC" |
||
506 | include "TWO_TEX.INC" |
||
507 | |||
1245 | hidnplayr | 508 | |
509 | movzx ecx,[size_x] |
||
510 | movzx eax,[size_y] |
||
511 | mul ecx |
||
512 | lea ecx,[eax*3] |
||
513 | push ecx |
||
514 | shl eax,2 |
||
515 | add ecx,eax |
||
516 | add ecx,MEM_END |
||
517 | mov ebx,1 |
||
518 | mov eax,64 ; allocate mem - resize app mem |
||
519 | int 0x40 |
||
520 | mov [screen_ptr],MEM_END |
||
521 | mov [Zbuffer_ptr],MEM_END |
||
522 | pop ecx |
||
523 | add [Zbuffer_ptr],ecx |
||
524 | ret |
||
525 | |||
526 | |||
527 | ; updates flags and writing flag description |
||
528 | ; in ah - button number |
||
529 | push ax |
||
530 | mov edi,menu |
||
531 | .ch_another: |
||
532 | cmp ah,byte[edi] ; ah = button id |
||
533 | jne @f |
||
534 | mov bl,byte[edi+11] ; max_flag + 1 |
||
535 | cmp bl,255 |
||
536 | je .no_write |
||
537 | inc byte[edi+12] ; flag |
||
538 | cmp byte[edi+12],bl |
||
539 | jne .write |
||
540 | mov byte[edi+12],0 |
||
541 | jmp .write |
||
542 | @@: |
||
543 | add edi,17 |
||
544 | cmp byte[edi],-1 |
||
545 | jne .ch_another |
||
546 | .write: |
||
547 | ; clreol {pascal never dies} |
||
548 | ; * eax = 13 - function number |
||
549 | ; * ebx = [coordinate on axis x]*65536 + [size on axis x] |
||
550 | ; * ecx = [coordinate on axis y]*65536 + [size on axis y] |
||
551 | ; * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill |
||
552 | |||
553 | |||
554 | movzx ecx,byte[edi] |
||
555 | sub cl,2 |
||
556 | lea ecx,[ecx*3] |
||
557 | lea ecx,[ecx*5] |
||
558 | add ecx,28 |
||
559 | shl ecx,16 |
||
560 | add ecx,14 ; ecx = [coord y]*65536 + [size y] |
||
561 | mov ebx,(SIZE_X+12+70)*65536+25 ; [x start] *65536 + [size x] |
||
562 | mov edx,0x00000000 ; color 0x00RRGGBB |
||
563 | int 0x40 |
||
564 | |||
565 | |||
566 | movzx ebx,byte[edi] |
||
567 | sub bl,2 |
||
568 | lea ebx,[ebx*3] |
||
569 | lea ebx,[ebx*5] |
||
570 | add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
||
571 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
572 | movzx edx,byte[edi+12] ; current flag |
||
573 | shl edx,2 ; * 4 = text length |
||
574 | add edx,dword[edi+13] ; pointer to text beginning |
||
575 | mov esi,4 ; text length - |
||
576 | ; flag description 4 characters |
||
577 | int 0x40 |
||
578 | |||
579 | |||
580 | pop ax |
||
581 | ret |
||
582 | normalize_all_light_vectors: |
||
583 | mov edi,lights |
||
584 | @@: |
||
585 | call normalize_vector ; 3dmath.inc |
||
586 | add edi,LIGHT_SIZE |
||
587 | cmp edi,lightsend ;ecx |
||
588 | jl @b |
||
589 | ret |
||
590 | |||
591 | |||
592 | ;macro .comment222 |
||
593 | ; ; planar mapping |
||
594 | ; mov esi,points |
||
595 | ; mov edi,tex_points |
||
596 | ; @@: |
||
597 | ; add esi,2 |
||
598 | ; movsd |
||
599 | ; cmp dword[esi],dword -1 |
||
600 | ; jne @b |
||
601 | |||
602 | |||
603 | |||
604 | |||
605 | ; sub esp,4 |
||
606 | |||
607 | |||
1776 | yogev_ezra | 608 | fldpi |
1245 | hidnplayr | 609 | fadd st,st |
610 | mov esi,[points_ptr] |
||
611 | mov edi,tex_points |
||
612 | movzx ecx,[points_count_var] |
||
613 | inc ecx |
||
614 | ; cmp [map_tex_flag],1 |
||
1776 | yogev_ezra | 615 | ; jne .cylindric |
616 | ; spherical mapping around y axle |
||
617 | |||
1245 | hidnplayr | 618 | |
619 | fld dword[esi] ; x coord |
||
620 | fld dword[esi+8] ; z coord |
||
621 | fpatan ; arctg(st1/st) |
||
622 | ; fdiv .Pi2 |
||
623 | fdiv st0,st1 |
||
624 | fimul [tex_x_div2] |
||
625 | fiadd [tex_x_div2] |
||
626 | fistp word[edi] ; x |
||
627 | |||
628 | |||
629 | fld dword[esi] ; x |
||
630 | fmul st,st0 |
||
631 | fld dword[esi+4] ; y |
||
632 | fmul st,st0 |
||
633 | fld dword[esi+8] ; z |
||
634 | fmul st,st0 |
||
635 | faddp |
||
636 | faddp |
||
637 | fsqrt |
||
638 | fpatan |
||
639 | fldpi |
||
640 | fdivp |
||
641 | fimul [tex_y_div2] |
||
642 | fiadd [tex_y_div2] |
||
643 | fistp word[edi+2] ; y |
||
644 | |||
645 | |||
646 | add edi,4 |
||
647 | loop @b |
||
648 | ffree st0 |
||
649 | ; jmp .end_map |
||
1776 | yogev_ezra | 650 | ; .cylindric: |
651 | ; fld dword[esi] ; around y axle |
||
652 | ; fld dword[esi+8] |
||
653 | ; fpatan |
||
654 | ; fdiv st0,st1 |
||
655 | ; fimul [tex_x_div2] |
||
656 | ; fiadd [tex_x_div2] |
||
657 | ; fistp word[edi] |
||
658 | |||
1245 | hidnplayr | 659 | |
1776 | yogev_ezra | 660 | ; fimul [tex_y_div2] |
661 | ; fiadd [tex_y_div2] |
||
662 | ; fistp word[edi+2] |
||
663 | |||
664 | |||
665 | ; add edi,4 |
||
666 | ; loop .cylindric |
||
667 | ; ffree st0 |
||
668 | ;; mov esp,ebp |
||
669 | ; .end_map: |
||
670 | ret |
||
1245 | hidnplayr | 671 | |
672 | |||
673 | |||
674 | ;env_map 512 x 512 x 3 bytes |
||
675 | .temp equ word [ebp-2] |
||
676 | .nEy equ word [ebp-4] |
||
677 | .nEx equ word [ebp-6] |
||
678 | .col_r equ [ebp-8] |
||
679 | .col_g equ [ebp-9] |
||
680 | .col_b equ [ebp-10] |
||
681 | |||
682 | |||
683 | mov ebp,esp |
||
684 | sub esp,20 |
||
685 | mov edi,envmap |
||
686 | fninit |
||
687 | |||
688 | |||
689 | .ie_ver: |
||
690 | mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
||
691 | .ie_hor: |
||
692 | xor ebx,ebx |
||
693 | mov dword .col_b, 0 |
||
694 | .light: |
||
695 | lea esi,[lights+ebx] |
||
696 | fld dword[esi] ; light vector x cooficient |
||
697 | fimul [tex_x_div2] ;[i256] |
||
698 | mov .temp,cx |
||
699 | fisubr .temp |
||
700 | fistp .nEx |
||
701 | fld dword[esi+4] ; light vector y cooficient |
||
702 | fimul [tex_y_div2] ;[i256] |
||
703 | mov .temp,dx |
||
704 | fisubr .temp |
||
705 | fistp .nEy |
||
706 | |||
707 | |||
708 | jl .update_counters |
||
709 | cmp .nEy,- TEX_Y / 2 ;256 |
||
710 | jl .update_counters |
||
711 | cmp .nEx,TEX_X / 2 ;256 |
||
712 | jg .update_counters |
||
713 | cmp .nEy,TEX_Y / 2 ;256 |
||
714 | jg .update_counters |
||
715 | |||
716 | |||
717 | fmul st,st0 |
||
718 | fild .nEy |
||
719 | fmul st,st0 |
||
720 | faddp |
||
721 | fsqrt |
||
722 | fisubr [i256] |
||
723 | fmul [env_const] |
||
724 | fidiv [i256] ; st - 'virtual' dot product |
||
725 | |||
726 | |||
727 | fstsw ax |
||
728 | sahf |
||
729 | jb @f |
||
730 | ffree st |
||
731 | fld1 ;[dot_max] |
||
732 | @@: |
||
733 | fcom [dot_min] |
||
734 | fstsw ax |
||
735 | sahf |
||
736 | ja @f |
||
737 | ffree st |
||
738 | fldz ;[dot_min] |
||
739 | @@: |
||
740 | push ebp |
||
741 | movzx ax,byte[esi+21] |
||
742 | push ax ;- shines |
||
743 | mov al,byte[esi+14] ; b orginal color |
||
744 | push ax |
||
745 | mov al,byte[esi+13] ; g |
||
746 | push ax |
||
747 | mov al,byte[esi+12] ; r |
||
748 | push ax |
||
749 | mov al,byte[esi+20] ; b max color |
||
750 | push ax |
||
751 | mov al,byte[esi+19] ; g |
||
752 | push ax |
||
753 | mov al,byte[esi+18] ; r |
||
754 | push ax |
||
755 | mov al,byte[esi+17] ; b min col |
||
756 | push ax |
||
757 | mov al,byte[esi+16] ; g |
||
758 | push ax |
||
759 | mov al,byte[esi+15] ; r |
||
760 | push ax |
||
761 | push eax ; earlier - dot pr |
||
762 | ; fstp .dot_product |
||
763 | ; push .dot_product |
||
764 | call calc_one_col |
||
765 | pop ebp |
||
766 | ; eax-0x00rrggbb |
||
767 | cmp al,.col_b |
||
768 | jbe @f |
||
769 | mov .col_b,al |
||
770 | @@: ; eax - ggbb00rr |
||
771 | shr ax,8 |
||
772 | cmp al,.col_g |
||
773 | jbe @f |
||
774 | mov .col_g,al |
||
775 | @@: ; eax - bb0000gg |
||
776 | shr eax,16 |
||
777 | cmp al,.col_r |
||
778 | jbe @f |
||
779 | mov .col_r,al |
||
780 | @@: |
||
781 | .update_counters: ; update and jump when neccesery |
||
782 | add ebx,LIGHT_SIZE |
||
783 | cmp bx,[all_lights_size] |
||
784 | jl .light ; next_light |
||
785 | mov eax,dword .col_b |
||
786 | stosd |
||
787 | dec edi |
||
788 | |||
789 | |||
790 | cmp cx,TEX_X / 2 ;256 |
||
791 | jne .ie_hor |
||
792 | |||
793 | |||
794 | cmp dx,TEX_Y / 2 ;256 |
||
795 | jne .ie_ver |
||
796 | |||
797 | |||
798 | pop ebp |
||
799 | ret |
||
800 | |||
801 | |||
802 | ;env_map 512 x 512 x 3 bytes ; many lights using |
||
803 | .temp equ word [ebp-2] |
||
804 | .nz equ dword [ebp-6] ; dword |
||
805 | .ny equ dword [ebp-10] |
||
806 | .nx equ dword [ebp-14] |
||
807 | .col_r equ [ebp-16] |
||
808 | .col_g equ [ebp-17] |
||
809 | .col_b equ [ebp-18] |
||
810 | |||
811 | |||
812 | mov ebp,esp |
||
813 | sub esp,20 |
||
814 | mov edi,color_map |
||
815 | fninit |
||
816 | |||
817 | |||
818 | .ie_ver: |
||
819 | mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
||
820 | .ie_hor: |
||
821 | mov .temp,cx |
||
822 | fild .temp |
||
823 | fidiv [i256] ;st = Nx - vector normal x cooficient |
||
824 | fst .nx |
||
825 | fmul st,st0 |
||
826 | mov .temp,dx |
||
827 | fild .temp |
||
828 | fidiv [i256] ; st = Ny - vector normal y coeficient |
||
829 | fst .ny |
||
830 | fmul st,st0 |
||
831 | faddp |
||
832 | fld1 |
||
833 | fchs |
||
834 | faddp |
||
835 | fabs |
||
836 | fsqrt |
||
837 | fchs |
||
838 | fstp .nz ; st - Nz - vect normal z coeficient |
||
839 | xor ebx,ebx |
||
840 | mov dword .col_b, 0 |
||
841 | .light: |
||
842 | push edi ;env_map |
||
843 | lea esi,[lights+ebx] |
||
844 | lea edi,.nx |
||
845 | call dot_product |
||
846 | pop edi |
||
847 | fcom [dot_min] |
||
848 | fstsw ax |
||
849 | sahf |
||
850 | ja .env_ok1 ;compare with dot_max |
||
851 | ffree st |
||
852 | |||
853 | |||
854 | .env_ok1: |
||
855 | fcom [dot_max] |
||
856 | fstsw ax |
||
857 | sahf |
||
858 | jb .env_ok2 ; calc col |
||
859 | ffree st |
||
860 | jmp .update_counters |
||
861 | .env_ok2: ;calc col |
||
862 | push ebp |
||
863 | movzx ax,byte[esi+21] |
||
864 | push ax ;- shines |
||
865 | mov al,byte[esi+14] ; b orginal color |
||
866 | push ax |
||
867 | mov al,byte[esi+13] ; g |
||
868 | push ax |
||
869 | mov al,byte[esi+12] ; r |
||
870 | push ax |
||
871 | mov al,byte[esi+20] ; b max color |
||
872 | push ax |
||
873 | mov al,byte[esi+19] ; g |
||
874 | push ax |
||
875 | mov al,byte[esi+18] ; r |
||
876 | push ax |
||
877 | mov al,byte[esi+17] ; b min col |
||
878 | push ax |
||
879 | mov al,byte[esi+16] ; g |
||
880 | push ax |
||
881 | mov al,byte[esi+15] ; r |
||
882 | push ax |
||
883 | push eax ; earlier - dot pr |
||
884 | ; fstp .dot_product |
||
885 | ; push .dot_product |
||
886 | call calc_one_col |
||
887 | pop ebp |
||
888 | ; eax-0x00rrggbb |
||
889 | cmp al,.col_b |
||
890 | jbe @f |
||
891 | mov .col_b,al |
||
892 | @@: |
||
893 | shr ax,8 |
||
894 | cmp al,.col_g |
||
895 | jbe @f |
||
896 | mov .col_g,al |
||
897 | @@: |
||
898 | shr eax,16 |
||
899 | cmp al,.col_r |
||
900 | jbe @f |
||
901 | mov .col_r,al |
||
902 | @@: |
||
903 | .update_counters: ; update and jump when neccesery |
||
904 | add ebx,LIGHT_SIZE |
||
905 | cmp bx,[all_lights_size] |
||
906 | jl .light ; next_light |
||
907 | mov eax,dword .col_b |
||
908 | stosd |
||
909 | dec edi |
||
910 | |||
911 | |||
912 | cmp cx,TEX_X / 2 ;256 |
||
913 | jne .ie_hor |
||
914 | |||
915 | |||
916 | cmp dx,TEX_X / 2 ;256 |
||
917 | jne .ie_ver |
||
918 | |||
919 | |||
920 | mov esp,ebp |
||
921 | pop ebp |
||
922 | ret |
||
923 | if 0 |
||
924 | init_triangles_normals: |
||
925 | mov ebx,triangles_normals |
||
926 | mov ebp,triangles |
||
927 | @@: |
||
928 | push ebx |
||
929 | mov ebx,vectors |
||
930 | movzx esi,word[ebp] ; first point index |
||
931 | lea esi,[esi*3] |
||
932 | lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
||
933 | movzx edi,word[ebp+2] ; second point index |
||
934 | lea edi,[edi*3] |
||
935 | lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
||
936 | call make_vector |
||
937 | add ebx,12 |
||
938 | mov esi,edi |
||
939 | movzx edi,word[ebp+4] ; third point index |
||
940 | lea edi,[edi*3] |
||
941 | lea edi,[points+edi*2] |
||
942 | call make_vector |
||
943 | mov edi,ebx ; edi - pointer to 2nd vector |
||
944 | mov esi,ebx |
||
945 | sub esi,12 ; esi - pointer to 1st vector |
||
946 | pop ebx |
||
947 | call cross_product |
||
948 | mov edi,ebx |
||
949 | call normalize_vector |
||
950 | add ebp,6 |
||
951 | add ebx,12 |
||
952 | cmp dword[ebp],-1 |
||
953 | jne @b |
||
954 | ret |
||
955 | end if |
||
956 | init_point_normals: |
||
957 | .x equ dword [ebp-4] |
||
958 | .y equ dword [ebp-8] |
||
959 | .z equ dword [ebp-12] |
||
960 | .point_number equ word [ebp-26] |
||
961 | .hit_faces equ word [ebp-28] |
||
962 | |||
963 | |||
964 | mov ebp,esp |
||
965 | sub esp,28 |
||
966 | mov edi,[points_normals_ptr] |
||
967 | mov .point_number,0 |
||
968 | .ipn_loop: |
||
969 | mov .hit_faces,0 |
||
970 | mov .x,0 |
||
971 | mov .y,0 |
||
972 | mov .z,0 |
||
973 | mov esi,[triangles_ptr] |
||
974 | xor ecx,ecx ; ecx - triangle number |
||
975 | .ipn_check_face: |
||
976 | xor ebx,ebx ; ebx - 'position' in one triangle |
||
977 | .ipn_check_vertex: |
||
978 | movzx eax,word[esi+ebx] ; eax - point_number |
||
979 | cmp ax,.point_number |
||
980 | jne .ipn_next_vertex |
||
981 | push esi |
||
982 | mov esi,ecx |
||
983 | lea esi,[esi*3] |
||
984 | ; lea esi,[triangles_normals+esi*4] |
||
985 | shl esi,2 |
||
986 | add esi,[triangles_normals_ptr] |
||
987 | |||
988 | |||
989 | fadd dword[esi+vec_x] ; vec_x this defined in 3dmath.asm - x cooficient |
||
990 | fstp .x ; of normal vactor |
||
991 | fld .y |
||
992 | fadd dword[esi+vec_y] |
||
993 | fstp .y |
||
994 | fld .z |
||
995 | fadd dword[esi+vec_z] |
||
996 | fstp .z |
||
997 | pop esi |
||
998 | inc .hit_faces |
||
999 | jmp .ipn_next_face |
||
1000 | .ipn_next_vertex: |
||
1001 | add ebx,2 |
||
1002 | cmp ebx,6 |
||
1003 | jne .ipn_check_vertex |
||
1004 | .ipn_next_face: |
||
1005 | add esi,6 |
||
1006 | inc ecx |
||
1007 | cmp cx,[triangles_count_var] |
||
1008 | jne .ipn_check_face |
||
1009 | |||
1010 | |||
1011 | fidiv .hit_faces |
||
1012 | fstp dword[edi+vec_x] |
||
1013 | fld .y |
||
1014 | fidiv .hit_faces |
||
1015 | fstp dword[edi+vec_y] |
||
1016 | fld .z |
||
1017 | fidiv .hit_faces |
||
1018 | fstp dword[edi+vec_z] |
||
1019 | call normalize_vector |
||
1020 | add edi,12 ;type vector 3d |
||
1021 | inc .point_number |
||
1022 | mov dx,.point_number |
||
1023 | cmp dx,[points_count_var] |
||
1024 | jne .ipn_loop |
||
1025 | |||
1026 | |||
1027 | ret |
||
1028 | ;=============================================================== |
||
1029 | |||
1030 | |||
1031 | mov ebx,[triangles_normals_ptr] |
||
1032 | mov ebp,[triangles_ptr] |
||
1033 | @@: |
||
1034 | push ebx |
||
1035 | mov ebx,vectors |
||
1036 | movzx esi,word[ebp] ; first point index |
||
1037 | lea esi,[esi*3] |
||
1038 | ; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
||
1039 | shl esi,2 |
||
1040 | add esi,[points_ptr] |
||
1041 | movzx edi,word[ebp+2] ; first point index |
||
1042 | lea edi,[edi*3] |
||
1043 | shl edi,2 |
||
1044 | add edi,[points_ptr] |
||
1045 | ; movzx edi,word[ebp+2] ; second point index |
||
1046 | ; lea edi,[edi*3] |
||
1047 | ; lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
||
1048 | call make_vector_r |
||
1049 | add ebx,12 |
||
1050 | mov esi,edi |
||
1051 | movzx edi,word[ebp+4] ; third point index |
||
1052 | lea edi,[edi*3] |
||
1053 | shl edi,2 |
||
1054 | add edi,[points_ptr] |
||
1055 | ; lea edi,[points+edi*2] |
||
1056 | call make_vector_r |
||
1057 | mov edi,ebx ; edi - pointer to 2nd vector |
||
1058 | mov esi,ebx |
||
1059 | sub esi,12 ; esi - pointer to 1st vector |
||
1060 | pop ebx |
||
1061 | call cross_product |
||
1062 | mov edi,ebx |
||
1063 | call normalize_vector |
||
1064 | add ebp,6 |
||
1065 | add ebx,12 |
||
1066 | cmp dword[ebp],-1 |
||
1067 | jne @b |
||
1068 | ret |
||
1069 | |||
1070 | |||
1071 | |||
1072 | sort_triangles: |
||
1073 | mov esi,[triangles_ptr] |
||
1074 | mov edi,triangles_with_z |
||
1075 | mov ebp,[points_translated_ptr] |
||
1076 | |||
1077 | |||
1078 | movzx eax,word[esi] |
||
1079 | lea eax,[eax*3] |
||
1080 | movzx ecx,word[ebp+eax*2+4] |
||
1081 | |||
1082 | |||
1083 | lea eax,[eax*3] |
||
1084 | add cx,word[ebp+eax*2+4] |
||
1085 | |||
1086 | |||
1087 | lea eax,[eax*3] |
||
1088 | add cx,word[ebp+eax*2+4] |
||
1089 | |||
1090 | |||
1091 | ; cwd |
||
1092 | ; idiv word[i3] |
||
1093 | movsd ; store vertex coordinates |
||
1094 | movsw |
||
1095 | stosw ; middle vertex coordinate 'z' in triangles_with_z list |
||
1096 | cmp dword[esi],-1 |
||
1097 | jne make_triangle_with_z |
||
1098 | movsd ; copy end mark |
||
1099 | mov eax,4 |
||
1100 | lea edx,[edi-8-trizdd] |
||
1101 | ; lea edx, [edi-8] |
||
1102 | ; sub edx,[triangles_w_z_ptr] |
||
1103 | mov [high],edx |
||
1104 | call quicksort |
||
1105 | mov eax,4 |
||
1106 | mov edx,[high] |
||
1107 | call insertsort |
||
1108 | jmp end_sort |
||
1109 | |||
1110 | |||
1111 | mov ecx,edx |
||
1112 | sub ecx,eax |
||
1113 | cmp ecx,32 |
||
1114 | jc .exit |
||
1115 | lea ecx,[eax+edx] |
||
1116 | shr ecx,4 |
||
1117 | lea ecx,[ecx*8-4]; |
||
1118 | ; mov edi,[triangles_w_z_ptr] |
||
1119 | ; mov ebx,[edi+eax] |
||
1120 | ; mov esi,[edi+ecx] |
||
1121 | ; mov edi,[edi+edx] |
||
1122 | mov ebx,[trizdd+eax]; trizdd[l] |
||
1123 | mov esi,[trizdd+ecx]; trizdd[i] |
||
1124 | mov edi,[trizdd+edx]; trizdd[h] |
||
1125 | cmp ebx,esi |
||
1126 | jg @f ; direction NB! you need to negate these to invert the order |
||
1127 | if Ext=NON |
||
1128 | mov [trizdd+eax],esi |
||
1129 | mov [trizdd+ecx],ebx |
||
1130 | mov ebx,[trizdd+eax-4] |
||
1131 | mov esi,[trizdd+ecx-4] |
||
1132 | mov [trizdd+eax-4],esi |
||
1133 | mov [trizdd+ecx-4],ebx |
||
1134 | mov ebx,[trizdd+eax] |
||
1135 | mov esi,[trizdd+ecx] |
||
1136 | else |
||
1137 | ; push ebx |
||
1138 | ; mov ebx,[triangles_w_z_ptr] |
||
1139 | ; movq mm0,[ebx+eax-4] |
||
1140 | ; movq mm1,[ebx+ecx-4] |
||
1141 | ; movq [ebx+ecx-4],mm0 |
||
1142 | ; movq [ebx+eax-4],mm1 |
||
1143 | ; pop ebx |
||
1144 | movq mm0,[trizdq+eax-4] |
||
1145 | movq mm1,[trizdq+ecx-4] |
||
1146 | movq [trizdq+ecx-4],mm0 |
||
1147 | movq [trizdq+eax-4],mm1 |
||
1148 | xchg ebx,esi |
||
1149 | end if |
||
1150 | @@: |
||
1151 | cmp ebx,edi |
||
1152 | jg @f ; direction |
||
1153 | if Ext=NON |
||
1154 | mov [trizdd+eax],edi |
||
1155 | mov [trizdd+edx],ebx |
||
1156 | mov ebx,[trizdd+eax-4] |
||
1157 | mov edi,[trizdd+edx-4] |
||
1158 | mov [trizdd+eax-4],edi |
||
1159 | mov [trizdd+edx-4],ebx |
||
1160 | mov ebx,[trizdd+eax] |
||
1161 | mov edi,[trizdd+edx] |
||
1162 | else |
||
1163 | ; push ebx |
||
1164 | ; mov ebx,[triangles_w_z_ptr] |
||
1165 | ; movq mm0,[ebx+eax-4] |
||
1166 | ; movq mm1,[ebx+edx-4] |
||
1167 | ; movq [ebx+edx-4],mm0 |
||
1168 | ; movq [ebx+eax-4],mm1 |
||
1169 | movq mm0,[trizdq+eax-4] |
||
1170 | movq mm1,[trizdq+edx-4] |
||
1171 | movq [trizdq+edx-4],mm0 |
||
1172 | movq [trizdq+eax-4],mm1 |
||
1173 | ; pop ebx |
||
1174 | xchg ebx,edi |
||
1175 | end if |
||
1176 | @@: |
||
1177 | cmp esi,edi |
||
1178 | jg @f ; direction |
||
1179 | if Ext=NON |
||
1180 | mov [trizdd+ecx],edi |
||
1181 | mov [trizdd+edx],esi |
||
1182 | mov esi,[trizdd+ecx-4] |
||
1183 | mov edi,[trizdd+edx-4] |
||
1184 | mov [trizdd+ecx-4],edi |
||
1185 | mov [trizdd+edx-4],esi |
||
1186 | else |
||
1187 | ; push ebx |
||
1188 | ; mov ebx,[triangles_w_z_ptr] |
||
1189 | ; movq mm0,[ebx+ecx-4] |
||
1190 | ; movq mm1,[ebx+edx-4] |
||
1191 | ; movq [ebx+edx-4],mm0 |
||
1192 | ; movq [ebx+ecx-4],mm1 |
||
1193 | ; pop ebx |
||
1194 | |||
1195 | |||
1196 | movq mm1,[trizdq+edx-4] |
||
1197 | movq [trizdq+edx-4],mm0 |
||
1198 | movq [trizdq+ecx-4],mm1 |
||
1199 | xchg ebx,esi |
||
1200 | end if |
||
1201 | @@: |
||
1202 | mov ebp,eax ; direction |
||
1203 | add ebp,8 ; j |
||
1204 | if Ext=NON |
||
1205 | mov esi,[trizdd+ebp] |
||
1206 | mov edi,[trizdd+ecx] |
||
1207 | mov [trizdd+ebp],edi |
||
1208 | mov [trizdd+ecx],esi |
||
1209 | mov esi,[trizdd+ebp-4] |
||
1210 | mov edi,[trizdd+ecx-4] |
||
1211 | mov [trizdd+ecx-4],esi |
||
1212 | mov [trizdd+ebp-4],edi |
||
1213 | else |
||
1214 | ; push ebx |
||
1215 | ; mov ebx,[triangles_w_z_ptr] |
||
1216 | ; movq mm0,[ebx+ebp-4] |
||
1217 | ; movq mm1,[ebx+ecx-4] |
||
1218 | ; movq [ebx+ecx-4],mm0 |
||
1219 | ; movq [ebx+ebp-4],mm1 |
||
1220 | ; pop ebx |
||
1221 | |||
1222 | |||
1223 | movq mm1,[trizdq+ecx-4] |
||
1224 | movq [trizdq+ecx-4],mm0 |
||
1225 | movq [trizdq+ebp-4],mm1 |
||
1226 | end if |
||
1227 | mov ecx,edx ; i; direction |
||
1228 | mov ebx,[trizdd+ebp]; trizdd[j] |
||
1229 | ; mov ebx, [triangles_w_z_ptr] |
||
1230 | ; add ebx, ebp |
||
1231 | |||
1232 | |||
1233 | ; mov eax, [triangles_w_z_ptr] |
||
1234 | .loop: |
||
1235 | sub ecx,8 ; direction |
||
1236 | cmp [trizdd+ecx],ebx |
||
1237 | ; cmp [eax+ecx],ebx |
||
1238 | jl .loop ; direction |
||
1239 | @@: |
||
1240 | add ebp,8 ; direction |
||
1241 | cmp [trizdd+ebp],ebx |
||
1242 | ; cmp [eax+ebp],ebx |
||
1243 | jg @b ; direction |
||
1244 | cmp ebp,ecx |
||
1245 | jge @f ; direction |
||
1246 | if Ext=NON |
||
1247 | mov esi,[trizdd+ecx] |
||
1248 | mov edi,[trizdd+ebp] |
||
1249 | mov [trizdd+ebp],esi |
||
1250 | mov [trizdd+ecx],edi |
||
1251 | mov edi,[trizdd+ecx-4] |
||
1252 | mov esi,[trizdd+ebp-4] |
||
1253 | mov [trizdd+ebp-4],edi |
||
1254 | mov [trizdd+ecx-4],esi |
||
1255 | else |
||
1256 | ; movq mm0,[eax+ecx-4] |
||
1257 | ; movq mm1,[eax+ebp-4] |
||
1258 | ; movq [eax+ebp-4],mm0 |
||
1259 | ; movq [eax+ecx-4],mm1 |
||
1260 | movq mm0,[trizdq+ecx-4] |
||
1261 | movq mm1,[trizdq+ebp-4] |
||
1262 | movq [trizdq+ebp-4],mm0 |
||
1263 | movq [trizdq+ecx-4],mm1 |
||
1264 | end if |
||
1265 | jmp .loop |
||
1266 | ; pop eax |
||
1267 | @@: |
||
1268 | if Ext=NON |
||
1269 | mov esi,[trizdd+ecx] |
||
1270 | mov edi,[trizdd+eax+8] |
||
1271 | mov [trizdd+eax+8],esi |
||
1272 | mov [trizdd+ecx],edi |
||
1273 | mov edi,[trizdd+ecx-4] |
||
1274 | mov esi,[trizdd+eax+4] |
||
1275 | mov [trizdd+eax+4],edi |
||
1276 | mov [trizdd+ecx-4],esi |
||
1277 | else |
||
1278 | ; push edx |
||
1279 | ; mov edx,[triangles_w_z_ptr] |
||
1280 | ; movq mm0,[edx+ecx-4] |
||
1281 | ; movq mm1,[edx+eax+4]; dir |
||
1282 | ; movq [edx+eax+4],mm0; dir |
||
1283 | ; movq [edx+ecx-4],mm1 |
||
1284 | ; pop edx |
||
1285 | |||
1286 | |||
1287 | movq mm1,[trizdq+eax+4]; dir |
||
1288 | movq [trizdq+eax+4],mm0; dir |
||
1289 | movq [trizdq+ecx-4],mm1 |
||
1290 | end if |
||
1291 | add ecx,8 |
||
1292 | push ecx edx |
||
1293 | mov edx,ebp |
||
1294 | call quicksort |
||
1295 | pop edx eax |
||
1296 | call quicksort |
||
1297 | .exit: |
||
1298 | ret |
||
1299 | insertsort: |
||
1300 | mov esi,eax |
||
1301 | .start: |
||
1302 | add esi,8 |
||
1303 | cmp esi,edx |
||
1304 | ja .exit |
||
1305 | mov ebx,[trizdd+esi] |
||
1306 | ; mov ebx,[triangles_w_z_ptr] |
||
1307 | ; add ebx,esi |
||
1308 | if Ext=NON |
||
1309 | mov ecx,[trizdd+esi-4] |
||
1310 | else |
||
1311 | ; push ebx |
||
1312 | ; mov ebx,[triangles_w_z_ptr] |
||
1313 | ; movq mm1,[ebx+esi-4] |
||
1314 | movq mm1,[trizdq+esi-4] |
||
1315 | ; pop ebx |
||
1316 | end if |
||
1317 | mov edi,esi |
||
1318 | @@: |
||
1319 | cmp edi,eax |
||
1320 | jna @f |
||
1321 | ; push eax |
||
1322 | ; mov eax,[triangles_w_z_ptr] |
||
1323 | ; cmp [eax+edi-8],ebx |
||
1324 | ; pop eax |
||
1325 | cmp [trizdd+edi-8],ebx |
||
1326 | jg @f ; direction |
||
1327 | if Ext=NON |
||
1328 | mov ebp,[trizdd+edi-8] |
||
1329 | mov [trizdd+edi],ebp |
||
1330 | mov ebp,[trizdd+edi-12] |
||
1331 | mov [trizdd+edi-4],ebp |
||
1332 | else |
||
1333 | ; push eax |
||
1334 | ; mov eax,[triangles_w_z_ptr] |
||
1335 | ; movq mm0,[eax+edi-12] |
||
1336 | ; movq [eax+edi-4],mm0 |
||
1337 | movq mm0,[trizdq+edi-12] |
||
1338 | movq [trizdq+edi-4],mm0 |
||
1339 | ; pop eax |
||
1340 | end if |
||
1341 | sub edi,8 |
||
1342 | jmp @b |
||
1343 | @@: |
||
1344 | if Ext=NON |
||
1345 | mov [trizdd+edi],ebx |
||
1346 | mov [trizdd+edi-4],ecx |
||
1347 | else |
||
1348 | ; push eax |
||
1349 | ; mov eax,[triangles_w_z_ptr] |
||
1350 | ; movq [eax+edi-4],mm1 |
||
1351 | movq [trizdq+edi-4],mm1 |
||
1352 | ; pop eax |
||
1353 | end if |
||
1354 | jmp .start |
||
1355 | .exit: |
||
1356 | ret |
||
1357 | end_sort: |
||
1358 | ; translate triangles_with_z to sorted_triangles |
||
1359 | mov esi,triangles_with_z |
||
1360 | ; mov esi,[triangles_w_z_ptr] |
||
1361 | ; mov edi,sorted_triangles |
||
1362 | mov edi,[triangles_ptr] |
||
1363 | again_copy: |
||
1364 | if Ext=NON |
||
1365 | movsd |
||
1366 | movsw |
||
1367 | add esi,2 |
||
1368 | else |
||
1369 | movq mm0,[esi] |
||
1370 | movq [edi],mm0 |
||
1371 | add esi,8 |
||
1372 | add edi,6 |
||
1373 | end if |
||
1374 | cmp dword[esi],-1 |
||
1375 | jne again_copy |
||
1376 | ; if Ext=MMX |
||
1377 | ; emms |
||
1378 | ; end if |
||
1379 | movsd ; copy end mark too |
||
1380 | ret |
||
1381 | |||
1382 | |||
1383 | mov edi,screen |
||
1384 | mov ecx,SIZE_X*SIZE_Y*3/4 |
||
1385 | xor eax,eax |
||
1386 | if Ext=NON |
||
1387 | rep stosd |
||
1388 | else |
||
1389 | pxor mm0,mm0 |
||
1390 | @@: |
||
1391 | movq [edi+00],mm0 |
||
1392 | movq [edi+08],mm0 |
||
1393 | movq [edi+16],mm0 |
||
1394 | movq [edi+24],mm0 |
||
1395 | add edi,32 |
||
1396 | sub ecx,8 |
||
1397 | jnc @b |
||
1398 | end if |
||
1399 | ret |
||
1400 | |||
1401 | |||
1402 | |||
1403 | mov esi,[triangles_ptr] |
||
1404 | .again_dts: |
||
1405 | mov ebp,[points_translated_ptr] |
||
1406 | if Ext=NON |
||
1407 | movzx eax,word[esi] |
||
1408 | mov [point_index1],ax |
||
1409 | lea eax,[eax*3] |
||
1410 | add eax,eax |
||
1411 | push ebp |
||
1412 | add ebp,eax |
||
1413 | mov eax,[ebp] |
||
1414 | mov dword[xx1],eax |
||
1415 | mov eax,[ebp+4] |
||
1416 | mov [zz1],ax |
||
1417 | pop ebp |
||
1418 | |||
1419 | |||
1420 | |||
1421 | mov [point_index2],ax |
||
1422 | lea eax,[eax*3] |
||
1423 | add eax,eax |
||
1424 | push ebp |
||
1425 | add ebp,eax |
||
1426 | mov eax,[ebp] |
||
1427 | mov dword[xx2],eax |
||
1428 | mov eax,[ebp+4] |
||
1429 | mov [zz2],ax |
||
1430 | pop ebp |
||
1431 | |||
1432 | |||
1433 | |||
1434 | mov [point_index3],ax |
||
1435 | lea eax,[eax*3] |
||
1436 | add eax,eax |
||
1437 | ; push ebp |
||
1438 | add ebp,eax |
||
1439 | mov eax,[ebp] |
||
1440 | mov dword[xx3],eax |
||
1441 | mov eax,[ebp+4] |
||
1442 | mov [zz3],ax |
||
1443 | else |
||
1444 | mov eax,dword[esi] ; don't know MMX |
||
1445 | mov dword[point_index1],eax |
||
1446 | ; shr eax,16 |
||
1447 | ; mov [point_index2],ax |
||
1448 | mov ax,word[esi+4] |
||
1449 | mov [point_index3],ax |
||
1450 | movq mm0,[esi] |
||
1451 | pmullw mm0,qword[const6] |
||
1452 | movd eax,mm0 |
||
1453 | psrlq mm0,16 |
||
1454 | movd ebx,mm0 |
||
1455 | psrlq mm0,16 |
||
1456 | movd ecx,mm0 |
||
1457 | and eax,0FFFFh |
||
1458 | and ebx,0FFFFh |
||
1459 | and ecx,0FFFFh |
||
1460 | movq mm0,[ebp+eax] |
||
1461 | movq mm1,[ebp+ebx] |
||
1462 | movq mm2,[ebp+ecx] |
||
1463 | movq qword[xx1],mm0 |
||
1464 | movq qword[xx2],mm1 |
||
1465 | movq qword[xx3],mm2 |
||
1466 | ; emms |
||
1467 | end if ; ********************************* |
||
1468 | push esi ; |
||
1469 | fninit ; DO culling AT FIRST |
||
1470 | cmp [culling_flag],1 ; (if culling_flag = 1) |
||
1471 | jne .no_culling |
||
1472 | mov esi,point_index1 ; ********************************* |
||
1473 | mov ecx,3 ; |
||
1474 | @@: |
||
1475 | movzx eax,word[esi] |
||
1476 | lea eax,[eax*3] |
||
1477 | shl eax,2 |
||
1478 | add eax,[points_normals_rot_ptr] |
||
1479 | ; lea eax,[eax+point_normals_rotated] |
||
1480 | fld dword[eax+8] ; ***************************** |
||
1481 | ftst ; CHECKING OF Z COOFICIENT OF |
||
1482 | fstsw ax ; NORMAL VECTOR |
||
1483 | sahf |
||
1484 | jb @f |
||
1485 | ffree st |
||
1486 | loop @b |
||
1487 | jmp .end_draw ; non visable |
||
1488 | @@: |
||
1489 | ffree st ;is visable |
||
1490 | .no_culling: |
||
1491 | cmp [dr_flag],0 ; draw type flag |
||
1492 | je .flat_draw |
||
1493 | cmp [dr_flag],2 |
||
1494 | je .env_mapping |
||
1495 | cmp [dr_flag],3 |
||
1496 | je .bump_mapping |
||
1497 | cmp [dr_flag],4 |
||
1498 | je .tex_mapping |
||
1499 | cmp [dr_flag],5 |
||
1500 | je .rainbow |
||
1501 | cmp [dr_flag],7 |
||
1502 | je .grd_tex |
||
1503 | cmp [dr_flag],8 |
||
1504 | je .two_tex |
||
1505 | cmp [dr_flag],9 |
||
1506 | je .bump_tex |
||
1507 | cmp [dr_flag],10 |
||
1508 | je .cubic_env_mapping |
||
1509 | ; **************** |
||
1510 | mov esi,point_index3 ; do Gouraud shading |
||
1511 | mov ecx,3 |
||
1512 | .again_grd_draw: |
||
1513 | movzx eax,word[esi] |
||
1514 | shl eax,2 |
||
1515 | lea eax,[eax*3] |
||
1516 | add eax,[points_normals_rot_ptr] |
||
1517 | ; texture x=(rotated point normal -> x * 255)+255 |
||
1518 | fld dword[eax] ; x cooficient of normal vector |
||
1519 | fimul [correct_tex] |
||
1520 | fiadd [correct_tex] |
||
1521 | fistp word[esp-2] |
||
1522 | ; texture y=(rotated point normal -> y * 255)+255 |
||
1523 | fld dword[eax+4] ; y cooficient |
||
1524 | fimul [correct_tex] |
||
1525 | fiadd [correct_tex] |
||
1526 | fistp word[esp-4] |
||
1527 | |||
1528 | |||
1529 | movzx ebx,word[esp-2] |
||
1530 | shl eax,TEX_SHIFT |
||
1531 | add eax,ebx |
||
1532 | lea eax,[eax*3+color_map] |
||
1533 | mov eax,dword[eax] |
||
1534 | cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
||
1535 | jne @f |
||
1536 | lea edx,[ecx*3] |
||
1537 | push word[edx*2+xx1-2] ; zz1 ,2 ,3 |
||
1538 | @@: |
||
1539 | ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr |
||
1540 | xor ah,ah |
||
1541 | push ax ;r |
||
1542 | rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg |
||
1543 | xor ah,ah |
||
1544 | push ax ;g |
||
1545 | shr eax,24 |
||
1546 | push ax ;b |
||
1547 | |||
1548 | |||
1549 | dec cx |
||
1550 | jnz .again_grd_draw |
||
1551 | jmp .both_draw |
||
1552 | |||
1553 | |||
1554 | ; lea edi,[edi*3] |
||
1555 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1556 | ; mov esi,light_vector |
||
1557 | ; call dot_product |
||
1558 | ; fabs |
||
1559 | ; fimul [orginal_color_r] |
||
1560 | ; fistp [temp_col] |
||
1561 | ; and [temp_col],0x00ff |
||
1562 | ; push [temp_col] |
||
1563 | ; push [temp_col] |
||
1564 | ; push [temp_col] |
||
1565 | |||
1566 | |||
1567 | ; lea edi,[edi*3] |
||
1568 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1569 | ; mov esi,light_vector |
||
1570 | ; call dot_product |
||
1571 | ; fabs |
||
1572 | ; fimul [orginal_color_r] |
||
1573 | ; fistp [temp_col] |
||
1574 | ; and [temp_col],0x00ff |
||
1575 | ; push [temp_col] |
||
1576 | ; push [temp_col] |
||
1577 | ; push [temp_col] |
||
1578 | |||
1579 | |||
1580 | ; lea edi,[edi*3] |
||
1581 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1582 | ; mov esi,light_vector |
||
1583 | ; call dot_product |
||
1584 | ; fabs |
||
1585 | ; fimul [orginal_color_r] |
||
1586 | ; fistp [temp_col] |
||
1587 | ; and [temp_col],0x00ff |
||
1588 | ; push [temp_col] |
||
1589 | ; push [temp_col] |
||
1590 | ; push [temp_col] |
||
1591 | .rainbow: |
||
1592 | cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
||
1593 | jne @f |
||
1594 | push [zz3] |
||
1595 | @@: |
||
1596 | mov eax,dword[yy3] |
||
1597 | mov ebx,0x00ff00ff |
||
1598 | and eax,ebx |
||
1599 | push eax |
||
1600 | neg al |
||
1601 | push ax |
||
1602 | cmp [catmull_flag],1 |
||
1603 | jne @f |
||
1604 | push [zz2] |
||
1605 | @@: |
||
1606 | mov eax,dword[yy2] |
||
1607 | and eax,ebx |
||
1608 | push eax |
||
1609 | neg al |
||
1610 | push ax |
||
1611 | cmp [catmull_flag],1 |
||
1612 | jne @f |
||
1613 | push [zz1] |
||
1614 | @@: |
||
1615 | mov eax,dword[yy1] |
||
1616 | and eax,ebx |
||
1617 | push eax |
||
1618 | neg al |
||
1619 | push ax |
||
1620 | .both_draw: |
||
1621 | mov eax,dword[xx1] |
||
1622 | ror eax,16 |
||
1623 | mov ebx,dword[xx2] |
||
1624 | ror ebx,16 |
||
1625 | mov ecx,dword[xx3] |
||
1626 | ror ecx,16 |
||
1627 | lea edi,[screen] |
||
1628 | cmp [catmull_flag],0 |
||
1629 | je @f |
||
1630 | ; lea esi,[Z_buffer] |
||
1631 | mov esi,[Zbuffer_ptr] |
||
1632 | call gouraud_triangle_z |
||
1633 | jmp .end_draw |
||
1634 | @@: |
||
1635 | call gouraud_triangle |
||
1636 | jmp .end_draw |
||
1637 | |||
1638 | |||
1639 | ; FLAT DRAWING |
||
1640 | movzx eax,[point_index1] |
||
1641 | movzx ebx,[point_index2] |
||
1642 | movzx ecx,[point_index3] |
||
1643 | shl eax,2 |
||
1644 | shl ebx,2 |
||
1645 | shl ecx,2 |
||
1646 | lea eax,[eax*3] ;+point_normals_rotated] |
||
1647 | add eax,[points_normals_rot_ptr] |
||
1648 | lea ebx,[ebx*3] ;+point_normals_rotated] |
||
1649 | add ebx,[points_normals_rot_ptr] |
||
1650 | lea ecx,[ecx*3] ;+point_normals_rotated] |
||
1651 | add ecx,[points_normals_rot_ptr] |
||
1652 | fld dword[eax] ; x cooficient of normal vector |
||
1653 | fadd dword[ebx] |
||
1654 | fadd dword[ecx] |
||
1655 | fidiv [i3] |
||
1656 | fimul [correct_tex] |
||
1657 | fiadd [correct_tex] |
||
1658 | fistp dword[esp-4] ; x temp variables |
||
1659 | fld dword[eax+4] ; y cooficient of normal vector |
||
1660 | fadd dword[ebx+4] |
||
1661 | fadd dword[ecx+4] |
||
1662 | fidiv [i3] |
||
1663 | fimul [correct_tex] |
||
1664 | fiadd [correct_tex] |
||
1665 | fistp dword[esp-8] ; y |
||
1666 | mov edx,dword[esp-8] |
||
1667 | shl edx,TEX_SHIFT |
||
1668 | add edx,dword[esp-4] |
||
1669 | lea eax,[3*edx+color_map] |
||
1670 | mov edx,dword[eax] |
||
1671 | |||
1672 | |||
1673 | |||
1674 | |||
1675 | |||
1676 | |||
1677 | ; add ax,[zz2] |
||
1678 | ; add ax,[zz3] |
||
1679 | ; cwd |
||
1680 | ; idiv [i3] ; = -((a+b+c)/3+130) |
||
1681 | ; add ax,130 |
||
1682 | ; neg al |
||
1683 | ; xor edx,edx |
||
1684 | ; mov ah,al ;set color according to z position |
||
1685 | ; shl eax,8 |
||
1686 | ; mov edx,eax |
||
1687 | |||
1688 | |||
1689 | ror eax,16 |
||
1690 | mov ebx,dword[xx2] |
||
1691 | ror ebx,16 |
||
1692 | mov ecx,dword[xx3] |
||
1693 | ror ecx,16 |
||
1694 | ; mov edi,screen |
||
1695 | lea edi,[screen] |
||
1696 | cmp [catmull_flag],0 |
||
1697 | je @f |
||
1698 | ; lea esi,[Z_buffer] |
||
1699 | mov esi,[Zbuffer_ptr] |
||
1700 | push word[zz3] |
||
1701 | push word[zz2] |
||
1702 | push word[zz1] |
||
1703 | call flat_triangle_z |
||
1704 | jmp .end_draw |
||
1705 | @@: |
||
1706 | call draw_triangle |
||
1707 | jmp .end_draw |
||
1708 | .env_mapping: |
||
1709 | ; fninit |
||
1710 | cmp [catmull_flag],0 |
||
1711 | je @f |
||
1712 | push [zz3] |
||
1713 | push [zz2] |
||
1714 | push [zz1] |
||
1715 | @@: |
||
1716 | mov esi,point_index1 |
||
1717 | sub esp,12 |
||
1718 | mov edi,esp |
||
1719 | mov ecx,3 |
||
1720 | @@: |
||
1721 | movzx eax,word[esi] |
||
1722 | lea eax,[eax*3] |
||
1723 | shl eax,2 |
||
1724 | add eax,[points_normals_rot_ptr] ;point_normals_rotated |
||
1725 | ; # |
||
1726 | ; fld dword[eax] |
||
1727 | ; fmul dword[eax+4] |
||
1728 | ; fld1 |
||
1729 | ; fld1 |
||
1730 | ; faddp |
||
1731 | ; fmulp |
||
1732 | ; fimul [correct_tex] |
||
1733 | ; fiadd [correct_tex] |
||
1734 | ; fistp word[edi] |
||
1735 | ; mov word[edi+2],0 |
||
1736 | ;; fistp word[edi+2] |
||
1737 | ; # last change |
||
1738 | ; texture x=(rotated point normal -> x * 255)+255 |
||
1739 | fld dword[eax] |
||
1740 | fimul [correct_tex] |
||
1741 | fiadd [correct_tex] |
||
1742 | fistp word[edi] |
||
1743 | ; texture y=(rotated point normal -> y * 255)+255 |
||
1744 | fld dword[eax+4] |
||
1745 | fimul [correct_tex] |
||
1746 | fiadd [correct_tex] |
||
1747 | fistp word[edi+2] |
||
1748 | ; # end of last ch. |
||
1749 | add edi,4 |
||
1750 | add esi,2 |
||
1751 | loop @b |
||
1752 | |||
1753 | |||
1754 | ror eax,16 |
||
1755 | mov ebx,dword[xx2] |
||
1756 | ror ebx,16 |
||
1757 | mov ecx,dword[xx3] |
||
1758 | ror ecx,16 |
||
1759 | mov edi,screen |
||
1760 | mov esi,envmap |
||
1761 | cmp [catmull_flag],0 |
||
1762 | je @f |
||
1763 | ; mov edx,Z_buffer |
||
1764 | mov edx,[Zbuffer_ptr] |
||
1765 | call tex_triangle_z |
||
1766 | jmp .end_draw |
||
1767 | @@: |
||
1768 | call tex_triangle |
||
1769 | jmp .end_draw |
||
1770 | ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
1771 | .cubic_env_mapping: |
||
1772 | ; fninit |
||
1773 | cmp [catmull_flag],0 |
||
1774 | je @f |
||
1775 | push [zz3] |
||
1776 | push [zz2] |
||
1777 | push [zz1] |
||
1778 | @@: |
||
1779 | mov esi,point_index1 |
||
1780 | sub esp,12 |
||
1781 | mov edi,esp |
||
1782 | mov ecx,3 |
||
1783 | @@: |
||
1784 | movzx eax,word[esi] |
||
1785 | lea eax,[eax*3] |
||
1786 | shl eax,2 |
||
1787 | add eax,[points_normals_rot_ptr] ;point_normals_rotated |
||
1788 | ; # |
||
1789 | fld dword[eax] |
||
1790 | fmul dword[eax+4] |
||
1791 | fld1 |
||
1792 | fld1 |
||
1793 | faddp |
||
1794 | fmulp |
||
1795 | fimul [correct_tex] |
||
1796 | fiadd [correct_tex] |
||
1797 | fistp word[edi] |
||
1798 | mov word[edi+2],0 |
||
1799 | ; fistp word[edi+2] |
||
1800 | ; # last change |
||
1801 | ; ; texture x=(rotated point normal -> x * 255)+255 |
||
1802 | ; fld dword[eax] |
||
1803 | ; fimul [correct_tex] |
||
1804 | ; fiadd [correct_tex] |
||
1805 | ; fistp word[edi] |
||
1806 | ; ; texture y=(rotated point normal -> y * 255)+255 |
||
1807 | ; fld dword[eax+4] |
||
1808 | ; fimul [correct_tex] |
||
1809 | ; fiadd [correct_tex] |
||
1810 | ; fistp word[edi+2] |
||
1811 | ; # end of last ch. |
||
1812 | add edi,4 |
||
1813 | add esi,2 |
||
1814 | loop @b |
||
1815 | |||
1816 | |||
1817 | ror eax,16 |
||
1818 | mov ebx,dword[xx2] |
||
1819 | ror ebx,16 |
||
1820 | mov ecx,dword[xx3] |
||
1821 | ror ecx,16 |
||
1822 | mov edi,screen |
||
1823 | mov esi,envmap_cub |
||
1824 | cmp [catmull_flag],0 |
||
1825 | je @f |
||
1826 | ; mov edx,Z_buffer |
||
1827 | mov edx,[Zbuffer_ptr] |
||
1828 | call tex_triangle_z |
||
1829 | jmp .end_draw |
||
1830 | @@: |
||
1831 | call tex_triangle |
||
1832 | jmp .end_draw |
||
1833 | |||
1834 | |||
1835 | |||
1836 | |||
1837 | ; fninit |
||
1838 | cmp [catmull_flag],0 |
||
1839 | je @f |
||
1840 | ; push Z_buffer |
||
1841 | push [Zbuffer_ptr] |
||
1842 | push [zz3] |
||
1843 | push [zz2] |
||
1844 | push [zz1] |
||
1845 | @@: |
||
1846 | mov esi,point_index1 |
||
1847 | sub esp,12 |
||
1848 | mov edi,esp |
||
1849 | mov ecx,3 |
||
1850 | @@: |
||
1851 | movzx eax,word[esi] |
||
1852 | lea eax,[eax*3] |
||
1853 | shl eax,2 |
||
1854 | add eax,[points_normals_rot_ptr] ;point_normals_rotated |
||
1855 | ; texture x=(rotated point normal -> x * 255)+255 |
||
1856 | fld dword[eax] |
||
1857 | fimul [correct_tex] |
||
1858 | fiadd [correct_tex] |
||
1859 | fistp word[edi] |
||
1860 | ; texture y=(rotated point normal -> y * 255)+255 |
||
1861 | fld dword[eax+4] |
||
1862 | fimul [correct_tex] |
||
1863 | fiadd [correct_tex] |
||
1864 | fistp word[edi+2] |
||
1865 | |||
1866 | |||
1867 | add esi,2 |
||
1868 | loop @b |
||
1869 | |||
1870 | |||
1871 | shl esi,2 |
||
1872 | add esi,tex_points |
||
1873 | push dword[esi] |
||
1874 | movzx esi,[point_index2] |
||
1875 | shl esi,2 |
||
1876 | add esi,tex_points |
||
1877 | ; lea esi,[esi*3] |
||
1878 | ; lea esi,[points+2+esi*2] |
||
1879 | push dword[esi] |
||
1880 | ; push dword[xx2] |
||
1881 | movzx esi,[point_index1] |
||
1882 | shl esi,2 |
||
1883 | add esi,tex_points |
||
1884 | ; lea esi,[esi*3] |
||
1885 | ; lea esi,[points+2+esi*2] |
||
1886 | push dword[esi] |
||
1887 | ; push dword[xx1] |
||
1888 | |||
1889 | |||
1890 | ror eax,16 |
||
1891 | mov ebx,dword[xx2] |
||
1892 | ror ebx,16 |
||
1893 | mov ecx,dword[xx3] |
||
1894 | ror ecx,16 |
||
1895 | mov edi,screen |
||
1896 | mov esi,envmap |
||
1897 | mov edx,bumpmap ;BUMP_MAPPING |
||
1898 | |||
1899 | |||
1900 | je @f |
||
1901 | call bump_triangle_z |
||
1902 | jmp .end_draw |
||
1903 | @@: |
||
1904 | call bump_triangle |
||
1905 | jmp .end_draw |
||
1906 | |||
1907 | |||
1908 | |||
1909 | |||
1910 | cmp [catmull_flag],0 |
||
1911 | je @f |
||
1912 | push [zz3] |
||
1913 | push [zz2] |
||
1914 | push [zz1] |
||
1915 | @@: |
||
1916 | movzx esi,[point_index3] ; tex map coords |
||
1917 | shl esi,2 |
||
1918 | add esi,tex_points |
||
1919 | push dword[esi] |
||
1920 | movzx esi,[point_index2] |
||
1921 | shl esi,2 |
||
1922 | add esi,tex_points |
||
1923 | push dword[esi] |
||
1924 | movzx esi,[point_index1] |
||
1925 | shl esi,2 |
||
1926 | add esi,tex_points |
||
1927 | push dword[esi] |
||
1928 | |||
1929 | |||
1930 | ror eax,16 |
||
1931 | mov ebx,dword[xx2] |
||
1932 | ror ebx,16 |
||
1933 | mov ecx,dword[xx3] |
||
1934 | ror ecx,16 |
||
1935 | mov edi,screen |
||
1936 | mov esi,texmap |
||
1937 | cmp [catmull_flag],0 |
||
1938 | je @f |
||
1939 | ; mov edx,Z_buffer |
||
1940 | mov edx,[Zbuffer_ptr] |
||
1941 | call tex_triangle_z |
||
1942 | ; call tex_plus_grd_trianlgle |
||
1943 | jmp .end_draw |
||
1944 | @@: |
||
1945 | call tex_triangle |
||
1946 | jmp .end_draw |
||
1947 | ; .ray: |
||
1948 | ; grd_triangle according to points index |
||
1949 | ; cmp [catmull_flag],0 |
||
1950 | ; je @f |
||
1951 | ; push [zz3] ; spot light with attenuation |
||
1952 | ; @@: |
||
1953 | ; movzx eax,[point_index3] ; env_map - points color list |
||
1954 | ; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
||
1955 | ; lea eax,[3*eax+bumpmap] |
||
1956 | ; push word[eax] |
||
1957 | ; push word[eax+2] |
||
1958 | ; push word[eax+4] |
||
1959 | ; cmp [catmull_flag],0 |
||
1960 | ; je @f |
||
1961 | ; push [zz2] |
||
1962 | ; @@: |
||
1963 | ; movzx eax,[point_index2] ; env_map - points color list |
||
1964 | ; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
||
1965 | ; lea eax,[eax*3+bumpmap] |
||
1966 | ; push word[eax] |
||
1967 | ; push word[eax+2] |
||
1968 | ; push word[eax+4] |
||
1969 | ; cmp [catmull_flag],0 |
||
1970 | ; je @f |
||
1971 | ; push [zz1] |
||
1972 | ; @@: |
||
1973 | ; movzx eax,[point_index1] ; env_map - points color list |
||
1974 | ; shl eax,1 ; each color as word, 0xrr00gg00bb00.. |
||
1975 | ; lea eax,[eax*3+bumpmap] |
||
1976 | ; push word[eax] |
||
1977 | ; push word[eax+2] |
||
1978 | ; push word[eax+4] |
||
1979 | ; jmp .both_draw |
||
1980 | |||
1981 | |||
1982 | push ebp |
||
1983 | mov ebp,esp |
||
1984 | sub esp,4 |
||
1985 | push ebp |
||
1986 | |||
1987 | |||
1988 | shl esi,2 |
||
1989 | add esi,tex_points |
||
1990 | push dword[esi] ; texture coords as first |
||
1991 | movzx esi,[point_index2] ; group of parameters |
||
1992 | shl esi,2 |
||
1993 | add esi,tex_points |
||
1994 | push dword[esi] |
||
1995 | movzx esi,[point_index1] |
||
1996 | shl esi,2 |
||
1997 | add esi,tex_points |
||
1998 | push dword[esi] |
||
1999 | |||
2000 | |||
2001 | mov ecx,3 |
||
2002 | |||
2003 | |||
2004 | |||
2005 | |||
2006 | push word[edx*2+xx1-2] ; zz1 ,2 ,3 |
||
2007 | |||
2008 | |||
2009 | shl eax,2 |
||
2010 | lea eax,[eax*3] ;+point_normals_rotated] |
||
2011 | add eax,[points_normals_rot_ptr] |
||
2012 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2013 | fld dword[eax] ; x cooficient of normal vector |
||
2014 | fimul [correct_tex] |
||
2015 | fiadd [correct_tex] |
||
2016 | fistp word[ebp-2] |
||
2017 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2018 | fld dword[eax+4] ; y cooficient |
||
2019 | fimul [correct_tex] |
||
2020 | fiadd [correct_tex] |
||
2021 | fistp word[ebp-4] |
||
2022 | |||
2023 | |||
2024 | movzx ebx,word[ebp-2] |
||
2025 | shl eax,TEX_SHIFT |
||
2026 | add eax,ebx |
||
2027 | lea eax,[eax*3+color_map] |
||
2028 | mov eax,dword[eax] |
||
2029 | |||
2030 | |||
2031 | xor ah,ah |
||
2032 | push ax ;r |
||
2033 | rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg |
||
2034 | xor ah,ah |
||
2035 | push ax ;g |
||
2036 | shr eax,24 |
||
2037 | push ax ;b |
||
2038 | |||
2039 | |||
2040 | dec cx |
||
2041 | jnz .aagain_grd_draw |
||
2042 | |||
2043 | |||
2044 | ror eax,16 |
||
2045 | mov ebx,dword[xx2] |
||
2046 | ror ebx,16 |
||
2047 | mov ecx,dword[xx3] |
||
2048 | ror ecx,16 |
||
2049 | mov edi,screen |
||
2050 | mov edx,texmap |
||
2051 | mov esi,[Zbuffer_ptr] |
||
2052 | |||
2053 | |||
2054 | |||
2055 | |||
2056 | mov esp,ebp |
||
2057 | pop ebp |
||
2058 | jmp .end_draw |
||
2059 | |||
2060 | |||
2061 | push [Zbuffer_ptr] |
||
2062 | |||
2063 | |||
2064 | push word[zz2] |
||
2065 | push word[zz1] |
||
2066 | |||
2067 | |||
2068 | shl esi,2 |
||
2069 | add esi,tex_points |
||
2070 | push dword[esi] |
||
2071 | movzx esi,[point_index2] |
||
2072 | shl esi,2 |
||
2073 | add esi,tex_points |
||
2074 | push dword[esi] |
||
2075 | movzx esi,[point_index1] |
||
2076 | shl esi,2 |
||
2077 | add esi,tex_points |
||
2078 | push dword[esi] |
||
2079 | |||
2080 | |||
2081 | sub esp,12 |
||
2082 | mov edi,esp |
||
2083 | mov ecx,3 |
||
2084 | @@: |
||
2085 | movzx eax,word[esi] |
||
2086 | lea eax,[eax*3] |
||
2087 | shl eax,2 |
||
2088 | add eax,[points_normals_rot_ptr] |
||
2089 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2090 | fld dword[eax] |
||
2091 | fimul [correct_tex] |
||
2092 | fiadd [correct_tex] |
||
2093 | fistp word[edi] |
||
2094 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2095 | fld dword[eax+4] |
||
2096 | fimul [correct_tex] |
||
2097 | fiadd [correct_tex] |
||
2098 | fistp word[edi+2] |
||
2099 | |||
2100 | |||
2101 | add esi,2 |
||
2102 | loop @b |
||
2103 | |||
2104 | |||
2105 | ror eax,16 |
||
2106 | mov ebx,dword[xx2] |
||
2107 | ror ebx,16 |
||
2108 | mov ecx,dword[xx3] |
||
2109 | ror ecx,16 |
||
2110 | mov edi,screen |
||
2111 | mov esi,texmap |
||
2112 | mov edx,envmap |
||
2113 | |||
2114 | |||
2115 | jmp .end_draw |
||
2116 | |||
2117 | |||
2118 | movzx esi,[point_index3] ; tex map coords |
||
2119 | shl esi,2 |
||
2120 | add esi,tex_points |
||
2121 | push dword[esi] |
||
2122 | movzx esi,[point_index2] |
||
2123 | shl esi,2 |
||
2124 | add esi,tex_points |
||
2125 | push dword[esi] |
||
2126 | movzx esi,[point_index1] |
||
2127 | shl esi,2 |
||
2128 | add esi,tex_points |
||
2129 | push dword[esi] |
||
2130 | |||
2131 | |||
2132 | |||
2133 | |||
2134 | xor edi,edi |
||
2135 | |||
2136 | |||
2137 | push word[zz2] |
||
2138 | push word[zz1] |
||
2139 | |||
2140 | |||
2141 | sub esp,12 |
||
2142 | mov edi,esp |
||
2143 | mov ecx,3 |
||
2144 | @@: |
||
2145 | movzx eax,word[esi] |
||
2146 | lea eax,[eax*3] |
||
2147 | shl eax,2 |
||
2148 | add eax,[points_normals_rot_ptr] |
||
2149 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2150 | fld dword[eax] |
||
2151 | fimul [correct_tex] |
||
2152 | fiadd [correct_tex] |
||
2153 | fistp word[edi] |
||
2154 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2155 | fld dword[eax+4] |
||
2156 | fimul [correct_tex] |
||
2157 | fiadd [correct_tex] |
||
2158 | fistp word[edi+2] |
||
2159 | |||
2160 | |||
2161 | add esi,2 |
||
2162 | loop @b |
||
2163 | |||
2164 | |||
2165 | ; push dword 127 shl 16 + 1 |
||
2166 | ; push dword 127 shl 16 + 127 |
||
2167 | |||
2168 | |||
2169 | shl esi,2 |
||
2170 | add esi,tex_points |
||
2171 | push dword[esi] |
||
2172 | movzx esi,[point_index2] |
||
2173 | shl esi,2 |
||
2174 | add esi,tex_points |
||
2175 | push dword[esi] |
||
2176 | |||
2177 | |||
2178 | shl esi,2 |
||
2179 | add esi,tex_points |
||
2180 | push dword[esi] |
||
2181 | |||
2182 | |||
2183 | ; push dword 127 shl 16 + 127 |
||
2184 | ; push dword 1 shl 16 + 1 ; bump coords |
||
2185 | |||
2186 | |||
2187 | ror eax,16 |
||
2188 | mov ebx,dword[xx2] |
||
2189 | ror ebx,16 |
||
2190 | mov ecx,dword[xx3] |
||
2191 | ror ecx,16 |
||
2192 | mov edi,screen |
||
2193 | mov esi,envmap |
||
2194 | mov edx,bumpmap |
||
2195 | |||
2196 | |||
2197 | |||
2198 | |||
2199 | pop esi |
||
2200 | add esi,6 |
||
2201 | cmp dword[esi],-1 |
||
2202 | jne .again_dts |
||
2203 | ret |
||
2204 | |||
2205 | |||
2206 | |||
2207 | mov eax,0x70000000 |
||
2208 | ; mov edi,Z_buffer |
||
2209 | mov edi,[Zbuffer_ptr] |
||
2210 | mov ecx,SIZE_X*SIZE_Y |
||
2211 | rep stosd |
||
2212 | ret |
||
2213 | |||
2214 | |||
2215 | fninit |
||
2216 | mov edi,[triangles_ptr] |
||
2217 | xor ebx,ebx |
||
2218 | xor ebp,ebp |
||
2219 | mov [points_count_var],0 |
||
2220 | mov [triangles_count_var],0 |
||
2221 | if USE_LFN = 0 |
||
2222 | mov esi,SourceFile |
||
2223 | else |
||
2224 | mov esi,[fptr] |
||
2225 | end if |
||
2226 | cmp [esi],word 4D4Dh |
||
2227 | jne .exit ;Must be legal .3DS file |
||
2228 | ; cmp dword[esi+2],EndFile-SourceFile |
||
2229 | ; jne .exit ;This must tell the length |
||
2230 | mov eax,dword[esi+2] |
||
2231 | ; cmp eax,[fsize] |
||
2232 | ; jne .exit |
||
2233 | |||
2234 | |||
2235 | mov [EndFile],eax ; |
||
2236 | |||
2237 | |||
2238 | @@: |
||
2239 | cmp [esi],word 3D3Dh |
||
2240 | je @f |
||
2241 | add esi,[esi+2] |
||
2242 | jmp @b |
||
2243 | @@: |
||
2244 | add esi,6 |
||
2245 | .find4k: |
||
2246 | cmp [esi],word 4000h |
||
2247 | je @f |
||
2248 | add esi,[esi+2] |
||
2249 | cmp esi,[EndFile] |
||
2250 | jc .find4k |
||
2251 | jmp .exit |
||
2252 | @@: |
||
2253 | add esi,6 |
||
2254 | @@: |
||
2255 | cmp [esi],byte 0 |
||
2256 | je @f |
||
2257 | inc esi |
||
2258 | jmp @b |
||
2259 | @@: |
||
2260 | inc esi |
||
2261 | @@: |
||
2262 | cmp [esi],word 4100h |
||
2263 | je @f |
||
2264 | add esi,[esi+2] |
||
2265 | jmp @b |
||
2266 | @@: |
||
2267 | add esi,6 |
||
2268 | @@: |
||
2269 | cmp [esi],word 4110h |
||
2270 | je @f |
||
2271 | add esi,[esi+2] |
||
2272 | jmp @b |
||
2273 | @@: |
||
2274 | movzx ecx,word[esi+6] |
||
2275 | add [points_count_var],cx |
||
2276 | |||
2277 | |||
2278 | add esi,8 |
||
2279 | @@: |
||
2280 | push edi |
||
2281 | mov edi,[points_ptr] |
||
2282 | push dword[esi+4] |
||
2283 | pop dword[edi+ebx*2+0] |
||
2284 | push dword[esi+8] |
||
2285 | pop dword[edi+ebx*2+4] |
||
2286 | push dword[esi+0] |
||
2287 | pop dword[edi+ebx*2+8] |
||
2288 | pop edi |
||
2289 | ; fld dword[esi+4] |
||
2290 | ; fstp dword[real_points+ebx*2+0] ; x |
||
2291 | ; fld dword[esi+8] |
||
2292 | ; fstp dword[real_points+ebx*2+4] ; y |
||
2293 | ; fld dword[esi+0] |
||
2294 | ; fstp dword[real_points+ebx*2+8] ; z |
||
2295 | |||
2296 | |||
2297 | add esi,12 |
||
2298 | dec ecx |
||
2299 | jnz @b |
||
2300 | @@: |
||
2301 | ; mov dword[points+ebx],-1 |
||
2302 | push edi |
||
2303 | mov edi,[points_ptr] |
||
2304 | mov dword[edi+ebx*2],-1 ; end mark (not always in use) |
||
2305 | pop edi |
||
2306 | @@: |
||
2307 | cmp [esi],word 4120h |
||
2308 | je @f |
||
2309 | add esi,[esi+2] |
||
2310 | jmp @b |
||
2311 | @@: |
||
2312 | movzx ecx,word[esi+6] |
||
2313 | add [triangles_count_var],cx |
||
2314 | add esi,8 |
||
2315 | ;mov edi,triangles |
||
2316 | @@: |
||
2317 | movsd |
||
2318 | movsw |
||
2319 | add word[edi-6],bp |
||
2320 | add word[edi-4],bp |
||
2321 | add word[edi-2],bp |
||
2322 | add esi,2 |
||
2323 | dec ecx |
||
2324 | jnz @b |
||
2325 | add ebp,edx |
||
2326 | jmp .find4k |
||
2327 | mov eax,-1 ;<---mark if OK |
||
2328 | .exit: |
||
2329 | mov dword[edi],-1 |
||
2330 | ret |
||
2331 | |||
2332 | |||
2333 | ; and allocate memory |
||
2334 | xor ebx,ebx |
||
2335 | xor ebp,ebp |
||
2336 | mov [points_count_var],bx |
||
2337 | mov [triangles_count_var],bx |
||
2338 | if USE_LFN = 0 |
||
2339 | mov esi,SourceFile |
||
2340 | else |
||
2341 | mov esi,[fptr] |
||
2342 | end if |
||
2343 | |||
2344 | |||
2345 | je @f ;Must be legal .3DS file |
||
2346 | xor eax,eax |
||
2347 | ret |
||
2348 | @@: |
||
2349 | mov eax,dword[esi+2] |
||
2350 | cmp eax,[fsize] ;This must tell the length |
||
2351 | je @f |
||
2352 | xor eax,eax |
||
2353 | ret |
||
2354 | @@: |
||
2355 | add eax,esi |
||
2356 | mov [EndFile],eax ; |
||
2357 | |||
2358 | |||
2359 | @@: |
||
2360 | cmp [esi],word 3D3Dh |
||
2361 | je @f |
||
2362 | add esi,[esi+2] |
||
2363 | jmp @b |
||
2364 | @@: |
||
2365 | add esi,6 |
||
2366 | .find4k: |
||
2367 | cmp [esi],word 4000h |
||
2368 | je @f |
||
2369 | add esi,[esi+2] |
||
2370 | cmp esi,[EndFile] |
||
2371 | jc .find4k |
||
2372 | jmp .exit |
||
2373 | @@: |
||
2374 | add esi,6 |
||
2375 | @@: |
||
2376 | cmp [esi],byte 0 |
||
2377 | je @f |
||
2378 | inc esi |
||
2379 | jmp @b |
||
2380 | @@: |
||
2381 | inc esi |
||
2382 | @@: |
||
2383 | cmp [esi],word 4100h |
||
2384 | je @f |
||
2385 | add esi,[esi+2] |
||
2386 | jmp @b |
||
2387 | @@: |
||
2388 | add esi,6 |
||
2389 | @@: |
||
2390 | cmp [esi],word 4110h |
||
2391 | je @f |
||
2392 | add esi,[esi+2] |
||
2393 | jmp @b |
||
2394 | @@: |
||
2395 | movzx ecx,word[esi+6] |
||
2396 | add [points_count_var],cx |
||
2397 | |||
2398 | |||
2399 | add esi,8 |
||
2400 | @@: |
||
2401 | |||
2402 | |||
2403 | add esi,12 |
||
2404 | ; dec ecx |
||
2405 | loop @b |
||
2406 | @@: |
||
2407 | |||
2408 | |||
2409 | cmp [esi],word 4120h |
||
2410 | je @f |
||
2411 | add esi,[esi+2] |
||
2412 | jmp @b |
||
2413 | @@: |
||
2414 | movzx ecx,word[esi+6] |
||
2415 | add [triangles_count_var],cx |
||
2416 | add esi,8 |
||
2417 | |||
2418 | |||
2419 | add esi,8 |
||
2420 | dec ecx |
||
2421 | jnz @b |
||
2422 | ; xor ecx,ecx |
||
2423 | add ebp,edx |
||
2424 | jmp .find4k |
||
2425 | mov eax,-1 ;<---mark if OK |
||
2426 | .exit: |
||
2427 | ret |
||
2428 | |||
2429 | |||
2430 | alloc_mem_for_tp: |
||
2431 | mov eax, 68 |
||
2432 | cmp [re_alloc_flag],1 |
||
1776 | yogev_ezra | 2433 | jz @f |
2434 | mov ebx, 12 |
||
1245 | hidnplayr | 2435 | jmp .alloc |
1776 | yogev_ezra | 2436 | @@: |
2437 | mov ebx,20 |
||
2438 | .alloc: |
||
2439 | movzx ecx, [triangles_count_var] |
||
1245 | hidnplayr | 2440 | inc ecx |
2441 | lea ecx, [ecx*3] |
||
2442 | add ecx, ecx |
||
2443 | mov edx,[triangles_ptr] |
||
1776 | yogev_ezra | 2444 | int 0x40 ; -> allocate memory to triangles |
1245 | hidnplayr | 2445 | mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
2446 | |||
2447 | |||
2448 | ; mov ebx, 12 |
||
2449 | ; movzx ecx, [triangles_count_var] |
||
2450 | ; shl ecx, 4 |
||
2451 | ; int 0x40 |
||
2452 | ; mov [triangles_w_z_ptr], eax ; for trainagles_with_z list |
||
2453 | ; ststic memory |
||
2454 | |||
2455 | |||
2456 | movzx ecx, [triangles_count_var] |
||
2457 | lea ecx, [3+ecx*3] |
||
2458 | shl ecx, 2 |
||
2459 | mov edx,[triangles_normals_ptr] |
||
1776 | yogev_ezra | 2460 | int 0x40 ; -> allocate memory for triangles normals |
1245 | hidnplayr | 2461 | mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem |
2462 | |||
2463 | |||
2464 | movzx ecx, [points_count_var] |
||
2465 | lea ecx,[3+ecx*3] |
||
2466 | shl ecx, 2 |
||
2467 | mov edx,[points_normals_ptr] |
||
1776 | yogev_ezra | 2468 | int 0x40 |
1245 | hidnplayr | 2469 | mov [points_normals_ptr], eax |
2470 | |||
2471 | |||
2472 | ; mov ebx, 12 |
||
1776 | yogev_ezra | 2473 | movzx ecx, [points_count_var] |
1245 | hidnplayr | 2474 | lea ecx,[3+ecx*3] |
2475 | shl ecx, 2 |
||
2476 | mov edx,[points_normals_rot_ptr] |
||
1776 | yogev_ezra | 2477 | int 0x40 |
1245 | hidnplayr | 2478 | mov [points_normals_rot_ptr], eax |
2479 | |||
2480 | |||
2481 | mov edx,[points_ptr] |
||
1776 | yogev_ezra | 2482 | int 0x40 |
1245 | hidnplayr | 2483 | mov [points_ptr], eax |
2484 | |||
2485 | |||
2486 | mov edx,[points_rotated_ptr] |
||
1776 | yogev_ezra | 2487 | int 0x40 |
1245 | hidnplayr | 2488 | mov [points_rotated_ptr], eax |
2489 | |||
2490 | |||
2491 | movzx ecx, [points_count_var] |
||
2492 | inc ecx |
||
2493 | shl ecx, 3 |
||
2494 | mov edx,[points_translated_ptr] |
||
1776 | yogev_ezra | 2495 | int 0x40 |
1245 | hidnplayr | 2496 | mov [points_translated_ptr], eax |
2497 | ret |
||
2498 | end if |
||
2499 | |||
2500 | |||
2501 | |||
2502 | if USE_LFN |
||
2503 | ;- |
||
2504 | mov eax, 70 |
||
2505 | mov ebx, file_info |
||
2506 | mov dword[ebx], 5 ; -> subfunction number |
||
2507 | int 0x40 ; -> read file size |
||
2508 | mov ebx, [fptr] |
||
2509 | mov ebx, dword[ebx+32] |
||
2510 | inc ebx |
||
2511 | mov [fsize], ebx |
||
2512 | |||
2513 | |||
2514 | mov ebx, 11 |
||
2515 | int 0x40 ; -> create heap |
||
2516 | |||
2517 | |||
2518 | mov ebx, 12 |
||
2519 | mov ecx, [fsize] |
||
2520 | int 0x40 ; -> allocate memory for file |
||
2521 | mov [fptr], eax ; -> eax = pointer to allocated mem |
||
2522 | |||
2523 | |||
2524 | mov ebx, file_info |
||
2525 | mov dword[ebx],0 |
||
2526 | int 0x40 ; -> read file |
||
2527 | |||
2528 | |||
2529 | |||
2530 | |||
2531 | jnz @f |
||
2532 | xor eax,eax ;;;;--- |
||
2533 | @@: |
||
2534 | else |
||
2535 | mov eax,58 |
||
2536 | mov ebx,file_info |
||
2537 | int 0x40 |
||
2538 | |||
2539 | |||
2540 | shr eax,9 |
||
2541 | inc eax |
||
2542 | mov [fsize],eax |
||
2543 | ; mov ecx,ebx |
||
2544 | ; add ecx,MEM_END |
||
2545 | ; mov ebx,1 |
||
2546 | ; mov eax,64 ; allocate mem - resize app mem |
||
2547 | ; for points and triangles |
||
2548 | int 0x40 |
||
2549 | |||
2550 | |||
2551 | mov ebx,file_info |
||
2552 | int 0x40 |
||
2553 | end if |
||
2554 | ; eax = 0 -> ok file loaded |
||
2555 | ret |
||
2556 | read_param: |
||
2557 | mov esi,I_Param |
||
2558 | cmp dword[esi],0 |
||
2559 | je .end |
||
2560 | cmp byte[esi],'/' |
||
2561 | je .copy |
||
2562 | mov edi,esi |
||
2563 | mov ecx,25 ; 25 - would be enought |
||
2564 | repe scasb |
||
2565 | jne .end |
||
2566 | dec edi |
||
2567 | mov esi,edi |
||
2568 | .copy: |
||
2569 | mov edi,file_name |
||
2570 | mov ecx,50 |
||
2571 | rep movsd |
||
2572 | .end: |
||
2573 | ret |
||
2574 | buttons: ; draw some buttons (all but navigation and close ) |
||
2575 | mov edi,menu |
||
2576 | .again: |
||
2577 | mov eax,8 ; function 8 : define and draw button |
||
2578 | mov ebx,(SIZE_X+10)*65536+62 ; [x start] *65536 + [x size] |
||
2579 | movzx ecx,byte[edi] ; button id = position+2 |
||
2580 | sub cl,2 |
||
2581 | lea ecx,[ecx*5] |
||
2582 | lea ecx,[ecx*3] |
||
2583 | add ecx,25 |
||
2584 | shl ecx,16 |
||
2585 | add ecx,12 |
||
2586 | movzx edx,byte[edi] ; button id |
||
2587 | mov esi,0x6688dd ; button color RRGGBB |
||
2588 | int 0x40 |
||
2589 | ; BUTTON LABEL |
||
2590 | mov eax,4 ; function 4 : write text to window |
||
2591 | movzx ebx,byte[edi] |
||
2592 | sub bl,2 ; button id, according to position |
||
2593 | lea ebx,[ebx*3] |
||
2594 | lea ebx,[ebx*5] |
||
2595 | add ebx,(SIZE_X+12)*65536+28 ; [x start] *65536 + [y start] |
||
2596 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2597 | lea edx,[edi+1] ; pointer to text beginning |
||
2598 | mov esi,10 ; text length |
||
2599 | int 0x40 |
||
2600 | cmp byte[edi+11],255 ; if max_flag=255 |
||
2601 | je @f ; skip |
||
2602 | ; flag description |
||
2603 | ; mov eax,4 ; function 4 : write text to window |
||
2604 | ; movzx ebx,byte[edi] |
||
2605 | ; sub bl,2 |
||
2606 | ; lea ebx,[ebx*3] |
||
2607 | ; lea ebx,[ebx*5] |
||
2608 | ; add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
||
2609 | add ebx,70*65536 |
||
2610 | ; mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2611 | movzx edx,byte[edi+12] ; current flag |
||
2612 | shl edx,2 ; * 4 = text length |
||
2613 | add edx,dword[edi+13] ; pointer to text beginning |
||
2614 | mov esi,4 ; text length |
||
2615 | int 0x40 |
||
2616 | |||
2617 | |||
2618 | add edi,17 |
||
2619 | cmp byte[edi],-1 |
||
2620 | jnz .again |
||
2621 | ret |
||
2622 | ; ********************************************* |
||
2623 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
2624 | ; ********************************************* |
||
2625 | draw_window: |
||
2626 | mov eax,12 ; function 12:tell os about windowdraw |
||
2627 | mov ebx,1 ; 1, start of draw |
||
2628 | int 0x40 |
||
2629 | |||
2630 | |||
2631 | mov eax,0 ; function 0 : define and draw window |
||
2632 | mov ebx,100*65536;+SIZE_X;+80+30 ; [x start] *65536 + [x size] |
||
2633 | mov ecx,100*65536;+SIZE_Y;+30 ; [y start] *65536 + [y size] |
||
2634 | mov bx,[size_x] |
||
2635 | add bx,110 |
||
2636 | mov cx,[size_y] |
||
2637 | add cx,30 |
||
2638 | mov edx,0x14000000 ; color of work area RRGGBB,8->color gl |
||
1776 | yogev_ezra | 2639 | mov esi,0x805080d0 ; color of grab bar RRGGBB,8->color gl |
1245 | hidnplayr | 2640 | mov edi,0x005080d0 ; color of frames RRGGBB |
2641 | int 0x40 |
||
2642 | |||
2643 | |||
2644 | mov eax,4 ; function 4 : write text to window |
||
2645 | mov ebx,8*65536+8 ; [x start] *65536 + [y start] |
||
2646 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2647 | mov edx,labelt ; pointer to text beginning |
||
2648 | mov esi,labellen-labelt ; text length |
||
2649 | int 0x40 |
||
2650 | |||
2651 | |||
2652 | ; mov eax,8 ; function 8 : define and draw button |
||
1776 | yogev_ezra | 2653 | ; movzx ebx,[size_x] |
2654 | ; shl ebx,16 |
||
2655 | ; add ebx, 91 shl 16 + 12 |
||
2656 | ;; mov ebx,(SIZE_X+80+30-19)*65536+12 ; [x start] *65536 + [x size] |
||
2657 | ; mov ecx,5*65536+12 ; [y start] *65536 + [y size] |
||
2658 | ; mov edx,1 ; button id |
||
2659 | ; mov esi,0x6688dd ; button color RRGGBB |
||
2660 | ; int 0x40 |
||
2661 | |||
1245 | hidnplayr | 2662 | |
2663 | |||
2664 | |||
2665 | |||
2666 | |||
2667 | mov eax,4 ; function 4 : write text to window |
||
2668 | mov ebx,(SIZE_X+12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2669 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2670 | mov edx,labelvector ; pointer to text beginning |
||
2671 | mov esi,labelvectorend-labelvector ; text length |
||
2672 | ; cmp [move_flag],2 |
||
2673 | ; jne @f |
||
2674 | ; add edx,navigation_size |
||
2675 | ; @@: |
||
2676 | int 0x40 |
||
2677 | ; VECTOR Y- BUTTON |
||
2678 | mov eax,8 ; function 8 : define and draw button |
||
2679 | mov ebx,(SIZE_X+30)*65536+20 ; [x start] *65536 + [x size] |
||
2680 | mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
2681 | mov edx,30 ; button id |
||
2682 | mov esi,0x6688dd ; button color RRGGBB |
||
2683 | int 0x40 |
||
2684 | ;VECTOR Y- LABEL |
||
2685 | mov eax,4 ; function 4 : write text to window |
||
2686 | mov ebx,(SIZE_X+32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2687 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2688 | mov edx,labelyminus ; pointer to text beginning |
||
2689 | mov esi,labelyminusend-labelyminus ; text length |
||
2690 | cmp [move_flag],2 |
||
2691 | ; jne @f |
||
2692 | ; add edx,navigation_size |
||
2693 | ; @@: |
||
2694 | int 0x40 |
||
2695 | ; VECTOR Z+ BUTTON |
||
2696 | mov eax,8 ; function 8 : define and draw button |
||
2697 | mov ebx,(SIZE_X+51)*65536+21 ; [x start] *65536 + [x size] |
||
2698 | mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
2699 | mov edx,31 ; button id |
||
2700 | mov esi,0x6688dd ; button color RRGGBB |
||
2701 | int 0x40 |
||
2702 | ;VECTOR Z+ LABEL |
||
2703 | mov eax,4 ; function 4 : write text to window |
||
2704 | mov ebx,(SIZE_X+53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2705 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2706 | mov edx,labelzplus ; pointer to text beginning |
||
2707 | mov esi,labelzplusend-labelzplus ; text length |
||
2708 | ; cmp [move_flag],2 |
||
2709 | ; jne @f |
||
2710 | ; add edx,navigation_size |
||
2711 | ; @@: |
||
2712 | |||
2713 | |||
2714 | ; VECTOR x- BUTTON |
||
2715 | mov eax,8 ; function 8 : define and draw button |
||
2716 | mov ebx,(SIZE_X+10)*65536+21 ; [x start] *65536 + [x size] |
||
2717 | mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
2718 | mov edx,32 ; button id |
||
2719 | mov esi,0x6688dd ; button color RRGGBB |
||
2720 | int 0x40 |
||
2721 | ;VECTOR x- LABEL |
||
2722 | mov eax,4 ; function 4 : write text to window |
||
2723 | mov ebx,(SIZE_X+12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2724 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2725 | mov edx,labelxminus ; pointer to text beginning |
||
2726 | mov esi,labelxminusend-labelxminus ; text length |
||
2727 | ; cmp [move_flag],2 |
||
2728 | ; jne @f |
||
2729 | ; add edx,navigation_size |
||
2730 | ; @@: |
||
2731 | int 0x40 |
||
2732 | ; VECTOR x+ BUTTON |
||
2733 | mov eax,8 ; function 8 : define and draw button |
||
2734 | mov ebx,(SIZE_X+51)*65536+21 ; [x start] *65536 + [x size] |
||
2735 | mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
2736 | mov edx,33 ; button id |
||
2737 | mov esi,0x6688dd ; button color RRGGBB |
||
2738 | int 0x40 |
||
2739 | ;VECTOR x+ LABEL |
||
2740 | mov eax,4 ; function 4 : write text to window |
||
2741 | mov ebx,(SIZE_X+53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2742 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2743 | mov edx,labelxplus ; pointer to text beginning |
||
2744 | mov esi,labelxplusend-labelxplus ; text length |
||
2745 | ; cmp [move_flag],2 |
||
2746 | ; jne @f |
||
2747 | ; add edx,navigation_size |
||
2748 | ; @@: |
||
2749 | int 0x40 |
||
2750 | ; VECTOR z- BUTTON |
||
2751 | mov eax,8 ; function 8 : define and draw button |
||
2752 | mov ebx,(SIZE_X+10)*65536+62-41 ; [x start] *65536 + [x size] |
||
2753 | mov ecx,(25+140+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
2754 | mov edx,34 ; button id |
||
2755 | mov esi,0x6688dd ; button color RRGGBB |
||
2756 | int 0x40 |
||
2757 | ;VECTOR z- LABEL |
||
2758 | mov eax,4 ; function 4 : write text to window |
||
2759 | mov ebx,(SIZE_X+12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2760 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2761 | mov edx,labelzminus ; pointer to text beginning |
||
2762 | mov esi,labelzminusend-labelzminus ; text length |
||
2763 | ; cmp [move_flag],2 |
||
2764 | ; jne @f |
||
2765 | ; add edx,navigation_size |
||
2766 | ; @@: |
||
2767 | int 0x40 |
||
2768 | ;VECTOR Y+ BUTTON |
||
2769 | mov eax,8 ; function 8 : define and draw button |
||
2770 | mov ebx,(SIZE_X+10+20)*65536+20 ; [x start] *65536 + [x size] |
||
2771 | mov ecx,(165+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
2772 | mov edx,35 ; button id |
||
2773 | mov esi,0x6688dd ; button color RRGGBB |
||
2774 | int 0x40 |
||
2775 | ;VECTOR Y+ LABEL |
||
2776 | mov eax,4 ; function 4 : write text to window |
||
2777 | mov ebx,(SIZE_X+32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
||
2778 | mov ecx,0x20ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
2779 | mov edx,labelyplus ; pointer to text beginning |
||
2780 | mov esi,labelyplusend-labelyplus ; text length |
||
2781 | ; cmp [move_flag],2 |
||
2782 | ; jne @f |
||
2783 | ; add edx,navigation_size |
||
2784 | ; @@: |
||
2785 | int 0x40 |
||
2786 | |||
2787 | |||
2788 | mov ebx,2 ; 2, end of draw |
||
2789 | int 0x40 |
||
2790 | ret |
||
2791 | |||
2792 | |||
2793 | |||
2794 | |||
2795 | |||
2796 | |||
2797 | |||
2798 |