menu bg, pc linux build
[picodrive.git] / platform / s60 / S60v3video.inl
1 static int EmulateScanFull16(unsigned int scan,unsigned short *data)\r
2 {\r
3         unsigned short *ps=NULL,*end=NULL;\r
4         unsigned short *pd=NULL;\r
5         unsigned short *pdSrc1 = NULL;\r
6         unsigned short *pdSrc2 = NULL;\r
7         int screenScan;\r
8 \r
9         int index = 0;\r
10         int xpitch=0;\r
11         TInt retValue = 0;\r
12         if(scan<224)\r
13                 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
14         screenScan = gLineTable[scan];\r
15         \r
16         if ((int)screenScan< 0) return 0; // Out of range\r
17         if ((int)screenScan>=Targ.view.iBr.iY) return 0; // Out of range\r
18         \r
19         pd=(unsigned short*)(Targ.screen+screenScan*2+Targ.screen_offset);\r
20         pdSrc1 = pd;\r
21         \r
22         xpitch=-(Targ.scanline_length>>1);\r
23         if((Pico.video.reg[12]&1))\r
24         {\r
25                 ps=data; end=ps+320;\r
26                 do\r
27                 {\r
28                         if(gColumnStepTable[index]>1)\r
29                         {\r
30                                 *pd = gColorMapTab[*ps];\r
31                                 pd+=xpitch;\r
32                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);   \r
33                                 index++;\r
34                                 ps++;\r
35                         }\r
36                         else if(gColumnStepTable[index]>0)\r
37                         {\r
38                                 *pd = gColorMapTab[*ps];\r
39                                 index++;\r
40                                 ps++;                           \r
41                         }\r
42                         else\r
43                         {\r
44                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
45                                 ps+=2;\r
46                                 index+=2;\r
47                         }\r
48                         pd+=xpitch;\r
49                 }\r
50                 while (ps<end);\r
51         }\r
52         else\r
53         {\r
54                 ps=data+32; end=ps+256;\r
55                 \r
56                 // Reduce 10 pixels into 7\r
57                 do\r
58                 {\r
59                         if(gNarrowColumnStepTable[index]>1)\r
60                         {\r
61                                 *pd = gColorMapTab[*ps];\r
62                                 pd+=xpitch;\r
63                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);           \r
64                                 index++;\r
65                         }\r
66                         else if(gNarrowColumnStepTable[index]>0)\r
67                         {\r
68                                 *pd = gColorMapTab[*ps];\r
69                                 ps++;\r
70                                 index++;\r
71                         }\r
72                         else\r
73                         {\r
74                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
75                                 ps+=2;\r
76                                 index+=2;\r
77                         }\r
78                         pd+=xpitch;             \r
79                 }\r
80                 while (ps<end);         \r
81         }\r
82 \r
83         if(scan>0 && screenScan != gLineTable[scan-1]+1)\r
84                 {               \r
85                         pdSrc2 = pdSrc1-2;\r
86                         pd = pdSrc1-1;\r
87 \r
88                         for(TInt loop=0;loop<Targ.view.iBr.iY;loop++)\r
89                         {\r
90                                 *pd=((*pdSrc1+*pdSrc2)>>1);\r
91                                 pd+=xpitch;\r
92                                 pdSrc1+=xpitch;\r
93                                 pdSrc2+=xpitch;\r
94                         }\r
95                         \r
96                 }\r
97 \r
98         return retValue;\r
99 }\r
100 \r
101 static int EmulateScanFullRight16(unsigned int scan,unsigned short *data)\r
102 {\r
103         unsigned short *ps=NULL,*end=NULL;\r
104         unsigned short *pd=NULL;\r
105         unsigned short *pdSrc1 = NULL;\r
106         unsigned short *pdSrc2 = NULL;\r
107         int screenScan;\r
108         int xpitch=0;\r
109         int retValue = 0;\r
110         int index = 0;\r
111         if(scan<224)\r
112                 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
113         screenScan = gLineTable[scan];\r
114 \r
115         if ((int)screenScan< 0) return 0; // Out of range\r
116         if ((int)screenScan>=Targ.view.iBr.iY) return 0; // Out of range\r
117         \r
118         pd=(unsigned short*)(Targ.screen+Targ.scanline_length-screenScan*2);\r
119         pdSrc1 = pd;\r
120         \r
121         xpitch=+(Targ.scanline_length>>1);\r
122         if((Pico.video.reg[12]&1))\r
123         {\r
124                 ps=data; end=ps+320;\r
125                 do\r
126                 {\r
127                         if(gColumnStepTable[index]>1)\r
128                         {\r
129                                 *pd = gColorMapTab[*ps];\r
130                                 pd+=xpitch;\r
131                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);   \r
132                                 index++;\r
133                                 ps++;\r
134                         }\r
135                         else if(gColumnStepTable[index]>0)\r
136                         {\r
137                                 *pd = gColorMapTab[*ps];\r
138                                 index++;\r
139                                 ps++;                           \r
140                         }\r
141                         else\r
142                         {\r
143                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
144                                 ps+=2;\r
145                                 index+=2;\r
146                         }\r
147                         pd+=xpitch;\r
148                 }\r
149                 while (ps<end);\r
150         }\r
151         else\r
152         {\r
153                 ps=data+32; end=ps+256;\r
154                 \r
155                 // Reduce 10 pixels into 7\r
156                 do\r
157                 {\r
158                         if(gNarrowColumnStepTable[index]>1)\r
159                         {\r
160                                 *pd = gColorMapTab[*ps];\r
161                                 pd+=xpitch;\r
162                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);           \r
163                                 index++;\r
164                         }\r
165                         else if(gNarrowColumnStepTable[index]>0)\r
166                         {\r
167                                 *pd = gColorMapTab[*ps];\r
168                                 ps++;\r
169                                 index++;\r
170                         }\r
171                         else\r
172                         {\r
173                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
174                                 ps+=2;\r
175                                 index+=2;\r
176                         }\r
177                         pd+=xpitch;             \r
178                 }\r
179                 while (ps<end);         \r
180         }\r
181 \r
182         if(scan>0 && screenScan != gLineTable[scan-1]+1)\r
183                 {               \r
184                         pdSrc2 = pdSrc1+2;\r
185                         pd = pdSrc1+1;\r
186 \r
187                         for(TInt loop=0;loop<Targ.view.iBr.iY;loop++)\r
188                         {\r
189                                 *pd=((*pdSrc1+*pdSrc2)>>1);\r
190                                 pd+=xpitch;\r
191                                 pdSrc1+=xpitch;\r
192                                 pdSrc2+=xpitch;\r
193                         }\r
194                         \r
195                 }\r
196         \r
197         return retValue;\r
198 }\r
199 \r
200 \r
201 \r
202 static int EmulateScan16(unsigned int scan,unsigned short *data)\r
203 {\r
204         //  int len=0;\r
205         unsigned short *ps=NULL,*end=NULL;\r
206         unsigned short *pd=NULL;\r
207         int xpitch=0;\r
208         int retValue = 0;\r
209         int index = 0;\r
210 \r
211         if(scan<224)\r
212                 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
213         scan = gLineTable[scan];\r
214         \r
215         if ((int)scan< 0) return 0; // Out of range\r
216         if ((int)scan>=Targ.view.iBr.iY) return 0; // Out of range\r
217         \r
218         pd=(unsigned short*)(Targ.screen+scan*Targ.scanline_length);\r
219         \r
220         xpitch=2;\r
221         if((Pico.video.reg[12]&1))\r
222         {\r
223                 ps=data; end=ps+320;\r
224                 do\r
225                 {\r
226                         if(gColumnStepTable[index]>0)\r
227                         {\r
228                         *pd = gColorMapTab[*ps];\r
229                         ps++;\r
230                 \r
231                         index++;\r
232                         }\r
233                         else\r
234                         {\r
235                         *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
236                         ps+=2;\r
237                         index+=2;\r
238                         }\r
239                         pd++;\r
240                 \r
241                 }\r
242                 while (ps<end);\r
243         } \r
244         else\r
245         {\r
246                 ps=data+32; end=ps+256;\r
247                 // Reduce 10 pixels into 7\r
248                 do\r
249                 {\r
250                         if(gNarrowColumnStepTable[index]>0)\r
251                         {\r
252                                 *pd = gColorMapTab[*ps];\r
253                                 ps++;\r
254                                 index++;\r
255                         }\r
256                         else\r
257                         {\r
258                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
259                                 ps+=2;\r
260                                 index+=2;\r
261                         }\r
262                         pd++;           \r
263                 }\r
264                 while (ps<end);\r
265         \r
266         }\r
267         \r
268         return retValue;\r
269 }\r
270 \r
271 static int EmulateStretchScan16(unsigned int scan,unsigned short *data)\r
272 {\r
273         unsigned short *ps=NULL,*end=NULL;\r
274         unsigned short *pd=NULL;\r
275         unsigned short *pdSrc1 = NULL;\r
276         unsigned short *pdSrc2 = NULL;\r
277 \r
278         int retValue = 0;\r
279         int index = 0;\r
280         int screenScan;\r
281         if(scan<224)\r
282                 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
283         screenScan = gLineTable[scan];\r
284 \r
285         if ((int)screenScan<0) \r
286                 return 0; // Out of range\r
287         if ((int)screenScan>=Targ.view.iBr.iY) \r
288                 return 0; // Out of range\r
289         \r
290         pd=(unsigned short*)(Targ.screen+screenScan*Targ.scanline_length);\r
291         pdSrc1 = pd;\r
292 \r
293         if((Pico.video.reg[12]&1))\r
294         {\r
295                 ps=data; end=ps+320;            \r
296                 do\r
297                 {\r
298                         if(gColumnStepTable[index]>1)\r
299                         {\r
300                                 *pd = gColorMapTab[*ps];\r
301                                 pd++;\r
302                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);   \r
303                                 index++;\r
304                                 ps++;\r
305                         }\r
306                         else if(gColumnStepTable[index]>0)\r
307                         {\r
308                                 *pd = gColorMapTab[*ps];\r
309                                 index++;\r
310                                 ps++;                           \r
311                         }\r
312                         else\r
313                         {\r
314                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
315                                 ps+=2;\r
316                                 index+=2;\r
317                         }\r
318                         pd++;\r
319                 }\r
320                 while (ps<end);\r
321 \r
322                 \r
323         \r
324         }\r
325         else\r
326         {\r
327                 ps=data+32; end=ps+256;\r
328                 // Reduce 10 pixels into 7\r
329                 do\r
330                 {\r
331                         if(gNarrowColumnStepTable[index]>1)\r
332                         {\r
333                                 *pd = gColorMapTab[*ps];\r
334                                 pd++;\r
335                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);           \r
336                                 index++;\r
337                         }\r
338                         else if(gNarrowColumnStepTable[index]>0)\r
339                         {\r
340                                 *pd = gColorMapTab[*ps];\r
341                                 ps++;\r
342                                 index++;\r
343                         }\r
344                         else\r
345                         {\r
346                                 *pd = ((gColorMapTab[*ps]+gColorMapTab[*(ps+1)])>>1);\r
347                                 ps+=2;\r
348                                 index+=2;\r
349                         }\r
350                         pd++;           \r
351                 }\r
352                 while (ps<end);         \r
353         }\r
354 \r
355         if(scan>0 && screenScan != gLineTable[scan-1]+1)\r
356                 {               \r
357                         pdSrc2 = pdSrc1-Targ.scanline_length;\r
358                         pd = pdSrc1-(Targ.scanline_length>>1);\r
359 \r
360                         for(TInt loop=0;loop<Targ.view.iBr.iX;loop++)\r
361                         {\r
362                                 *pd=((*pdSrc1+*pdSrc2)>>1);\r
363                                 pd++;\r
364                                 pdSrc1++;\r
365                                 pdSrc2++;\r
366                         }\r
367                         \r
368                 }\r
369         \r
370         return retValue;\r
371 }\r