set MSX palette when loading

This commit is contained in:
Thomas Bernard 2019-12-27 16:37:19 +01:00
parent 4d57ba39bb
commit c1c6be51cf
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
3 changed files with 40 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include "loadsavefuncs.h"
#include "io.h"
#include "misc.h"
#include "oldies.h"
#include "gfx2log.h"
#include "gfx2mem.h"
@ -129,7 +130,9 @@ void Load_MSX(T_IO_Context * context)
fclose(file);
File_error = 0;
// TODO: load MSX palette
if (Config.Clear_palette)
memset(context->Palette, 0, sizeof(T_Palette));
MSX_set_palette(context->Palette);
context->Transparent_color = 0; // Set color 0 as transparent
Pre_load(context, 256, 192, file_size, FORMAT_MSX, PIXEL_SIMPLE, 4);
for (row = 0; row < 24; row++)

View File

@ -1068,3 +1068,29 @@ void DHGR_set_palette(T_Components * palette)
palette[31].G = 255;
palette[31].B = 255;
}
void MSX_set_palette(T_Components * palette)
{
static const T_Components MSX_palette[] = {
{0, 0, 0},
{32,219,32},
{109,255,109},
{32,32,255},
{48,109,255},
{182,32,32},
{73,219,255},
{255,32,32},
{255,109,109},
{219,219,32},
{219,219,146},
{32,146,32},
{219,73,182},
{182,182,182},
{255,255,255}
};
memcpy(palette + 1, MSX_palette, sizeof(MSX_palette));
// set color 0 (transparent) to a dark gray
palette[0].R = 32;
palette[0].G = 32;
palette[0].B = 32;
}

View File

@ -19,6 +19,9 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
#ifndef OLDIES_H_DEFINED
#define OLDIES_H_DEFINED
///@file oldies.h
/// functions relative to old computers (Commodore 64, Thomsons MO/TO, Amstrad CPC, ZX Spectrum, etc.)
@ -297,3 +300,10 @@ void HGR_set_palette(T_Components * palette);
void DHGR_set_palette(T_Components * palette);
/** @}*/
/**
* Set the 15 color MSX palette
*/
void MSX_set_palette(T_Components * palette);
#endif