(mode5 branch) Fix a bug in saving, including autosave every few minutes, that auto-selects the last layer to draw.

git-svn-id: svn://pulkomandy.tk/GrafX2/branches/cpcmode5@1743 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2011-03-02 22:07:24 +00:00
parent 9058926e4b
commit 55422d160e
4 changed files with 32 additions and 20 deletions

View File

@ -2085,7 +2085,7 @@ void Load_GIF(T_IO_Context * context)
// This a second layer/frame, or more.
// Attempt to add a layer to current image
current_layer++;
Set_layer(context, current_layer);
Set_loading_layer(context, current_layer);
}
number_LID++;
@ -2444,7 +2444,7 @@ void Save_GIF(T_IO_Context * context)
GCE_block[3] |= 1; // Transparent color flag
GCE_block[6] = context->Transparent_color;
Set_layer(context, current_layer);
Set_saving_layer(context, current_layer);
if (current_layer == context->Nb_layers -1)
{

View File

@ -436,7 +436,7 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size,
context->Nb_layers=1;
Main_current_layer=0;
Main_layers_visible=1<<0;
Set_layer(context,0);
Set_loading_layer(context,0);
// Remove previous comment, unless we load just a palette
if (! Get_fileformat(context->Format)->Palette_only)
@ -1261,7 +1261,18 @@ void Init_context_surface(T_IO_Context * context, char *file_name, char *file_di
}
/// Function to call when need to switch layers.
void Set_layer(T_IO_Context *context, byte layer)
void Set_saving_layer(T_IO_Context *context, byte layer)
{
context->Current_layer = layer;
if (context->Type == CONTEXT_MAIN_IMAGE)
{
context->Target_address=Main_backups->Pages->Image[layer];
}
}
/// Function to call when need to switch layers.
void Set_loading_layer(T_IO_Context *context, byte layer)
{
context->Current_layer = layer;
@ -1280,9 +1291,8 @@ void Set_layer(T_IO_Context *context, byte layer)
context->Nb_layers = Main_backups->Pages->Nb_layers;
Main_layers_visible = (2<<layer)-1;
}
context->Target_address=Main_backups->Pages->Image[layer];
Main_current_layer = layer;
context->Target_address=Main_backups->Pages->Image[layer];
}
}

View File

@ -215,7 +215,9 @@ void Set_pixel(T_IO_Context *context, short x, short y, byte c);
/// Set the color of a 24bit pixel (on load)
void Set_pixel_24b(T_IO_Context *context, short x, short y, byte r, byte g, byte b);
/// Function to call when need to switch layers.
void Set_layer(T_IO_Context *context, byte layer);
void Set_loading_layer(T_IO_Context *context, byte layer);
/// Function to call when need to switch layers.
void Set_saving_layer(T_IO_Context *context, byte layer);
// =================================================================

View File

@ -2206,7 +2206,7 @@ void Load_C64_fli(T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *c
}
}
Set_layer(context, 1);
Set_loading_layer(context, 1);
for(cy=0; cy<25; cy++)
{
for(cx=0; cx<40; cx++)
@ -2222,7 +2222,7 @@ void Load_C64_fli(T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *c
}
}
Set_layer(context, 2);
Set_loading_layer(context, 2);
for(cy=0; cy<25; cy++)
{
for(cx=0; cx<40; cx++)
@ -2244,7 +2244,7 @@ void Load_C64_fli(T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *c
}
}
}
Set_layer(context, 3);
Set_loading_layer(context, 3);
for(y=0; y<200; y++)
{
for(x=0; x<160; x++)
@ -3015,7 +3015,7 @@ void Load_CM5(T_IO_Context* context)
if (Read_byte(file, &value)!=1)
File_error = 2;
Set_layer(context, 0);
Set_loading_layer(context, 0);
for(ty=0; ty<context->Height; ty++)
for(tx=0; tx<context->Width; tx++)
{
@ -3029,19 +3029,19 @@ void Load_CM5(T_IO_Context* context)
{
case 0:
// This is color for layer 1
Set_layer(context, 1);
Set_loading_layer(context, 1);
for(tx=0; tx<context->Width; tx++)
Set_pixel(context, tx, line, value);
break;
case 1:
// This is color for layer 2
Set_layer(context, 2);
Set_loading_layer(context, 2);
for(tx=0; tx<context->Width; tx++)
Set_pixel(context, tx, line, value);
break;
default:
// This is color for a block in layer 4
Set_layer(context, 3);
Set_loading_layer(context, 3);
for(tx=(mod-2)*48; tx<(mod-1)*48; tx++)
Set_pixel(context, tx, line, value);
break;
@ -3065,7 +3065,7 @@ void Load_CM5(T_IO_Context* context)
return;
}
Set_layer(context, 4);
Set_loading_layer(context, 4);
for (ty = 0; ty < 256; ty++)
{
@ -3106,15 +3106,15 @@ void Save_CM5(T_IO_Context* context)
}
// Write layer 0
Set_layer(context, 0);
Set_saving_layer(context, 0);
Write_byte(file, Get_pixel(context, 0, 0));
for(ty = 0; ty < 256; ty++)
{
Set_layer(context, 1);
Set_saving_layer(context, 1);
Write_byte(file, Get_pixel(context, 0, ty));
Set_layer(context, 2);
Set_saving_layer(context, 2);
Write_byte(file, Get_pixel(context, 0, ty));
Set_layer(context, 3);
Set_saving_layer(context, 3);
for(tx = 0; tx < 6; tx++)
{
Write_byte(file, Get_pixel(context, tx*48, ty));
@ -3132,7 +3132,7 @@ void Save_CM5(T_IO_Context* context)
return;
}
Set_layer(context, 4);
Set_saving_layer(context, 4);
for (ty = 0; ty < 256; ty++)
{