Rev 8063 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8063 | Rev 8069 | ||
---|---|---|---|
1 | include 'opengl_const.inc' |
1 | include 'opengl_const.inc' |
2 | include 'zbuffer.inc' |
2 | include 'zbuffer.inc' |
3 | include 'zmath.inc' |
3 | include 'zmath.inc' |
4 | 4 | ||
5 | offs_X equ 0 |
5 | offs_X equ 0 |
6 | offs_Y equ 4 |
6 | offs_Y equ 4 |
7 | offs_Z equ 8 |
7 | offs_Z equ 8 |
8 | offs_W equ 12 |
8 | offs_W equ 12 |
9 | 9 | ||
10 | ;enum { OP_ ## a , ... } |
10 | ;enum { OP_ ## a , ... } |
11 | sum1 equ 0 |
11 | sum1 equ 0 |
12 | macro ADD_OP a,b,c |
12 | macro ADD_OP a,b,c |
13 | { |
13 | { |
14 | OP_#a equ sum1 |
14 | OP_#a equ sum1 |
15 | sum1 equ (sum1+1) |
15 | sum1 equ (sum1+1) |
16 | } |
16 | } |
17 | include 'opinfo.inc' |
17 | include 'opinfo.inc' |
18 | 18 | ||
19 | 19 | ||
20 | ;initially # of allocated GLVertexes (will grow when necessary) |
20 | ;initially # of allocated GLVertexes (will grow when necessary) |
21 | POLYGON_MAX_VERTEX equ 16 |
21 | POLYGON_MAX_VERTEX equ 16 |
22 | 22 | ||
23 | ;Max # of specular light pow buffers |
23 | ;Max # of specular light pow buffers |
24 | MAX_SPECULAR_BUFFERS equ 8 |
24 | MAX_SPECULAR_BUFFERS equ 8 |
25 | ;# of entries in specular buffer |
25 | ;# of entries in specular buffer |
26 | SPECULAR_BUFFER_SIZE equ 1024 |
26 | SPECULAR_BUFFER_SIZE equ 1024 |
27 | ;specular buffer granularity |
27 | ;specular buffer granularity |
28 | SPECULAR_BUFFER_RESOLUTION equ 1024 |
28 | SPECULAR_BUFFER_RESOLUTION equ 1024 |
29 | 29 | ||
30 | 30 | ||
31 | MAX_MODELVIEW_STACK_DEPTH equ 32 |
31 | MAX_MODELVIEW_STACK_DEPTH equ 32 |
32 | MAX_PROJECTION_STACK_DEPTH equ 8 |
32 | MAX_PROJECTION_STACK_DEPTH equ 8 |
33 | MAX_TEXTURE_STACK_DEPTH equ 8 |
33 | MAX_TEXTURE_STACK_DEPTH equ 8 |
34 | MAX_NAME_STACK_DEPTH equ 64 |
34 | MAX_NAME_STACK_DEPTH equ 64 |
35 | MAX_TEXTURE_LEVELS equ 11 |
35 | MAX_TEXTURE_LEVELS equ 11 |
36 | MAX_LIGHTS equ 16 |
36 | MAX_LIGHTS equ 16 |
37 | 37 | ||
38 | VERTEX_HASH_SIZE equ 1031 |
38 | VERTEX_HASH_SIZE equ 1031 |
39 | 39 | ||
40 | MAX_DISPLAY_LISTS equ 1024 |
40 | MAX_DISPLAY_LISTS equ 1024 |
41 | OP_BUFFER_MAX_SIZE equ 512 |
41 | OP_BUFFER_MAX_SIZE equ 512 |
42 | 42 | ||
43 | TGL_OFFSET_FILL equ 0x1 |
43 | TGL_OFFSET_FILL equ 0x1 |
44 | TGL_OFFSET_LINE equ 0x2 |
44 | TGL_OFFSET_LINE equ 0x2 |
45 | TGL_OFFSET_POINT equ 0x4 |
45 | TGL_OFFSET_POINT equ 0x4 |
46 | 46 | ||
47 | struct GLSpecBuf |
47 | struct GLSpecBuf |
48 | shininess_i dd ? ;int |
48 | shininess_i dd ? ;int |
49 | last_used dd ? ;int |
49 | last_used dd ? ;int |
50 | buf rd SPECULAR_BUFFER_SIZE+1 ;float[SPECULAR_BUFFER_SIZE+1] |
50 | buf rd SPECULAR_BUFFER_SIZE+1 ;float[SPECULAR_BUFFER_SIZE+1] |
51 | next dd ? ;struct GLSpecBuf* |
51 | next dd ? ;struct GLSpecBuf* |
52 | ends |
52 | ends |
53 | 53 | ||
54 | offs_spec_shininess_i equ 0 |
54 | offs_spec_shininess_i equ 0 |
55 | offs_spec_last_used equ 4 |
55 | offs_spec_last_used equ 4 |
56 | offs_spec_buf equ 8 |
56 | offs_spec_buf equ 8 |
57 | offs_spec_next equ 8+4*(SPECULAR_BUFFER_SIZE+1) |
57 | offs_spec_next equ 8+4*(SPECULAR_BUFFER_SIZE+1) |
58 | 58 | ||
59 | struct GLLight |
59 | struct GLLight |
60 | ambient V4 |
60 | ambient V4 |
61 | diffuse V4 |
61 | diffuse V4 |
62 | specular V4 |
62 | specular V4 |
63 | position V4 |
63 | position V4 |
64 | spot_direction V3 |
64 | spot_direction V3 |
65 | spot_exponent dd ? ;float |
65 | spot_exponent dd ? ;float |
66 | spot_cutoff dd ? ;float |
66 | spot_cutoff dd ? ;float |
67 | attenuation rd 3 ;float[3] |
67 | attenuation rd 3 ;float[3] |
68 | ; precomputed values |
68 | ; precomputed values |
69 | cos_spot_cutoff dd ? ;float |
69 | cos_spot_cutoff dd ? ;float |
70 | norm_spot_direction V3 |
70 | norm_spot_direction V3 |
71 | norm_position V3 |
71 | norm_position V3 |
72 | ; we use a linked list to know which are the enabled lights |
72 | ; we use a linked list to know which are the enabled lights |
73 | enabled dd ? ;int |
73 | enabled dd ? ;int |
74 | next dd ? ;struct GLLight* |
74 | next dd ? ;struct GLLight* |
75 | prev dd ? ;struct GLLight* |
75 | prev dd ? ;struct GLLight* |
76 | ends |
76 | ends |
77 | 77 | ||
78 | struct GLMaterial |
78 | struct GLMaterial |
79 | emission V4 |
79 | emission V4 |
80 | ambient V4 |
80 | ambient V4 |
81 | diffuse V4 |
81 | diffuse V4 |
82 | specular V4 |
82 | specular V4 |
83 | shininess dd ? ;float |
83 | shininess dd ? ;float |
84 | 84 | ||
85 | ; computed values |
85 | ; computed values |
86 | shininess_i dd ? ;int |
86 | shininess_i dd ? ;int |
87 | do_specular dd ? ;int |
87 | do_specular dd ? ;int |
88 | ends |
88 | ends |
89 | 89 | ||
90 | struct GLViewport |
90 | struct GLViewport |
91 | xmin dd ? ;int |
91 | xmin dd ? ;int |
92 | ymin dd ? ;int |
92 | ymin dd ? ;int |
93 | xsize dd ? ;int |
93 | xsize dd ? ;int |
94 | ysize dd ? ;int |
94 | ysize dd ? ;int |
95 | scale V3 |
95 | scale V3 |
96 | trans V3 |
96 | trans V3 |
97 | updated dd ? ;int |
97 | updated dd ? ;int |
98 | ends |
98 | ends |
99 | - | ||
100 | offs_vpor_xmin equ 0 |
- | |
101 | offs_vpor_ymin equ 4 |
- | |
102 | offs_vpor_xsize equ 8 |
- | |
103 | offs_vpor_ysize equ 12 |
- | |
104 | offs_vpor_scale equ 16 |
- | |
105 | offs_vpor_trans equ 28 |
- | |
106 | offs_vpor_updated equ 40 |
- | |
107 | 99 | ||
108 | struct GLParamBuffer |
100 | struct GLParamBuffer |
109 | ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE] |
101 | ops rd OP_BUFFER_MAX_SIZE ;GLParam[OP_BUFFER_MAX_SIZE] |
110 | next dd ? ;struct GLParamBuffer* |
102 | next dd ? ;struct GLParamBuffer* |
111 | ends |
103 | ends |
112 | 104 | ||
113 | offs_gpbu_ops equ 0 |
105 | offs_gpbu_ops equ 0 |
114 | offs_gpbu_next equ 4*OP_BUFFER_MAX_SIZE |
106 | offs_gpbu_next equ 4*OP_BUFFER_MAX_SIZE |
115 | 107 | ||
116 | struct GLList |
108 | struct GLList |
117 | first_op_buffer dd ? ;GLParamBuffer* |
109 | first_op_buffer dd ? ;GLParamBuffer* |
118 | ; TODO: extensions for an hash table or a better allocating scheme |
110 | ; TODO: extensions for an hash table or a better allocating scheme |
119 | ends |
111 | ends |
120 | 112 | ||
121 | struct GLVertex |
113 | struct GLVertex |
122 | edge_flag dd ? ;int |
114 | edge_flag dd ? ;int |
123 | normal V3 |
115 | normal V3 |
124 | coord V4 |
116 | coord V4 |
125 | tex_coord V4 |
117 | tex_coord V4 |
126 | color V4 |
118 | color V4 |
127 | 119 | ||
128 | ; computed values |
120 | ; computed values |
129 | ec V4 ; eye coordinates |
121 | ec V4 ; eye coordinates |
130 | pc V4 ; coordinates in the normalized volume |
122 | pc V4 ; coordinates in the normalized volume |
131 | clip_code dd ? ;int ; clip code |
123 | clip_code dd ? ;int ; clip code |
132 | zp ZBufferPoint ; integer coordinates for the rasterization |
124 | zp ZBufferPoint ; integer coordinates for the rasterization |
133 | ends |
125 | ends |
134 | 126 | ||
135 | struct GLImage |
127 | struct GLImage |
136 | pixmap dd ? ;void* |
128 | pixmap dd ? ;void* |
137 | xsize dd ? ;int |
129 | xsize dd ? ;int |
138 | ysize dd ? ;int |
130 | ysize dd ? ;int |
139 | xsize_log2 dd ? ;unsigned int |
131 | xsize_log2 dd ? ;unsigned int |
140 | s_bound dd ? ;unsigned int |
132 | s_bound dd ? ;unsigned int |
141 | t_bound dd ? ;unsigned int |
133 | t_bound dd ? ;unsigned int |
142 | ends |
134 | ends |
143 | 135 | ||
144 | offs_imag_pixmap equ 0 |
136 | offs_imag_pixmap equ 0 |
145 | offs_imag_xsize equ 4 |
137 | offs_imag_xsize equ 4 |
146 | offs_imag_ysize equ 8 |
138 | offs_imag_ysize equ 8 |
147 | offs_imag_xsize_log2 equ 12 |
139 | offs_imag_xsize_log2 equ 12 |
148 | offs_imag_s_bound equ 16 |
140 | offs_imag_s_bound equ 16 |
149 | offs_imag_t_bound equ 20 |
141 | offs_imag_t_bound equ 20 |
150 | 142 | ||
151 | ; textures |
143 | ; textures |
152 | 144 | ||
153 | TEXTURE_HASH_TABLE_SIZE equ 256 ;должно быть кратное 2, в коде берется остаток от деления (через and быстрее чем div) |
145 | TEXTURE_HASH_TABLE_SIZE equ 256 ;должно быть кратное 2, в коде берется остаток от деления (через and быстрее чем div) |
154 | 146 | ||
155 | struct GLTexture |
147 | struct GLTexture |
156 | images rb sizeof.GLImage * MAX_TEXTURE_LEVELS ;GLImage[MAX_TEXTURE_LEVELS] |
148 | images rb sizeof.GLImage * MAX_TEXTURE_LEVELS ;GLImage[MAX_TEXTURE_LEVELS] |
157 | handle dd ? ;int |
149 | handle dd ? ;int |
158 | next dd ? ;struct GLTexture* |
150 | next dd ? ;struct GLTexture* |
159 | prev dd ? ;struct GLTexture* |
151 | prev dd ? ;struct GLTexture* |
160 | ends |
152 | ends |
161 | 153 | ||
162 | offs_text_images equ 0 |
154 | offs_text_images equ 0 |
163 | offs_text_handle equ sizeof.GLImage*MAX_TEXTURE_LEVELS |
155 | offs_text_handle equ sizeof.GLImage*MAX_TEXTURE_LEVELS |
164 | offs_text_next equ 4+offs_text_handle |
156 | offs_text_next equ 4+offs_text_handle |
165 | offs_text_prev equ 8+offs_text_handle |
157 | offs_text_prev equ 8+offs_text_handle |
166 | 158 | ||
167 | ; shared state |
159 | ; shared state |
168 | 160 | ||
169 | struct GLSharedState |
161 | struct GLSharedState |
170 | lists dd ? ;GLList** |
162 | lists dd ? ;GLList** |
171 | texture_hash_table dd ? ;GLTexture** |
163 | texture_hash_table dd ? ;GLTexture** |
172 | ends |
164 | ends |
173 | 165 | ||
174 | 166 | ||
175 | ; display context |
167 | ; display context |
176 | 168 | ||
177 | struct GLContext |
169 | struct GLContext |
178 | ; Z buffer |
170 | ; Z buffer |
179 | zb dd ? ;ZBuffer* |
171 | zb dd ? ;ZBuffer* |
180 | 172 | ||
181 | ; lights |
173 | ; lights |
182 | lights rb sizeof.GLLight * MAX_LIGHTS ;GLLight[MAX_LIGHTS] |
174 | lights rb sizeof.GLLight * MAX_LIGHTS ;GLLight[MAX_LIGHTS] |
183 | first_light dd ? ;GLLight* |
175 | first_light dd ? ;GLLight* |
184 | ambient_light_model V4 |
176 | ambient_light_model V4 |
185 | local_light_model dd ? ;int |
177 | local_light_model dd ? ;int |
186 | lighting_enabled dd ? ;int |
178 | lighting_enabled dd ? ;int |
187 | light_model_two_side dd ? ;int |
179 | light_model_two_side dd ? ;int |
188 | 180 | ||
189 | ; materials |
181 | ; materials |
190 | materials rb sizeof.GLMaterial * 2 ;GLMaterial[2] |
182 | materials rb sizeof.GLMaterial * 2 ;GLMaterial[2] |
191 | color_material_enabled dd ? ;int |
183 | color_material_enabled dd ? ;int |
192 | current_color_material_mode dd ? ;int |
184 | current_color_material_mode dd ? ;int |
193 | current_color_material_type dd ? ;int |
185 | current_color_material_type dd ? ;int |
194 | 186 | ||
195 | ; textures |
187 | ; textures |
196 | current_texture dd ? ;GLTexture* |
188 | current_texture dd ? ;GLTexture* |
197 | texture_2d_enabled dd ? ;int |
189 | texture_2d_enabled dd ? ;int |
198 | 190 | ||
199 | ; shared state |
191 | ; shared state |
200 | shared_state GLSharedState |
192 | shared_state GLSharedState |
201 | 193 | ||
202 | ; current list |
194 | ; current list |
203 | current_op_buffer dd ? ;GLParamBuffer* |
195 | current_op_buffer dd ? ;GLParamBuffer* |
204 | current_op_buffer_index dd ? ;int |
196 | current_op_buffer_index dd ? ;int |
205 | exec_flag dd ? ;int |
197 | exec_flag dd ? ;int |
206 | compile_flag dd ? ;int |
198 | compile_flag dd ? ;int |
207 | print_flag dd ? ;int |
199 | print_flag dd ? ;int |
208 | 200 | ||
209 | ; matrix |
201 | ; matrix |
210 | 202 | ||
211 | matrix_mode dd ? ;int режим активного вида матрицы (один из 3-х: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) |
203 | matrix_mode dd ? ;int режим активного вида матрицы (один из 3-х: GL_MODELVIEW, GL_PROJECTION, GL_TEXTURE) |
212 | matrix_stack rd 3 ;*M4[3] указатель на начало массива матриц |
204 | matrix_stack rd 3 ;*M4[3] указатель на начало массива матриц |
213 | matrix_stack_ptr rd 3 ;*M4[3] указатель на активную матрицу из массива |
205 | matrix_stack_ptr rd 3 ;*M4[3] указатель на активную матрицу из массива |
214 | matrix_stack_depth_max rd 3 ;int[3] максимальное число матриц в массивах matrix_stack |
206 | matrix_stack_depth_max rd 3 ;int[3] максимальное число матриц в массивах matrix_stack |
215 | 207 | ||
216 | matrix_model_view_inv M4 |
208 | matrix_model_view_inv M4 |
217 | matrix_model_projection M4 |
209 | matrix_model_projection M4 |
218 | matrix_model_projection_updated dd ? ;int |
210 | matrix_model_projection_updated dd ? ;int |
219 | matrix_model_projection_no_w_transform dd ? ;int |
211 | matrix_model_projection_no_w_transform dd ? ;int |
220 | apply_texture_matrix dd ? ;int |
212 | apply_texture_matrix dd ? ;int |
221 | 213 | ||
222 | ; viewport |
214 | ; viewport |
223 | viewport GLViewport |
215 | viewport GLViewport |
224 | 216 | ||
225 | ; current state |
217 | ; current state |
226 | polygon_mode_back dd ? ;int |
218 | polygon_mode_back dd ? ;int |
227 | polygon_mode_front dd ? ;int |
219 | polygon_mode_front dd ? ;int |
228 | 220 | ||
229 | current_front_face dd ? ;int |
221 | current_front_face dd ? ;int |
230 | current_shade_model dd ? ;int |
222 | current_shade_model dd ? ;int |
231 | current_cull_face dd ? ;int |
223 | current_cull_face dd ? ;int |
232 | cull_face_enabled dd ? ;int |
224 | cull_face_enabled dd ? ;int |
233 | normalize_enabled dd ? ;int |
225 | normalize_enabled dd ? ;int |
234 | draw_triangle_front dd ? ;gl_draw_triangle_func |
226 | draw_triangle_front dd ? ;gl_draw_triangle_func |
235 | draw_triangle_back dd ? ;gl_draw_triangle_func |
227 | draw_triangle_back dd ? ;gl_draw_triangle_func |
236 | 228 | ||
237 | ; selection |
229 | ; selection |
238 | render_mode dd ? ;int |
230 | render_mode dd ? ;int |
239 | select_buffer dd ? ;unsigned int* |
231 | select_buffer dd ? ;unsigned int* |
240 | select_size dd ? ;int |
232 | select_size dd ? ;int |
241 | select_ptr dd ? ;unsigned int* |
233 | select_ptr dd ? ;unsigned int* |
242 | select_hit dd ? ;unsigned int* |
234 | select_hit dd ? ;unsigned int* |
243 | select_overflow dd ? ;int |
235 | select_overflow dd ? ;int |
244 | select_hits dd ? ;int |
236 | select_hits dd ? ;int |
245 | 237 | ||
246 | ; names |
238 | ; names |
247 | name_stack rd MAX_NAME_STACK_DEPTH ;unsigned int[MAX_NAME_STACK_DEPTH] |
239 | name_stack rd MAX_NAME_STACK_DEPTH ;unsigned int[MAX_NAME_STACK_DEPTH] |
248 | name_stack_size dd ? ;int |
240 | name_stack_size dd ? ;int |
249 | 241 | ||
250 | ; clear |
242 | ; clear |
251 | clear_depth dd ? ;float |
243 | clear_depth dd ? ;float |
252 | clear_color V4 |
244 | clear_color V4 |
253 | 245 | ||
254 | ; current vertex state |
246 | ; current vertex state |
255 | current_color V4 |
247 | current_color V4 |
256 | longcurrent_color rd 3 ;unsigned int[3] ;precomputed integer color |
248 | longcurrent_color rd 3 ;unsigned int[3] ;precomputed integer color |
257 | current_normal V4 |
249 | current_normal V4 |
258 | current_tex_coord V4 |
250 | current_tex_coord V4 |
259 | current_edge_flag dd ? ;int |
251 | current_edge_flag dd ? ;int |
260 | 252 | ||
261 | ; glBegin / glEnd |
253 | ; glBegin / glEnd |
262 | in_begin dd ? ;int |
254 | in_begin dd ? ;int |
263 | begin_type dd ? ;int |
255 | begin_type dd ? ;int |
264 | vertex_n dd ? ;int |
256 | vertex_n dd ? ;int |
265 | vertex_cnt dd ? ;int |
257 | vertex_cnt dd ? ;int |
266 | vertex_max dd ? ;int |
258 | vertex_max dd ? ;int |
267 | vertex dd ? ;GLVertex* |
259 | vertex dd ? ;GLVertex* |
268 | 260 | ||
269 | ; opengl 1.1 arrays |
261 | ; opengl 1.1 arrays |
270 | vertex_array dd ? ;float* |
262 | vertex_array dd ? ;float* |
271 | vertex_array_size dd ? ;int |
263 | vertex_array_size dd ? ;int |
272 | vertex_array_stride dd ? ;int |
264 | vertex_array_stride dd ? ;int |
273 | normal_array dd ? ;float* |
265 | normal_array dd ? ;float* |
274 | normal_array_stride dd ? ;int |
266 | normal_array_stride dd ? ;int |
275 | color_array dd ? ;float* |
267 | color_array dd ? ;float* |
276 | color_array_size dd ? ;int |
268 | color_array_size dd ? ;int |
277 | color_array_stride dd ? ;int |
269 | color_array_stride dd ? ;int |
278 | texcoord_array dd ? ;float* |
270 | texcoord_array dd ? ;float* |
279 | texcoord_array_size dd ? ;int |
271 | texcoord_array_size dd ? ;int |
280 | texcoord_array_stride dd ? ;int |
272 | texcoord_array_stride dd ? ;int |
281 | client_states dd ? ;int |
273 | client_states dd ? ;int |
282 | 274 | ||
283 | ; opengl 1.1 polygon offset |
275 | ; opengl 1.1 polygon offset |
284 | offset_factor dd ? ;float |
276 | offset_factor dd ? ;float |
285 | offset_units dd ? ;float |
277 | offset_units dd ? ;float |
286 | offset_states dd ? ;int |
278 | offset_states dd ? ;int |
287 | 279 | ||
288 | ; specular buffer. could probably be shared between contexts, |
280 | ; specular buffer. could probably be shared between contexts, |
289 | ; but that wouldn't be 100% thread safe |
281 | ; but that wouldn't be 100% thread safe |
290 | specbuf_first dd ? ;GLSpecBuf* |
282 | specbuf_first dd ? ;GLSpecBuf* |
291 | specbuf_used_counter dd ? ;int |
283 | specbuf_used_counter dd ? ;int |
292 | specbuf_num_buffers dd ? ;int |
284 | specbuf_num_buffers dd ? ;int |
293 | 285 | ||
294 | ; opaque structure for user's use |
286 | ; opaque structure for user's use |
295 | opaque dd ? ;void* |
287 | opaque dd ? ;void* |
296 | ; resize viewport function |
288 | ; resize viewport function |
297 | gl_resize_viewport dd ? ;(struct GLContext *c,int *xsize,int *ysize) |
289 | gl_resize_viewport dd ? ;(struct GLContext *c,int *xsize,int *ysize) |
298 | 290 | ||
299 | ; depth test |
291 | ; depth test |
300 | depth_test dd ? ;int |
292 | depth_test dd ? ;int |
301 | ends |
293 | ends |
302 | 294 | ||
303 | align 16 |
295 | align 16 |
304 | gl_ctx dd ? ;extern GLContext* |
296 | gl_ctx dd ? ;extern GLContext* |
305 | 297 | ||
306 | align 16 |
298 | align 16 |
307 | proc gl_get_context |
299 | proc gl_get_context |
308 | mov eax,[gl_ctx] |
300 | mov eax,[gl_ctx] |
309 | ret |
301 | ret |
310 | endp |
302 | endp |
311 | 303 | ||
312 | ; this clip epsilon is needed to avoid some rounding errors after |
304 | ; this clip epsilon is needed to avoid some rounding errors after |
313 | ; several clipping stages |
305 | ; several clipping stages |
314 | 306 | ||
315 | CLIP_EPSILON dd 1.0e-5 |
307 | CLIP_EPSILON dd 1.0e-5 |
316 | 308 | ||
317 | align 4 |
309 | align 4 |
318 | proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword |
310 | proc gl_clipcode uses ebx, x:dword, y:dword, z:dword, w1:dword |
319 | xor ebx,ebx |
311 | xor ebx,ebx |
320 | 312 | ||
321 | fld1 |
313 | fld1 |
322 | fadd dword[CLIP_EPSILON] |
314 | fadd dword[CLIP_EPSILON] |
323 | fmul dword[w1] |
315 | fmul dword[w1] |
324 | 316 | ||
325 | fcom dword[x] |
317 | fcom dword[x] |
326 | fstsw ax |
318 | fstsw ax |
327 | sahf |
319 | sahf |
328 | ja @f |
320 | ja @f |
329 | or ebx,2 |
321 | or ebx,2 |
330 | @@: |
322 | @@: |
331 | fcom dword[y] |
323 | fcom dword[y] |
332 | fstsw ax |
324 | fstsw ax |
333 | sahf |
325 | sahf |
334 | ja @f |
326 | ja @f |
335 | or ebx,8 |
327 | or ebx,8 |
336 | @@: |
328 | @@: |
337 | fcom dword[z] |
329 | fcom dword[z] |
338 | fstsw ax |
330 | fstsw ax |
339 | sahf |
331 | sahf |
340 | ja @f |
332 | ja @f |
341 | or ebx,32 |
333 | or ebx,32 |
342 | @@: |
334 | @@: |
343 | 335 | ||
344 | fchs |
336 | fchs |
345 | fcom dword[x] |
337 | fcom dword[x] |
346 | fstsw ax |
338 | fstsw ax |
347 | sahf |
339 | sahf |
348 | jbe @f |
340 | jbe @f |
349 | or ebx,1 |
341 | or ebx,1 |
350 | @@: |
342 | @@: |
351 | fcom dword[y] |
343 | fcom dword[y] |
352 | fstsw ax |
344 | fstsw ax |
353 | sahf |
345 | sahf |
354 | jbe @f |
346 | jbe @f |
355 | or ebx,4 |
347 | or ebx,4 |
356 | @@: |
348 | @@: |
357 | fcom dword[z] |
349 | fcom dword[z] |
358 | fstsw ax |
350 | fstsw ax |
359 | sahf |
351 | sahf |
360 | jbe @f |
352 | jbe @f |
361 | or ebx,16 |
353 | or ebx,16 |
362 | @@: |
354 | @@: |
363 | 355 | ||
364 | ffree st0 |
356 | ffree st0 |
365 | fincstp |
357 | fincstp |
366 | 358 | ||
367 | mov eax,ebx |
359 | mov eax,ebx |
368 | ret |
360 | ret |
369 | endp |
361 | endp |
370 | 362 | ||
371 | ;input: |
363 | ;input: |
372 | ; rf,gf,bf - значения float |
364 | ; rf,gf,bf - значения float |
373 | ; ri,gi,bi - адреса куда будут записаны rf,gf,bf преобразованые в int |
365 | ; ri,gi,bi - адреса куда будут записаны rf,gf,bf преобразованые в int |
374 | align 4 |
366 | align 4 |
375 | proc RGBFtoRGBI uses eax, rf:dword,gf:dword,bf:dword, ri:dword,gi:dword,bi:dword |
367 | proc RGBFtoRGBI uses eax, rf:dword,gf:dword,bf:dword, ri:dword,gi:dword,bi:dword |
376 | locals |
368 | locals |
377 | s dd ? |
369 | s dd ? |
378 | endl |
370 | endl |
379 | mov dword[s],(ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) |
371 | mov dword[s],(ZB_POINT_RED_MAX - ZB_POINT_RED_MIN) |
380 | fild dword[s] |
372 | fild dword[s] |
381 | fmul dword[rf] |
373 | fmul dword[rf] |
382 | mov eax,[ri] |
374 | mov eax,[ri] |
383 | fistp dword[eax] |
375 | fistp dword[eax] |
384 | add dword[eax],ZB_POINT_RED_MIN |
376 | add dword[eax],ZB_POINT_RED_MIN |
385 | 377 | ||
386 | mov dword[s],(ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) |
378 | mov dword[s],(ZB_POINT_GREEN_MAX - ZB_POINT_GREEN_MIN) |
387 | fild dword[s] |
379 | fild dword[s] |
388 | fmul dword[gf] |
380 | fmul dword[gf] |
389 | mov eax,[gi] |
381 | mov eax,[gi] |
390 | fistp dword[eax] |
382 | fistp dword[eax] |
391 | add dword[eax],ZB_POINT_GREEN_MIN |
383 | add dword[eax],ZB_POINT_GREEN_MIN |
392 | 384 | ||
393 | ;bi = (unsigned int) (bf * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + ZB_POINT_BLUE_MIN); |
385 | ;bi = (unsigned int) (bf * (ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) + ZB_POINT_BLUE_MIN); |
394 | mov dword[s],(ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) |
386 | mov dword[s],(ZB_POINT_BLUE_MAX - ZB_POINT_BLUE_MIN) |
395 | fild dword[s] |
387 | fild dword[s] |
396 | fmul dword[bf] |
388 | fmul dword[bf] |
397 | mov eax,[bi] |
389 | mov eax,[bi] |
398 | fistp dword[eax] |
390 | fistp dword[eax] |
399 | add dword[eax],ZB_POINT_BLUE_MIN |
391 | add dword[eax],ZB_POINT_BLUE_MIN |
400 | ret |
392 | ret |
401 | endp |
393 | endp |