OSDN Git Service

[WIP][Agar] Build fit to CSP.
[csp-qt/common_source_project-fm7.git] / source / src / agar / common / scaler / generic / scaler_x125.c
1 /*
2  * Zoom x1.25x2 i.e. 800x480.
3  * (C) 2014 K.Ohta
4  * 
5  * History:
6  *  2013-04-02 Move from scaler_x2.c
7  */
8 #include <agar/core.h>
9 #include <agar/gui.h>
10 #include "simd_types.h"
11 #include "sdl_cpuid.h"
12
13 extern struct XM7_CPUID *pCpuID;
14 extern BOOL bFullScan;
15
16 static void Scaler_DrawLine(Uint32 *dst, Uint32 *src, int ww, int repeat, int pitch)
17 {
18    int xx;
19    int yy;
20    int yrep2;
21    int yrep3;
22    int blank;
23    Uint32 *b2p;
24    v4hi r1, r2;
25    v4hi *d0;
26    v4hi *b;
27    int pitch2;
28 #if AG_BIG_ENDIAN != 1
29    const Uint32 bb = 0xff000000;
30 #else
31    const Uint32 bb = 0x000000ff;
32 #endif
33      
34    if(repeat <= 0) return;
35    b = (v4hi *)src;
36    b2p = (Uint32 *)dst;
37    pitch2 = pitch / sizeof(Uint32);
38    if((bFullScan) || (repeat < 2)) {
39       for(xx = 0; xx < ww; xx += 8) {
40          b2p = (Uint32 *)dst;
41          r1 = *b++;
42          r2 = *b++;
43          // 76543210 -> 7654432100
44          for(yy = 0; yy < repeat; yy++) {
45                b2p[0] = b2p[1] = r1.i[0];
46                b2p[2] = r1.i[1];
47                b2p[3] = r1.i[2];
48                b2p[4] = r1.i[3];
49                b2p[5] = b2p[6] = r2.i[0];
50                b2p[7] = r2.i[1];
51                b2p[8] = r2.i[2];
52                b2p[9] = r2.i[3];
53                b2p = b2p + pitch2;
54          }
55          dst = dst + 10;
56 //       b += 2;
57       }
58    } else {
59       for(xx = 0; xx < ww; xx += 8) {
60          b2p = (Uint32 *)dst;
61          r1 = *b++;
62          r2 = *b++;
63          // 76543210 -> 776655444332211000
64          // 76543210 -> 7654432100
65          for(yy = 0; yy < repeat - 1; yy++) {
66                b2p[0] = b2p[1] = r1.i[0];
67                b2p[2] = r1.i[1];
68                b2p[3] = r1.i[2];
69                b2p[4] = r1.i[3];
70                b2p[5] = b2p[6] = r2.i[0];
71                b2p[7] = r2.i[1];
72                b2p[8] = r2.i[2];
73                b2p[9] = r2.i[3];
74                b2p = b2p + pitch2;
75          }
76          b2p[0] = b2p[1] = b2p[2] = b2p[3] =
77          b2p[4] = b2p[5] = b2p[6] = b2p[7] =
78          b2p[8] = b2p[9] =
79            bb;
80          dst = dst + 10;
81 //       b += 2;
82       }
83    }
84    
85 }
86
87
88
89 void pVram2RGB_x125_Line(Uint32 *src, Uint8 *dst, int xbegin, int xend, int y, int yrep)
90 {
91    register v4hi *b;
92    AG_Surface *Surface = GetDrawSurface();
93    Uint32 *d1;
94    Uint32 *d2;
95    Uint32 *p;
96    int w;
97    int h;
98    int yy;
99    int xx;
100    int hh;
101    int ww;
102    int i;
103    int x = xbegin;
104    int yrep2;
105    unsigned  pitch;
106    Uint32 black;
107    if(Surface == NULL) return;
108    w = Surface->w;
109    h = Surface->h;
110
111
112    ww = xend - xbegin;
113 //   if(ww > (w / 2)) ww = w / 2;
114    ww = (ww / 8) * 8;
115    if(ww <= 0) return;
116
117
118 #if AG_BIG_ENDIAN != 1
119    black = 0xff000000;
120 #else
121    black = 0x000000ff;
122 #endif
123 //   yrep = yrep * 16.0f;
124
125    yrep2 = yrep;
126
127    d1 = (Uint32 *)((Uint8 *)dst + ((x * 10) / 8) * Surface->format->BytesPerPixel);
128    d2 = &src[x + y * 640];
129    Scaler_DrawLine(d1, (Uint32 *)d2, ww, yrep2, Surface->pitch);
130 //   AG_SurfaceUnlock(Surface);
131    return;
132 }
133
134