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