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