Subversion Repositories Kolibri OS

Rev

Rev 1783 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1783 Rev 1784
1
;
1
;
2
; application : Deus Caritas Est - app shows three models shading 
2
; application : Deus Caritas Est - app shows three models shading 
3
; compiler    : FASM  1.65.13
3
; compiler    : FASM  1.65.13
4
; system      : KolibriOS/MenuetOS
4
; system      : KolibriOS/MenuetOS
5
; author      : macgub
5
; author      : macgub
6
; email       : macgub3@wp.pl
6
; email       : macgub3@wp.pl
7
; web         : www.menuet.xt.pl
7
; web         : www.menuet.xt.pl
8
; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS.
8
; Fell free to use this intro in your own distribution of KolibriOS/MenuetOS.
9
; Special greetings to all MenuetOS maniax in the world.
9
; Special greetings to all MenuetOS maniax in the world.
10
; I hope because my intros Christian Belive will be near to each of You.
10
; I hope because my intros 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
SIZE_X equ 250
19
SIZE_X equ 250
20
SIZE_Y equ 250
20
SIZE_Y equ 250
21
TIMEOUT equ 4
21
TIMEOUT equ 4
22
ROUND equ 10
22
ROUND equ 10
23
TEX_X equ 512	  ; texture width
23
TEX_X equ 512	  ; texture width
24
TEX_Y equ 512	  ;         height
24
TEX_Y equ 512	  ;         height
25
TEX_SHIFT equ 9  ; texture widith shifting
25
TEX_SHIFT equ 9  ; texture widith shifting
26
TEX equ  SHIFTING ;  TEX={SHIFTING | FLUENTLY}
26
TEX equ  SHIFTING ;  TEX={SHIFTING | FLUENTLY}
27
FLUENTLY = 0
27
FLUENTLY = 0
28
SHIFTING = 1
28
SHIFTING = 1
29
;CATMULL_SHIFT equ 8
29
;CATMULL_SHIFT equ 8
30
NON   =   0
30
NON   =   0
31
MMX   =   1
31
MMX   =   1
32
 
32
 
33
Ext   =   MMX			;Ext={ NON | MMX}
33
Ext   =   MMX			;Ext={ NON | MMX}
34
 
34
 
35
use32
35
use32
36
	org    0x0
36
	org    0x0
37
	db     'MENUET01'	; 8 byte id
37
	db     'MENUET01'	; 8 byte id
38
	dd     0x01		; header version
38
	dd     0x01		; header version
39
	dd     START		; start of code
39
	dd     START		; start of code
40
	dd     I_END		; size of image
40
	dd     I_END		; size of image
41
	dd     I_END		; memory for app
41
	dd     I_END		; memory for app
42
	dd     I_END		; esp
42
	dd     I_END		; esp
43
	dd     0x0 , 0x0	; I_Param , I_Icon
43
	dd     0x0 , 0x0	; I_Param , I_Icon
44
 
44
 
45
START:	  ; start of execution
45
START:	  ; start of execution
46
	cld
46
	cld
47
 ;       call alloc_buffer_mem
47
 ;       call alloc_buffer_mem
48
	call read_from_file
48
	call read_from_file
49
	call init_triangles_normals
49
	call init_triangles_normals
50
	call init_point_normals
50
	call init_point_normals
51
	call init_envmap
51
	call init_envmap
52
	call draw_window
52
	call draw_window
53
 
53
 
54
 
54
 
55
still:
55
still:
56
	mov	eax,23		; wait here for event with timeout
56
	mov	eax,23		; wait here for event with timeout
57
	mov	ebx,TIMEOUT
57
	mov	ebx,TIMEOUT
58
	cmp	[speed_flag],1
58
	cmp	[speed_flag],1
59
	jne	.skip
59
	jne	.skip
60
	mov	eax,11
60
	mov	eax,11
61
    .skip:
61
    .skip:
62
	int	0x40
62
	int	0x40
63
 
63
 
64
	cmp	eax,1		; redraw request ?
64
	cmp	eax,1		; redraw request ?
65
	je	red
65
	je	red
66
	cmp	eax,2		; key in buffer ?
66
	cmp	eax,2		; key in buffer ?
67
	je	key
67
	je	key
68
	cmp	eax,3		; button in buffer ?
68
	cmp	eax,3		; button in buffer ?
69
	je	button
69
	je	button
70
 
70
 
71
	jmp	noclose
71
	jmp	noclose
72
 
72
 
73
    red:			; redraw
73
    red:			; redraw
74
	call	draw_window
74
	call	draw_window
75
	jmp	noclose
75
	jmp	noclose
76
 
76
 
77
    key:			; key
77
    key:			; key
78
	mov	eax,2		; just read it and ignore
78
	mov	eax,2		; just read it and ignore
79
	int	0x40
79
	int	0x40
80
	jmp	noclose
80
	jmp	noclose
81
 
81
 
82
    button:			; button
82
    button:			; button
83
	mov	eax,17		; get id
83
	mov	eax,17		; get id
84
	int	0x40
84
	int	0x40
85
 
85
 
86
	cmp	ah,1		; button id=1 ?
86
	cmp	ah,1		; button id=1 ?
87
	jne	.ch_another
87
	jne	.ch_another
88
 
88
 
89
	mov	eax,-1		; close this program
89
	mov	eax,-1		; close this program
90
	int	0x40
90
	int	0x40
91
      .ch_another:
91
      .ch_another:
92
	cmp	ah,2
92
	cmp	ah,2
93
	jne	.ch_another1
93
	jne	.ch_another1
94
	inc	[r_flag]
94
	inc	[r_flag]
95
	cmp	[r_flag],3
95
	cmp	[r_flag],3
96
	jne	noclose
96
	jne	noclose
97
	mov	[r_flag],0
97
	mov	[r_flag],0
98
      .ch_another1:
98
      .ch_another1:
99
	cmp	ah,3
99
	cmp	ah,3
100
	jne	.ch_another2
100
	jne	.ch_another2
101
	inc	[dr_flag]
101
	inc	[dr_flag]
102
	cmp	[dr_flag],3
102
	cmp	[dr_flag],3
103
	jne	noclose
103
	jne	noclose
104
	mov	[dr_flag],0
104
	mov	[dr_flag],0
105
      .ch_another2:
105
      .ch_another2:
106
	cmp	ah,4			 ; toggle speed
106
	cmp	ah,4			 ; toggle speed
107
	jne	@f
107
	jne	@f
108
	inc	[speed_flag]
108
	inc	[speed_flag]
109
	cmp	[speed_flag],2
109
	cmp	[speed_flag],2
110
	jne	noclose
110
	jne	noclose
111
	mov	[speed_flag],0
111
	mov	[speed_flag],0
112
      @@:
112
      @@:
113
	cmp	ah,5
113
	cmp	ah,5
114
	jne	@f			 ;scale-
114
	jne	@f			 ;scale-
115
	mov	[scale],0.7
115
	mov	[scale],0.7
116
	fninit
116
	fninit
117
	fld	[sscale]
117
	fld	[sscale]
118
	fmul	[scale]
118
	fmul	[scale]
119
	fstp	[sscale]
119
	fstp	[sscale]
120
	call	read_from_file
120
	call	read_from_file
121
	mov	ax,[vect_x]  ;-- last change
121
	mov	ax,[vect_x]  ;-- last change
122
	mov	bx,[vect_y]
122
	mov	bx,[vect_y]
123
	mov	cx,[vect_z]
123
	mov	cx,[vect_z]
124
	call	add_vector
124
	call	add_vector
125
;        call    do_scale
125
;        call    do_scale
126
      @@:
126
      @@:
127
	cmp	ah,6
127
	cmp	ah,6
128
	jne	@f			; scale+
128
	jne	@f			; scale+
129
	mov	[scale],1.3
129
	mov	[scale],1.3
130
	fninit
130
	fninit
131
	fld	[sscale]
131
	fld	[sscale]
132
	fmul	[scale]
132
	fmul	[scale]
133
	fstp	[sscale]
133
	fstp	[sscale]
134
	call	read_from_file
134
	call	read_from_file
135
	mov	ax,[vect_x]
135
	mov	ax,[vect_x]
136
	mov	bx,[vect_y]
136
	mov	bx,[vect_y]
137
	mov	cx,[vect_z]
137
	mov	cx,[vect_z]
138
	call	add_vector
138
	call	add_vector
139
	call	init_triangles_normals
139
	call	init_triangles_normals
140
	call	init_point_normals
140
	call	init_point_normals
141
      @@:
141
      @@:
142
	cmp	ah,7
142
	cmp	ah,7
143
	jne	@f
143
	jne	@f
144
	xor	ax,ax		 ;add vector to object and rotary point
144
	xor	ax,ax		 ;add vector to object and rotary point
145
	mov	bx,-10
145
	mov	bx,-10
146
	xor	cx,cx
146
	xor	cx,cx
147
	call	add_vector
147
	call	add_vector
148
	sub	[vect_y],10
148
	sub	[vect_y],10
149
	sub	[yo],10
149
	sub	[yo],10
150
      @@:
150
      @@:
151
	cmp	ah,8
151
	cmp	ah,8
152
	jne	@f
152
	jne	@f
153
	xor	ax,ax
153
	xor	ax,ax
154
	xor	bx,bx
154
	xor	bx,bx
155
	mov	cx,10
155
	mov	cx,10
156
	call	add_vector
156
	call	add_vector
157
	add	[vect_z],10
157
	add	[vect_z],10
158
	add	[zo],10
158
	add	[zo],10
159
      @@:
159
      @@:
160
	cmp	ah,9
160
	cmp	ah,9
161
	jne	@f
161
	jne	@f
162
	mov	ax,-10
162
	mov	ax,-10
163
	xor	bx,bx
163
	xor	bx,bx
164
	xor	cx,cx
164
	xor	cx,cx
165
	call	add_vector
165
	call	add_vector
166
	sub	[vect_x],10
166
	sub	[vect_x],10
167
	sub	[xo],10
167
	sub	[xo],10
168
      @@:
168
      @@:
169
	cmp	ah,10
169
	cmp	ah,10
170
	jne	@f
170
	jne	@f
171
	mov	ax,10
171
	mov	ax,10
172
	xor	bx,bx
172
	xor	bx,bx
173
	xor	cx,cx
173
	xor	cx,cx
174
	call	add_vector
174
	call	add_vector
175
	add	[vect_x],10
175
	add	[vect_x],10
176
	add	[xo],10
176
	add	[xo],10
177
      @@:
177
      @@:
178
	cmp	ah,11
178
	cmp	ah,11
179
	jne	@f
179
	jne	@f
180
	xor	ax,ax
180
	xor	ax,ax
181
	xor	bx,bx
181
	xor	bx,bx
182
	mov	cx,-10
182
	mov	cx,-10
183
	call	add_vector
183
	call	add_vector
184
	sub	[vect_z],10
184
	sub	[vect_z],10
185
	sub	[zo],10
185
	sub	[zo],10
186
      @@:
186
      @@:
187
	cmp	ah,12
187
	cmp	ah,12
188
	jne	@f
188
	jne	@f
189
	xor	ax,ax
189
	xor	ax,ax
190
	mov	bx,10
190
	mov	bx,10
191
	xor	cx,cx
191
	xor	cx,cx
192
	call	add_vector
192
	call	add_vector
193
	add	[vect_y],10
193
	add	[vect_y],10
194
	add	[yo],10
194
	add	[yo],10
195
      @@:
195
      @@:
196
	cmp	ah,13			 ; change main color -
196
	cmp	ah,13			 ; change main color -
197
	jne	@f			 ; - lead color setting
197
	jne	@f			 ; - lead color setting
198
	cmp	[max_color_r],245
198
	cmp	[max_color_r],245
199
	jge	@f
199
	jge	@f
200
	add	[max_color_r],10
200
	add	[max_color_r],10
201
	call	init_envmap
201
	call	init_envmap
202
      @@:
202
      @@:
203
	cmp	ah,14
203
	cmp	ah,14
204
	jne	@f
204
	jne	@f
205
	cmp	[max_color_g],245
205
	cmp	[max_color_g],245
206
	jge	@f
206
	jge	@f
207
	add	[max_color_g],10
207
	add	[max_color_g],10
208
	call	init_envmap
208
	call	init_envmap
209
      @@:
209
      @@:
210
	cmp	ah,15
210
	cmp	ah,15
211
	jne	@f
211
	jne	@f
212
	cmp	[max_color_b],245
212
	cmp	[max_color_b],245
213
	jge	@f
213
	jge	@f
214
	add	[max_color_b],10
214
	add	[max_color_b],10
215
	call	init_envmap
215
	call	init_envmap
216
      @@:
216
      @@:
217
	cmp	ah,16			 ; change main color
217
	cmp	ah,16			 ; change main color
218
	jne	@f
218
	jne	@f
219
	cmp	[max_color_r],10
219
	cmp	[max_color_r],10
220
	jle	@f
220
	jle	@f
221
	sub	[max_color_r],10
221
	sub	[max_color_r],10
222
	call	init_envmap
222
	call	init_envmap
223
      @@:
223
      @@:
224
	cmp	ah,17
224
	cmp	ah,17
225
	jne	@f
225
	jne	@f
226
	cmp	[max_color_g],10
226
	cmp	[max_color_g],10
227
	jle	@f
227
	jle	@f
228
	sub	[max_color_g],10
228
	sub	[max_color_g],10
229
	call	init_envmap
229
	call	init_envmap
230
      @@:
230
      @@:
231
	cmp	ah,18
231
	cmp	ah,18
232
	jne	@f
232
	jne	@f
233
	cmp	[max_color_b],10
233
	cmp	[max_color_b],10
234
	jle	@f
234
	jle	@f
235
	sub	[max_color_b],10
235
	sub	[max_color_b],10
236
	call	init_envmap
236
	call	init_envmap
237
      @@:
237
      @@:
238
	cmp	ah,19
238
	cmp	ah,19
239
	jne	@f
239
	jne	@f
240
	inc	[catmull_flag]
240
	inc	[catmull_flag]
241
	cmp	[catmull_flag],2
241
	cmp	[catmull_flag],2
242
	jne	@f
242
	jne	@f
243
	mov	[catmull_flag],0
243
	mov	[catmull_flag],0
244
      @@:
244
      @@:
245
    noclose:
245
    noclose:
246
 
246
 
247
	call	calculate_angle ; calculates sinus and cosinus
247
	call	calculate_angle ; calculates sinus and cosinus
248
	call	copy_point_normals
248
	call	copy_point_normals
249
   ; copy normals and rotate the copy using sin/cosbeta - best way
249
   ; copy normals and rotate the copy using sin/cosbeta - best way
250
	call	rotate_point_normals
250
	call	rotate_point_normals
251
	call	calculate_colors
251
	call	calculate_colors
252
	call	copy_points
252
	call	copy_points
253
	call	rotate_points
253
	call	rotate_points
254
	call	translate_perspective_points; translate from 3d to 2d
254
	call	translate_perspective_points; translate from 3d to 2d
255
	call	clrscr		; clear the screen
255
	call	clrscr		; clear the screen
256
	cmp	[dr_flag],2
256
	cmp	[dr_flag],2
257
	je	@f
257
	je	@f
258
	cmp	[catmull_flag],1  ;if env_mapping sort faces
258
	cmp	[catmull_flag],1  ;if env_mapping sort faces
259
	je	@f
259
	je	@f
260
      @@:
260
      @@:
261
	call	sort_triangles
261
	call	sort_triangles
262
      @@:
262
      @@:
263
	call	fill_Z_buffer
263
	call	fill_Z_buffer
264
 
264
 
265
    RDTSC
265
    RDTSC
266
    push eax
266
    push eax
267
	call	draw_triangles	; draw all triangles from the list
267
	call	draw_triangles	; draw all triangles from the list
268
 
268
 
269
    RDTSC
269
    RDTSC
270
    sub eax,[esp]
270
    sub eax,[esp]
271
    sub eax,41
271
    sub eax,41
272
    ;    lea     esi,[debug_points]
272
    ;    lea     esi,[debug_points]
273
    ;    lea     edi,[debug_points+6]
273
    ;    lea     edi,[debug_points+6]
274
    ;    lea     ebx,[debug_vector1]
274
    ;    lea     ebx,[debug_vector1]
275
    ;    call    make_vector
275
    ;    call    make_vector
276
    ;    fninit
276
    ;    fninit
277
    ;    fld     [sinbeta_one]
277
    ;    fld     [sinbeta_one]
278
    ;    fimul   [debug_dwd]
278
    ;    fimul   [debug_dwd]
279
    ;    fistp   [debug_dd]
279
    ;    fistp   [debug_dd]
280
    ;    movzx    eax,[debug_dd]
280
    ;    movzx    eax,[debug_dd]
281
 
281
 
282
 
282
 
283
    mov     ecx,10
283
    mov     ecx,10
284
  .dc:
284
  .dc:
285
    xor     edx,edx
285
    xor     edx,edx
286
    mov     edi,10
286
    mov     edi,10
287
    div     edi
287
    div     edi
288
    add     dl,30h
288
    add     dl,30h
289
    mov     [STRdata+ecx-1],dl
289
    mov     [STRdata+ecx-1],dl
290
    loop    .dc
290
    loop    .dc
291
    pop eax
291
    pop eax
292
macro show
292
macro show
293
{
293
{
294
	mov	eax,7		; put image
294
	mov	eax,7		; put image
295
	mov	ebx,screen
295
	mov	ebx,screen
296
	mov	ecx,SIZE_X shl 16 + SIZE_Y
296
	mov	ecx,SIZE_X shl 16 + SIZE_Y
297
	mov	edx,5 shl 16 + 20
297
	mov	edx,5 shl 16 + 20
298
	int	0x40
298
	int	0x40
299
}
299
}
300
    show
300
    show
301
    mov  eax,4			   ; function 4 : write text to window
301
    mov  eax,4			   ; function 4 : write text to window
302
    mov  ebx,5*65536+23 	   ; [x start] *65536 + [y start]
302
    mov  ebx,5*65536+23 	   ; [x start] *65536 + [y start]
303
    mov  ecx,-1
303
    mov  ecx,-1
304
    mov  edx,STRdata		   ; pointer to text beginning
304
    mov  edx,STRdata		   ; pointer to text beginning
305
    mov  esi,10 		   ; text length
305
    mov  esi,10 		   ; text length
306
    int  40h
306
    int  40h
307
 
307
 
308
 
308
 
309
 
309
 
310
	jmp	still
310
	jmp	still
311
 
311
 
312
;--------------------------------------------------------------------------------
312
;--------------------------------------------------------------------------------
313
;-------------------------PROCEDURES---------------------------------------------
313
;-------------------------PROCEDURES---------------------------------------------
314
;--------------------------------------------------------------------------------
314
;--------------------------------------------------------------------------------
315
include "../../3DS/TEX3.INC"
315
include "../../3DS/TEX3.INC"
316
include "../../3DS/FLAT_CAT.INC"
316
include "../../3DS/FLAT_CAT.INC"
317
include "../../3DS/GRD_CAT.INC"
317
include "../../3DS/GRD_CAT.INC"
318
include "../../3DS/3DMATH.INC"
318
include "../../3DS/3DMATH.INC"
319
include "../../3DS/GRD3.INC"
319
include "../../3DS/GRD3.INC"
320
include "../../3DS/FLAT3.INC"
320
include "../../3DS/FLAT3.INC"
-
 
321
 
-
 
322
fill_Z_buffer:
-
 
323
	mov	eax,0x70000000
-
 
324
      ;  mov     edi,Z_buffer
-
 
325
	mov	edi,[Zbuffer_ptr]
-
 
326
	mov	ecx,SIZE_X*SIZE_Y
-
 
327
	rep	stosd
-
 
328
ret
321
 
329
 
322
 
330
 
323
;alloc_buffer_mem:
331
;alloc_buffer_mem:
324
;        mov     eax,68
332
;        mov     eax,68
325
;        mov     ebx,5
333
;        mov     ebx,5
326
;        mov     ecx,SIZE_X*SIZE_Y*3
334
;        mov     ecx,SIZE_X*SIZE_Y*3
327
;        int     0x40
335
;        int     0x40
328
;        mov     [screen],eax
336
;        mov     [screen],eax
329
;ret
337
;ret
330
init_envmap:
338
init_envmap:
331
 
339
 
332
.temp equ word [ebp-2]
340
.temp equ word [ebp-2]
333
	 push	  ebp
341
	 push	  ebp
334
	 mov	  ebp,esp
342
	 mov	  ebp,esp
335
	 sub	  esp,2
343
	 sub	  esp,2
336
	 mov	  edi,envmap
344
	 mov	  edi,envmap
337
	 fninit
345
	 fninit
338
 
346
 
339
	 mov	  dx,-256
347
	 mov	  dx,-256
340
    .ie_ver:
348
    .ie_ver:
341
	 mov	  cx,-256
349
	 mov	  cx,-256
342
    .ie_hor:
350
    .ie_hor:
343
	 mov	  .temp,cx
351
	 mov	  .temp,cx
344
	 fild	  .temp
352
	 fild	  .temp
345
	 fmul	  st,st0
353
	 fmul	  st,st0
346
	 mov	  .temp,dx
354
	 mov	  .temp,dx
347
	 fild	  .temp
355
	 fild	  .temp
348
	 fmul	  st,st0
356
	 fmul	  st,st0
349
	 faddp
357
	 faddp
350
	 fsqrt
358
	 fsqrt
351
	 mov	  .temp,254
359
	 mov	  .temp,254
352
	 fisubr   .temp
360
	 fisubr   .temp
353
	 fmul	  [env_const]
361
	 fmul	  [env_const]
354
	 fistp	  .temp
362
	 fistp	  .temp
355
	 mov	  ax,.temp
363
	 mov	  ax,.temp
356
 
364
 
357
	 or	 ax,ax
365
	 or	 ax,ax
358
	 jge	 .ie_ok1
366
	 jge	 .ie_ok1
359
	 xor	 ax,ax
367
	 xor	 ax,ax
360
	 jmp	 .ie_ok2
368
	 jmp	 .ie_ok2
361
  .ie_ok1:
369
  .ie_ok1:
362
	 cmp	 ax,254
370
	 cmp	 ax,254
363
	 jle	 .ie_ok2
371
	 jle	 .ie_ok2
364
	 mov	 ax,254
372
	 mov	 ax,254
365
  .ie_ok2:
373
  .ie_ok2:
366
	 push	 dx
374
	 push	 dx
367
	 mov	 bx,ax
375
	 mov	 bx,ax
368
	 mul	 [max_color_b]
376
	 mul	 [max_color_b]
369
	 shr	 ax,8
377
	 shr	 ax,8
370
	 stosb
378
	 stosb
371
	 mov	 ax,bx
379
	 mov	 ax,bx
372
	 mul	 [max_color_g]
380
	 mul	 [max_color_g]
373
	 shr	 ax,8
381
	 shr	 ax,8
374
	 stosb
382
	 stosb
375
	 mov	 ax,bx
383
	 mov	 ax,bx
376
	 mul	 [max_color_r]
384
	 mul	 [max_color_r]
377
	 shr	 ax,8
385
	 shr	 ax,8
378
	 stosb
386
	 stosb
379
	 pop	 dx
387
	 pop	 dx
380
 
388
 
381
	 inc	 cx
389
	 inc	 cx
382
	 cmp	 cx,256
390
	 cmp	 cx,256
383
	 jne	 .ie_hor
391
	 jne	 .ie_hor
384
 
392
 
385
	 inc	 dx
393
	 inc	 dx
386
	 cmp	 dx,256
394
	 cmp	 dx,256
387
	 jne	 .ie_ver
395
	 jne	 .ie_ver
388
 
396
 
389
	 mov	 esp,ebp
397
	 mov	 esp,ebp
390
	 pop	 ebp
398
	 pop	 ebp
391
macro debug
399
macro debug
392
{
400
{
393
	 mov	 edi,envmap
401
	 mov	 edi,envmap
394
	 mov	 ecx,512*512*3/4
402
	 mov	 ecx,512*512*3/4
395
	 mov	 eax,0xffffffff
403
	 mov	 eax,0xffffffff
396
	 rep	 stosd
404
	 rep	 stosd
397
}
405
}
398
ret
406
ret
399
calculate_colors:
407
calculate_colors:
400
	fninit
408
	fninit
401
	xor	ebx,ebx
409
	xor	ebx,ebx
402
	movzx	ecx,[points_count_var]
410
	movzx	ecx,[points_count_var]
403
	lea	ecx,[ecx*3]
411
	lea	ecx,[ecx*3]
404
	add	ecx,ecx
412
	add	ecx,ecx
405
      .cc_again:
413
      .cc_again:
406
	mov	esi,light_vector
414
	mov	esi,light_vector
407
	lea	edi,[point_normals_rotated+ebx*2]
415
	lea	edi,[point_normals_rotated+ebx*2]
408
	call	dot_product
416
	call	dot_product
409
	fcom	[dot_min]
417
	fcom	[dot_min]
410
	fstsw	ax
418
	fstsw	ax
411
	sahf
419
	sahf
412
	ja	.cc_ok1
420
	ja	.cc_ok1
413
	ffree	st
421
	ffree	st
414
	mov	dword[points_color+ebx],0
422
	mov	dword[points_color+ebx],0
415
	mov	word[points_color+ebx+4],0
423
	mov	word[points_color+ebx+4],0
416
	add	ebx,6
424
	add	ebx,6
417
	cmp	ebx,ecx
425
	cmp	ebx,ecx
418
	jne	.cc_again
426
	jne	.cc_again
419
	jmp	.cc_done
427
	jmp	.cc_done
420
      .cc_ok1:
428
      .cc_ok1:
421
	fcom	[dot_max]
429
	fcom	[dot_max]
422
	fstsw	ax
430
	fstsw	ax
423
	sahf
431
	sahf
424
	jb	.cc_ok2
432
	jb	.cc_ok2
425
	ffree	st
433
	ffree	st
426
	mov	dword[points_color+ebx],0  ; clear r,g,b
434
	mov	dword[points_color+ebx],0  ; clear r,g,b
427
	mov	word[points_color+ebx+4],0
435
	mov	word[points_color+ebx+4],0
428
	add	ebx,6
436
	add	ebx,6
429
	cmp	ebx,ecx
437
	cmp	ebx,ecx
430
	jne	.cc_again
438
	jne	.cc_again
431
	jmp	.cc_done
439
	jmp	.cc_done
432
      .cc_ok2:
440
      .cc_ok2:
433
	fld	st
441
	fld	st
434
	fld	st
442
	fld	st
435
	fimul	[max_color_r]
443
	fimul	[max_color_r]
436
	fistp	word[points_color+ebx]	      ;each color as word
444
	fistp	word[points_color+ebx]	      ;each color as word
437
	fimul	[max_color_g]
445
	fimul	[max_color_g]
438
	fistp	word[points_color+ebx+2]
446
	fistp	word[points_color+ebx+2]
439
	fimul	[max_color_b]
447
	fimul	[max_color_b]
440
	fistp	word[points_color+ebx+4]
448
	fistp	word[points_color+ebx+4]
441
	add	ebx,6
449
	add	ebx,6
442
	cmp	ebx,ecx
450
	cmp	ebx,ecx
443
	jne	.cc_again
451
	jne	.cc_again
444
     .cc_done:
452
     .cc_done:
445
ret
453
ret
446
copy_point_normals:
454
copy_point_normals:
447
	movzx	ecx,[points_count_var]
455
	movzx	ecx,[points_count_var]
448
	shl	ecx,2
456
	shl	ecx,2
449
	inc	ecx
457
	inc	ecx
450
	mov	esi,point_normals
458
	mov	esi,point_normals
451
	mov	edi,point_normals_rotated
459
	mov	edi,point_normals_rotated
452
	rep	movsd
460
	rep	movsd
453
ret
461
ret
454
rotate_point_normals:
462
rotate_point_normals:
455
	movzx	ecx,[points_count_var]
463
	movzx	ecx,[points_count_var]
456
	mov	ebx,point_normals_rotated
464
	mov	ebx,point_normals_rotated
457
	fninit			   ; for now only rotate around Z axle
465
	fninit			   ; for now only rotate around Z axle
458
     .again_r:
466
     .again_r:
459
	cmp	[r_flag],1
467
	cmp	[r_flag],1
460
	je	.z_rot
468
	je	.z_rot
461
	cmp	[r_flag],2
469
	cmp	[r_flag],2
462
	je	.x_rot
470
	je	.x_rot
463
 
471
 
464
      .y_rot:
472
      .y_rot:
465
	fld	dword[ebx]	   ; x
473
	fld	dword[ebx]	   ; x
466
	fld	[sinbeta]
474
	fld	[sinbeta]
467
	fmul	dword[ebx+8]	   ; z * sinbeta
475
	fmul	dword[ebx+8]	   ; z * sinbeta
468
	fchs
476
	fchs
469
	fld	[cosbeta]
477
	fld	[cosbeta]
470
	fmul	dword[ebx]	   ; x * cosbeta
478
	fmul	dword[ebx]	   ; x * cosbeta
471
	faddp
479
	faddp
472
	fstp	dword[ebx]	   ; new x
480
	fstp	dword[ebx]	   ; new x
473
	fmul	[sinbeta]	   ; old x * sinbeta
481
	fmul	[sinbeta]	   ; old x * sinbeta
474
	fld	[cosbeta]
482
	fld	[cosbeta]
475
	fmul	dword[ebx+8]	   ; z * cosbeta
483
	fmul	dword[ebx+8]	   ; z * cosbeta
476
	faddp
484
	faddp
477
	fstp	dword[ebx+8]	   ; new z
485
	fstp	dword[ebx+8]	   ; new z
478
	add	ebx,12
486
	add	ebx,12
479
	loop	.y_rot
487
	loop	.y_rot
480
	jmp	.end_rot
488
	jmp	.end_rot
481
      .z_rot:
489
      .z_rot:
482
	fld	dword[ebx]	;x
490
	fld	dword[ebx]	;x
483
	fld	[sinbeta]
491
	fld	[sinbeta]
484
	fmul	dword[ebx+4]	;y
492
	fmul	dword[ebx+4]	;y
485
	fld	[cosbeta]
493
	fld	[cosbeta]
486
	fmul	dword[ebx]	;x
494
	fmul	dword[ebx]	;x
487
	faddp
495
	faddp
488
	fstp	dword[ebx]	;new x
496
	fstp	dword[ebx]	;new x
489
	fmul	[sinbeta]	; sinbeta * old x
497
	fmul	[sinbeta]	; sinbeta * old x
490
	fchs
498
	fchs
491
	fld	[cosbeta]
499
	fld	[cosbeta]
492
	fmul	dword[ebx+4]	     ; cosbeta * y
500
	fmul	dword[ebx+4]	     ; cosbeta * y
493
	faddp
501
	faddp
494
	fstp	dword[ebx+4]	; new y
502
	fstp	dword[ebx+4]	; new y
495
	add	ebx,12
503
	add	ebx,12
496
	loop	.z_rot
504
	loop	.z_rot
497
	jmp	.end_rot
505
	jmp	.end_rot
498
       .x_rot:
506
       .x_rot:
499
	fld	dword[ebx+4]	;y
507
	fld	dword[ebx+4]	;y
500
	fld	[sinbeta]
508
	fld	[sinbeta]
501
	fmul	dword[ebx+8]	;z
509
	fmul	dword[ebx+8]	;z
502
	fld	[cosbeta]
510
	fld	[cosbeta]
503
	fmul	dword[ebx+4]	;y
511
	fmul	dword[ebx+4]	;y
504
	faddp
512
	faddp
505
	fstp	dword[ebx+4]	; new y
513
	fstp	dword[ebx+4]	; new y
506
	fmul	[sinbeta]	; sinbeta * old y
514
	fmul	[sinbeta]	; sinbeta * old y
507
	fchs
515
	fchs
508
	fld	[cosbeta]
516
	fld	[cosbeta]
509
	fmul	dword[ebx+8]
517
	fmul	dword[ebx+8]
510
	faddp
518
	faddp
511
	fstp	dword[ebx+8]
519
	fstp	dword[ebx+8]
512
	add	ebx,12
520
	add	ebx,12
513
	loop	.x_rot
521
	loop	.x_rot
514
       .end_rot:
522
       .end_rot:
515
ret
523
ret
516
init_triangles_normals:
524
init_triangles_normals:
517
	mov	ebx,triangles_normals
525
	mov	ebx,triangles_normals
518
	mov	ebp,triangles
526
	mov	ebp,triangles
519
     @@:
527
     @@:
520
	push	ebx
528
	push	ebx
521
	mov	ebx,vectors
529
	mov	ebx,vectors
522
	movzx	esi,word[ebp]	       ; first point index
530
	movzx	esi,word[ebp]	       ; first point index
523
	lea	esi,[esi*3]
531
	lea	esi,[esi*3]
524
	lea	esi,[points+esi*2]     ; esi - pointer to 1st 3d point
532
	lea	esi,[points+esi*2]     ; esi - pointer to 1st 3d point
525
	movzx	edi,word[ebp+2]        ; second point index
533
	movzx	edi,word[ebp+2]        ; second point index
526
	lea	edi,[edi*3]
534
	lea	edi,[edi*3]
527
	lea	edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
535
	lea	edi,[points+edi*2]     ; edi - pointer to 2nd 3d point
528
	call	make_vector
536
	call	make_vector
529
	add	ebx,12
537
	add	ebx,12
530
	mov	esi,edi
538
	mov	esi,edi
531
	movzx	edi,word[ebp+4]        ; third point index
539
	movzx	edi,word[ebp+4]        ; third point index
532
	lea	edi,[edi*3]
540
	lea	edi,[edi*3]
533
	lea	edi,[points+edi*2]
541
	lea	edi,[points+edi*2]
534
	call	make_vector
542
	call	make_vector
535
	mov	edi,ebx 		; edi - pointer to 2nd vector
543
	mov	edi,ebx 		; edi - pointer to 2nd vector
536
	mov	esi,ebx
544
	mov	esi,ebx
537
	sub	esi,12			; esi - pointer to 1st vector
545
	sub	esi,12			; esi - pointer to 1st vector
538
	pop	ebx
546
	pop	ebx
539
	call	cross_product
547
	call	cross_product
540
	mov	edi,ebx
548
	mov	edi,ebx
541
	call	normalize_vector
549
	call	normalize_vector
542
	add	ebp,6
550
	add	ebp,6
543
	add	ebx,12
551
	add	ebx,12
544
	cmp	dword[ebp],-1
552
	cmp	dword[ebp],-1
545
	jne	@b
553
	jne	@b
546
ret
554
ret
547
 
555
 
548
init_point_normals:
556
init_point_normals:
549
.x equ dword [ebp-4]
557
.x equ dword [ebp-4]
550
.y equ dword [ebp-8]
558
.y equ dword [ebp-8]
551
.z equ dword [ebp-12]
559
.z equ dword [ebp-12]
552
.point_number equ word [ebp-26]
560
.point_number equ word [ebp-26]
553
.hit_faces    equ word [ebp-28]
561
.hit_faces    equ word [ebp-28]
554
 
562
 
555
	fninit
563
	fninit
556
	mov	  ebp,esp
564
	mov	  ebp,esp
557
	sub	  esp,28
565
	sub	  esp,28
558
	mov	  edi,point_normals
566
	mov	  edi,point_normals
559
	mov	  .point_number,0
567
	mov	  .point_number,0
560
    .ipn_loop:
568
    .ipn_loop:
561
	mov	  .hit_faces,0
569
	mov	  .hit_faces,0
562
	mov	  .x,0
570
	mov	  .x,0
563
	mov	  .y,0
571
	mov	  .y,0
564
	mov	  .z,0
572
	mov	  .z,0
565
	mov	  esi,triangles
573
	mov	  esi,triangles
566
	xor	  ecx,ecx	       ; ecx - triangle number
574
	xor	  ecx,ecx	       ; ecx - triangle number
567
    .ipn_check_face:
575
    .ipn_check_face:
568
	xor	  ebx,ebx	       ; ebx - 'position' in one triangle
576
	xor	  ebx,ebx	       ; ebx - 'position' in one triangle
569
    .ipn_check_vertex:
577
    .ipn_check_vertex:
570
	movzx	  eax,word[esi+ebx]    ;  eax - point_number
578
	movzx	  eax,word[esi+ebx]    ;  eax - point_number
571
	cmp	  ax,.point_number
579
	cmp	  ax,.point_number
572
	jne	  .ipn_next_vertex
580
	jne	  .ipn_next_vertex
573
	push	  esi
581
	push	  esi
574
	mov	  esi,ecx
582
	mov	  esi,ecx
575
	lea	  esi,[esi*3]
583
	lea	  esi,[esi*3]
576
	lea	  esi,[triangles_normals+esi*4]
584
	lea	  esi,[triangles_normals+esi*4]
577
       ; shl       esi,2
585
       ; shl       esi,2
578
       ; add       esi,triangles_normals
586
       ; add       esi,triangles_normals
579
 
587
 
580
	fld	  .x
588
	fld	  .x
581
	fadd	  dword[esi+vec_x]
589
	fadd	  dword[esi+vec_x]
582
	fstp	  .x
590
	fstp	  .x
583
	fld	  .y
591
	fld	  .y
584
	fadd	  dword[esi+vec_y]
592
	fadd	  dword[esi+vec_y]
585
	fstp	  .y
593
	fstp	  .y
586
	fld	  .z
594
	fld	  .z
587
	fadd	  dword[esi+vec_z]
595
	fadd	  dword[esi+vec_z]
588
	fstp	  .z
596
	fstp	  .z
589
	pop	  esi
597
	pop	  esi
590
	inc	  .hit_faces
598
	inc	  .hit_faces
591
	jmp	  .ipn_next_face
599
	jmp	  .ipn_next_face
592
    .ipn_next_vertex:
600
    .ipn_next_vertex:
593
	add	  ebx,2
601
	add	  ebx,2
594
	cmp	  ebx,6
602
	cmp	  ebx,6
595
	jne	  .ipn_check_vertex
603
	jne	  .ipn_check_vertex
596
    .ipn_next_face:
604
    .ipn_next_face:
597
	add	  esi,6
605
	add	  esi,6
598
	inc	  ecx
606
	inc	  ecx
599
	cmp	  cx,[triangles_count_var]
607
	cmp	  cx,[triangles_count_var]
600
	jne	  .ipn_check_face
608
	jne	  .ipn_check_face
601
 
609
 
602
	fld	  .x
610
	fld	  .x
603
	fidiv	  .hit_faces
611
	fidiv	  .hit_faces
604
	fstp	  dword[edi+vec_x]
612
	fstp	  dword[edi+vec_x]
605
	fld	  .y
613
	fld	  .y
606
	fidiv	  .hit_faces
614
	fidiv	  .hit_faces
607
	fstp	  dword[edi+vec_y]
615
	fstp	  dword[edi+vec_y]
608
	fld	  .z
616
	fld	  .z
609
	fidiv	  .hit_faces
617
	fidiv	  .hit_faces
610
	fstp	  dword[edi+vec_z]
618
	fstp	  dword[edi+vec_z]
611
	call	  normalize_vector
619
	call	  normalize_vector
612
	add	  edi,12  ;type vector 3d
620
	add	  edi,12  ;type vector 3d
613
	inc	  .point_number
621
	inc	  .point_number
614
	mov	  dx,.point_number
622
	mov	  dx,.point_number
615
	cmp	  dx,[points_count_var]
623
	cmp	  dx,[points_count_var]
616
	jne	  .ipn_loop
624
	jne	  .ipn_loop
617
 
625
 
618
	mov	  esp,ebp
626
	mov	  esp,ebp
619
ret
627
ret
620
 
628
 
621
add_vector:
629
add_vector:
622
	mov ebp,points
630
	mov ebp,points
623
       @@:
631
       @@:
624
	add word[ebp],ax
632
	add word[ebp],ax
625
	add word[ebp+2],bx
633
	add word[ebp+2],bx
626
	add word[ebp+4],cx
634
	add word[ebp+4],cx
627
	add ebp,6
635
	add ebp,6
628
	cmp dword[ebp],-1
636
	cmp dword[ebp],-1
629
	jne @b
637
	jne @b
630
ret
638
ret
631
;do_scale:
639
;do_scale:
632
;        fninit
640
;        fninit
633
;        mov ebp,points
641
;        mov ebp,points
634
;      .next_sc:
642
;      .next_sc:
635
;        fld1
643
;        fld1
636
;        fsub [scale]
644
;        fsub [scale]
637
;        fld st
645
;        fld st
638
;        fimul [xo]
646
;        fimul [xo]
639
;        fld [scale]
647
;        fld [scale]
640
;        fimul word[ebp] ;x
648
;        fimul word[ebp] ;x
641
;        faddp
649
;        faddp
642
;        fistp word[ebp]
650
;        fistp word[ebp]
643
;        fld st
651
;        fld st
644
;        fimul [yo]
652
;        fimul [yo]
645
;        fld [scale]
653
;        fld [scale]
646
;        fimul word[ebp+2]
654
;        fimul word[ebp+2]
647
;        faddp
655
;        faddp
648
;        fistp word[ebp+2]
656
;        fistp word[ebp+2]
649
;        fimul [zo]
657
;        fimul [zo]
650
;        fld [scale]
658
;        fld [scale]
651
;        fimul word[ebp+4]
659
;        fimul word[ebp+4]
652
;        faddp
660
;        faddp
653
;        fistp word[ebp+4]
661
;        fistp word[ebp+4]
654
;        add ebp,6
662
;        add ebp,6
655
;        cmp dword[ebp],-1
663
;        cmp dword[ebp],-1
656
;        jne .next_sc
664
;        jne .next_sc
657
;ret
665
;ret
658
sort_triangles:
666
sort_triangles:
659
	mov	esi,triangles
667
	mov	esi,triangles
660
	mov	edi,triangles_with_z
668
	mov	edi,triangles_with_z
661
	mov	ebp,points_rotated
669
	mov	ebp,points_rotated
662
 
670
 
663
    make_triangle_with_z:	;makes list with triangles and z position
671
    make_triangle_with_z:	;makes list with triangles and z position
664
	movzx	eax,word[esi]
672
	movzx	eax,word[esi]
665
	lea	eax,[eax*3]
673
	lea	eax,[eax*3]
666
	movzx	ecx,word[ebp+eax*2+4]
674
	movzx	ecx,word[ebp+eax*2+4]
667
 
675
 
668
	movzx	eax,word[esi+2]
676
	movzx	eax,word[esi+2]
669
	lea	eax,[eax*3]
677
	lea	eax,[eax*3]
670
	add	cx,word[ebp+eax*2+4]
678
	add	cx,word[ebp+eax*2+4]
671
 
679
 
672
	movzx	eax,word[esi+4]
680
	movzx	eax,word[esi+4]
673
	lea	eax,[eax*3]
681
	lea	eax,[eax*3]
674
	add	cx,word[ebp+eax*2+4]
682
	add	cx,word[ebp+eax*2+4]
675
 
683
 
676
	mov	ax,cx
684
	mov	ax,cx
677
       ; cwd
685
       ; cwd
678
       ; idiv    word[i3]
686
       ; idiv    word[i3]
679
	movsd			; store vertex coordinates
687
	movsd			; store vertex coordinates
680
	movsw
688
	movsw
681
	stosw			; middle vertex coordinate  'z' in triangles_with_z list
689
	stosw			; middle vertex coordinate  'z' in triangles_with_z list
682
	cmp	dword[esi],-1
690
	cmp	dword[esi],-1
683
	jne	make_triangle_with_z
691
	jne	make_triangle_with_z
684
	movsd			; copy end mark
692
	movsd			; copy end mark
685
	mov	eax,4
693
	mov	eax,4
686
	lea	edx,[edi-8-trizdd]
694
	lea	edx,[edi-8-trizdd]
687
	mov	[high],edx
695
	mov	[high],edx
688
	call	quicksort
696
	call	quicksort
689
	mov	eax,4
697
	mov	eax,4
690
	mov	edx,[high]
698
	mov	edx,[high]
691
	call	insertsort
699
	call	insertsort
692
	jmp	end_sort
700
	jmp	end_sort
693
 
701
 
694
    quicksort:
702
    quicksort:
695
	mov	ecx,edx
703
	mov	ecx,edx
696
	sub	ecx,eax
704
	sub	ecx,eax
697
	cmp	ecx,32
705
	cmp	ecx,32
698
	jc	.exit
706
	jc	.exit
699
	lea	ecx,[eax+edx]
707
	lea	ecx,[eax+edx]
700
	shr	ecx,4
708
	shr	ecx,4
701
	lea	ecx,[ecx*8-4]; i
709
	lea	ecx,[ecx*8-4]; i
702
	mov	ebx,[trizdd+eax]; trizdd[l]
710
	mov	ebx,[trizdd+eax]; trizdd[l]
703
	mov	esi,[trizdd+ecx]; trizdd[i]
711
	mov	esi,[trizdd+ecx]; trizdd[i]
704
	mov	edi,[trizdd+edx]; trizdd[h]
712
	mov	edi,[trizdd+edx]; trizdd[h]
705
	cmp	ebx,esi
713
	cmp	ebx,esi
706
	jg	@f		; direction NB! you need to negate these to invert the order
714
	jg	@f		; direction NB! you need to negate these to invert the order
707
      if Ext=NON
715
      if Ext=NON
708
	mov	[trizdd+eax],esi
716
	mov	[trizdd+eax],esi
709
	mov	[trizdd+ecx],ebx
717
	mov	[trizdd+ecx],ebx
710
	mov	ebx,[trizdd+eax-4]
718
	mov	ebx,[trizdd+eax-4]
711
	mov	esi,[trizdd+ecx-4]
719
	mov	esi,[trizdd+ecx-4]
712
	mov	[trizdd+eax-4],esi
720
	mov	[trizdd+eax-4],esi
713
	mov	[trizdd+ecx-4],ebx
721
	mov	[trizdd+ecx-4],ebx
714
	mov	ebx,[trizdd+eax]
722
	mov	ebx,[trizdd+eax]
715
	mov	esi,[trizdd+ecx]
723
	mov	esi,[trizdd+ecx]
716
      else
724
      else
717
	movq	mm0,[trizdq+eax-4]
725
	movq	mm0,[trizdq+eax-4]
718
	movq	mm1,[trizdq+ecx-4]
726
	movq	mm1,[trizdq+ecx-4]
719
	movq	[trizdq+ecx-4],mm0
727
	movq	[trizdq+ecx-4],mm0
720
	movq	[trizdq+eax-4],mm1
728
	movq	[trizdq+eax-4],mm1
721
	xchg	ebx,esi
729
	xchg	ebx,esi
722
      end if
730
      end if
723
      @@:
731
      @@:
724
	cmp	ebx,edi
732
	cmp	ebx,edi
725
	jg	@f		; direction
733
	jg	@f		; direction
726
      if Ext=NON
734
      if Ext=NON
727
	mov	[trizdd+eax],edi
735
	mov	[trizdd+eax],edi
728
	mov	[trizdd+edx],ebx
736
	mov	[trizdd+edx],ebx
729
	mov	ebx,[trizdd+eax-4]
737
	mov	ebx,[trizdd+eax-4]
730
	mov	edi,[trizdd+edx-4]
738
	mov	edi,[trizdd+edx-4]
731
	mov	[trizdd+eax-4],edi
739
	mov	[trizdd+eax-4],edi
732
	mov	[trizdd+edx-4],ebx
740
	mov	[trizdd+edx-4],ebx
733
	mov	ebx,[trizdd+eax]
741
	mov	ebx,[trizdd+eax]
734
	mov	edi,[trizdd+edx]
742
	mov	edi,[trizdd+edx]
735
      else
743
      else
736
	movq	mm0,[trizdq+eax-4]
744
	movq	mm0,[trizdq+eax-4]
737
	movq	mm1,[trizdq+edx-4]
745
	movq	mm1,[trizdq+edx-4]
738
	movq	[trizdq+edx-4],mm0
746
	movq	[trizdq+edx-4],mm0
739
	movq	[trizdq+eax-4],mm1
747
	movq	[trizdq+eax-4],mm1
740
	xchg	ebx,edi
748
	xchg	ebx,edi
741
      end if
749
      end if
742
      @@:
750
      @@:
743
	cmp	esi,edi
751
	cmp	esi,edi
744
	jg	@f		; direction
752
	jg	@f		; direction
745
      if Ext=NON
753
      if Ext=NON
746
	mov	[trizdd+ecx],edi
754
	mov	[trizdd+ecx],edi
747
	mov	[trizdd+edx],esi
755
	mov	[trizdd+edx],esi
748
	mov	esi,[trizdd+ecx-4]
756
	mov	esi,[trizdd+ecx-4]
749
	mov	edi,[trizdd+edx-4]
757
	mov	edi,[trizdd+edx-4]
750
	mov	[trizdd+ecx-4],edi
758
	mov	[trizdd+ecx-4],edi
751
	mov	[trizdd+edx-4],esi
759
	mov	[trizdd+edx-4],esi
752
      else
760
      else
753
	movq	mm0,[trizdq+ecx-4]
761
	movq	mm0,[trizdq+ecx-4]
754
	movq	mm1,[trizdq+edx-4]
762
	movq	mm1,[trizdq+edx-4]
755
	movq	[trizdq+edx-4],mm0
763
	movq	[trizdq+edx-4],mm0
756
	movq	[trizdq+ecx-4],mm1
764
	movq	[trizdq+ecx-4],mm1
757
;        xchg    ebx,esi
765
;        xchg    ebx,esi
758
      end if
766
      end if
759
      @@:
767
      @@:
760
	mov	ebp,eax 	; direction
768
	mov	ebp,eax 	; direction
761
	add	ebp,8	   ;   j
769
	add	ebp,8	   ;   j
762
      if Ext=NON
770
      if Ext=NON
763
	mov	esi,[trizdd+ebp]
771
	mov	esi,[trizdd+ebp]
764
	mov	edi,[trizdd+ecx]
772
	mov	edi,[trizdd+ecx]
765
	mov	[trizdd+ebp],edi
773
	mov	[trizdd+ebp],edi
766
	mov	[trizdd+ecx],esi
774
	mov	[trizdd+ecx],esi
767
	mov	esi,[trizdd+ebp-4]
775
	mov	esi,[trizdd+ebp-4]
768
	mov	edi,[trizdd+ecx-4]
776
	mov	edi,[trizdd+ecx-4]
769
	mov	[trizdd+ecx-4],esi
777
	mov	[trizdd+ecx-4],esi
770
	mov	[trizdd+ebp-4],edi
778
	mov	[trizdd+ebp-4],edi
771
      else
779
      else
772
	movq	mm0,[trizdq+ebp-4]
780
	movq	mm0,[trizdq+ebp-4]
773
	movq	mm1,[trizdq+ecx-4]
781
	movq	mm1,[trizdq+ecx-4]
774
	movq	[trizdq+ecx-4],mm0
782
	movq	[trizdq+ecx-4],mm0
775
	movq	[trizdq+ebp-4],mm1
783
	movq	[trizdq+ebp-4],mm1
776
      end if
784
      end if
777
	mov	ecx,edx    ;   i; direction
785
	mov	ecx,edx    ;   i; direction
778
	mov	ebx,[trizdd+ebp]; trizdd[j]
786
	mov	ebx,[trizdd+ebp]; trizdd[j]
779
      .loop:
787
      .loop:
780
	sub	ecx,8		; direction
788
	sub	ecx,8		; direction
781
	cmp	[trizdd+ecx],ebx
789
	cmp	[trizdd+ecx],ebx
782
	jl	.loop		; direction
790
	jl	.loop		; direction
783
      @@:
791
      @@:
784
	add	ebp,8		; direction
792
	add	ebp,8		; direction
785
	cmp	[trizdd+ebp],ebx
793
	cmp	[trizdd+ebp],ebx
786
	jg	@b		; direction
794
	jg	@b		; direction
787
	cmp	ebp,ecx
795
	cmp	ebp,ecx
788
	jge	@f		; direction
796
	jge	@f		; direction
789
      if Ext=NON
797
      if Ext=NON
790
	mov	esi,[trizdd+ecx]
798
	mov	esi,[trizdd+ecx]
791
	mov	edi,[trizdd+ebp]
799
	mov	edi,[trizdd+ebp]
792
	mov	[trizdd+ebp],esi
800
	mov	[trizdd+ebp],esi
793
	mov	[trizdd+ecx],edi
801
	mov	[trizdd+ecx],edi
794
	mov	edi,[trizdd+ecx-4]
802
	mov	edi,[trizdd+ecx-4]
795
	mov	esi,[trizdd+ebp-4]
803
	mov	esi,[trizdd+ebp-4]
796
	mov	[trizdd+ebp-4],edi
804
	mov	[trizdd+ebp-4],edi
797
	mov	[trizdd+ecx-4],esi
805
	mov	[trizdd+ecx-4],esi
798
      else
806
      else
799
	movq	mm0,[trizdq+ecx-4]
807
	movq	mm0,[trizdq+ecx-4]
800
	movq	mm1,[trizdq+ebp-4]
808
	movq	mm1,[trizdq+ebp-4]
801
	movq	[trizdq+ebp-4],mm0
809
	movq	[trizdq+ebp-4],mm0
802
	movq	[trizdq+ecx-4],mm1
810
	movq	[trizdq+ecx-4],mm1
803
      end if
811
      end if
804
	jmp	.loop
812
	jmp	.loop
805
      @@:
813
      @@:
806
      if Ext=NON
814
      if Ext=NON
807
	mov	esi,[trizdd+ecx]
815
	mov	esi,[trizdd+ecx]
808
	mov	edi,[trizdd+eax+8]
816
	mov	edi,[trizdd+eax+8]
809
	mov	[trizdd+eax+8],esi
817
	mov	[trizdd+eax+8],esi
810
	mov	[trizdd+ecx],edi
818
	mov	[trizdd+ecx],edi
811
	mov	edi,[trizdd+ecx-4]
819
	mov	edi,[trizdd+ecx-4]
812
	mov	esi,[trizdd+eax+4]
820
	mov	esi,[trizdd+eax+4]
813
	mov	[trizdd+eax+4],edi
821
	mov	[trizdd+eax+4],edi
814
	mov	[trizdd+ecx-4],esi
822
	mov	[trizdd+ecx-4],esi
815
      else
823
      else
816
	movq	mm0,[trizdq+ecx-4]
824
	movq	mm0,[trizdq+ecx-4]
817
	movq	mm1,[trizdq+eax+4]; dir
825
	movq	mm1,[trizdq+eax+4]; dir
818
	movq	[trizdq+eax+4],mm0; dir
826
	movq	[trizdq+eax+4],mm0; dir
819
	movq	[trizdq+ecx-4],mm1
827
	movq	[trizdq+ecx-4],mm1
820
      end if
828
      end if
821
	add	ecx,8
829
	add	ecx,8
822
	push	ecx edx
830
	push	ecx edx
823
	mov	edx,ebp
831
	mov	edx,ebp
824
	call	quicksort
832
	call	quicksort
825
	pop	edx eax
833
	pop	edx eax
826
	call	quicksort
834
	call	quicksort
827
      .exit:
835
      .exit:
828
    ret
836
    ret
829
    insertsort:
837
    insertsort:
830
	mov	esi,eax
838
	mov	esi,eax
831
      .start:
839
      .start:
832
	add	esi,8
840
	add	esi,8
833
	cmp	esi,edx
841
	cmp	esi,edx
834
	ja	.exit
842
	ja	.exit
835
	mov	ebx,[trizdd+esi]
843
	mov	ebx,[trizdd+esi]
836
      if Ext=NON
844
      if Ext=NON
837
	mov	ecx,[trizdd+esi-4]
845
	mov	ecx,[trizdd+esi-4]
838
      else
846
      else
839
	movq	mm1,[trizdq+esi-4]
847
	movq	mm1,[trizdq+esi-4]
840
      end if
848
      end if
841
	mov	edi,esi
849
	mov	edi,esi
842
      @@:
850
      @@:
843
	cmp	edi,eax
851
	cmp	edi,eax
844
	jna	@f
852
	jna	@f
845
	cmp	[trizdd+edi-8],ebx
853
	cmp	[trizdd+edi-8],ebx
846
	jg	@f		   ; direction
854
	jg	@f		   ; direction
847
      if Ext=NON
855
      if Ext=NON
848
	mov	ebp,[trizdd+edi-8]
856
	mov	ebp,[trizdd+edi-8]
849
	mov	[trizdd+edi],ebp
857
	mov	[trizdd+edi],ebp
850
	mov	ebp,[trizdd+edi-12]
858
	mov	ebp,[trizdd+edi-12]
851
	mov	[trizdd+edi-4],ebp
859
	mov	[trizdd+edi-4],ebp
852
      else
860
      else
853
	movq	mm0,[trizdq+edi-12]
861
	movq	mm0,[trizdq+edi-12]
854
	movq	[trizdq+edi-4],mm0
862
	movq	[trizdq+edi-4],mm0
855
      end if
863
      end if
856
	sub	edi,8
864
	sub	edi,8
857
	jmp	@b
865
	jmp	@b
858
      @@:
866
      @@:
859
      if Ext=NON
867
      if Ext=NON
860
	mov	[trizdd+edi],ebx
868
	mov	[trizdd+edi],ebx
861
	mov	[trizdd+edi-4],ecx
869
	mov	[trizdd+edi-4],ecx
862
      else
870
      else
863
	movq	[trizdq+edi-4],mm1
871
	movq	[trizdq+edi-4],mm1
864
      end if
872
      end if
865
	jmp	.start
873
	jmp	.start
866
      .exit:
874
      .exit:
867
    ret
875
    ret
868
   end_sort:
876
   end_sort:
869
    ; translate triangles_with_z to sorted_triangles
877
    ; translate triangles_with_z to sorted_triangles
870
	mov	esi,triangles_with_z
878
	mov	esi,triangles_with_z
871
      ;  mov     edi,sorted_triangles
879
      ;  mov     edi,sorted_triangles
872
	mov	 edi,triangles
880
	mov	 edi,triangles
873
    again_copy:
881
    again_copy:
874
      if Ext=NON
882
      if Ext=NON
875
	movsd
883
	movsd
876
	movsw
884
	movsw
877
	add	esi,2
885
	add	esi,2
878
      else
886
      else
879
	movq	mm0,[esi]
887
	movq	mm0,[esi]
880
	movq	[edi],mm0
888
	movq	[edi],mm0
881
	add	esi,8
889
	add	esi,8
882
	add	edi,6
890
	add	edi,6
883
      end if
891
      end if
884
	cmp	dword[esi],-1
892
	cmp	dword[esi],-1
885
	jne	again_copy
893
	jne	again_copy
886
;      if Ext=MMX
894
;      if Ext=MMX
887
;        emms
895
;        emms
888
;      end if
896
;      end if
889
	movsd  ; copy end mark too
897
	movsd  ; copy end mark too
890
ret
898
ret
891
 
899
 
892
clrscr:
900
clrscr:
893
	mov	edi,screen
901
	mov	edi,screen
894
	mov	ecx,SIZE_X*SIZE_Y*3/4
902
	mov	ecx,SIZE_X*SIZE_Y*3/4
895
	xor	eax,eax
903
	xor	eax,eax
896
      if Ext=NON
904
      if Ext=NON
897
	rep	stosd
905
	rep	stosd
898
      else
906
      else
899
	pxor	mm0,mm0
907
	pxor	mm0,mm0
900
      @@:
908
      @@:
901
	movq	[edi+00],mm0
909
	movq	[edi+00],mm0
902
	movq	[edi+08],mm0
910
	movq	[edi+08],mm0
903
	movq	[edi+16],mm0
911
	movq	[edi+16],mm0
904
	movq	[edi+24],mm0
912
	movq	[edi+24],mm0
905
	add	edi,32
913
	add	edi,32
906
	sub	ecx,8
914
	sub	ecx,8
907
	jnc	@b
915
	jnc	@b
908
      end if
916
      end if
909
ret
917
ret
910
 
918
 
911
calculate_angle:
919
calculate_angle:
912
	fninit
920
	fninit
913
;        fldpi
921
;        fldpi
914
;        fidiv   [i180]
922
;        fidiv   [i180]
915
	fld	[piD180]
923
	fld	[piD180]
916
	fimul	[angle_counter]
924
	fimul	[angle_counter]
917
	fsincos
925
	fsincos
918
	fstp	[sinbeta]
926
	fstp	[sinbeta]
919
	fstp	[cosbeta]
927
	fstp	[cosbeta]
920
	inc	[angle_counter]
928
	inc	[angle_counter]
921
	cmp	[angle_counter],360
929
	cmp	[angle_counter],360
922
	jne	end_calc_angle
930
	jne	end_calc_angle
923
	mov	[angle_counter],0
931
	mov	[angle_counter],0
924
    end_calc_angle:
932
    end_calc_angle:
925
ret
933
ret
926
 
934
 
927
rotate_points:
935
rotate_points:
928
	fninit
936
	fninit
929
	mov	ebx,points_rotated
937
	mov	ebx,points_rotated
930
    again_r:
938
    again_r:
931
	cmp	[r_flag],1
939
	cmp	[r_flag],1
932
	je	.z_rot
940
	je	.z_rot
933
	cmp	[r_flag],2
941
	cmp	[r_flag],2
934
	je	.x_rot
942
	je	.x_rot
935
    .y_rot:
943
    .y_rot:
936
	mov	eax,[ebx+2]	;z
944
	mov	eax,[ebx+2]	;z
937
	mov	ax,word[ebx]	;x
945
	mov	ax,word[ebx]	;x
938
	sub	eax,dword[xo]
946
	sub	eax,dword[xo]
939
	mov	dword[xsub],eax
947
	mov	dword[xsub],eax
940
	fld	[sinbeta]
948
	fld	[sinbeta]
941
	fimul	[zsub]
949
	fimul	[zsub]
942
	fchs
950
	fchs
943
	fld	[cosbeta]
951
	fld	[cosbeta]
944
	fimul	[xsub]
952
	fimul	[xsub]
945
	faddp
953
	faddp
946
	fiadd	[xo]
954
	fiadd	[xo]
947
	fistp	word[ebx]  ;x
955
	fistp	word[ebx]  ;x
948
	fld	[sinbeta]
956
	fld	[sinbeta]
949
	fimul	[xsub]
957
	fimul	[xsub]
950
	fld	[cosbeta]
958
	fld	[cosbeta]
951
	fimul	[zsub]
959
	fimul	[zsub]
952
	faddp
960
	faddp
953
	fiadd	[zo]
961
	fiadd	[zo]
954
	fistp	word[ebx+4] ;z
962
	fistp	word[ebx+4] ;z
955
	jmp	.end_rot
963
	jmp	.end_rot
956
   .z_rot:
964
   .z_rot:
957
	mov	ax,word[ebx]
965
	mov	ax,word[ebx]
958
	sub	ax,word[xo]	  ;need optimization
966
	sub	ax,word[xo]	  ;need optimization
959
	mov	[xsub],ax
967
	mov	[xsub],ax
960
	mov	ax,word[ebx+2]
968
	mov	ax,word[ebx+2]
961
	sub	ax,word[yo]
969
	sub	ax,word[yo]
962
	mov	[ysub],ax
970
	mov	[ysub],ax
963
	fld	[sinbeta]
971
	fld	[sinbeta]
964
	fimul	[ysub]
972
	fimul	[ysub]
965
	fld	[cosbeta]
973
	fld	[cosbeta]
966
	fimul	[xsub]
974
	fimul	[xsub]
967
	faddp
975
	faddp
968
	fiadd	[xo]
976
	fiadd	[xo]
969
	fistp	word[ebx]
977
	fistp	word[ebx]
970
	fld	[cosbeta]
978
	fld	[cosbeta]
971
	fimul	[ysub]
979
	fimul	[ysub]
972
	fld	[sinbeta]
980
	fld	[sinbeta]
973
	fimul	[xsub]
981
	fimul	[xsub]
974
	fchs
982
	fchs
975
	faddp
983
	faddp
976
	fiadd	[yo]
984
	fiadd	[yo]
977
	fistp	word[ebx+2]
985
	fistp	word[ebx+2]
978
	jmp	.end_rot
986
	jmp	.end_rot
979
   .x_rot:
987
   .x_rot:
980
	mov	ax,word[ebx+2]
988
	mov	ax,word[ebx+2]
981
	sub	ax,[yo]
989
	sub	ax,[yo]
982
	mov	[ysub],ax
990
	mov	[ysub],ax
983
	mov	ax,word[ebx+4]
991
	mov	ax,word[ebx+4]
984
	sub	ax,word[zo]
992
	sub	ax,word[zo]
985
	mov	[zsub],ax
993
	mov	[zsub],ax
986
	fld	[sinbeta]
994
	fld	[sinbeta]
987
	fimul	[zsub]
995
	fimul	[zsub]
988
	fld	[cosbeta]
996
	fld	[cosbeta]
989
	fimul	[ysub]
997
	fimul	[ysub]
990
	faddp
998
	faddp
991
	fiadd	[yo]
999
	fiadd	[yo]
992
	fistp	word[ebx+2];y
1000
	fistp	word[ebx+2];y
993
	fld	[cosbeta]
1001
	fld	[cosbeta]
994
	fimul	[zsub]
1002
	fimul	[zsub]
995
	fld	[sinbeta]
1003
	fld	[sinbeta]
996
	fimul	[ysub]
1004
	fimul	[ysub]
997
	fchs
1005
	fchs
998
	faddp
1006
	faddp
999
	fiadd	[zo]
1007
	fiadd	[zo]
1000
	fistp	word[ebx+4]
1008
	fistp	word[ebx+4]
1001
     .end_rot:
1009
     .end_rot:
1002
	add	ebx,6
1010
	add	ebx,6
1003
	cmp	dword[ebx],-1
1011
	cmp	dword[ebx],-1
1004
	jne	again_r
1012
	jne	again_r
1005
ret
1013
ret
1006
 
1014
 
1007
draw_triangles:
1015
draw_triangles:
1008
	mov esi,triangles
1016
	mov esi,triangles
1009
    .again_dts:
1017
    .again_dts:
1010
	mov ebp,points_rotated
1018
	mov ebp,points_rotated
1011
      if Ext=NON
1019
      if Ext=NON
1012
	movzx	eax,word[esi]
1020
	movzx	eax,word[esi]
1013
	mov	[point_index1],ax
1021
	mov	[point_index1],ax
1014
	lea	eax,[eax*3]
1022
	lea	eax,[eax*3]
1015
	add	eax,eax
1023
	add	eax,eax
1016
	push	ebp
1024
	push	ebp
1017
	add	ebp,eax
1025
	add	ebp,eax
1018
	mov	eax,[ebp]
1026
	mov	eax,[ebp]
1019
	mov	dword[xx1],eax
1027
	mov	dword[xx1],eax
1020
	mov	eax,[ebp+4]
1028
	mov	eax,[ebp+4]
1021
	mov	[zz1],ax
1029
	mov	[zz1],ax
1022
	pop	ebp
1030
	pop	ebp
1023
 
1031
 
1024
 
1032
 
1025
	movzx	eax,word[esi+2]
1033
	movzx	eax,word[esi+2]
1026
	mov	[point_index2],ax
1034
	mov	[point_index2],ax
1027
	lea	eax,[eax*3]
1035
	lea	eax,[eax*3]
1028
	add	eax,eax
1036
	add	eax,eax
1029
	push	ebp
1037
	push	ebp
1030
	add	ebp,eax
1038
	add	ebp,eax
1031
	mov	eax,[ebp]
1039
	mov	eax,[ebp]
1032
	mov	dword[xx2],eax
1040
	mov	dword[xx2],eax
1033
	mov	eax,[ebp+4]
1041
	mov	eax,[ebp+4]
1034
	mov	[zz2],ax
1042
	mov	[zz2],ax
1035
	pop	ebp
1043
	pop	ebp
1036
 
1044
 
1037
 
1045
 
1038
	movzx	eax,word[esi+4]        ; xyz3 = [ebp+[esi+4]*6]
1046
	movzx	eax,word[esi+4]        ; xyz3 = [ebp+[esi+4]*6]
1039
	mov	[point_index3],ax
1047
	mov	[point_index3],ax
1040
	lea	eax,[eax*3]
1048
	lea	eax,[eax*3]
1041
	add	eax,eax
1049
	add	eax,eax
1042
    ;    push    ebp
1050
    ;    push    ebp
1043
	add	ebp,eax
1051
	add	ebp,eax
1044
	mov	eax,[ebp]
1052
	mov	eax,[ebp]
1045
	mov	dword[xx3],eax
1053
	mov	dword[xx3],eax
1046
	mov	eax,[ebp+4]
1054
	mov	eax,[ebp+4]
1047
	mov	[zz3],ax
1055
	mov	[zz3],ax
1048
      else
1056
      else
1049
	mov	eax,dword[esi]		 ; don't know MMX
1057
	mov	eax,dword[esi]		 ; don't know MMX
1050
	mov	dword[point_index1],eax
1058
	mov	dword[point_index1],eax
1051
       ; shr     eax,16
1059
       ; shr     eax,16
1052
       ; mov     [point_index2],ax
1060
       ; mov     [point_index2],ax
1053
	mov	ax,word[esi+4]
1061
	mov	ax,word[esi+4]
1054
	mov	[point_index3],ax
1062
	mov	[point_index3],ax
1055
	movq	mm0,[esi]
1063
	movq	mm0,[esi]
1056
	pmullw	mm0,qword[const6]
1064
	pmullw	mm0,qword[const6]
1057
	movd	eax,mm0
1065
	movd	eax,mm0
1058
	psrlq	mm0,16
1066
	psrlq	mm0,16
1059
	movd	ebx,mm0
1067
	movd	ebx,mm0
1060
	psrlq	mm0,16
1068
	psrlq	mm0,16
1061
	movd	ecx,mm0
1069
	movd	ecx,mm0
1062
	and	eax,0FFFFh
1070
	and	eax,0FFFFh
1063
	and	ebx,0FFFFh
1071
	and	ebx,0FFFFh
1064
	and	ecx,0FFFFh
1072
	and	ecx,0FFFFh
1065
	movq	mm0,[ebp+eax]
1073
	movq	mm0,[ebp+eax]
1066
	movq	mm1,[ebp+ebx]
1074
	movq	mm1,[ebp+ebx]
1067
	movq	mm2,[ebp+ecx]
1075
	movq	mm2,[ebp+ecx]
1068
	movq	qword[xx1],mm0
1076
	movq	qword[xx1],mm0
1069
	movq	qword[xx2],mm1
1077
	movq	qword[xx2],mm1
1070
	movq	qword[xx3],mm2
1078
	movq	qword[xx3],mm2
1071
;        emms
1079
;        emms
1072
      end if
1080
      end if
1073
	push esi
1081
	push esi
1074
	; culling
1082
	; culling
1075
	fninit
1083
	fninit
1076
	mov	esi,point_index1
1084
	mov	esi,point_index1
1077
	mov	ecx,3
1085
	mov	ecx,3
1078
      @@:
1086
      @@:
1079
	movzx	eax,word[esi]
1087
	movzx	eax,word[esi]
1080
	lea	eax,[eax*3]
1088
	lea	eax,[eax*3]
1081
	shl	eax,2
1089
	shl	eax,2
1082
	lea	eax,[eax+point_normals_rotated]
1090
	lea	eax,[eax+point_normals_rotated]
1083
	fld	dword[eax+8]
1091
	fld	dword[eax+8]
1084
	ftst
1092
	ftst
1085
	fstsw	ax
1093
	fstsw	ax
1086
	sahf
1094
	sahf
1087
	jb     @f
1095
	jb     @f
1088
	ffree	st
1096
	ffree	st
1089
	loop	@b
1097
	loop	@b
1090
	jmp	.end_draw
1098
	jmp	.end_draw
1091
      @@:
1099
      @@:
1092
	ffree	st  ;is visable
1100
	ffree	st  ;is visable
1093
 
1101
 
1094
	cmp	[dr_flag],0		  ; draw type flag
1102
	cmp	[dr_flag],0		  ; draw type flag
1095
	je	.flat_draw
1103
	je	.flat_draw
1096
	cmp	[dr_flag],2
1104
	cmp	[dr_flag],2
1097
	je	.env_mapping
1105
	je	.env_mapping
1098
 
1106
 
1099
	movzx	edi,[point_index3]
1107
	movzx	edi,[point_index3]
1100
	lea	edi,[edi*3]
1108
	lea	edi,[edi*3]
1101
	lea	edi,[points_color+edi*2]
1109
	lea	edi,[points_color+edi*2]
1102
	cmp	[catmull_flag],0
1110
	cmp	[catmull_flag],0
1103
	je	@f
1111
	je	@f
1104
	push	[zz3]
1112
	push	[zz3]
1105
      @@:
1113
      @@:
1106
	push	word[edi]
1114
	push	word[edi]
1107
	push	word[edi+2]
1115
	push	word[edi+2]
1108
	push	word[edi+4]
1116
	push	word[edi+4]
1109
	movzx	edi,[point_index2]
1117
	movzx	edi,[point_index2]
1110
	lea	edi,[edi*3]
1118
	lea	edi,[edi*3]
1111
	lea	edi,[points_color+edi*2]
1119
	lea	edi,[points_color+edi*2]
1112
	cmp	[catmull_flag],0
1120
	cmp	[catmull_flag],0
1113
	je	@f
1121
	je	@f
1114
	push	[zz2]
1122
	push	[zz2]
1115
     @@:
1123
     @@:
1116
	push	word[edi]
1124
	push	word[edi]
1117
	push	word[edi+2]
1125
	push	word[edi+2]
1118
	push	word[edi+4]
1126
	push	word[edi+4]
1119
	movzx	edi,[point_index1]
1127
	movzx	edi,[point_index1]
1120
	lea	edi,[edi*3]
1128
	lea	edi,[edi*3]
1121
	lea	edi,[points_color+edi*2]
1129
	lea	edi,[points_color+edi*2]
1122
	cmp	[catmull_flag],0
1130
	cmp	[catmull_flag],0
1123
	je	@f
1131
	je	@f
1124
	push	[zz1]
1132
	push	[zz1]
1125
      @@:
1133
      @@:
1126
	push	word[edi]
1134
	push	word[edi]
1127
	push	word[edi+2]
1135
	push	word[edi+2]
1128
	push	word[edi+4]
1136
	push	word[edi+4]
1129
 
1137
 
1130
   ;     movzx   edi,[point_index3]   ;gouraud shading according to light vector
1138
   ;     movzx   edi,[point_index3]   ;gouraud shading according to light vector
1131
   ;     lea     edi,[edi*3]
1139
   ;     lea     edi,[edi*3]
1132
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1140
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1133
   ;     mov     esi,light_vector
1141
   ;     mov     esi,light_vector
1134
   ;     call    dot_product
1142
   ;     call    dot_product
1135
   ;     fabs
1143
   ;     fabs
1136
   ;     fimul   [max_color_r]
1144
   ;     fimul   [max_color_r]
1137
   ;     fistp   [temp_col]
1145
   ;     fistp   [temp_col]
1138
   ;     and     [temp_col],0x00ff
1146
   ;     and     [temp_col],0x00ff
1139
   ;     push    [temp_col]
1147
   ;     push    [temp_col]
1140
   ;     push    [temp_col]
1148
   ;     push    [temp_col]
1141
   ;     push    [temp_col]
1149
   ;     push    [temp_col]
1142
 
1150
 
1143
   ;     movzx   edi,[point_index2]
1151
   ;     movzx   edi,[point_index2]
1144
   ;     lea     edi,[edi*3]
1152
   ;     lea     edi,[edi*3]
1145
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1153
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1146
   ;     mov     esi,light_vector
1154
   ;     mov     esi,light_vector
1147
   ;     call    dot_product
1155
   ;     call    dot_product
1148
   ;     fabs
1156
   ;     fabs
1149
   ;     fimul   [max_color_r]
1157
   ;     fimul   [max_color_r]
1150
   ;     fistp    [temp_col]
1158
   ;     fistp    [temp_col]
1151
   ;     and     [temp_col],0x00ff
1159
   ;     and     [temp_col],0x00ff
1152
   ;     push    [temp_col]
1160
   ;     push    [temp_col]
1153
   ;     push    [temp_col]
1161
   ;     push    [temp_col]
1154
   ;     push    [temp_col]
1162
   ;     push    [temp_col]
1155
 
1163
 
1156
   ;     movzx   edi,[point_index1]
1164
   ;     movzx   edi,[point_index1]
1157
   ;     lea     edi,[edi*3]
1165
   ;     lea     edi,[edi*3]
1158
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1166
   ;     lea     edi,[4*edi+point_normals_rotated] ; edi - normal
1159
   ;     mov     esi,light_vector
1167
   ;     mov     esi,light_vector
1160
   ;     call    dot_product
1168
   ;     call    dot_product
1161
   ;     fabs
1169
   ;     fabs
1162
   ;     fimul   [max_color_r]
1170
   ;     fimul   [max_color_r]
1163
   ;     fistp   [temp_col]
1171
   ;     fistp   [temp_col]
1164
   ;     and     [temp_col],0x00ff
1172
   ;     and     [temp_col],0x00ff
1165
   ;     push    [temp_col]
1173
   ;     push    [temp_col]
1166
   ;     push    [temp_col]
1174
   ;     push    [temp_col]
1167
   ;     push    [temp_col]
1175
   ;     push    [temp_col]
1168
 
1176
 
1169
;        xor     edx,edx            ; draw acording to position
1177
;        xor     edx,edx            ; draw acording to position
1170
;        mov     ax,[zz3]
1178
;        mov     ax,[zz3]
1171
;        add     ax,128
1179
;        add     ax,128
1172
;        neg     al
1180
;        neg     al
1173
;        and     ax,0x00ff
1181
;        and     ax,0x00ff
1174
;        push    ax
1182
;        push    ax
1175
;        neg     al
1183
;        neg     al
1176
;        push    ax
1184
;        push    ax
1177
;        mov     dx,[yy3]
1185
;        mov     dx,[yy3]
1178
;        and     dx,0x00ff
1186
;        and     dx,0x00ff
1179
;        push    dx
1187
;        push    dx
1180
;        mov     ax,[zz2]
1188
;        mov     ax,[zz2]
1181
;        add     ax,128
1189
;        add     ax,128
1182
;        neg     al
1190
;        neg     al
1183
;        and     ax,0x00ff
1191
;        and     ax,0x00ff
1184
;        push    ax
1192
;        push    ax
1185
;        neg     al
1193
;        neg     al
1186
;        push    ax
1194
;        push    ax
1187
;        mov     dx,[yy2]
1195
;        mov     dx,[yy2]
1188
;        and     dx,0x00ff
1196
;        and     dx,0x00ff
1189
;        push    dx
1197
;        push    dx
1190
;        mov     ax,[zz1]
1198
;        mov     ax,[zz1]
1191
;        add     ax,128
1199
;        add     ax,128
1192
;        neg     al
1200
;        neg     al
1193
;        and     ax,0x00ff
1201
;        and     ax,0x00ff
1194
;        push    ax
1202
;        push    ax
1195
;        neg     al
1203
;        neg     al
1196
;        push    ax
1204
;        push    ax
1197
;        mov     dx,[yy1]
1205
;        mov     dx,[yy1]
1198
;        and     dx,0x00ff
1206
;        and     dx,0x00ff
1199
;        push    dx
1207
;        push    dx
1200
	mov	eax,dword[xx1]
1208
	mov	eax,dword[xx1]
1201
	ror	eax,16
1209
	ror	eax,16
1202
	mov	ebx,dword[xx2]
1210
	mov	ebx,dword[xx2]
1203
	ror	ebx,16
1211
	ror	ebx,16
1204
	mov	ecx,dword[xx3]
1212
	mov	ecx,dword[xx3]
1205
	ror	ecx,16
1213
	ror	ecx,16
1206
	lea	edi,[screen]
1214
	lea	edi,[screen]
1207
	cmp	[catmull_flag],0
1215
	cmp	[catmull_flag],0
1208
	je	@f
1216
	je	@f
1209
	lea	esi,[Z_buffer]
1217
	lea	esi,[Z_buffer]
1210
	call	gouraud_triangle_z
1218
	call	gouraud_triangle_z
1211
	jmp	.end_draw
1219
	jmp	.end_draw
1212
       @@:
1220
       @@:
1213
	call	gouraud_triangle
1221
	call	gouraud_triangle
1214
	jmp	.end_draw
1222
	jmp	.end_draw
1215
     .flat_draw:
1223
     .flat_draw:
1216
 
1224
 
1217
	movzx	edi,[point_index3]
1225
	movzx	edi,[point_index3]
1218
	lea	edi,[edi*3]
1226
	lea	edi,[edi*3]
1219
	lea	edi,[points_color+edi*2]
1227
	lea	edi,[points_color+edi*2]
1220
	movzx	eax,word[edi]
1228
	movzx	eax,word[edi]
1221
	movzx	ebx,word[edi+2]
1229
	movzx	ebx,word[edi+2]
1222
	movzx	ecx,word[edi+4]
1230
	movzx	ecx,word[edi+4]
1223
	movzx	edi,[point_index2]
1231
	movzx	edi,[point_index2]
1224
	lea	edi,[edi*3]
1232
	lea	edi,[edi*3]
1225
	lea	edi,[points_color+edi*2]
1233
	lea	edi,[points_color+edi*2]
1226
	add	ax,word[edi]
1234
	add	ax,word[edi]
1227
	add	bx,word[edi+2]
1235
	add	bx,word[edi+2]
1228
	add	cx,word[edi+4]
1236
	add	cx,word[edi+4]
1229
	movzx	edi,[point_index1]
1237
	movzx	edi,[point_index1]
1230
	lea	edi,[edi*3]
1238
	lea	edi,[edi*3]
1231
	lea	edi,[points_color+edi*2]
1239
	lea	edi,[points_color+edi*2]
1232
	add	ax,word[edi]
1240
	add	ax,word[edi]
1233
	add	bx,word[edi+2]
1241
	add	bx,word[edi+2]
1234
	add	cx,word[edi+4]
1242
	add	cx,word[edi+4]
1235
	cwd
1243
	cwd
1236
	idiv	[i3]
1244
	idiv	[i3]
1237
	mov	di,ax
1245
	mov	di,ax
1238
	shl	edi,16
1246
	shl	edi,16
1239
	mov	ax,bx
1247
	mov	ax,bx
1240
	cwd
1248
	cwd
1241
	idiv	[i3]
1249
	idiv	[i3]
1242
	mov	di,ax
1250
	mov	di,ax
1243
	shl	di,8
1251
	shl	di,8
1244
	mov	ax,cx
1252
	mov	ax,cx
1245
	cwd
1253
	cwd
1246
	idiv	[i3]
1254
	idiv	[i3]
1247
	mov	edx,edi
1255
	mov	edx,edi
1248
	mov	dl,al
1256
	mov	dl,al
1249
	and	edx,0x00ffffff
1257
	and	edx,0x00ffffff
1250
 
1258
 
1251
 
1259
 
1252
     ;   mov     ax,[zz1]      ; z position depend draw
1260
     ;   mov     ax,[zz1]      ; z position depend draw
1253
     ;   add     ax,[zz2]
1261
     ;   add     ax,[zz2]
1254
     ;   add     ax,[zz3]
1262
     ;   add     ax,[zz3]
1255
     ;   cwd
1263
     ;   cwd
1256
     ;   idiv    [i3] ;    = -((a+b+c)/3+130)
1264
     ;   idiv    [i3] ;    = -((a+b+c)/3+130)
1257
     ;   add     ax,130
1265
     ;   add     ax,130
1258
     ;   neg     al
1266
     ;   neg     al
1259
     ;   xor     edx,edx
1267
     ;   xor     edx,edx
1260
     ;   mov     ah,al           ;set color according to z position
1268
     ;   mov     ah,al           ;set color according to z position
1261
     ;   shl     eax,8
1269
     ;   shl     eax,8
1262
     ;   mov     edx,eax
1270
     ;   mov     edx,eax
1263
 
1271
 
1264
	mov	eax,dword[xx1]
1272
	mov	eax,dword[xx1]
1265
	ror	eax,16
1273
	ror	eax,16
1266
	mov	ebx,dword[xx2]
1274
	mov	ebx,dword[xx2]
1267
	ror	ebx,16
1275
	ror	ebx,16
1268
	mov	ecx,dword[xx3]
1276
	mov	ecx,dword[xx3]
1269
	ror	ecx,16
1277
	ror	ecx,16
1270
       ; mov     edi,screen
1278
       ; mov     edi,screen
1271
	lea	edi,[screen]
1279
	lea	edi,[screen]
1272
	cmp	[catmull_flag],0
1280
	cmp	[catmull_flag],0
1273
	je	@f
1281
	je	@f
1274
	lea	esi,[Z_buffer]
1282
	lea	esi,[Z_buffer]
1275
	push	word[zz3]
1283
	push	word[zz3]
1276
	push	word[zz2]
1284
	push	word[zz2]
1277
	push	word[zz1]
1285
	push	word[zz1]
1278
	call	flat_triangle_z
1286
	call	flat_triangle_z
1279
	jmp	.end_draw
1287
	jmp	.end_draw
1280
      @@:
1288
      @@:
1281
	call	draw_triangle
1289
	call	draw_triangle
1282
	jmp	.end_draw
1290
	jmp	.end_draw
1283
      .env_mapping:
1291
      .env_mapping:
1284
       ; fninit
1292
       ; fninit
1285
	mov	esi,point_index1
1293
	mov	esi,point_index1
1286
	sub	esp,12
1294
	sub	esp,12
1287
	mov	edi,esp
1295
	mov	edi,esp
1288
	mov	ecx,3
1296
	mov	ecx,3
1289
      @@:
1297
      @@:
1290
	movzx	eax,word[esi]
1298
	movzx	eax,word[esi]
1291
	lea	eax,[eax*3]
1299
	lea	eax,[eax*3]
1292
	shl	eax,2
1300
	shl	eax,2
1293
	add	eax,point_normals_rotated
1301
	add	eax,point_normals_rotated
1294
	; texture x=(rotated point normal -> x * 255)+255
1302
	; texture x=(rotated point normal -> x * 255)+255
1295
	fld	dword[eax]
1303
	fld	dword[eax]
1296
	fimul	[correct_tex]
1304
	fimul	[correct_tex]
1297
	fiadd	[correct_tex]
1305
	fiadd	[correct_tex]
1298
	fistp	word[edi]
1306
	fistp	word[edi]
1299
	; texture y=(rotated point normal -> y * 255)+255
1307
	; texture y=(rotated point normal -> y * 255)+255
1300
	fld	dword[eax+4]
1308
	fld	dword[eax+4]
1301
	fimul	[correct_tex]
1309
	fimul	[correct_tex]
1302
	fiadd	[correct_tex]
1310
	fiadd	[correct_tex]
1303
	fistp	word[edi+2]
1311
	fistp	word[edi+2]
1304
 
1312
 
1305
	add	edi,4
1313
	add	edi,4
1306
	add	esi,2
1314
	add	esi,2
1307
	loop	@b
1315
	loop	@b
1308
 
1316
 
1309
	mov	eax,dword[xx1]
1317
	mov	eax,dword[xx1]
1310
	ror	eax,16
1318
	ror	eax,16
1311
	mov	ebx,dword[xx2]
1319
	mov	ebx,dword[xx2]
1312
	ror	ebx,16
1320
	ror	ebx,16
1313
	mov	ecx,dword[xx3]
1321
	mov	ecx,dword[xx3]
1314
	ror	ecx,16
1322
	ror	ecx,16
1315
	mov	edi,screen
1323
	mov	edi,screen
1316
	mov	esi,envmap
1324
	mov	esi,envmap
1317
	call	tex_triangle
1325
	call	tex_triangle
1318
 
1326
 
1319
      .end_draw:
1327
      .end_draw:
1320
	pop	esi
1328
	pop	esi
1321
	add	esi,6
1329
	add	esi,6
1322
	cmp	dword[esi],-1
1330
	cmp	dword[esi],-1
1323
	jne	.again_dts
1331
	jne	.again_dts
1324
ret
1332
ret
1325
;translate_points:
1333
;translate_points:
1326
;        fninit
1334
;        fninit
1327
;        mov     ebx,points_rotated
1335
;        mov     ebx,points_rotated
1328
;    again_trans:
1336
;    again_trans:
1329
;        fild    word[ebx+4] ;z1
1337
;        fild    word[ebx+4] ;z1
1330
;        fmul    [sq]
1338
;        fmul    [sq]
1331
;        fld     st
1339
;        fld     st
1332
;        fiadd   word[ebx]  ;x1
1340
;        fiadd   word[ebx]  ;x1
1333
;        fistp   word[ebx]
1341
;        fistp   word[ebx]
1334
;        fchs
1342
;        fchs
1335
;        fiadd   word[ebx+2] ;y1
1343
;        fiadd   word[ebx+2] ;y1
1336
;        fistp   word[ebx+2] ;y1
1344
;        fistp   word[ebx+2] ;y1
1337
 
1345
 
1338
;        add     ebx,6
1346
;        add     ebx,6
1339
;        cmp     dword[ebx],-1
1347
;        cmp     dword[ebx],-1
1340
;        jne     again_trans
1348
;        jne     again_trans
1341
;ret
1349
;ret
1342
translate_perspective_points: ;translate points from 3d to 2d using
1350
translate_perspective_points: ;translate points from 3d to 2d using
1343
	fninit		      ;perspective equations
1351
	fninit		      ;perspective equations
1344
	mov ebx,points_rotated
1352
	mov ebx,points_rotated
1345
      .again_trans:
1353
      .again_trans:
1346
	fild word[ebx]
1354
	fild word[ebx]
1347
	fisub [xobs]
1355
	fisub [xobs]
1348
	fimul [zobs]
1356
	fimul [zobs]
1349
	fild word[ebx+4]
1357
	fild word[ebx+4]
1350
	fisub [zobs]
1358
	fisub [zobs]
1351
	fdivp
1359
	fdivp
1352
	fiadd [xobs]
1360
	fiadd [xobs]
1353
	fistp word[ebx]
1361
	fistp word[ebx]
1354
	fild word[ebx+2]
1362
	fild word[ebx+2]
1355
	fisub [yobs]
1363
	fisub [yobs]
1356
	fimul [zobs]
1364
	fimul [zobs]
1357
	fild word[ebx+4]
1365
	fild word[ebx+4]
1358
	fisub [zobs]
1366
	fisub [zobs]
1359
	fdivp
1367
	fdivp
1360
	fchs
1368
	fchs
1361
	fiadd [yobs]
1369
	fiadd [yobs]
1362
	fistp word[ebx+2]
1370
	fistp word[ebx+2]
1363
	add ebx,6
1371
	add ebx,6
1364
	cmp dword[ebx],-1
1372
	cmp dword[ebx],-1
1365
	jne .again_trans
1373
	jne .again_trans
1366
ret
1374
ret
1367
 
1375
 
1368
 
1376
 
1369
copy_points:
1377
copy_points:
1370
	mov	esi,points
1378
	mov	esi,points
1371
	mov	edi,points_rotated
1379
	mov	edi,points_rotated
1372
	mov	ecx,points_count*3+2
1380
	mov	ecx,points_count*3+2
1373
	rep	movsw
1381
	rep	movsw
1374
ret
1382
ret
1375
 
1383
 
1376
 
1384
 
1377
 
1385
 
1378
read_from_file:
1386
read_from_file:
1379
	mov	edi,triangles
1387
	mov	edi,triangles
1380
	xor	ebx,ebx
1388
	xor	ebx,ebx
1381
	xor	ebp,ebp
1389
	xor	ebp,ebp
1382
	mov	esi,SourceFile
1390
	mov	esi,SourceFile
1383
	cmp	[esi],word 4D4Dh
1391
	cmp	[esi],word 4D4Dh
1384
	jne	.exit ;Must be legal .3DS file
1392
	jne	.exit ;Must be legal .3DS file
1385
	cmp	dword[esi+2],EndFile-SourceFile
1393
	cmp	dword[esi+2],EndFile-SourceFile
1386
	jne	.exit ;This must tell the length
1394
	jne	.exit ;This must tell the length
1387
	add	esi,6
1395
	add	esi,6
1388
      @@:
1396
      @@:
1389
	cmp	[esi],word 3D3Dh
1397
	cmp	[esi],word 3D3Dh
1390
	je	@f
1398
	je	@f
1391
	add	esi,[esi+2]
1399
	add	esi,[esi+2]
1392
	jmp	@b
1400
	jmp	@b
1393
      @@:
1401
      @@:
1394
	add	esi,6
1402
	add	esi,6
1395
      .find4k:
1403
      .find4k:
1396
	cmp	[esi],word 4000h
1404
	cmp	[esi],word 4000h
1397
	je	@f
1405
	je	@f
1398
	add	esi,[esi+2]
1406
	add	esi,[esi+2]
1399
	cmp	esi,EndFile
1407
	cmp	esi,EndFile
1400
	jc	.find4k
1408
	jc	.find4k
1401
	jmp	.exit
1409
	jmp	.exit
1402
      @@:
1410
      @@:
1403
	add	esi,6
1411
	add	esi,6
1404
      @@:
1412
      @@:
1405
	cmp	[esi],byte 0
1413
	cmp	[esi],byte 0
1406
	je	@f
1414
	je	@f
1407
	inc	esi
1415
	inc	esi
1408
	jmp	@b
1416
	jmp	@b
1409
      @@:
1417
      @@:
1410
	inc	esi
1418
	inc	esi
1411
      @@:
1419
      @@:
1412
	cmp	[esi],word 4100h
1420
	cmp	[esi],word 4100h
1413
	je	@f
1421
	je	@f
1414
	add	esi,[esi+2]
1422
	add	esi,[esi+2]
1415
	jmp	@b
1423
	jmp	@b
1416
      @@:
1424
      @@:
1417
	add	esi,6
1425
	add	esi,6
1418
      @@:
1426
      @@:
1419
	cmp	[esi],word 4110h
1427
	cmp	[esi],word 4110h
1420
	je	@f
1428
	je	@f
1421
	add	esi,[esi+2]
1429
	add	esi,[esi+2]
1422
	jmp	@b
1430
	jmp	@b
1423
      @@:
1431
      @@:
1424
	movzx	ecx,word[esi+6]
1432
	movzx	ecx,word[esi+6]
1425
	mov	[points_count_var],cx
1433
	mov	[points_count_var],cx
1426
	mov	edx,ecx
1434
	mov	edx,ecx
1427
	add	esi,8
1435
	add	esi,8
1428
      @@:
1436
      @@:
1429
	fld	dword[esi+4]
1437
	fld	dword[esi+4]
1430
	fmul	[sscale]
1438
	fmul	[sscale]
1431
	fadd	[xoffset]
1439
	fadd	[xoffset]
1432
	fld	dword[esi+8]
1440
	fld	dword[esi+8]
1433
	fchs
1441
	fchs
1434
	fmul	[sscale]
1442
	fmul	[sscale]
1435
	fadd	[yoffset]
1443
	fadd	[yoffset]
1436
	fld	dword[esi+0]
1444
	fld	dword[esi+0]
1437
	fchs
1445
	fchs
1438
	fmul	[sscale]
1446
	fmul	[sscale]
1439
	fistp	word[points+ebx+4]
1447
	fistp	word[points+ebx+4]
1440
	fistp	word[points+ebx+2]
1448
	fistp	word[points+ebx+2]
1441
	fistp	word[points+ebx+0]
1449
	fistp	word[points+ebx+0]
1442
	add	ebx,6
1450
	add	ebx,6
1443
	add	esi,12
1451
	add	esi,12
1444
	dec	ecx
1452
	dec	ecx
1445
	jnz	@b
1453
	jnz	@b
1446
      @@:
1454
      @@:
1447
	mov	dword[points+ebx],-1
1455
	mov	dword[points+ebx],-1
1448
      @@:
1456
      @@:
1449
	cmp	[esi],word 4120h
1457
	cmp	[esi],word 4120h
1450
	je	@f
1458
	je	@f
1451
	add	esi,[esi+2]
1459
	add	esi,[esi+2]
1452
	jmp	@b
1460
	jmp	@b
1453
      @@:
1461
      @@:
1454
	movzx	ecx,word[esi+6]
1462
	movzx	ecx,word[esi+6]
1455
	mov	[triangles_count_var],cx
1463
	mov	[triangles_count_var],cx
1456
	add	esi,8
1464
	add	esi,8
1457
	;mov     edi,triangles
1465
	;mov     edi,triangles
1458
      @@:
1466
      @@:
1459
	movsd
1467
	movsd
1460
	movsw
1468
	movsw
1461
	add	word[edi-6],bp
1469
	add	word[edi-6],bp
1462
	add	word[edi-4],bp
1470
	add	word[edi-4],bp
1463
	add	word[edi-2],bp
1471
	add	word[edi-2],bp
1464
	add	esi,2
1472
	add	esi,2
1465
	dec	ecx
1473
	dec	ecx
1466
	jnz	@b
1474
	jnz	@b
1467
	add	ebp,edx
1475
	add	ebp,edx
1468
	jmp	.find4k
1476
	jmp	.find4k
1469
 
1477
 
1470
      .exit:
1478
      .exit:
1471
	mov	dword[edi],-1
1479
	mov	dword[edi],-1
1472
ret
1480
ret
1473
 
1481
 
1474
 
1482
 
1475
;   *********************************************
1483
;   *********************************************
1476
;   *******  WINDOW DEFINITIONS AND DRAW ********
1484
;   *******  WINDOW DEFINITIONS AND DRAW ********
1477
;   *********************************************
1485
;   *********************************************
1478
    draw_window:
1486
    draw_window:
1479
	mov	eax,12		; function 12:tell os about windowdraw
1487
	mov	eax,12		; function 12:tell os about windowdraw
1480
	mov	ebx,1		; 1, start of draw
1488
	mov	ebx,1		; 1, start of draw
1481
	int	0x40
1489
	int	0x40
1482
 
1490
 
1483
	; DRAW WINDOW
1491
	; DRAW WINDOW
1484
	mov	eax,0		; function 0 : define and draw window
1492
	mov	eax,0		; function 0 : define and draw window
1485
	mov	ebx,100*65536+SIZE_X+80 ; [x start] *65536 + [x size]
1493
	mov	ebx,100*65536+SIZE_X+80 ; [x start] *65536 + [x size]
1486
	mov	ecx,100*65536+SIZE_Y+30 ; [y start] *65536 + [y size]
1494
	mov	ecx,100*65536+SIZE_Y+30 ; [y start] *65536 + [y size]
1487
	mov	edx,0x02000000	; color of work area RRGGBB,8->color gl
1495
	mov	edx,0x02000000	; color of work area RRGGBB,8->color gl
1488
	mov	esi,0x805080d0	; color of grab bar  RRGGBB,8->color gl
1496
	mov	esi,0x805080d0	; color of grab bar  RRGGBB,8->color gl
1489
	mov	edi,0x005080d0	; color of frames    RRGGBB
1497
	mov	edi,0x005080d0	; color of frames    RRGGBB
1490
	int	0x40
1498
	int	0x40
1491
 
1499
 
1492
	; WINDOW LABEL
1500
	; WINDOW LABEL
1493
	mov	eax,4		; function 4 : write text to window
1501
	mov	eax,4		; function 4 : write text to window
1494
	mov	ebx,8*65536+8	; [x start] *65536 + [y start]
1502
	mov	ebx,8*65536+8	; [x start] *65536 + [y start]
1495
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1503
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1496
	mov	edx,labelt	; pointer to text beginning
1504
	mov	edx,labelt	; pointer to text beginning
1497
	mov	esi,labellen-labelt	; text length
1505
	mov	esi,labellen-labelt	; text length
1498
	int	0x40
1506
	int	0x40
1499
 
1507
 
1500
	; CLOSE BUTTON
1508
	; CLOSE BUTTON
1501
	mov	eax,8		; function 8 : define and draw button
1509
	mov	eax,8		; function 8 : define and draw button
1502
	mov	ebx,(SIZE_X+80-19)*65536+12	; [x start] *65536 + [x size]
1510
	mov	ebx,(SIZE_X+80-19)*65536+12	; [x start] *65536 + [x size]
1503
	mov	ecx,5*65536+12	; [y start] *65536 + [y size]
1511
	mov	ecx,5*65536+12	; [y start] *65536 + [y size]
1504
	mov	edx,1		; button id
1512
	mov	edx,1		; button id
1505
	mov	esi,0x6688dd	; button color RRGGBB
1513
	mov	esi,0x6688dd	; button color RRGGBB
1506
	int	0x40
1514
	int	0x40
1507
 
1515
 
1508
	 ; ROTARY BUTTON
1516
	 ; ROTARY BUTTON
1509
	mov	eax,8		; function 8 : define and draw button
1517
	mov	eax,8		; function 8 : define and draw button
1510
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1518
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1511
	mov	ecx,25*65536+12  ; [y start] *65536 + [y size]
1519
	mov	ecx,25*65536+12  ; [y start] *65536 + [y size]
1512
	mov	edx,2		; button id
1520
	mov	edx,2		; button id
1513
	mov	esi,0x6688dd	; button color RRGGBB
1521
	mov	esi,0x6688dd	; button color RRGGBB
1514
	int	0x40
1522
	int	0x40
1515
	 ; ROTARY  LABEL
1523
	 ; ROTARY  LABEL
1516
	mov	eax,4		; function 4 : write text to window
1524
	mov	eax,4		; function 4 : write text to window
1517
	mov	ebx,(SIZE_X+12)*65536+28   ; [x start] *65536 + [y start]
1525
	mov	ebx,(SIZE_X+12)*65536+28   ; [x start] *65536 + [y start]
1518
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1526
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1519
	mov	edx,labelrot	  ; pointer to text beginning
1527
	mov	edx,labelrot	  ; pointer to text beginning
1520
	mov	esi,labelrotend-labelrot     ; text length
1528
	mov	esi,labelrotend-labelrot     ; text length
1521
	int	0x40
1529
	int	0x40
1522
 
1530
 
1523
	 ; DRAW MODE BUTTON
1531
	 ; DRAW MODE BUTTON
1524
	mov	eax,8		; function 8 : define and draw button
1532
	mov	eax,8		; function 8 : define and draw button
1525
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1533
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1526
	mov	ecx,(25+15)*65536+12  ; [y start] *65536 + [y size]
1534
	mov	ecx,(25+15)*65536+12  ; [y start] *65536 + [y size]
1527
	mov	edx,3		; button id
1535
	mov	edx,3		; button id
1528
	mov	esi,0x6688dd	; button color RRGGBB
1536
	mov	esi,0x6688dd	; button color RRGGBB
1529
	int	0x40
1537
	int	0x40
1530
	 ; DRAW MODE LABEL
1538
	 ; DRAW MODE LABEL
1531
	mov	eax,4		; function 4 : write text to window
1539
	mov	eax,4		; function 4 : write text to window
1532
	mov	ebx,(SIZE_X+12)*65536+28+15   ; [x start] *65536 + [y start]
1540
	mov	ebx,(SIZE_X+12)*65536+28+15   ; [x start] *65536 + [y start]
1533
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1541
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1534
	mov	edx,labeldrmod	    ; pointer to text beginning
1542
	mov	edx,labeldrmod	    ; pointer to text beginning
1535
	mov	esi,labeldrmodend-labeldrmod	 ; text length
1543
	mov	esi,labeldrmodend-labeldrmod	 ; text length
1536
	int	0x40
1544
	int	0x40
1537
 
1545
 
1538
	 ; SPEED BUTTON
1546
	 ; SPEED BUTTON
1539
	mov	eax,8		; function 8 : define and draw button
1547
	mov	eax,8		; function 8 : define and draw button
1540
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1548
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1541
	mov	ecx,(25+15*2)*65536+12	; [y start] *65536 + [y size]
1549
	mov	ecx,(25+15*2)*65536+12	; [y start] *65536 + [y size]
1542
	mov	edx,4		; button id
1550
	mov	edx,4		; button id
1543
	mov	esi,0x6688dd	; button color RRGGBB
1551
	mov	esi,0x6688dd	; button color RRGGBB
1544
	int	0x40
1552
	int	0x40
1545
	 ; SPEED MODE LABEL
1553
	 ; SPEED MODE LABEL
1546
	mov	eax,4		; function 4 : write text to window
1554
	mov	eax,4		; function 4 : write text to window
1547
	mov	ebx,(SIZE_X+12)*65536+(28+15*2)   ; [x start] *65536 + [y start]
1555
	mov	ebx,(SIZE_X+12)*65536+(28+15*2)   ; [x start] *65536 + [y start]
1548
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1556
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1549
	mov	edx,labelspeedmod      ; pointer to text beginning
1557
	mov	edx,labelspeedmod      ; pointer to text beginning
1550
	mov	esi,labelspeedmodend-labelspeedmod     ; text length
1558
	mov	esi,labelspeedmodend-labelspeedmod     ; text length
1551
	int	0x40
1559
	int	0x40
1552
 
1560
 
1553
	 ; SCALE- BUTTON
1561
	 ; SCALE- BUTTON
1554
	mov	eax,8		; function 8 : define and draw button
1562
	mov	eax,8		; function 8 : define and draw button
1555
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1563
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1556
	mov	ecx,(25+15*3)*65536+12	; [y start] *65536 + [y size]
1564
	mov	ecx,(25+15*3)*65536+12	; [y start] *65536 + [y size]
1557
	mov	edx,5		; button id
1565
	mov	edx,5		; button id
1558
	mov	esi,0x6688dd	; button color RRGGBB
1566
	mov	esi,0x6688dd	; button color RRGGBB
1559
	int	0x40
1567
	int	0x40
1560
	 ; SCALE- MODE LABEL
1568
	 ; SCALE- MODE LABEL
1561
	mov	eax,4		; function 4 : write text to window
1569
	mov	eax,4		; function 4 : write text to window
1562
	mov	ebx,(SIZE_X+12)*65536+(28+15*3)   ; [x start] *65536 + [y start]
1570
	mov	ebx,(SIZE_X+12)*65536+(28+15*3)   ; [x start] *65536 + [y start]
1563
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1571
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1564
	mov	edx,labelzoomout      ; pointer to text beginning
1572
	mov	edx,labelzoomout      ; pointer to text beginning
1565
	mov	esi,labelzoomoutend-labelzoomout     ; text length
1573
	mov	esi,labelzoomoutend-labelzoomout     ; text length
1566
	int	0x40
1574
	int	0x40
1567
 
1575
 
1568
	 ; SCALE+ BUTTON
1576
	 ; SCALE+ BUTTON
1569
	mov	eax,8		; function 8 : define and draw button
1577
	mov	eax,8		; function 8 : define and draw button
1570
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1578
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1571
	mov	ecx,(25+15*4)*65536+12	; [y start] *65536 + [y size]
1579
	mov	ecx,(25+15*4)*65536+12	; [y start] *65536 + [y size]
1572
	mov	edx,6		; button id
1580
	mov	edx,6		; button id
1573
	mov	esi,0x6688dd	; button color RRGGBB
1581
	mov	esi,0x6688dd	; button color RRGGBB
1574
	int	0x40
1582
	int	0x40
1575
	 ; SCALE+ MODE LABEL
1583
	 ; SCALE+ MODE LABEL
1576
	mov	eax,4		; function 4 : write text to window
1584
	mov	eax,4		; function 4 : write text to window
1577
	mov	ebx,(SIZE_X+12)*65536+(28+15*4)   ; [x start] *65536 + [y start]
1585
	mov	ebx,(SIZE_X+12)*65536+(28+15*4)   ; [x start] *65536 + [y start]
1578
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1586
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1579
	mov	edx,labelzoomin      ; pointer to text beginning
1587
	mov	edx,labelzoomin      ; pointer to text beginning
1580
	mov	esi,labelzoominend-labelzoomin	   ; text length
1588
	mov	esi,labelzoominend-labelzoomin	   ; text length
1581
	int	0x40
1589
	int	0x40
1582
	; ADD VECTOR LABEL
1590
	; ADD VECTOR LABEL
1583
	mov	eax,4		; function 4 : write text to window
1591
	mov	eax,4		; function 4 : write text to window
1584
	mov	ebx,(SIZE_X+12)*65536+(28+15*5)   ; [x start] *65536 + [y start]
1592
	mov	ebx,(SIZE_X+12)*65536+(28+15*5)   ; [x start] *65536 + [y start]
1585
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1593
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1586
	mov	edx,labelvector      ; pointer to text beginning
1594
	mov	edx,labelvector      ; pointer to text beginning
1587
	mov	esi,labelvectorend-labelvector	   ; text length
1595
	mov	esi,labelvectorend-labelvector	   ; text length
1588
	int	0x40
1596
	int	0x40
1589
	 ; VECTOR Y- BUTTON
1597
	 ; VECTOR Y- BUTTON
1590
	mov	eax,8		; function 8 : define and draw button
1598
	mov	eax,8		; function 8 : define and draw button
1591
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1599
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1592
	mov	ecx,(25+15*6)*65536+12	; [y start] *65536 + [y size]
1600
	mov	ecx,(25+15*6)*65536+12	; [y start] *65536 + [y size]
1593
	mov	edx,7		; button id
1601
	mov	edx,7		; button id
1594
	mov	esi,0x6688dd	; button color RRGGBB
1602
	mov	esi,0x6688dd	; button color RRGGBB
1595
	int	0x40
1603
	int	0x40
1596
	;VECTOR Y- LABEL
1604
	;VECTOR Y- LABEL
1597
	mov	eax,4		; function 4 : write text to window
1605
	mov	eax,4		; function 4 : write text to window
1598
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*6)   ; [x start] *65536 + [y start]
1606
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*6)   ; [x start] *65536 + [y start]
1599
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1607
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1600
	mov	edx,labelyminus      ; pointer to text beginning
1608
	mov	edx,labelyminus      ; pointer to text beginning
1601
	mov	esi,labelyminusend-labelyminus	   ; text length
1609
	mov	esi,labelyminusend-labelyminus	   ; text length
1602
	int	0x40
1610
	int	0x40
1603
	; VECTOR Z+ BUTTON
1611
	; VECTOR Z+ BUTTON
1604
	mov	eax,8		; function 8 : define and draw button
1612
	mov	eax,8		; function 8 : define and draw button
1605
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1613
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1606
	mov	ecx,(25+15*6)*65536+12	; [y start] *65536 + [y size]
1614
	mov	ecx,(25+15*6)*65536+12	; [y start] *65536 + [y size]
1607
	mov	edx,8		; button id
1615
	mov	edx,8		; button id
1608
	mov	esi,0x6688dd	; button color RRGGBB
1616
	mov	esi,0x6688dd	; button color RRGGBB
1609
	int	0x40
1617
	int	0x40
1610
	;VECTOR Z+ LABEL
1618
	;VECTOR Z+ LABEL
1611
	mov	eax,4		; function 4 : write text to window
1619
	mov	eax,4		; function 4 : write text to window
1612
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*6)   ; [x start] *65536 + [y start]
1620
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*6)   ; [x start] *65536 + [y start]
1613
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1621
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1614
	mov	edx,labelzplus	    ; pointer to text beginning
1622
	mov	edx,labelzplus	    ; pointer to text beginning
1615
	mov	esi,labelzplusend-labelzplus	 ; text length
1623
	mov	esi,labelzplusend-labelzplus	 ; text length
1616
	int	0x40
1624
	int	0x40
1617
	; VECTOR x- BUTTON
1625
	; VECTOR x- BUTTON
1618
	mov	eax,8		; function 8 : define and draw button
1626
	mov	eax,8		; function 8 : define and draw button
1619
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1627
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1620
	mov	ecx,(25+15*7)*65536+12	; [y start] *65536 + [y size]
1628
	mov	ecx,(25+15*7)*65536+12	; [y start] *65536 + [y size]
1621
	mov	edx,9		; button id
1629
	mov	edx,9		; button id
1622
	mov	esi,0x6688dd	; button color RRGGBB
1630
	mov	esi,0x6688dd	; button color RRGGBB
1623
	int	0x40
1631
	int	0x40
1624
	;VECTOR x- LABEL
1632
	;VECTOR x- LABEL
1625
	mov	eax,4		; function 4 : write text to window
1633
	mov	eax,4		; function 4 : write text to window
1626
	mov	ebx,(SIZE_X+12)*65536+(28+15*7)   ; [x start] *65536 + [y start]
1634
	mov	ebx,(SIZE_X+12)*65536+(28+15*7)   ; [x start] *65536 + [y start]
1627
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1635
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1628
	mov	edx,labelxminus      ; pointer to text beginning
1636
	mov	edx,labelxminus      ; pointer to text beginning
1629
	mov	esi,labelxminusend-labelxminus	   ; text length
1637
	mov	esi,labelxminusend-labelxminus	   ; text length
1630
	int	0x40
1638
	int	0x40
1631
	; VECTOR x+ BUTTON
1639
	; VECTOR x+ BUTTON
1632
	mov	eax,8		; function 8 : define and draw button
1640
	mov	eax,8		; function 8 : define and draw button
1633
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1641
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1634
	mov	ecx,(25+15*7)*65536+12	; [y start] *65536 + [y size]
1642
	mov	ecx,(25+15*7)*65536+12	; [y start] *65536 + [y size]
1635
	mov	edx,10		 ; button id
1643
	mov	edx,10		 ; button id
1636
	mov	esi,0x6688dd	; button color RRGGBB
1644
	mov	esi,0x6688dd	; button color RRGGBB
1637
	int	0x40
1645
	int	0x40
1638
	;VECTOR x+ LABEL
1646
	;VECTOR x+ LABEL
1639
	mov	eax,4		; function 4 : write text to window
1647
	mov	eax,4		; function 4 : write text to window
1640
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*7)   ; [x start] *65536 + [y start]
1648
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*7)   ; [x start] *65536 + [y start]
1641
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1649
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1642
	mov	edx,labelxplus	    ; pointer to text beginning
1650
	mov	edx,labelxplus	    ; pointer to text beginning
1643
	mov	esi,labelxplusend-labelxplus	 ; text length
1651
	mov	esi,labelxplusend-labelxplus	 ; text length
1644
	int	0x40
1652
	int	0x40
1645
	; VECTOR z- BUTTON
1653
	; VECTOR z- BUTTON
1646
	mov	eax,8		; function 8 : define and draw button
1654
	mov	eax,8		; function 8 : define and draw button
1647
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1655
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1648
	mov	ecx,(25+15*8)*65536+12	; [y start] *65536 + [y size]
1656
	mov	ecx,(25+15*8)*65536+12	; [y start] *65536 + [y size]
1649
	mov	edx,11		 ; button id
1657
	mov	edx,11		 ; button id
1650
	mov	esi,0x6688dd	; button color RRGGBB
1658
	mov	esi,0x6688dd	; button color RRGGBB
1651
	int	0x40
1659
	int	0x40
1652
	;VECTOR z- LABEL
1660
	;VECTOR z- LABEL
1653
	mov	eax,4		; function 4 : write text to window
1661
	mov	eax,4		; function 4 : write text to window
1654
	mov	ebx,(SIZE_X+12)*65536+(28+15*8)   ; [x start] *65536 + [y start]
1662
	mov	ebx,(SIZE_X+12)*65536+(28+15*8)   ; [x start] *65536 + [y start]
1655
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1663
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1656
	mov	edx,labelzminus      ; pointer to text beginning
1664
	mov	edx,labelzminus      ; pointer to text beginning
1657
	mov	esi,labelzminusend-labelzminus	   ; text length
1665
	mov	esi,labelzminusend-labelzminus	   ; text length
1658
	int	0x40
1666
	int	0x40
1659
       ;VECTOR Y+ BUTTON
1667
       ;VECTOR Y+ BUTTON
1660
	mov	eax,8		; function 8 : define and draw button
1668
	mov	eax,8		; function 8 : define and draw button
1661
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1669
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1662
	mov	ecx,(25+15*8)*65536+12	; [y start] *65536 + [y size]
1670
	mov	ecx,(25+15*8)*65536+12	; [y start] *65536 + [y size]
1663
	mov	edx,12		 ; button id
1671
	mov	edx,12		 ; button id
1664
	mov	esi,0x6688dd	; button color RRGGBB
1672
	mov	esi,0x6688dd	; button color RRGGBB
1665
	int	0x40
1673
	int	0x40
1666
	;VECTOR Y+ LABEL
1674
	;VECTOR Y+ LABEL
1667
	mov	eax,4		; function 4 : write text to window
1675
	mov	eax,4		; function 4 : write text to window
1668
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*8)   ; [x start] *65536 + [y start]
1676
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*8)   ; [x start] *65536 + [y start]
1669
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1677
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1670
	mov	edx,labelyplus	    ; pointer to text beginning
1678
	mov	edx,labelyplus	    ; pointer to text beginning
1671
	mov	esi,labelyplusend-labelyplus	 ; text length
1679
	mov	esi,labelyplusend-labelyplus	 ; text length
1672
	int	0x40
1680
	int	0x40
1673
	; LEAD COLOR LABEL
1681
	; LEAD COLOR LABEL
1674
	mov	eax,4		; function 4 : write text to window
1682
	mov	eax,4		; function 4 : write text to window
1675
	mov	ebx,(SIZE_X+12)*65536+(28+15*9)   ; [x start] *65536 + [y start]
1683
	mov	ebx,(SIZE_X+12)*65536+(28+15*9)   ; [x start] *65536 + [y start]
1676
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1684
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1677
	mov	edx,labelmaincolor	; pointer to text beginning
1685
	mov	edx,labelmaincolor	; pointer to text beginning
1678
	mov	esi,labelmaincolorend-labelmaincolor	 ; text length
1686
	mov	esi,labelmaincolorend-labelmaincolor	 ; text length
1679
	int	0x40
1687
	int	0x40
1680
 
1688
 
1681
	;RED+ BUTTON
1689
	;RED+ BUTTON
1682
	mov	eax,8		; function 8 : define and draw button
1690
	mov	eax,8		; function 8 : define and draw button
1683
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1691
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1684
	mov	ecx,(25+15*10)*65536+12  ; [y start] *65536 + [y size]
1692
	mov	ecx,(25+15*10)*65536+12  ; [y start] *65536 + [y size]
1685
	mov	edx,13		 ; button id
1693
	mov	edx,13		 ; button id
1686
	mov	esi,0x6688dd	; button color RRGGBB
1694
	mov	esi,0x6688dd	; button color RRGGBB
1687
	int	0x40
1695
	int	0x40
1688
	;RED+  LABEL
1696
	;RED+  LABEL
1689
	mov	eax,4		; function 4 : write text to window
1697
	mov	eax,4		; function 4 : write text to window
1690
	mov	ebx,(SIZE_X+12)*65536+(28+15*10)   ; [x start] *65536 + [y start]
1698
	mov	ebx,(SIZE_X+12)*65536+(28+15*10)   ; [x start] *65536 + [y start]
1691
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1699
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1692
	mov	edx,labelredplus      ; pointer to text beginning
1700
	mov	edx,labelredplus      ; pointer to text beginning
1693
	mov	esi,labelredplusend-labelredplus     ; text length
1701
	mov	esi,labelredplusend-labelredplus     ; text length
1694
	int	0x40
1702
	int	0x40
1695
	;GREEN+ BUTTON
1703
	;GREEN+ BUTTON
1696
	mov	eax,8		; function 8 : define and draw button
1704
	mov	eax,8		; function 8 : define and draw button
1697
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1705
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1698
	mov	ecx,(25+15*10)*65536+12  ; [y start] *65536 + [y size]
1706
	mov	ecx,(25+15*10)*65536+12  ; [y start] *65536 + [y size]
1699
	mov	edx,14		 ; button id
1707
	mov	edx,14		 ; button id
1700
	mov	esi,0x6688dd	; button color RRGGBB
1708
	mov	esi,0x6688dd	; button color RRGGBB
1701
	int	0x40
1709
	int	0x40
1702
	;GREEN+ LABEL
1710
	;GREEN+ LABEL
1703
	mov	eax,4		; function 4 : write text to window
1711
	mov	eax,4		; function 4 : write text to window
1704
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*10)   ; [x start] *65536 + [y start]
1712
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*10)   ; [x start] *65536 + [y start]
1705
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1713
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1706
	mov	edx,labelgreenplus	; pointer to text beginning
1714
	mov	edx,labelgreenplus	; pointer to text beginning
1707
	mov	esi,labelgreenplusend-labelgreenplus	 ; text length
1715
	mov	esi,labelgreenplusend-labelgreenplus	 ; text length
1708
	int	0x40
1716
	int	0x40
1709
	;BLUE+ BUTTON
1717
	;BLUE+ BUTTON
1710
	mov	eax,8		; function 8 : define and draw button
1718
	mov	eax,8		; function 8 : define and draw button
1711
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1719
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1712
	mov	ecx,(25+15*10)*65536+12  ; [y start] *65536 + [y size]
1720
	mov	ecx,(25+15*10)*65536+12  ; [y start] *65536 + [y size]
1713
	mov	edx,15		 ; button id
1721
	mov	edx,15		 ; button id
1714
	mov	esi,0x6688dd	; button color RRGGBB
1722
	mov	esi,0x6688dd	; button color RRGGBB
1715
	int	0x40
1723
	int	0x40
1716
	;BLUE+ LABEL
1724
	;BLUE+ LABEL
1717
	mov	eax,4		; function 4 : write text to window
1725
	mov	eax,4		; function 4 : write text to window
1718
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*10)   ; [x start] *65536 + [y start]
1726
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*10)   ; [x start] *65536 + [y start]
1719
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1727
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1720
	mov	edx,labelblueplus      ; pointer to text beginning
1728
	mov	edx,labelblueplus      ; pointer to text beginning
1721
	mov	esi,labelblueplusend-labelblueplus     ; text length
1729
	mov	esi,labelblueplusend-labelblueplus     ; text length
1722
	int	0x40
1730
	int	0x40
1723
	;RED- BUTTON
1731
	;RED- BUTTON
1724
	mov	eax,8		; function 8 : define and draw button
1732
	mov	eax,8		; function 8 : define and draw button
1725
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1733
	mov	ebx,(SIZE_X+10)*65536+62-41	; [x start] *65536 + [x size]
1726
	mov	ecx,(25+15*11)*65536+12  ; [y start] *65536 + [y size]
1734
	mov	ecx,(25+15*11)*65536+12  ; [y start] *65536 + [y size]
1727
	mov	edx,16		 ; button id
1735
	mov	edx,16		 ; button id
1728
	mov	esi,0x6688dd	; button color RRGGBB
1736
	mov	esi,0x6688dd	; button color RRGGBB
1729
	int	0x40
1737
	int	0x40
1730
	;RED-  LABEL
1738
	;RED-  LABEL
1731
	mov	eax,4		; function 4 : write text to window
1739
	mov	eax,4		; function 4 : write text to window
1732
	mov	ebx,(SIZE_X+12)*65536+(28+15*11)   ; [x start] *65536 + [y start]
1740
	mov	ebx,(SIZE_X+12)*65536+(28+15*11)   ; [x start] *65536 + [y start]
1733
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1741
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1734
	mov	edx,labelredminus      ; pointer to text beginning
1742
	mov	edx,labelredminus      ; pointer to text beginning
1735
	mov	esi,labelredminusend-labelredminus     ; text length
1743
	mov	esi,labelredminusend-labelredminus     ; text length
1736
	int	0x40
1744
	int	0x40
1737
	;GREEN- BUTTON
1745
	;GREEN- BUTTON
1738
	mov	eax,8		; function 8 : define and draw button
1746
	mov	eax,8		; function 8 : define and draw button
1739
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1747
	mov	ebx,(SIZE_X+10+20)*65536+62-42	   ; [x start] *65536 + [x size]
1740
	mov	ecx,(25+15*11)*65536+12  ; [y start] *65536 + [y size]
1748
	mov	ecx,(25+15*11)*65536+12  ; [y start] *65536 + [y size]
1741
	mov	edx,17		 ; button id
1749
	mov	edx,17		 ; button id
1742
	mov	esi,0x6688dd	; button color RRGGBB
1750
	mov	esi,0x6688dd	; button color RRGGBB
1743
	int	0x40
1751
	int	0x40
1744
	;GREEN- LABEL
1752
	;GREEN- LABEL
1745
	mov	eax,4		; function 4 : write text to window
1753
	mov	eax,4		; function 4 : write text to window
1746
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*11)   ; [x start] *65536 + [y start]
1754
	mov	ebx,(SIZE_X+12+20)*65536+(28+15*11)   ; [x start] *65536 + [y start]
1747
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1755
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1748
	mov	edx,labelgreenminus	 ; pointer to text beginning
1756
	mov	edx,labelgreenminus	 ; pointer to text beginning
1749
	mov	esi,labelgreenminusend-labelgreenminus	   ; text length
1757
	mov	esi,labelgreenminusend-labelgreenminus	   ; text length
1750
	int	0x40
1758
	int	0x40
1751
	;BLUE- BUTTON
1759
	;BLUE- BUTTON
1752
	mov	eax,8		; function 8 : define and draw button
1760
	mov	eax,8		; function 8 : define and draw button
1753
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1761
	mov	ebx,(SIZE_X+10+41)*65536+62-41	   ; [x start] *65536 + [x size]
1754
	mov	ecx,(25+15*11)*65536+12  ; [y start] *65536 + [y size]
1762
	mov	ecx,(25+15*11)*65536+12  ; [y start] *65536 + [y size]
1755
	mov	edx,18		 ; button id
1763
	mov	edx,18		 ; button id
1756
	mov	esi,0x6688dd	; button color RRGGBB
1764
	mov	esi,0x6688dd	; button color RRGGBB
1757
	int	0x40
1765
	int	0x40
1758
	;BLUE- LABEL
1766
	;BLUE- LABEL
1759
	mov	eax,4		; function 4 : write text to window
1767
	mov	eax,4		; function 4 : write text to window
1760
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*11)   ; [x start] *65536 + [y start]
1768
	mov	ebx,(SIZE_X+12+41)*65536+(28+15*11)   ; [x start] *65536 + [y start]
1761
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1769
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1762
	mov	edx,labelblueminus	; pointer to text beginning
1770
	mov	edx,labelblueminus	; pointer to text beginning
1763
	mov	esi,labelblueminusend-labelblueminus	 ; text length
1771
	mov	esi,labelblueminusend-labelblueminus	 ; text length
1764
	int	0x40
1772
	int	0x40
1765
	; Catmull  LABEL
1773
	; Catmull  LABEL
1766
	mov	eax,4		; function 4 : write text to window
1774
	mov	eax,4		; function 4 : write text to window
1767
	mov	ebx,(SIZE_X+12)*65536+(28+15*12)   ; [x start] *65536 + [y start]
1775
	mov	ebx,(SIZE_X+12)*65536+(28+15*12)   ; [x start] *65536 + [y start]
1768
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1776
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1769
	mov	edx,labelcatmullmod	 ; pointer to text beginning
1777
	mov	edx,labelcatmullmod	 ; pointer to text beginning
1770
	mov	esi,labelcatmullmodend-labelcatmullmod	   ; text length
1778
	mov	esi,labelcatmullmodend-labelcatmullmod	   ; text length
1771
	int	0x40
1779
	int	0x40
1772
	; on/off BUTTON
1780
	; on/off BUTTON
1773
	mov	eax,8		; function 8 : define and draw button
1781
	mov	eax,8		; function 8 : define and draw button
1774
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1782
	mov	ebx,(SIZE_X+10)*65536+62     ; [x start] *65536 + [x size]
1775
	mov	ecx,(25+15*13)*65536+12  ; [y start] *65536 + [y size]
1783
	mov	ecx,(25+15*13)*65536+12  ; [y start] *65536 + [y size]
1776
	mov	edx,19		 ; button id
1784
	mov	edx,19		 ; button id
1777
	mov	esi,0x6688dd	; button color RRGGBB
1785
	mov	esi,0x6688dd	; button color RRGGBB
1778
	int	0x40
1786
	int	0x40
1779
	 ; on/off LABEL
1787
	 ; on/off LABEL
1780
	mov	eax,4		; function 4 : write text to window
1788
	mov	eax,4		; function 4 : write text to window
1781
	mov	ebx,(SIZE_X+12)*65536+(28+15*13)   ; [x start] *65536 + [y start]
1789
	mov	ebx,(SIZE_X+12)*65536+(28+15*13)   ; [x start] *65536 + [y start]
1782
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1790
	mov	ecx,0x20ddeeff	; font 1 & color ( 0xF0RRGGBB )
1783
	mov	edx,labelonoff	    ; pointer to text beginning
1791
	mov	edx,labelonoff	    ; pointer to text beginning
1784
	mov	esi,labelonoffend-labelonoff	 ; text length
1792
	mov	esi,labelonoffend-labelonoff	 ; text length
1785
	int	0x40
1793
	int	0x40
1786
 
1794
 
1787
 
1795
 
1788
	mov	eax,12		; function 12:tell os about windowdraw
1796
	mov	eax,12		; function 12:tell os about windowdraw
1789
	mov	ebx,2		; 2, end of draw
1797
	mov	ebx,2		; 2, end of draw
1790
	int	0x40
1798
	int	0x40
1791
 
1799
 
1792
	ret
1800
	ret
1793
 
1801
 
1794
 
1802
 
1795
	; DATA AREA
1803
	; DATA AREA
1796
	i3		dw	3
1804
	i3		dw	3
1797
	light_vector	dd	0.0,0.0,-1.0
1805
	light_vector	dd	0.0,0.0,-1.0
1798
     ;  debug_vector    dd      0.0,2.0,2.0   ;--debug
1806
     ;  debug_vector    dd      0.0,2.0,2.0   ;--debug
1799
     ;  debug_vector1   dd      0.0,0.0,0.0
1807
     ;  debug_vector1   dd      0.0,0.0,0.0
1800
     ;  debug_points    dw      1,1,1,3,4,20
1808
     ;  debug_points    dw      1,1,1,3,4,20
1801
     ;  debug_dd        dw      ?
1809
     ;  debug_dd        dw      ?
1802
     ;  debug_dwd       dd      65535
1810
     ;  debug_dwd       dd      65535
1803
     ;  debug_counter   dw      0
1811
     ;  debug_counter   dw      0
1804
	dot_max 	dd	1.0
1812
	dot_max 	dd	1.0
1805
	dot_min 	dd	0.0
1813
	dot_min 	dd	0.0
1806
	env_const	dd	1.2
1814
	env_const	dd	1.2
1807
	correct_tex	dw	255
1815
	correct_tex	dw	255
1808
	max_color_r	dw	255
1816
	max_color_r	dw	255
1809
	max_color_g	dw	25
1817
	max_color_g	dw	25
1810
	max_color_b	dw	35
1818
	max_color_b	dw	35
1811
	xobs		dw	SIZE_X / 2 ;200 ;observer
1819
	xobs		dw	SIZE_X / 2 ;200 ;observer
1812
	yobs		dw	SIZE_Y / 2 ;200 ;coordinates
1820
	yobs		dw	SIZE_Y / 2 ;200 ;coordinates
1813
	zobs		dw	-500
1821
	zobs		dw	-500
1814
 
1822
 
1815
 
1823
 
1816
	angle_counter dw 0
1824
	angle_counter dw 0
1817
	piD180	      dd 0.017453292519943295769236907684886
1825
	piD180	      dd 0.017453292519943295769236907684886
1818
      ;  sq            dd 0.70710678118654752440084436210485
1826
      ;  sq            dd 0.70710678118654752440084436210485
1819
	const6	      dw 6,6,6,6
1827
	const6	      dw 6,6,6,6
1820
	xo	      dw 130;87
1828
	xo	      dw 130;87
1821
	zo	      dw 0
1829
	zo	      dw 0
1822
	yo	      dw 100
1830
	yo	      dw 100
1823
	xoffset       dd 130.0
1831
	xoffset       dd 130.0
1824
	yoffset       dd 150.0
1832
	yoffset       dd 150.0
1825
	sscale	      dd 6.0		 ; real scale
1833
	sscale	      dd 6.0		 ; real scale
1826
	vect_x	      dw 0
1834
	vect_x	      dw 0
1827
	vect_y	      dw 0
1835
	vect_y	      dw 0
1828
	vect_z	      dw 0
1836
	vect_z	      dw 0
1829
 
1837
 
1830
 
1838
 
1831
	r_flag	      db 0
1839
	r_flag	      db 0
1832
	dr_flag       db 2
1840
	dr_flag       db 2
1833
	speed_flag    db 0
1841
	speed_flag    db 0
1834
	catmull_flag  db 0
1842
	catmull_flag  db 0
1835
    SourceFile file '../../3DS/HRT.3DS'
1843
    SourceFile file '../../3DS/HRT.3DS'
1836
    EndFile:
1844
    EndFile:
1837
    labelrot:
1845
    labelrot:
1838
	db   'rot. mode'
1846
	db   'rot. mode'
1839
    labelrotend:
1847
    labelrotend:
1840
    labeldrmod:
1848
    labeldrmod:
1841
	db   'shd. mode'
1849
	db   'shd. mode'
1842
    labeldrmodend:
1850
    labeldrmodend:
1843
    labelspeedmod:
1851
    labelspeedmod:
1844
	db   'spd. mode'
1852
	db   'spd. mode'
1845
    labelspeedmodend:
1853
    labelspeedmodend:
1846
    labelzoomout:
1854
    labelzoomout:
1847
	db   'zoom out'
1855
	db   'zoom out'
1848
    labelzoomoutend:
1856
    labelzoomoutend:
1849
    labelzoomin:
1857
    labelzoomin:
1850
	db   'zoom in'
1858
	db   'zoom in'
1851
    labelzoominend:
1859
    labelzoominend:
1852
    labelvector:
1860
    labelvector:
1853
	db   'add vector'
1861
	db   'add vector'
1854
    labelvectorend:
1862
    labelvectorend:
1855
    labelyminus:
1863
    labelyminus:
1856
	db   'y -'
1864
	db   'y -'
1857
    labelyminusend:
1865
    labelyminusend:
1858
    labelzplus:
1866
    labelzplus:
1859
	db   'z +'
1867
	db   'z +'
1860
    labelzplusend:
1868
    labelzplusend:
1861
    labelxminus:
1869
    labelxminus:
1862
	db   'x -'
1870
	db   'x -'
1863
    labelxminusend:
1871
    labelxminusend:
1864
    labelxplus:
1872
    labelxplus:
1865
	db   'x +'
1873
	db   'x +'
1866
    labelxplusend:
1874
    labelxplusend:
1867
    labelzminus:
1875
    labelzminus:
1868
	db   'z -'
1876
	db   'z -'
1869
    labelzminusend:
1877
    labelzminusend:
1870
    labelyplus:
1878
    labelyplus:
1871
	db   'y +'
1879
	db   'y +'
1872
    labelyplusend:
1880
    labelyplusend:
1873
    labelmaincolor:
1881
    labelmaincolor:
1874
	db   'main color'
1882
	db   'main color'
1875
    labelmaincolorend:
1883
    labelmaincolorend:
1876
    labelredplus:
1884
    labelredplus:
1877
	db   'r +'
1885
	db   'r +'
1878
    labelredplusend:
1886
    labelredplusend:
1879
    labelgreenplus:
1887
    labelgreenplus:
1880
	db   'g +'
1888
	db   'g +'
1881
    labelgreenplusend:
1889
    labelgreenplusend:
1882
    labelblueplus:
1890
    labelblueplus:
1883
	db   'b +'
1891
	db   'b +'
1884
    labelblueplusend:
1892
    labelblueplusend:
1885
    labelredminus:
1893
    labelredminus:
1886
	db   'r -'
1894
	db   'r -'
1887
    labelredminusend:
1895
    labelredminusend:
1888
    labelgreenminus:
1896
    labelgreenminus:
1889
	db   'g -'
1897
	db   'g -'
1890
    labelgreenminusend:
1898
    labelgreenminusend:
1891
    labelblueminus:
1899
    labelblueminus:
1892
	db   'b -'
1900
	db   'b -'
1893
    labelblueminusend:
1901
    labelblueminusend:
1894
    labelcatmullmod:
1902
    labelcatmullmod:
1895
	db 'catmull'
1903
	db 'catmull'
1896
    labelcatmullmodend:
1904
    labelcatmullmodend:
1897
    labelonoff:
1905
    labelonoff:
1898
	db 'on/off'
1906
	db 'on/off'
1899
    labelonoffend:
1907
    labelonoffend:
1900
    labelt:
1908
    labelt:
1901
	db   'DEUS CARITAS EST'
1909
	db   'DEUS CARITAS EST'
1902
      if Ext=MMX
1910
      if Ext=MMX
1903
	db   ' (MMX)'
1911
	db   ' (MMX)'
1904
      end if
1912
      end if
1905
    labellen:
1913
    labellen:
1906
	STRdata db '-1        '
1914
	STRdata db '-1        '
1907
align 8
1915
align 8
1908
	@col	dd	?
1916
	@col	dd	?
1909
	@y1	dw	?
1917
	@y1	dw	?
1910
	@x1	dw	?;+8
1918
	@x1	dw	?;+8
1911
	@y2	dw	?
1919
	@y2	dw	?
1912
	@x2	dw	?
1920
	@x2	dw	?
1913
	@y3	dw	?
1921
	@y3	dw	?
1914
	@x3	dw	?;+16
1922
	@x3	dw	?;+16
1915
 
1923
 
1916
	@dx12	dd	?
1924
	@dx12	dd	?
1917
	@dx13	dd	?;+24
1925
	@dx13	dd	?;+24
1918
	@dx23	dd	?
1926
	@dx23	dd	?
1919
 
1927
 
1920
	sinbeta dd	?;+32
1928
	sinbeta dd	?;+32
1921
	cosbeta dd	?
1929
	cosbeta dd	?
1922
 
1930
 
1923
	xsub	dw	?
1931
	xsub	dw	?
1924
	zsub	dw	?;+40
1932
	zsub	dw	?;+40
1925
	ysub	dw	?
1933
	ysub	dw	?
1926
 
1934
 
1927
	xx1	dw	?
1935
	xx1	dw	?
1928
	yy1	dw	?
1936
	yy1	dw	?
1929
	zz1	dw	?;+48
1937
	zz1	dw	?;+48
1930
	xx2	dw	?
1938
	xx2	dw	?
1931
	yy2	dw	?
1939
	yy2	dw	?
1932
	zz2	dw	?
1940
	zz2	dw	?
1933
	xx3	dw	?;+56
1941
	xx3	dw	?;+56
1934
	yy3	dw	?
1942
	yy3	dw	?
1935
	zz3	dw	?
1943
	zz3	dw	?
1936
	scale	dd	?		  ; help scale variable
1944
	scale	dd	?		  ; help scale variable
1937
	;screen  dd      ?                ;pointer to screen buffer
1945
	;screen  dd      ?                ;pointer to screen buffer
1938
	triangles_count_var dw ?
1946
	triangles_count_var dw ?
1939
	points_count_var    dw ?
1947
	points_count_var    dw ?
1940
 
1948
 
1941
 
1949
 
1942
	point_index1	    dw ?   ;-\
1950
	point_index1	    dw ?   ;-\
1943
	point_index2	    dw ?   ;  }  don't change order
1951
	point_index2	    dw ?   ;  }  don't change order
1944
	point_index3	    dw ?   ;-/
1952
	point_index3	    dw ?   ;-/
1945
	temp_col	    dw ?
1953
	temp_col	    dw ?
1946
	high	dd	?
1954
	high	dd	?
1947
align 8
1955
align 8
1948
	buffer	dq	?
1956
	buffer	dq	?
1949
 
1957
 
1950
	err_	dd	?
1958
	err_	dd	?
1951
	drr	dd	?
1959
	drr	dd	?
1952
	xx	dd	?
1960
	xx	dd	?
1953
	yy	dd	?
1961
	yy	dd	?
1954
	xst	dd	?
1962
	xst	dd	?
1955
	yst	dd	?
1963
	yst	dd	?
1956
align 16
1964
align 16
1957
    points:
1965
    points:
1958
	rw (EndFile-SourceFile)/12*3
1966
	rw (EndFile-SourceFile)/12*3
1959
	points_count = ($-points)/6
1967
	points_count = ($-points)/6
1960
    triangles:
1968
    triangles:
1961
	rw (EndFile-SourceFile)/12*3
1969
	rw (EndFile-SourceFile)/12*3
1962
	triangles_count = ($-triangles)/6
1970
	triangles_count = ($-triangles)/6
1963
 
1971
 
1964
align 16
1972
align 16
1965
	points_rotated rw points_count*3 + 2
1973
	points_rotated rw points_count*3 + 2
1966
align 16
1974
align 16
1967
	label trizdd dword
1975
	label trizdd dword
1968
	label trizdq qword
1976
	label trizdq qword
1969
	triangles_with_z rw triangles_count*4 + 2 ; triangles triple dw + z position
1977
	triangles_with_z rw triangles_count*4 + 2 ; triangles triple dw + z position
1970
align 16
1978
align 16
1971
	triangles_normals rb triangles_count * 12 ;
1979
	triangles_normals rb triangles_count * 12 ;
1972
	point_normals rb points_count * 12  ;one 3dvector - triple float dword x,y,z
1980
	point_normals rb points_count * 12  ;one 3dvector - triple float dword x,y,z
1973
align 16
1981
align 16
1974
	point_normals_rotated rb points_count * 12
1982
	point_normals_rotated rb points_count * 12
1975
align 16
1983
align 16
1976
	vectors rb 24
1984
	vectors rb 24
1977
	points_color rb 6*points_count	  ; each color as word
1985
	points_color rb 6*points_count	  ; each color as word
1978
;        sorted_triangles rw triangles_count*3 + 2
1986
;        sorted_triangles rw triangles_count*3 + 2
1979
;align 16
1987
;align 16
1980
	screen rb SIZE_X * SIZE_Y * 3	; screen buffer
1988
	screen rb SIZE_X * SIZE_Y * 3	; screen buffer
1981
	Z_buffer rb SIZE_X * SIZE_Y * 4
1989
	Z_buffer rb SIZE_X * SIZE_Y * 4
1982
	envmap	 rb 512*512*3
1990
	envmap	 rb 512*512*3
1983
	memStack rb 1000 ;memory area for stack
1991
	memStack rb 1000 ;memory area for stack
1984
    I_END:
1992
    I_END: