annotate temp-c-stuff @ 487:09df21060be6

merge
author Robert McIntyre <rlm@mit.edu>
date Mon, 07 May 2012 11:15:49 -0500
parents cd6a96a07d2e
children
rev   line source
rlm@485 1 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rlm@485 2
rlm@485 3
rlm@485 4 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rlm@485 5
rlm@485 6
rlm@485 7 // This section of code is used to convert an RGB (pc) triplet into a RGB (gameboy)
rlm@485 8 // triplet. This section of code was kindly donated by Brett Bibby (GameBrains).
rlm@485 9
rlm@485 10 BYTE intensity[32] =
rlm@485 11 {
rlm@485 12 0x00,0x10,0x20,0x30,0x40,0x50,0x5e,0x6c,0x7a,0x88,0x94,0xa0,0xae,0xb7,0xbf,0xc6,
rlm@485 13 0xce,0xd3,0xd9,0xdf,0xe3,0xe7,0xeb,0xef,0xf3,0xf6,0xf9,0xfb,0xfd,0xfe,0xff,0xff
rlm@485 14 };
rlm@485 15
rlm@485 16 unsigned char influence[3][3] =
rlm@485 17 {
rlm@485 18 {16,4,4},
rlm@485 19 {8,16,8},
rlm@485 20 {0,8,16}
rlm@485 21 };
rlm@485 22
rlm@485 23 RGBQUAD translate(BYTE rgb[3])
rlm@485 24 {
rlm@485 25 RGBQUAD color;
rlm@485 26 BYTE tmp[3];
rlm@485 27 BYTE m[3][3];
rlm@485 28 BYTE i,j;
rlm@485 29
rlm@485 30 for (i=0;i<3;i++)
rlm@485 31 for (j=0;j<3;j++)
rlm@485 32 m[i][j] = (intensity[rgb[i]>>3]*influence[i][j]) >> 5;
rlm@485 33
rlm@485 34 for (i=0;i<3;i++)
rlm@485 35 {
rlm@485 36 if (m[0][i]>m[1][i])
rlm@485 37 {
rlm@485 38 j=m[0][i];
rlm@485 39 m[0][i]=m[1][i];
rlm@485 40 m[1][i]=j;
rlm@485 41 }
rlm@485 42
rlm@485 43 if (m[1][i]>m[2][i])
rlm@485 44 {
rlm@485 45 j=m[1][i];
rlm@485 46 m[1][i]=m[2][i];
rlm@485 47 m[2][i]=j;
rlm@485 48 }
rlm@485 49
rlm@485 50 if (m[0][i]>m[1][i])
rlm@485 51 {
rlm@485 52 j=m[0][i];
rlm@485 53 m[0][i]=m[1][i];
rlm@485 54 m[1][i]=j;
rlm@485 55 }
rlm@485 56
rlm@485 57 tmp[i]=(((m[0][i]+m[1][i]*2+m[2][i]*4)*5) >> 4)+32;
rlm@485 58 }
rlm@485 59
rlm@485 60 color.rgbRed = tmp[0];
rlm@485 61 color.rgbGreen = tmp[1];
rlm@485 62 color.rgbBlue = tmp[2];
rlm@485 63
rlm@485 64 return color;
rlm@485 65 }
rlm@485 66
rlm@485 67
rlm@485 68
rlm@485 69
rlm@485 70
rlm@485 71 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
rlm@485 72