Subversion Repositories Kolibri OS

Rev

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

Rev 1245 Rev 6619
1
;---------------------------------------------------------------------
1
;---------------------------------------------------------------------
2
;--------------------textured triangle procedure----------------------
2
;--------------------textured triangle procedure----------------------
3
;---------------------------------------------------------------------
3
;---------------------------------------------------------------------
4
 
4
 
5
tex_triangle:
5
tex_triangle:
6
;----------in - eax - x1 shl 16 + y1
6
;----------in - eax - x1 shl 16 + y1
7
;-------------- ebx - x2 shl 16 + y2
7
;-------------- ebx - x2 shl 16 + y2
8
;---------------ecx - x3 shl 16 + y3
8
;---------------ecx - x3 shl 16 + y3
9
;---------------edx - nothing
9
;---------------edx - nothing
10
;---------------esi - pointer to texture buffer
10
;---------------esi - pointer to texture buffer
11
;---------------edi - pointer to screen buffer
11
;---------------edi - pointer to screen buffer
12
;-------------stack - texture coordinates
12
;-------------stack - texture coordinates
13
.tex_x1 equ  ebp+4
13
.tex_x1 equ  ebp+4
14
.tex_y1 equ  ebp+6
14
.tex_y1 equ  ebp+6
15
.tex_x2 equ  ebp+8
15
.tex_x2 equ  ebp+8
16
.tex_y2 equ  ebp+10
16
.tex_y2 equ  ebp+10
17
.tex_x3 equ  ebp+12
17
.tex_x3 equ  ebp+12
18
.tex_y3 equ  ebp+14
18
.tex_y3 equ  ebp+14
19
 
19
 
20
.x1 equ ebp-2 ;dw ?
20
.x1 equ ebp-2 ;dw ?
21
.y1 equ ebp-4 ;dw ?
21
.y1 equ ebp-4 ;dw ?
22
.x2 equ ebp-6 ;dw ?
22
.x2 equ ebp-6 ;dw ?
23
.y2 equ ebp-8 ;dw ?
23
.y2 equ ebp-8 ;dw ?
24
.x3 equ ebp-10 ;dw ?
24
.x3 equ ebp-10 ;dw ?
25
.y3 equ ebp-12 ;dw ?
25
.y3 equ ebp-12 ;dw ?
26
.dx12 equ ebp-16 ;dd ?
26
.dx12 equ ebp-16 ;dd ?
27
.dx13 equ ebp-20 ;dd ?
27
.dx13 equ ebp-20 ;dd ?
28
.dx23 equ ebp-24 ;dd ?
28
.dx23 equ ebp-24 ;dd ?
29
.tex_dx12 equ ebp-28 ;dd ?
29
.tex_dx12 equ ebp-28 ;dd ?
30
.tex_dy12 equ ebp-32 ;dd ?
30
.tex_dy12 equ ebp-32 ;dd ?
31
.tex_dx13 equ ebp-36 ;dd ?
31
.tex_dx13 equ ebp-36 ;dd ?
32
.tex_dy13 equ ebp-40 ;dd ?
32
.tex_dy13 equ ebp-40 ;dd ?
33
.tex_dx23 equ ebp-44 ;dd ?
33
.tex_dx23 equ ebp-44 ;dd ?
34
.tex_dy23 equ ebp-48 ;dd ?
34
.tex_dy23 equ ebp-48 ;dd ?
35
.tex_ptr equ ebp-52 ;dd ?
35
.tex_ptr equ ebp-52 ;dd ?
36
 
36
 
37
.scan_x2 equ ebp-56 ;dd ?
37
.scan_x2 equ ebp-56 ;dd ?
38
.scan_y2 equ ebp-60 ;dd ?
38
.scan_y2 equ ebp-60 ;dd ?
39
.scan_x1 equ ebp-64 ;dd ?
39
.scan_x1 equ ebp-64 ;dd ?
40
.scan_y1 equ ebp-68 ;dd ?
40
.scan_y1 equ ebp-68 ;dd ?
41
 
41
 
42
  mov ebp,esp
42
  mov ebp,esp
43
  sub esp,68
43
  sub esp,68
44
;if  Ext = MMX
44
;if  Ext = MMX
45
;  emms
45
;  emms
46
;end if
46
;end if
47
  mov edx,dword[.tex_x1]		  ; check all parameters
47
  mov edx,dword[.tex_x1]		  ; check all parameters
48
  or dx,dx
48
  or dx,dx
49
  jl .tt_end
49
  jl .tt_end
50
  cmp dx,TEX_X-1
50
  cmp dx,TEX_X-1
51
  jg .tt_end
51
  jg .tt_end
52
  shr edx,16
52
  shr edx,16
53
  or dx,dx
53
  or dx,dx
54
  jl .tt_end
54
  jl .tt_end
55
  cmp dx,TEX_Y-1
55
  cmp dx,TEX_Y-1
56
  jg .tt_end
56
  jg .tt_end
57
 
57
 
58
  mov edx,dword[.tex_x2]
58
  mov edx,dword[.tex_x2]
59
  or dx,dx
59
  or dx,dx
60
  jl .tt_end
60
  jl .tt_end
61
  cmp dx,TEX_X-1
61
  cmp dx,TEX_X-1
62
  jg .tt_end
62
  jg .tt_end
63
  shr edx,16
63
  shr edx,16
64
  or dx,dx
64
  or dx,dx
65
  jl .tt_end
65
  jl .tt_end
66
  cmp dx,TEX_Y-1
66
  cmp dx,TEX_Y-1
67
  jg .tt_end
67
  jg .tt_end
68
 
68
 
69
  mov edx,dword[.tex_x3]
69
  mov edx,dword[.tex_x3]
70
  or dx,dx
70
  or dx,dx
71
  jl .tt_end
71
  jl .tt_end
72
  cmp dx,TEX_X-1
72
  cmp dx,TEX_X-1
73
  jg .tt_end
73
  jg .tt_end
74
  shr edx,16
74
  shr edx,16
75
  cmp dx,TEX_Y-1
75
  cmp dx,TEX_Y-1
76
  jg .tt_end
76
  jg .tt_end
77
  or dx,dx
77
  or dx,dx
78
  jl .tt_end
78
  jl .tt_end
79
 
79
 
80
  mov edx,eax	 ; check X&Y triangle coordinate
80
  mov edx,eax	 ; check X&Y triangle coordinate
81
  or edx,ebx
81
  or edx,ebx
82
  or edx,ecx
82
  or edx,ecx
83
  test edx,80008000h
83
  test edx,80008000h
84
  jne .tt_end
84
  jne .tt_end
85
 
-
 
-
 
85
  mov  dx,[size_x_var]
86
 ; or ax,ax
86
 ; or ax,ax
87
 ; jl .tt_end
87
 ; jl .tt_end
88
  cmp ax,SIZE_Y
88
;  cmp ax,SIZE_Y
89
  jg .tt_end
89
;  jg .tt_end
90
  ror eax,16
90
  ror eax,16
91
 ; or ax,ax
91
 ; or ax,ax
92
 ; jl .tt_end
92
 ; jl .tt_end
93
  cmp ax,SIZE_X
93
  cmp ax,dx  ;SIZE_X
94
  jg .tt_end
94
  jg .tt_end
95
  rol eax,16
95
  rol eax,16
96
 
96
 
97
 ; or bx,bx
97
 ; or bx,bx
98
 ; jl .tt_end
98
 ; jl .tt_end
99
  cmp bx,SIZE_Y
99
;  cmp bx,SIZE_Y
100
  jg .tt_end
100
;  jg .tt_end
101
  ror ebx,16
101
  ror ebx,16
102
 ; or bx,bx
102
 ; or bx,bx
103
 ; jl .tt_end
103
 ; jl .tt_end
104
  cmp bx,SIZE_X
104
  cmp bx,dx ;SIZE_X
105
  jg .tt_end
105
  jg .tt_end
106
  rol ebx,16
106
  rol ebx,16
107
 
107
 
108
 ; or cx,cx
108
 ; or cx,cx
109
 ; jl .tt_end
109
 ; jl .tt_end
110
  cmp cx,SIZE_Y
110
;  cmp cx,SIZE_Y
111
  jg .tt_end
111
;  jg .tt_end
112
  ror ecx,16
112
  ror ecx,16
113
 ; or cx,cx
113
 ; or cx,cx
114
 ; jl .tt_end
114
 ; jl .tt_end
115
  cmp cx,SIZE_X
115
  cmp cx,dx  ;SIZE_X
116
  jg .tt_end
116
  jg .tt_end
117
  rol ecx,16		       ; uff.. parameters was checked
117
  rol ecx,16		       ; uff.. parameters was checked
118
 
118
 
119
  cmp ax,bx			    ;sort all parameters
119
  cmp ax,bx			    ;sort all parameters
120
  jle .tt_sort1
120
  jle .tt_sort1
121
  xchg eax,ebx
121
  xchg eax,ebx
122
  mov edx,dword [.tex_x1]
122
  mov edx,dword [.tex_x1]
123
  xchg edx,dword [.tex_x2]
123
  xchg edx,dword [.tex_x2]
124
  mov dword[.tex_x1],edx
124
  mov dword[.tex_x1],edx
125
.tt_sort1:
125
.tt_sort1:
126
  cmp ax,cx
126
  cmp ax,cx
127
  jle .tt_sort2
127
  jle .tt_sort2
128
  xchg eax,ecx
128
  xchg eax,ecx
129
  mov edx,dword [.tex_x1]
129
  mov edx,dword [.tex_x1]
130
  xchg edx,dword [.tex_x3]
130
  xchg edx,dword [.tex_x3]
131
  mov dword [.tex_x1],edx
131
  mov dword [.tex_x1],edx
132
.tt_sort2:
132
.tt_sort2:
133
  cmp bx,cx
133
  cmp bx,cx
134
  jle .tt_sort3
134
  jle .tt_sort3
135
  xchg ebx,ecx
135
  xchg ebx,ecx
136
  mov edx,dword [.tex_x2]
136
  mov edx,dword [.tex_x2]
137
  xchg edx,dword [.tex_x3]
137
  xchg edx,dword [.tex_x3]
138
  mov dword [.tex_x2],edx
138
  mov dword [.tex_x2],edx
139
.tt_sort3:
139
.tt_sort3:
140
  mov [.y1],ax	   ; and store to user friendly variables
140
  mov [.y1],ax	   ; and store to user friendly variables
141
  shr eax,16
141
  shr eax,16
142
  mov [.x1],ax
142
  mov [.x1],ax
143
  mov [.y2],bx
143
  mov [.y2],bx
144
  shr ebx,16
144
  shr ebx,16
145
  mov [.x2],bx
145
  mov [.x2],bx
146
  mov [.y3],cx
146
  mov [.y3],cx
147
  shr ecx,16
147
  shr ecx,16
148
  mov [.x3],cx
148
  mov [.x3],cx
149
  mov [.tex_ptr],esi
149
  mov [.tex_ptr],esi
150
 
150
 
151
  movsx ebx,word[.y2]
151
  movsx ebx,word[.y2]
152
  sub bx,[.y1]
152
  sub bx,[.y1]
153
  jnz .tt_dx12_make
153
  jnz .tt_dx12_make
154
 
154
 
155
  mov dword[.dx12],0
155
  mov dword[.dx12],0
156
  mov dword[.tex_dx12],0
156
  mov dword[.tex_dx12],0
157
  mov dword[.tex_dy12],0
157
  mov dword[.tex_dy12],0
158
  jmp .tt_dx12_done
158
  jmp .tt_dx12_done
159
.tt_dx12_make:
159
.tt_dx12_make:
160
  mov ax,[.x2]
160
  mov ax,[.x2]
161
  sub ax,[.x1]
161
  sub ax,[.x1]
162
  cwde
162
  cwde
163
  shl eax,ROUND
163
  shl eax,ROUND
164
  cdq
164
  cdq
165
  idiv ebx
165
  idiv ebx
166
  mov [.dx12],eax				      ; dx12 = (x2-x1)/(y2-y1)
166
  mov [.dx12],eax				      ; dx12 = (x2-x1)/(y2-y1)
167
 
167
 
168
  mov ax,word[.tex_x2]
168
  mov ax,word[.tex_x2]
169
  sub ax,word[.tex_x1]
169
  sub ax,word[.tex_x1]
170
  cwde
170
  cwde
171
  shl eax,ROUND
171
  shl eax,ROUND
172
  cdq
172
  cdq
173
  idiv ebx
173
  idiv ebx
174
  mov [.tex_dx12],eax			  ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1)
174
  mov [.tex_dx12],eax			  ; tex_dx12 = (tex_x2-tex_x1)/(y2-y1)
175
 
175
 
176
  mov ax,word[.tex_y2]
176
  mov ax,word[.tex_y2]
177
  sub ax,word[.tex_y1]
177
  sub ax,word[.tex_y1]
178
  cwde
178
  cwde
179
  shl eax,ROUND
179
  shl eax,ROUND
180
  cdq
180
  cdq
181
  idiv ebx
181
  idiv ebx
182
  mov [.tex_dy12],eax			  ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1)
182
  mov [.tex_dy12],eax			  ; tex_dy12 = (tex_y2-tex_y1)/(y2-y1)
183
.tt_dx12_done:
183
.tt_dx12_done:
184
 
184
 
185
  movsx ebx,word[.y3]
185
  movsx ebx,word[.y3]
186
  sub bx,word[.y1]
186
  sub bx,word[.y1]
187
  jnz .tt_dx13_make
187
  jnz .tt_dx13_make
188
 
188
 
189
  mov dword [.dx13],0
189
  mov dword [.dx13],0
190
  mov dword [.tex_dx13],0
190
  mov dword [.tex_dx13],0
191
  mov dword [.tex_dy13],0
191
  mov dword [.tex_dy13],0
192
  jmp .tt_dx13_done
192
  jmp .tt_dx13_done
193
.tt_dx13_make:
193
.tt_dx13_make:
194
  mov ax,[.x3]
194
  mov ax,[.x3]
195
  sub ax,[.x1]
195
  sub ax,[.x1]
196
  cwde
196
  cwde
197
  shl eax,ROUND
197
  shl eax,ROUND
198
  cdq
198
  cdq
199
  idiv ebx
199
  idiv ebx
200
  mov [.dx13],eax				  ; dx13 = (x3-x1)/(y3-y1)
200
  mov [.dx13],eax				  ; dx13 = (x3-x1)/(y3-y1)
201
 
201
 
202
  mov ax,word[.tex_x3]
202
  mov ax,word[.tex_x3]
203
  sub ax,word[.tex_x1]
203
  sub ax,word[.tex_x1]
204
  cwde
204
  cwde
205
  shl eax,ROUND
205
  shl eax,ROUND
206
  cdq
206
  cdq
207
  idiv ebx
207
  idiv ebx
208
  mov [.tex_dx13],eax			    ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1)
208
  mov [.tex_dx13],eax			    ; tex_dx13 = (tex_x3-tex_x1)/(y3-y1)
209
 
209
 
210
  mov ax,word[.tex_y3]
210
  mov ax,word[.tex_y3]
211
  sub ax,word[.tex_y1]
211
  sub ax,word[.tex_y1]
212
  cwde
212
  cwde
213
  shl eax,ROUND
213
  shl eax,ROUND
214
  cdq
214
  cdq
215
  idiv ebx
215
  idiv ebx
216
  mov [.tex_dy13],eax			    ; tex_dy13 = (tex_y3-tex_y1)/(y3-y1)
216
  mov [.tex_dy13],eax			    ; tex_dy13 = (tex_y3-tex_y1)/(y3-y1)
217
.tt_dx13_done:
217
.tt_dx13_done:
218
 
218
 
219
  movsx ebx,word[.y3]
219
  movsx ebx,word[.y3]
220
  sub bx,word[.y2]
220
  sub bx,word[.y2]
221
  jnz .tt_dx23_make
221
  jnz .tt_dx23_make
222
 
222
 
223
  mov dword [.dx23],0
223
  mov dword [.dx23],0
224
  mov dword [.tex_dx23],0
224
  mov dword [.tex_dx23],0
225
  mov dword [.tex_dy23],0
225
  mov dword [.tex_dy23],0
226
  jmp .tt_dx23_done
226
  jmp .tt_dx23_done
227
.tt_dx23_make:
227
.tt_dx23_make:
228
  mov ax,[.x3]
228
  mov ax,[.x3]
229
  sub ax,[.x2]
229
  sub ax,[.x2]
230
  cwde
230
  cwde
231
  shl eax,ROUND
231
  shl eax,ROUND
232
  cdq
232
  cdq
233
  idiv ebx
233
  idiv ebx
234
  mov [.dx23],eax				  ; dx23 = (x3-x2)/(y3-y2)
234
  mov [.dx23],eax				  ; dx23 = (x3-x2)/(y3-y2)
235
 
235
 
236
  mov ax,word[.tex_x3]
236
  mov ax,word[.tex_x3]
237
  sub ax,word[.tex_x2]
237
  sub ax,word[.tex_x2]
238
  cwde
238
  cwde
239
  shl eax,ROUND
239
  shl eax,ROUND
240
  cdq
240
  cdq
241
  idiv ebx
241
  idiv ebx
242
  mov [.tex_dx23],eax			 ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2)
242
  mov [.tex_dx23],eax			 ; tex_dx23 = (tex_x3-tex_x2)/(y3-y2)
243
 
243
 
244
  mov ax,word[.tex_y3]
244
  mov ax,word[.tex_y3]
245
  sub ax,word[.tex_y2]
245
  sub ax,word[.tex_y2]
246
  cwde
246
  cwde
247
  shl eax,ROUND
247
  shl eax,ROUND
248
  cdq
248
  cdq
249
  idiv ebx
249
  idiv ebx
250
  mov [.tex_dy23],eax			; tex_dy23 = (tex_y3-tex_y2)/(y3-y2)
250
  mov [.tex_dy23],eax			; tex_dy23 = (tex_y3-tex_y2)/(y3-y2)
251
.tt_dx23_done:
251
.tt_dx23_done:
252
 
252
 
253
  movsx eax,word[.x1]
253
  movsx eax,word[.x1]
254
  shl eax,ROUND
254
  shl eax,ROUND
255
  mov ebx,eax
255
  mov ebx,eax
256
 
256
 
257
  movsx edx, word[.tex_x1]
257
  movsx edx, word[.tex_x1]
258
  shl edx,ROUND
258
  shl edx,ROUND
259
  mov [.scan_x1],edx
259
  mov [.scan_x1],edx
260
  mov [.scan_x2],edx
260
  mov [.scan_x2],edx
261
  movsx edx, word[.tex_y1]
261
  movsx edx, word[.tex_y1]
262
  shl edx,ROUND
262
  shl edx,ROUND
263
  mov [.scan_y1],edx
263
  mov [.scan_y1],edx
264
  mov [.scan_y2],edx
264
  mov [.scan_y2],edx
265
 
265
 
266
  mov cx,[.y1]
266
  mov cx,[.y1]
267
  cmp cx, [.y2]
267
  cmp cx, [.y2]
268
  jge .tt_loop1_end
268
  jge .tt_loop1_end
269
.tt_loop1:
269
.tt_loop1:
270
  push edi
270
  push edi
271
  push eax
271
  push eax
272
  push ebx
272
  push ebx
273
  push cx
273
  push cx
274
  push ebp
274
  push ebp
275
;; Madis
275
;; Madis
276
;if Ext=MMX                          ; With MMX enabled it reverse light vectors ????
276
;if Ext=MMX                          ; With MMX enabled it reverse light vectors ????
277
;  mov   dword[esp-8],ROUND
277
;  mov   dword[esp-8],ROUND
278
;  mov   dword[esp-4],0 ; Is this a bug? Explanation down 3 lines
278
;  mov   dword[esp-4],0 ; Is this a bug? Explanation down 3 lines
279
;  movq  mm0,qword[.scan_y1]
279
;  movq  mm0,qword[.scan_y1]
280
;  movq  mm1,qword[.scan_y2]
280
;  movq  mm1,qword[.scan_y2]
281
;  psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc.
281
;  psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc.
282
;  psrad mm1,[esp-8] ;It always defaults to QWORD
282
;  psrad mm1,[esp-8] ;It always defaults to QWORD
283
;  packssdw mm0,mm1
283
;  packssdw mm0,mm1
284
;  movq  [esp-8],mm0
284
;  movq  [esp-8],mm0
285
;  sub   esp,8
285
;  sub   esp,8
286
;else
286
;else
287
 
287
 
288
   push     dword[.scan_y2]  ; now I push variables on stack without shifting
288
   push     dword[.scan_y2]  ; now I push variables on stack without shifting
289
   push     dword[.scan_x2]
289
   push     dword[.scan_x2]
290
   push     dword[.scan_y1]
290
   push     dword[.scan_y1]
291
   push     dword[.scan_x1]
291
   push     dword[.scan_x1]
292
 
292
 
293
;end if
293
;end if
294
 
294
 
295
 
295
 
296
 
296
 
297
  push	dword[.tex_ptr]
297
  push	dword[.tex_ptr]
298
 
298
 
299
  push	cx
299
  push	cx
300
  mov	edx,ebx
300
  mov	edx,ebx
301
  sar	edx,ROUND
301
  sar	edx,ROUND
302
  push	dx
302
  push	dx
303
  mov	edx,eax
303
  mov	edx,eax
304
  sar	edx,ROUND
304
  sar	edx,ROUND
305
  push	dx
305
  push	dx
306
  call	textured_line
306
  call	textured_line
307
 
307
 
308
  pop	ebp
308
  pop	ebp
309
  pop	cx
309
  pop	cx
310
  pop	ebx
310
  pop	ebx
311
  pop	eax
311
  pop	eax
312
  pop	edi
312
  pop	edi
313
 
313
 
314
  mov	edx, [.tex_dx13]
314
  mov	edx, [.tex_dx13]
315
  add	[.scan_x1], edx
315
  add	[.scan_x1], edx
316
  mov	edx, [.tex_dx12]
316
  mov	edx, [.tex_dx12]
317
  add	[.scan_x2], edx
317
  add	[.scan_x2], edx
318
  mov	edx, [.tex_dy13]
318
  mov	edx, [.tex_dy13]
319
  add	[.scan_y1], edx
319
  add	[.scan_y1], edx
320
  mov	edx, [.tex_dy12]
320
  mov	edx, [.tex_dy12]
321
  add	[.scan_y2], edx
321
  add	[.scan_y2], edx
322
 
322
 
323
  add	eax, [.dx13]
323
  add	eax, [.dx13]
324
  add	ebx, [.dx12]
324
  add	ebx, [.dx12]
325
  inc	cx
325
  inc	cx
326
  cmp	cx,[.y2]
326
  cmp	cx,[.y2]
327
  jl	.tt_loop1
327
  jl	.tt_loop1
328
 
328
 
329
.tt_loop1_end:
329
.tt_loop1_end:
330
 
330
 
331
 
331
 
332
  mov	cx, [.y2]
332
  mov	cx, [.y2]
333
  cmp	cx, [.y3]
333
  cmp	cx, [.y3]
334
  jge	.tt_loop2_end
334
  jge	.tt_loop2_end
335
 
335
 
336
  movsx ebx,word[.x2]
336
  movsx ebx,word[.x2]
337
  shl	ebx,ROUND
337
  shl	ebx,ROUND
338
 
338
 
339
  movsx edx, word[.tex_x2]
339
  movsx edx, word[.tex_x2]
340
  shl	edx,ROUND
340
  shl	edx,ROUND
341
  mov	[.scan_x2],edx
341
  mov	[.scan_x2],edx
342
  movsx edx, word[.tex_y2]
342
  movsx edx, word[.tex_y2]
343
  shl	edx,ROUND
343
  shl	edx,ROUND
344
  mov	[.scan_y2],edx
344
  mov	[.scan_y2],edx
345
 
345
 
346
.tt_loop2:
346
.tt_loop2:
347
  push	edi
347
  push	edi
348
  push	eax
348
  push	eax
349
  push	ebx
349
  push	ebx
350
  push	cx
350
  push	cx
351
  push	ebp
351
  push	ebp
352
;; Madis
352
;; Madis
353
;if Ext=MMX
353
;if Ext=MMX
354
;  mov   dword[esp-8],ROUND
354
;  mov   dword[esp-8],ROUND
355
;  mov   dword[esp-4],0 ; Is this a bug? Explanation down 3 lines
355
;  mov   dword[esp-4],0 ; Is this a bug? Explanation down 3 lines
356
;  movq  mm0,qword[.scan_y1]
356
;  movq  mm0,qword[.scan_y1]
357
;  movq  mm1,qword[.scan_y2]
357
;  movq  mm1,qword[.scan_y2]
358
;  psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc.
358
;  psrad mm0,[esp-8] ;This instr. won't allow modifiers BYTE, WORD, etc.
359
;  psrad mm1,[esp-8] ;It always defaults to QWORD
359
;  psrad mm1,[esp-8] ;It always defaults to QWORD
360
;  packssdw mm0,mm1
360
;  packssdw mm0,mm1
361
;  movq  [esp-8],mm0
361
;  movq  [esp-8],mm0
362
;  sub   esp,8
362
;  sub   esp,8
363
;else
363
;else
364
 
364
 
365
;end if
365
;end if
366
  push	dword[.scan_y2]
366
  push	dword[.scan_y2]
367
  push	dword[.scan_x2]
367
  push	dword[.scan_x2]
368
  push	dword[.scan_y1]
368
  push	dword[.scan_y1]
369
  push	dword[.scan_x1]
369
  push	dword[.scan_x1]
370
 
370
 
371
 
371
 
372
 
372
 
373
  push	dword[.tex_ptr]
373
  push	dword[.tex_ptr]
374
 
374
 
375
  push	cx
375
  push	cx
376
  mov	edx,ebx
376
  mov	edx,ebx
377
  sar	edx,ROUND
377
  sar	edx,ROUND
378
  push	dx
378
  push	dx
379
  mov	edx,eax
379
  mov	edx,eax
380
  sar	edx,ROUND
380
  sar	edx,ROUND
381
  push	dx
381
  push	dx
382
  call	textured_line
382
  call	textured_line
383
 
383
 
384
  pop	ebp
384
  pop	ebp
385
  pop	cx
385
  pop	cx
386
  pop	ebx
386
  pop	ebx
387
  pop	eax
387
  pop	eax
388
  pop	edi
388
  pop	edi
389
 
389
 
390
  mov	edx, [.tex_dx13]
390
  mov	edx, [.tex_dx13]
391
  add	[.scan_x1], edx
391
  add	[.scan_x1], edx
392
  mov	edx, [.tex_dx23]
392
  mov	edx, [.tex_dx23]
393
  add	[.scan_x2], edx
393
  add	[.scan_x2], edx
394
  mov	edx, [.tex_dy13]
394
  mov	edx, [.tex_dy13]
395
  add	[.scan_y1], edx
395
  add	[.scan_y1], edx
396
  mov	edx, [.tex_dy23]
396
  mov	edx, [.tex_dy23]
397
  add	[.scan_y2], edx
397
  add	[.scan_y2], edx
398
 
398
 
399
  add	eax, [.dx13]
399
  add	eax, [.dx13]
400
  add	ebx, [.dx23]
400
  add	ebx, [.dx23]
401
  inc	cx
401
  inc	cx
402
  cmp	cx,[.y3]
402
  cmp	cx,[.y3]
403
  jl	.tt_loop2
403
  jl	.tt_loop2
404
 
404
 
405
.tt_loop2_end:
405
.tt_loop2_end:
406
 
406
 
407
.tt_end:
407
.tt_end:
408
 mov	esp,ebp
408
 mov	esp,ebp
409
 
409
 
410
ret 12
410
ret 12
411
 
411
 
412
 
412
 
413
textured_line:
413
textured_line:
414
;-----in -edi screen buffer pointer
414
;-----in -edi screen buffer pointer
415
;------------ stack:
415
;------------ stack:
416
  .x1 equ word [ebp+4]
416
  .x1 equ word [ebp+4]
417
  .x2 equ word [ebp+6]
417
  .x2 equ word [ebp+6]
418
  .y  equ word [ebp+8]
418
  .y  equ word [ebp+8]
419
 
419
 
420
  .tex_ptr equ dword [ebp+10]
420
  .tex_ptr equ dword [ebp+10]
421
  .tex_x1  equ	[ebp+14]
421
  .tex_x1  equ	[ebp+14]
422
  .tex_y1  equ	[ebp+18]
422
  .tex_y1  equ	[ebp+18]
423
  .tex_x2  equ	[ebp+22]
423
  .tex_x2  equ	[ebp+22]
424
  .tex_y2  equ	[ebp+26]
424
  .tex_y2  equ	[ebp+26]
425
 
425
 
426
  .tex_dx equ ebp-4 ;dd ?
426
  .tex_dx equ ebp-4 ;dd ?
427
  .tex_dy equ ebp-8 ;dd ?
427
  .tex_dy equ ebp-8 ;dd ?
428
 
428
 
429
  mov	ebp,esp
429
  mov	ebp,esp
430
  sub	esp,8
430
  sub	esp,8
431
 
431
 
432
  mov	ax,.y
432
  mov	ax,.y
433
  or	ax,ax
433
  or	ax,ax
434
  jl	.tl_quit
434
  jl	.tl_quit
-
 
435
  mov	dx,[size_y_var]
435
  cmp	ax,SIZE_Y
436
  cmp	ax,dx ;SIZE_Y
436
  jg	.tl_quit
437
  jg	.tl_quit
437
 
438
 
438
  mov	ax,.x1
439
  mov	ax,.x1
439
  cmp	ax,.x2
440
  cmp	ax,.x2
440
  je	.tl_quit
441
  je	.tl_quit
441
  jl	.tl_ok
442
  jl	.tl_ok
442
 
443
 
443
  xchg	ax,.x2
444
  xchg	ax,.x2
444
  mov	.x1,ax
445
  mov	.x1,ax
445
 
446
 
446
if Ext >= MMX
447
if Ext >= MMX
447
  movq	  mm0,.tex_x1
448
  movq	  mm0,.tex_x1
448
  movq	  mm1,.tex_x2
449
  movq	  mm1,.tex_x2
449
  movq	  .tex_x2,mm0
450
  movq	  .tex_x2,mm0
450
  movq	  .tex_x1,mm1
451
  movq	  .tex_x1,mm1
451
 
452
 
452
else
453
else
453
 
454
 
454
  mov	eax,.tex_x1
455
  mov	eax,.tex_x1
455
  xchg	eax,.tex_x2
456
  xchg	eax,.tex_x2
456
  mov	.tex_x1,eax
457
  mov	.tex_x1,eax
457
 
458
 
458
  mov	eax,.tex_y1
459
  mov	eax,.tex_y1
459
  xchg	eax,.tex_y2
460
  xchg	eax,.tex_y2
460
  mov	.tex_y1,eax
461
  mov	.tex_y1,eax
461
 
462
 
462
end if
463
end if
463
 
464
 
464
 .tl_ok:
465
 .tl_ok:
465
 
466
 
466
  mov	ebx,edi
467
  mov	ebx,edi
467
  movsx edi,.y
468
  movsx edi,.y
-
 
469
  movzx eax,word[size_x_var]
-
 
470
  lea	eax,[eax*3]
468
  mov	eax,SIZE_X*3
471
;  mov   eax,SIZE_X*3
469
  mul	edi
472
  mul	edi
470
  mov	edi,eax
473
  mov	edi,eax
471
  movsx eax,.x1
474
  movsx eax,.x1
472
  add	edi,eax
475
  add	edi,eax
473
  shl	eax,1
476
  shl	eax,1
474
  add	edi,eax
477
  add	edi,eax
475
  add	edi,ebx
478
  add	edi,ebx
476
 
479
 
477
  mov	cx,.x2
480
  mov	cx,.x2
478
  sub	cx,.x1
481
  sub	cx,.x1
479
  movsx ecx,cx
482
  movsx ecx,cx
480
 
483
 
481
  mov	eax,.tex_x2
484
  mov	eax,.tex_x2
482
  sub	eax,.tex_x1
485
  sub	eax,.tex_x1
483
  cdq
486
  cdq
484
  idiv	ecx
487
  idiv	ecx
485
  mov	[.tex_dx],eax		; tex_dx=(tex_x2-tex_x1)/(x2-x1)
488
  mov	[.tex_dx],eax		; tex_dx=(tex_x2-tex_x1)/(x2-x1)
486
 
489
 
487
  mov	eax,.tex_y2
490
  mov	eax,.tex_y2
488
  sub	eax,.tex_y1
491
  sub	eax,.tex_y1
489
  cdq
492
  cdq
490
  idiv	ecx
493
  idiv	ecx
491
  mov	[.tex_dy],eax		       ; tex_dy = (tex_y2-tex_y1)/(x2-x1)
494
  mov	[.tex_dy],eax		       ; tex_dy = (tex_y2-tex_y1)/(x2-x1)
492
 
495
 
493
  mov	eax,.tex_x1
496
  mov	eax,.tex_x1
494
  mov	ebx,.tex_y1
497
  mov	ebx,.tex_y1
495
  cld
498
  cld
496
 .tl_loop:
499
 .tl_loop:
497
  mov	edx,eax    ; eax - cur x
500
  mov	edx,eax    ; eax - cur x
498
  mov	esi,ebx    ; ebx - cur y
501
  mov	esi,ebx    ; ebx - cur y
499
  shr	edx,ROUND
502
  shr	edx,ROUND
500
  shr	esi,ROUND
503
  shr	esi,ROUND
501
 macro .fluent
504
 macro .fluent
502
 {
505
 {
503
  push	eax
506
  push	eax
504
  push	edx
507
  push	edx
505
  mov	eax,TEX_X*3
508
  mov	eax,TEX_X*3
506
  mul	esi
509
  mul	esi
507
  mov	esi,eax
510
  mov	esi,eax
508
  pop	edx
511
  pop	edx
509
  pop	eax
512
  pop	eax
510
 }
513
 }
511
 macro .shift
514
 macro .shift
512
 {
515
 {
513
  shl	esi,TEX_SHIFT
516
  shl	esi,TEX_SHIFT
514
  lea	esi,[esi*3]
517
  lea	esi,[esi*3]
515
  ;push edx
518
  ;push edx
516
  ;mov edx,esi
519
  ;mov edx,esi
517
  ;shl esi,1
520
  ;shl esi,1
518
  ;add esi,edx
521
  ;add esi,edx
519
  ;pop edx
522
  ;pop edx
520
 }
523
 }
521
  if TEX = FLUENTLY
524
  if TEX = FLUENTLY
522
    .fluent
525
    .fluent
523
  end if
526
  end if
524
  if TEX = SHIFTING
527
  if TEX = SHIFTING
525
    .shift
528
    .shift
526
  end if
529
  end if
527
  lea	edx,[edx*3]
530
  lea	edx,[edx*3]
528
  add	esi,edx
531
  add	esi,edx
529
 ; shl edx,1
532
 ; shl edx,1
530
 ; add esi,edx
533
 ; add esi,edx
531
  add	esi,.tex_ptr
534
  add	esi,.tex_ptr
532
  movsd
535
  movsd
533
  dec	edi
536
  dec	edi
534
  add	eax,[.tex_dx]
537
  add	eax,[.tex_dx]
535
  add	ebx,[.tex_dy]
538
  add	ebx,[.tex_dy]
536
  loop .tl_loop
539
  loop .tl_loop
537
 
540
 
538
 .tl_quit:
541
 .tl_quit:
539
  mov esp,ebp
542
  mov esp,ebp
540
 
543
 
541
ret 18+8
544
ret 18+8
542
;  .tex_dx dd ?
545
;  .tex_dx dd ?
543
;  .tex_dy dd ?
546
;  .tex_dy dd ?