1 /*
2  * OpenBOR - http://www.chronocrash.com
3  * -----------------------------------------------------------------------
4  * All rights reserved, see LICENSE in OpenBOR root for details.
5  *
6  * Copyright (c) 2004 - 2014 OpenBOR Team
7  */
8 
9 #include "gfxtypes.h"
10 
DOT_16(u16 c,int j,int i)11 static inline u16 DOT_16(u16 c, int j, int i)
12 {
13     static const u16 dotmatrix[16] =
14     {
15         0x01E0, 0x0007, 0x3800, 0x0000,
16         0x39E7, 0x0000, 0x39E7, 0x0000,
17         0x3800, 0x0000, 0x01E0, 0x0007,
18         0x39E7, 0x0000, 0x39E7, 0x0000
19     };
20     return c - ((c >> 2) & *(dotmatrix + ((j & 3) << 2) + (i & 3)));
21 }
22 
DotMatrix(u8 * srcPtr,u32 srcPitch,u8 * deltaPtr,u8 * dstPtr,u32 dstPitch,int width,int height)23 void DotMatrix(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height)
24 {
25     u32 nextlineSrc = srcPitch / sizeof(u16);
26     u32 nextlineDst = dstPitch / sizeof(u16);
27     u16 *p = (u16 *)srcPtr;
28     u16 *q = (u16 *)dstPtr;
29     int i, ii, j, jj;
30 
31     for(j = 0, jj = 0; j < height; ++j, jj += 2)
32     {
33         for(i = 0, ii = 0; i < width; ++i, ii += 2)
34         {
35             u16 c = *(p + i);
36             *(q + ii) = DOT_16(c, jj, ii);
37             *(q + ii + 1) = DOT_16(c, jj, ii + 1);
38             *(q + ii + nextlineDst) = DOT_16(c, jj + 1, ii);
39             *(q + ii + nextlineDst + 1) = DOT_16(c, jj + 1, ii + 1);
40         }
41         p += nextlineSrc;
42         q += nextlineDst << 1;
43     }
44 }
45