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