diff --git a/src/brush.c b/src/brush.c index 29cc7f4c..ca7fff7a 100644 --- a/src/brush.c +++ b/src/brush.c @@ -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 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; } @@ -292,7 +292,7 @@ void Draw_paintbrush(short x,short y,byte color) int position; 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 if (x= 0 && y >= 0 diff --git a/src/buttons.c b/src/buttons.c index 65181850..dee3eb25 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -4514,7 +4514,7 @@ void Display_effect_states(void) Display_effect_state(C2+23, 81, "Grid" ,Snap_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); } @@ -4800,7 +4800,7 @@ void Button_Effects(void) { Button_Constraint_mode(); 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(); } else { Close_window(); @@ -4834,7 +4834,7 @@ void Button_Effects(void) else 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); Display_cursor(); diff --git a/src/buttons_effects.c b/src/buttons_effects.c index 3a74f984..3186253c 100644 --- a/src/buttons_effects.c +++ b/src/buttons_effects.c @@ -167,10 +167,9 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca // Constaint enforcer/checker ------------------------------------------------ void Button_Constraint_mode(void) { - Constraint_mode=!Constraint_mode; - - if (Constraint_mode) + if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED) { + Main_backups->Pages->Image_mode = IMAGE_MODE_MODE5; // TODO backup // CPC Mode 5 - ensure there are at least 5 layers while(Main_backups->Pages->Nb_layers < 5) @@ -182,6 +181,11 @@ void Button_Constraint_mode(void) // 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; Sieve_mode=0; Snap_mode=0; - Constraint_mode=0; Main_tilemap_mode=0; } diff --git a/src/const.h b/src/const.h index adb9a730..9a68caf1 100644 --- a/src/const.h +++ b/src/const.h @@ -564,4 +564,11 @@ enum OPERATIONS 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 diff --git a/src/global.h b/src/global.h index 86b9952f..54583d67 100644 --- a/src/global.h +++ b/src/global.h @@ -726,11 +726,6 @@ GFX2_GLOBAL byte Mask_mode; /// Array of booleans. True if the indexed color is protected by the mask. GFX2_GLOBAL byte Mask_table[256]; -// -- Constraint mode - -/// Constraint enforcer -GFX2_GLOBAL byte Constraint_mode; - // -- Tilemap mode /// Tilemap mode for main page diff --git a/src/graph.c b/src/graph.c index e62451dc..119cf8a2 100644 --- a/src/graph.c +++ b/src/graph.c @@ -3009,7 +3009,7 @@ byte Read_pixel_from_current_screen (word x,word y) byte depth; byte color; - if (Constraint_mode) + if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5) if (Main_current_layer==4) 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) { #ifndef NOLAYERS - if (!Constraint_mode) + if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED) { // layered Pixel_in_current_screen = Pixel_in_screen_layered; 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) { // overlay diff --git a/src/miscfileformats.c b/src/miscfileformats.c index bc82be6b..8c4a6c2f 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -3021,8 +3021,8 @@ void Load_CM5(T_IO_Context* context) // Now select layer 0 again Set_loading_layer(context, 0); - if (Constraint_mode != 1) - Constraint_mode = 1; + if (context->Type == CONTEXT_MAIN_IMAGE) + Main_backups->Pages->Image_mode = IMAGE_MODE_MODE5; for(ty=0; tyHeight; ty++) for(tx=0; txWidth; tx++) diff --git a/src/pages.c b/src/pages.c index 73ba7bf3..e51f5881 100644 --- a/src/pages.c +++ b/src/pages.c @@ -73,6 +73,7 @@ T_Page * New_page(int nb_layers) } page->Width=0; page->Height=0; + page->Image_mode = IMAGE_MODE_LAYERED; memset(page->Palette,0,sizeof(T_Palette)); page->Comment[0]='\0'; page->File_directory[0]='\0'; @@ -203,7 +204,7 @@ void Redraw_layered_image(void) // Re-construct the image with the visible layers byte layer=0; // 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 // Copy it in Main_visible_image @@ -484,7 +485,7 @@ int Allocate_list_of_pages(T_List_of_pages * list) T_Page * page; // On initialise chacune des nouvelles pages - page=New_page(NB_LAYERS); + page=New_page(1); if (!page) 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->Background_transparent=Main_backups->Pages->Next->Background_transparent; 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 for (i=0; iPages->Nb_layers;i++) diff --git a/src/struct.h b/src/struct.h index 627b9c60..1271c187 100644 --- a/src/struct.h +++ b/src/struct.h @@ -401,6 +401,8 @@ typedef struct T_Page int Height; ///< Image height in pixels. 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 File_directory[MAX_PATH_CHARACTERS];///< Directory that contains the file.