]> 4ch.mooo.com Git - 16.git/blob - 16/xw_/mxln.asm
16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / 16 / xw_ / mxln.asm
1                 PUBLIC  MXLINE
2                 EXTRN   MX_BYTESPERLINE:BYTE
3                 EXTRN   MX_VIDEOSEGMENT:BYTE
4                 EXTRN   MX_CLIPX1:BYTE
5                 EXTRN   MX_CLIPX2:BYTE
6                 EXTRN   MX_CLIPY1:BYTE
7                 EXTRN   MX_CLIPY2:BYTE
8 MX_TEXT         SEGMENT PARA PUBLIC USE16 'CODE'
9                 ASSUME CS:MX_TEXT, DS:DGROUP, SS:DGROUP
10 L$1:
11     DW  offset L$29
12     DW  offset L$32
13     DW  offset L$35
14     DW  offset L$38
15 MXLINE:
16         push            bp
17         mov             bp,sp
18         sub             sp,12H
19         push            ds
20         push            si
21         push            di
22         mov             ax,word ptr 10H[bp]
23         mov             bx,word ptr 0eH[bp]
24         mov             cx,word ptr 0cH[bp]
25         mov             dx,word ptr 0aH[bp]
26         call            near ptr L$8
27         jae             L$2
28         jmp             near ptr L$7
29 L$2:
30         mov             si,cx
31         xchg            ax,si
32         sub             ax,si
33         jge             L$3
34         xchg            cx,si
35         xchg            dx,bx
36         neg             ax
37 L$3:
38         mov             word ptr -2[bp],ax
39         mov             cx,word ptr cs:MX_BYTESPERLINE
40         mov             ax,dx
41         sub             ax,bx
42         jge             L$4
43         neg             cx
44         neg             ax
45 L$4:
46         mov             word ptr -4[bp],ax
47         mov             word ptr -0cH[bp],cx
48         mov             ax,bx
49         mul             word ptr cs:MX_BYTESPERLINE
50         mov             cx,si
51         shr             si,1
52         shr             si,1
53         add             si,ax
54         and             cl,3
55         mov             ax,1102H
56         shl             ah,cl
57         mov             byte ptr -12H[bp],ah
58         mov             dx,3c4H
59         out             dx,ax
60         mov             ax,word ptr cs:MX_VIDEOSEGMENT
61         mov             ds,ax
62         xor             bx,bx
63         mov             al,byte ptr 6[bp]
64         cmp             al,0
65         je              L$5
66         and             al,3
67         shl             al,1
68         shl             al,1
69         shl             al,1
70         mov             ah,al
71         mov             al,3
72         mov             dx,3ceH
73         out             dx,ax
74         inc             bx
75         inc             bx
76 L$5:
77         mov             ax,word ptr -2[bp]
78         mov             cx,word ptr -4[bp]
79         cmp             ax,cx
80         jae             L$6
81         inc             bx
82 L$6:
83         shl             bx,1
84         call            word ptr cs:L$1[bx]
85         cmp             byte ptr 6[bp],0
86         je              L$7
87         mov             ax,3
88         mov             dx,3ceH
89         out             dx,ax
90 L$7:
91         xor             ax,ax
92         pop             di
93         pop             si
94         pop             ds
95         mov             sp,bp
96         pop             bp
97         retf            0cH
98 L$8:
99         mov             di,ax
100         mov             si,dx
101         xor             al,al
102         cmp             cx,word ptr cs:MX_CLIPX1
103         jge             L$9
104         or              al,1
105 L$9:
106         cmp             cx,word ptr cs:MX_CLIPX2
107         jle             L$10
108         or              al,2
109 L$10:
110         cmp             si,word ptr cs:MX_CLIPY1
111         jge             L$11
112         or              al,4
113 L$11:
114         cmp             si,word ptr cs:MX_CLIPY2
115         jle             L$12
116         or              al,8
117 L$12:
118         mov             byte ptr -10H[bp],al
119         xor             al,al
120         cmp             di,word ptr cs:MX_CLIPX1
121         jge             L$13
122         or              al,1
123 L$13:
124         cmp             di,word ptr cs:MX_CLIPX2
125         jle             L$14
126         or              al,2
127 L$14:
128         cmp             bx,word ptr cs:MX_CLIPY1
129         jge             L$15
130         or              al,4
131 L$15:
132         cmp             bx,word ptr cs:MX_CLIPY2
133         jle             L$16
134         or              al,8
135 L$16:
136         mov             byte ptr -0eH[bp],al
137         mov             ah,byte ptr -10H[bp]
138         test            ah,al
139         je              L$17
140         jmp             near ptr L$28
141 L$17:
142         or              ah,al
143         jne             L$18
144         jmp             near ptr L$27
145 L$18:
146         mov             ax,cx
147         sub             ax,di
148         mov             word ptr -0aH[bp],ax
149         mov             ax,si
150         sub             ax,bx
151         mov             word ptr -0cH[bp],ax
152         mov             al,byte ptr -0eH[bp]
153 L$19:
154         test            al,al
155         jne             L$20
156         xchg            di,cx
157         xchg            si,bx
158         xchg            byte ptr -10H[bp],al
159 L$20:
160         test            al,1
161         je              L$21
162         mov             ax,word ptr cs:MX_CLIPX1
163         sub             ax,di
164         mov             di,word ptr cs:MX_CLIPX1
165         jmp             L$22
166 L$21:
167         test            al,2
168         je              L$23
169         mov             ax,word ptr cs:MX_CLIPX2
170         sub             ax,di
171         mov             di,word ptr cs:MX_CLIPX2
172 L$22:
173         imul            word ptr -0cH[bp]
174         idiv            word ptr -0aH[bp]
175         add             bx,ax
176         mov             al,8
177         cmp             bx,word ptr cs:MX_CLIPY2
178         jg              L$26
179         mov             al,4
180         cmp             bx,word ptr cs:MX_CLIPY1
181         jl              L$26
182         xor             al,al
183         jmp             L$26
184 L$23:
185         test            al,4
186         je              L$24
187         mov             ax,word ptr cs:MX_CLIPY1
188         sub             ax,bx
189         mov             bx,word ptr cs:MX_CLIPY1
190         jmp             L$25
191 L$24:
192         mov             ax,word ptr cs:MX_CLIPY2
193         sub             ax,bx
194         mov             bx,word ptr cs:MX_CLIPY2
195 L$25:
196         imul            word ptr -0aH[bp]
197         idiv            word ptr -0cH[bp]
198         add             di,ax
199         mov             al,1
200         cmp             di,word ptr cs:MX_CLIPX1
201         jl              L$26
202         mov             al,2
203         cmp             di,word ptr cs:MX_CLIPX2
204         jg              L$26
205         xor             al,al
206 L$26:
207         mov             ah,byte ptr -10H[bp]
208         test            ah,al
209         jne             L$28
210         or              ah,al
211         je              L$27
212         jmp             near ptr L$19
213 L$27:
214         mov             ax,di
215         mov             dx,si
216         clc
217         ret
218 L$28:
219         stc
220         ret
221 L$29:
222         mov             di,ax
223         neg             di
224         shl             cx,1
225         mov             word ptr -6[bp],cx
226         mov             cx,ax
227         shl             ax,1
228         mov             word ptr -8[bp],ax
229         mov             al,2
230         mov             ah,byte ptr -12H[bp]
231         mov             bl,byte ptr 8[bp]
232         mov             dx,3c4H
233         inc             cx
234 L$30:
235         mov             byte ptr [si],bl
236         dec             cx
237         je              L$31
238         rol             ah,1
239         adc             si,0
240         out             dx,ax
241         add             di,word ptr -6[bp]
242         jl              L$30
243         add             si,word ptr -0cH[bp]
244         sub             di,word ptr -8[bp]
245         jmp             L$30
246 L$31:
247         ret
248 L$32:
249         mov             di,cx
250         neg             di
251         shl             ax,1
252         mov             word ptr -6[bp],ax
253         mov             ax,cx
254         shl             ax,1
255         mov             word ptr -8[bp],ax
256         mov             bl,byte ptr 8[bp]
257         mov             ah,byte ptr -12H[bp]
258         mov             al,2
259         mov             dx,3c4H
260         inc             cx
261 L$33:
262         mov             byte ptr [si],bl
263         dec             cx
264         je              L$34
265         add             si,word ptr -0cH[bp]
266         add             di,word ptr -6[bp]
267         jl              L$33
268         rol             ah,1
269         adc             si,0
270         out             dx,ax
271         sub             di,word ptr -8[bp]
272         jmp             L$33
273 L$34:
274         ret
275 L$35:
276         mov             di,ax
277         neg             di
278         shl             cx,1
279         mov             word ptr -6[bp],cx
280         mov             cx,ax
281         shl             ax,1
282         mov             word ptr -8[bp],ax
283         mov             al,2
284         mov             ah,byte ptr -12H[bp]
285         mov             bl,byte ptr 8[bp]
286         mov             dx,3c4H
287         inc             cx
288 L$36:
289         mov             bh,byte ptr [si]
290         mov             byte ptr [si],bl
291         dec             cx
292         je              L$37
293         rol             ah,1
294         adc             si,0
295         out             dx,ax
296         add             di,word ptr -6[bp]
297         jl              L$36
298         add             si,word ptr -0cH[bp]
299         sub             di,word ptr -8[bp]
300         jmp             L$36
301 L$37:
302         ret
303 L$38:
304         mov             di,cx
305         neg             di
306         shl             ax,1
307         mov             word ptr -6[bp],ax
308         mov             ax,cx
309         shl             ax,1
310         mov             word ptr -8[bp],ax
311         mov             bl,byte ptr 8[bp]
312         mov             ah,byte ptr -12H[bp]
313         mov             al,2
314         mov             dx,3c4H
315         inc             cx
316 L$39:
317         mov             bh,byte ptr [si]
318         mov             byte ptr [si],bl
319         dec             cx
320         je              L$40
321         add             si,word ptr -0cH[bp]
322         add             di,word ptr -6[bp]
323         jl              L$39
324         rol             ah,1
325         adc             si,0
326         out             dx,ax
327         sub             di,word ptr -8[bp]
328         jmp             L$39
329 L$40:
330         ret
331 MX_TEXT         ENDS
332                 END