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