license info at top of Cyclone source files
[cyclone68000.git] / Pico / Utils.cpp
CommitLineData
15eb0001 1\r
2#include "PicoInt.h"\r
3\r
4int PicuAnd=0xf7de;\r
5\r
6// Quick low-quality conversion of 320 to 176:\r
7int PicuQuick(unsigned short *dest,unsigned short *src)\r
8{\r
9 unsigned short *end=NULL;\r
10\r
11 src+=13; end=src+290;\r
12 dest++;\r
13\r
14 do\r
15 {\r
16 *dest++=*src++;\r
17 *dest++=*src; src+=2;\r
18 *dest++=*src; src+=2;\r
19 *dest++=*src++;\r
20 *dest++=*src; src+=2;\r
21 *dest++=*src; src+=2;\r
22 }\r
23 while (src<end);\r
24\r
25 return 0;\r
26}\r
27\r
28// Shrink the pixels in src/srcLen, to the screen line pointed to by dest/destLen\r
29int PicuShrink(unsigned short *dest,int destLen,unsigned short *src,int srcLen)\r
30{\r
31 unsigned short *end=NULL;\r
32 int bias=0,pa=0,sub=0;\r
33\r
34 end=dest+destLen;\r
35 sub=srcLen-destLen;\r
36\r
37 do\r
38 {\r
39 pa=*src++; bias-=sub;\r
40 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
41 *dest++=(unsigned short)pa;\r
42\r
43 pa=*src++; bias-=sub;\r
44 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
45 *dest++=(unsigned short)pa;\r
46 }\r
47 while (dest<end);\r
48 \r
49 return 0;\r
50}\r
51\r
52int PicuMerge(unsigned short *dest,int destLen,unsigned short *src,int srcLen)\r
53{\r
54 unsigned short *end=NULL;\r
55 int bias=0,pa=0,mask=PicuAnd,sub=0;\r
56\r
57 end=dest+destLen;\r
58 sub=srcLen-destLen;\r
59\r
60 do\r
61 {\r
62 pa=*src++; bias-=sub;\r
63 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
64 pa&=mask; pa+=(*dest)&mask; pa>>=1;\r
65 *dest++=(unsigned short)pa;\r
66\r
67 pa=*src++; bias-=sub;\r
68 if (bias<0) { pa+=*src++; pa>>=1; bias+=destLen; }\r
69 pa&=mask; pa+=(*dest)&mask; pa>>=1;\r
70 *dest++=(unsigned short)pa;\r
71 }\r
72 while (dest<end);\r
73 \r
74 return 0;\r
75}\r
76\r