]> 4ch.mooo.com Git - 16.git/blob - 16/xw__/mxpg.asm
16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / 16 / xw__ / mxpg.asm
1 .387
2                 PUBLIC  MXGOURAUDPOLY
3                 EXTRN   MX_BYTESPERLINE:BYTE
4                 EXTRN   MX_CLIPX1:BYTE
5                 EXTRN   MX_CLIPX2:BYTE
6                 EXTRN   MX_CLIPY1:BYTE
7                 EXTRN   MX_CLIPY2:BYTE
8                 EXTRN   MX_CODESEGMENT:BYTE
9                 EXTRN   MX_SCANBUFFER:BYTE
10                 EXTRN   MX_VIDEOSEGMENT:BYTE
11 MX_TEXT         SEGMENT PARA PUBLIC USE16 'CODE'
12                 ASSUME CS:MX_TEXT, DS:DGROUP, SS:DGROUP
13 L$1:
14         mov             cx,word ptr [si]
15         sub             cx,word ptr [bx]
16         jg              L$2
17         ret
18 L$2:
19         push            bp
20         push            di
21         push            cx
22         push            ax
23         push            dx
24         mov             ax,word ptr 2[si]
25         mov             bx,word ptr 2[bx]
26         sub             ax,bx
27         jg              L$4
28         jl              L$6
29         mov             ax,bx
30 L$3:
31         mov             word ptr es:[di],ax
32         add             di,8
33         dec             cx
34         jne             L$3
35         jmp             L$8
36 L$4:
37         cwd
38         div             cx
39         mov             bp,ax
40         xor             ax,ax
41         div             cx
42         xchg            ax,bx
43         mov             dx,8000H
44 L$5:
45         mov             word ptr es:[di],ax
46         add             di,8
47         add             dx,bx
48         adc             ax,bp
49         dec             cx
50         jne             L$5
51         jmp             L$8
52 L$6:
53         neg             ax
54         cwd
55         div             cx
56         mov             bp,ax
57         xor             ax,ax
58         div             cx
59         xchg            ax,bx
60         mov             dx,8000H
61 L$7:
62         mov             word ptr es:[di],ax
63         add             di,8
64         sub             dx,bx
65         sbb             ax,bp
66         dec             cx
67         jne             L$7
68 L$8:
69         pop             bx
70         pop             ax
71         pop             cx
72         pop             di
73         sub             ax,bx
74         jg              L$10
75         jl              L$12
76         mov             ah,bl
77         mov             al,80H
78 L$9:
79         mov             word ptr es:2[di],ax
80         add             di,8
81         dec             cx
82         jne             L$9
83         jmp             L$14
84 L$10:
85         cwd
86         div             cx
87         mov             bp,ax
88         xor             ax,ax
89         div             cx
90         xchg            ax,bx
91         mov             dx,8000H
92 L$11:
93         mov             byte ptr es:3[di],al
94         mov             byte ptr es:2[di],dh
95         add             di,8
96         add             dx,bx
97         adc             ax,bp
98         dec             cx
99         jne             L$11
100         jmp             L$14
101 L$12:
102         neg             ax
103         cwd
104         div             cx
105         mov             bp,ax
106         xor             ax,ax
107         div             cx
108         xchg            ax,bx
109         mov             dx,8000H
110 L$13:
111         mov             byte ptr es:3[di],al
112         mov             byte ptr es:2[di],dh
113         add             di,8
114         sub             dx,bx
115         sbb             ax,bp
116         dec             cx
117         jne             L$13
118 L$14:
119         pop             bp
120         ret
121 L$15:
122         mov             ax,word ptr 6[si]
123         mov             bx,word ptr 2[si]
124         cmp             ah,bh
125         jg              L$17
126         jl              L$19
127         add             ax,dx
128         mov             dx,word ptr cs:MX_BYTESPERLINE
129 L$16:
130         mov             byte ptr es:[di],ah
131         add             di,dx
132         dec             cx
133         jne             L$16
134         ret
135 L$17:
136         push            bp
137         push            si
138         mov             si,bx
139         add             si,dx
140         sub             ax,bx
141         xor             dx,dx
142         div             cx
143         mov             bp,ax
144         xor             ax,ax
145         div             cx
146         mov             bx,ax
147         mov             dx,8000H
148         mov             ax,word ptr cs:MX_BYTESPERLINE
149         xchg            ax,si
150 L$18:
151         mov             byte ptr es:[di],ah
152         add             dx,bx
153         adc             ax,bp
154         add             di,si
155         dec             cx
156         jne             L$18
157         pop             si
158         pop             bp
159         ret
160 L$19:
161         push            bp
162         push            si
163         mov             si,bx
164         add             si,dx
165         sub             ax,bx
166         neg             ax
167         xor             dx,dx
168         div             cx
169         mov             bp,ax
170         xor             ax,ax
171         div             cx
172         mov             bx,ax
173         mov             dx,8000H
174         mov             ax,word ptr cs:MX_BYTESPERLINE
175         xchg            ax,si
176 L$20:
177         mov             byte ptr es:[di],ah
178         sub             dx,bx
179         sbb             ax,bp
180         add             di,si
181         dec             cx
182         jne             L$20
183         pop             si
184         pop             bp
185         ret
186 MXGOURAUDPOLY:
187         push            bp
188         mov             bp,sp
189         sub             sp,1eH
190         push            ds
191         push            si
192         push            es
193         push            di
194         mov             cx,word ptr 14H[bp]
195         cmp             cx,3
196         jae             L$21
197         jmp             near ptr L$47
198 L$21:
199         les             di,dword ptr 10H[bp]
200         lds             si,dword ptr 0cH[bp]
201         mov             word ptr -16H[bp],7fffH
202         mov             word ptr -1aH[bp],8000H
203         mov             word ptr -18H[bp],7fffH
204         mov             word ptr -1eH[bp],8000H
205         xor             dx,dx
206 L$22:
207         mov             bx,word ptr es:[di]
208         shl             bx,1
209         shl             bx,1
210         add             bx,si
211         mov             ax,word ptr [bx]
212         cmp             ax,word ptr -16H[bp]
213         jge             L$23
214         mov             word ptr -16H[bp],ax
215         mov             word ptr -0eH[bp],dx
216         mov             word ptr -10H[bp],dx
217 L$23:
218         cmp             ax,word ptr -1aH[bp]
219         jle             L$24
220         mov             word ptr -1aH[bp],ax
221         mov             word ptr -12H[bp],dx
222 L$24:
223         mov             ax,word ptr 2[bx]
224         cmp             ax,word ptr -18H[bp]
225         jge             L$25
226         mov             word ptr -18H[bp],ax
227 L$25:
228         cmp             ax,word ptr -1eH[bp]
229         jle             L$26
230         mov             word ptr -1eH[bp],ax
231 L$26:
232         inc             di
233         inc             di
234         inc             dx
235         inc             dx
236         dec             cx
237         jne             L$22
238         mov             ax,word ptr -1aH[bp]
239         cmp             ax,word ptr cs:MX_CLIPX1
240         jge             L$27
241         jmp             near ptr L$47
242 L$27:
243         mov             bx,word ptr -16H[bp]
244         cmp             bx,word ptr cs:MX_CLIPX2
245         jle             L$28
246         jmp             near ptr L$47
247 L$28:
248         sub             ax,bx
249         jg              L$29
250         jmp             near ptr L$47
251 L$29:
252         mov             ax,word ptr -1eH[bp]
253         cmp             ax,word ptr cs:MX_CLIPY1
254         jge             L$30
255         jmp             near ptr L$47
256 L$30:
257         mov             bx,word ptr -18H[bp]
258         cmp             bx,word ptr cs:MX_CLIPY2
259         jle             L$31
260         jmp             near ptr L$47
261 L$31:
262         sub             ax,bx
263         jg              L$32
264         jmp             near ptr L$47
265 L$32:
266         dec             word ptr 14H[bp]
267         shl             word ptr 14H[bp],1
268         mov             es,word ptr cs:MX_CODESEGMENT
269         mov             ax,offset MX_TEXT:MX_SCANBUFFER
270         mov             word ptr -4[bp],ax
271         mov             si,word ptr -0eH[bp]
272 L$33:
273         lds             bx,dword ptr 10H[bp]
274         mov             di,word ptr [bx+si]
275         dec             si
276         dec             si
277         test            si,si
278         jge             L$34
279         mov             si,word ptr 14H[bp]
280 L$34:
281         mov             word ptr -0eH[bp],si
282         mov             si,word ptr [bx+si]
283         lds             bx,dword ptr 8[bp]
284         shl             di,1
285         shl             si,1
286         mov             ax,word ptr [bx+si]
287         mov             dx,word ptr [bx+di]
288         lds             bx,dword ptr 0cH[bp]
289         shl             si,1
290         shl             di,1
291         add             si,bx
292         add             bx,di
293         mov             di,word ptr -4[bp]
294         call            near ptr L$1
295         mov             word ptr -4[bp],di
296         mov             si,word ptr -0eH[bp]
297         cmp             si,word ptr -12H[bp]
298         jne             L$33
299         mov             ax,offset MX_TEXT:MX_SCANBUFFER+4
300         mov             word ptr -6[bp],ax
301         mov             si,word ptr -10H[bp]
302 L$35:
303         lds             bx,dword ptr 10H[bp]
304         mov             di,word ptr [bx+si]
305         inc             si
306         inc             si
307         cmp             si,word ptr 14H[bp]
308         jbe             L$36
309         xor             si,si
310 L$36:
311         mov             word ptr -10H[bp],si
312         mov             si,word ptr [bx+si]
313         lds             bx,dword ptr 8[bp]
314         shl             di,1
315         shl             si,1
316         mov             ax,word ptr [bx+si]
317         mov             dx,word ptr [bx+di]
318         lds             bx,dword ptr 0cH[bp]
319         shl             si,1
320         shl             di,1
321         add             si,bx
322         add             bx,di
323         mov             di,word ptr -6[bp]
324         call            near ptr L$1
325         mov             word ptr -6[bp],di
326         mov             si,word ptr -10H[bp]
327         cmp             si,word ptr -12H[bp]
328         jne             L$35
329         mov             si,offset MX_TEXT:MX_SCANBUFFER
330         mov             ax,word ptr -16H[bp]
331         mov             cx,word ptr -1aH[bp]
332         sub             cx,ax
333         mov             bx,word ptr cs:MX_CLIPX1
334         sub             bx,ax
335         jle             L$37
336         sub             cx,bx
337         add             ax,bx
338         mov             word ptr -16H[bp],ax
339         shl             bx,1
340         shl             bx,1
341         shl             bx,1
342         add             si,bx
343 L$37:
344         mov             bx,ax
345         add             bx,cx
346         sub             bx,word ptr cs:MX_CLIPX2
347         jle             L$38
348         sub             cx,bx
349 L$38:
350         test            cx,cx
351         jg              L$39
352         jmp             near ptr L$47
353 L$39:
354         mov             word ptr -8[bp],cx
355         mov             word ptr -4[bp],si
356         mov             ds,word ptr cs:MX_CODESEGMENT
357         mov             ax,word ptr -18H[bp]
358         cmp             ax,word ptr cs:MX_CLIPY1
359         jl              L$40
360         mov             ax,word ptr -1eH[bp]
361         cmp             ax,word ptr cs:MX_CLIPY2
362         jg              L$40
363         jmp             L$44
364 L$40:
365         mov             di,cx
366         inc             di
367         sub             si,8
368 L$41:
369         dec             di
370         je              L$44
371         add             si,8
372         mov             ax,word ptr [si]
373         mov             cx,word ptr 4[si]
374         mov             dx,word ptr cs:MX_CLIPY2
375         cmp             ax,dx
376         jg              L$43
377         cmp             cx,dx
378         jle             L$42
379         mov             word ptr 4[si],dx
380         mov             bx,cx
381         sub             bx,dx
382         sub             cx,ax
383         jle             L$43
384         mov             ax,word ptr 2[si]
385         sub             ax,word ptr 6[si]
386         imul            bx
387         idiv            cx
388         add             word ptr 6[si],ax
389         mov             ax,word ptr [si]
390         mov             cx,word ptr 4[si]
391 L$42:
392         mov             dx,word ptr cs:MX_CLIPY1
393         cmp             cx,dx
394         jl              L$43
395         sub             cx,ax
396         jle             L$43
397         cmp             ax,dx
398         jge             L$41
399         mov             word ptr [si],dx
400         sub             dx,ax
401         cmp             cx,dx
402         jbe             L$43
403         mov             ax,word ptr 6[si]
404         sub             ax,word ptr 2[si]
405         imul            dx
406         idiv            cx
407         add             word ptr 2[si],ax
408         jmp             L$41
409 L$43:
410         mov             word ptr [si],0ffffH
411         jmp             L$41
412 L$44:
413         mov             es,word ptr cs:MX_VIDEOSEGMENT
414         mov             si,word ptr -4[bp]
415         mov             cl,byte ptr -16H[bp]
416         and             cl,3
417         mov             al,11H
418         shl             al,cl
419         mov             byte ptr -2[bp],al
420         shr             word ptr -16H[bp],1
421         shr             word ptr -16H[bp],1
422         mov             ax,word ptr 6[bp]
423         mov             ah,al
424         xor             al,al
425         mov             word ptr 6[bp],ax
426 L$45:
427         mov             ax,word ptr [si]
428         test            ax,ax
429         js              L$46
430         mov             cx,word ptr 4[si]
431         sub             cx,ax
432         jle             L$46
433         mul             word ptr cs:MX_BYTESPERLINE
434         add             ax,word ptr -16H[bp]
435         mov             di,ax
436         mov             ah,byte ptr -2[bp]
437         mov             al,2
438         mov             dx,3c4H
439         out             dx,ax
440         mov             dx,word ptr 6[bp]
441         call            near ptr L$15
442 L$46:
443         rol             byte ptr -2[bp],1
444         adc             word ptr -16H[bp],0
445         add             si,8
446         dec             word ptr -8[bp]
447         jne             L$45
448 L$47:
449         xor             ax,ax
450         pop             di
451         pop             es
452         pop             si
453         pop             ds
454         mov             sp,bp
455         pop             bp
456         retf            10H
457 MX_TEXT         ENDS
458                 END