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