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