User:Steven/flip frame decode.c: Difference between revisions

Steven (talk | contribs)
New page: Please note that there is very little comments and this application just outputs to the text console at the moment, but the code used here can be expanded to produce any other image file f...
 
Endres (talk | contribs)
GCC gave me errors which were caused by "wise" M$ thinking that typecast isn't neccessary :(
 
(2 intermediate revisions by one other user not shown)
Line 99: Line 99:
{
{
     printf( "Magic Number    : %c%c%c%c\n", ptr->magic[0], ptr->magic[1], ptr->magic[2], ptr->magic[3] );
     printf( "Magic Number    : %c%c%c%c\n", ptr->magic[0], ptr->magic[1], ptr->magic[2], ptr->magic[3] );
     printf( "File Size      : %d (%08X)\n", ptr->fileSize, ptr->fileSize );
     printf( "File Size      : %d (%08X)\n", (int)ptr->fileSize, (unsigned int)ptr->fileSize );
     printf( "Audio offset    : %d (%08X)\n", ptr->audioOffset, ptr->audioOffset );
     printf( "Audio offset    : %d (%08X)\n", (int)ptr->audioOffset, (unsigned int)ptr->audioOffset );
     printf( "# Frames        : %d\n", ptr->numberOfFrames );
     printf( "# Frames        : %d\n", ptr->numberOfFrames );
     printf( "Unknown        : 0x%04X\n", ptr->unk0 );
     printf( "Unknown        : 0x%04X\n", ptr->unk0 );
Line 237: Line 237:
if( buf == NULL )
if( buf == NULL )
{
{
printf( "Error unable to allocate buffer for frame %d\n", frmBuf );
printf( "Error unable to allocate buffer for frame %d\n", (int)frmBuf );
return;
return;
}
}
Line 243: Line 243:
frmOffset = getFrameOffset( frmBuf, 1 );
frmOffset = getFrameOffset( frmBuf, 1 );


printf( "Frame #%d offset %08X\n", frmNum, frmOffset );
printf( "Frame #%d offset %08X\n", frmNum, (unsigned int)frmOffset );


colPaper  = frmBuf[ frmOffset ] & 0x01;
colPaper  = frmBuf[ frmOffset ] & 0x01;
Line 294: Line 294:
case 0: // Skip this line
case 0: // Skip this line
byteUse = 0;
byteUse = 0;
printf( "Line %3d(%04X), Layer 1, Skip Frame [%08X]\toffset %08X\n", lnePos, lnePos, byteUse, frmOffset + 0x6a0 );
printf( "Line %3d(%04X), Layer 1, Skip Frame [%08X]\toffset %08X\n", lnePos, lnePos, (unsigned int)byteUse, (unsigned int)frmOffset + 0x6a0 );
break;
break;
case 1: // Coded
case 1: // Coded
byteUse = getu32inv( &frmBuf[ frmOffset ] );
byteUse = getu32inv( &frmBuf[ frmOffset ] );
printf( "Line %3d(%04X), Layer 1, Coded      [%08X]\toffset %08X\n", lnePos, lnePos, byteUse, frmOffset + 0x6a0 );
printf( "Line %3d(%04X), Layer 1, Coded      [%08X]\toffset %08X\n", lnePos, lnePos, (unsigned int)byteUse, (unsigned int)frmOffset + 0x6a0 );
frmOffset += 4;
frmOffset += 4;
frmOffset += decodeLine( &buf[ lnePos << 8 ], &frmBuf[ frmOffset ], byteUse, outFrameG[ 0 ], outFrameG[ colLayer1 ], 0 );
frmOffset += decodeLine( &buf[ lnePos << 8 ], &frmBuf[ frmOffset ], byteUse, outFrameG[ 0 ], outFrameG[ colLayer1 ], 0 );
Line 304: Line 304:
case 2: // Inv Coded
case 2: // Inv Coded
byteUse = getu32inv( &frmBuf[ frmOffset ] );
byteUse = getu32inv( &frmBuf[ frmOffset ] );
printf( "Line %3d(%04X), Layer 1, Inv Coded  [%08X]\toffset %08X\n", lnePos, lnePos, byteUse, frmOffset + 0x6a0 );
printf( "Line %3d(%04X), Layer 1, Inv Coded  [%08X]\toffset %08X\n", lnePos, lnePos, (unsigned int)byteUse, (unsigned int)frmOffset + 0x6a0 );
frmOffset += 4;
frmOffset += 4;
frmOffset += decodeLine( &buf[ lnePos << 8 ], &frmBuf[ frmOffset ], byteUse, outFrameG[ colLayer1 ], outFrameG[ 0 ], 1 );
frmOffset += decodeLine( &buf[ lnePos << 8 ], &frmBuf[ frmOffset ], byteUse, outFrameG[ colLayer1 ], outFrameG[ 0 ], 1 );
Line 310: Line 310:
case 3: // Full Line
case 3: // Full Line
byteUse = 0xFFFFFFFF;
byteUse = 0xFFFFFFFF;
printf( "Line %3d(%04X), Layer 1, Full Frame [%08X]\toffset %08X\n", lnePos, lnePos, byteUse, frmOffset + 0x6a0 );
printf( "Line %3d(%04X), Layer 1, Full Frame [%08X]\toffset %08X\n", lnePos, lnePos, (unsigned int)byteUse, (unsigned int)frmOffset + 0x6a0 );
frmOffset += decodeLine( &buf[ lnePos << 8 ], &frmBuf[ frmOffset ], byteUse, outFrameG[ 0 ], outFrameG[ colLayer1 ], 0 );
frmOffset += decodeLine( &buf[ lnePos << 8 ], &frmBuf[ frmOffset ], byteUse, outFrameG[ 0 ], outFrameG[ colLayer1 ], 0 );
break;
break;