changeset 485:cd6a96a07d2e

added reference c program for converting vga rgb to vb rgb.
author Robert McIntyre <rlm@mit.edu>
date Sun, 06 May 2012 20:54:09 -0500
parents f6b5a1914efa
children 09df21060be6
files temp-c-stuff
diffstat 1 files changed, 72 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/temp-c-stuff	Sun May 06 20:54:09 2012 -0500
     1.3 @@ -0,0 +1,72 @@
     1.4 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     1.5 +
     1.6 +
     1.7 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     1.8 +
     1.9 +
    1.10 +// This section of code is used to convert an RGB (pc) triplet into a RGB (gameboy)
    1.11 +// triplet. This section of code was kindly donated by Brett Bibby (GameBrains).
    1.12 +
    1.13 +BYTE intensity[32] = 
    1.14 +  {
    1.15 +    0x00,0x10,0x20,0x30,0x40,0x50,0x5e,0x6c,0x7a,0x88,0x94,0xa0,0xae,0xb7,0xbf,0xc6,
    1.16 +    0xce,0xd3,0xd9,0xdf,0xe3,0xe7,0xeb,0xef,0xf3,0xf6,0xf9,0xfb,0xfd,0xfe,0xff,0xff
    1.17 +  };
    1.18 +
    1.19 +unsigned char influence[3][3] = 
    1.20 +  {
    1.21 +    {16,4,4},
    1.22 +    {8,16,8},
    1.23 +    {0,8,16}
    1.24 +  };
    1.25 +
    1.26 +RGBQUAD translate(BYTE rgb[3])
    1.27 +{
    1.28 +  RGBQUAD color;
    1.29 +  BYTE	tmp[3];
    1.30 +  BYTE	m[3][3];
    1.31 +  BYTE	i,j;
    1.32 +
    1.33 +  for (i=0;i<3;i++)
    1.34 +    for (j=0;j<3;j++)
    1.35 +      m[i][j] = (intensity[rgb[i]>>3]*influence[i][j]) >> 5;
    1.36 +
    1.37 +  for (i=0;i<3;i++)
    1.38 +    {
    1.39 +      if (m[0][i]>m[1][i])
    1.40 +	{
    1.41 +	  j=m[0][i]; 
    1.42 +	  m[0][i]=m[1][i]; 
    1.43 +	  m[1][i]=j;
    1.44 +	}
    1.45 +
    1.46 +      if (m[1][i]>m[2][i])
    1.47 +	{
    1.48 +	  j=m[1][i]; 
    1.49 +	  m[1][i]=m[2][i]; 
    1.50 +	  m[2][i]=j;
    1.51 +	}
    1.52 +
    1.53 +      if (m[0][i]>m[1][i])
    1.54 +	{
    1.55 +	  j=m[0][i]; 
    1.56 +	  m[0][i]=m[1][i]; 
    1.57 +	  m[1][i]=j;
    1.58 +	}
    1.59 +
    1.60 +      tmp[i]=(((m[0][i]+m[1][i]*2+m[2][i]*4)*5) >> 4)+32;
    1.61 +    }
    1.62 +
    1.63 +  color.rgbRed	= tmp[0];
    1.64 +  color.rgbGreen	= tmp[1];
    1.65 +  color.rgbBlue	= tmp[2];
    1.66 +
    1.67 +  return color;
    1.68 +}
    1.69 +
    1.70 +
    1.71 +
    1.72 +
    1.73 +
    1.74 +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1.75 +