2 * Glide64 - Glide video plugin for Nintendo 64 emulators.
3 * Copyright (c) 2002 Dave2001
4 * Copyright (c) 2008 Günther <guenther.emu@freenet.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //****************************************************************
23 // Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64)
24 // Project started on December 29th, 2001
27 // * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.
28 // * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.
30 // Official Glide64 development channel: #Glide64 on EFnet
32 // Original author: Dave2001 (Dave2999@hotmail.com)
33 // Other authors: Gonetz, Gugaman
35 //****************************************************************
37 //****************************************************************
40 DWORD
Load16bRGBA (unsigned char * dst
, unsigned char * src
, int wid_64
, int height
, int line
, int real_width
, int tile
)
42 if (wid_64
< 1) wid_64
= 1;
43 if (height
< 1) height
= 1;
44 int ext
= (real_width
- (wid_64
<< 2)) << 1;
47 mov esi
,dword ptr
[src
]
48 mov edi
,dword ptr
[dst
]
50 mov ecx
,dword ptr
[height
]
54 mov ecx
,dword ptr
[wid_64
]
56 mov eax
,dword ptr
[esi
] // read both pixels
65 mov dword ptr
[edi
],eax
69 mov eax
,dword ptr
[esi
] // read both pixels
78 mov dword ptr
[edi
],eax
90 add esi
,dword ptr
[line
]
91 add edi
,dword ptr
[ext
]
93 mov ecx
,dword ptr
[wid_64
]
95 mov eax
,dword ptr
[esi
+4] // read both pixels
103 mov dword ptr
[edi
],eax
107 mov eax
,dword ptr
[esi
] // read both pixels
116 mov dword ptr
[edi
],eax
123 add esi
,dword ptr
[line
]
124 add edi
,dword ptr
[ext
]
133 //printf("Load16bRGBA\n");
134 long lTemp
, lHeight
= (long) height
;
137 "mov %[c], %[temp] \n"
139 "mov %[wid_64], %%ecx \n"
141 "mov (%[src]), %%eax \n" // read both pixels
144 "mov %%eax, %%edx \n"
150 "mov %%eax, (%[dst]) \n"
154 "mov (%[src]), %%eax \n" // read both pixels
157 "mov %%eax, %%edx \n"
163 "mov %%eax, (%[dst]) \n"
170 "mov %[temp], %[c] \n"
173 "mov %[c], %[temp] \n"
175 "add %[line], %[src] \n"
176 "add %[ext], %[dst] \n"
178 "mov %[wid_64], %%ecx \n"
180 "mov 4(%[src]), %%eax \n" // read both pixels
182 "mov %%eax, %%edx \n"
188 "mov %%eax, (%[dst]) \n"
192 "mov (%[src]), %%eax \n" // read both pixels
195 "mov %%eax, %%edx \n"
201 "mov %%eax, (%[dst]) \n"
208 "add %[line], %[src] \n"
209 "add %[ext], %[dst] \n"
211 "mov %[temp], %[c] \n"
216 : [temp
]"=m"(lTemp
), [src
]"+S"(src
), [dst
]"+D"(dst
), [c
]"+c"(lHeight
)
217 : [wid_64
] "g" (wid_64
), [line
] "g" ((uintptr_t)line
), [ext
] "g" ((uintptr_t)ext
)
218 : "memory", "cc", "eax", "edx"
221 return (1 << 16) | GR_TEXFMT_ARGB_1555
;
224 //****************************************************************
225 // Size: 2, Format: 3
227 // ** by Gugaman/Dave2001 **
229 DWORD
Load16bIA (unsigned char * dst
, unsigned char * src
, int wid_64
, int height
, int line
, int real_width
, int tile
)
231 if (wid_64
< 1) wid_64
= 1;
232 if (height
< 1) height
= 1;
233 int ext
= (real_width
- (wid_64
<< 2)) << 1;
236 mov esi
,dword ptr
[src
]
237 mov edi
,dword ptr
[dst
]
239 mov ecx
,dword ptr
[height
]
243 mov ecx
,dword ptr
[wid_64
]
245 mov eax
,dword ptr
[esi
] // read both pixels
247 mov dword ptr
[edi
],eax
251 mov eax
,dword ptr
[esi
] // read both pixels
253 mov dword ptr
[edi
],eax
265 add esi
,dword ptr
[line
]
266 add edi
,dword ptr
[ext
]
268 mov ecx
,dword ptr
[wid_64
]
270 mov eax
,dword ptr
[esi
+4] // read both pixels
271 mov dword ptr
[edi
],eax
275 mov eax
,dword ptr
[esi
] // read both pixels
277 mov dword ptr
[edi
],eax
284 add esi
,dword ptr
[line
]
285 add edi
,dword ptr
[ext
]
294 //printf("Load16bIA\n");
295 long lTemp
, lHeight
= (long) height
;
298 "mov %[c], %[temp] \n"
300 "mov %[wid_64], %%ecx \n"
302 "mov (%[src]), %%eax \n" // read both pixels
304 "mov %%eax, (%[dst]) \n"
308 "mov (%[src]), %%eax \n" // read both pixels
310 "mov %%eax, (%[dst]) \n"
317 "mov %[temp], %[c] \n"
320 "mov %[c], %[temp] \n"
322 "add %[line], %[src] \n"
323 "add %[ext], %[dst] \n"
325 "mov %[wid_64], %%ecx \n"
327 "mov 4(%[src]), %%eax \n" // read both pixels
328 "mov %%eax, (%[dst]) \n"
332 "mov (%[src]), %%eax \n" // read both pixels
334 "mov %%eax, (%[dst]) \n"
341 "add %[line], %[src] \n"
342 "add %[ext], %[dst] \n"
344 "mov %[temp], %[c] \n"
349 : [temp
]"=m"(lTemp
), [src
]"+S"(src
), [dst
]"+D"(dst
), [c
]"+c"(lHeight
)
350 : [wid_64
] "g" (wid_64
), [line
] "g" ((uintptr_t)line
), [ext
] "g" ((uintptr_t)ext
)
351 : "memory", "cc", "eax"
354 return (1 << 16) | GR_TEXFMT_ALPHA_INTENSITY_88
;