license info added to Pico directory
[cyclone68000.git] / Pico / Utils.cpp
CommitLineData
15eb0001 1\r
4abeeb4b 2// This file is part of the PicoDrive Megadrive Emulator\r
3\r
4// This code is licensed under the GNU General Public License version 2.0 and the MAME License.\r
5// You can choose the license that has the most advantages for you.\r
6\r
7// SVN repository can be found at http://code.google.com/p/cyclone68000/\r
8\r
15eb0001 9#include "PicoInt.h"\r
10\r
11int PicuAnd=0xf7de;\r
12\r
13// Quick low-quality conversion of 320 to 176:\r
14int PicuQuick(unsigned short *dest,unsigned short *src)\r
15{\r
16 unsigned short *end=NULL;\r
17\r
18 src+=13; end=src+290;\r
19 dest++;\r
20\r
21 do\r
22 {\r
23 *dest++=*src++;\r
24 *dest++=*src; src+=2;\r
25 *dest++=*src; src+=2;\r
26 *dest++=*src++;\r
27 *dest++=*src; src+=2;\r
28 *dest++=*src; src+=2;\r
29 }\r
30 while (src<end);\r
31\r
32 return 0;\r
33}\r
34\r
35// Shrink the pixels in src/srcLen, to the screen line pointed to by dest/destLen\r
36int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen)\r
37{\r
38 unsigned short *end=NULL;\r
39 int bias=0,pa=0,sub=0;\r
40\r
41 end=dest+destLen;\r
42 sub=srcLen-destLen;\r
43\r
44 do\r
45 {\r
46 pa=*src++; bias-=sub;\r
47 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
48 *dest++=(unsigned short)pa;\r
49\r
50 pa=*src++; bias-=sub;\r
51 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
52 *dest++=(unsigned short)pa;\r
53 }\r
54 while (dest<end);\r
55 \r
56 return 0;\r
57}\r
58\r
59int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen)\r
60{\r
61 unsigned short *end=NULL;\r
62 int bias=0,pa=0,mask=PicuAnd,sub=0;\r
63\r
64 end=dest+destLen;\r
65 sub=srcLen-destLen;\r
66\r
67 do\r
68 {\r
69 pa=*src++; bias-=sub;\r
70 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
71 pa&=mask; pa+=(*dest)&mask; pa>>=1;\r
72 *dest++=(unsigned short)pa;\r
73\r
74 pa=*src++; bias-=sub;\r
75 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
76 pa&=mask; pa+=(*dest)&mask; pa>>=1;\r
77 *dest++=(unsigned short)pa;\r
78 }\r
79 while (dest<end);\r
80 \r
81 return 0;\r
82}\r
83\r