Commit 7d6679e9 authored by Jan Möbius's avatar Jan Möbius
Browse files

64 bit compatible crc and working header rendering

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7487 383ad7c9-94d9-4d36-a494-682f7c89f535
parent acfc46b9
......@@ -293,7 +293,7 @@ glViewer::drawScenePhilipsStereo()
glstate_->reset_projection();
glstate_->reset_modelview();
glstate_->ortho(0, 10, 0, 10, 0, 1);
glstate_->ortho(0, glWidth(), 0, glHeight(), 0, 1);
// ======================================================================================================
......@@ -311,9 +311,9 @@ glViewer::drawScenePhilipsStereo()
// Render a simple quad (rest is done by shader)
// ======================================================================================================
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 1.0f); glVertex2i( 0, 10);
glTexCoord2f(1.0f, 1.0f); glVertex2i( 10, 10);
glTexCoord2f(1.0f, 0.0f); glVertex2i( 10, 0);
glTexCoord2f(0.0f, 1.0f); glVertex2i( 0, glHeight());
glTexCoord2f(1.0f, 1.0f); glVertex2i( glWidth(), glHeight());
glTexCoord2f(1.0f, 0.0f); glVertex2i( glWidth(), 0);
glTexCoord2f(0.0f, 0.0f); glVertex2i( 0, 0);
glEnd();
......@@ -328,43 +328,72 @@ glViewer::drawScenePhilipsStereo()
colorTexture.del();
// ======================================================================================================
// Reset projection and modelview
// ======================================================================================================
glstate_->pop_projection_matrix();
glstate_->pop_modelview_matrix();
// Compute the header required for the display
// ======================================================================================================
uchar *header = new uchar[ 6 ];
header[0] = 241; // Header_ID1 = 11110001
header[1] = 3; // Hdr_Content_type (Game) = 00000011
header[1] = 3; // Hdr_Content_type (Game) = 00000011 (Gaming Mode)
header[2] = 64; // Hdr_Factor
header[3] = 128; // Hdr_Offset_CC
header[4] = 0; // Hdr_Factor_select(1) + Hdr_Offset_select(1) + reserved(6)
header[5] = 0; // Reserved
//unsigned long has 32bit = 4Byte
unsigned long checksum = CalcCRC32(header, 6);
unsigned long checksum = CalcCRC32(&header[0], 6);
std::vector< uchar > bitVector;
// for (uint i=1; i <= 6*8; i++)
// bitVector.push_back( header & (1 << i );
//
// for (uint i=1; i <= 32; i++)
// bitVector.push_back( checksum & (1 << i );
// For all bytes of the header
for (int i = 0; i < 6; i++) {
// for each bit of a headers byte
for ( int j = 7 ; j >= 0 ; --j ) {
bitVector.push_back(0);
bitVector.push_back(0);
// If bit is set, the full component will be set to one otherwise zero
if ( header[i] & (1 << j ) ) {
bitVector.push_back(255);
} else {
bitVector.push_back(0);
}
bitVector.push_back(0);
bitVector.push_back(0);
bitVector.push_back(0);
}
}
// Append checksum to header.
for (int i=31; i >= 0; i--) {
bitVector.push_back(0);
bitVector.push_back(0);
if ( checksum & (1 << i ) )
bitVector.push_back( 255 );
else
bitVector.push_back( 0 );
bitVector.push_back(0);
bitVector.push_back(0);
bitVector.push_back(0);
}
//render the header
glBegin(GL_POINTS);
{
// header is 10 bytes long = 80bit
// one bit is stored per blue Color
for (uint i=0; i < 80; i++){
glColor3b(0,0,bitVector[i] * 255);
glVertex2i( 2*i, 0);
}
}
glRasterPos2i (0,glHeight()-1);
glDrawPixels(bitVector.size()/3, 1,GL_RGB ,GL_UNSIGNED_BYTE , &bitVector[0]);
// ======================================================================================================
// Reset projection and modelview
// ======================================================================================================
glstate_->pop_projection_matrix();
glstate_->pop_modelview_matrix();
}
......
......@@ -33,6 +33,8 @@
#include "crc32.hh"
#include <iostream>
/*****************************************************************/
/* */
/* CRC LOOKUP TABLE */
......@@ -150,7 +152,7 @@ unsigned long crctable[256] =
unsigned long CalcCRC32(unsigned char *p, unsigned long len)
{
unsigned long i;
unsigned long crc = 0;
unsigned int crc = 0;
/* process each byte prior to checksum field */
for (i = 0; i < len; i++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment