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