rename expr.cpp.h to expr.c.h
[rofl0r-VisualBoyAdvance.git] / src / simple2x.c
blob17b3f04c774030c709ee310d35ad5b1d761931a1
1 // VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
2 // Copyright (C) 1999-2003 Forgotten
3 // Copyright (C) 2004 Forgotten and the VBA development team
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, or(at your option)
8 // 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.
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 Foundation,
17 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include "System.h"
21 void Simple2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
22 u8 *dstPtr, u32 dstPitch, int width, int height)
24 u8 *nextLine, *finish;
26 nextLine = dstPtr + dstPitch;
28 do {
29 u32 *bP = (u32 *) srcPtr;
30 u32 *dP = (u32 *) dstPtr;
31 u32 *nL = (u32 *) nextLine;
32 u32 currentPixel;
34 finish = (u8 *) bP + ((width+2) << 1);
35 currentPixel = *bP++;
37 do {
38 #ifdef WORDS_BIGENDIAN
39 u32 color = currentPixel >> 16;
40 #else
41 u32 color = currentPixel & 0xffff;
42 #endif
44 color = color | (color << 16);
46 *(dP) = color;
47 *(nL) = color;
49 #ifdef WORDS_BIGENDIAN
50 color = currentPixel & 0xffff;
51 #else
52 color = currentPixel >> 16;
53 #endif
54 color = color| (color << 16);
55 *(dP + 1) = color;
56 *(nL + 1) = color;
58 currentPixel = *bP++;
60 dP += 2;
61 nL += 2;
62 } while ((u8 *) bP < finish);
64 srcPtr += srcPitch;
65 dstPtr += dstPitch << 1;
66 nextLine += dstPitch << 1;
68 while (--height);
71 void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
72 u8 *dstPtr, u32 dstPitch, int width, int height)
74 u8 *nextLine, *finish;
76 nextLine = dstPtr + dstPitch;
78 do {
79 u32 *bP = (u32 *) srcPtr;
80 u32 *dP = (u32 *) dstPtr;
81 u32 *nL = (u32 *) nextLine;
82 u32 currentPixel;
84 finish = (u8 *) bP + ((width+1) << 2);
85 currentPixel = *bP++;
87 do {
88 u32 color = currentPixel;
90 *(dP) = color;
91 *(dP+1) = color;
92 *(nL) = color;
93 *(nL + 1) = color;
95 currentPixel = *bP++;
97 dP += 2;
98 nL += 2;
99 } while ((u8 *) bP < finish);
101 srcPtr += srcPitch;
102 dstPtr += dstPitch << 1;
103 nextLine += dstPitch << 1;
105 while (--height);