at present I am trying to convert Megadrive-Palettes to 24-bit Bitmap-Palettes. I am having to do it this terrible way:
1. Load ROM in Gens-KMod, get to part of Game I am interested in.
2. Pause the Emulator, view the VDP Debug.
3. Save the CRAM-Dump to File.
4. Take a Screen-Grab of my Desktop to get the Colours in the Palettes.
5. Load the Screen-Grab in PSP6 then sample the Colours in the four Palettes.
6. Take the CRAM-Dump File then convert to C-Array and then include in my MD-Program.
7. Transform the CRAM-Dump to C-Array Dump Colour-Codes in the Palettes from MD 9-bit 'BGR' Format to standard 9-bit RGB Format.
8. I have a table of (at present) 512 Colour-Codes that act as Equivalents for MD 9-bit in standard RGB to 24-bit Bitmap. I update the Table Colour by Colour but it's a bit long-winded.
Is there a way to accurately calculate the equivalent MD 9-bit BGR/RGB Value's 24-bit Bitmap Colour-Code?
My intention is to have a full table to support all 512 Megadrive Colours in 'normal-Mode' and to then find all the Colour-Codes for a Table to store the entire range of 1536 (512 * 3) for 'Shadow/Hilight Mode'. If there is a simple method to calculate the 24-bit Bitmap Colour-Code then there would be no need to use a Table.
Does anyone have any Ideas at all?
Code: Select all
//******************************************************************
// [Data Types]
//******************************************************************
//Basic-Types:
typedef unsigned char t_ubyte;
typedef unsigned int t_uword;
typedef unsigned long t_ulong;
typedef char t_byte;
typedef int t_word;
typedef long t_long;
typedef char t_char;
typedef t_uword t_id;
.....
//24bit Colour-Bitmap Colour Union:
union t_bitmap_24bit_colour_u
{
t_ulong colourStd;
struct t_bitmap_24bit_colour_st colourRGB;
t_ubyte colourRaw[BM_24BITCOLOUR_RAWCOLOUR_LEN];
};
....
struct t_bitmap_md_9bit_rgb_colour_st
{
t_ubyte red;
t_ubyte green;
t_ubyte blue;
};
....
/*
The Megadrive's Colour-Code are represented using standard RGB:
For Example:
the raw Colour-Code for the MD = 0x0222, this would be represented in standard-RGB as:
R = 0x001
G = 0x001
B = 0x001
or using the full unsigned Word = 0x0049.
This would be mapped to the 24-bit Bitmap Colour-Code = 0x212021, padded for 4 Bytes = 0x00212021.
*/
union t_bitmap_md_colour_st
{
t_uword raw;
struct t_bitmap_md_9bit_rgb_colour_st part;
};
......
struct t_bitmap_md_bmp_colour_equivalent_st
{
union t_bitmap_md_colour_st mdColour;
union t_bitmap_24bit_colour_u bmpColour;
};
.....
//******************************************************************
// [Globals]
//******************************************************************
...
//******************************************************
// [Megadrive to 24-bit Bitmap Colour-Code Equivalency Table]
//******************************************************
/*
Status: Table remains incomplete and has not been tested with an actual MD VRAM-Dump to 24-bit Bitmap-
Conversion.
Note: Each Pair Entry has the Format: { "MD-Colour-Code", "24-bit-BMP Colour-Code" }.
The Md-Colour-Code in the Table doesn't use the standard MD 9-bit BGR-Format but instead uses standard RGB-
Codes in the RGB-Format. Conversion Functions/Macros are used to operate on the conversions between the-
two Formats.
For Example:
the Raw MD Colour-Code for 0x0AA8 is represented as the Standard-RGB of 0x012D which maps to the 24-bit-
Bitmap Colour-Code of 0x0084A2A5.
*/
static const struct t_bitmap_md_bmp_colour_equivalent_st g_mdColEquivTab[MD_COLOUREQUIVALENT_TAB_SIZE] =
{
{ {0x0000, 0x00000000} }, { {0x0001, 0x00000021} }, { {0x0002, 0x00000000} }, { {0x0003, 0x00000063} },
{ {0x0004, 0x00000000} }, { {0x0005, 0x00000000} }, { {0x0006, 0x00000000} }, { {0x0007, 0x000000E7} },
..... the rest of the Colour-Code Equivalents .....
};
Cheers.