1 /*
2  * VisualBoyAdvanced - Nintendo Gameboy/GameboyAdvance (TM) emulator
3  * Copyrigh(c) 1999-2002 Forgotten (vb@emuhq.com)
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 #include <xtl.h>
20 //#include "System.h"
21 
22 #define u8 unsigned char
23 #define u32 DWORD
24 #define u16 WORD
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
Simple2x(u8 * srcPtr,u32 srcPitch,u8 *,u8 * dstPtr,u32 dstPitch,int width,int height,int scanlines)30 void Simple2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
31               u8 *dstPtr, u32 dstPitch, int width, int height, int scanlines)
32 {
33   u8 *nextLine, *finish;
34 
35   nextLine = dstPtr + dstPitch;
36 
37   do {
38     u32 *bP = (u32 *) srcPtr;
39     u32 *dP = (u32 *) dstPtr;
40     u32 *nL = (u32 *) nextLine;
41     u32 currentPixel;
42 
43     finish = (u8 *) bP + ((width+2) << 1);
44     currentPixel = *bP++;
45 
46     do {
47 #ifdef WORDS_BIGENDIAN
48       u32 color = currentPixel >> 16;
49 #else
50       u32 color = currentPixel & 0xffff;
51 #endif
52 
53       color = color | (color << 16);
54 
55       *(dP) = color;
56       *(nL) = color;
57 
58 #ifdef WORDS_BIGENDIAN
59       color = (currentPixel << 16) >> 16;
60 #else
61       color = currentPixel >> 16;
62 #endif
63       color = color| (color << 16);
64       *(dP + 1) = color;
65       *(nL + 1) = color;
66 
67       currentPixel = *bP++;
68 
69       dP += 2;
70       nL += 2;
71     } while ((u8 *) bP < finish);
72 
73     srcPtr += srcPitch;
74     dstPtr += dstPitch * 2;
75     nextLine += dstPitch * 2;
76   }
77   while (--height);
78 }
79 
Simple2x32(u8 * srcPtr,u32 srcPitch,u8 *,u8 * dstPtr,u32 dstPitch,int width,int height)80 void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
81                 u8 *dstPtr, u32 dstPitch, int width, int height)
82 {
83   u8 *nextLine, *finish;
84 
85   nextLine = dstPtr + dstPitch;
86 
87   do {
88     u32 *bP = (u32 *) srcPtr;
89     u32 *dP = (u32 *) dstPtr;
90     u32 *nL = (u32 *) nextLine;
91     u32 currentPixel;
92 
93     finish = (u8 *) bP + ((width+1) << 2);
94     currentPixel = *bP++;
95 
96     do {
97       u32 color = currentPixel;
98 
99       *(dP) = color;
100       *(dP+1) = color;
101       *(nL) = color;
102       *(nL + 1) = color;
103 
104       currentPixel = *bP++;
105 
106       dP += 2;
107       nL += 2;
108     } while ((u8 *) bP < finish);
109 
110     srcPtr += srcPitch;
111     dstPtr += dstPitch * 2;
112     nextLine += dstPitch * 2;
113   }
114   while (--height);
115 }
116 #ifdef __cplusplus
117 }
118 #endif
119