source: trunk/src/gdi32/rgbcvt.asm@ 5280

Last change on this file since 5280 was 4034, checked in by sandervl, 25 years ago

lots of small changes; CreateHalftonePalette + rgb 565 -> rgb 555 conversion

File size: 3.5 KB
Line 
1; $Id: rgbcvt.asm,v 1.4 2000-08-18 18:14:58 sandervl Exp $
2; Copyright 2000 Daniela Engert (dani@ngrt.de)
3
4 .586p
5 .MMX
6 .MODEL FLAT
7
8 .DATA
9
10 align 4
11 and1mask dd 0001F001Fh
12 dd 0001F001Fh
13 and2mask dd 0FFC0FFC0h
14 dd 0FFC0FFC0h
15 and2mask565 dd 0FFE07FE0h
16 dd 07FE07FE0h
17
18 .CODE
19
20; void _Optlink RGB555to565 (WORD *dest, WORD *src, ULONG num);
21
22 PUBLIC RGB555to565
23
24RGB555to565 PROC NEAR
25
26 push esi
27 push edi
28 cld
29
30 mov edi, eax ; _Optlink arg1 = EAX
31 mov esi, edx ; _Optlink arg2 = EDX
32 shr ecx, 1 ; _Optlink arg3 = ECX
33 pushf
34cvt:
35 mov eax, [esi]
36 mov edx, eax
37
38 add esi, 4
39 shl eax, 1
40
41 and edx, 0001F001Fh
42 and eax, 0FFC0FFC0h
43
44 add edi, 4
45 or eax, edx
46
47 mov [edi-4], eax
48 loop cvt
49
50 popf
51 jnc SHORT done
52
53 mov ax, [esi]
54 mov dx, ax
55 and dx, 0001Fh
56 shl ax, 1
57 and ax, 0FFC0h
58 or ax, dx
59 mov [edi], ax
60
61done:
62 pop edi
63 pop esi
64 ret
65
66RGB555to565 ENDP
67
68 PUBLIC RGB565to555
69
70RGB565to555 PROC NEAR
71
72 push esi
73 push edi
74 cld
75
76 mov edi, eax ; _Optlink arg1 = EAX
77 mov esi, edx ; _Optlink arg2 = EDX
78 shr ecx, 1 ; _Optlink arg3 = ECX
79 pushf
80cvt:
81 mov eax, [esi]
82 mov edx, eax
83
84 add esi, 4
85 shr eax, 1
86
87 and edx, 0001F001Fh
88 and eax, 0FFE07FE0h
89
90 add edi, 4
91 or eax, edx
92
93 mov [edi-4], eax
94 loop cvt
95
96 popf
97 jnc SHORT done
98
99 mov ax, [esi]
100 mov dx, ax
101 and dx, 0001Fh
102 shr ax, 1
103 and ax, 0FFE0h
104 or ax, dx
105 mov [edi], ax
106
107done:
108 pop edi
109 pop esi
110 ret
111
112RGB565to555 ENDP
113
114; void _Optlink RGB555to565MMX(WORD *dest, WORD *src, ULONG num);
115
116 PUBLIC RGB555to565MMX
117
118RGB555to565MMX PROC NEAR
119 push esi
120 push edi
121 cld
122
123 cmp ecx, 0
124 jz done
125
126 push ecx
127
128 mov edi, eax ; _Optlink arg1 = EAX
129 mov esi, edx ; _Optlink arg2 = EDX
130 shr ecx, 3 ; _Optlink arg3 = ECX
131 jz lastpixels
132
133 sub esp, 108
134 fsaved dword ptr [esp]
135
136 movq mm2, qword ptr and1mask ; 0001F001F001F001Fh
137 movq mm3, qword ptr and2mask ; FFC0FFC00FFC0FFC0h
138
139cvt:
140 movq mm0, qword ptr [esi]
141 add edi, 16
142
143 movq mm4, qword ptr [esi+8]
144 movq mm1, mm0
145
146 movq mm5, mm4
147 psllq mm0, 1
148
149 psllq mm4, 1
150 pand mm1, mm2
151
152 pand mm0, mm3
153 pand mm5, mm2
154
155 pand mm4, mm3
156 por mm0, mm1
157
158 por mm4, mm5
159 add esi, 16
160
161 movq qword ptr [edi-16], mm0
162 dec ecx
163
164 movq qword ptr [edi-8], mm4
165 jnz cvt
166
167 nop
168 nop
169
170 frstord dword ptr [esp]
171 add esp, 108
172
173lastpixels:
174 pop ecx
175 and ecx, 3
176 jz short done
177
178cvt2loop:
179 mov ax, [esi]
180 mov dx, ax
181
182 add esi, 2
183 and dx, 001Fh
184
185 shl ax, 1
186 add edi, 2
187
188 and ax, 0FFC0h
189 or ax, dx
190
191 mov [edi-2], ax
192 loop cvt2loop
193
194done:
195 pop edi
196 pop esi
197 ret
198
199RGB555to565MMX ENDP
200
201
202; void _Optlink RGB565to555MMX(WORD *dest, WORD *src, ULONG num);
203
204 PUBLIC RGB565to555MMX
205
206RGB565to555MMX PROC NEAR
207 push esi
208 push edi
209 cld
210
211 cmp ecx, 0
212 jz done
213
214 push ecx
215
216 mov edi, eax ; _Optlink arg1 = EAX
217 mov esi, edx ; _Optlink arg2 = EDX
218 shr ecx, 3 ; _Optlink arg3 = ECX
219 jz lastpixels
220
221 sub esp, 108
222 fsaved dword ptr [esp]
223
224 movq mm2, qword ptr and1mask ; 0001F001F001F001Fh
225 movq mm3, qword ptr and2mask565 ; FFE07FE007FE07FE0h
226
227cvt:
228 movq mm0, qword ptr [esi]
229 add edi, 16
230
231 movq mm4, qword ptr [esi+8]
232 movq mm1, mm0
233
234 movq mm5, mm4
235 psrlq mm0, 1
236
237 psrlq mm4, 1
238 pand mm1, mm2
239
240 pand mm0, mm3
241 pand mm5, mm2
242
243 pand mm4, mm3
244 por mm0, mm1
245
246 por mm4, mm5
247 add esi, 16
248
249 movq qword ptr [edi-16], mm0
250 dec ecx
251
252 movq qword ptr [edi-8], mm4
253 jnz cvt
254
255 nop
256 nop
257
258 frstord dword ptr [esp]
259 add esp, 108
260
261lastpixels:
262 pop ecx
263 and ecx, 3
264 jz short done
265
266cvt2loop:
267 mov ax, [esi]
268 mov dx, ax
269
270 add esi, 2
271 and dx, 001Fh
272
273 shr ax, 1
274 add edi, 2
275
276 and ax, 0FFE0h
277 or ax, dx
278
279 mov [edi-2], ax
280 loop cvt2loop
281
282done:
283 pop edi
284 pop esi
285 ret
286
287RGB565to555MMX ENDP
288
289 END
Note: See TracBrowser for help on using the repository browser.