CPC mode 5 : replaced the global Constraint_mode by a state (Image_mode) in each versioned T_Page: This allows keeping it sane when swapping to Spare, and when Undo/Redoing. Also fixed the first page when program starts, it was unnecessarily allocating pointers for the maximum number of layers(16)/frames(999)

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1907 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2012-02-27 00:47:18 +00:00
parent 55d0889bc8
commit d38f5ee981
9 changed files with 30 additions and 20 deletions

View File

@ -124,7 +124,7 @@ void Display_paintbrush(short x,short y,byte color)
if (Mouse_K) // pas de curseur si on est en preview et if (Mouse_K) // pas de curseur si on est en preview et
return; // en train de cliquer return; // en train de cliquer
if (Constraint_mode && Main_current_layer < 4) if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 && Main_current_layer < 4)
{ {
goto single_pixel; goto single_pixel;
} }
@ -292,7 +292,7 @@ void Draw_paintbrush(short x,short y,byte color)
int position; int position;
byte old_color; byte old_color;
if (Constraint_mode && Main_current_layer < 4) if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 && Main_current_layer < 4)
{ {
// Flood-fill the enclosing area // Flood-fill the enclosing area
if (x<Main_image_width && y<Main_image_height && x>= 0 && y >= 0 if (x<Main_image_width && y<Main_image_height && x>= 0 && y >= 0

View File

@ -4514,7 +4514,7 @@ void Display_effect_states(void)
Display_effect_state(C2+23, 81, "Grid" ,Snap_mode); Display_effect_state(C2+23, 81, "Grid" ,Snap_mode);
Display_effect_state(C2+23,100, "Tiling" ,Tiling_mode); Display_effect_state(C2+23,100, "Tiling" ,Tiling_mode);
Display_effect_state(177+23,24, "8 bit" ,Constraint_mode); Display_effect_state(177+23,24, "8 bit" ,Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION);
Display_effect_state(177+23,43, "Tilemap",Main_tilemap_mode); Display_effect_state(177+23,43, "Tilemap",Main_tilemap_mode);
} }
@ -4800,7 +4800,7 @@ void Button_Effects(void)
{ {
Button_Constraint_mode(); Button_Constraint_mode();
Hide_cursor(); Hide_cursor();
Display_effect_state(177+23,24, "8 bit" ,Constraint_mode); Display_effect_state(177+23,24, "8 bit" ,Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION);
Display_cursor(); Display_cursor();
} else { } else {
Close_window(); Close_window();
@ -4834,7 +4834,7 @@ void Button_Effects(void)
else else
Hide_cursor(); Hide_cursor();
if (!(Shade_mode||Quick_shade_mode||Colorize_mode||Smooth_mode||Tiling_mode||Smear_mode||Stencil_mode||Mask_mode||Sieve_mode||Snap_mode||Constraint_mode||Main_tilemap_mode)) if (!(Shade_mode||Quick_shade_mode||Colorize_mode||Smooth_mode||Tiling_mode||Smear_mode||Stencil_mode||Mask_mode||Sieve_mode||Snap_mode||Main_tilemap_mode))
Unselect_button(BUTTON_EFFECTS); Unselect_button(BUTTON_EFFECTS);
Display_cursor(); Display_cursor();

View File

@ -167,10 +167,9 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca
// Constaint enforcer/checker ------------------------------------------------ // Constaint enforcer/checker ------------------------------------------------
void Button_Constraint_mode(void) void Button_Constraint_mode(void)
{ {
Constraint_mode=!Constraint_mode; if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED)
if (Constraint_mode)
{ {
Main_backups->Pages->Image_mode = IMAGE_MODE_MODE5;
// TODO backup // TODO backup
// CPC Mode 5 - ensure there are at least 5 layers // CPC Mode 5 - ensure there are at least 5 layers
while(Main_backups->Pages->Nb_layers < 5) while(Main_backups->Pages->Nb_layers < 5)
@ -182,6 +181,11 @@ void Button_Constraint_mode(void)
// TODO set the palette to a CPC one ? // TODO set the palette to a CPC one ?
} }
else if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5)
{
// Disable
Main_backups->Pages->Image_mode = IMAGE_MODE_LAYERED;
}
} }
@ -906,7 +910,6 @@ void Effects_off(void)
Mask_mode=0; Mask_mode=0;
Sieve_mode=0; Sieve_mode=0;
Snap_mode=0; Snap_mode=0;
Constraint_mode=0;
Main_tilemap_mode=0; Main_tilemap_mode=0;
} }

View File

@ -564,4 +564,11 @@ enum OPERATIONS
NB_OPERATIONS ///< Number of operations handled by the engine NB_OPERATIONS ///< Number of operations handled by the engine
}; };
enum IMAGE_MODES
{
IMAGE_MODE_LAYERED=0, ///< Layered image
IMAGE_MODE_ANIMATION, ///< Animation
IMAGE_MODE_MODE5, ///< CPC mode 5
};
#endif #endif

View File

@ -726,11 +726,6 @@ GFX2_GLOBAL byte Mask_mode;
/// Array of booleans. True if the indexed color is protected by the mask. /// Array of booleans. True if the indexed color is protected by the mask.
GFX2_GLOBAL byte Mask_table[256]; GFX2_GLOBAL byte Mask_table[256];
// -- Constraint mode
/// Constraint enforcer
GFX2_GLOBAL byte Constraint_mode;
// -- Tilemap mode // -- Tilemap mode
/// Tilemap mode for main page /// Tilemap mode for main page

View File

@ -3009,7 +3009,7 @@ byte Read_pixel_from_current_screen (word x,word y)
byte depth; byte depth;
byte color; byte color;
if (Constraint_mode) if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5)
if (Main_current_layer==4) if (Main_current_layer==4)
return *(Main_backups->Pages->Image[Main_current_layer].Pixels + x+y*Main_image_width); return *(Main_backups->Pages->Image[Main_current_layer].Pixels + x+y*Main_image_width);
@ -3163,12 +3163,13 @@ byte Read_pixel_from_current_layer(word x,word y)
void Update_pixel_renderer(void) void Update_pixel_renderer(void)
{ {
#ifndef NOLAYERS #ifndef NOLAYERS
if (!Constraint_mode) if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED)
{ {
// layered // layered
Pixel_in_current_screen = Pixel_in_screen_layered; Pixel_in_current_screen = Pixel_in_screen_layered;
Pixel_in_current_screen_with_preview = Pixel_in_screen_layered_with_preview; Pixel_in_current_screen_with_preview = Pixel_in_screen_layered_with_preview;
} }
// Implicit else : Image_mode must be IMAGE_MODE_MODE5
else if ( Main_current_layer == 4) else if ( Main_current_layer == 4)
{ {
// overlay // overlay

View File

@ -3021,8 +3021,8 @@ void Load_CM5(T_IO_Context* context)
// Now select layer 0 again // Now select layer 0 again
Set_loading_layer(context, 0); Set_loading_layer(context, 0);
if (Constraint_mode != 1) if (context->Type == CONTEXT_MAIN_IMAGE)
Constraint_mode = 1; Main_backups->Pages->Image_mode = IMAGE_MODE_MODE5;
for(ty=0; ty<context->Height; ty++) for(ty=0; ty<context->Height; ty++)
for(tx=0; tx<context->Width; tx++) for(tx=0; tx<context->Width; tx++)

View File

@ -73,6 +73,7 @@ T_Page * New_page(int nb_layers)
} }
page->Width=0; page->Width=0;
page->Height=0; page->Height=0;
page->Image_mode = IMAGE_MODE_LAYERED;
memset(page->Palette,0,sizeof(T_Palette)); memset(page->Palette,0,sizeof(T_Palette));
page->Comment[0]='\0'; page->Comment[0]='\0';
page->File_directory[0]='\0'; page->File_directory[0]='\0';
@ -203,7 +204,7 @@ void Redraw_layered_image(void)
// Re-construct the image with the visible layers // Re-construct the image with the visible layers
byte layer=0; byte layer=0;
// First layer // First layer
if (Constraint_mode && Main_layers_visible & (1<<4)) if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 && Main_layers_visible & (1<<4))
{ {
// The raster result layer is visible: start there // The raster result layer is visible: start there
// Copy it in Main_visible_image // Copy it in Main_visible_image
@ -484,7 +485,7 @@ int Allocate_list_of_pages(T_List_of_pages * list)
T_Page * page; T_Page * page;
// On initialise chacune des nouvelles pages // On initialise chacune des nouvelles pages
page=New_page(NB_LAYERS); page=New_page(1);
if (!page) if (!page)
return 0; return 0;
@ -911,6 +912,7 @@ int Backup_with_new_dimensions(int width,int height)
Main_backups->Pages->Gradients=Dup_gradient(Main_backups->Pages->Next); Main_backups->Pages->Gradients=Dup_gradient(Main_backups->Pages->Next);
Main_backups->Pages->Background_transparent=Main_backups->Pages->Next->Background_transparent; Main_backups->Pages->Background_transparent=Main_backups->Pages->Next->Background_transparent;
Main_backups->Pages->Transparent_color=Main_backups->Pages->Next->Transparent_color; Main_backups->Pages->Transparent_color=Main_backups->Pages->Next->Transparent_color;
Main_backups->Pages->Image_mode=Main_backups->Pages->Next->Image_mode;
// Fill with transparent color // Fill with transparent color
for (i=0; i<Main_backups->Pages->Nb_layers;i++) for (i=0; i<Main_backups->Pages->Nb_layers;i++)

View File

@ -401,6 +401,8 @@ typedef struct T_Page
int Height; ///< Image height in pixels. int Height; ///< Image height in pixels.
T_Palette Palette; ///< Image palette. T_Palette Palette; ///< Image palette.
byte Image_mode; ///< 0= layered image, 1=animation,
char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file. char Comment[COMMENT_SIZE+1]; ///< Comment to store in the image file.
char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file. char File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.