]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/cfb/stipmips.s
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / cfb / stipmips.s
1 /*
2  * $XConsortium: stipmips.s,v 1.10 94/04/17 20:29:08 keith Exp $
3  *
4 Copyright (c) 1990  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26  *
27  * Author:  Keith Packard, MIT X Consortium
28  */
29
30 /*
31  * MIPS assembly code for optimized text rendering.
32  *
33  * Other stippling could be done in assembly, but the payoff is
34  * not nearly as large.  Mostly because large areas are heavily
35  * optimized already.
36  */
37
38 #ifdef MIPSEL
39 # define BitsR          sll
40 # define BitsL          srl
41 # define BO(o)          o
42 # define HO(o)          o
43 # define WO(o)          o
44 # define FourBits(dest,bits)    and     dest, bits, 0xf
45 #else
46 # define BitsR  srl
47 # define BitsL  sll
48 # define BO(o)          3-o
49 # define HO(o)          2-o
50 # define WO(o)          o
51 # define FourBits(dest,bits)    srl     dest, bits, 28
52 #endif
53
54 /* reordering instructions would be fatal here */
55         .set    noreorder
56
57         
58 /*
59  * cfbStippleStack(addr, stipple, value, stride, Count, Shift)
60  *               4       5       6      7     16(sp) 20(sp)
61  *
62  *  Apply successive 32-bit stipples starting at addr, addr+stride, ...
63  *
64  *  Used for text rendering, but only when no data could be lost
65  *  when the stipple is shifted left by Shift bits
66  */
67 /* arguments */
68 #define addr    $4
69 #define stipple $5
70 #define value   $6
71 #define stride  $7
72 #define Count   16($sp)
73 #define Shift   20($sp)
74
75 /* local variables */
76 #define count   $14
77 #define shift   $13
78 #define atemp   $12
79 #define bits    $11
80 #define lshift  $9
81 #define sbase   $8
82 #define stemp   $2
83
84 #define CASE_SIZE       5       /* case blocks are 2^5 bytes each */
85 #define CASE_MASK       0x1e0   /* first case mask */
86
87 #define ForEachLine     $200
88 #define NextLine        $201
89 #define NextLine1       $202
90 #define CaseBegin       $203
91 #define ForEachBits     $204
92 #define ForEachBits1    $205
93 #define NextBits        $206
94
95 #ifdef TETEXT
96 #define cfbStippleStack cfbStippleStackTE
97 #endif
98
99         .globl  cfbStippleStack
100         .ent    cfbStippleStack 2
101 cfbStippleStack:
102         .frame  $sp, 0, $31
103         lw      count, Count                    /* fetch stack params */
104         la      sbase,CaseBegin                 /* load up switch table */
105         lw      shift, Shift
106         li      lshift, 4                       /* compute offset within */
107         subu    lshift, lshift, shift           /*  stipple of remaining bits */
108 #ifdef MIPSEL
109         addu    shift, shift, CASE_SIZE         /* first shift for LSB */
110 #else
111         addu    shift, shift, 28-CASE_SIZE      /* first shift for MSB */
112 #endif
113         /* do ... while (--count > 0); */
114 ForEachLine:
115         lw      bits, 0(stipple)                /* get stipple bits */
116         move    atemp, addr                     /* set up for this line */
117 #ifdef TETEXT
118         /* Terminal emulator fonts are expanded and have many 0 rows */
119         beqz    bits, NextLine                  /* skip out early on 0 */
120 #endif
121         addu    addr, addr, stride              /* step for the loop */
122         BitsR   stemp, bits, shift              /* get first bits */
123         and     stemp, stemp, CASE_MASK         /* compute first branch */
124         addu    stemp, stemp, sbase             /*  ... */
125         j       stemp                           /*  ... */
126         BitsL   bits, bits, lshift              /* set remaining bits */
127
128 ForEachBits:
129         addu    atemp, atemp, 4
130 ForEachBits1:
131         FourBits(stemp, bits)                   /* compute jump for */
132         sll     stemp, stemp, CASE_SIZE         /*  next four bits */
133         addu    stemp, stemp, sbase             /*  ... */
134         j       stemp                           /*  ... */
135         BitsL   bits, bits, 4                   /* step for remaining bits */
136 CaseBegin:
137         bnez    bits, ForEachBits1              /* 0 */
138         addu    atemp, atemp, 4
139 NextLine:
140         addu    count, count, -1
141         bnez    count, ForEachLine
142         addu    stipple, stipple, 4
143         j       $31
144         nop
145         nop
146
147         bnez    bits, ForEachBits               /* 1 */
148         sb      value, BO(0)(atemp)
149         addu    count, count, -1
150         bnez    count, ForEachLine
151         addu    stipple, stipple, 4
152         j       $31
153         nop
154         nop
155                                         
156         bnez    bits, ForEachBits               /* 2 */
157         sb      value, BO(1)(atemp)
158         addu    count, count, -1
159         bnez    count, ForEachLine
160         addu    stipple, stipple, 4
161         j       $31
162         nop
163         nop
164                                         
165         bnez    bits, ForEachBits               /* 3 */
166         sh      value, HO(0)(atemp)
167         addu    count, count, -1
168         bnez    count, ForEachLine
169         addu    stipple, stipple, 4
170         j       $31
171         nop
172         nop
173                                         
174         bnez    bits, ForEachBits               /* 4 */
175         sb      value, BO(2)(atemp)
176         addu    count, count, -1
177         bnez    count, ForEachLine
178         addu    stipple, stipple, 4
179         j       $31
180         nop
181         nop
182                                         
183         sb      value, BO(0)(atemp)             /* 5 */
184         bnez    bits, ForEachBits
185         sb      value, BO(2)(atemp)
186         addu    count, count, -1
187         bnez    count, ForEachLine
188         addu    stipple, stipple, 4
189         j       $31
190         nop
191                                         
192         sb      value, BO(1)(atemp)             /* 6 */
193         bnez    bits, ForEachBits
194         sb      value, BO(2)(atemp)
195         addu    count, count, -1
196         bnez    count, ForEachLine
197         addu    stipple, stipple, 4
198         j       $31
199         nop
200                                         
201         bnez    bits, ForEachBits               /* 7 */
202         swl     value, BO(2)(atemp)             /* untested on MSB */
203         addu    count, count, -1
204         bnez    count, ForEachLine
205         addu    stipple, stipple, 4
206         j       $31
207         nop
208         nop
209                                         
210         bnez    bits, ForEachBits               /* 8 */
211         sb      value, BO(3)(atemp)
212         addu    count, count, -1
213         bnez    count, ForEachLine
214         addu    stipple, stipple, 4
215         j       $31
216         nop
217         nop
218                                         
219         sb      value, BO(0)(atemp)             /* 9 */
220         bnez    bits, ForEachBits
221         sb      value, BO(3)(atemp)
222         addu    count, count, -1
223         bnez    count, ForEachLine
224         addu    stipple, stipple, 4
225         j       $31
226         nop
227                                         
228         sb      value, BO(1)(atemp)             /* a */
229         bnez    bits, ForEachBits
230         sb      value, BO(3)(atemp)
231         addu    count, count, -1
232         bnez    count, ForEachLine
233         addu    stipple, stipple, 4
234         j       $31
235         nop
236
237         sh      value, HO(0)(atemp)             /* b */
238         bnez    bits, ForEachBits
239         sb      value, BO(3)(atemp)
240         addu    count, count, -1
241         bnez    count, ForEachLine
242         addu    stipple, stipple, 4
243         j       $31
244         nop
245                                         
246         bnez    bits, ForEachBits               /* c */
247         sh      value, HO(2)(atemp)
248         addu    count, count, -1
249         bnez    count, ForEachLine
250         addu    stipple, stipple, 4
251         j       $31
252         nop
253         nop
254                                         
255         sb      value, BO(0)(atemp)             /* d */
256         bnez    bits, ForEachBits
257         sh      value, HO(2)(atemp)
258         addu    count, count, -1
259         bnez    count, ForEachLine
260         addu    stipple, stipple, 4
261         j       $31
262         nop
263
264         bnez    bits, ForEachBits               /* e */
265         swr     value, BO(1)(atemp)             /* untested on MSB */
266         addu    count, count, -1
267         bnez    count, ForEachLine
268         addu    stipple, stipple, 4
269         j       $31
270         nop
271         nop
272                                         
273         bnez    bits, ForEachBits               /* f */
274         sw      value, WO(0)(atemp)
275         addu    count, count, -1
276         bnez    count, ForEachLine
277         addu    stipple, stipple, 4
278         j       $31
279         nop
280         nop
281                                         
282         .end    cfbStippleStack