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