--- /dev/null
+/*\r
+ Copyright 2006 Chris Tallon\r
+\r
+ This file is part of VOMP.\r
+\r
+ VOMP is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ VOMP is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with VOMP; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+*/\r
+\r
+#include "wwss.h"\r
+\r
+Wwss::Wwss()\r
+{\r
+}\r
+\r
+Wwss::~Wwss()\r
+{\r
+}\r
+\r
+UINT Wwss::gcd(UINT a, UINT b)\r
+{\r
+ UINT t;\r
+ while (b != 0)\r
+ {\r
+ t = b;\r
+ b = a % b;\r
+ a = t;\r
+ }\r
+ return a;\r
+}\r
+\r
+UINT Wwss::lcm(UINT a, UINT b)\r
+{\r
+ return (a / gcd(a, b)) * b;\r
+}\r
+\r
+void Wwss::setWide(bool twide)\r
+{\r
+ wide = twide;\r
+}\r
+\r
+void Wwss::draw()\r
+{\r
+ // The aspect43 and aspect169 codes are not what they should be according to the docs, but these are what work...\r
+ // (1 = 111000, = 0 000111)\r
+ static UCHAR runIn[] = {1,1,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1}; // 29 pos 0\r
+ static UCHAR startCode[] = {0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,1,1}; // 24 pos 29\r
+ static UCHAR aspect43[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,1,1,1,0,0,0}; // = 0001 4:3 full frame // 24 pos 53\r
+ static UCHAR aspect169[] = {1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,1,1}; // = 1110 16:9 anamorphic // 24 pos 53\r
+ static UCHAR theRest[] = {0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1, // 60 pos 77\r
+ 0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,\r
+ 0,0,0,1,1,1,0,0,0,1,1,1};\r
+ /*\r
+ Real PAL pixel frequency: 13.5 MHz\r
+ WSS element frequency: 5 MHz\r
+ = 2.7 pal pixels per wss element\r
+ * 137 wss elements = 369.9 pal pixels (total code width) (round to 370..)\r
+\r
+ There is also a 11us gap at the start of the pal raster, but since I don't really have any\r
+ idea where our 720 pixels start in the raster I can't calculate an offset.\r
+\r
+ PAL line 23 seems to be MVP line 6.\r
+ */\r
+\r
+ const UINT Ns = 137; // Num pix src\r
+ const UINT Nd = 370; // Num pix dst 359->395 does something. not the right thing, but something.\r
+ UINT Nl = lcm(Ns, Nd); // Num pix in lcm\r
+ UINT Ss = Nl / Ns; // Source split (how many lcm px = 1 src px)\r
+ UINT Sd = Nl / Nd; // Dst split\r
+ UCHAR src[Ns];\r
+\r
+ memcpy(&src[0], runIn, 29);\r
+ memcpy(&src[29], startCode, 24);\r
+ if (wide) memcpy(&src[53], aspect169, 24);\r
+ else memcpy(&src[53], aspect43, 24);\r
+ memcpy(&src[77], theRest, 60);\r
+\r
+ float dst[Nd];\r
+ UINT lcmpxbase = 0;\r
+\r
+ for(UINT t = 0; t < Nd; t++) // for every destination pixel\r
+ {\r
+ dst[t] = 0;\r
+ for(UINT lcmpx = lcmpxbase; lcmpx < (lcmpxbase + Sd); lcmpx++)\r
+ {\r
+ if (src[lcmpx / Ss]) dst[t] += (float)1/Sd;\r
+ }\r
+ lcmpxbase += Sd;\r
+ }\r
+\r
+ Colour c;\r
+ UINT value;\r
+ for(UINT q = 0; q < Nd; q++)\r
+ {\r
+ value = (UINT)(dst[q] * 182); // Apparently this is a better number than 255 for the colour value\r
+ c.set(value, value, value);\r
+ drawPixel(q, 6, c);\r
+ }\r
+}\r