diff --git a/src/cpcformats.c b/src/cpcformats.c index e00ea130..ba2c92ec 100644 --- a/src/cpcformats.c +++ b/src/cpcformats.c @@ -315,10 +315,6 @@ void Load_SCR(T_IO_Context * context) } 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); if (load_address == 0x170) { @@ -409,7 +405,7 @@ void Load_SCR(T_IO_Context * context) int j; mode = cpc_ram[0x800]; 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; if (cpc_ram[0x80bb] == 1) addr = 0x80bb; @@ -452,7 +448,7 @@ void Load_SCR(T_IO_Context * context) { int 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) diff --git a/src/oldies.c b/src/oldies.c index 4cd8d689..86ca0d28 100644 --- a/src/oldies.c +++ b/src/oldies.c @@ -696,6 +696,17 @@ static const T_Components CPC_Hw_Palette[] = { {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) { 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)); } +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 i; diff --git a/src/oldies.h b/src/oldies.h index b9cf67ec..9c5f5b7a 100644 --- a/src/oldies.h +++ b/src/oldies.h @@ -127,6 +127,13 @@ void CPC_set_default_BASIC_palette(T_Components * palette); */ 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 *