Code for loading "CM5" (CPC Mode 5) pixtures

* Fix a bug in the Set_layer function : it was only possible to set a new layer, and this format needs us to write to previous layers too
 * Saving is missing (you need to save as png then convert back to cm5 using SyX converter)
 * Preview does not work (it does not use layers, so the result is broken)
 * Loading switches the "8bit" mode on automatically

git-svn-id: svn://pulkomandy.tk/GrafX2/branches/cpcmode5@1723 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Adrien Destugues
2011-02-15 17:48:16 +00:00
parent 72e9892b53
commit bf9c34d7fe
3 changed files with 180 additions and 4 deletions

View File

@@ -125,6 +125,10 @@ void Save_C64(T_IO_Context *);
// -- SCR (Amstrad CPC)
void Save_SCR(T_IO_Context *);
// -- CM5 (Amstrad CPC)
void Test_CM5(T_IO_Context *);
void Load_CM5(T_IO_Context *);
// -- XPM (X PixMap)
// Loading is done through SDL_Image
void Save_XPM(T_IO_Context*);
@@ -142,7 +146,7 @@ void Load_SDL_Image(T_IO_Context *);
// ENUM Name TestFunc LoadFunc SaveFunc PalOnly Comment Layers Ext Exts
T_Format File_formats[] = {
{FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;koala;fli;bml;cdu;prg;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
{FORMAT_ALL_IMAGES, "(all)", NULL, NULL, NULL, 0, 0, 0, "", "gif;png;bmp;pcx;pkm;lbm;iff;img;sci;scq;scf;scn;sco;pi1;pc1;cel;neo;kcf;pal;c64;koa;koala;fli;bml;cdu;prg;tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;cm5"},
{FORMAT_ALL_FILES, "(*.*)", NULL, NULL, NULL, 0, 0, 0, "", "*"},
{FORMAT_GIF, " gif", Test_GIF, Load_GIF, Save_GIF, 0, 1, 1, "gif", "gif"},
#ifndef __no_pnglib__
@@ -162,6 +166,7 @@ T_Format File_formats[] = {
{FORMAT_PAL, " pal", Test_PAL, Load_PAL, Save_PAL, 1, 0, 0, "pal", "pal"},
{FORMAT_C64, " c64", Test_C64, Load_C64, Save_C64, 0, 1, 0, "c64", "c64;koa;koala;fli;bml;cdu;prg"},
{FORMAT_SCR, " cpc", NULL, NULL, Save_SCR, 0, 0, 0, "cpc", "cpc;scr"},
{FORMAT_CM5, " cm5", Test_CM5, Load_CM5, NULL, 0, 0, 1, "cm5", "cm5"},
{FORMAT_XPM, " xpm", NULL, NULL, Save_XPM, 0, 0, 0, "xpm", "xpm"},
{FORMAT_MISC,"misc.",NULL, NULL, NULL, 0, 0, 0, "", "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico"},
};
@@ -1262,7 +1267,7 @@ void Set_layer(T_IO_Context *context, byte layer)
if (context->Type == CONTEXT_MAIN_IMAGE)
{
// This awful thing is the part that happens on load
while (layer > (context->Nb_layers-1))
while (layer >= context->Nb_layers)
{
if (Add_layer(Main_backups, layer))
{
@@ -1272,10 +1277,11 @@ void Set_layer(T_IO_Context *context, byte layer)
break;
}
context->Nb_layers = Main_backups->Pages->Nb_layers;
Main_current_layer = layer;
Main_layers_visible = (2<<layer)-1;
}
context->Target_address=Main_backups->Pages->Image[layer];
Main_current_layer = layer;
}
}