doWallpaper();
// End of startup. Lock the mutex and put the first view up
+// logger->log("Command", Log::DEBUG, "WANT LOCK");
#ifndef WIN32
pthread_mutex_lock(&masterLock);
#else
WaitForSingleObject(masterLock, INFINITE );
#endif
+ //logger->log("Command", Log::DEBUG, "LOCKED");
+
VConnect* vconnect = new VConnect();
viewman->add(vconnect);
vconnect->run();
while(irun)
{
// unlock and wait
+ //logger->log("Command", Log::DEBUG, "UNLOCK");
#ifndef WIN32
pthread_mutex_unlock(&masterLock);
#else
button = remote->getButtonPress(2); // FIXME why is this set to 2 and not 0? so it can quit
// something happened, lock and process
+ //logger->log("Command", Log::DEBUG, "WANT LOCK");
#ifndef WIN32
pthread_mutex_lock(&masterLock);
#else
WaitForSingleObject(masterLock, INFINITE );
#endif
+ //logger->log("Command", Log::DEBUG, "LOCK");
if ((button == Remote::NA_NONE) || (button == Remote::NA_UNKNOWN)) continue;
processMessageQueue();
}
+ //logger->log("Command", Log::DEBUG, "UNLOCK");
#ifndef WIN32
pthread_mutex_unlock(&masterLock);
#else
// locking the mutex ensures that the master thread is waiting on getButtonPress
+ //logger->log("Command", Log::DEBUG, "WANT LOCK");
#ifndef WIN32
pthread_mutex_lock(&masterLock);
#else
WaitForSingleObject(masterLock, INFINITE );
#endif
+ //logger->log("Command", Log::DEBUG, "LOCK");
MessageQueue::postMessage(m);
#ifndef WIN32
((RemoteWin*)Remote::getInstance())->Signal();
ReleaseMutex(masterLock);
#endif
+ //logger->log("Command", Log::DEBUG, "UNLOCK");
}
void Command::postMessageNoLock(Message* m)
// This is for the timers module
// If the masterlock is locked then the timers module wants to
// cancel delivery
+ //logger->log("Command", Log::DEBUG, "TRY LOCK");
#ifndef WIN32
if (pthread_mutex_trylock(&masterLock) != EBUSY)
{
+ //logger->log("Command", Log::DEBUG, "LOCK");
MessageQueue::postMessage(m);
kill(mainPid, SIGURG);
pthread_mutex_unlock(&masterLock);
+ //logger->log("Command", Log::DEBUG, "UNLOCK");
return true;
}
else
// deliver timer
- logger->log("Command", Log::DEBUG, "sending timer");
+ logger->log("Command", Log::DEBUG, "sending timer to %p with parameter %u", m->to, m->parameter);
((TimerReceiver*)m->to)->timercall(m->parameter);
// handleCommand(Remote::NA_NONE); // in case any timer has posted messages to viewman,
// // run viewman message queue here. FIXME improve this!
\r
Wwss::Wwss()\r
{\r
+ format = Video::NTSC;\r
}\r
\r
Wwss::~Wwss()\r
{\r
}\r
\r
+void Wwss::setFormat(UCHAR tformat)\r
+{\r
+ format = tformat;\r
+}\r
+\r
UINT Wwss::gcd(UINT a, UINT b)\r
{\r
UINT t;\r
}\r
\r
void Wwss::draw()\r
+{\r
+ if (format == Video::PAL) drawPAL();\r
+// else if (format == Video::NTSC) drawNTSC();\r
+}\r
+\r
+void Wwss::drawPAL()\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
drawPixel(q, 6, c);\r
}\r
}\r
+\r
+void Wwss::drawNTSC()\r
+{\r
+ static UCHAR startCode[] = {1,0};\r
+ static UCHAR aspect43[] = {0,0};\r
+ static UCHAR aspect169[] = {1,0};\r
+ static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0};\r
+ static UCHAR crc43[] = {0,0,0,0,0,0};\r
+ static UCHAR crc169[] = {1,0,0,1,0,1};\r
+\r
+ /*\r
+ Real NTSC pixel frequency: 13.5 MHz\r
+ WSS bit frequency: 447.443125 kHz\r
+ = 30.1714 NTSC pixels per wss bit\r
+ * 22 wss bits = 663.7715 NTSC pixels (total code width) (round to 664..)\r
+\r
+ There is also a 11.2us 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 = 22; // Num pix src\r
+ const UINT Nd = 664; // Num pix dst\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], startCode, 2);\r
+ if (wide) memcpy(&src[2], aspect169, 2);\r
+ else memcpy(&src[2], aspect43, 2);\r
+ memcpy(&src[4], theRest, 12);\r
+ if (wide) memcpy(&src[16], crc169, 6);\r
+ else memcpy(&src[16], crc43, 6);\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
+\r
+/*\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
+\r
+for(int yy = 0; yy < 100; yy++)\r
+{\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+20, yy, c);\r
+ }\r
+}\r
+\r
+\r
+\r
+}\r
+\r
+/*\r
+x6 + x + 1\r
+\r
+1x6 + 0x5 + 0x4 + 0x3 + 0x2 + 1x1 + 1x0\r
+=\r
+1 0 0 0 0 1 1\r
+=\r
+1000011\r
+key width = 6\r
+\r
+static UCHAR startCode[] = {1,0};\r
+static UCHAR aspect43[] = {0,0};\r
+static UCHAR aspect169[] = {1,0};\r
+static UCHAR theRest[] = {0,0,0,0,0,0,0,0,0,0,0,0};\r
+static UCHAR crc43[] = {0,0,0,0,0,0};\r
+static UCHAR crc169[] = {1,0,0,1,0,1};\r
+\r
+Message 4:3\r
+\r
+1000000000000000\r
+\r
+Message 4:3 augmented\r
+\r
+1000000000000000000000\r
+\r
+Key\r
+\r
+1000011\r
+\r
+\r
+Ho ho, polynomial long division. Yeeeeaaahhh I remember\r
+doing *that*. Of course I do. If you know of a faster,\r
+easier, more reliable way of doing this, please let me know.\r
+\r
+\r
+ 100\r
+ ________________________\r
+1000011 ) 1000000000000000000000\r
+ 1000011\r
+ -------\r
+ 0000110\r
+ 0000000\r
+ -------\r
+ 0001100\r
+\r
+\r
+\r
+\r
+\r
+\r
+Message 16:9\r
+\r
+1010000000000000\r
+\r
+Message 4:3 augmented\r
+\r
+1010000000000000000000\r
+\r
+Key\r
+\r
+1000011\r
+\r
+ 1010011110100011\r
+ ________________________\r
+1000011 ) 1010000000000000000000\r
+ 1000011\r
+ -------\r
+ 0100110\r
+ 0000000\r
+ -------\r
+ 1001100\r
+ 1000011\r
+ -------\r
+ 0011110\r
+ 0000000\r
+ -------\r
+ 0111100\r
+ 0000000\r
+ -------\r
+ 1111000\r
+ 1000011\r
+ -------\r
+ 1110110\r
+ 1000011\r
+ -------\r
+ 1101010\r
+ 1000011\r
+ -------\r
+ 1010010\r
+ 1000011\r
+ -------\r
+ 0100010\r
+ 0000000\r
+ -------\r
+ 1000100\r
+ 1000011\r
+ -------\r
+ 0001110\r
+ 0000000\r
+ -------\r
+ 0011100\r
+ 0000000\r
+ -------\r
+ 0111000\r
+ 0000000\r
+ -------\r
+ 1110000\r
+ 1000011\r
+ -------\r
+ 1100110\r
+ 1000011\r
+ -------\r
+ 100101\r
+*/\r