CPC_Firmware_to_Hardware_color()

This commit is contained in:
Thomas Bernard 2019-12-21 17:22:19 +01:00
parent 1aeab71663
commit 5b5bdf54dc
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
3 changed files with 27 additions and 6 deletions

View File

@ -315,10 +315,6 @@ void Load_SCR(T_IO_Context * context)
} }
else else
{ {
static const byte CPC_Firmware_Colors[] = {
0x54, 0x44, 0x55, 0x5c, 0x58, 0x5d, 0x4c, 0x45, 0x4d,
0x56, 0x46, 0x57, 0x5e, 0x40, 0x5f, 0x4e, 0x47, 0x4f,
0x52, 0x42, 0x53, 0x5a, 0x59, 0x5b, 0x4a, 0x43, 0x4b };
GFX2_Log(GFX2_DEBUG, ".SCR file. Data length %d\n", i); GFX2_Log(GFX2_DEBUG, ".SCR file. Data length %d\n", i);
if (load_address == 0x170) if (load_address == 0x170)
{ {
@ -409,7 +405,7 @@ void Load_SCR(T_IO_Context * context)
int j; int j;
mode = cpc_ram[0x800]; mode = cpc_ram[0x800];
for (j = 0; j < 16; j++) for (j = 0; j < 16; j++)
pal_data[12*j] = CPC_Firmware_Colors[cpc_ram[0x801 + j]]; pal_data[12*j] = CPC_Firmware_to_Hardware_color(cpc_ram[0x801 + j]);
addr = 0x847; addr = 0x847;
if (cpc_ram[0x80bb] == 1) if (cpc_ram[0x80bb] == 1)
addr = 0x80bb; addr = 0x80bb;
@ -452,7 +448,7 @@ void Load_SCR(T_IO_Context * context)
{ {
int j; int j;
for (j = 0; j < 16; j++) for (j = 0; j < 16; j++)
pal_data[12*j] = CPC_Firmware_Colors[cpc_ram[0xD7D1 + j]]; pal_data[12*j] = CPC_Firmware_to_Hardware_color(cpc_ram[0xD7D1 + j]);
} }
} }
else if (load_address == 0x0040 && exec_address == 0x8000) else if (load_address == 0x0040 && exec_address == 0x8000)

View File

@ -696,6 +696,17 @@ static const T_Components CPC_Hw_Palette[] = {
{0x6E, 0x7B, 0xF6} {0x6E, 0x7B, 0xF6}
}; };
/**
* The CPC firmware palette is ordered by luminosity
* see http://www.cpcwiki.eu/index.php/CPC_Palette
*/
static const byte CPC_Firmware_Colors[] = {
0x54, 0x44, 0x55, 0x5c, 0x58, 0x5d, 0x4c, 0x45, 0x4d,
0x56, 0x46, 0x57, 0x5e, 0x40, 0x5f, 0x4e, 0x47, 0x4f,
0x52, 0x42, 0x53, 0x5a, 0x59, 0x5b, 0x4a, 0x43, 0x4b
};
void CPC_set_HW_palette(T_Components * palette) void CPC_set_HW_palette(T_Components * palette)
{ {
memcpy(palette, CPC_Hw_Palette, sizeof(CPC_Hw_Palette)); memcpy(palette, CPC_Hw_Palette, sizeof(CPC_Hw_Palette));
@ -733,6 +744,13 @@ void CPC_set_default_BASIC_palette(T_Components * palette)
sizeof(T_Components)); sizeof(T_Components));
} }
byte CPC_Firmware_to_Hardware_color(byte fw_color)
{
if (fw_color <= 26)
return CPC_Firmware_Colors[fw_color];
return 0;
}
int CPC_check_AMSDOS(FILE * file, word * loading_address, word * exec_address, unsigned long * file_length) int CPC_check_AMSDOS(FILE * file, word * loading_address, word * exec_address, unsigned long * file_length)
{ {
int i; int i;

View File

@ -127,6 +127,13 @@ void CPC_set_default_BASIC_palette(T_Components * palette);
*/ */
int CPC_compare_colors(T_Components * col1, T_Components * col2); int CPC_compare_colors(T_Components * col1, T_Components * col2);
/**
* Convert CPC firmware color to hardware color (Gate Array)
* @param fw_color a CPC Firmware color index (from 0 to 26)
* @return a CPC Hardware color (from 0x40 to 0x5f)
*/
byte CPC_Firmware_to_Hardware_color(byte fw_color);
/** /**
* Check AMSDOS header * Check AMSDOS header
* *