Rev 8666 | Rev 9237 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8719 | leency | 1 | |
2 | ; with a few graphics effects demonstration. |
||
3 | ; compiler : FASM |
||
4 | ; system : KolibriOS |
||
5 | ; author : Macgub aka Maciej Guba |
||
6 | ; email : macgub3@wp.pl |
||
7 | ; web : http://macgub.co.pl, http://macgub.j.pl |
||
8 | ; Fell free to use this intro in your own distribution of KolibriOS. |
||
9 | ; Special greetings to KolibriOS team . |
||
10 | ; I hope because my demos Christian Belive will be near to each of You. |
||
11 | |||
12 | |||
13 | |||
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) ; now not exist |
||
19 | |||
20 | |||
21 | |||
22 | SIZE_Y equ 512 ; ///// I want definitely |
||
23 | TIMEOUT equ 10 ; ------ say: |
||
24 | ROUND equ 10 ; \ @ @/ keep smiling every |
||
25 | TEX_X equ 512 ; texture width ; \ ./ / day. |
||
26 | TEX_Y equ 512 ; height ; \/ / |
||
27 | TEX_SHIFT equ 9 ; texture width shifting ; __||__ / |
||
28 | TEXTURE_SIZE EQU (TEX_X * TEX_Y)-1 ; /| | |
||
29 | TEX equ SHIFTING ; TEX={SHIFTING | FLUENTLY} ; / \ / |
||
30 | FLUENTLY = 0 ; / | | |
||
31 | SHIFTING = 1 ; ------ |
||
32 | CATMULL_SHIFT equ 8 ; | | |
||
33 | LIGHT_SIZE equ 22 ; | | |
||
34 | NON = 0 ; -/ \- |
||
35 | MMX = 1 |
||
36 | SSE = 2 |
||
37 | SSE2 = 3 |
||
38 | SSE3 = 4 |
||
39 | Ext = SSE3 ;Ext={ NON | MMX | SSE | SSE2 | SSE3 } |
||
40 | |||
41 | |||
42 | USE_LFN = 1 ; App is Kolibri only now. |
||
43 | |||
44 | |||
45 | org 0x0 |
||
46 | db 'MENUET01' ; 8 byte id |
||
47 | dd 0x01 ; header version |
||
48 | dd START ; start of code |
||
49 | dd I_END ; size of image |
||
50 | dd MEM_END ; memory for app |
||
51 | dd MEM_END ; esp |
||
52 | dd I_Param ; I_Param |
||
53 | dd 0x0 ; I_Icon |
||
54 | |||
55 | |||
56 | cld |
||
57 | push dword (SIZE_Y shr 3) * 3 |
||
58 | fninit |
||
59 | fild dword[esp] |
||
60 | fstp [rsscale] |
||
61 | pop ebx |
||
62 | |||
63 | |||
64 | call read_param |
||
65 | call read_from_disk ; read, if all is ok eax = 0 |
||
66 | cmp eax,0 |
||
67 | jne .gen |
||
68 | mov esi,[fptr] |
||
69 | cmp [esi],word 4D4Dh |
||
70 | jne .asc |
||
71 | call read_tp_variables ; init points and triangles count variables |
||
72 | cmp eax,0 |
||
73 | je .gen |
||
74 | jmp .malloc |
||
75 | .gen: |
||
76 | call generate_object |
||
77 | jmp .opt |
||
78 | .asc: |
||
79 | mov [triangles_count_var],10000 ; to do: read asc header |
||
80 | mov [points_count_var],10000 |
||
81 | call alloc_mem_for_tp |
||
82 | call read_asc |
||
83 | jmp .opt |
||
84 | .malloc: |
||
85 | call alloc_mem_for_tp |
||
86 | call read_from_file |
||
87 | .opt: |
||
88 | call optimize_object1 ; proc in file b_procs.asm |
||
89 | ; set point(0,0,0) in center and calc all coords |
||
90 | ; to be in <-1.0,1.0> |
||
91 | call normalize_all_light_vectors |
||
92 | if Ext >= SSE3 |
||
93 | call copy_lights ; to aligned float |
||
94 | end if |
||
95 | call init_triangles_normals2 |
||
96 | call init_point_normals |
||
97 | call init_envmap2 |
||
98 | call init_envmap_cub |
||
99 | call generate_texture2 |
||
100 | call init_sincos_tab |
||
101 | call do_color_buffer ; intit color_map |
||
102 | mov edi,bumpmap |
||
103 | call calc_bumpmap |
||
104 | call calc_bumpmap_coords ; bump and texture mapping |
||
105 | call do_edges_list |
||
106 | call draw_window |
||
107 | ;mov [draw_win_at_first],0 |
||
108 | ;mov eax,40 ; set events mask |
||
109 | ;mov ebx,1100000000000000000000000100111b |
||
110 | ;int 0x40 |
||
111 | |||
112 | |||
113 | |||
114 | cmp [edit_flag],1 |
||
115 | jne @f |
||
116 | mov eax,40 ; set events mask |
||
117 | mov ebx,1100000000000000000000000100111b |
||
118 | jmp .int |
||
119 | @@: |
||
120 | mov eax,40 ; set events mask |
||
121 | mov ebx,111b |
||
122 | .int: |
||
123 | int 0x40 |
||
124 | |||
125 | |||
126 | mov ebx,TIMEOUT |
||
127 | cmp [speed_flag],0 |
||
128 | je .skip |
||
129 | mov eax,11 |
||
130 | .skip: |
||
131 | cmp [edit_flag],1 |
||
132 | jne @f |
||
133 | mov eax,10 |
||
134 | |||
135 | |||
136 | int 0x40 |
||
137 | |||
138 | |||
139 | je red |
||
140 | cmp eax,2 ; key event ? |
||
141 | je key |
||
142 | cmp eax,3 ; button event ? |
||
143 | je button |
||
144 | cmp eax,6 ; mouse event ? |
||
145 | jne @f |
||
146 | cmp [edit_flag],1 ; handle mouse only when edit is active |
||
147 | jne @f |
||
148 | |||
149 | |||
150 | mov ebx,7 ; get mouse scroll |
||
151 | int 0x40 |
||
152 | and eax, 0xFFFF ; check only vertial |
||
153 | cmp eax, 65535 |
||
154 | je button.zoom_in |
||
155 | cmp eax, 1 |
||
156 | je button.zoom_out |
||
157 | |||
158 | |||
159 | mov ebx,3 ;read mouse state |
||
160 | int 0x40 |
||
161 | mov [mouse_state],eax |
||
162 | call edit |
||
163 | @@: |
||
164 | jmp noclose |
||
165 | |||
166 | |||
167 | mov eax,9 ; get process info |
||
168 | mov ebx,procinfo |
||
169 | mov ecx,-1 |
||
170 | int 0x40 |
||
171 | mov eax,[procinfo+42] ; read params of window |
||
172 | sub eax,225 |
||
173 | mov [size_x_var],ax |
||
174 | shr ax,1 |
||
175 | mov [vect_x],ax |
||
176 | ; |
||
177 | mov eax,[procinfo+46] |
||
178 | sub eax,30 |
||
179 | mov [size_y_var],ax |
||
180 | shr ax,1 |
||
181 | mov [vect_y],ax |
||
182 | |||
183 | |||
184 | mov [x_start],ax |
||
185 | mov eax,[procinfo+38] |
||
186 | mov [y_start],ax |
||
187 | call alloc_buffer_mem ;realloc mem for scr & z buffs |
||
188 | call draw_window |
||
189 | |||
190 | |||
191 | |||
192 | |||
193 | mov eax,2 ; just read it and ignore |
||
194 | int 0x40 |
||
195 | |||
196 | |||
197 | je button.zoom_in |
||
198 | cmp ah, '=' |
||
199 | je button.zoom_in |
||
200 | cmp ah, '-' |
||
201 | je button.zoom_out |
||
202 | cmp ah, 176 ;left |
||
203 | je add_vec_buttons.x_minus |
||
204 | cmp ah, 179 ;right |
||
205 | je add_vec_buttons.x_plus |
||
206 | cmp ah, 178 ;up |
||
207 | je add_vec_buttons.y_minus |
||
208 | cmp ah, 177 ;down |
||
209 | je add_vec_buttons.y_plus |
||
210 | |||
211 | |||
212 | |||
213 | |||
214 | mov eax,17 ; get id |
||
215 | int 0x40 |
||
216 | |||
217 | |||
218 | jne @f |
||
219 | |||
220 | |||
221 | int 0x40 |
||
222 | @@: |
||
223 | cmp ah,30 |
||
224 | jge add_vec_buttons |
||
225 | call update_flags ; update flags and write labels of flags |
||
226 | |||
227 | |||
228 | cmp ah,3 ; ah = 3 -> shading model |
||
229 | jne .next_m6 |
||
230 | cmp [dr_flag],2 |
||
231 | jne @f |
||
232 | ; call init_envmap2 ; <----! this don't works in env mode |
||
233 | ; and more than ~18 kb objects |
||
234 | ; call init_envmap_cub2 |
||
235 | @@: |
||
236 | cmp [dr_flag],4 |
||
237 | jne @f |
||
238 | call generate_texture2 |
||
239 | |||
240 | |||
241 | .next_m6: |
||
242 | ; ah = 5 -> scale- |
||
243 | cmp ah,5 |
||
244 | jne @f |
||
245 | .zoom_out: |
||
246 | mov dword[scale],0.7 |
||
247 | fninit |
||
248 | fld [rsscale] |
||
249 | fmul [scale] |
||
250 | fstp [rsscale] |
||
251 | @@: |
||
252 | cmp ah,6 ; ah = 6 -> scale+ |
||
253 | jne @f |
||
254 | .zoom_in: |
||
255 | mov dword[scale],1.3 |
||
256 | fninit |
||
257 | fld [rsscale] |
||
258 | fmul [scale] |
||
259 | fstp [rsscale] |
||
260 | @@: |
||
261 | cmp ah,9 ; lights random ; 'flat' 0 |
||
262 | jne .next_m5 ; 'grd ' 1 |
||
263 | call make_random_lights ; 'env ' 2 |
||
264 | call normalize_all_light_vectors ; 'bump' 3 |
||
265 | if Ext >= SSE3 |
||
266 | call copy_lights |
||
267 | end if |
||
268 | call do_color_buffer ; intit color_map ; 'tex ' 4 |
||
269 | |||
270 | |||
271 | .next_m5: |
||
272 | cmp ah,11 |
||
273 | je @f |
||
274 | cmp ah,12 |
||
275 | je @f |
||
276 | cmp ah,13 |
||
277 | jne .next_m4 |
||
278 | @@: |
||
279 | call mirror |
||
280 | .next_m4: |
||
281 | cmp ah,14 |
||
282 | jne @f |
||
283 | call exchange |
||
284 | @@: |
||
285 | cmp ah,15 |
||
286 | jne @f |
||
287 | cmp [emboss_flag],1 |
||
288 | ; call init_envmap2 |
||
289 | call do_emboss |
||
290 | @@: |
||
291 | ; cmp ah,17 |
||
292 | ; jne .next_m |
||
293 | ; cmp [move_flag],2 |
||
294 | ; jne @f |
||
295 | ; call draw_window ; redraw other labels to navigation buttons |
||
296 | ; @@: |
||
297 | ; cmp [move_flag],0 |
||
298 | ; jne .next_m |
||
299 | ; call draw_window ; redraw other labels to navigation buttons |
||
300 | .next_m: |
||
301 | cmp ah,18 |
||
302 | jne .next_m2 |
||
303 | |||
304 | |||
305 | mov [triangles_count_var],20000 |
||
306 | mov [points_count_var],20000 |
||
307 | call alloc_mem_for_tp |
||
308 | mov [re_alloc_flag],0 |
||
309 | |||
310 | |||
311 | ; or bl,bl |
||
312 | ; jz .next_m2 |
||
313 | cmp bl,1 |
||
314 | jne @f |
||
315 | call generate_object |
||
316 | jmp .calc_norm |
||
317 | @@: |
||
318 | cmp bl,4 |
||
319 | jg @f |
||
320 | movzx eax,bl ; eax < - object number |
||
321 | call generate_object2 |
||
322 | jmp .calc_norm |
||
323 | @@: |
||
324 | call generate_object3 |
||
325 | .calc_norm: |
||
326 | call optimize_object1 |
||
327 | call init_triangles_normals2 |
||
328 | call init_point_normals |
||
329 | call calc_bumpmap_coords ; bump and texture mapping |
||
330 | call do_edges_list |
||
331 | call write_info |
||
332 | .next_m2: |
||
333 | cmp ah,19 |
||
334 | je @f |
||
335 | cmp ah,20 |
||
336 | jne .next_m3 |
||
337 | @@: |
||
338 | mov edi,bumpmap |
||
339 | call calc_bumpmap |
||
340 | .next_m3: |
||
341 | cmp ah,21 ; re map bumps, texture coordinates |
||
342 | jne @f |
||
343 | call calc_bumpmap_coords |
||
344 | @@: |
||
345 | jmp noclose |
||
346 | |||
347 | |||
348 | |||
349 | add_vec_buttons: ; can move: object, camera,.. list is open |
||
350 | ; |
||
351 | cmp ah,30 |
||
352 | jne .next |
||
353 | cmp [move_flag],0 |
||
354 | jne @f |
||
355 | ; cmp [move_flag],2 |
||
356 | ; je .set_light1 |
||
357 | .y_minus: |
||
358 | sub [vect_y],10 |
||
359 | jmp .next |
||
360 | @@: |
||
361 | cmp [move_flag],1 |
||
362 | jne @f |
||
363 | sub [yobs],10 ; observator = camera position |
||
364 | jmp .next |
||
365 | @@: |
||
366 | sub [sin_amplitude],10 |
||
367 | ;-------------------------------------------------- |
||
368 | ; .set_light1: ; r - |
||
369 | ; movzx ebx,[light_no_flag] ; * 22 |
||
370 | ; mov ecx,ebx |
||
371 | ; shl ebx,4 |
||
372 | ; shl ecx,1 |
||
373 | ; add ebx,ecx |
||
374 | ; shl ecx,1 |
||
375 | ; add ebx,ecx |
||
376 | ; add ebx,lights+6 ; 6 -> light vector size |
||
377 | ; |
||
378 | ; movzx ecx,[light_comp_flag] |
||
379 | ; lea ecx,[ecx*3} |
||
380 | ; add ebx,ecx ; ebx -> color to set |
||
381 | |||
382 | |||
383 | .next: |
||
384 | cmp ah,31 |
||
385 | jne .next1 |
||
386 | cmp [move_flag],1 |
||
387 | je @f |
||
388 | add [vect_z],10 |
||
389 | jmp .next1 |
||
390 | @@: |
||
391 | add [zobs],10 ; observator = camera position |
||
392 | .next1: |
||
393 | cmp ah,33 |
||
394 | jne .next2 |
||
395 | cmp [move_flag],0 |
||
396 | jne @f |
||
397 | .x_minus: |
||
398 | sub [vect_x],10 |
||
399 | jmp .next2 |
||
400 | @@: |
||
401 | cmp [move_flag],1 |
||
402 | jne @f |
||
403 | sub [xobs],10 ; observator = camera position |
||
404 | jmp .next2 |
||
405 | @@: |
||
406 | fninit |
||
407 | fld [sin_frq] |
||
408 | fsub [sin_delta] |
||
409 | fstp [sin_frq] |
||
410 | .next2: |
||
411 | cmp ah,32 |
||
412 | jne .next3 |
||
413 | cmp [move_flag],0 |
||
414 | jne @f |
||
415 | .x_plus: |
||
416 | add [vect_x],10 |
||
417 | jmp .next3 |
||
418 | @@: |
||
419 | cmp [move_flag],1 |
||
420 | jne @f |
||
421 | add [xobs],10 ; observator = camera position |
||
422 | jmp .next3 |
||
423 | @@: |
||
424 | fninit |
||
425 | fld [sin_frq] ; change wave effect frequency |
||
426 | fadd [sin_delta] |
||
427 | fstp [sin_frq] |
||
428 | .next3: |
||
429 | cmp ah,34 |
||
430 | jne .next4 |
||
431 | cmp [move_flag],1 |
||
432 | je @f |
||
433 | |||
434 | |||
435 | jmp .next4 |
||
436 | @@: |
||
437 | sub [zobs],10 ; observator = camera position |
||
438 | .next4: |
||
439 | cmp ah,35 |
||
440 | jne .next5 |
||
441 | cmp [move_flag],0 |
||
442 | jne @f |
||
443 | ; call add_vector |
||
444 | .y_plus: |
||
445 | add [vect_y],10 |
||
446 | jmp .next5 |
||
447 | @@: |
||
448 | cmp [move_flag],1 |
||
449 | jne @f |
||
450 | add [yobs],10 ; observator = camera position |
||
451 | jmp .next5 |
||
452 | @@: |
||
453 | add [sin_amplitude],10 |
||
454 | .next5: |
||
455 | |||
456 | |||
457 | |||
458 | |||
459 | |||
460 | |||
461 | jz .end_rot |
||
462 | cmp [r_flag],2 |
||
463 | jne .no_x |
||
464 | inc [angle_x] |
||
465 | and [angle_x],0xff |
||
466 | mov [angle_z],0 |
||
467 | jmp .end_rot |
||
468 | |||
469 | |||
470 | cmp [r_flag],0 |
||
471 | jne .no_y |
||
472 | inc [angle_y] |
||
473 | and [angle_y],0xff |
||
474 | mov [angle_z],0 |
||
475 | jmp .end_rot |
||
476 | |||
477 | |||
478 | cmp [r_flag],1 |
||
479 | jne .end_rot |
||
480 | mov cx,[angle_x] |
||
481 | inc cx |
||
482 | and cx,0xff |
||
483 | mov [angle_z],0 |
||
484 | mov [angle_y],cx |
||
485 | mov [angle_x],cx |
||
486 | .end_rot: |
||
487 | |||
488 | |||
489 | mov edi,matrix |
||
490 | call make_rotation_matrix |
||
491 | RDTSC |
||
492 | push eax |
||
493 | mov esi,[points_normals_ptr] |
||
494 | mov edi,[points_normals_rot_ptr] |
||
495 | mov ebx,matrix |
||
496 | mov ecx,[points_count_var] |
||
497 | call rotary |
||
498 | |||
499 | |||
500 | call add_scale_to_matrix |
||
501 | |||
502 | |||
503 | mov edi,[points_rotated_ptr] |
||
504 | mov ebx,matrix |
||
505 | mov ecx,[points_count_var] |
||
506 | call rotary |
||
507 | |||
508 | |||
509 | |||
510 | mov edi,[points_translated_ptr] |
||
511 | mov ecx,[points_count_var] |
||
512 | call translate_points |
||
513 | |||
514 | |||
515 | jne @f |
||
516 | call clrscr ; clear the screen |
||
517 | @@: |
||
518 | ; cmp [catmull_flag],1 ;non sort if Catmull = on |
||
519 | ; je .no_sort |
||
520 | ; 64 indexes call sort_triangles |
||
521 | .no_sort: |
||
522 | cmp [dr_flag],7 ; fill if 2tex and texgrd |
||
523 | jge @f |
||
524 | cmp [catmull_flag],0 ;non fill if Catmull = off |
||
525 | je .non_f |
||
526 | cmp [dr_flag],6 ; non fill if dots |
||
527 | je .non_f |
||
528 | @@: |
||
529 | call fill_Z_buffer ; make background |
||
530 | .non_f: |
||
531 | cmp [dr_flag],6 |
||
532 | jne @f |
||
533 | call draw_dots |
||
534 | jmp .blurrr |
||
535 | @@: |
||
536 | call draw_triangles ; draw all triangles from the list |
||
537 | cmp [edit_flag],0 |
||
538 | jz .no_edit |
||
539 | call clear_vertices_index |
||
540 | call draw_handlers |
||
541 | ; call edit |
||
542 | |||
543 | |||
544 | |||
545 | |||
546 | |||
547 | |||
548 | |||
549 | |||
550 | |||
551 | cmp [sinus_flag],0 |
||
552 | je @f |
||
553 | call do_sinus |
||
554 | @@: |
||
555 | cmp [fire_flag],0 |
||
556 | jne @f |
||
557 | cmp [blur_flag],0 |
||
558 | je .no_blur ; no blur, no fire |
||
559 | movzx ecx,[blur_flag] |
||
560 | call blur_screen ; blur and fire |
||
561 | jmp .no_blur |
||
562 | @@: |
||
563 | cmp [emboss_flag],0 |
||
564 | jne .emb ; if emboss=true -> no fire |
||
565 | movzx ecx,[fire_flag] |
||
566 | call blur_screen ; blur and fire |
||
567 | .no_blur: ; no blur, no fire |
||
568 | cmp [emboss_flag],0 |
||
569 | je @f |
||
570 | .emb: |
||
571 | call do_emboss |
||
572 | |||
573 | |||
574 | |||
575 | |||
576 | |||
577 | je .no_inc_bright |
||
578 | movzx ebx,[inc_bright_flag] |
||
579 | shl ebx,4 |
||
580 | mov esi,[screen_ptr] |
||
581 | movzx ecx,word[size_y_var] |
||
582 | movzx eax,word[size_x_var] |
||
583 | mul ecx |
||
584 | lea ecx,[eax*4] |
||
585 | |||
586 | |||
587 | mov bh,bl |
||
588 | push bx |
||
589 | shl ebx,16 |
||
590 | pop bx |
||
591 | push ebx |
||
592 | push ebx |
||
593 | movq mm0,[esp] |
||
594 | add esp,8 |
||
595 | else if Ext >= SSE2 |
||
596 | mov bh,bl |
||
597 | push bx |
||
598 | shl ebx,16 |
||
599 | pop bx |
||
600 | movd xmm0,ebx |
||
601 | shufps xmm0,xmm0,0 |
||
602 | end if |
||
603 | .oop: |
||
604 | if Ext=NON |
||
605 | lodsb |
||
606 | add al,bl |
||
607 | jnc @f |
||
608 | mov byte[esi-1],255 |
||
609 | loop .oop |
||
610 | @@: |
||
611 | mov [esi-1],al |
||
612 | loop .oop |
||
613 | else if (Ext=MMX)|(Ext=SSE) |
||
614 | movq mm1,[esi] |
||
615 | movq mm2,[esi+8] |
||
616 | paddusb mm1,mm0 |
||
617 | paddusb mm2,mm0 |
||
618 | movq [esi],mm1 |
||
619 | movq [esi+8],mm2 |
||
620 | add esi,16 |
||
621 | sub ecx,16 |
||
622 | jnz .oop |
||
623 | else |
||
624 | movaps xmm1,[esi] |
||
625 | paddusb xmm1,xmm0 |
||
626 | movaps [esi],xmm1 |
||
627 | add esi,16 |
||
628 | sub ecx,16 |
||
629 | jnc .oop |
||
630 | end if |
||
631 | |||
632 | |||
633 | |||
634 | |||
635 | |||
636 | je .no_dec_bright |
||
637 | movzx ebx,[dec_bright_flag] |
||
638 | shl ebx,4 |
||
639 | mov esi,[screen_ptr] |
||
640 | movzx eax,word[size_x_var] |
||
641 | movzx ecx,word[size_y_var] |
||
642 | mul ecx |
||
643 | lea ecx,[eax*4] |
||
644 | if (Ext = MMX)|(Ext = SSE) |
||
645 | mov bh,bl |
||
646 | push bx |
||
647 | shl ebx,16 |
||
648 | pop bx |
||
649 | push ebx |
||
650 | push ebx |
||
651 | movq mm0,[esp] |
||
652 | add esp,8 |
||
653 | else if Ext >=SSE2 |
||
654 | mov bh,bl |
||
655 | push bx |
||
656 | shl ebx,16 |
||
657 | pop bx |
||
658 | movd xmm0,ebx |
||
659 | shufps xmm0,xmm0,0 |
||
660 | end if |
||
661 | .oop1: |
||
662 | if Ext=NON |
||
663 | lodsb |
||
664 | sub al,bl |
||
665 | jb @f |
||
666 | mov [esi-1],al |
||
667 | loop .oop1 |
||
668 | @@: |
||
669 | mov byte[esi-1],0 |
||
670 | loop .oop1 |
||
671 | else if (Ext = MMX)|(Ext=SSE) |
||
672 | movq mm1,[esi] |
||
673 | psubusb mm1,mm0 |
||
674 | movq [esi],mm1 |
||
675 | add esi,8 |
||
676 | sub ecx,8 |
||
677 | jnz .oop1 |
||
678 | else |
||
679 | movaps xmm1,[esi] |
||
680 | psubusb xmm1,xmm0 |
||
681 | movaps [esi],xmm1 |
||
682 | add esi,16 |
||
683 | sub ecx,16 |
||
684 | jnc .oop1 |
||
685 | end if |
||
686 | .no_dec_bright: |
||
687 | |||
688 | |||
689 | |||
690 | sub eax,[esp] |
||
691 | sub eax,41 |
||
692 | ; pop eax |
||
693 | |||
694 | |||
695 | .dc: |
||
696 | xor edx,edx |
||
697 | mov edi,10 |
||
698 | div edi |
||
699 | add dl,30h |
||
700 | mov [STRdata+ecx-1],dl |
||
701 | loop .dc |
||
702 | pop eax |
||
703 | |||
704 | |||
705 | |||
706 | mov ebx,[screen_ptr] |
||
707 | mov ecx,[size_y_var] |
||
708 | mov edx,[offset_y] |
||
709 | cmp [dr_flag],11 |
||
710 | jge .ff |
||
711 | int 0x40 |
||
712 | jmp .f |
||
713 | .ff: |
||
714 | mov eax,65 |
||
715 | mov esi,32 |
||
716 | xor ebp,ebp |
||
717 | int 0x40 |
||
718 | .f: |
||
719 | mov eax,13 |
||
720 | mov bx,[size_x_var] |
||
721 | add ebx,18 |
||
722 | shl ebx,16 |
||
723 | mov bx,60 |
||
724 | mov cx,[size_y_var] |
||
725 | sub cx,2 |
||
726 | shl ecx,16 |
||
727 | mov cx,9 |
||
728 | xor edx,edx |
||
729 | int 40h |
||
730 | |||
731 | |||
732 | mov bx,[size_x_var] |
||
733 | add ebx,18 |
||
734 | shl ebx,16 |
||
735 | mov bx,[size_y_var] |
||
736 | sub bx,2 ; [x start] *65536 + [y start] |
||
737 | mov ecx,0x00888888 |
||
738 | mov edx,STRdata ; pointer to text beginning |
||
739 | mov esi,10 ; text length |
||
740 | int 40h |
||
741 | |||
742 | |||
743 | |||
744 | |||
745 | |||
746 | |||
747 | ;-------------------------PROCEDURES--------------------------------------------- |
||
748 | ;-------------------------------------------------------------------------------- |
||
749 | include "flat_cat.inc" |
||
750 | include "tex_cat.inc" |
||
751 | include "bump_cat.inc" |
||
752 | include "3dmath.inc" |
||
753 | include "grd_line.inc" |
||
754 | include "b_procs.inc" |
||
755 | include "a_procs.inc" |
||
756 | include "grd_cat.inc" |
||
757 | include "bump_tex.inc" |
||
758 | include "grd_tex.inc" |
||
759 | include "two_tex.inc" |
||
760 | include "asc.inc" |
||
761 | if Ext >= SSE3 |
||
762 | include "3r_phg.inc" |
||
763 | include '3stencil.inc' |
||
764 | include '3glass.inc' |
||
765 | include '3glass_tex.inc' |
||
766 | end if |
||
767 | clear_vertices_index: |
||
768 | mov edi,[vertices_index_ptr] |
||
769 | movzx eax,word[size_x_var] |
||
770 | movzx ecx,word[size_y_var] |
||
771 | imul ecx,eax |
||
772 | xor eax,eax |
||
773 | shr ecx,1 |
||
774 | rep stosd |
||
775 | ret |
||
776 | edit: ; mmx required, edit mesh by vertex |
||
777 | push ebp |
||
778 | mov ebp,esp |
||
779 | sub esp,128 |
||
780 | |||
781 | |||
782 | .x_coord equ ebp-4 |
||
783 | .points_translated equ ebp-10 |
||
784 | .points equ ebp-22 |
||
785 | .points_rotated equ ebp-34 |
||
786 | .mx equ ebp-70 |
||
787 | |||
788 | |||
789 | { |
||
790 | movzx ebx,word[.x_coord] |
||
791 | movzx ecx,word[.y_coord] |
||
792 | movzx edx,word[size_x_var] |
||
793 | imul edx,ecx |
||
794 | add ebx,edx |
||
795 | push ebx |
||
796 | lea ecx,[ebx*2] |
||
797 | lea ebx,[ebx*3] |
||
798 | |||
799 | |||
800 | jl @f |
||
801 | add ebx,[esp] |
||
802 | @@: |
||
803 | add esp,4 |
||
804 | add ebx,[screen_ptr] |
||
805 | mov ebx,[ebx] |
||
806 | and ebx,0x00ffffff |
||
807 | cmp ebx,0x00ff0000 ; is handle bar ? |
||
808 | } |
||
809 | |||
810 | |||
811 | mov eax,37 ; get mouse state |
||
812 | mov ebx,1 ; x = 5, y = 25 - offsets |
||
813 | int 0x40 |
||
814 | |||
815 | |||
816 | movd mm0,ebx |
||
817 | movd mm1,eax |
||
818 | movd mm3,[size_y_var] |
||
819 | pcmpgtw mm0,mm1 |
||
820 | pcmpgtw mm3,mm1 |
||
821 | pxor mm3,mm0 |
||
822 | movd eax,mm3 |
||
823 | mov cx,ax |
||
824 | shr eax,16 |
||
825 | and ax,cx |
||
826 | or ax,ax |
||
827 | jz .no_edit |
||
828 | |||
829 | |||
830 | |||
831 | psubw mm1,mm0 |
||
832 | movd eax,mm1 |
||
833 | |||
834 | |||
835 | ror eax,16 |
||
836 | ; push eax |
||
837 | ; sub esp,256 |
||
838 | mov [.x_coord],eax |
||
839 | test word[mouse_state],100000000b |
||
840 | jz .not_press ; check if left mouse button press |
||
841 | |||
842 | |||
843 | |||
844 | |||
845 | |||
846 | jne .no_edit |
||
847 | add ecx,[vertices_index_ptr] |
||
848 | mov cx,word[ecx] |
||
849 | inc cx |
||
850 | |||
851 | |||
852 | |||
853 | |||
854 | |||
855 | mov dword[edit_end_x],eax |
||
856 | mov dword[edit_start_x],eax |
||
857 | jmp .end |
||
858 | .not_press: |
||
859 | test byte[mouse_state],1b ; check if left button is held |
||
860 | jz .not_held |
||
861 | ; check_bar |
||
862 | ; jne .no_edit |
||
863 | ; add ecx,[vertices_index_ptr] |
||
864 | ; mov cx,[ecx] |
||
865 | ; inc cx |
||
866 | cmp [vertex_edit_no],0 ; cx ; vertex number |
||
867 | je .end |
||
868 | push dword[.x_coord] |
||
869 | pop dword[edit_end_x] |
||
870 | jmp .end |
||
871 | .not_held: |
||
872 | shr [mouse_state],16 |
||
873 | test byte[mouse_state],1b ; test if left button released |
||
874 | jz .end |
||
875 | check_bar |
||
876 | jne .end |
||
877 | |||
878 | |||
879 | dec esi |
||
880 | lea esi,[esi*3] |
||
881 | add esi,esi |
||
882 | add esi,[points_translated_ptr] |
||
883 | emms |
||
884 | |||
885 | |||
886 | paddw mm1,mm0 |
||
887 | psubw mm1,qword[vect_x] |
||
888 | movd dword[esi],mm1 |
||
889 | |||
890 | |||
891 | ; detranslate |
||
892 | fninit |
||
893 | fild word[esi+4] |
||
894 | fstp dword[edi+8] |
||
895 | fild word[esi+2] |
||
896 | fisub word[offset_x] |
||
897 | fstp dword[edi+4] |
||
898 | fild word[esi] |
||
899 | fisub word[offset_y] ; proteza |
||
900 | fstp dword[edi] |
||
901 | |||
902 | |||
903 | lea edi,[.mx] |
||
904 | call reverse_mx_3x3 |
||
905 | |||
906 | |||
907 | lea edi,[.points_rotated] |
||
908 | lea ebx,[.mx] |
||
909 | mov ecx,1 |
||
910 | call rotary |
||
911 | |||
912 | |||
913 | movzx edi,[vertex_edit_no] |
||
914 | dec edi |
||
915 | lea edi,[edi*3] |
||
916 | shl edi,2 |
||
917 | add edi,[points_ptr] |
||
918 | lea esi,[.points_rotated] |
||
919 | cld |
||
920 | movsd |
||
921 | movsd |
||
922 | movsd |
||
923 | ; mov ecx,3 |
||
924 | ; cld |
||
925 | ; rep movsd |
||
926 | |||
927 | |||
928 | |||
929 | mov [vertex_edit_no],0 |
||
930 | |||
931 | |||
932 | .end: |
||
933 | mov esp,ebp |
||
934 | pop ebp |
||
935 | ret |
||
936 | |||
937 | |||
938 | push ebp |
||
939 | mov ebp,esp |
||
940 | .temp equ ebp-4 |
||
941 | push dword 0 |
||
942 | |||
943 | |||
944 | mov ebx, 11 |
||
945 | int 0x40 ; -> create heap, to be sure |
||
946 | |||
947 | |||
948 | |||
949 | movzx eax,word[size_y_var] |
||
950 | mul ecx |
||
951 | |||
952 | |||
953 | lea ecx,[eax*4] ; more mem for r_phg cause |
||
954 | add ecx,256 |
||
955 | mov eax,68 |
||
956 | mov ebx,20 |
||
957 | mov edx,[screen_ptr] |
||
958 | int 0x40 |
||
959 | mov [screen_ptr],eax |
||
960 | |||
961 | |||
962 | shl ecx,2 |
||
963 | add ecx,256 |
||
964 | mov eax,68 |
||
965 | mov ebx,20 |
||
966 | mov edx,[Zbuffer_ptr] |
||
967 | int 0x40 |
||
968 | mov [Zbuffer_ptr],eax |
||
969 | |||
970 | |||
971 | |||
972 | add ecx,ecx |
||
973 | add ecx,256 |
||
974 | mov eax,68 |
||
975 | mov ebx,20 |
||
976 | mov edx,[vertices_index_ptr] |
||
977 | int 0x40 |
||
978 | mov [vertices_index_ptr],eax |
||
979 | |||
980 | |||
981 | pop ebp |
||
982 | |||
983 | |||
984 | |||
985 | |||
986 | |||
987 | ; updates flags and writing flag description |
||
988 | ; in ah - button number |
||
989 | push ax |
||
990 | mov edi,menu |
||
991 | .ch_another: |
||
992 | cmp ah,byte[edi] ; ah = button id |
||
993 | jne @f |
||
994 | mov bl,byte[edi+11] ; max_flag + 1 |
||
995 | cmp bl,255 |
||
996 | je .no_write |
||
997 | inc byte[edi+12] ; flag |
||
998 | cmp byte[edi+12],bl |
||
999 | jne .write |
||
1000 | mov byte[edi+12],0 |
||
1001 | jmp .write |
||
1002 | @@: |
||
1003 | add edi,17 |
||
1004 | cmp byte[edi],-1 |
||
1005 | jne .ch_another |
||
1006 | jmp .no_write |
||
1007 | .write: |
||
1008 | ; clreol {pascal never dies} |
||
1009 | ; * eax = 13 - function number |
||
1010 | ; * ebx = [coordinate on axis x]*65536 + [size on axis x] |
||
1011 | ; * ecx = [coordinate on axis y]*65536 + [size on axis y] |
||
1012 | ; * edx = color 0xRRGGBB or 0x80RRGGBB for gradient fill |
||
1013 | |||
1014 | |||
1015 | movzx ecx,byte[edi] |
||
1016 | sub cl,2 |
||
1017 | lea ecx,[ecx*3] |
||
1018 | lea ecx,[ecx*5] |
||
1019 | add ecx,28 |
||
1020 | shl ecx,16 |
||
1021 | add ecx,14 ; ecx = [coord y]*65536 + [size y] |
||
1022 | mov bx,[size_x_var] |
||
1023 | shl ebx,16 |
||
1024 | add ebx,(12+70)*65536+25 ; [x start] *65536 + [size x] |
||
1025 | mov edx,0x00000000 ; color 0x00RRGGBB |
||
1026 | int 0x40 |
||
1027 | |||
1028 | |||
1029 | movzx ebx,byte[edi] |
||
1030 | sub bl,2 |
||
1031 | lea ebx,[ebx*3] |
||
1032 | lea ebx,[ebx*5] |
||
1033 | mov cx,[size_x_var] |
||
1034 | shl ecx,16 |
||
1035 | add ebx,ecx |
||
1036 | add ebx,(12+70)*65536+28 ; [x start] *65536 + [y start] |
||
1037 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
1038 | movzx edx,byte[edi+12] ; current flag |
||
1039 | shl edx,2 ; * 4 = text length |
||
1040 | add edx,dword[edi+13] ; pointer to text beginning |
||
1041 | mov esi,4 ; text length - |
||
1042 | ; flag description 4 characters |
||
1043 | int 0x40 |
||
1044 | |||
1045 | |||
1046 | pop ax |
||
1047 | ret |
||
1048 | normalize_all_light_vectors: |
||
1049 | mov edi,lights |
||
1050 | @@: |
||
1051 | call normalize_vector ; 3dmath.inc |
||
1052 | add edi,LIGHT_SIZE |
||
1053 | cmp edi,lightsend ;ecx |
||
1054 | jl @b |
||
1055 | ret |
||
1056 | |||
1057 | |||
1058 | ;macro .comment222 |
||
1059 | ; ; planar mapping |
||
1060 | ; mov esi,points |
||
1061 | ; mov edi,tex_points |
||
1062 | ; @@: |
||
1063 | ; add esi,2 |
||
1064 | ; movsd |
||
1065 | ; cmp dword[esi],dword -1 |
||
1066 | ; jne @b |
||
1067 | |||
1068 | |||
1069 | |||
1070 | |||
1071 | ; sub esp,4 |
||
1072 | |||
1073 | |||
1074 | fldpi |
||
1075 | fadd st,st |
||
1076 | mov esi,[points_ptr] |
||
1077 | mov edi,tex_points |
||
1078 | mov ecx,[points_count_var] |
||
1079 | inc ecx |
||
1080 | ; cmp [map_tex_flag],1 |
||
1081 | ; jne .cylindric |
||
1082 | ; spherical mapping around y axle |
||
1083 | |||
1084 | |||
1085 | fld dword[esi] ; x coord |
||
1086 | fld dword[esi+8] ; z coord |
||
1087 | fpatan ; arctg(st1/st) |
||
1088 | ; fdiv .Pi2 |
||
1089 | fdiv st0,st1 |
||
1090 | fimul [tex_x_div2] |
||
1091 | fiadd [tex_x_div2] |
||
1092 | fistp word[edi] ; x |
||
1093 | |||
1094 | |||
1095 | fld dword[esi] ; x |
||
1096 | fmul st,st0 |
||
1097 | fld dword[esi+4] ; y |
||
1098 | fmul st,st0 |
||
1099 | fld dword[esi+8] ; z |
||
1100 | fmul st,st0 |
||
1101 | faddp |
||
1102 | faddp |
||
1103 | fsqrt |
||
1104 | fpatan |
||
1105 | fldpi |
||
1106 | fdivp |
||
1107 | fimul [tex_y_div2] |
||
1108 | fiadd [tex_y_div2] |
||
1109 | fistp word[edi+2] ; y |
||
1110 | |||
1111 | |||
1112 | add edi,4 |
||
1113 | loop @b |
||
1114 | ffree st0 |
||
1115 | ; jmp .end_map |
||
1116 | ; .cylindric: |
||
1117 | ; fld dword[esi] ; around y axle |
||
1118 | ; fld dword[esi+8] |
||
1119 | ; fpatan |
||
1120 | ; fdiv st0,st1 |
||
1121 | ; fimul [tex_x_div2] |
||
1122 | ; fiadd [tex_x_div2] |
||
1123 | ; fistp word[edi] |
||
1124 | |||
1125 | |||
1126 | ; fimul [tex_y_div2] |
||
1127 | ; fiadd [tex_y_div2] |
||
1128 | ; fistp word[edi+2] |
||
1129 | |||
1130 | |||
1131 | ; add edi,4 |
||
1132 | ; loop .cylindric |
||
1133 | ; ffree st0 |
||
1134 | ;; mov esp,ebp |
||
1135 | ; .end_map: |
||
1136 | ret |
||
1137 | |||
1138 | |||
1139 | |||
1140 | ;env_map 512 x 512 x 3 bytes |
||
1141 | .temp equ word [ebp-2] |
||
1142 | .nEy equ word [ebp-4] |
||
1143 | .nEx equ word [ebp-6] |
||
1144 | .col_r equ [ebp-8] |
||
1145 | .col_g equ [ebp-9] |
||
1146 | .col_b equ [ebp-10] |
||
1147 | |||
1148 | |||
1149 | mov ebp,esp |
||
1150 | sub esp,20 |
||
1151 | mov edi,envmap |
||
1152 | fninit |
||
1153 | |||
1154 | |||
1155 | .ie_ver: |
||
1156 | mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
||
1157 | .ie_hor: |
||
1158 | xor ebx,ebx |
||
1159 | mov dword .col_b, 0 |
||
1160 | .light: |
||
1161 | lea esi,[lights+ebx] |
||
1162 | fld dword[esi] ; light vector x cooficient |
||
1163 | fimul [tex_x_div2] ;[i256] |
||
1164 | mov .temp,cx |
||
1165 | fisubr .temp |
||
1166 | fistp .nEx |
||
1167 | fld dword[esi+4] ; light vector y cooficient |
||
1168 | fimul [tex_y_div2] ;[i256] |
||
1169 | mov .temp,dx |
||
1170 | fisubr .temp |
||
1171 | fistp .nEy |
||
1172 | |||
1173 | |||
1174 | jl .update_counters |
||
1175 | cmp .nEy,- TEX_Y / 2 ;256 |
||
1176 | jl .update_counters |
||
1177 | cmp .nEx,TEX_X / 2 ;256 |
||
1178 | jg .update_counters |
||
1179 | cmp .nEy,TEX_Y / 2 ;256 |
||
1180 | jg .update_counters |
||
1181 | |||
1182 | |||
1183 | fmul st,st0 |
||
1184 | fild .nEy |
||
1185 | fmul st,st0 |
||
1186 | faddp |
||
1187 | fsqrt |
||
1188 | fisubr [i256] |
||
1189 | fmul [env_const] |
||
1190 | fidiv [i256] ; st - 'virtual' dot product |
||
1191 | |||
1192 | |||
1193 | fstsw ax |
||
1194 | sahf |
||
1195 | jb @f |
||
1196 | ffree st |
||
1197 | fld1 ;[dot_max] |
||
1198 | @@: |
||
1199 | fcom [dot_min] |
||
1200 | fstsw ax |
||
1201 | sahf |
||
1202 | ja @f |
||
1203 | ffree st |
||
1204 | fldz ;[dot_min] |
||
1205 | @@: |
||
1206 | push ebp |
||
1207 | movzx ax,byte[esi+21] |
||
1208 | push ax ;- shines |
||
1209 | mov al,byte[esi+14] ; b orginal color |
||
1210 | push ax |
||
1211 | mov al,byte[esi+13] ; g |
||
1212 | push ax |
||
1213 | mov al,byte[esi+12] ; r |
||
1214 | push ax |
||
1215 | mov al,byte[esi+20] ; b max color |
||
1216 | push ax |
||
1217 | mov al,byte[esi+19] ; g |
||
1218 | push ax |
||
1219 | mov al,byte[esi+18] ; r |
||
1220 | push ax |
||
1221 | mov al,byte[esi+17] ; b min col |
||
1222 | push ax |
||
1223 | mov al,byte[esi+16] ; g |
||
1224 | push ax |
||
1225 | mov al,byte[esi+15] ; r |
||
1226 | push ax |
||
1227 | push eax ; earlier - dot pr |
||
1228 | ; fstp .dot_product |
||
1229 | ; push .dot_product |
||
1230 | call calc_one_col |
||
1231 | pop ebp |
||
1232 | ; eax-0x00rrggbb |
||
1233 | cmp al,.col_b |
||
1234 | jbe @f |
||
1235 | mov .col_b,al |
||
1236 | @@: ; eax - ggbb00rr |
||
1237 | shr ax,8 |
||
1238 | cmp al,.col_g |
||
1239 | jbe @f |
||
1240 | mov .col_g,al |
||
1241 | @@: ; eax - bb0000gg |
||
1242 | shr eax,16 |
||
1243 | cmp al,.col_r |
||
1244 | jbe @f |
||
1245 | mov .col_r,al |
||
1246 | @@: |
||
1247 | .update_counters: ; update and jump when neccesery |
||
1248 | add ebx,LIGHT_SIZE |
||
1249 | cmp bx,[all_lights_size] |
||
1250 | jl .light ; next_light |
||
1251 | mov eax,dword .col_b |
||
1252 | stosd |
||
1253 | dec edi |
||
1254 | |||
1255 | |||
1256 | cmp cx,TEX_X / 2 ;256 |
||
1257 | jne .ie_hor |
||
1258 | |||
1259 | |||
1260 | cmp dx,TEX_Y / 2 ;256 |
||
1261 | jne .ie_ver |
||
1262 | |||
1263 | |||
1264 | pop ebp |
||
1265 | ret |
||
1266 | |||
1267 | |||
1268 | |||
1269 | |||
1270 | ;env_map 512 x 512 x 3 bytes ; many lights using |
||
1271 | .temp equ word [ebp-2] |
||
1272 | .nz equ dword [ebp-6] ; dword |
||
1273 | .ny equ dword [ebp-10] |
||
1274 | .nx equ dword [ebp-14] |
||
1275 | .col_r equ [ebp-16] |
||
1276 | .col_g equ [ebp-17] |
||
1277 | .col_b equ [ebp-18] |
||
1278 | |||
1279 | |||
1280 | mov ebp,esp |
||
1281 | sub esp,20 |
||
1282 | mov edi,color_map |
||
1283 | fninit |
||
1284 | |||
1285 | |||
1286 | .ie_ver: |
||
1287 | mov cx,- TEX_X / 2 ;256 ; cx - horizontal coord = x |
||
1288 | .ie_hor: |
||
1289 | mov .temp,cx |
||
1290 | fild .temp |
||
1291 | fidiv [i256] ;st = Nx - vector normal x cooficient |
||
1292 | fst .nx |
||
1293 | fmul st,st0 |
||
1294 | mov .temp,dx |
||
1295 | fild .temp |
||
1296 | fidiv [i256] ; st = Ny - vector normal y coeficient |
||
1297 | fst .ny |
||
1298 | fmul st,st0 |
||
1299 | faddp |
||
1300 | fld1 |
||
1301 | fchs |
||
1302 | faddp |
||
1303 | fabs |
||
1304 | fsqrt |
||
1305 | fchs |
||
1306 | fstp .nz ; st - Nz - vect normal z coeficient |
||
1307 | xor ebx,ebx |
||
1308 | mov dword .col_b, 0 |
||
1309 | .light: |
||
1310 | push edi ;env_map |
||
1311 | lea esi,[lights+ebx] |
||
1312 | lea edi,.nx |
||
1313 | call dot_product |
||
1314 | pop edi |
||
1315 | fcom [dot_min] |
||
1316 | fstsw ax |
||
1317 | sahf |
||
1318 | ja .env_ok1 ;compare with dot_max |
||
1319 | ffree st |
||
1320 | |||
1321 | |||
1322 | .env_ok1: |
||
1323 | fcom [dot_max] |
||
1324 | fstsw ax |
||
1325 | sahf |
||
1326 | jb .env_ok2 ; calc col |
||
1327 | ffree st |
||
1328 | jmp .update_counters |
||
1329 | .env_ok2: ;calc col |
||
1330 | push ebp |
||
1331 | movzx ax,byte[esi+21] |
||
1332 | push ax ;- shines |
||
1333 | mov al,byte[esi+14] ; b orginal color |
||
1334 | push ax |
||
1335 | mov al,byte[esi+13] ; g |
||
1336 | push ax |
||
1337 | mov al,byte[esi+12] ; r |
||
1338 | push ax |
||
1339 | mov al,byte[esi+20] ; b max color |
||
1340 | push ax |
||
1341 | mov al,byte[esi+19] ; g |
||
1342 | push ax |
||
1343 | mov al,byte[esi+18] ; r |
||
1344 | push ax |
||
1345 | mov al,byte[esi+17] ; b min col |
||
1346 | push ax |
||
1347 | mov al,byte[esi+16] ; g |
||
1348 | push ax |
||
1349 | mov al,byte[esi+15] ; r |
||
1350 | push ax |
||
1351 | push eax ; earlier - dot pr |
||
1352 | ; fstp .dot_product |
||
1353 | ; push .dot_product |
||
1354 | call calc_one_col |
||
1355 | pop ebp |
||
1356 | ; eax-0x00rrggbb |
||
1357 | cmp al,.col_b |
||
1358 | jbe @f |
||
1359 | mov .col_b,al |
||
1360 | @@: |
||
1361 | shr ax,8 |
||
1362 | cmp al,.col_g |
||
1363 | jbe @f |
||
1364 | mov .col_g,al |
||
1365 | @@: |
||
1366 | shr eax,16 |
||
1367 | cmp al,.col_r |
||
1368 | jbe @f |
||
1369 | mov .col_r,al |
||
1370 | @@: |
||
1371 | .update_counters: ; update and jump when neccesery |
||
1372 | add ebx,LIGHT_SIZE |
||
1373 | cmp bx,[all_lights_size] |
||
1374 | jl .light ; next_light |
||
1375 | mov eax,dword .col_b |
||
1376 | stosd |
||
1377 | dec edi |
||
1378 | |||
1379 | |||
1380 | cmp cx,TEX_X / 2 ;256 |
||
1381 | jne .ie_hor |
||
1382 | |||
1383 | |||
1384 | cmp dx,TEX_X / 2 ;256 |
||
1385 | jne .ie_ver |
||
1386 | |||
1387 | |||
1388 | mov esp,ebp |
||
1389 | pop ebp |
||
1390 | ret |
||
1391 | if Ext >= SSE3 |
||
1392 | init_point_normals: |
||
1393 | .z equ dword [ebp-8] |
||
1394 | .y equ dword [ebp-12] |
||
1395 | .x equ [ebp-16] |
||
1396 | .point_number equ dword [ebp-28] |
||
1397 | .hit_faces equ dword [ebp-32] |
||
1398 | |||
1399 | |||
1400 | push ebp |
||
1401 | mov ebp,esp |
||
1402 | sub esp,64 |
||
1403 | and ebp,-16 |
||
1404 | mov edi,[points_normals_ptr] |
||
1405 | mov .point_number,0 |
||
1406 | .ipn_loop: |
||
1407 | movd xmm0,.point_number |
||
1408 | pshufd xmm0,xmm0,0 |
||
1409 | mov .hit_faces,0 |
||
1410 | mov .x,dword 0 |
||
1411 | mov .y,0 |
||
1412 | mov .z,0 |
||
1413 | mov esi,[triangles_ptr] |
||
1414 | xor ecx,ecx ; ecx - triangle number |
||
1415 | .ipn_check_face: |
||
1416 | movdqu xmm1,[esi] |
||
1417 | pcmpeqd xmm1,xmm0 |
||
1418 | pmovmskb eax,xmm1 |
||
1419 | and eax,0xfff |
||
1420 | or eax,eax |
||
1421 | jz .ipn_next_face |
||
1422 | push esi |
||
1423 | mov esi,ecx |
||
1424 | lea esi,[esi*3] |
||
1425 | shl esi,2 |
||
1426 | add esi,[triangles_normals_ptr] |
||
1427 | movups xmm7,[esi] |
||
1428 | addps xmm7,.x |
||
1429 | movaps .x,xmm7 |
||
1430 | pop esi |
||
1431 | inc .hit_faces |
||
1432 | |||
1433 | |||
1434 | add esi,12 |
||
1435 | inc ecx |
||
1436 | cmp ecx,[triangles_count_var] |
||
1437 | jne .ipn_check_face |
||
1438 | cvtsi2ss xmm6,.hit_faces |
||
1439 | movaps xmm7,.x |
||
1440 | rcpss xmm6,xmm6 |
||
1441 | shufps xmm6,xmm6,11000000b |
||
1442 | mulps xmm7,xmm6 |
||
1443 | movaps xmm6,xmm7 |
||
1444 | mulps xmm6,xmm6 |
||
1445 | andps xmm6,[zero_hgst_dd] |
||
1446 | haddps xmm6,xmm6 |
||
1447 | haddps xmm6,xmm6 |
||
1448 | rsqrtps xmm6,xmm6 |
||
1449 | mulps xmm7,xmm6 |
||
1450 | movlps [edi],xmm7 |
||
1451 | movhlps xmm7,xmm7 |
||
1452 | movss [edi+8],xmm7 |
||
1453 | add edi,12 |
||
1454 | inc .point_number |
||
1455 | mov edx,.point_number |
||
1456 | cmp edx,[points_count_var] |
||
1457 | jne .ipn_loop |
||
1458 | |||
1459 | |||
1460 | pop ebp |
||
1461 | ret |
||
1462 | else |
||
1463 | init_point_normals: |
||
1464 | .x equ dword [ebp-4] |
||
1465 | .y equ dword [ebp-8] |
||
1466 | .z equ dword [ebp-12] |
||
1467 | .point_number equ dword [ebp-28] |
||
1468 | .hit_faces equ dword [ebp-32] |
||
1469 | |||
1470 | |||
1471 | mov ebp,esp |
||
1472 | sub esp,32 |
||
1473 | mov edi,[points_normals_ptr] |
||
1474 | mov .point_number,0 |
||
1475 | .ipn_loop: |
||
1476 | mov .hit_faces,0 |
||
1477 | mov .x,0 |
||
1478 | mov .y,0 |
||
1479 | mov .z,0 |
||
1480 | mov esi,[triangles_ptr] |
||
1481 | xor ecx,ecx ; ecx - triangle number |
||
1482 | .ipn_check_face: |
||
1483 | xor ebx,ebx ; ebx - 'position' in one triangle |
||
1484 | .ipn_check_vertex: |
||
1485 | mov eax,dword[esi+ebx] ; eax - point_number |
||
1486 | cmp eax,.point_number |
||
1487 | jne .ipn_next_vertex |
||
1488 | push esi |
||
1489 | mov esi,ecx |
||
1490 | lea esi,[esi*3] |
||
1491 | ; lea esi,[triangles_normals+esi*4] |
||
1492 | shl esi,2 |
||
1493 | add esi,[triangles_normals_ptr] |
||
1494 | |||
1495 | |||
1496 | fadd dword[esi+vec_x] ; vec_x this defined in 3dmath.asm - x cooficient |
||
1497 | fstp .x ; of normal vactor |
||
1498 | fld .y |
||
1499 | fadd dword[esi+vec_y] |
||
1500 | fstp .y |
||
1501 | fld .z |
||
1502 | fadd dword[esi+vec_z] |
||
1503 | fstp .z |
||
1504 | pop esi |
||
1505 | inc .hit_faces |
||
1506 | jmp .ipn_next_face |
||
1507 | .ipn_next_vertex: |
||
1508 | add ebx,4 |
||
1509 | cmp ebx,12 |
||
1510 | jne .ipn_check_vertex |
||
1511 | .ipn_next_face: |
||
1512 | add esi,12 |
||
1513 | inc ecx |
||
1514 | cmp ecx,[triangles_count_var] |
||
1515 | jne .ipn_check_face |
||
1516 | |||
1517 | |||
1518 | fidiv .hit_faces |
||
1519 | fstp dword[edi+vec_x] |
||
1520 | fld .y |
||
1521 | fidiv .hit_faces |
||
1522 | fstp dword[edi+vec_y] |
||
1523 | fld .z |
||
1524 | fidiv .hit_faces |
||
1525 | fstp dword[edi+vec_z] |
||
1526 | call normalize_vector |
||
1527 | add edi,12 ;type vector 3d |
||
1528 | inc .point_number |
||
1529 | mov edx,.point_number |
||
1530 | cmp edx,[points_count_var] |
||
1531 | jne .ipn_loop |
||
1532 | |||
1533 | |||
1534 | ret |
||
1535 | ;=============================================================== |
||
1536 | end if |
||
1537 | init_triangles_normals2: |
||
1538 | mov ebx,[triangles_normals_ptr] |
||
1539 | mov ebp,[triangles_ptr] |
||
1540 | mov ecx,[triangles_count_var] |
||
1541 | @@: |
||
1542 | push ecx |
||
1543 | push ebx |
||
1544 | mov ebx,vectors |
||
1545 | mov esi,dword[ebp] ; first point index |
||
1546 | lea esi,[esi*3] |
||
1547 | ; lea esi,[points+esi*2] ; esi - pointer to 1st 3d point |
||
1548 | shl esi,2 |
||
1549 | add esi,[points_ptr] |
||
1550 | mov edi,dword[ebp+4] ; first point index |
||
1551 | lea edi,[edi*3] |
||
1552 | shl edi,2 |
||
1553 | add edi,[points_ptr] |
||
1554 | ; movzx edi,word[ebp+2] ; second point index |
||
1555 | ; lea edi,[edi*3] |
||
1556 | ; lea edi,[points+edi*2] ; edi - pointer to 2nd 3d point |
||
1557 | call make_vector_r |
||
1558 | add ebx,12 |
||
1559 | mov esi,edi |
||
1560 | mov edi,dword[ebp+8] ; third point index |
||
1561 | lea edi,[edi*3] |
||
1562 | shl edi,2 |
||
1563 | add edi,[points_ptr] |
||
1564 | ; lea edi,[points+edi*2] |
||
1565 | call make_vector_r |
||
1566 | mov edi,ebx ; edi - pointer to 2nd vector |
||
1567 | mov esi,ebx |
||
1568 | sub esi,12 ; esi - pointer to 1st vector |
||
1569 | pop ebx |
||
1570 | call cross_product |
||
1571 | mov edi,ebx |
||
1572 | call normalize_vector |
||
1573 | add ebp,12 |
||
1574 | add ebx,12 |
||
1575 | pop ecx |
||
1576 | sub ecx,1 |
||
1577 | jnz @b |
||
1578 | ; cmp dword[ebp],-1 |
||
1579 | ; jne @b |
||
1580 | ret |
||
1581 | |||
1582 | |||
1583 | copy_lights: ; after normalising ! |
||
1584 | mov esi,lights |
||
1585 | mov edi,lights_aligned |
||
1586 | mov ecx,3 |
||
1587 | .again: |
||
1588 | push ecx |
||
1589 | mov ecx,3 |
||
1590 | cld |
||
1591 | rep movsd |
||
1592 | xor eax,eax |
||
1593 | stosd |
||
1594 | mov ecx,3 |
||
1595 | .b: |
||
1596 | push ecx |
||
1597 | mov ecx,3 |
||
1598 | @@: |
||
1599 | movzx ebx,byte[esi] |
||
1600 | cvtsi2ss xmm0,ebx |
||
1601 | movss [edi],xmm0 |
||
1602 | inc esi |
||
1603 | add edi,4 |
||
1604 | loop @b |
||
1605 | stosd |
||
1606 | pop ecx |
||
1607 | loop .b |
||
1608 | inc esi ; skip shiness |
||
1609 | pop ecx |
||
1610 | loop .again |
||
1611 | ret |
||
1612 | end if |
||
1613 | |||
1614 | |||
1615 | mov edi,[screen_ptr] |
||
1616 | movzx ecx,word[size_x_var] |
||
1617 | movzx eax,word[size_y_var] |
||
1618 | imul ecx,eax |
||
1619 | |||
1620 | |||
1621 | |||
1622 | if Ext=NON |
||
1623 | rep stosd |
||
1624 | else if Ext = MMX |
||
1625 | pxor mm0,mm0 |
||
1626 | @@: |
||
1627 | movq [edi+00],mm0 |
||
1628 | movq [edi+08],mm0 |
||
1629 | movq [edi+16],mm0 |
||
1630 | movq [edi+24],mm0 |
||
1631 | add edi,32 |
||
1632 | sub ecx,8 |
||
1633 | jnc @b |
||
1634 | else |
||
1635 | push ecx |
||
1636 | mov ecx,edi |
||
1637 | and ecx,0x0000000f |
||
1638 | rep stosb |
||
1639 | pop ecx |
||
1640 | and ecx,0xfffffff0 |
||
1641 | xorps xmm0,xmm0 |
||
1642 | @@: |
||
1643 | movaps [edi],xmm0 |
||
1644 | movaps [edi+16],xmm0 |
||
1645 | movaps [edi+32],xmm0 |
||
1646 | movaps [edi+48],xmm0 |
||
1647 | add edi,64 |
||
1648 | sub ecx,16 |
||
1649 | jnz @b |
||
1650 | end if |
||
1651 | |||
1652 | |||
1653 | |||
1654 | |||
1655 | |||
1656 | |||
1657 | |||
1658 | ; update translated list MMX required |
||
1659 | cmp [vertex_edit_no],0 |
||
1660 | je @f |
||
1661 | movzx eax,[vertex_edit_no] |
||
1662 | dec eax |
||
1663 | movd mm0,[edit_end_x] |
||
1664 | psubw mm0,[edit_start_x] |
||
1665 | lea eax,[eax*3] |
||
1666 | add eax,eax |
||
1667 | add eax,[points_translated_ptr] |
||
1668 | movd mm1,dword[eax] |
||
1669 | paddw mm1,mm0 |
||
1670 | movd dword[eax],mm1 |
||
1671 | @@: |
||
1672 | if Ext >= SSE3 |
||
1673 | cmp [dr_flag],13 |
||
1674 | jnge .no_stencil |
||
1675 | mov esi,[triangles_ptr] |
||
1676 | mov ecx,[triangles_count_var] |
||
1677 | @@: |
||
1678 | push esi |
||
1679 | push ecx |
||
1680 | |||
1681 | |||
1682 | mov ebx,[esi+4] |
||
1683 | mov ecx,[esi+8] |
||
1684 | imul eax,[i12] |
||
1685 | imul ebx,[i12] |
||
1686 | imul ecx,[i12] |
||
1687 | add eax,[points_rotated_ptr] |
||
1688 | add ebx,[points_rotated_ptr] |
||
1689 | add ecx,[points_rotated_ptr] |
||
1690 | push dword[ecx+8] |
||
1691 | push dword[ebx+8] |
||
1692 | push dword[eax+8] |
||
1693 | movups xmm0,[esp] |
||
1694 | add esp,12 |
||
1695 | andps xmm0,[zero_hgst_dd] |
||
1696 | |||
1697 | |||
1698 | |||
1699 | mov ebx,[esi+4] |
||
1700 | mov ecx,[esi+8] |
||
1701 | shl eax,1 |
||
1702 | shl ebx,1 |
||
1703 | shl ecx,1 |
||
1704 | lea eax,[eax*3] |
||
1705 | lea ebx,[ebx*3] |
||
1706 | lea ecx,[ecx*3] |
||
1707 | add eax,[points_translated_ptr] |
||
1708 | add ebx,[points_translated_ptr] |
||
1709 | add ecx,[points_translated_ptr] |
||
1710 | mov eax,[eax] |
||
1711 | mov ebx,[ebx] |
||
1712 | mov ecx,[ecx] |
||
1713 | ror eax,16 |
||
1714 | ror ebx,16 |
||
1715 | ror ecx,16 |
||
1716 | |||
1717 | |||
1718 | |||
1719 | |||
1720 | |||
1721 | |||
1722 | |||
1723 | pop esi |
||
1724 | add esi,12 |
||
1725 | dec ecx |
||
1726 | jnz @b |
||
1727 | |||
1728 | |||
1729 | end if |
||
1730 | |||
1731 | |||
1732 | |||
1733 | je .draw_smooth_line |
||
1734 | |||
1735 | |||
1736 | mov ecx,[triangles_count_var] |
||
1737 | .again_dts: |
||
1738 | push ecx |
||
1739 | mov ebp,[points_translated_ptr] |
||
1740 | if Ext >= SSE2 |
||
1741 | mov eax,dword[esi] |
||
1742 | mov [point_index1],eax |
||
1743 | lea eax,[eax*3] |
||
1744 | add eax,eax |
||
1745 | push ebp |
||
1746 | add ebp,eax |
||
1747 | mov eax,[ebp] |
||
1748 | ; cmp [vertex_edit_no],0 |
||
1749 | ; jne @f |
||
1750 | ; |
||
1751 | ; @@: |
||
1752 | mov dword[xx1],eax |
||
1753 | mov eax,[ebp+4] |
||
1754 | mov [zz1],ax |
||
1755 | |||
1756 | |||
1757 | |||
1758 | |||
1759 | |||
1760 | mov [point_index2],eax |
||
1761 | lea eax,[eax*3] |
||
1762 | add eax,eax |
||
1763 | push ebp |
||
1764 | add ebp,eax |
||
1765 | mov eax,[ebp] |
||
1766 | mov dword[xx2],eax |
||
1767 | mov eax,[ebp+4] |
||
1768 | mov [zz2],ax |
||
1769 | pop ebp |
||
1770 | |||
1771 | |||
1772 | |||
1773 | mov [point_index3],eax |
||
1774 | lea eax,[eax*3] |
||
1775 | add eax,eax |
||
1776 | ; push ebp |
||
1777 | add ebp,eax |
||
1778 | mov eax,[ebp] |
||
1779 | mov dword[xx3],eax |
||
1780 | mov eax,[ebp+4] |
||
1781 | mov [zz3],ax |
||
1782 | else |
||
1783 | movq mm0,[esi] ; don't know MMX |
||
1784 | mov qword[point_index1],mm0 |
||
1785 | ; shr eax,16 |
||
1786 | ; mov [point_index2],ax |
||
1787 | mov eax,dword[esi+8] |
||
1788 | mov [point_index3],eax |
||
1789 | movdqu xmm0,[esi] |
||
1790 | paddd xmm0,xmm0 |
||
1791 | movdqa xmm1,xmm0 |
||
1792 | paddd xmm0,xmm0 |
||
1793 | paddd xmm0,xmm1 |
||
1794 | movd eax,xmm0 |
||
1795 | psrldq xmm0,4 |
||
1796 | movd ebx,xmm0 |
||
1797 | psrldq xmm0,4 |
||
1798 | movd ecx,xmm0 |
||
1799 | and eax,0FFFFh |
||
1800 | and ebx,0FFFFh |
||
1801 | and ecx,0FFFFh |
||
1802 | movq mm0,[ebp+eax] |
||
1803 | movq mm1,[ebp+ebx] |
||
1804 | movq mm2,[ebp+ecx] |
||
1805 | movq qword[xx1],mm0 |
||
1806 | movq qword[xx2],mm1 |
||
1807 | movq qword[xx3],mm2 |
||
1808 | ; emms |
||
1809 | end if ; ********************************* |
||
1810 | if 0 |
||
1811 | cmp [vertex_edit_no],0 |
||
1812 | jne .no_edit |
||
1813 | mov ax,[vertex_edit_no] |
||
1814 | dec ax |
||
1815 | cmp ax,[point_index1] |
||
1816 | jne @f |
||
1817 | movd mm0,[edit_start_x] |
||
1818 | psubw mm0,[edit_end_x] |
||
1819 | movd mm1,dword[xx1] |
||
1820 | paddw mm1,mm0 |
||
1821 | movd dword[xx1],mm1 |
||
1822 | jmp .no_edit |
||
1823 | @@: |
||
1824 | |||
1825 | |||
1826 | jne @f |
||
1827 | movd mm0,[edit_start_x] |
||
1828 | psubw mm0,[edit_end_x] |
||
1829 | movd mm1,dword[xx2] |
||
1830 | paddw mm1,mm0 |
||
1831 | movd dword[xx2],mm1 |
||
1832 | jmp .no_edit |
||
1833 | @@: |
||
1834 | |||
1835 | |||
1836 | jne @f |
||
1837 | movd mm0,[edit_start_x] |
||
1838 | psubw mm0,[edit_end_x] |
||
1839 | movd mm1,dword[xx3] |
||
1840 | paddw mm1,mm0 |
||
1841 | movd dword[xx3],mm1 |
||
1842 | jmp .no_edit |
||
1843 | @@: |
||
1844 | |||
1845 | |||
1846 | |||
1847 | end if |
||
1848 | |||
1849 | |||
1850 | fninit ; DO culling AT FIRST |
||
1851 | cmp [culling_flag],1 ; (if culling_flag = 1) |
||
1852 | jne .no_culling |
||
1853 | mov esi,point_index1 ; ********************************* |
||
1854 | mov ecx,3 ; |
||
1855 | @@: |
||
1856 | mov eax,dword[esi] |
||
1857 | lea eax,[eax*3] |
||
1858 | shl eax,2 |
||
1859 | add eax,[points_normals_rot_ptr] |
||
1860 | ; lea eax,[eax+point_normals_rotated] |
||
1861 | fld dword[eax+8] ; ***************************** |
||
1862 | ftst ; CHECKING OF Z COOFICIENT OF |
||
1863 | fstsw ax ; NORMAL VECTOR |
||
1864 | sahf |
||
1865 | jb @f |
||
1866 | ffree st |
||
1867 | loop @b |
||
1868 | jmp .end_draw ; non visable |
||
1869 | @@: |
||
1870 | ffree st ;is visable |
||
1871 | .no_culling: |
||
1872 | cmp [dr_flag],0 ; draw type flag |
||
1873 | je .flat_draw |
||
1874 | cmp [dr_flag],2 |
||
1875 | je .env_mapping |
||
1876 | cmp [dr_flag],3 |
||
1877 | je .bump_mapping |
||
1878 | cmp [dr_flag],4 |
||
1879 | je .tex_mapping |
||
1880 | cmp [dr_flag],5 |
||
1881 | je .rainbow |
||
1882 | cmp [dr_flag],7 |
||
1883 | je .grd_tex |
||
1884 | cmp [dr_flag],8 |
||
1885 | je .two_tex |
||
1886 | cmp [dr_flag],9 |
||
1887 | je .bump_tex |
||
1888 | cmp [dr_flag],10 |
||
1889 | je .cubic_env_mapping |
||
1890 | cmp [dr_flag],11 |
||
1891 | je .draw_smooth_line |
||
1892 | if Ext >= SSE3 |
||
1893 | cmp [dr_flag],12 |
||
1894 | je .r_phg |
||
1895 | cmp [dr_flag],13 |
||
1896 | je .glass |
||
1897 | cmp [dr_flag],14 |
||
1898 | je .glass_tex |
||
1899 | end if ; **************** |
||
1900 | mov esi,point_index3 ; do Gouraud shading |
||
1901 | mov ecx,3 |
||
1902 | .again_grd_draw: |
||
1903 | mov eax,dword[esi] |
||
1904 | shl eax,2 |
||
1905 | lea eax,[eax*3] |
||
1906 | add eax,[points_normals_rot_ptr] |
||
1907 | ; texture x=(rotated point normal -> x * 255)+255 |
||
1908 | fld dword[eax] ; x cooficient of normal vector |
||
1909 | fimul [correct_tex] |
||
1910 | fiadd [correct_tex] |
||
1911 | fistp [temp1] |
||
1912 | ; texture y=(rotated point normal -> y * 255)+255 |
||
1913 | fld dword[eax+4] ; y cooficient |
||
1914 | fimul [correct_tex] |
||
1915 | fiadd [correct_tex] |
||
1916 | fistp [temp2] |
||
1917 | |||
1918 | |||
1919 | mov ebx,[temp1] |
||
1920 | and ebx,0xfffffff |
||
1921 | shl eax,TEX_SHIFT |
||
1922 | add eax,ebx |
||
1923 | lea eax,[eax*3+color_map] |
||
1924 | mov eax,dword[eax] |
||
1925 | ; cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
||
1926 | ; jne @f |
||
1927 | lea edx,[ecx*3] |
||
1928 | push word[edx*2+xx1-2] ; zz1 ,2 ,3 |
||
1929 | ; @@: |
||
1930 | ror eax,16 ; eax -0xxxrrggbb -> 0xggbbxxrr |
||
1931 | xor ah,ah |
||
1932 | push ax ;r |
||
1933 | rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg |
||
1934 | xor ah,ah |
||
1935 | push ax ;g |
||
1936 | shr eax,24 |
||
1937 | push ax ;b |
||
1938 | |||
1939 | |||
1940 | dec cx |
||
1941 | jnz .again_grd_draw |
||
1942 | jmp .both_draw |
||
1943 | |||
1944 | |||
1945 | ; lea edi,[edi*3] |
||
1946 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1947 | ; mov esi,light_vector |
||
1948 | ; call dot_product |
||
1949 | ; fabs |
||
1950 | ; fimul [orginal_color_r] |
||
1951 | ; fistp [temp_col] |
||
1952 | ; and [temp_col],0x00ff |
||
1953 | ; push [temp_col] |
||
1954 | ; push [temp_col] |
||
1955 | ; push [temp_col] |
||
1956 | |||
1957 | |||
1958 | ; lea edi,[edi*3] |
||
1959 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1960 | ; mov esi,light_vector |
||
1961 | ; call dot_product |
||
1962 | ; fabs |
||
1963 | ; fimul [orginal_color_r] |
||
1964 | ; fistp [temp_col] |
||
1965 | ; and [temp_col],0x00ff |
||
1966 | ; push [temp_col] |
||
1967 | ; push [temp_col] |
||
1968 | ; push [temp_col] |
||
1969 | |||
1970 | |||
1971 | ; lea edi,[edi*3] |
||
1972 | ; lea edi,[4*edi+point_normals_rotated] ; edi - normal |
||
1973 | ; mov esi,light_vector |
||
1974 | ; call dot_product |
||
1975 | ; fabs |
||
1976 | ; fimul [orginal_color_r] |
||
1977 | ; fistp [temp_col] |
||
1978 | ; and [temp_col],0x00ff |
||
1979 | ; push [temp_col] |
||
1980 | ; push [temp_col] |
||
1981 | ; push [temp_col] |
||
1982 | .rainbow: |
||
1983 | ; cmp [catmull_flag],1 ; put on stack z coordinate if necessary |
||
1984 | ; jne @f |
||
1985 | push [zz3] |
||
1986 | @@: |
||
1987 | mov eax,dword[yy3] |
||
1988 | mov ebx,0x00ff00ff |
||
1989 | and eax,ebx |
||
1990 | push eax |
||
1991 | neg al |
||
1992 | push ax |
||
1993 | push [zz2] |
||
1994 | |||
1995 | |||
1996 | and eax,ebx |
||
1997 | push eax |
||
1998 | neg al |
||
1999 | push ax |
||
2000 | push [zz1] |
||
2001 | |||
2002 | |||
2003 | and eax,ebx |
||
2004 | push eax |
||
2005 | neg al |
||
2006 | push ax |
||
2007 | .both_draw: |
||
2008 | mov eax,dword[xx1] |
||
2009 | ror eax,16 |
||
2010 | mov ebx,dword[xx2] |
||
2011 | ror ebx,16 |
||
2012 | mov ecx,dword[xx3] |
||
2013 | ror ecx,16 |
||
2014 | mov edi,[screen_ptr] |
||
2015 | mov esi,[Zbuffer_ptr] |
||
2016 | call gouraud_triangle_z |
||
2017 | jmp .end_draw |
||
2018 | |||
2019 | |||
2020 | fninit ; FLAT DRAWING |
||
2021 | mov eax,[point_index1] |
||
2022 | mov ebx,[point_index2] |
||
2023 | mov ecx,[point_index3] |
||
2024 | shl eax,2 |
||
2025 | shl ebx,2 |
||
2026 | shl ecx,2 |
||
2027 | lea eax,[eax*3] ;+point_normals_rotated] |
||
2028 | add eax,[points_normals_rot_ptr] |
||
2029 | lea ebx,[ebx*3] ;+point_normals_rotated] |
||
2030 | add ebx,[points_normals_rot_ptr] |
||
2031 | lea ecx,[ecx*3] ;+point_normals_rotated] |
||
2032 | add ecx,[points_normals_rot_ptr] |
||
2033 | fld dword[eax] ; x cooficient of normal vector |
||
2034 | fadd dword[ebx] |
||
2035 | fadd dword[ecx] |
||
2036 | fidiv [i3] |
||
2037 | fimul [correct_tex] |
||
2038 | fiadd [correct_tex] |
||
2039 | fistp [temp1] ;dword[esp-4] ; x temp variables |
||
2040 | fld dword[eax+4] ; y cooficient of normal vector |
||
2041 | fadd dword[ebx+4] |
||
2042 | fadd dword[ecx+4] |
||
2043 | fidiv [i3] |
||
2044 | fimul [correct_tex] |
||
2045 | fiadd [correct_tex] |
||
2046 | fistp [temp2] ;dword[esp-8] ; y |
||
2047 | mov edx,[temp2] ;dword[esp-8] |
||
2048 | and edx,0xfffffff |
||
2049 | and [temp1],0xfffffff |
||
2050 | shl edx,TEX_SHIFT |
||
2051 | add edx,[temp1] ;dword[esp-4] |
||
2052 | |||
2053 | |||
2054 | add eax,color_map |
||
2055 | mov edx,dword[eax] |
||
2056 | |||
2057 | |||
2058 | |||
2059 | |||
2060 | |||
2061 | |||
2062 | ; add ax,[zz2] |
||
2063 | ; add ax,[zz3] |
||
2064 | ; cwd |
||
2065 | ; idiv [i3] ; = -((a+b+c)/3+130) |
||
2066 | ; add ax,130 |
||
2067 | ; neg al |
||
2068 | ; xor edx,edx |
||
2069 | ; mov ah,al ;set color according to z position |
||
2070 | ; shl eax,8 |
||
2071 | ; mov edx,eax |
||
2072 | |||
2073 | |||
2074 | ror eax,16 |
||
2075 | mov ebx,dword[xx2] |
||
2076 | ror ebx,16 |
||
2077 | mov ecx,dword[xx3] |
||
2078 | ror ecx,16 |
||
2079 | mov edi,[screen_ptr] |
||
2080 | |||
2081 | |||
2082 | push word[zz3] |
||
2083 | push word[zz2] |
||
2084 | push word[zz1] |
||
2085 | call flat_triangle_z |
||
2086 | jmp .end_draw |
||
2087 | |||
2088 | |||
2089 | push [zz3] |
||
2090 | push [zz2] |
||
2091 | push [zz1] |
||
2092 | |||
2093 | |||
2094 | sub esp,12 |
||
2095 | mov edi,esp |
||
2096 | mov ecx,3 |
||
2097 | @@: |
||
2098 | mov eax,dword[esi] |
||
2099 | lea eax,[eax*3] |
||
2100 | shl eax,2 |
||
2101 | add eax,[points_normals_rot_ptr] ;point_normals_rotated |
||
2102 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2103 | fld dword[eax] |
||
2104 | fimul [correct_tex] |
||
2105 | fiadd [correct_tex] |
||
2106 | fistp word[edi] |
||
2107 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2108 | fld dword[eax+4] |
||
2109 | fimul [correct_tex] |
||
2110 | fiadd [correct_tex] |
||
2111 | fistp word[edi+2] |
||
2112 | |||
2113 | |||
2114 | add esi,4 |
||
2115 | loop @b |
||
2116 | |||
2117 | |||
2118 | ror eax,16 |
||
2119 | mov ebx,dword[xx2] |
||
2120 | ror ebx,16 |
||
2121 | mov ecx,dword[xx3] |
||
2122 | ror ecx,16 |
||
2123 | mov edi,[screen_ptr] |
||
2124 | mov esi,envmap |
||
2125 | |||
2126 | |||
2127 | call tex_triangle_z |
||
2128 | |||
2129 | |||
2130 | ;+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
||
2131 | .cubic_env_mapping: |
||
2132 | push [zz3] |
||
2133 | push [zz2] |
||
2134 | push [zz1] |
||
2135 | |||
2136 | |||
2137 | sub esp,12 |
||
2138 | mov edi,esp |
||
2139 | mov ecx,3 |
||
2140 | @@: |
||
2141 | mov eax,dword[esi] |
||
2142 | lea eax,[eax*3] |
||
2143 | shl eax,2 |
||
2144 | add eax,[points_normals_rot_ptr] |
||
2145 | |||
2146 | |||
2147 | fmul dword[eax+4] |
||
2148 | fld1 |
||
2149 | fld1 |
||
2150 | faddp |
||
2151 | fmulp |
||
2152 | fimul [correct_tex] |
||
2153 | fiadd [correct_tex] |
||
2154 | fistp word[edi] |
||
2155 | mov word[edi+2],0 |
||
2156 | ; fistp word[edi+2] |
||
2157 | ; # last change |
||
2158 | ; ; texture x=(rotated point normal -> x * 255)+255 |
||
2159 | ; fld dword[eax] |
||
2160 | ; fimul [correct_tex] |
||
2161 | ; fiadd [correct_tex] |
||
2162 | ; fistp word[edi] |
||
2163 | ; ; texture y=(rotated point normal -> y * 255)+255 |
||
2164 | ; fld dword[eax+4] |
||
2165 | ; fimul [correct_tex] |
||
2166 | ; fiadd [correct_tex] |
||
2167 | ; fistp word[edi+2] |
||
2168 | ; # end of last ch. |
||
2169 | add edi,4 |
||
2170 | add esi,4 |
||
2171 | loop @b |
||
2172 | |||
2173 | |||
2174 | ror eax,16 |
||
2175 | mov ebx,dword[xx2] |
||
2176 | ror ebx,16 |
||
2177 | mov ecx,dword[xx3] |
||
2178 | ror ecx,16 |
||
2179 | mov edi,[screen_ptr] |
||
2180 | mov esi,envmap_cub |
||
2181 | mov edx,[Zbuffer_ptr] |
||
2182 | |||
2183 | |||
2184 | |||
2185 | |||
2186 | |||
2187 | |||
2188 | |||
2189 | |||
2190 | |||
2191 | |||
2192 | push [zz3] |
||
2193 | push [zz2] |
||
2194 | push [zz1] |
||
2195 | |||
2196 | |||
2197 | sub esp,12 |
||
2198 | mov edi,esp |
||
2199 | mov ecx,3 |
||
2200 | @@: |
||
2201 | mov eax,dword[esi] |
||
2202 | lea eax,[eax*3] |
||
2203 | shl eax,2 |
||
2204 | add eax,[points_normals_rot_ptr] ;point_normals_rotated |
||
2205 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2206 | fld dword[eax] |
||
2207 | fimul [correct_tex] |
||
2208 | fiadd [correct_tex] |
||
2209 | fistp word[edi] |
||
2210 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2211 | fld dword[eax+4] |
||
2212 | fimul [correct_tex] |
||
2213 | fiadd [correct_tex] |
||
2214 | fistp word[edi+2] |
||
2215 | |||
2216 | |||
2217 | add esi,4 |
||
2218 | loop @b |
||
2219 | |||
2220 | |||
2221 | shl esi,2 |
||
2222 | add esi,tex_points |
||
2223 | push dword[esi] |
||
2224 | mov esi,[point_index2] |
||
2225 | shl esi,2 |
||
2226 | add esi,tex_points |
||
2227 | ; lea esi,[esi*3] |
||
2228 | ; lea esi,[points+2+esi*2] |
||
2229 | push dword[esi] |
||
2230 | ; push dword[xx2] |
||
2231 | mov esi,[point_index1] |
||
2232 | shl esi,2 |
||
2233 | add esi,tex_points |
||
2234 | ; lea esi,[esi*3] |
||
2235 | ; lea esi,[points+2+esi*2] |
||
2236 | push dword[esi] |
||
2237 | ; push dword[xx1] |
||
2238 | |||
2239 | |||
2240 | ror eax,16 |
||
2241 | mov ebx,dword[xx2] |
||
2242 | ror ebx,16 |
||
2243 | mov ecx,dword[xx3] |
||
2244 | ror ecx,16 |
||
2245 | mov edi,[screen_ptr] |
||
2246 | mov esi,envmap |
||
2247 | mov edx,bumpmap ;BUMP_MAPPING |
||
2248 | |||
2249 | |||
2250 | |||
2251 | |||
2252 | |||
2253 | |||
2254 | |||
2255 | |||
2256 | push [zz2] |
||
2257 | push [zz1] |
||
2258 | ; @@: |
||
2259 | mov esi,[point_index3] ; tex map coords |
||
2260 | shl esi,2 |
||
2261 | add esi,tex_points |
||
2262 | push dword[esi] |
||
2263 | mov esi,[point_index2] |
||
2264 | shl esi,2 |
||
2265 | add esi,tex_points |
||
2266 | push dword[esi] |
||
2267 | mov esi,[point_index1] |
||
2268 | shl esi,2 |
||
2269 | add esi,tex_points |
||
2270 | push dword[esi] |
||
2271 | |||
2272 | |||
2273 | ror eax,16 |
||
2274 | mov ebx,dword[xx2] |
||
2275 | ror ebx,16 |
||
2276 | mov ecx,dword[xx3] |
||
2277 | ror ecx,16 |
||
2278 | mov edi,[screen_ptr] |
||
2279 | mov esi,texmap |
||
2280 | mov edx,[Zbuffer_ptr] |
||
2281 | |||
2282 | |||
2283 | |||
2284 | |||
2285 | ; .ray: |
||
2286 | ; grd_triangle according to points index |
||
2287 | ; cmp [catmull_flag],0 |
||
2288 | ; je @f |
||
2289 | ; push [zz3] ; spot light with attenuation |
||
2290 | ; @@: |
||
2291 | ; movzx eax,[point_index3] ; env_map - points color list |
||
2292 | ; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
||
2293 | ; lea eax,[3*eax+bumpmap] |
||
2294 | ; push word[eax] |
||
2295 | ; push word[eax+2] |
||
2296 | ; push word[eax+4] |
||
2297 | ; cmp [catmull_flag],0 |
||
2298 | ; je @f |
||
2299 | ; push [zz2] |
||
2300 | ; @@: |
||
2301 | ; movzx eax,[point_index2] ; env_map - points color list |
||
2302 | ; shl eax,1 ; each color as word, 0x00rr00gg00bb.. |
||
2303 | ; lea eax,[eax*3+bumpmap] |
||
2304 | ; push word[eax] |
||
2305 | ; push word[eax+2] |
||
2306 | ; push word[eax+4] |
||
2307 | ; cmp [catmull_flag],0 |
||
2308 | ; je @f |
||
2309 | ; push [zz1] |
||
2310 | ; @@: |
||
2311 | ; movzx eax,[point_index1] ; env_map - points color list |
||
2312 | ; shl eax,1 ; each color as word, 0xrr00gg00bb00.. |
||
2313 | ; lea eax,[eax*3+bumpmap] |
||
2314 | ; push word[eax] |
||
2315 | ; push word[eax+2] |
||
2316 | ; push word[eax+4] |
||
2317 | ; jmp .both_draw |
||
2318 | |||
2319 | |||
2320 | push ebp |
||
2321 | mov ebp,esp |
||
2322 | sub esp,4 |
||
2323 | push ebp |
||
2324 | |||
2325 | |||
2326 | shl esi,2 |
||
2327 | add esi,tex_points |
||
2328 | push dword[esi] ; texture coords as first |
||
2329 | mov esi,[point_index2] ; group of parameters |
||
2330 | shl esi,2 |
||
2331 | add esi,tex_points |
||
2332 | push dword[esi] |
||
2333 | mov esi,[point_index1] |
||
2334 | shl esi,2 |
||
2335 | add esi,tex_points |
||
2336 | push dword[esi] |
||
2337 | |||
2338 | |||
2339 | mov ecx,3 |
||
2340 | |||
2341 | |||
2342 | |||
2343 | |||
2344 | push word[edx*2+xx1-2] ; zz1 ,2 ,3 |
||
2345 | fninit |
||
2346 | mov eax,dword[esi] |
||
2347 | shl eax,2 |
||
2348 | lea eax,[eax*3] ;+point_normals_rotated] |
||
2349 | add eax,[points_normals_rot_ptr] |
||
2350 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2351 | fld dword[eax] ; x cooficient of normal vector |
||
2352 | fimul [correct_tex] |
||
2353 | fiadd [correct_tex] |
||
2354 | fistp [temp1] ;word[ebp-2] |
||
2355 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2356 | fld dword[eax+4] ; y cooficient |
||
2357 | fimul [correct_tex] |
||
2358 | fiadd [correct_tex] |
||
2359 | fistp [temp2] ;word[ebp-4] |
||
2360 | |||
2361 | |||
2362 | mov ebx,[temp1] ;word[ebp-2] |
||
2363 | and ebx,0xfffffff ; some onjects need thid 'and' |
||
2364 | shl eax,TEX_SHIFT |
||
2365 | add eax,ebx |
||
2366 | lea eax,[eax*3] |
||
2367 | add eax,color_map |
||
2368 | mov eax,dword[eax] |
||
2369 | |||
2370 | |||
2371 | xor ah,ah |
||
2372 | push ax ;r |
||
2373 | rol eax,8 ; eax-0xggbb00rr -> 0xbb00rrgg |
||
2374 | xor ah,ah |
||
2375 | push ax ;g |
||
2376 | shr eax,24 |
||
2377 | push ax ;b |
||
2378 | |||
2379 | |||
2380 | dec cx |
||
2381 | jnz .aagain_grd_draw |
||
2382 | |||
2383 | |||
2384 | ror eax,16 |
||
2385 | mov ebx,dword[xx2] |
||
2386 | ror ebx,16 |
||
2387 | mov ecx,dword[xx3] |
||
2388 | ror ecx,16 |
||
2389 | mov edi,[screen_ptr] |
||
2390 | mov edx,texmap |
||
2391 | mov esi,[Zbuffer_ptr] |
||
2392 | |||
2393 | |||
2394 | |||
2395 | |||
2396 | mov esp,ebp |
||
2397 | pop ebp |
||
2398 | jmp .end_draw |
||
2399 | |||
2400 | |||
2401 | push [Zbuffer_ptr] |
||
2402 | |||
2403 | |||
2404 | push word[zz2] |
||
2405 | push word[zz1] |
||
2406 | |||
2407 | |||
2408 | shl esi,2 |
||
2409 | add esi,tex_points |
||
2410 | push dword[esi] |
||
2411 | mov esi,[point_index2] |
||
2412 | shl esi,2 |
||
2413 | add esi,tex_points |
||
2414 | push dword[esi] |
||
2415 | mov esi,[point_index1] |
||
2416 | shl esi,2 |
||
2417 | add esi,tex_points |
||
2418 | push dword[esi] |
||
2419 | |||
2420 | |||
2421 | sub esp,12 |
||
2422 | mov edi,esp |
||
2423 | mov ecx,3 |
||
2424 | @@: |
||
2425 | mov eax,dword[esi] |
||
2426 | lea eax,[eax*3] |
||
2427 | shl eax,2 |
||
2428 | add eax,[points_normals_rot_ptr] |
||
2429 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2430 | fld dword[eax] |
||
2431 | fimul [correct_tex] |
||
2432 | fiadd [correct_tex] |
||
2433 | fistp word[edi] |
||
2434 | |||
2435 | |||
2436 | fld dword[eax+4] |
||
2437 | fimul [correct_tex] |
||
2438 | fiadd [correct_tex] |
||
2439 | fistp word[edi+2] |
||
2440 | and word[edi+2],0x7fff ; some objects need it |
||
2441 | add edi,4 |
||
2442 | add esi,4 |
||
2443 | loop @b |
||
2444 | |||
2445 | |||
2446 | ror eax,16 |
||
2447 | mov ebx,dword[xx2] |
||
2448 | ror ebx,16 |
||
2449 | mov ecx,dword[xx3] |
||
2450 | ror ecx,16 |
||
2451 | mov edi,[screen_ptr] |
||
2452 | mov esi,texmap |
||
2453 | mov edx,envmap |
||
2454 | |||
2455 | |||
2456 | jmp .end_draw |
||
2457 | |||
2458 | |||
2459 | mov esi,[point_index3] ; tex map coords |
||
2460 | shl esi,2 |
||
2461 | add esi,tex_points |
||
2462 | push dword[esi] |
||
2463 | mov esi,[point_index2] |
||
2464 | shl esi,2 |
||
2465 | add esi,tex_points |
||
2466 | push dword[esi] |
||
2467 | mov esi,[point_index1] |
||
2468 | shl esi,2 |
||
2469 | add esi,tex_points |
||
2470 | push dword[esi] |
||
2471 | |||
2472 | |||
2473 | |||
2474 | |||
2475 | xor edi,edi |
||
2476 | |||
2477 | |||
2478 | push word[zz2] |
||
2479 | push word[zz1] |
||
2480 | |||
2481 | |||
2482 | sub esp,12 |
||
2483 | mov edi,esp |
||
2484 | mov ecx,3 |
||
2485 | @@: |
||
2486 | mov eax,dword[esi] |
||
2487 | lea eax,[eax*3] |
||
2488 | shl eax,2 |
||
2489 | add eax,[points_normals_rot_ptr] |
||
2490 | ; texture x=(rotated point normal -> x * 255)+255 |
||
2491 | fld dword[eax] |
||
2492 | fimul [correct_tex] |
||
2493 | fiadd [correct_tex] |
||
2494 | fistp word[edi] |
||
2495 | ; texture y=(rotated point normal -> y * 255)+255 |
||
2496 | fld dword[eax+4] |
||
2497 | fimul [correct_tex] |
||
2498 | fiadd [correct_tex] |
||
2499 | fistp word[edi+2] |
||
2500 | |||
2501 | |||
2502 | add esi,4 |
||
2503 | loop @b |
||
2504 | |||
2505 | |||
2506 | ; push dword 127 shl 16 + 1 |
||
2507 | ; push dword 127 shl 16 + 127 |
||
2508 | |||
2509 | |||
2510 | shl esi,2 |
||
2511 | add esi,tex_points |
||
2512 | push dword[esi] |
||
2513 | mov esi,[point_index2] |
||
2514 | shl esi,2 |
||
2515 | add esi,tex_points |
||
2516 | push dword[esi] |
||
2517 | |||
2518 | |||
2519 | shl esi,2 |
||
2520 | add esi,tex_points |
||
2521 | push dword[esi] |
||
2522 | |||
2523 | |||
2524 | ; push dword 127 shl 16 + 127 |
||
2525 | ; push dword 1 shl 16 + 1 ; bump coords |
||
2526 | |||
2527 | |||
2528 | ror eax,16 |
||
2529 | mov ebx,dword[xx2] |
||
2530 | ror ebx,16 |
||
2531 | mov ecx,dword[xx3] |
||
2532 | ror ecx,16 |
||
2533 | mov edi,[screen_ptr] |
||
2534 | mov esi,envmap |
||
2535 | mov edx,bumpmap |
||
2536 | |||
2537 | |||
2538 | |||
2539 | |||
2540 | |||
2541 | |||
2542 | |||
2543 | .r_phg: |
||
2544 | |||
2545 | |||
2546 | |||
2547 | punpcklwd xmm5,[the_zero] |
||
2548 | pshufd xmm5,xmm5,01110011b |
||
2549 | |||
2550 | |||
2551 | |||
2552 | mov ebx,[point_index2] |
||
2553 | mov ecx,[point_index3] |
||
2554 | imul eax,[i12] |
||
2555 | imul ebx,[i12] |
||
2556 | imul ecx,[i12] |
||
2557 | add eax,[points_normals_rot_ptr] |
||
2558 | add ebx,[points_normals_rot_ptr] |
||
2559 | add ecx,[points_normals_rot_ptr] |
||
2560 | movups xmm0,[eax] |
||
2561 | movups xmm1,[ebx] |
||
2562 | movups xmm2,[ecx] |
||
2563 | andps xmm0,[zero_hgst_dd] |
||
2564 | andps xmm1,[zero_hgst_dd] |
||
2565 | andps xmm2,[zero_hgst_dd] |
||
2566 | xorps xmm3,xmm3 |
||
2567 | |||
2568 | |||
2569 | mov ebx,[point_index2] |
||
2570 | mov ecx,[point_index3] |
||
2571 | imul eax,[i12] |
||
2572 | imul ebx,[i12] |
||
2573 | imul ecx,[i12] |
||
2574 | add eax,[points_rotated_ptr] |
||
2575 | add ebx,[points_rotated_ptr] |
||
2576 | add ecx,[points_rotated_ptr] |
||
2577 | push dword[ecx+8] |
||
2578 | push dword[ebx+8] |
||
2579 | push dword[eax+8] |
||
2580 | movups xmm4,[esp] |
||
2581 | add esp,12 |
||
2582 | andps xmm4,[zero_hgst_dd] |
||
2583 | |||
2584 | |||
2585 | |||
2586 | |||
2587 | ror eax,16 |
||
2588 | mov ebx,dword[xx2] |
||
2589 | ror ebx,16 |
||
2590 | mov ecx,dword[xx3] |
||
2591 | ror ecx,16 |
||
2592 | mov edi,[screen_ptr] |
||
2593 | mov esi,[Zbuffer_ptr] |
||
2594 | |||
2595 | |||
2596 | |||
2597 | |||
2598 | |||
2599 | |||
2600 | movd xmm5,[size_y_var] |
||
2601 | punpcklwd xmm5,[the_zero] |
||
2602 | pshufd xmm5,xmm5,01110011b |
||
2603 | |||
2604 | |||
2605 | |||
2606 | mov ebx ,[point_index2] |
||
2607 | mov ecx,[point_index3] |
||
2608 | imul eax,[i12] |
||
2609 | imul ebx,[i12] |
||
2610 | imul ecx,[i12] |
||
2611 | add eax,[points_normals_rot_ptr] |
||
2612 | add ebx,[points_normals_rot_ptr] |
||
2613 | add ecx,[points_normals_rot_ptr] |
||
2614 | movups xmm0,[eax] |
||
2615 | movups xmm1,[ebx] |
||
2616 | movups xmm2,[ecx] |
||
2617 | andps xmm0,[zero_hgst_dd] |
||
2618 | andps xmm1,[zero_hgst_dd] |
||
2619 | andps xmm2,[zero_hgst_dd] |
||
2620 | xorps xmm3,xmm3 |
||
2621 | |||
2622 | |||
2623 | mov ebx,[point_index2] |
||
2624 | mov ecx,[point_index3] |
||
2625 | imul eax,[i12] |
||
2626 | imul ebx,[i12] |
||
2627 | imul ecx,[i12] |
||
2628 | add eax,[points_rotated_ptr] |
||
2629 | add ebx,[points_rotated_ptr] |
||
2630 | add ecx,[points_rotated_ptr] |
||
2631 | push dword[ecx+8] |
||
2632 | push dword[ebx+8] |
||
2633 | push dword[eax+8] |
||
2634 | movups xmm4,[esp] |
||
2635 | add esp,12 |
||
2636 | andps xmm4,[zero_hgst_dd] |
||
2637 | |||
2638 | |||
2639 | |||
2640 | |||
2641 | ror eax,16 |
||
2642 | mov ebx,dword[xx2] |
||
2643 | ror ebx,16 |
||
2644 | mov ecx,dword[xx3] |
||
2645 | ror ecx,16 |
||
2646 | mov edi,[screen_ptr] |
||
2647 | mov edx,[Zbuffer_ptr] |
||
2648 | mov esi,[Zbuffer_ptr] |
||
2649 | |||
2650 | |||
2651 | jmp .end_draw |
||
2652 | |||
2653 | |||
2654 | |||
2655 | movd xmm5,[size_y_var] |
||
2656 | punpcklwd xmm5,[the_zero] |
||
2657 | pshufd xmm5,xmm5,01110011b |
||
2658 | |||
2659 | |||
2660 | mov ebx,[point_index2] |
||
2661 | mov ecx,[point_index3] |
||
2662 | imul eax,[i12] |
||
2663 | imul ebx,[i12] |
||
2664 | imul ecx,[i12] |
||
2665 | add eax,[points_normals_rot_ptr] |
||
2666 | add ebx,[points_normals_rot_ptr] |
||
2667 | add ecx,[points_normals_rot_ptr] |
||
2668 | movups xmm0,[eax] |
||
2669 | movups xmm1,[ebx] |
||
2670 | movups xmm2,[ecx] |
||
2671 | andps xmm0,[zero_hgst_dd] |
||
2672 | andps xmm1,[zero_hgst_dd] |
||
2673 | andps xmm2,[zero_hgst_dd] |
||
2674 | xorps xmm3,xmm3 |
||
2675 | |||
2676 | |||
2677 | mov ebx,[point_index2] |
||
2678 | mov ecx,[point_index3] |
||
2679 | imul eax,[i12] |
||
2680 | imul ebx,[i12] |
||
2681 | imul ecx,[i12] |
||
2682 | add eax,[points_rotated_ptr] |
||
2683 | add ebx,[points_rotated_ptr] |
||
2684 | add ecx,[points_rotated_ptr] |
||
2685 | push dword[ecx+8] |
||
2686 | push dword[ebx+8] |
||
2687 | push dword[eax+8] |
||
2688 | movups xmm4,[esp] |
||
2689 | add esp,12 |
||
2690 | andps xmm4,[zero_hgst_dd] |
||
2691 | |||
2692 | |||
2693 | shl esi,2 |
||
2694 | add esi,tex_points |
||
2695 | push dword[esi] |
||
2696 | mov esi,[point_index2] |
||
2697 | shl esi,2 |
||
2698 | add esi,tex_points |
||
2699 | push dword[esi] |
||
2700 | mov esi,[point_index1] |
||
2701 | shl esi,2 |
||
2702 | add esi,tex_points |
||
2703 | push dword[esi] |
||
2704 | movups xmm6,[esp] |
||
2705 | add esp,12 |
||
2706 | ; pshuflw xmm6,xmm6,10110001b |
||
2707 | ; pshufhw xmm6,xmm6,10110001b |
||
2708 | |||
2709 | |||
2710 | andps xmm6,[zero_hgst_dd] |
||
2711 | movd xmm7,eax |
||
2712 | pslldq xmm7,12 |
||
2713 | por xmm6,xmm7 |
||
2714 | |||
2715 | |||
2716 | |||
2717 | ror eax,16 |
||
2718 | mov ebx,dword[xx2] |
||
2719 | ror ebx,16 |
||
2720 | mov ecx,dword[xx3] |
||
2721 | ror ecx,16 |
||
2722 | mov edx,texmap |
||
2723 | mov edi,[screen_ptr] |
||
2724 | mov esi,[Zbuffer_ptr] |
||
2725 | |||
2726 | |||
2727 | |||
2728 | |||
2729 | |||
2730 | |||
2731 | |||
2732 | |||
2733 | pop esi |
||
2734 | add esi,12 |
||
2735 | |||
2736 | |||
2737 | dec ecx |
||
2738 | |||
2739 | |||
2740 | ret |
||
2741 | |||
2742 | |||
2743 | |||
2744 | mov esi,[edges_ptr] |
||
2745 | xor ecx,ecx |
||
2746 | .again_s_line: |
||
2747 | push ecx |
||
2748 | push esi |
||
2749 | |||
2750 | |||
2751 | .aga_n: |
||
2752 | mov eax,[esi] |
||
2753 | shl eax,2 |
||
2754 | lea eax,[eax*3] |
||
2755 | add eax,[points_normals_rot_ptr] |
||
2756 | movups xmm0,[eax] |
||
2757 | xorps xmm1,xmm1 |
||
2758 | mov edx,lights_aligned |
||
2759 | .again_cc: |
||
2760 | movaps xmm3,xmm0 ;.cnv |
||
2761 | mulps xmm3,[edx] |
||
2762 | andps xmm3,[zero_hgst_dd] |
||
2763 | ; haddps xmm3,xmm3 |
||
2764 | ; haddps xmm3,xmm3 ; xmm3 - dot pr |
||
2765 | movhlps xmm2,xmm3 |
||
2766 | addps xmm3,xmm2 |
||
2767 | movdqa xmm2,xmm3 |
||
2768 | shufps xmm2,xmm2,01010101b |
||
2769 | addps xmm3,xmm2 |
||
2770 | shufps xmm3,xmm3,0 |
||
2771 | movaps xmm6,xmm3 ;xmm7 |
||
2772 | mulps xmm6,xmm6 |
||
2773 | mulps xmm6,xmm6 |
||
2774 | mulps xmm6,xmm6 |
||
2775 | mulps xmm6,xmm6 |
||
2776 | mulps xmm6,xmm6 |
||
2777 | mulps xmm6,[edx+48] |
||
2778 | movaps xmm7,xmm3 |
||
2779 | mulps xmm7,[edx+16] |
||
2780 | addps xmm7,xmm6 |
||
2781 | addps xmm7,[edx+32] |
||
2782 | minps xmm7,[mask_255f] ; global |
||
2783 | |||
2784 | |||
2785 | add edx,64 ; size of one light in aligned list |
||
2786 | cmp edx,lights_aligned_end |
||
2787 | jl .again_cc |
||
2788 | sub esp,16 |
||
2789 | movups [esp],xmm1 |
||
2790 | add esi,4 |
||
2791 | loop .aga_n |
||
2792 | |||
2793 | |||
2794 | movups xmm1,[esp+16] |
||
2795 | add esp,32 |
||
2796 | sub esi,8 |
||
2797 | |||
2798 | |||
2799 | mov edx,[esi+4] |
||
2800 | imul ecx,[i6] |
||
2801 | imul edx,[i6] |
||
2802 | add ecx,[points_translated_ptr] |
||
2803 | add edx,[points_translated_ptr] |
||
2804 | |||
2805 | |||
2806 | movhps xmm7,[edx] |
||
2807 | pshufd xmm7,xmm7,11101000b |
||
2808 | movdqa xmm6,xmm7 |
||
2809 | movd xmm5,[size_y_var] |
||
2810 | pshuflw xmm5,xmm5,00010001b |
||
2811 | pcmpgtw xmm7,xmm5 |
||
2812 | pcmpgtw xmm6,[the_zero] |
||
2813 | pxor xmm7,xmm6 |
||
2814 | pmovmskb eax,xmm7 |
||
2815 | cmp al,-1 |
||
2816 | jnz .skp |
||
2817 | |||
2818 | |||
2819 | |||
2820 | |||
2821 | |||
2822 | mov ebx,[esi+4] |
||
2823 | imul eax,[i12] |
||
2824 | imul ebx,[i12] |
||
2825 | add eax,[points_rotated_ptr] |
||
2826 | add ebx,[points_rotated_ptr] |
||
2827 | movss xmm2,[eax+8] |
||
2828 | movss xmm3,[ebx+8] |
||
2829 | |||
2830 | |||
2831 | |||
2832 | movzx ebx,word[ecx+2] |
||
2833 | movzx ecx,word[edx] |
||
2834 | movzx edx,word[edx+2] |
||
2835 | |||
2836 | |||
2837 | movd mm1,[screen_ptr] |
||
2838 | movd mm0,[Zbuffer_ptr] |
||
2839 | movzx esi,word[size_x_var] |
||
2840 | movd mm2,esi |
||
2841 | |||
2842 | |||
2843 | call line_grd |
||
2844 | pop ebp |
||
2845 | .skp: |
||
2846 | pop esi |
||
2847 | pop ecx |
||
2848 | add esi,8 |
||
2849 | inc ecx |
||
2850 | cmp ecx,[edges_count] |
||
2851 | jnz .again_s_line |
||
2852 | |||
2853 | |||
2854 | |||
2855 | |||
2856 | |||
2857 | |||
2858 | |||
2859 | |||
2860 | |||
2861 | |||
2862 | |||
2863 | mov ebp,esp |
||
2864 | |||
2865 | |||
2866 | .xres3m18 equ ebp-8 |
||
2867 | .xres2m12 equ ebp-12 |
||
2868 | |||
2869 | |||
2870 | |||
2871 | sub esp,12 |
||
2872 | push dword 0 |
||
2873 | |||
2874 | |||
2875 | cmp [dr_flag],12 |
||
2876 | jge @f |
||
2877 | lea ebx,[eax*3] |
||
2878 | sub ebx,18 |
||
2879 | add eax,eax |
||
2880 | sub eax,12 |
||
2881 | mov [.xres3m18],ebx |
||
2882 | mov [.xres2m12],eax |
||
2883 | jmp .f |
||
2884 | @@: |
||
2885 | lea ebx,[eax*4] |
||
2886 | sub ebx,4*6 |
||
2887 | add eax,eax |
||
2888 | sub eax,3*4 |
||
2889 | mov [.xres3m18],ebx |
||
2890 | mov [.xres2m12],eax |
||
2891 | .f: |
||
2892 | |||
2893 | |||
2894 | |||
2895 | |||
2896 | .loop: |
||
2897 | push esi |
||
2898 | ; DO culling AT FIRST |
||
2899 | cmp [culling_flag],1 ; (if culling_flag = 1) |
||
2900 | jne .no_culling |
||
2901 | mov edi,[.counter] ; ********************************* |
||
2902 | lea edi,[edi*3] |
||
2903 | shl edi,2 |
||
2904 | add edi,[points_normals_rot_ptr] |
||
2905 | mov eax,[edi+8] ; check sign of z coof |
||
2906 | shr eax,31 |
||
2907 | cmp eax,1 |
||
2908 | jnz .skip |
||
2909 | .no_culling: |
||
2910 | mov eax,[esi] |
||
2911 | movzx ebx,ax ; ebx - x |
||
2912 | shr eax,16 ; eax - y |
||
2913 | cmp eax,4 ; check if markers not exceedes screen |
||
2914 | jle .skip |
||
2915 | cmp ebx,4 |
||
2916 | jle .skip |
||
2917 | movzx edx,word[size_x_var] |
||
2918 | sub edx,4 |
||
2919 | movzx ecx,word[size_y_var] |
||
2920 | sub ecx,4 |
||
2921 | cmp ebx,edx |
||
2922 | jge .skip |
||
2923 | cmp eax,ecx |
||
2924 | jge .skip |
||
2925 | |||
2926 | |||
2927 | ; sub ebx,3 |
||
2928 | ; sub eax,3 |
||
2929 | imul eax,edx |
||
2930 | add eax,ebx |
||
2931 | push eax |
||
2932 | lea edi,[eax*3] |
||
2933 | cmp [dr_flag],12 |
||
2934 | jl @f |
||
2935 | add edi,[esp] |
||
2936 | @@: |
||
2937 | add esp,4 |
||
2938 | lea eax,[eax*2] |
||
2939 | ; draw bar 6x6 |
||
2940 | add edi,[screen_ptr] |
||
2941 | add eax,dword[vertices_index_ptr] |
||
2942 | |||
2943 | |||
2944 | |||
2945 | |||
2946 | |||
2947 | mov ecx,6 |
||
2948 | |||
2949 | |||
2950 | push ecx |
||
2951 | mov ecx,6 |
||
2952 | |||
2953 | |||
2954 | mov word[edi],0x0000 ;ax |
||
2955 | mov byte[edi+2],0xff ;al |
||
2956 | mov word[eax],dx |
||
2957 | add eax,2 |
||
2958 | cmp [dr_flag],12 |
||
2959 | jl @f |
||
2960 | add edi,4 |
||
2961 | loop .do |
||
2962 | jmp .ad |
||
2963 | @@: |
||
2964 | add edi,3 |
||
2965 | loop .do |
||
2966 | .ad: |
||
2967 | add edi,[.xres3m18] |
||
2968 | add eax,[.xres2m12] |
||
2969 | pop ecx |
||
2970 | loop .oop |
||
2971 | |||
2972 | |||
2973 | pop esi |
||
2974 | add esi,6 |
||
2975 | inc dword[.counter] |
||
2976 | mov ecx,[.counter] |
||
2977 | cmp ecx,[points_count_var] |
||
2978 | jng .loop |
||
2979 | |||
2980 | |||
2981 | pop ebp |
||
2982 | |||
2983 | |||
2984 | |||
2985 | |||
2986 | |||
2987 | mov eax,0x70000000 |
||
2988 | cmp [dr_flag],11 |
||
2989 | jl @f |
||
2990 | mov eax,60000.1 |
||
2991 | @@: |
||
2992 | mov edi,[Zbuffer_ptr] |
||
2993 | movzx ecx,word[size_x_var] |
||
2994 | movzx ebx,word[size_y_var] |
||
2995 | imul ecx,ebx |
||
2996 | if Ext>=SSE2 |
||
2997 | movd xmm0,eax |
||
2998 | shufps xmm0,xmm0,0 |
||
2999 | push ecx |
||
3000 | mov ecx,edi |
||
3001 | and edi,0xffffff00 |
||
3002 | and ecx,0x000000ff |
||
3003 | mov edx,ecx |
||
3004 | rep stosd |
||
3005 | pop ecx |
||
3006 | sub ecx,edx |
||
3007 | @@: |
||
3008 | movaps [edi],xmm0 |
||
3009 | movaps [edi+16],xmm0 |
||
3010 | movaps [edi+32],xmm0 |
||
3011 | movaps [edi+48],xmm0 |
||
3012 | add edi,64 |
||
3013 | sub ecx,16 |
||
3014 | jnc @b |
||
3015 | else |
||
3016 | rep stosd |
||
3017 | end if |
||
3018 | ret |
||
3019 | |||
3020 | |||
3021 | ; and allocate memory |
||
3022 | xor ebx,ebx |
||
3023 | xor ebp,ebp |
||
3024 | mov [points_count_var],ebx |
||
3025 | mov [triangles_count_var],ebx |
||
3026 | if USE_LFN = 0 |
||
3027 | mov esi,SourceFile |
||
3028 | else |
||
3029 | mov esi,[fptr] |
||
3030 | end if |
||
3031 | |||
3032 | |||
3033 | je @f ;Must be legal .3DS file |
||
3034 | xor eax,eax |
||
3035 | ret |
||
3036 | @@: |
||
3037 | mov eax,dword[esi+2] |
||
3038 | cmp eax,[fsize] ;This must tell the length |
||
3039 | je @f |
||
3040 | xor eax,eax |
||
3041 | ret |
||
3042 | @@: |
||
3043 | add eax,esi |
||
3044 | mov [EndFile],eax ; |
||
3045 | |||
3046 | |||
3047 | @@: |
||
3048 | cmp [esi],word 3D3Dh |
||
3049 | je @f |
||
3050 | add esi,[esi+2] |
||
3051 | jmp @b |
||
3052 | @@: |
||
3053 | add esi,6 |
||
3054 | .find4k: |
||
3055 | cmp [esi],word 4000h |
||
3056 | je @f |
||
3057 | add esi,[esi+2] |
||
3058 | cmp esi,[EndFile] |
||
3059 | jc .find4k |
||
3060 | jmp .exit |
||
3061 | @@: |
||
3062 | add esi,6 |
||
3063 | @@: |
||
3064 | cmp [esi],byte 0 |
||
3065 | je @f |
||
3066 | inc esi |
||
3067 | jmp @b |
||
3068 | @@: |
||
3069 | inc esi |
||
3070 | @@: |
||
3071 | cmp [esi],word 4100h |
||
3072 | je @f |
||
3073 | add esi,[esi+2] |
||
3074 | jmp @b |
||
3075 | @@: |
||
3076 | add esi,6 |
||
3077 | @@: |
||
3078 | cmp [esi],word 4110h |
||
3079 | je @f |
||
3080 | add esi,[esi+2] |
||
3081 | jmp @b |
||
3082 | @@: |
||
3083 | movzx ecx,word[esi+6] |
||
3084 | add [points_count_var],ecx |
||
3085 | |||
3086 | |||
3087 | add esi,8 |
||
3088 | @@: |
||
3089 | |||
3090 | |||
3091 | add esi,12 |
||
3092 | ; dec ecx |
||
3093 | loop @b |
||
3094 | @@: |
||
3095 | |||
3096 | |||
3097 | cmp [esi],word 4120h |
||
3098 | je @f |
||
3099 | add esi,[esi+2] |
||
3100 | jmp @b |
||
3101 | @@: |
||
3102 | movzx ecx,word[esi+6] |
||
3103 | add [triangles_count_var],ecx |
||
3104 | add esi,8 |
||
3105 | |||
3106 | |||
3107 | add esi,8 |
||
3108 | dec ecx |
||
3109 | jnz @b |
||
3110 | ; xor ecx,ecx |
||
3111 | add ebp,edx |
||
3112 | jmp .find4k |
||
3113 | mov eax,-1 ;<---mark if OK |
||
3114 | .exit: |
||
3115 | ret |
||
3116 | |||
3117 | |||
3118 | fninit |
||
3119 | mov edi,[triangles_ptr] |
||
3120 | xor ebx,ebx |
||
3121 | xor ebp,ebp |
||
3122 | mov [points_count_var],0 |
||
3123 | mov [triangles_count_var],0 |
||
3124 | mov esi,[fptr] |
||
3125 | cmp [esi],word 4D4Dh |
||
3126 | jne .exit ;Must be legal .3DS file |
||
3127 | ; cmp dword[esi+2],EndFile-SourceFile |
||
3128 | ; jne .exit ;This must tell the length |
||
3129 | mov eax,dword[esi+2] |
||
3130 | ; cmp eax,[fsize] |
||
3131 | ; jne .exit |
||
3132 | |||
3133 | |||
3134 | mov [EndFile],eax ; |
||
3135 | |||
3136 | |||
3137 | @@: |
||
3138 | cmp [esi],word 3D3Dh |
||
3139 | je @f |
||
3140 | add esi,[esi+2] |
||
3141 | jmp @b |
||
3142 | @@: |
||
3143 | add esi,6 |
||
3144 | .find4k: |
||
3145 | cmp [esi],word 4000h |
||
3146 | je @f |
||
3147 | add esi,[esi+2] |
||
3148 | cmp esi,[EndFile] |
||
3149 | jc .find4k |
||
3150 | jmp .exit |
||
3151 | @@: |
||
3152 | add esi,6 |
||
3153 | @@: |
||
3154 | cmp [esi],byte 0 |
||
3155 | je @f |
||
3156 | inc esi |
||
3157 | jmp @b |
||
3158 | @@: |
||
3159 | inc esi |
||
3160 | @@: |
||
3161 | cmp [esi],word 4100h |
||
3162 | je @f |
||
3163 | add esi,[esi+2] |
||
3164 | jmp @b |
||
3165 | @@: |
||
3166 | add esi,6 |
||
3167 | @@: |
||
3168 | cmp [esi],word 4110h |
||
3169 | je @f |
||
3170 | add esi,[esi+2] |
||
3171 | jmp @b |
||
3172 | @@: |
||
3173 | movzx ecx,word[esi+6] |
||
3174 | add [points_count_var],ecx |
||
3175 | |||
3176 | |||
3177 | add esi,8 |
||
3178 | @@: |
||
3179 | push edi |
||
3180 | mov edi,[points_ptr] |
||
3181 | push dword[esi+0] |
||
3182 | pop dword[edi+ebx*2+0] |
||
3183 | push dword[esi+4] |
||
3184 | pop dword[edi+ebx*2+4] |
||
3185 | push dword[esi+8] |
||
3186 | pop dword[edi+ebx*2+8] |
||
3187 | pop edi |
||
3188 | |||
3189 | |||
3190 | add esi,12 |
||
3191 | dec ecx |
||
3192 | jnz @b |
||
3193 | @@: |
||
3194 | ; mov dword[points+ebx],-1 |
||
3195 | push edi |
||
3196 | mov edi,[points_ptr] |
||
3197 | mov dword[edi+ebx*2],-1 ; end mark (not always in use) |
||
3198 | pop edi |
||
3199 | @@: |
||
3200 | cmp [esi],word 4120h |
||
3201 | je @f |
||
3202 | add esi,[esi+2] |
||
3203 | jmp @b |
||
3204 | @@: |
||
3205 | movzx ecx,word[esi+6] |
||
3206 | add [triangles_count_var],ecx |
||
3207 | add esi,8 |
||
3208 | ;mov edi,triangles |
||
3209 | @@: |
||
3210 | movzx eax,word[esi] |
||
3211 | stosd |
||
3212 | movzx eax,word[esi+2] |
||
3213 | stosd |
||
3214 | movzx eax,word[esi+4] |
||
3215 | stosd |
||
3216 | add dword[edi-12],ebp |
||
3217 | add dword[edi-8],ebp |
||
3218 | add dword[edi-4],ebp |
||
3219 | add esi,8 |
||
3220 | dec ecx |
||
3221 | jnz @b |
||
3222 | add ebp,edx |
||
3223 | jmp .find4k |
||
3224 | mov eax,-1 ;<---mark if OK |
||
3225 | .exit: |
||
3226 | mov dword[edi],-1 |
||
3227 | ret |
||
3228 | |||
3229 | |||
3230 | mov eax, 68 |
||
3231 | cmp [re_alloc_flag],1 |
||
3232 | jz @f |
||
3233 | mov ebx, 12 |
||
3234 | jmp .alloc |
||
3235 | @@: |
||
3236 | mov ebx,20 |
||
3237 | .alloc: |
||
3238 | |||
3239 | |||
3240 | add ecx,20 |
||
3241 | lea ecx, [ecx*3] |
||
3242 | shl ecx,2 |
||
3243 | mov edx,[triangles_ptr] |
||
3244 | int 0x40 ; -> allocate memory to triangles |
||
3245 | mov [triangles_ptr], eax ; -> eax = pointer to allocated mem |
||
3246 | |||
3247 | |||
3248 | mov ecx,[triangles_count_var] |
||
3249 | imul ecx,[i36] |
||
3250 | mov edx,[edges_ptr] |
||
3251 | int 0x40 ; -> allocate memory to triangles |
||
3252 | mov [edges_ptr], eax ; -> eax = pointer to allocated mem |
||
3253 | |||
3254 | |||
3255 | |||
3256 | |||
3257 | |||
3258 | mov ecx, [triangles_count_var] |
||
3259 | lea ecx, [3+ecx*3] |
||
3260 | shl ecx, 2 |
||
3261 | mov edx,[triangles_normals_ptr] |
||
3262 | int 0x40 ; -> allocate memory for triangles normals |
||
3263 | mov [triangles_normals_ptr], eax ; -> eax = pointer to allocated mem |
||
3264 | |||
3265 | |||
3266 | |||
3267 | mov ecx, [points_count_var] |
||
3268 | lea ecx,[3+ecx*3] |
||
3269 | shl ecx, 2 |
||
3270 | mov edx,[points_normals_ptr] |
||
3271 | int 0x40 |
||
3272 | mov [points_normals_ptr], eax |
||
3273 | |||
3274 | |||
3275 | |||
3276 | ; mov ebx, 12 |
||
3277 | mov ecx, [points_count_var] |
||
3278 | lea ecx,[3+ecx*3] |
||
3279 | shl ecx, 2 |
||
3280 | mov edx,[points_normals_rot_ptr] |
||
3281 | int 0x40 |
||
3282 | mov [points_normals_rot_ptr], eax |
||
3283 | |||
3284 | |||
3285 | mov edx,[points_ptr] |
||
3286 | int 0x40 |
||
3287 | mov [points_ptr], eax |
||
3288 | |||
3289 | |||
3290 | mov edx,[points_rotated_ptr] |
||
3291 | int 0x40 |
||
3292 | mov [points_rotated_ptr], eax |
||
3293 | |||
3294 | |||
3295 | mov ecx, [points_count_var] |
||
3296 | inc ecx |
||
3297 | shl ecx, 3 |
||
3298 | mov edx,[points_translated_ptr] |
||
3299 | int 0x40 |
||
3300 | mov [points_translated_ptr], eax |
||
3301 | ret |
||
3302 | |||
3303 | |||
3304 | |||
3305 | |||
3306 | mov eax, 68 |
||
3307 | mov ebx, 11 |
||
3308 | int 0x40 ; -> create heap |
||
3309 | |||
3310 | |||
3311 | mov eax,68 |
||
3312 | mov ebx,27 |
||
3313 | mov ecx,file_name |
||
3314 | int 0x40 |
||
3315 | |||
3316 | |||
3317 | mov [file_info+16],eax |
||
3318 | |||
3319 | |||
3320 | jnz .open_opened_well |
||
3321 | mov eax,6 ;otherwise => failed |
||
3322 | jmp @f |
||
3323 | .open_opened_well: |
||
3324 | xor eax,eax |
||
3325 | @@: |
||
3326 | ; eax = 0 -> ok file loaded |
||
3327 | ret |
||
3328 | read_param: |
||
3329 | mov esi,I_Param |
||
3330 | cmp dword[esi],0 |
||
3331 | je .end |
||
3332 | cmp byte[esi],'/' |
||
3333 | je .copy |
||
3334 | mov edi,esi |
||
3335 | mov ecx,25 ; 25 - would be enought |
||
3336 | repe scasb |
||
3337 | jne .end |
||
3338 | dec edi |
||
3339 | mov esi,edi |
||
3340 | .copy: |
||
3341 | mov edi,file_name |
||
3342 | mov ecx,50 |
||
3343 | rep movsd |
||
3344 | .end: |
||
3345 | ret |
||
3346 | buttons: ; draw some buttons (all but navigation and close ) |
||
3347 | mov edi,menu |
||
3348 | .again: |
||
3349 | mov eax,8 ; function 8 : define and draw button |
||
3350 | mov bx,[size_x_var] |
||
3351 | shl ebx,16 |
||
3352 | add ebx,(10)*65536+62 ; [x start] *65536 + [x size] |
||
3353 | movzx ecx,byte[edi] ; button id = position+2 |
||
3354 | sub cl,2 |
||
3355 | lea ecx,[ecx*5] |
||
3356 | lea ecx,[ecx*3] |
||
3357 | add ecx,25 |
||
3358 | shl ecx,16 |
||
3359 | add ecx,12 |
||
3360 | movzx edx,byte[edi] ; button id |
||
3361 | mov esi,0x6688dd ; button color RRGGBB |
||
3362 | int 0x40 |
||
3363 | ; BUTTON LABEL |
||
3364 | mov eax,4 ; function 4 : write text to window |
||
3365 | movzx ebx,byte[edi] |
||
3366 | sub bl,2 ; button id, according to position |
||
3367 | lea ebx,[ebx*3] |
||
3368 | lea ebx,[ebx*5] |
||
3369 | mov cx,[size_x_var] |
||
3370 | shl ecx,16 |
||
3371 | add ebx,ecx |
||
3372 | add ebx,(12)*65536+28 ; [x start] *65536 + [y start] |
||
3373 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3374 | lea edx,[edi+1] ; pointer to text beginning |
||
3375 | mov esi,10 ; text length |
||
3376 | int 0x40 |
||
3377 | cmp byte[edi+11],255 ; if max_flag=255 |
||
3378 | je @f ; skip |
||
3379 | ; flag description |
||
3380 | ; mov eax,4 ; function 4 : write text to window |
||
3381 | ; movzx ebx,byte[edi] |
||
3382 | ; sub bl,2 |
||
3383 | ; lea ebx,[ebx*3] |
||
3384 | ; lea ebx,[ebx*5] |
||
3385 | ; add ebx,(SIZE_X+12+70)*65536+28 ; [x start] *65536 + [y start] |
||
3386 | add ebx,70*65536 |
||
3387 | ; mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3388 | movzx edx,byte[edi+12] ; current flag |
||
3389 | shl edx,2 ; * 4 = text length |
||
3390 | add edx,dword[edi+13] ; pointer to text beginning |
||
3391 | mov esi,4 ; text length |
||
3392 | int 0x40 |
||
3393 | |||
3394 | |||
3395 | add edi,17 |
||
3396 | cmp byte[edi],-1 |
||
3397 | jnz .again |
||
3398 | ret |
||
3399 | write_info: |
||
3400 | mov eax,13 |
||
3401 | mov bx,[size_x_var] |
||
3402 | shl ebx,16 |
||
3403 | add ebx,120*65536+70 ; [x start] *65536 + [y start] |
||
3404 | mov ecx,30 shl 16 + 100 |
||
3405 | xor edx,edx |
||
3406 | int 0x40 |
||
3407 | |||
3408 | |||
3409 | |||
3410 | emms |
||
3411 | movd mm7,esi |
||
3412 | .nxxx: |
||
3413 | push esi |
||
3414 | movd mm7,esi |
||
3415 | |||
3416 | |||
3417 | movzx ebx,word[size_x_var] |
||
3418 | shl ebx,16 |
||
3419 | add ebx,120*65536 ; [x start] *65536 + [y start] |
||
3420 | mov bx,si |
||
3421 | shl bx,3 |
||
3422 | add ebx,30 |
||
3423 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3424 | movd edx,mm7 |
||
3425 | shl edx,2 |
||
3426 | add edx,lab_vert ; pointer to text beginning |
||
3427 | mov esi,lab_vert_end-lab_vert ; text length |
||
3428 | int 0x40 |
||
3429 | |||
3430 | |||
3431 | mov eax,[points_count_var+esi] |
||
3432 | mov ecx,10 |
||
3433 | .dc: |
||
3434 | xor edx,edx |
||
3435 | mov edi,10 |
||
3436 | div edi |
||
3437 | add dl,30h |
||
3438 | mov [STRdata+ecx-1],dl |
||
3439 | loop .dc |
||
3440 | |||
3441 | |||
3442 | mov bx,[size_x_var] |
||
3443 | add ebx,120 |
||
3444 | shl ebx,16 |
||
3445 | mov bx,si ; [x start] *65536 + [y start] |
||
3446 | shl bx,3 |
||
3447 | add bx,45 |
||
3448 | mov ecx,0x00ddeeff |
||
3449 | mov edx,STRdata ; pointer to text beginning |
||
3450 | mov esi,10 ; text length |
||
3451 | int 40h |
||
3452 | pop esi |
||
3453 | add esi,4 |
||
3454 | cmp esi,12 |
||
3455 | jnz .nxxx |
||
3456 | ret |
||
3457 | ; ********************************************* |
||
3458 | ; ******* WINDOW DEFINITIONS AND DRAW ******** |
||
3459 | ; ********************************************* |
||
3460 | draw_window: |
||
3461 | mov eax,12 ; function 12:tell os about windowdraw |
||
3462 | mov ebx,1 ; 1, start of draw |
||
3463 | int 0x40 |
||
3464 | |||
3465 | |||
3466 | mov eax,0 ; function 0 : define and draw window |
||
3467 | mov bx,[x_start] |
||
3468 | shl ebx,16 |
||
3469 | mov cx,[y_start] |
||
3470 | shl ecx,16 |
||
3471 | ;ebx - [x start] *65536 + [x size] |
||
3472 | ;ecx - [y start] *65536 + [y size] |
||
3473 | mov bx,[size_x_var] |
||
3474 | add bx,225 |
||
3475 | mov cx,[size_y_var] |
||
3476 | add cx,30 |
||
3477 | ; @@: |
||
3478 | mov edx,0x13000000 ; color of work area RRGGBB,8->color gl |
||
3479 | mov edi,labelt ; WINDOW LABEL |
||
3480 | int 0x40 |
||
3481 | |||
3482 | |||
3483 | |||
3484 | |||
3485 | |||
3486 | |||
3487 | ; mov ebx,0000000000111000000000000000b |
||
3488 | ; mov ecx,[points_count_var] |
||
3489 | ; movzx edx,word[size_x_var] |
||
3490 | ; shl edx,16 |
||
3491 | ; add edx,130*65536+60 ; [x start] *65536 + [y start] |
||
3492 | ; mov esi,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3493 | ; int 0x40 |
||
3494 | call write_info |
||
3495 | |||
3496 | |||
3497 | mov eax,4 ; function 4 : write text to window |
||
3498 | movzx ebx,word[size_x_var] |
||
3499 | shl ebx,16 |
||
3500 | add ebx,(12)*65536+(168+15*(13+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3501 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3502 | mov edx,labelvector ; pointer to text beginning |
||
3503 | mov esi,labelvectorend-labelvector ; text length |
||
3504 | ; cmp [move_flag],2 |
||
3505 | ; jne @f |
||
3506 | ; add edx,navigation_size |
||
3507 | ; @@: |
||
3508 | int 0x40 |
||
3509 | ; VECTOR Y- BUTTON |
||
3510 | mov eax,8 ; function 8 : define and draw button |
||
3511 | movzx ebx,word[size_x_var] |
||
3512 | shl ebx,16 |
||
3513 | add ebx,30*65536+20 ; [x start] *65536 + [x size] |
||
3514 | mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
3515 | mov edx,30 ; button id |
||
3516 | mov esi,0x6688dd ; button color RRGGBB |
||
3517 | int 0x40 |
||
3518 | ;VECTOR Y- LABEL |
||
3519 | mov eax,4 ; function 4 : write text to window |
||
3520 | movzx ebx,word[size_x_var] |
||
3521 | shl ebx,16 |
||
3522 | add ebx,(32)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3523 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3524 | mov edx,labelyminus ; pointer to text beginning |
||
3525 | mov esi,labelyminusend-labelyminus ; text length |
||
3526 | cmp [move_flag],2 |
||
3527 | ; jne @f |
||
3528 | ; add edx,navigation_size |
||
3529 | ; @@: |
||
3530 | int 0x40 |
||
3531 | ; VECTOR Z+ BUTTON |
||
3532 | mov eax,8 ; function 8 : define and draw button |
||
3533 | movzx ebx,word[size_x_var] |
||
3534 | shl ebx,16 |
||
3535 | add ebx,(51)*65536+21 ; [x start] *65536 + [x size] |
||
3536 | mov ecx,(165+15*(14+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
3537 | mov edx,31 ; button id |
||
3538 | mov esi,0x6688dd ; button color RRGGBB |
||
3539 | int 0x40 |
||
3540 | ;VECTOR Z+ LABEL |
||
3541 | mov eax,4 ; function 4 : write text to window |
||
3542 | movzx ebx,word[size_x_var] |
||
3543 | shl ebx,16 |
||
3544 | add ebx,(53)*65536+(168+15*(14+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3545 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3546 | mov edx,labelzplus ; pointer to text beginning |
||
3547 | mov esi,labelzplusend-labelzplus ; text length |
||
3548 | ; cmp [move_flag],2 |
||
3549 | ; jne @f |
||
3550 | ; add edx,navigation_size |
||
3551 | ; @@: |
||
3552 | |||
3553 | |||
3554 | ; VECTOR x- BUTTON |
||
3555 | mov eax,8 ; function 8 : define and draw button |
||
3556 | movzx ebx,word[size_x_var] |
||
3557 | shl ebx,16 |
||
3558 | add ebx,(10)*65536+21 ; [x start] *65536 + [x size] |
||
3559 | mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
3560 | mov edx,32 ; button id |
||
3561 | mov esi,0x6688dd ; button color RRGGBB |
||
3562 | int 0x40 |
||
3563 | ;VECTOR x- LABEL |
||
3564 | mov eax,4 ; function 4 : write text to window |
||
3565 | movzx ebx,word[size_x_var] |
||
3566 | shl ebx,16 |
||
3567 | add ebx,(12)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3568 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3569 | mov edx,labelxminus ; pointer to text beginning |
||
3570 | mov esi,labelxminusend-labelxminus ; text length |
||
3571 | ; cmp [move_flag],2 |
||
3572 | ; jne @f |
||
3573 | ; add edx,navigation_size |
||
3574 | ; @@: |
||
3575 | int 0x40 |
||
3576 | ; VECTOR x+ BUTTON |
||
3577 | mov eax,8 ; function 8 : define and draw button |
||
3578 | movzx ebx,word[size_x_var] |
||
3579 | shl ebx,16 |
||
3580 | add ebx,(51)*65536+21 ; [x start] *65536 + [x size] |
||
3581 | mov ecx,(165+15*(15+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
3582 | mov edx,33 ; button id |
||
3583 | mov esi,0x6688dd ; button color RRGGBB |
||
3584 | int 0x40 |
||
3585 | ;VECTOR x+ LABEL |
||
3586 | mov eax,4 ; function 4 : write text to window |
||
3587 | movzx ebx,word[size_x_var] |
||
3588 | shl ebx,16 |
||
3589 | add ebx,(53)*65536+(168+15*(15+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3590 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3591 | mov edx,labelxplus ; pointer to text beginning |
||
3592 | mov esi,labelxplusend-labelxplus ; text length |
||
3593 | ; cmp [move_flag],2 |
||
3594 | ; jne @f |
||
3595 | ; add edx,navigation_size |
||
3596 | ; @@: |
||
3597 | int 0x40 |
||
3598 | ; VECTOR z- BUTTON |
||
3599 | mov eax,8 ; function 8 : define and draw button |
||
3600 | movzx ebx,word[size_x_var] |
||
3601 | shl ebx,16 |
||
3602 | add ebx,(10)*65536+62-41 ; [x start] *65536 + [x size] |
||
3603 | mov ecx,(25+140+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
3604 | mov edx,34 ; button id |
||
3605 | mov esi,0x6688dd ; button color RRGGBB |
||
3606 | int 0x40 |
||
3607 | ;VECTOR z- LABEL |
||
3608 | mov eax,4 ; function 4 : write text to window |
||
3609 | movzx ebx,word[size_x_var] |
||
3610 | shl ebx,16 |
||
3611 | add ebx,(12)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3612 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3613 | mov edx,labelzminus ; pointer to text beginning |
||
3614 | mov esi,labelzminusend-labelzminus ; text length |
||
3615 | ; cmp [move_flag],2 |
||
3616 | ; jne @f |
||
3617 | ; add edx,navigation_size |
||
3618 | ; @@: |
||
3619 | int 0x40 |
||
3620 | ;VECTOR Y+ BUTTON |
||
3621 | mov eax,8 ; function 8 : define and draw button |
||
3622 | movzx ebx,word[size_x_var] |
||
3623 | shl ebx,16 |
||
3624 | add ebx,(10+20)*65536+20 ; [x start] *65536 + [x size] |
||
3625 | mov ecx,(165+15*(16+.Y_ADD))*65536+12 ; [y start] *65536 + [y size] |
||
3626 | mov edx,35 ; button id |
||
3627 | mov esi,0x6688dd ; button color RRGGBB |
||
3628 | int 0x40 |
||
3629 | ;VECTOR Y+ LABEL |
||
3630 | mov eax,4 ; function 4 : write text to window |
||
3631 | movzx ebx,word[size_x_var] |
||
3632 | shl ebx,16 |
||
3633 | add ebx,(32)*65536+(168+15*(16+.Y_ADD)) ; [x start] *65536 + [y start] |
||
3634 | mov ecx,0x00ddeeff ; font 1 & color ( 0xF0RRGGBB ) |
||
3635 | mov edx,labelyplus ; pointer to text beginning |
||
3636 | mov esi,labelyplusend-labelyplus ; text length |
||
3637 | ; cmp [move_flag],2 |
||
3638 | ; jne @f |
||
3639 | ; add edx,navigation_size |
||
3640 | ; @@: |
||
3641 | int 0x40 |
||
3642 | |||
3643 | |||
3644 | mov ebx,2 ; 2, end of draw |
||
3645 | int 0x40 |
||
3646 | ret |
||
3647 | |||
3648 | |||
3649 | |||
3650 | |||
3651 | |||
3652 | align 16 |
||
3653 | MEM_END:---mark>---mark>>----!>-1.0,1.0> |
||
3654 |