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