Sonic CD shows it's title screen
[picodrive.git] / platform / s60 / interpolatevideo.inl
... / ...
CommitLineData
1static int EmulateScanFull16_176Interpolate(unsigned int scan,unsigned short *data)\r
2{\r
3 unsigned short *ps=NULL,*end=NULL;\r
4 unsigned char *pd=NULL;\r
5 int xpitch=0;\r
6 TInt retValue = 0;\r
7 if(scan<224)\r
8 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
9 scan = gLineTable[scan];\r
10 \r
11 if ((int)scan< 0) return 0; // Out of range\r
12 if ((int)scan>=176) return 0; // Out of range\r
13 \r
14 pd=Targ.screen+gLineOffsets[scan];//Targ.screen+scan*2+Targ.screen_offset+8;\r
15 \r
16 xpitch=-Targ.scanline_length;\r
17 if((Pico.video.reg[12]&1))\r
18 {\r
19 ps=data; end=ps+320;\r
20 // Reduce 14 pixels into 9\r
21 do\r
22 {\r
23 *(unsigned short *)pd=gColorMapTab[ps[0]];pd+=xpitch;\r
24 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[1]]+gColorMapTab[ps[2]])>>1);pd+=xpitch;\r
25 *(unsigned short *)pd=gColorMapTab[ps[3]];pd+=xpitch;\r
26 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[4]]+gColorMapTab[ps[5]])>>1);pd+=xpitch;\r
27 *(unsigned short *)pd=gColorMapTab[ps[6]];pd+=xpitch;\r
28 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[7]]+gColorMapTab[ps[8]])>>1);pd+=xpitch;\r
29 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[9]]+gColorMapTab[ps[10]])>>1);pd+=xpitch;\r
30 *(unsigned short *)pd=gColorMapTab[ps[11]];pd+=xpitch;\r
31 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[12]]+gColorMapTab[ps[13]])>>1);pd+=xpitch;\r
32 ps+=14;\r
33 }\r
34 while (ps<end);\r
35 }\r
36 else\r
37 {\r
38 ps=data+32; end=ps+256;\r
39 \r
40 // Reduce 5 pixels into 4\r
41 do\r
42 {\r
43 *(unsigned short *)pd=gColorMapTab[ps[0]];pd+=xpitch;\r
44 *(unsigned short *)pd=gColorMapTab[ps[1]];pd+=xpitch;\r
45 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[2]]+gColorMapTab[ps[3]])>>1);pd+=xpitch;\r
46 *(unsigned short *)pd=gColorMapTab[ps[4]];pd+=xpitch;\r
47 ps+=5;\r
48 }\r
49 while (ps<end);\r
50 }\r
51 return retValue;\r
52}\r
53\r
54static int EmulateScanFullRight16_176Interpolate(unsigned int scan,unsigned short *data)\r
55{\r
56 unsigned short *ps=NULL,*end=NULL;\r
57 unsigned char *pd=NULL;\r
58 int xpitch=0;\r
59 int retValue = 0;\r
60 if(scan<224)\r
61 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
62 scan = gLineTable[scan];\r
63\r
64 if ((int)scan< 0) return 0; // Out of range\r
65 if ((int)scan>=176) return 0; // Out of range\r
66 \r
67 pd=Targ.screen+gLineOffsets[scan];//Targ.screen+Targ.scanline_length-scan*2-8;\r
68 \r
69 xpitch=+Targ.scanline_length;\r
70 if((Pico.video.reg[12]&1))\r
71 {\r
72 ps=data; end=ps+320;\r
73 // Reduce 14 pixels into 9\r
74 do\r
75 {\r
76 *(unsigned short *)pd=gColorMapTab[ps[0]];pd+=xpitch;\r
77 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[1]]+gColorMapTab[ps[2]])>>1);pd+=xpitch;\r
78 *(unsigned short *)pd=gColorMapTab[ps[3]];pd+=xpitch;\r
79 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[4]]+gColorMapTab[ps[5]])>>1);pd+=xpitch;\r
80 *(unsigned short *)pd=gColorMapTab[ps[6]];pd+=xpitch;\r
81 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[7]]+gColorMapTab[ps[8]])>>1);pd+=xpitch;\r
82 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[9]]+gColorMapTab[ps[10]])>>1);pd+=xpitch;\r
83 *(unsigned short *)pd=gColorMapTab[ps[11]];pd+=xpitch;\r
84 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[12]]+gColorMapTab[ps[13]])>>1);pd+=xpitch;\r
85 ps+=14;\r
86 }\r
87 while (ps<end);\r
88 }\r
89 else\r
90 {\r
91 ps=data+32; end=ps+256;\r
92 // Reduce 5 pixels into 4\r
93 do\r
94 {\r
95 *(unsigned short *)pd=gColorMapTab[ps[0]];pd+=xpitch;\r
96 *(unsigned short *)pd=gColorMapTab[ps[1]];pd+=xpitch;\r
97 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[2]]+gColorMapTab[ps[3]])>>1);pd+=xpitch;\r
98 *(unsigned short *)pd=gColorMapTab[ps[4]];pd+=xpitch;\r
99 ps+=5;\r
100 }\r
101 while (ps<end);\r
102 }\r
103 \r
104 return retValue;\r
105}\r
106\r
107\r
108\r
109static int EmulateScan16_176Interpolate(unsigned int scan,unsigned short *data)\r
110{\r
111 unsigned short *ps=NULL,*end=NULL;\r
112 unsigned char *pd=NULL;\r
113 int xpitch=0;\r
114 int retValue = 0;\r
115 if(scan<224)\r
116 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
117 scan = gLineTable[scan];\r
118 \r
119 if ((int)scan< 0) return 0; // Out of range\r
120 if ((int)scan>=176) return 0; // Out of range\r
121 \r
122 pd=Targ.screen+gLineOffsets[scan];//Targ.screen+scan*Targ.scanline_length;\r
123 \r
124 xpitch=2;\r
125 if((Pico.video.reg[12]&1))\r
126 {\r
127 ps=data; end=ps+320;\r
128 // Reduce 9 pixels into 5\r
129 do\r
130 {\r
131 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[0]]+gColorMapTab[ps[1]])>>1);pd+=xpitch;\r
132 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[2]]+gColorMapTab[ps[3]])>>1);pd+=xpitch;\r
133 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[4]]+gColorMapTab[ps[5]])>>1);pd+=xpitch;\r
134 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[6]]+gColorMapTab[ps[7]])>>1);pd+=xpitch;\r
135 *(unsigned short *)pd=gColorMapTab[ps[8]];pd+=xpitch;\r
136 ps+=9;\r
137 }\r
138 while (ps<end);\r
139 } \r
140 else\r
141 {\r
142 ps=data+32; end=ps+256;\r
143 // Reduce 10 pixels into 7\r
144 do\r
145 {\r
146 *(unsigned short *)pd=gColorMapTab[ps[0]];pd+=xpitch;\r
147 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[1]]+gColorMapTab[ps[2]])>>1);pd+=xpitch;\r
148 *(unsigned short *)pd=gColorMapTab[ps[3]];pd+=xpitch;\r
149 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[4]]+gColorMapTab[ps[5]])>>1);pd+=xpitch;\r
150 *(unsigned short *)pd=gColorMapTab[ps[6]];pd+=xpitch;\r
151 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[7]]+gColorMapTab[ps[8]])>>1);pd+=xpitch; \r
152 *(unsigned short *)pd=gColorMapTab[ps[9]];pd+=xpitch;\r
153 ps+=10;\r
154 }\r
155 while (ps<end); \r
156 }\r
157 \r
158 return retValue;\r
159}\r
160\r
161static int EmulateStretchScan16_176Interpolate(unsigned int scan,unsigned short *data)\r
162{\r
163 unsigned short *ps=NULL,*end=NULL;\r
164 unsigned char *pd=NULL;\r
165 int xpitch=0;\r
166 int retValue = 0;\r
167 if(scan<224)\r
168 retValue = 1-(gLineTable[scan+1]-gLineTable[scan]);\r
169 scan = gLineTable[scan];\r
170\r
171 if ((int)scan<0) \r
172 return 0; // Out of range\r
173 if ((int)scan>=208) \r
174 return 0; // Out of range\r
175 \r
176 pd=Targ.screen+gLineOffsets[scan];//Targ.screen+scan*Targ.scanline_length;\r
177 \r
178 xpitch=2;\r
179 if((Pico.video.reg[12]&1))\r
180 {\r
181 ps=data; end=ps+320;\r
182 // Reduce 9 pixels into 5\r
183 do\r
184 {\r
185 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[0]]+gColorMapTab[ps[1]])>>1);pd+=xpitch;\r
186 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[2]]+gColorMapTab[ps[3]])>>1);pd+=xpitch;\r
187 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[4]]+gColorMapTab[ps[5]])>>1);pd+=xpitch;\r
188 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[6]]+gColorMapTab[ps[7]])>>1);pd+=xpitch;\r
189 *(unsigned short *)pd=gColorMapTab[ps[8]];pd+=xpitch;\r
190 ps+=9;\r
191 }\r
192 while (ps<end);\r
193 }\r
194 else\r
195 {\r
196 ps=data+32; end=ps+256;\r
197 // Reduce 10 pixels into 7\r
198 do\r
199 {\r
200 *(unsigned short *)pd=gColorMapTab[ps[0]];pd+=xpitch;\r
201 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[1]]+gColorMapTab[ps[2]])>>1);pd+=xpitch;\r
202 *(unsigned short *)pd=gColorMapTab[ps[3]];pd+=xpitch;\r
203 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[4]]+gColorMapTab[ps[5]])>>1);pd+=xpitch;\r
204 *(unsigned short *)pd=gColorMapTab[ps[6]];pd+=xpitch;\r
205 *(unsigned short *)pd=(unsigned short)((gColorMapTab[ps[7]]+gColorMapTab[ps[8]])>>1);pd+=xpitch; \r
206 *(unsigned short *)pd=gColorMapTab[ps[9]];pd+=xpitch;\r
207 ps+=10;\r
208 }\r
209 while (ps<end); \r
210 }\r
211 \r
212 return retValue;\r
213}\r