Rev 5171 | Rev 5208 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5153 | IgorA | 1 | include 'opengl_const.inc' |
2 | include 'zbuffer.inc' |
||
3 | include 'zmath.inc' |
||
4 | |||
5 | |||
6 | ;enum { OP_ ## a , ... } |
||
5175 | IgorA | 7 | sum1 equ 0 |
5153 | IgorA | 8 | macro ADD_OP a,b,c |
9 | { |
||
5175 | IgorA | 10 | OP_#a equ sum1 |
11 | sum1 equ (sum1+1) |
||
5153 | IgorA | 12 | } |
13 | include 'opinfo.inc' |
||
14 | |||
15 | |||
16 | ;initially # of allocated GLVertexes (will grow when necessary) |
||
17 | POLYGON_MAX_VERTEX equ 16 |
||
18 | |||
19 | ;Max # of specular light pow buffers |
||
20 | MAX_SPECULAR_BUFFERS equ 8 |
||
21 | ;# of entries in specular buffer |
||
22 | SPECULAR_BUFFER_SIZE equ 1024 |
||
23 | ;specular buffer granularity |
||
24 | SPECULAR_BUFFER_RESOLUTION equ 1024 |
||
25 | |||
26 | |||
27 | MAX_MODELVIEW_STACK_DEPTH equ 32 |
||
28 | MAX_PROJECTION_STACK_DEPTH equ 8 |
||
29 | MAX_TEXTURE_STACK_DEPTH equ 8 |
||
30 | MAX_NAME_STACK_DEPTH equ 64 |
||
31 | MAX_TEXTURE_LEVELS equ 11 |
||
32 | MAX_LIGHTS equ 16 |
||
33 | |||
34 | VERTEX_HASH_SIZE equ 1031 |
||
35 | |||
36 | MAX_DISPLAY_LISTS equ 1024 |
||
37 | OP_BUFFER_MAX_SIZE equ 512 |
||
38 | |||
39 | TGL_OFFSET_FILL equ 0x1 |
||
40 | TGL_OFFSET_LINE equ 0x2 |
||
41 | TGL_OFFSET_POINT equ 0x4 |
||
42 | |||
43 | struct GLSpecBuf |
||
44 | shininess_i dd ? ;int |
||
45 | last_used dd ? ;int |
||
46 | buf rd SPECULAR_BUFFER_SIZE+1 ;float[SPECULAR_BUFFER_SIZE+1] |
||
47 | next dd ? ;struct GLSpecBuf* |
||
48 | ends |
||
49 | |||
50 | struct GLLight |
||
51 | ambient V4 |
||
52 | diffuse V4 |
||
53 | specular V4 |
||
54 | position V4 |
||
55 | spot_direction V3 |
||
56 | spot_exponent dd ? ;float |
||
57 | spot_cutoff dd ? ;float |
||
58 | attenuation rd 3 ;float[3] |
||
59 | ; precomputed values |
||
60 | cos_spot_cutoff dd ? ;float |
||
61 | norm_spot_direction V3 |
||
62 | norm_position V3 |
||
63 | ; we use a linked list to know which are the enabled lights |
||
64 | enabled dd ? ;int |
||
65 | next dd ? ;struct GLLight* |
||
66 | prev dd ? ;struct GLLight* |
||
67 | ends |
||
68 | |||
69 | offs_ligh_ambient equ 0 ;V4 |
||
70 | offs_ligh_diffuse equ 16 ;V4 |
||
71 | offs_ligh_specular equ 32 ;V4 |
||
72 | offs_ligh_position equ 48 ;V4 |
||
73 | offs_ligh_spot_direction equ 64 ;V3 |
||
74 | offs_ligh_spot_exponent equ 76 ;dd ? |
||
75 | offs_ligh_spot_cutoff equ 80 ;dd ? |
||
76 | offs_ligh_attenuation equ 84 ;rd 3 |
||
77 | offs_ligh_cos_spot_cutoff equ 96 ;dd ? |
||
78 | offs_ligh_norm_spot_direction equ 100 ;V3 |
||
79 | offs_ligh_norm_position equ 112 ;V3 |
||
80 | offs_ligh_enabled equ 124 ;dd ? |
||
81 | offs_ligh_next equ 128 ;dd ? |
||
82 | offs_ligh_prev equ 132 ;dd ? |
||
83 | |||
84 | struct GLMaterial |
||
85 | emission V4 |
||
86 | ambient V4 |
||
87 | diffuse V4 |
||
88 | specular V4 |
||
89 | shininess dd ? ;float |
||
90 | |||
91 | ; computed values |
||
92 | shininess_i dd ? ;int |
||
93 | do_specular dd ? ;int |
||
94 | ends |
||
95 | |||
96 | offs_mate_emission equ 0 ;V4 |
||
97 | offs_mate_ambient equ 16 ;V4 |
||
98 | offs_mate_diffuse equ 32 ;V4 |
||
99 | offs_mate_specular equ 48 ;V4 |
||
100 | offs_mate_shininess equ 64 ;dd |
||
101 | offs_mate_shininess_i equ 68 ;dd |
||
102 | offs_mate_do_specular equ 72 ;dd |
||
103 | |||
104 | struct GLViewport |
||
105 | xmin dd ? ;int |
||
106 | ymin dd ? ;int |
||
107 | xsize dd ? ;int |
||
108 | ysize dd ? ;int |
||
109 | scale V3 |
||
110 | trans V3 |
||
111 | updated dd ? ;int |
||
112 | ends |
||
113 | |||
114 | offs_vpor_xmin equ 0 |
||
115 | offs_vpor_ymin equ 4 |
||
116 | offs_vpor_xsize equ 8 |
||
117 | offs_vpor_ysize equ 12 |
||
118 | offs_vpor_scale equ 16 |
||
119 | offs_vpor_trans equ 28 |
||
120 | offs_vpor_updated equ 40 |
||
121 | |||
122 | struct GLParamBuffer |
||
123 | ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE] |
||
124 | next dd ? ;struct GLParamBuffer* |
||
125 | ends |
||
126 | |||
5171 | IgorA | 127 | offs_gpbu_ops equ 0 |
128 | offs_gpbu_next equ 4*OP_BUFFER_MAX_SIZE |
||
129 | |||
5153 | IgorA | 130 | struct GLList |
131 | first_op_buffer dd ? ;GLParamBuffer* |
||
5171 | IgorA | 132 | ; TODO: extensions for an hash table or a better allocating scheme |
5153 | IgorA | 133 | ends |
134 | |||
135 | struct GLVertex |
||
136 | edge_flag dd ? ;int |
||
137 | normal V3 |
||
138 | coord V4 |
||
139 | tex_coord V4 |
||
140 | color V4 |
||
141 | |||
142 | ; computed values |
||
143 | ec V4 ; eye coordinates |
||
144 | pc V4 ; coordinates in the normalized volume |
||
145 | clip_code dd ? ;int ; clip code |
||
146 | zp ZBufferPoint ; integer coordinates for the rasterization |
||
147 | ends |
||
148 | |||
149 | offs_vert_edge_flag equ 0 |
||
150 | offs_vert_normal equ 4 |
||
151 | offs_vert_coord equ 16 |
||
152 | offs_vert_tex_coord equ 32 |
||
153 | offs_vert_color equ 48 |
||
154 | offs_vert_ec equ 64 |
||
155 | offs_vert_pc equ 80 |
||
156 | offs_vert_clip_code equ 96 |
||
157 | offs_vert_zp equ 100 |
||
158 | |||
159 | struct GLImage |
||
160 | pixmap dd ? ;void* |
||
161 | xsize dd ? ;int |
||
162 | ysize dd ? ;int |
||
163 | ends |
||
164 | |||
165 | offs_imag_pixmap equ 0 |
||
166 | |||
167 | ; textures |
||
168 | |||
169 | TEXTURE_HASH_TABLE_SIZE equ 256 ;должно быть кратное 2, в коде берется остаток от деления (через and быстрее чем div) |
||
170 | |||
171 | struct GLTexture |
||
172 | images rb sizeof.GLImage * MAX_TEXTURE_LEVELS ;GLImage[MAX_TEXTURE_LEVELS] |
||
173 | handle dd ? ;int |
||
174 | next dd ? ;struct GLTexture* |
||
175 | prev dd ? ;struct GLTexture* |
||
176 | ends |
||
177 | |||
178 | offs_text_images equ 0 |
||
179 | offs_text_handle equ sizeof.GLImage*MAX_TEXTURE_LEVELS |
||
180 | offs_text_next equ 4+offs_text_handle |
||
181 | offs_text_prev equ 8+offs_text_handle |
||
182 | |||
183 | ; shared state |
||
184 | |||
185 | struct GLSharedState |
||
186 | lists dd ? ;GLList** |
||
187 | texture_hash_table dd ? ;GLTexture** |
||
188 | ends |
||
189 | |||
190 | |||
191 | ; display context |
||
192 | |||
193 | struct GLContext |
||
194 | ; Z buffer |
||
195 | zb dd ? ;ZBuffer* |
||
196 | |||
197 | ; lights |
||
198 | lights rb sizeof.GLLight * MAX_LIGHTS ;GLLight[MAX_LIGHTS] |
||
199 | first_light dd ? ;GLLight* |
||
200 | ambient_light_model V4 |
||
201 | local_light_model dd ? ;int |
||
202 | lighting_enabled dd ? ;int |
||
203 | light_model_two_side dd ? ;int |
||
204 | |||
205 | ; materials |
||
206 | materials rb sizeof.GLMaterial * 2 ;GLMaterial[2] |
||
207 | color_material_enabled dd ? ;int |
||
208 | current_color_material_mode dd ? ;int |
||
209 | current_color_material_type dd ? ;int |
||
210 | |||
211 | ; textures |
||
212 | current_texture dd ? ;GLTexture* |
||
213 | texture_2d_enabled dd ? ;int |
||
214 | |||
215 | ; shared state |
||
216 | shared_state GLSharedState |
||
217 | |||
218 | ; current list |
||
219 | current_op_buffer dd ? ;GLParamBuffer* |
||
220 | current_op_buffer_index dd ? ;int |
||
221 | exec_flag dd ? ;int |
||
222 | compile_flag dd ? ;int |
||
223 | print_flag dd ? ;int |
||
224 | |||
225 | ; matrix |
||
226 | |||
227 | matrix_mode dd ? ;int режим активного вида матрицы (один из 3-х: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) |
||
228 | matrix_stack rd 3 ;*M4[3] указатель на начало массива матриц |
||
229 | matrix_stack_ptr rd 3 ;*M4[3] указатель на активную матрицу из массива |
||
230 | matrix_stack_depth_max rd 3 ;int[3] максимальное число матриц в массивах matrix_stack |
||
231 | |||
232 | matrix_model_view_inv M4 |
||
233 | matrix_model_projection M4 |
||
234 | matrix_model_projection_updated dd ? ;int |
||
235 | matrix_model_projection_no_w_transform dd ? ;int |
||
236 | apply_texture_matrix dd ? ;int |
||
237 | |||
238 | ; viewport |
||
239 | viewport GLViewport |
||
240 | |||
241 | ; current state |
||
242 | polygon_mode_back dd ? ;int |
||
243 | polygon_mode_front dd ? ;int |
||
244 | |||
245 | current_front_face dd ? ;int |
||
246 | current_shade_model dd ? ;int |
||
247 | current_cull_face dd ? ;int |
||
248 | cull_face_enabled dd ? ;int |
||
249 | normalize_enabled dd ? ;int |
||
250 | draw_triangle_front dd ? ;gl_draw_triangle_func |
||
251 | draw_triangle_back dd ? ;gl_draw_triangle_func |
||
252 | |||
253 | ; selection |
||
254 | render_mode dd ? ;int |
||
255 | select_buffer dd ? ;unsigned int* |
||
256 | select_size dd ? ;int |
||
257 | select_ptr dd ? ;unsigned int* |
||
258 | select_hit dd ? ;unsigned int* |
||
259 | select_overflow dd ? ;int |
||
260 | select_hits dd ? ;int |
||
261 | |||
262 | ; names |
||
263 | name_stack rd MAX_NAME_STACK_DEPTH ;unsigned int[MAX_NAME_STACK_DEPTH] |
||
264 | name_stack_size dd ? ;int |
||
265 | |||
266 | ; clear |
||
267 | clear_depth dd ? ;float |
||
268 | clear_color V4 |
||
269 | |||
270 | ; current vertex state |
||
271 | current_color V4 |
||
272 | longcurrent_color rd 3 ;unsigned int[3] ;precomputed integer color |
||
273 | current_normal V4 |
||
274 | current_tex_coord V4 |
||
275 | current_edge_flag dd ? ;int |
||
276 | |||
277 | ; glBegin / glEnd |
||
278 | in_begin dd ? ;int |
||
279 | begin_type dd ? ;int |
||
280 | vertex_n dd ? ;int |
||
281 | vertex_cnt dd ? ;int |
||
282 | vertex_max dd ? ;int |
||
283 | vertex dd ? ;GLVertex* |
||
284 | |||
285 | ; opengl 1.1 arrays |
||
286 | vertex_array dd ? ;float* |
||
287 | vertex_array_size dd ? ;int |
||
288 | vertex_array_stride dd ? ;int |
||
289 | normal_array dd ? ;float* |
||
290 | normal_array_stride dd ? ;int |
||
291 | color_array dd ? ;float* |
||
292 | color_array_size dd ? ;int |
||
293 | color_array_stride dd ? ;int |
||
294 | texcoord_array dd ? ;float* |
||
295 | texcoord_array_size dd ? ;int |
||
296 | texcoord_array_stride dd ? ;int |
||
297 | client_states dd ? ;int |
||
298 | |||
299 | ; opengl 1.1 polygon offset |
||
300 | offset_factor dd ? ;float |
||
301 | offset_units dd ? ;float |
||
302 | offset_states dd ? ;int |
||
303 | |||
304 | ; specular buffer. could probably be shared between contexts, |
||
305 | ; but that wouldn't be 100% thread safe |
||
306 | specbuf_first dd ? ;GLSpecBuf* |
||
307 | specbuf_used_counter dd ? ;int |
||
308 | specbuf_num_buffers dd ? ;int |
||
309 | |||
310 | ; opaque structure for user's use |
||
311 | opaque dd ? ;void* |
||
312 | ; resize viewport function |
||
313 | gl_resize_viewport dd ? ;(struct GLContext *c,int *xsize,int *ysize) |
||
314 | |||
315 | ; depth test |
||
316 | depth_test dd ? ;int |
||
317 | ends |
||
318 | |||
319 | offs_cont_s0 equ (4 + sizeof.GLLight * MAX_LIGHTS) |
||
320 | offs_cont_s1 equ (32 + offs_cont_s0 + sizeof.GLMaterial * 2) |
||
321 | offs_cont_s2 equ (228 + offs_cont_s1 + sizeof.GLViewport) |
||
322 | offs_cont_s3 equ (64 + offs_cont_s2 + MAX_NAME_STACK_DEPTH * 4) |
||
323 | |||
324 | offs_cont_zb equ 0 ;ZBuffer* |
||
325 | offs_cont_lights equ 4 ;GLLight[MAX_LIGHTS] |
||
326 | offs_cont_first_light equ offs_cont_s0 ;GLLight* |
||
327 | offs_cont_ambient_light_model equ 4+offs_cont_s0 ;V4 |
||
328 | offs_cont_local_light_model equ 20+offs_cont_s0 ;int |
||
329 | offs_cont_lighting_enabled equ 24+offs_cont_s0 ;int |
||
330 | offs_cont_light_model_two_side equ 28+offs_cont_s0 ;int |
||
331 | offs_cont_materials equ 32+offs_cont_s0 ;GLMaterial[2] |
||
332 | offs_cont_color_material_enabled equ offs_cont_s1 ;int |
||
333 | offs_cont_current_color_material_mode equ 4+offs_cont_s1 ;int |
||
334 | offs_cont_current_color_material_type equ 8+offs_cont_s1 ;int |
||
335 | offs_cont_current_texture equ 12+offs_cont_s1 ;GLTexture* |
||
336 | offs_cont_texture_2d_enabled equ 16+offs_cont_s1 ;int |
||
337 | offs_cont_shared_state equ 20+offs_cont_s1 ;GLSharedState |
||
338 | offs_cont_current_op_buffer equ 28+offs_cont_s1 ;GLParamBuffer* |
||
339 | offs_cont_current_op_buffer_index equ 32+offs_cont_s1 ;int |
||
340 | offs_cont_exec_flag equ 36+offs_cont_s1 ;int |
||
341 | offs_cont_compile_flag equ 40+offs_cont_s1 ;int |
||
342 | offs_cont_print_flag equ 44+offs_cont_s1 ;int |
||
343 | offs_cont_matrix_mode equ 48+offs_cont_s1 ;int |
||
344 | offs_cont_matrix_stack equ 52+offs_cont_s1 ;*M4[3] |
||
345 | offs_cont_matrix_stack_ptr equ 64+offs_cont_s1 ;*M4[3] |
||
346 | offs_cont_matrix_stack_depth_max equ 76+offs_cont_s1 ;int[3] |
||
347 | offs_cont_matrix_model_view_inv equ 88+offs_cont_s1 ;M4 |
||
348 | offs_cont_matrix_model_projection equ 152+offs_cont_s1 ;M4 |
||
349 | offs_cont_matrix_model_projection_updated equ 216+offs_cont_s1 ;int |
||
350 | offs_cont_matrix_model_projection_no_w_transform equ 220+offs_cont_s1 ;int |
||
351 | offs_cont_apply_texture_matrix equ 224+offs_cont_s1 ;int |
||
352 | offs_cont_viewport equ 228+offs_cont_s1 ;GLViewport |
||
353 | offs_cont_polygon_mode_back equ offs_cont_s2 ;int |
||
354 | offs_cont_polygon_mode_front equ 4+offs_cont_s2 ;int |
||
355 | offs_cont_current_front_face equ 8+offs_cont_s2 ;int |
||
356 | offs_cont_current_shade_model equ 12+offs_cont_s2 ;int |
||
357 | offs_cont_current_cull_face equ 16+offs_cont_s2 ;int |
||
358 | offs_cont_cull_face_enabled equ 20+offs_cont_s2 ;int |
||
359 | offs_cont_normalize_enabled equ 24+offs_cont_s2 ;int |
||
360 | offs_cont_draw_triangle_front equ 28+offs_cont_s2 ;gl_draw_triangle_func |
||
361 | offs_cont_draw_triangle_back equ 32+offs_cont_s2 ;gl_draw_triangle_func |
||
362 | offs_cont_render_mode equ 36+offs_cont_s2 ;int |
||
363 | offs_cont_select_buffer equ 40+offs_cont_s2 ;unsigned int* |
||
364 | offs_cont_select_size equ 44+offs_cont_s2 ;int |
||
365 | offs_cont_select_ptr equ 48+offs_cont_s2 ;unsigned int* |
||
366 | offs_cont_select_hit equ 52+offs_cont_s2 ;unsigned int* |
||
367 | offs_cont_select_overflow equ 56+offs_cont_s2 ;int |
||
368 | offs_cont_select_hits equ 60+offs_cont_s2 ;int |
||
369 | offs_cont_name_stack equ 64+offs_cont_s2 ;unsigned int[MAX_NAME_STACK_DEPTH] |
||
370 | offs_cont_name_stack_size equ offs_cont_s3 ;int |
||
371 | offs_cont_clear_depth equ 4+offs_cont_s3 ;float |
||
372 | offs_cont_clear_color equ 8+offs_cont_s3 ;V4 |
||
373 | offs_cont_current_color equ 24+offs_cont_s3 ;V4 |
||
374 | offs_cont_longcurrent_color equ 40+offs_cont_s3 ;unsigned int[3] |
||
375 | offs_cont_current_normal equ 52+offs_cont_s3 ;V4 |
||
376 | offs_cont_current_tex_coord equ 68+offs_cont_s3 ;V4 |
||
377 | offs_cont_current_edge_flag equ 84+offs_cont_s3 ;int |
||
378 | offs_cont_in_begin equ 88+offs_cont_s3 ;int |
||
379 | offs_cont_begin_type equ 92+offs_cont_s3 ;int |
||
380 | offs_cont_vertex_n equ 96+offs_cont_s3 ;int |
||
381 | offs_cont_vertex_cnt equ 100+offs_cont_s3 ;int |
||
382 | offs_cont_vertex_max equ 104+offs_cont_s3 ;int |
||
383 | offs_cont_vertex equ 108+offs_cont_s3 ;GLVertex* |
||
384 | offs_cont_vertex_array equ 112+offs_cont_s3 ;float* |
||
385 | offs_cont_vertex_array_size equ 116+offs_cont_s3 ;int |
||
386 | offs_cont_vertex_array_stride equ 120+offs_cont_s3 ;int |
||
387 | offs_cont_normal_array equ 124+offs_cont_s3 ;float* |
||
388 | offs_cont_normal_array_stride equ 128+offs_cont_s3 ;int |
||
389 | offs_cont_color_array equ 132+offs_cont_s3 ;float* |
||
390 | offs_cont_color_array_size equ 136+offs_cont_s3 ;int |
||
391 | offs_cont_color_array_stride equ 140+offs_cont_s3 ;int |
||
392 | offs_cont_texcoord_array equ 144+offs_cont_s3 ;float* |
||
393 | offs_cont_texcoord_array_size equ 148+offs_cont_s3 ;int |
||
394 | offs_cont_texcoord_array_stride equ 152+offs_cont_s3 ;int |
||
395 | offs_cont_client_states equ 156+offs_cont_s3 ;int |
||
396 | offs_cont_offset_factor equ 160+offs_cont_s3 ;float |
||
397 | offs_cont_offset_units equ 164+offs_cont_s3 ;float |
||
398 | offs_cont_offset_states equ 168+offs_cont_s3 ;int |
||
399 | offs_cont_specbuf_first equ 172+offs_cont_s3 ;GLSpecBuf* |
||
400 | offs_cont_specbuf_used_counter equ 176+offs_cont_s3 ;int |
||
401 | offs_cont_specbuf_num_buffers equ 180+offs_cont_s3 ;int |
||
402 | offs_cont_opaque equ 184+offs_cont_s3 ;void* |
||
403 | offs_cont_gl_resize_viewport equ 188+offs_cont_s3 ;(struct GLContext *c,int *xsize,int *ysize) |
||
404 | offs_cont_depth_test equ 192+offs_cont_s3 ;int |
||
405 | |||
406 | align 16 |
||
407 | gl_ctx dd ? ;extern GLContext* |
||
408 | |||
409 | align 16 |
||
410 | proc gl_get_context |
||
411 | mov eax,[gl_ctx] |
||
412 | ret |
||
413 | endp |
||
414 | |||
415 | ; this clip epsilon is needed to avoid some rounding errors after |
||
416 | ; several clipping stages |
||
417 | |||
418 | CLIP_EPSILON dd 1.0e-5 |
||
419 | |||
420 | align 4 |
||
421 | proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword |
||
422 | xor ebx,ebx |
||
423 | |||
424 | ;ffree st0 |
||
425 | ;fincstp |
||
426 | fld1 |
||
427 | fadd dword[CLIP_EPSILON] |
||
428 | fmul dword[w1] |
||
429 | |||
430 | fcom dword[x] |
||
431 | fstsw ax |
||
432 | sahf |
||
433 | ja @f |
||
434 | or ebx,2 |
||
435 | @@: |
||
436 | fcom dword[y] |
||
437 | fstsw ax |
||
438 | sahf |
||
439 | ja @f |
||
440 | or ebx,8 |
||
441 | @@: |
||
442 | fcom dword[z] |
||
443 | fstsw ax |
||
444 | sahf |
||
445 | ja @f |
||
446 | or ebx,32 |
||
447 | @@: |
||
448 | |||
449 | fchs |
||
450 | fcom dword[x] |
||
451 | fstsw ax |
||
452 | sahf |
||
453 | jbe @f |
||
454 | or ebx,1 |
||
455 | @@: |
||
456 | fcom dword[y] |
||
457 | fstsw ax |
||
458 | sahf |
||
459 | jbe @f |
||
460 | or ebx,4 |
||
461 | @@: |
||
462 | fcom dword[z] |
||
463 | fstsw ax |
||
464 | sahf |
||
465 | jbe @f |
||
466 | or ebx,16 |
||
467 | @@: |
||
468 | |||
469 | mov eax,ebx |
||
470 | if DEBUG ;gl_clipcode |
||
471 | push edi |
||
472 | mov ecx,80 |
||
473 | lea edi,[buf_param] |
||
474 | stdcall convert_int_to_str,ecx |
||
475 | stdcall str_n_cat,edi,txt_nl,2 |
||
476 | stdcall dbg_print,f_clipcode,buf_param |
||
477 | pop edi |
||
478 | end if |
||
479 | ret |
||
480 | endp |
||
481 | |||
482 | ;input: |
||
483 | ; rf,gf,bf - значения float |
||
484 | ; ri,gi,bi - адреса куда будут записаны rf,gf,bf преобразованые в int |
||
485 | align 4 |
||
486 | proc RGBFtoRGBI uses eax, rf:dword,gf:dword,bf:dword, ri:dword,gi:dword,bi:dword |
||
487 | locals |
||
488 | s dd ? |
||
489 | endl |
||
490 | mov dword[s],(ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) |
||
491 | fild dword[s] |
||
492 | fmul dword[rf] |
||
493 | mov eax,[ri] |
||
494 | fistp dword[eax] |
||
495 | add dword[eax],ZB_POINT_RED_MIN |
||
496 | |||
497 | mov dword[s],(ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) |
||
498 | fild dword[s] |
||
499 | fmul dword[gf] |
||
500 | mov eax,[gi] |
||
501 | fistp dword[eax] |
||
502 | add dword[eax],ZB_POINT_GREEN_MIN |
||
503 | |||
504 | ;bi = (unsigned int) (bf * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + ZB_POINT_BLUE_MIN); |
||
505 | mov dword[s],(ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) |
||
506 | fild dword[s] |
||
507 | fmul dword[bf] |
||
508 | mov eax,[bi] |
||
509 | fistp dword[eax] |
||
510 | add dword[eax],ZB_POINT_BLUE_MIN |
||
511 | ret |
||
512 | endp |