diff --git a/src/brush.c b/src/brush.c index a3ef64b6..0d6ead28 100644 --- a/src/brush.c +++ b/src/brush.c @@ -120,7 +120,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 (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 && Main.current_layer < 4) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_MODE5 && Main.current_layer < 4) { goto single_pixel; } @@ -284,7 +284,7 @@ void Draw_paintbrush(short x,short y,byte color) int position; byte old_color; - if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 && 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 b86e0e7d..31732ecd 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -169,8 +169,8 @@ void Button_Message_initial(void) //Print_in_window( 120-4*13,128,"(placeholder)",MC_Dark,MC_Light); Print_in_window(130-4*16,136,"http://grafx2.tk",MC_Dark,MC_Light); - Window_set_normal_button(56, 151, 71, 14, "Anim", 0, (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION), KEY_NONE); - Window_set_normal_button(133, 151, 71, 14, "Layers", 0, (Main_backups->Pages->Image_mode != IMAGE_MODE_LAYERED), KEY_NONE); + Window_set_normal_button(56, 151, 71, 14, "Anim", 0, (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION), KEY_NONE); + Window_set_normal_button(133, 151, 71, 14, "Layers", 0, (Main.backups->Pages->Image_mode != IMAGE_MODE_LAYERED), KEY_NONE); Update_window_area(0,0,Window_width, Window_height); @@ -187,7 +187,7 @@ void Button_Message_initial(void) if (clicked_button > 0) { - if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_LAYERED) { Switch_layer_mode(IMAGE_MODE_ANIMATION); Config.Default_mode_layers = 0; @@ -203,7 +203,7 @@ void Button_Message_initial(void) Display_all_screen(); } // Modify the mode for the spare too - Spare_backups->Pages->Image_mode = Main_backups->Pages->Image_mode; + Spare.backups->Pages->Image_mode = Main.backups->Pages->Image_mode; Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); } @@ -506,12 +506,12 @@ void Button_Toggle_toolbar(void) Window_dropdown_add_item(&dropdown, 0, menu_name_tools); - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION || - Main_backups->Pages->Nb_layers==1) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION || + Main.backups->Pages->Nb_layers==1) Window_dropdown_add_item(&dropdown, 1, menu_name_layers); - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION || - (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED && Main_backups->Pages->Nb_layers==1)) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION || + (Main.backups->Pages->Image_mode == IMAGE_MODE_LAYERED && Main.backups->Pages->Nb_layers==1)) Window_dropdown_add_item(&dropdown, 2, menu_name_anim); item=Dropdown_activate(&dropdown,0,Menu_Y+Menu_bars[MENUBAR_STATUS].Top*Menu_factor_Y); @@ -531,7 +531,7 @@ void Button_Toggle_toolbar(void) } Set_bar_visibility(MENUBAR_LAYERS, !Menu_bars[MENUBAR_LAYERS].Visible, 0); - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) Switch_layer_mode(IMAGE_MODE_LAYERED); break; @@ -543,7 +543,7 @@ void Button_Toggle_toolbar(void) } Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible, 0); - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) Switch_layer_mode(IMAGE_MODE_ANIMATION); break; @@ -631,7 +631,7 @@ byte Button_Quit_local_function(void) { case 1 : return 0; // Rester case 2 : // Sauver et enregistrer - Get_full_filename(filename, Main_backups->Pages->Filename, Main_backups->Pages->File_directory); + Get_full_filename(filename, Main.backups->Pages->Filename, Main.backups->Pages->File_directory); if ( (!File_exists(filename)) || Confirmation_box("Erase old file ?") ) { T_IO_Context save_context; @@ -641,7 +641,7 @@ byte Button_Quit_local_function(void) Cursor_shape=CURSOR_SHAPE_HOURGLASS; Display_cursor(); - Init_context_layered_image(&save_context, Main_backups->Pages->Filename, Main_backups->Pages->File_directory); + Init_context_layered_image(&save_context, Main.backups->Pages->Filename, Main.backups->Pages->File_directory); Save_image(&save_context); Destroy_context(&save_context); @@ -698,9 +698,9 @@ void Button_Clear(void) Hide_cursor(); Backup(); if (Stencil_mode && Config.Clear_with_stencil) - Clear_current_image_with_stencil(Main_backups->Pages->Transparent_color,Stencil); + Clear_current_image_with_stencil(Main.backups->Pages->Transparent_color,Stencil); else - Clear_current_image(Main_backups->Pages->Transparent_color); + Clear_current_image(Main.backups->Pages->Transparent_color); Redraw_layered_image(); End_of_modification(); Display_all_screen(); @@ -1565,9 +1565,9 @@ void Button_Page(void) // On fait le reste du travail "à la main": // TODO - SWAP_PBYTES(Main_visible_image.Image,Spare_visible_image.Image)// ! - SWAP_WORDS (Main_visible_image.Width,Spare_visible_image.Width)// ! - SWAP_WORDS (Main_visible_image.Height,Spare_visible_image.Height)// ! + SWAP_PBYTES(Main.visible_image.Image,Spare.visible_image.Image) + SWAP_WORDS (Main.visible_image.Width,Spare.visible_image.Width) + SWAP_WORDS (Main.visible_image.Height,Spare.visible_image.Height) SWAP_SHORTS(Main.offset_X,Spare.offset_X) SWAP_SHORTS(Main.offset_Y,Spare.offset_Y) SWAP_SHORTS(Main.separator_position,Spare.separator_position) @@ -1652,20 +1652,20 @@ void Copy_image_only(void) { byte i; - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { if (i == Spare.current_layer) { // Copy the current layer - memcpy(Spare_backups->Pages->Image[i].Pixels,Main_backups->Pages->Image[Main.current_layer].Pixels,Main.image_width*Main.image_height); + memcpy(Spare.backups->Pages->Image[i].Pixels,Main.backups->Pages->Image[Main.current_layer].Pixels,Main.image_width*Main.image_height); } else { // Resize the original layer Copy_part_of_image_to_another( - Spare_backups->Pages->Next->Image[i].Pixels,0,0,Min(old_width,Spare.image_width), + Spare.backups->Pages->Next->Image[i].Pixels,0,0,Min(old_width,Spare.image_width), Min(old_height,Spare.image_height),old_width, - Spare_backups->Pages->Image[i].Pixels,0,0,Spare.image_width); + Spare.backups->Pages->Image[i].Pixels,0,0,Spare.image_width); } } @@ -1812,10 +1812,10 @@ void Button_Copy_page(void) // -- Suppression d'une page ------------------------------------------------- void Button_Kill(void) { - if ( (Main_backups->List_size==1) + if ( (Main.backups->List_size==1) || (!Confirmation_box("Delete the current page?")) ) { - if (Main_backups->List_size==1) + if (Main.backups->List_size==1) Warning_message("You can't delete the last page."); Hide_cursor(); Unselect_button(BUTTON_KILL); @@ -2467,19 +2467,19 @@ void Draw_button_gradient_style(short x_pos,short y_pos,int technique) void Load_gradient_data(int index) { - if (Main_backups->Pages->Gradients->Range[index].Start>Main_backups->Pages->Gradients->Range[index].End) + if (Main.backups->Pages->Gradients->Range[index].Start>Main.backups->Pages->Gradients->Range[index].End) Error(0); - Gradient_lower_bound =Main_backups->Pages->Gradients->Range[index].Start; - Gradient_upper_bound =Main_backups->Pages->Gradients->Range[index].End; - Gradient_is_inverted =Main_backups->Pages->Gradients->Range[index].Inverse; - Gradient_random_factor=Main_backups->Pages->Gradients->Range[index].Mix+1; + Gradient_lower_bound =Main.backups->Pages->Gradients->Range[index].Start; + Gradient_upper_bound =Main.backups->Pages->Gradients->Range[index].End; + Gradient_is_inverted =Main.backups->Pages->Gradients->Range[index].Inverse; + Gradient_random_factor=Main.backups->Pages->Gradients->Range[index].Mix+1; Gradient_bounds_range=(Gradient_lower_boundPages->Gradients->Range[index].Technique) + switch(Main.backups->Pages->Gradients->Range[index].Technique) { case 0 : // Degradé de base Gradient_function=Gradient_basic; @@ -2541,7 +2541,7 @@ void Button_Gradients(void) Gradient_pixel=Pixel; old_current_gradient=Current_gradient; changed_gradient_index=0; - memcpy(&backup_gradients,Main_backups->Pages->Gradients,sizeof(T_Gradient_array)); + memcpy(&backup_gradients,Main.backups->Pages->Gradients,sizeof(T_Gradient_array)); Open_window(235,146,"Gradation menu"); @@ -2550,19 +2550,19 @@ void Button_Gradients(void) gradient_scroller=Window_set_scroller_button(218,20,75,16,1,Current_gradient); // 2 // Slider for mix mix_scroller = Window_set_scroller_button(31,20,84,256,1, - Main_backups->Pages->Gradients->Range[Current_gradient].Mix); // 3 + Main.backups->Pages->Gradients->Range[Current_gradient].Mix); // 3 // Direction Window_set_normal_button(8,20,15,14, - (Main_backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",0,1,SDLK_TAB); // 4 + (Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",0,1,SDLK_TAB); // 4 // Technique Window_set_normal_button(8,90,15,14,"",0,1,SDLK_TAB|MOD_SHIFT); // 5 - Draw_button_gradient_style(8,90,Main_backups->Pages->Gradients->Range[Current_gradient].Technique); + Draw_button_gradient_style(8,90,Main.backups->Pages->Gradients->Range[Current_gradient].Technique); Window_set_normal_button(178,128,51,14,"OK",0,1,SDLK_RETURN); // 6 Window_set_normal_button(123,128,51,14,"Cancel",0,1,KEY_ESC); // 7 // Scrolling speed - speed_scroller = Window_set_horizontal_scroller_button(99,111,130,106,1,Main_backups->Pages->Gradients->Range[Current_gradient].Speed); // 8 - Num2str(Main_backups->Pages->Gradients->Range[Current_gradient].Speed,str,3); + speed_scroller = Window_set_horizontal_scroller_button(99,111,130,106,1,Main.backups->Pages->Gradients->Range[Current_gradient].Speed); // 8 + Num2str(Main.backups->Pages->Gradients->Range[Current_gradient].Speed,str,3); Print_in_window(73,113,str,MC_Black,MC_Light); Print_in_window(5,58,"MIX",MC_Dark,MC_Light); @@ -2572,7 +2572,7 @@ void Button_Gradients(void) Print_in_window(11,112,"Cycling",cycling_mode?MC_Black:MC_Dark,MC_Light); // On tagge les couleurs qui vont avec - Tag_color_range(Main_backups->Pages->Gradients->Range[Current_gradient].Start,Main_backups->Pages->Gradients->Range[Current_gradient].End); + Tag_color_range(Main.backups->Pages->Gradients->Range[Current_gradient].Start,Main.backups->Pages->Gradients->Range[Current_gradient].End); Num2str(Current_gradient+1,str,2); Print_in_window(215,100,str,MC_Black,MC_Light); @@ -2582,7 +2582,7 @@ void Button_Gradients(void) // On affiche la preview Draw_gradient_preview(8,128,108,14,Current_gradient); - first_color=last_color=(Main_backups->Pages->Gradients->Range[Current_gradient].Inverse)?Main_backups->Pages->Gradients->Range[Current_gradient].End:Main_backups->Pages->Gradients->Range[Current_gradient].Start; + first_color=last_color=(Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?Main.backups->Pages->Gradients->Range[Current_gradient].End:Main.backups->Pages->Gradients->Range[Current_gradient].Start; Update_window_area(0,0,Window_width, Window_height); Display_cursor(); @@ -2604,19 +2604,19 @@ void Button_Gradients(void) Print_in_window(215,100,str,MC_Black,MC_Light); // On tagge les couleurs qui vont avec - Tag_color_range(Main_backups->Pages->Gradients->Range[Current_gradient].Start,Main_backups->Pages->Gradients->Range[Current_gradient].End); + Tag_color_range(Main.backups->Pages->Gradients->Range[Current_gradient].Start,Main.backups->Pages->Gradients->Range[Current_gradient].End); // On affiche le sens qui va avec - Print_in_window(12,23,(Main_backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",MC_Black,MC_Light); + Print_in_window(12,23,(Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",MC_Black,MC_Light); // On raffiche le mélange (jauge) qui va avec - mix_scroller->Position=Main_backups->Pages->Gradients->Range[Current_gradient].Mix; + mix_scroller->Position=Main.backups->Pages->Gradients->Range[Current_gradient].Mix; Window_draw_slider(mix_scroller); // Update speed - speed_scroller->Position=Main_backups->Pages->Gradients->Range[Current_gradient].Speed; + speed_scroller->Position=Main.backups->Pages->Gradients->Range[Current_gradient].Speed; Window_draw_slider(speed_scroller); - Num2str(Main_backups->Pages->Gradients->Range[Current_gradient].Speed,str,3); + Num2str(Main.backups->Pages->Gradients->Range[Current_gradient].Speed,str,3); Print_in_window(73,113,str,MC_Black,MC_Light); // Gradient # @@ -2624,7 +2624,7 @@ void Button_Gradients(void) Window_draw_slider(gradient_scroller); // Technique (flat, dithered, very dithered) - Draw_button_gradient_style(8,90,Main_backups->Pages->Gradients->Range[Current_gradient].Technique); + Draw_button_gradient_style(8,90,Main.backups->Pages->Gradients->Range[Current_gradient].Technique); // Rectangular gradient preview Draw_gradient_preview(8,128,108,14,Current_gradient); @@ -2654,9 +2654,9 @@ void Button_Gradients(void) // On vient de clicker // On met à jour l'intervalle du dégradé - first_color=last_color=Main_backups->Pages->Gradients->Range[Current_gradient].Start=Main_backups->Pages->Gradients->Range[Current_gradient].End=temp_color; + first_color=last_color=Main.backups->Pages->Gradients->Range[Current_gradient].Start=Main.backups->Pages->Gradients->Range[Current_gradient].End=temp_color; // On tagge le bloc - Tag_color_range(Main_backups->Pages->Gradients->Range[Current_gradient].Start,Main_backups->Pages->Gradients->Range[Current_gradient].End); + Tag_color_range(Main.backups->Pages->Gradients->Range[Current_gradient].Start,Main.backups->Pages->Gradients->Range[Current_gradient].End); // Tracé de la preview: Draw_gradient_preview(8,128,108,14,Current_gradient); } @@ -2668,18 +2668,18 @@ void Button_Gradients(void) // On commence par ordonner la 1ère et dernière couleur du bloc if (first_colorPages->Gradients->Range[Current_gradient].Start=first_color; - Main_backups->Pages->Gradients->Range[Current_gradient].End =temp_color; + Main.backups->Pages->Gradients->Range[Current_gradient].Start=first_color; + Main.backups->Pages->Gradients->Range[Current_gradient].End =temp_color; } else if (first_color>temp_color) { - Main_backups->Pages->Gradients->Range[Current_gradient].Start=temp_color; - Main_backups->Pages->Gradients->Range[Current_gradient].End =first_color; + Main.backups->Pages->Gradients->Range[Current_gradient].Start=temp_color; + Main.backups->Pages->Gradients->Range[Current_gradient].End =first_color; } else - Main_backups->Pages->Gradients->Range[Current_gradient].Start=Main_backups->Pages->Gradients->Range[Current_gradient].End=first_color; + Main.backups->Pages->Gradients->Range[Current_gradient].Start=Main.backups->Pages->Gradients->Range[Current_gradient].End=first_color; // On tagge le bloc - Tag_color_range(Main_backups->Pages->Gradients->Range[Current_gradient].Start,Main_backups->Pages->Gradients->Range[Current_gradient].End); + Tag_color_range(Main.backups->Pages->Gradients->Range[Current_gradient].Start,Main.backups->Pages->Gradients->Range[Current_gradient].End); // Tracé de la preview: Draw_gradient_preview(8,128,108,14,Current_gradient); last_color=temp_color; @@ -2696,7 +2696,7 @@ void Button_Gradients(void) case 3 : // Nouveau mélange de dégradé Hide_cursor(); // Nouvel mélange dans Window_attribute2 - Main_backups->Pages->Gradients->Range[Current_gradient].Mix=Window_attribute2; + Main.backups->Pages->Gradients->Range[Current_gradient].Mix=Window_attribute2; // On affiche la nouvelle preview Draw_gradient_preview(8,128,108,14,Current_gradient); Display_cursor(); @@ -2704,8 +2704,8 @@ void Button_Gradients(void) case 4 : // Changement de sens Hide_cursor(); // On inverse le sens (par un XOR de 1) - Main_backups->Pages->Gradients->Range[Current_gradient].Inverse^=1; - Print_in_window(12,23,(Main_backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",MC_Black,MC_Light); + Main.backups->Pages->Gradients->Range[Current_gradient].Inverse^=1; + Print_in_window(12,23,(Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",MC_Black,MC_Light); // On affiche la nouvelle preview Draw_gradient_preview(8,128,108,14,Current_gradient); Display_cursor(); @@ -2713,14 +2713,14 @@ void Button_Gradients(void) case 5 : // Changement de technique Hide_cursor(); // On change la technique par (+1)%3 - Main_backups->Pages->Gradients->Range[Current_gradient].Technique=(Main_backups->Pages->Gradients->Range[Current_gradient].Technique+1)%3; - Draw_button_gradient_style(8,90,Main_backups->Pages->Gradients->Range[Current_gradient].Technique); + Main.backups->Pages->Gradients->Range[Current_gradient].Technique=(Main.backups->Pages->Gradients->Range[Current_gradient].Technique+1)%3; + Draw_button_gradient_style(8,90,Main.backups->Pages->Gradients->Range[Current_gradient].Technique); // On affiche la nouvelle preview Draw_gradient_preview(8,128,108,14,Current_gradient); Display_cursor(); case 8 : // Speed - Main_backups->Pages->Gradients->Range[Current_gradient].Speed=Window_attribute2; - Num2str(Main_backups->Pages->Gradients->Range[Current_gradient].Speed,str,3); + Main.backups->Pages->Gradients->Range[Current_gradient].Speed=Window_attribute2; + Num2str(Main.backups->Pages->Gradients->Range[Current_gradient].Speed,str,3); Hide_cursor(); Print_in_window(73,113,str,MC_Black,MC_Light); Display_cursor(); @@ -2746,9 +2746,9 @@ void Button_Gradients(void) temp_color=color; // On met à jour l'intervalle du dégradé - first_color=last_color=Main_backups->Pages->Gradients->Range[Current_gradient].Start=Main_backups->Pages->Gradients->Range[Current_gradient].End=temp_color; + first_color=last_color=Main.backups->Pages->Gradients->Range[Current_gradient].Start=Main.backups->Pages->Gradients->Range[Current_gradient].End=temp_color; // On tagge le bloc - Tag_color_range(Main_backups->Pages->Gradients->Range[Current_gradient].Start,Main_backups->Pages->Gradients->Range[Current_gradient].End); + Tag_color_range(Main.backups->Pages->Gradients->Range[Current_gradient].Start,Main.backups->Pages->Gradients->Range[Current_gradient].End); // Tracé de la preview: Draw_gradient_preview(8,128,108,14,Current_gradient); Display_cursor(); @@ -2804,7 +2804,7 @@ void Button_Gradients(void) if (clicked_button==7) // Cancel { Current_gradient=old_current_gradient; - memcpy(Main_backups->Pages->Gradients,&backup_gradients,sizeof(T_Gradient_array)); + memcpy(Main.backups->Pages->Gradients,&backup_gradients,sizeof(T_Gradient_array)); } } @@ -3158,8 +3158,8 @@ void Load_picture(byte image) if (image) { - strcpy(filename, Main_backups->Pages->Filename); - strcpy(directory, Main_backups->Pages->File_directory); + strcpy(filename, Main.backups->Pages->Filename); + strcpy(directory, Main.backups->Pages->File_directory); Init_context_layered_image(&context, filename, directory); } else @@ -3301,7 +3301,7 @@ void Button_Load(void) { // On sauve l'état actuel des paramètres de l'image pour pouvoir les // restituer en cas d'erreur n'affectant pas l'image - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); Load_picture(1); Tilemap_update(); @@ -3315,7 +3315,7 @@ void Button_Reload(void) // On sauve l'état actuel des paramètres de l'image pour pouvoir les // restituer en cas d'erreur n'affectant pas l'image - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); if ( (!Main.image_is_modified) || Confirmation_box("Discard unsaved changes ?") ) { @@ -3329,7 +3329,7 @@ void Button_Reload(void) Original_screen_X=0; Original_screen_Y=0; - Init_context_layered_image(&context, Main_backups->Pages->Filename, Main_backups->Pages->File_directory); + Init_context_layered_image(&context, Main.backups->Pages->Filename, Main.backups->Pages->File_directory); Load_image(&context); Hide_cursor(); @@ -3406,7 +3406,7 @@ void Backup_filename(char * fname, char * backup_name) short i; strcpy(backup_name,fname); - for (i=strlen(fname)-strlen(Main_backups->Pages->Filename); backup_name[i]!='.'; i++); + for (i=strlen(fname)-strlen(Main.backups->Pages->Filename); backup_name[i]!='.'; i++); backup_name[i+1]='\0'; strcat(backup_name,"BAK"); } @@ -3417,7 +3417,7 @@ void Backup_existing_file(void) char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier char new_filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier backup - Get_full_filename(filename, Main_backups->Pages->Filename, Main_backups->Pages->File_directory); + Get_full_filename(filename, Main.backups->Pages->Filename, Main.backups->Pages->File_directory); // Calcul du nom complet du fichier backup Backup_filename(filename,new_filename); @@ -3449,8 +3449,8 @@ void Save_picture(enum CONTEXT_TYPE type) if (type == CONTEXT_MAIN_IMAGE) { - strcpy(filename, Main_backups->Pages->Filename); - strcpy(directory, Main_backups->Pages->File_directory); + strcpy(filename, Main.backups->Pages->Filename); + strcpy(directory, Main.backups->Pages->File_directory); Init_context_layered_image(&save_context, filename, directory); save_context.Format = Main.fileformat; } @@ -3464,7 +3464,7 @@ void Save_picture(enum CONTEXT_TYPE type) else if (type == CONTEXT_PALETTE) { char* dotpos; - strcpy(filename, Main_backups->Pages->Filename); + strcpy(filename, Main.backups->Pages->Filename); // Replace extension with PAL dotpos = strrchr(filename, '.'); @@ -3472,7 +3472,7 @@ void Save_picture(enum CONTEXT_TYPE type) dotpos = filename + strlen(filename); strcpy(dotpos, ".pal"); - strcpy(directory, Main_backups->Pages->File_directory); + strcpy(directory, Main.backups->Pages->File_directory); Init_context_layered_image(&save_context, filename, directory); save_context.Type = CONTEXT_PALETTE; @@ -3510,12 +3510,12 @@ void Save_picture(enum CONTEXT_TYPE type) Save_image(&save_context); format=Get_fileformat(save_context.Format); - if (!File_error && type == CONTEXT_MAIN_IMAGE && !format->Palette_only && (Main_backups->Pages->Nb_layers==1 || format->Supports_layers)) + if (!File_error && type == CONTEXT_MAIN_IMAGE && !format->Palette_only && (Main.backups->Pages->Nb_layers==1 || format->Supports_layers)) { Main.image_is_modified=0; Main.fileformat=save_context.Format; - strcpy(Main_backups->Pages->Filename, save_context.File_name); - strcpy(Main_backups->Pages->File_directory, save_context.File_directory); + strcpy(Main.backups->Pages->Filename, save_context.File_name); + strcpy(Main.backups->Pages->File_directory, save_context.File_directory); } if (type == CONTEXT_BRUSH) { @@ -3547,7 +3547,7 @@ void Button_Autosave(void) byte file_already_exists; - Get_full_filename(filename, Main_backups->Pages->Filename, Main_backups->Pages->File_directory); + Get_full_filename(filename, Main.backups->Pages->Filename, Main.backups->Pages->File_directory); file_already_exists=File_exists(filename); if ( (!file_already_exists) || Confirmation_box("Erase old file ?") ) @@ -3567,7 +3567,7 @@ void Button_Autosave(void) Cursor_shape=CURSOR_SHAPE_HOURGLASS; Display_cursor(); - Init_context_layered_image(&save_context, Main_backups->Pages->Filename, Main_backups->Pages->File_directory); + Init_context_layered_image(&save_context, Main.backups->Pages->Filename, Main.backups->Pages->File_directory); Save_image(&save_context); if (!File_error) { @@ -4557,7 +4557,7 @@ void Display_effect_states(void) Display_effect_state(C3, L2, "Snap" ,Snap_mode); Display_effect_state(C3, L4, "Tiling" ,Tiling_mode); - Display_effect_state(C2,L4, "8 bit" ,Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION); + Display_effect_state(C2,L4, "8 bit" ,Main.backups->Pages->Image_mode > IMAGE_MODE_ANIMATION); Display_effect_state(C3,L3, "Tilemap",Main.tilemap_mode); } @@ -4858,7 +4858,7 @@ void Button_Effects(void) { Button_Constraint_mode(); Hide_cursor(); - Display_effect_state(C2,L4, "8 bit" ,Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION); + Display_effect_state(C2,L4, "8 bit" ,Main.backups->Pages->Image_mode > IMAGE_MODE_ANIMATION); Display_cursor(); } else { Close_window(); @@ -5613,5 +5613,5 @@ void Button_Brush_container(void) byte Any_effect_active(void) { return Shade_mode||Quick_shade_mode||Colorize_mode||Smooth_mode||Tiling_mode||Smear_mode - ||Stencil_mode||Mask_mode||Sieve_mode||Snap_mode||Main.tilemap_mode || (Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION); + ||Stencil_mode||Mask_mode||Sieve_mode||Snap_mode||Main.tilemap_mode || (Main.backups->Pages->Image_mode > IMAGE_MODE_ANIMATION); } diff --git a/src/buttons_effects.c b/src/buttons_effects.c index bd1db6fe..0b4a98d9 100644 --- a/src/buttons_effects.c +++ b/src/buttons_effects.c @@ -170,7 +170,7 @@ void Button_Constraint_mode() { int pixel; - if (Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode > IMAGE_MODE_ANIMATION) { // Disable Switch_layer_mode(IMAGE_MODE_LAYERED); @@ -182,15 +182,15 @@ void Button_Constraint_mode() if (Selected_Constraint_Mode == IMAGE_MODE_MODE5) { - if (Main_backups->Pages->Image_mode != IMAGE_MODE_LAYERED || - Main_backups->Pages->Nb_layers!=5 || (Main.image_width%48)) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_LAYERED || + Main.backups->Pages->Nb_layers!=5 || (Main.image_width%48)) { Verbose_message("Error!", "This emulation of Amstrad CPC's Mode5 can only be used on a 5-layer image whose width is a multiple of 48."); return; } for (pixel=0; pixel < Main.image_width*Main.image_height; pixel++) { - if (Main_backups->Pages->Image[4].Pixels[pixel]>3) + if (Main.backups->Pages->Image[4].Pixels[pixel]>3) { Verbose_message("Error!", "This emulation of Amstrad CPC's Mode5 needs all pixels of layer 5 to use colors 0-3."); return; @@ -239,7 +239,7 @@ void Button_Constraint_menu(void) if (clicked_button==2) // OK { if ((Selected_Constraint_Mode > IMAGE_MODE_ANIMATION) - && (Main_backups->Pages->Image_mode <= IMAGE_MODE_ANIMATION)) + && (Main.backups->Pages->Image_mode <= IMAGE_MODE_ANIMATION)) Button_Constraint_mode(); } diff --git a/src/engine.c b/src/engine.c index e9efd50a..1db94045 100644 --- a/src/engine.c +++ b/src/engine.c @@ -584,7 +584,7 @@ void Layer_preview_on(int * preview_is_visible) { int x,y; short layer; - short layercount = Main_backups->Pages->Nb_layers; + short layercount = Main.backups->Pages->Nb_layers; static int previewW=0, previewH=0; if (! *preview_is_visible && layercount>1) @@ -623,7 +623,7 @@ void Layer_preview_on(int * preview_is_visible) int imgx = x * Main.image_width / (previewW*Pixel_width*Menu_factor_X-1); int imgy = y * Main.image_height / (previewH*Pixel_height*Menu_factor_Y-1); // Use Pixel_simple() in order to get highest resolution - Pixel_simple(x+((layer*Layer_button_width+offset)*Menu_factor_X+Window_pos_X)*Pixel_width, y+Window_pos_Y*Pixel_height+1, *(Main_backups->Pages->Image[layer].Pixels + Pixel_simple(x+((layer*Layer_button_width+offset)*Menu_factor_X+Window_pos_X)*Pixel_width, y+Window_pos_Y*Pixel_height+1, *(Main.backups->Pages->Image[layer].Pixels + imgx + imgy * Main.image_width)); } } @@ -685,7 +685,7 @@ void Main_handler(void) char* flimit; byte old_cursor_shape; - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); flimit = Find_last_separator(Drop_file_name); *(flimit++) = '\0'; @@ -3646,7 +3646,7 @@ void Set_bar_visibility(word bar, int visible, int with_redraw) /// Display_menu() and Display_all_screen() int Check_menu_mode(void) { - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { if (Menu_bars[MENUBAR_LAYERS].Visible) { diff --git a/src/factory.c b/src/factory.c index e4b70886..1ddcb62a 100644 --- a/src/factory.c +++ b/src/factory.c @@ -218,7 +218,7 @@ void Backup_if_necessary(lua_State* L, int layer) Is_backed_up = 1; if (layer == Main.current_layer) { - Main_backup_page = Main_backups->Pages->Next; + Main_backup_page = Main.backups->Pages->Next; Main_backup_screen = Screen_backup; Register_main_writable(L); } @@ -230,7 +230,7 @@ void Backup_if_necessary(lua_State* L, int layer) // Already OK return; } - if (Dup_layer_if_shared(Main_backups->Pages, layer)) + if (Dup_layer_if_shared(Main.backups->Pages, layer)) { // Depth buffer etc to modify too ? @@ -391,17 +391,17 @@ int L_SetPictureSize(lua_State* L) Backup_with_new_dimensions(w, h); } // part of Resize_image() : the pixel copy part. - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { Copy_part_of_image_to_another( - Main_backups->Pages->Next->Image[i].Pixels,0,0,Min(Main_backups->Pages->Next->Width,Main.image_width), - Min(Main_backups->Pages->Next->Height,Main.image_height),Main_backups->Pages->Next->Width, - Main_backups->Pages->Image[i].Pixels,0,0,Main.image_width); + Main.backups->Pages->Next->Image[i].Pixels,0,0,Min(Main.backups->Pages->Next->Width,Main.image_width), + Min(Main.backups->Pages->Next->Height,Main.image_height),Main.backups->Pages->Next->Width, + Main.backups->Pages->Image[i].Pixels,0,0,Main.image_width); } Redraw_layered_image(); Is_backed_up = 1; - Main_backup_page = Main_backups->Pages->Next; + Main_backup_page = Main.backups->Pages->Next; Main_backup_screen = Screen_backup; Register_main_writable(L); lua_register(L,"setcolor",L_SetColor); @@ -424,12 +424,12 @@ int L_SetSparePictureSize(lua_State* L) Backup_and_resize_the_spare(w, h); // part of Resize_image() : the pixel copy part. - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { Copy_part_of_image_to_another( - Spare_backups->Pages->Next->Image[i].Pixels,0,0,Min(Spare_backups->Pages->Next->Width,Spare.image_width), - Min(Spare_backups->Pages->Next->Height,Spare.image_height),Spare_backups->Pages->Next->Width, - Spare_backups->Pages->Image[i].Pixels,0,0,Spare.image_width); + Spare.backups->Pages->Next->Image[i].Pixels,0,0,Min(Spare.backups->Pages->Next->Width,Spare.image_width), + Min(Spare.backups->Pages->Next->Height,Spare.image_height),Spare.backups->Pages->Next->Width, + Spare.backups->Pages->Image[i].Pixels,0,0,Spare.image_width); } Redraw_spare_image(); @@ -660,7 +660,7 @@ int L_GetPicturePixel(lua_State* L) if (x<0 || y<0 || x>=Main.image_width || y>=Main.image_height) { // Silently return the image's transparent color - lua_pushinteger(L, Main_backups->Pages->Transparent_color); + lua_pushinteger(L, Main.backups->Pages->Transparent_color); return 1; } lua_pushinteger(L, Read_pixel_from_current_screen(x,y)); @@ -705,7 +705,7 @@ int L_GetLayerPixel(lua_State* L) if (x<0 || y<0 || x>=Main.image_width || y>=Main.image_height) { // Silently return the image's transparent color - lua_pushinteger(L, Main_backups->Pages->Transparent_color); + lua_pushinteger(L, Main.backups->Pages->Transparent_color); return 1; } lua_pushinteger(L, Read_pixel_from_current_layer(x,y)); @@ -735,10 +735,10 @@ int L_GetSpareLayerPixel(lua_State* L) if (x<0 || y<0 || x>=Spare.image_width || y>=Spare.image_height) { // Silently return the image's transparent color - lua_pushinteger(L, Spare_backups->Pages->Transparent_color); + lua_pushinteger(L, Spare.backups->Pages->Transparent_color); return 1; } - lua_pushinteger(L, *(Spare_backups->Pages->Image[Spare.current_layer].Pixels + y*Spare.image_width + x)); + lua_pushinteger(L, *(Spare.backups->Pages->Image[Spare.current_layer].Pixels + y*Spare.image_width + x)); return 1; } @@ -756,7 +756,7 @@ int L_GetSparePicturePixel(lua_State* L) if (x<0 || y<0) { // Silently return the image's transparent color - lua_pushinteger(L, Spare_backups->Pages->Transparent_color); + lua_pushinteger(L, Spare.backups->Pages->Transparent_color); return 1; } lua_pushinteger(L, Read_pixel_from_spare_screen(x,y)); @@ -779,7 +779,7 @@ int L_GetSpareColor(lua_State* L) int L_GetSpareTransColor(lua_State* L) { - lua_pushinteger(L, Spare_backups->Pages->Transparent_color); + lua_pushinteger(L, Spare.backups->Pages->Transparent_color); return 1; } @@ -949,7 +949,7 @@ int L_GetBackColor(lua_State* L) int L_GetTransColor(lua_State* L) { - lua_pushinteger(L, Main_backups->Pages->Transparent_color); + lua_pushinteger(L, Main.backups->Pages->Transparent_color); return 1; } @@ -1893,7 +1893,7 @@ int L_GetLayerCount(lua_State* L) LUA_ARG_LIMIT (0, "layercount"); - lua_pushinteger(L, Main_backups->Pages->Nb_layers); + lua_pushinteger(L, Main.backups->Pages->Nb_layers); return 1; } @@ -1904,7 +1904,7 @@ int L_GetSpareLayerCount(lua_State* L) LUA_ARG_LIMIT (0, "layercount"); - lua_pushinteger(L, Spare_backups->Pages->Nb_layers); + lua_pushinteger(L, Spare.backups->Pages->Nb_layers); return 1; } @@ -1914,9 +1914,9 @@ int L_SelectSpareLayer(lua_State* L) int nb_args=lua_gettop(L); LUA_ARG_LIMIT (1, "selectsparelayer"); - LUA_ARG_NUMBER(1, "selectsparelayer", Spare.current_layer, 0, Spare_backups->Pages->Nb_layers - 1); + LUA_ARG_NUMBER(1, "selectsparelayer", Spare.current_layer, 0, Spare.backups->Pages->Nb_layers - 1); - if (Spare_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Spare.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { if (! ((1 << Spare.current_layer) & Spare.layers_visible)) { @@ -1932,11 +1932,11 @@ int L_SelectLayer(lua_State* L) int nb_args=lua_gettop(L); LUA_ARG_LIMIT (1, "selectlayer"); - LUA_ARG_NUMBER(1, "selectlayer", Main.current_layer, 0, Main_backups->Pages->Nb_layers - 1); + LUA_ARG_NUMBER(1, "selectlayer", Main.current_layer, 0, Main.backups->Pages->Nb_layers - 1); Backup_if_necessary(L, Main.current_layer); // - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { if (! ((1 << Main.current_layer) & Main.layers_visible)) { @@ -1965,7 +1965,7 @@ int L_FinalizePicture(lua_State* L) End_of_modification(); } Is_backed_up = 0; - Main_backup_page = Main_backups->Pages; + Main_backup_page = Main.backups->Pages; Main_backup_screen = Main_screen; Register_main_readonly(L); lua_register(L,"setcolor",L_SetColor_unsaved); @@ -1980,8 +1980,8 @@ int L_GetFileName(lua_State* L) LUA_ARG_LIMIT (0, "getfilename"); - lua_pushstring(L, Main_backups->Pages->Filename); - lua_pushstring(L, Main_backups->Pages->File_directory); + lua_pushstring(L, Main.backups->Pages->Filename); + lua_pushstring(L, Main.backups->Pages->File_directory); return 2; } @@ -2428,7 +2428,7 @@ void Run_script(const char *script_subdirectory, const char *script_filename) // like a feedback off effect (convolution matrix comes to mind). //Backup(); Is_backed_up = 0; - Main_backup_page = Main_backups->Pages; + Main_backup_page = Main.backups->Pages; Main_backup_screen = Main_screen; Backup_the_spare(LAYER_ALL); diff --git a/src/fileformats.c b/src/fileformats.c index b35cfb8f..e92e6ee3 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -766,7 +766,7 @@ void Load_IFF(T_IO_Context * context) if (context->Type == CONTEXT_MAIN_IMAGE) { - Main_backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; + Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; Update_screen_targets(); } if (File_error==0) @@ -2639,7 +2639,7 @@ void Load_GIF(T_IO_Context * context) // Load as an animation if (context->Type == CONTEXT_MAIN_IMAGE) { - Main_backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; + Main.backups->Pages->Image_mode = IMAGE_MODE_ANIMATION; Update_screen_targets(); } // Skip sub-block @@ -2756,13 +2756,13 @@ void Load_GIF(T_IO_Context * context) // Attempt to add a layer to current image current_layer++; Set_loading_layer(context, current_layer); - if (context->Type == CONTEXT_MAIN_IMAGE && Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (context->Type == CONTEXT_MAIN_IMAGE && Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { // Copy the content of previous layer. memcpy( - Main_backups->Pages->Image[Main.current_layer].Pixels, - Main_backups->Pages->Image[Main.current_layer-1].Pixels, - Main_backups->Pages->Width*Main_backups->Pages->Height); + Main.backups->Pages->Image[Main.current_layer].Pixels, + Main.backups->Pages->Image[Main.current_layer-1].Pixels, + Main.backups->Pages->Width*Main.backups->Pages->Height); } else { @@ -2812,7 +2812,7 @@ void Load_GIF(T_IO_Context * context) if (number_LID!=1) { // This a second layer/frame, or more. - if (context->Type == CONTEXT_MAIN_IMAGE && Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (context->Type == CONTEXT_MAIN_IMAGE && Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { // Need to clear previous image to back-color. if (previous_disposal_method==DISPOSAL_METHOD_RESTORE_BGCOLOR) @@ -2820,8 +2820,8 @@ void Load_GIF(T_IO_Context * context) int y; for (y=0; yPages->Image[Main.current_layer].Pixels - + (previous_pos_y+y)* Main_backups->Pages->Width+previous_pos_x, + Main.backups->Pages->Image[Main.current_layer].Pixels + + (previous_pos_y+y)* Main.backups->Pages->Width+previous_pos_x, is_transparent ? context->Transparent_color : LSDB.Backcol, previous_width); } @@ -3152,7 +3152,7 @@ void Save_GIF(T_IO_Context * context) // Write_bytes(GIF_file,"\x21\xFF\x0BNETSCAPE2.0\x03\xLL\xSS\xSS\x00",19); // LL : 01 to loop // SSSS : number of loops - if (context->Type == CONTEXT_MAIN_IMAGE && Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (context->Type == CONTEXT_MAIN_IMAGE && Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) if (context->Nb_layers>1) Write_bytes(GIF_file,"\x21\xFF\x0BNETSCAPE2.0\x03\x01\x00\x00\x00",19); @@ -3198,7 +3198,7 @@ void Save_GIF(T_IO_Context * context) GCE.Function = 0xF9; GCE.Block_size=4; - if (context->Type == CONTEXT_MAIN_IMAGE && Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (context->Type == CONTEXT_MAIN_IMAGE && Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { // Animation frame int duration; diff --git a/src/global.h b/src/global.h index c8fe17db..e6c66dff 100644 --- a/src/global.h +++ b/src/global.h @@ -407,9 +407,9 @@ GFX2_GLOBAL byte Spare_safety_backup_prefix; /// Backup of the current screen, used during drawing when FX feedback is OFF. GFX2_GLOBAL byte * Screen_backup; /// List of backup pages for the main image. -GFX2_GLOBAL T_List_of_pages * Main_backups;//TODO +//GFX2_GLOBAL T_List_of_pages * Main_backups; /// List of backup pages for the spare page. -GFX2_GLOBAL T_List_of_pages * Spare_backups;//TODO +//GFX2_GLOBAL T_List_of_pages * Spare_backups; // -- Brush data diff --git a/src/graph.c b/src/graph.c index d537cc6d..aa255a93 100644 --- a/src/graph.c +++ b/src/graph.c @@ -532,7 +532,7 @@ void Resize_image(word chosen_width,word chosen_height) // |B| | C = Nouvelle image // +-+-+ - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); if (Backup_with_new_dimensions(chosen_width,chosen_height)) { // La nouvelle page a pu être allouée, elle est pour l'instant pleine de @@ -541,12 +541,12 @@ void Resize_image(word chosen_width,word chosen_height) Main.image_is_modified=1; // On copie donc maintenant la partie C dans la nouvelle image. - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { Copy_part_of_image_to_another( - Main_backups->Pages->Next->Image[i].Pixels,0,0,Min(old_width,Main.image_width), + Main.backups->Pages->Next->Image[i].Pixels,0,0,Min(old_width,Main.image_width), Min(old_height,Main.image_height),old_width, - Main_backups->Pages->Image[i].Pixels,0,0,Main.image_width); + Main.backups->Pages->Image[i].Pixels,0,0,Main.image_width); } Redraw_layered_image(); } @@ -574,10 +574,10 @@ void Remap_spare(void) used[color]=0; // On calcule la table d'utilisation des couleurs - for (layer=0; layerPages->Nb_layers; layer++) + for (layer=0; layerPages->Nb_layers; layer++) for (y_pos=0;y_posPages->Image[layer].Pixels+(y_pos*Spare.image_width+x_pos))]=1; + used[*(Spare.backups->Pages->Image[layer].Pixels+(y_pos*Spare.image_width+x_pos))]=1; // On va maintenant se servir de la table "used" comme table de // conversion: pour chaque indice, la table donne une couleur de @@ -593,11 +593,11 @@ void Remap_spare(void) // Maintenant qu'on a une super table de conversion qui n'a que le nom // qui craint un peu, on peut faire l'échange dans la brosse de toutes les // teintes. - for (layer=0; layerPages->Nb_layers; layer++) - Remap_general_lowlevel(used,Spare_backups->Pages->Image[layer].Pixels,Spare_backups->Pages->Image[layer].Pixels,Spare.image_width,Spare.image_height,Spare.image_width); + for (layer=0; layerPages->Nb_layers; layer++) + Remap_general_lowlevel(used,Spare.backups->Pages->Image[layer].Pixels,Spare.backups->Pages->Image[layer].Pixels,Spare.image_width,Spare.image_height,Spare.image_width); // Change transparent color index - Spare_backups->Pages->Transparent_color=used[Spare_backups->Pages->Transparent_color]; + Spare.backups->Pages->Transparent_color=used[Spare.backups->Pages->Transparent_color]; } @@ -891,7 +891,7 @@ void Fill(short * top_reached , short * bottom_reached, byte Read_pixel_from_backup_layer(word x,word y) { - return *((y)*Main.image_width+(x)+Main_backups->Pages->Next->Image[Main.current_layer].Pixels); + return *((y)*Main.image_width+(x)+Main.backups->Pages->Next->Image[Main.current_layer].Pixels); } void Fill_general(byte fill_color) @@ -973,34 +973,34 @@ void Fill_general(byte fill_color) // Il va maintenant falloir qu'on "turn" ce gros caca "into" un truc qui // ressemble un peu plus à ce à quoi l'utilisateur peut s'attendre. if (top_reached>Limit_top) - Copy_part_of_image_to_another(Main_backups->Pages->Next->Image[Main.current_layer].Pixels, // source + Copy_part_of_image_to_another(Main.backups->Pages->Next->Image[Main.current_layer].Pixels, // source Limit_left,Limit_top, // Pos X et Y dans source (Limit_right-Limit_left)+1, // width copie top_reached-Limit_top,// height copie Main.image_width, // width de la source - Main_backups->Pages->Image[Main.current_layer].Pixels, // Destination + Main.backups->Pages->Image[Main.current_layer].Pixels, // Destination Limit_left,Limit_top, // Pos X et Y destination Main.image_width); // width destination if (bottom_reachedPages->Next->Image[Main.current_layer].Pixels, + Copy_part_of_image_to_another(Main.backups->Pages->Next->Image[Main.current_layer].Pixels, Limit_left,bottom_reached+1, (Limit_right-Limit_left)+1, Limit_bottom-bottom_reached, - Main.image_width,Main_backups->Pages->Image[Main.current_layer].Pixels, + Main.image_width,Main.backups->Pages->Image[Main.current_layer].Pixels, Limit_left,bottom_reached+1,Main.image_width); if (left_reached>Limit_left) - Copy_part_of_image_to_another(Main_backups->Pages->Next->Image[Main.current_layer].Pixels, + Copy_part_of_image_to_another(Main.backups->Pages->Next->Image[Main.current_layer].Pixels, Limit_left,top_reached, left_reached-Limit_left, (bottom_reached-top_reached)+1, - Main.image_width,Main_backups->Pages->Image[Main.current_layer].Pixels, + Main.image_width,Main.backups->Pages->Image[Main.current_layer].Pixels, Limit_left,top_reached,Main.image_width); if (right_reachedPages->Next->Image[Main.current_layer].Pixels, + Copy_part_of_image_to_another(Main.backups->Pages->Next->Image[Main.current_layer].Pixels, right_reached+1,top_reached, Limit_right-right_reached, (bottom_reached-top_reached)+1, - Main.image_width,Main_backups->Pages->Image[Main.current_layer].Pixels, + Main.image_width,Main.backups->Pages->Image[Main.current_layer].Pixels, right_reached+1,top_reached,Main.image_width); // Restore image limits : this is needed by the tilemap effect, @@ -2901,9 +2901,9 @@ byte Effect_smooth(word x,word y,byte color) byte Effect_layer_copy(word x,word y,byte color) { - if (colorPages->Nb_layers) + if (colorPages->Nb_layers) { - return *((y)*Main.image_width+(x)+Main_backups->Pages->Image[color].Pixels); + return *((y)*Main.image_width+(x)+Main.backups->Pages->Image[color].Pixels); } return Read_pixel_from_feedback_screen(x,y); } @@ -2952,33 +2952,33 @@ byte Read_pixel_from_current_screen (word x,word y) byte depth; byte color; - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { - return *((y)*Main.image_width+(x)+Main_backups->Pages->Image[Main.current_layer].Pixels); + return *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels); } - if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5) + 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); + return *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width); color = *(Main_screen+y*Main.image_width+x); - if (color != Main_backups->Pages->Transparent_color) // transparent color + if (color != Main.backups->Pages->Transparent_color) // transparent color return color; depth = *(Main_visible_image_depth_buffer.Image+x+y*Main.image_width); - return *(Main_backups->Pages->Image[depth].Pixels + x+y*Main.image_width); + return *(Main.backups->Pages->Image[depth].Pixels + x+y*Main.image_width); } /// Paint a a single pixel in image only : as-is. void Pixel_in_screen_direct(word x,word y,byte color) { - *((y)*Main.image_width+(x)+Main_backups->Pages->Image[Main.current_layer].Pixels)=color; + *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels)=color; } /// Paint a a single pixel in image and on screen: as-is. void Pixel_in_screen_direct_with_preview(word x,word y,byte color) { - *((y)*Main.image_width+(x)+Main_backups->Pages->Image[Main.current_layer].Pixels)=color; + *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels)=color; Pixel_preview(x,y,color); } @@ -2986,12 +2986,12 @@ void Pixel_in_screen_direct_with_preview(word x,word y,byte color) void Pixel_in_screen_layered(word x,word y,byte color) { byte depth = *(Main_visible_image_depth_buffer.Image+x+y*Main.image_width); - *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; + *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; if ( depth <= Main.current_layer) { - if (color == Main_backups->Pages->Transparent_color) // transparent color + if (color == Main.backups->Pages->Transparent_color) // transparent color // fetch pixel color from the topmost visible layer - color=*(Main_backups->Pages->Image[depth].Pixels + x+y*Main.image_width); + color=*(Main.backups->Pages->Image[depth].Pixels + x+y*Main.image_width); *(x+y*Main.image_width+Main_screen)=color; } @@ -3001,12 +3001,12 @@ void Pixel_in_screen_layered(word x,word y,byte color) void Pixel_in_screen_layered_with_preview(word x,word y,byte color) { byte depth = *(Main_visible_image_depth_buffer.Image+x+y*Main.image_width); - *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; + *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; if ( depth <= Main.current_layer) { - if (color == Main_backups->Pages->Transparent_color) // transparent color + if (color == Main.backups->Pages->Transparent_color) // transparent color // fetch pixel color from the topmost visible layer - color=*(Main_backups->Pages->Image[depth].Pixels + x+y*Main.image_width); + color=*(Main.backups->Pages->Image[depth].Pixels + x+y*Main.image_width); *(x+y*Main.image_width+Main_screen)=color; @@ -3017,7 +3017,7 @@ void Pixel_in_screen_layered_with_preview(word x,word y,byte color) void Pixel_in_screen_egx(word x,word y,byte color) { uint8_t mask; - if (Main_backups->Pages->Image_mode == IMAGE_MODE_EGX) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_EGX) { mask = 0xF3; } else { @@ -3036,7 +3036,7 @@ void Pixel_in_screen_egx(word x,word y,byte color) void Pixel_in_screen_egx_with_preview(word x,word y,byte color) { uint8_t mask; - if (Main_backups->Pages->Image_mode == IMAGE_MODE_EGX) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_EGX) { mask = 0xF3; } else { @@ -3059,14 +3059,14 @@ void Pixel_in_screen_thomson(word x,word y,byte color) uint8_t c1, c2; // The color we are going to replace - c1 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width); + c1 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width); if (c1 == color) return; for (x2 = 0; x2 < 8; x2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); if (c2 == color) continue; if (c2 != c1) @@ -3082,7 +3082,7 @@ void Pixel_in_screen_thomson(word x,word y,byte color) for (x2 = 0; x2 < 8; x2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); if (c2 == c1) { Pixel_in_screen_layered(x2+start,y,color); } @@ -3096,14 +3096,14 @@ void Pixel_in_screen_thomson_with_preview(word x,word y,byte color) uint8_t c1, c2; // The color we are going to replace - c1 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width); + c1 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width); if (c1 == color) return; for (x2 = 0; x2 < 8; x2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); if (c2 == color) continue; if (c2 != c1) @@ -3119,7 +3119,7 @@ void Pixel_in_screen_thomson_with_preview(word x,word y,byte color) for (x2 = 0; x2 < 8; x2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2+start)+y*Main.image_width); if (c2 == c1) { Pixel_in_screen_layered_with_preview(x2+start,y,color); } @@ -3134,7 +3134,7 @@ void Pixel_in_screen_zx(word x,word y,byte color) uint8_t c1, c2; // The color we are going to replace - c1 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + c1 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + x + y * Main.image_width); if (c1 == color) @@ -3144,7 +3144,7 @@ void Pixel_in_screen_zx(word x,word y,byte color) for (x2 = 0; x2 < 8; x2++) for (y2 = 0; y2 < 8; y2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2 + start) + (y2 + starty) * Main.image_width); // Pixel is already of the color we are going to add, it is no problem if (c2 == color) @@ -3177,7 +3177,7 @@ done: for (x2 = 0; x2 < 8; x2++) for (y2 = 0; y2 < 8; y2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2 + start) + (y2 + starty) * Main.image_width); if (c2 == c1) { Pixel_in_screen_layered(x2+start,y2+starty,color); @@ -3196,7 +3196,7 @@ void Pixel_in_screen_zx_with_preview(word x,word y,byte color) uint8_t c1, c2; // The color we are going to replace - c1 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + c1 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + x + y * Main.image_width); // Pixel is already of the wanted color: nothing to do @@ -3207,7 +3207,7 @@ void Pixel_in_screen_zx_with_preview(word x,word y,byte color) for (x2 = 0; x2 < 8; x2++) for (y2 = 0; y2 < 8; y2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2 + start) + (y2 + starty) * Main.image_width); // Pixel is already of the color we are going to add, it is no problem if (c2 == color) @@ -3240,7 +3240,7 @@ done: for (x2 = 0; x2 < 8; x2++) for (y2 = 0; y2 < 8; y2++) { - c2 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + c2 = *(Main.backups->Pages->Image[Main.current_layer].Pixels + (x2 + start) + (y2 + starty) * Main.image_width); if (c2 == c1) { Pixel_in_screen_layered_with_preview(x2+start,y2+starty,color); @@ -3257,9 +3257,9 @@ void Pixel_in_screen_underlay(word x,word y,byte color) byte depth; // Paste in layer - *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; + *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; // Search depth - depth = *(Main_backups->Pages->Image[4].Pixels + x+y*Main.image_width); + depth = *(Main.backups->Pages->Image[4].Pixels + x+y*Main.image_width); if ( depth == Main.current_layer) { @@ -3274,9 +3274,9 @@ void Pixel_in_screen_underlay_with_preview(word x,word y,byte color) byte depth; // Paste in layer - *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; + *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; // Search depth - depth = *(Main_backups->Pages->Image[4].Pixels + x+y*Main.image_width); + depth = *(Main.backups->Pages->Image[4].Pixels + x+y*Main.image_width); if ( depth == Main.current_layer) { @@ -3293,12 +3293,12 @@ void Pixel_in_screen_overlay(word x,word y,byte color) if (color<4) { // Paste in layer - *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; + *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; // Paste in depth buffer *(Main_visible_image_depth_buffer.Image+x+y*Main.image_width)=color; // Fetch pixel color from the target raster layer if (Main.layers_visible & (1 << color)) - color=*(Main_backups->Pages->Image[color].Pixels + x+y*Main.image_width); + color=*(Main.backups->Pages->Image[color].Pixels + x+y*Main.image_width); // Draw that color on the visible image buffer *(x+y*Main.image_width+Main_screen)=color; } @@ -3310,12 +3310,12 @@ void Pixel_in_screen_overlay_with_preview(word x,word y,byte color) if (color<4) { // Paste in layer - *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; + *(Main.backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width)=color; // Paste in depth buffer *(Main_visible_image_depth_buffer.Image+x+y*Main.image_width)=color; // Fetch pixel color from the target raster layer if (Main.layers_visible & (1 << color)) - color=*(Main_backups->Pages->Image[color].Pixels + x+y*Main.image_width); + color=*(Main.backups->Pages->Image[color].Pixels + x+y*Main.image_width); // Draw that color on the visible image buffer *(x+y*Main.image_width+Main_screen)=color; @@ -3328,50 +3328,50 @@ Func_pixel Pixel_in_current_screen_with_preview=Pixel_in_screen_direct_with_prev void Pixel_in_spare(word x,word y, byte color) { - *((y)*Spare.image_width+(x)+Spare_backups->Pages->Image[Spare.current_layer].Pixels)=color; + *((y)*Spare.image_width+(x)+Spare.backups->Pages->Image[Spare.current_layer].Pixels)=color; } void Pixel_in_current_layer(word x,word y, byte color) { - *((y)*Main.image_width+(x)+Main_backups->Pages->Image[Main.current_layer].Pixels)=color; + *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels)=color; } byte Read_pixel_from_current_layer(word x,word y) { - return *((y)*Main.image_width+(x)+Main_backups->Pages->Image[Main.current_layer].Pixels); + return *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels); } void Update_pixel_renderer(void) { - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { // direct Pixel_in_current_screen = Pixel_in_screen_direct; Pixel_in_current_screen_with_preview = Pixel_in_screen_direct_with_preview; } else - if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED) + 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; } else - if (Main_backups->Pages->Image_mode == IMAGE_MODE_EGX - || Main_backups->Pages->Image_mode == IMAGE_MODE_EGX2) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_EGX + || Main.backups->Pages->Image_mode == IMAGE_MODE_EGX2) { // special "EGX" mode Pixel_in_current_screen = Pixel_in_screen_egx; Pixel_in_current_screen_with_preview = Pixel_in_screen_egx_with_preview; } else - if (Main_backups->Pages->Image_mode == IMAGE_MODE_THOMSON) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_THOMSON) { Pixel_in_current_screen = Pixel_in_screen_thomson; Pixel_in_current_screen_with_preview = Pixel_in_screen_thomson_with_preview; } else - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ZX) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ZX) { Pixel_in_current_screen = Pixel_in_screen_zx; Pixel_in_current_screen_with_preview = Pixel_in_screen_zx_with_preview; diff --git a/src/input.c b/src/input.c index 1ed2c83c..61e068c1 100644 --- a/src/input.c +++ b/src/input.c @@ -1091,13 +1091,13 @@ int Color_cycling(void) { int len; - len=Main_backups->Pages->Gradients->Range[i].End-Main_backups->Pages->Gradients->Range[i].Start+1; - if (len>1 && Main_backups->Pages->Gradients->Range[i].Speed) + len=Main.backups->Pages->Gradients->Range[i].End-Main.backups->Pages->Gradients->Range[i].Start+1; + if (len>1 && Main.backups->Pages->Gradients->Range[i].Speed) { int new_offset; - new_offset=(now-start)/(int)(1000.0/(Main_backups->Pages->Gradients->Range[i].Speed*0.2856)) % len; - if (!Main_backups->Pages->Gradients->Range[i].Inverse) + new_offset=(now-start)/(int)(1000.0/(Main.backups->Pages->Gradients->Range[i].Speed*0.2856)) % len; + if (!Main.backups->Pages->Gradients->Range[i].Inverse) new_offset=len - new_offset; if (new_offset!=offset[i]) @@ -1118,14 +1118,15 @@ int Color_cycling(void) { int len; - len=Main_backups->Pages->Gradients->Range[i].End-Main_backups->Pages->Gradients->Range[i].Start+1; - if (len>1 && Main_backups->Pages->Gradients->Range[i].Speed) + // TODO improve + len=Main.backups->Pages->Gradients->Range[i].End-Main.backups->Pages->Gradients->Range[i].Start+1; + if (len>1 && Main.backups->Pages->Gradients->Range[i].Speed) { - for(color=Main_backups->Pages->Gradients->Range[i].Start;color<=Main_backups->Pages->Gradients->Range[i].End;color++) + for(color=Main.backups->Pages->Gradients->Range[i].Start;color<=Main.backups->Pages->Gradients->Range[i].End;color++) { - PaletteSDL[color].r=Main.palette[Main_backups->Pages->Gradients->Range[i].Start+((color-Main_backups->Pages->Gradients->Range[i].Start+offset[i])%len)].R; - PaletteSDL[color].g=Main.palette[Main_backups->Pages->Gradients->Range[i].Start+((color-Main_backups->Pages->Gradients->Range[i].Start+offset[i])%len)].G; - PaletteSDL[color].b=Main.palette[Main_backups->Pages->Gradients->Range[i].Start+((color-Main_backups->Pages->Gradients->Range[i].Start+offset[i])%len)].B; + PaletteSDL[color].r=Main.palette[Main.backups->Pages->Gradients->Range[i].Start+((color-Main.backups->Pages->Gradients->Range[i].Start+offset[i])%len)].R; + PaletteSDL[color].g=Main.palette[Main.backups->Pages->Gradients->Range[i].Start+((color-Main.backups->Pages->Gradients->Range[i].Start+offset[i])%len)].G; + PaletteSDL[color].b=Main.palette[Main.backups->Pages->Gradients->Range[i].Start+((color-Main.backups->Pages->Gradients->Range[i].Start+offset[i])%len)].B; } } } diff --git a/src/layers.c b/src/layers.c index 9382335b..4f8fd8bc 100644 --- a/src/layers.c +++ b/src/layers.c @@ -36,13 +36,13 @@ void Layer_activate(int layer, short side) { dword old_layers; - if (layer >= Main_backups->Pages->Nb_layers) + if (layer >= Main.backups->Pages->Nb_layers) return; // Keep a copy of which layers were visible old_layers = Main.layers_visible; - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { if (side == RIGHT_SIDE) { @@ -92,7 +92,7 @@ void Layer_activate(int layer, short side) Redraw_layered_image(); else Update_depth_buffer(); // Only need the depth buffer - //Download_infos_page_main(Main_backups->Pages); + //Download_infos_page_main(Main.backups->Pages); //Update_FX_feedback(Config.FX_Feedback); Update_pixel_renderer(); Display_all_screen(); @@ -106,11 +106,11 @@ void Button_Layer_add(void) Hide_cursor(); - if (Main_backups->Pages->Nb_layers < max[Main_backups->Pages->Image_mode]) + if (Main.backups->Pages->Nb_layers < max[Main.backups->Pages->Image_mode]) { // Backup with unchanged layers Backup_layers(LAYER_NONE); - if (!Add_layer(Main_backups,Main.current_layer+1)) + if (!Add_layer(Main.backups,Main.current_layer+1)) { Update_depth_buffer(); // I just noticed this might be unneeded, since the new layer @@ -133,19 +133,19 @@ void Button_Layer_duplicate(void) Hide_cursor(); - if (Main_backups->Pages->Nb_layers < max[Main_backups->Pages->Image_mode]) + if (Main.backups->Pages->Nb_layers < max[Main.backups->Pages->Image_mode]) { // Backup with unchanged layers Backup_layers(LAYER_NONE); - if (!Add_layer(Main_backups,Main.current_layer+1)) + if (!Add_layer(Main.backups,Main.current_layer+1)) { // Make a copy of current image memcpy( - Main_backups->Pages->Image[Main.current_layer].Pixels, - Main_backups->Pages->Image[Main.current_layer-1].Pixels, - Main_backups->Pages->Width*Main_backups->Pages->Height); + Main.backups->Pages->Image[Main.current_layer].Pixels, + Main.backups->Pages->Image[Main.current_layer-1].Pixels, + Main.backups->Pages->Width*Main.backups->Pages->Height); - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { Update_depth_buffer(); // I just noticed this might be unneeded, since the new layer // is transparent, it shouldn't have any visible effect. @@ -165,11 +165,11 @@ void Button_Layer_remove(void) { Hide_cursor(); - if (Main_backups->Pages->Nb_layers > 1) + if (Main.backups->Pages->Nb_layers > 1) { // Backup with unchanged layers Backup_layers(LAYER_NONE); - if (!Delete_layer(Main_backups,Main.current_layer)) + if (!Delete_layer(Main.backups,Main.current_layer)) { Update_screen_targets(); Redraw_layered_image(); @@ -194,8 +194,8 @@ short Layer_under_mouse(void) // Safety required because the mouse cursor can have slided outside button. if (layer < 0) layer=0; - else if (layer > Main_backups->Pages->Nb_layers-1) - layer=Main_backups->Pages->Nb_layers-1; + else if (layer > Main.backups->Pages->Nb_layers-1) + layer=Main.backups->Pages->Nb_layers-1; return layer; } @@ -217,8 +217,8 @@ void Button_Layer_toggle(void) // Safety required because the mouse cursor can have slided outside button. if (layer < 0) layer=0; - else if (layer > Main_backups->Pages->Nb_layers-1) - layer=Main_backups->Pages->Nb_layers-1; + else if (layer > Main.backups->Pages->Nb_layers-1) + layer=Main.backups->Pages->Nb_layers-1; Layer_activate(layer, RIGHT_SIDE); Mouse_K=0; @@ -240,8 +240,8 @@ static void Draw_transparent_background(byte background) void Button_Layer_menu(void) { - byte transparent_color = Main_backups->Pages->Transparent_color; - byte transparent_background = Main_backups->Pages->Background_transparent; + byte transparent_color = Main.backups->Pages->Transparent_color; + byte transparent_background = Main.backups->Pages->Background_transparent; short clicked_button; byte color; byte click; @@ -301,12 +301,12 @@ void Button_Layer_menu(void) if (clicked_button==3) { // Accept changes - if (Main_backups->Pages->Transparent_color != transparent_color || - Main_backups->Pages->Background_transparent != transparent_background) + if (Main.backups->Pages->Transparent_color != transparent_color || + Main.backups->Pages->Background_transparent != transparent_background) { Backup_layers(LAYER_NONE); - Main_backups->Pages->Transparent_color = transparent_color; - Main_backups->Pages->Background_transparent = transparent_background; + Main.backups->Pages->Transparent_color = transparent_color; + Main.backups->Pages->Background_transparent = transparent_background; Redraw_layered_image(); Display_all_screen(); End_of_modification(); @@ -321,10 +321,10 @@ void Button_Layer_set_transparent(void) { Hide_cursor(); - if (Main_backups->Pages->Transparent_color != Back_color) + if (Main.backups->Pages->Transparent_color != Back_color) { Backup_layers(LAYER_ALL); - Main_backups->Pages->Transparent_color = Back_color; + Main.backups->Pages->Transparent_color = Back_color; Redraw_layered_image(); Display_all_screen(); @@ -339,9 +339,9 @@ void Button_Layer_get_transparent(void) { Hide_cursor(); - if (Main_backups->Pages->Transparent_color != Back_color) + if (Main.backups->Pages->Transparent_color != Back_color) { - Set_back_color(Main_backups->Pages->Transparent_color); + Set_back_color(Main.backups->Pages->Transparent_color); } Unselect_button(BUTTON_LAYER_COLOR); @@ -374,7 +374,7 @@ void Button_Layer_up(void) { Hide_cursor(); - if (Main.current_layer < (Main_backups->Pages->Nb_layers-1)) + if (Main.current_layer < (Main.backups->Pages->Nb_layers-1)) { T_Image tmp; dword layer_flags; @@ -383,9 +383,9 @@ void Button_Layer_up(void) Backup_layers(LAYER_NONE); // swap - tmp = Main_backups->Pages->Image[Main.current_layer]; - Main_backups->Pages->Image[Main.current_layer] = Main_backups->Pages->Image[Main.current_layer+1]; - Main_backups->Pages->Image[Main.current_layer+1] = tmp; + tmp = Main.backups->Pages->Image[Main.current_layer]; + Main.backups->Pages->Image[Main.current_layer] = Main.backups->Pages->Image[Main.current_layer+1]; + Main.backups->Pages->Image[Main.current_layer+1] = tmp; // Swap visibility indicators layer_flags = (Main.layers_visible >> Main.current_layer) & 3; @@ -423,9 +423,9 @@ void Button_Layer_down(void) Backup_layers(LAYER_NONE); // swap - tmp = Main_backups->Pages->Image[Main.current_layer]; - Main_backups->Pages->Image[Main.current_layer] = Main_backups->Pages->Image[Main.current_layer-1]; - Main_backups->Pages->Image[Main.current_layer-1] = tmp; + tmp = Main.backups->Pages->Image[Main.current_layer]; + Main.backups->Pages->Image[Main.current_layer] = Main.backups->Pages->Image[Main.current_layer-1]; + Main.backups->Pages->Image[Main.current_layer-1] = tmp; // Swap visibility indicators layer_flags = (Main.layers_visible >> (Main.current_layer-1)) & 3; @@ -466,7 +466,7 @@ void Button_Anim_time(void) int frame; char buffer[6+1]; T_Special_button * input_duration_button; - int duration=Main_backups->Pages->Image[Main.current_layer].Duration; + int duration=Main.backups->Pages->Image[Main.current_layer].Duration; Open_window(166,110,"Animation speed"); @@ -547,27 +547,27 @@ void Button_Anim_time(void) duration=0; else if (duration>655350) duration=655350; - Main_backups->Pages->Image[Main.current_layer].Duration = duration; + Main.backups->Pages->Image[Main.current_layer].Duration = duration; break; case 1: if (duration<0) duration=0; else if (duration>655350) duration=655350; - for (frame=0; framePages->Nb_layers; frame++) + for (frame=0; framePages->Nb_layers; frame++) { - Main_backups->Pages->Image[frame].Duration = duration; + Main.backups->Pages->Image[frame].Duration = duration; } break; case 2: - for (frame=0; framePages->Nb_layers; frame++) + for (frame=0; framePages->Nb_layers; frame++) { - int cur_duration = Main_backups->Pages->Image[frame].Duration+duration; + int cur_duration = Main.backups->Pages->Image[frame].Duration+duration; if (cur_duration<0) cur_duration=0; else if (cur_duration>655350) cur_duration=655350; - Main_backups->Pages->Image[frame].Duration = cur_duration; + Main.backups->Pages->Image[frame].Duration = cur_duration; } break; break; @@ -591,10 +591,10 @@ void Button_Anim_first_frame(void) void Button_Anim_prev_frame(void) { - if (Main_backups->Pages->Nb_layers>1) + if (Main.backups->Pages->Nb_layers>1) { if (Main.current_layer==0) - Layer_activate(Main_backups->Pages->Nb_layers-1,LEFT_SIDE); + Layer_activate(Main.backups->Pages->Nb_layers-1,LEFT_SIDE); else Layer_activate(Main.current_layer-1,LEFT_SIDE); } @@ -605,9 +605,9 @@ void Button_Anim_prev_frame(void) void Button_Anim_next_frame(void) { - if (Main_backups->Pages->Nb_layers>1) + if (Main.backups->Pages->Nb_layers>1) { - if (Main.current_layer==Main_backups->Pages->Nb_layers-1) + if (Main.current_layer==Main.backups->Pages->Nb_layers-1) Layer_activate(0,LEFT_SIDE); else Layer_activate(Main.current_layer+1,LEFT_SIDE); @@ -620,8 +620,8 @@ void Button_Anim_next_frame(void) void Button_Anim_last_frame(void) { - if (Main.current_layer < (Main_backups->Pages->Nb_layers-1)) - Layer_activate((Main_backups->Pages->Nb_layers-1),LEFT_SIDE); + if (Main.current_layer < (Main.backups->Pages->Nb_layers-1)) + Layer_activate((Main.backups->Pages->Nb_layers-1),LEFT_SIDE); Hide_cursor(); Unselect_button(BUTTON_ANIM_LAST_FRAME); @@ -646,10 +646,10 @@ void Button_Anim_continuous_next(void) time_in_current_frame += time_now-time_start; time_start=time_now; target_frame = Main.current_layer; - while (time_in_current_frame > Main_backups->Pages->Image[target_frame].Duration) + while (time_in_current_frame > Main.backups->Pages->Image[target_frame].Duration) { - time_in_current_frame -= Interpret_delay(Main_backups->Pages->Image[target_frame].Duration); - target_frame = (target_frame+1) % Main_backups->Pages->Nb_layers; + time_in_current_frame -= Interpret_delay(Main.backups->Pages->Image[target_frame].Duration); + target_frame = (target_frame+1) % Main.backups->Pages->Nb_layers; } if (target_frame != Main.current_layer) { @@ -681,10 +681,10 @@ void Button_Anim_continuous_prev(void) time_in_current_frame += time_now-time_start; time_start=time_now; target_frame = Main.current_layer; - while (time_in_current_frame > Main_backups->Pages->Image[target_frame].Duration) + while (time_in_current_frame > Main.backups->Pages->Image[target_frame].Duration) { - time_in_current_frame -= Interpret_delay(Main_backups->Pages->Image[target_frame].Duration); - target_frame = (target_frame+Main_backups->Pages->Nb_layers-1) % Main_backups->Pages->Nb_layers; + time_in_current_frame -= Interpret_delay(Main.backups->Pages->Image[target_frame].Duration); + target_frame = (target_frame+Main.backups->Pages->Nb_layers-1) % Main.backups->Pages->Nb_layers; } if (target_frame != Main.current_layer) { diff --git a/src/loadsave.c b/src/loadsave.c index dac03e23..9d462610 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -276,9 +276,9 @@ void Fill_canvas(T_IO_Context *context, byte color) break; case CONTEXT_MAIN_IMAGE: memset( - Main_backups->Pages->Image[Main.current_layer].Pixels, + Main.backups->Pages->Image[Main.current_layer].Pixels, color, - Main_backups->Pages->Width*Main_backups->Pages->Height); + Main.backups->Pages->Width*Main.backups->Pages->Height); break; case CONTEXT_BRUSH: memset(context->Buffer_image, color, (long)context->Height*context->Pitch); @@ -356,7 +356,7 @@ void Set_frame_duration(T_IO_Context *context, int duration) switch(context->Type) { case CONTEXT_MAIN_IMAGE: - Main_backups->Pages->Image[context->Current_layer].Duration = duration; + Main.backups->Pages->Image[context->Current_layer].Duration = duration; break; default: break; @@ -368,7 +368,7 @@ int Get_frame_duration(T_IO_Context *context) switch(context->Type) { case CONTEXT_MAIN_IMAGE: - return Main_backups->Pages->Image[context->Current_layer].Duration; + return Main.backups->Pages->Image[context->Current_layer].Duration; default: return 0; } @@ -683,7 +683,7 @@ void Load_image(T_IO_Context *context) Cursor_shape=CURSOR_SHAPE_HOURGLASS; Display_cursor(); Flush_update(); - if (Convert_24b_bitmap_to_256(Main_backups->Pages->Image[0].Pixels,context->Buffer_image_24b,context->Width,context->Height,context->Palette)) + if (Convert_24b_bitmap_to_256(Main.backups->Pages->Image[0].Pixels,context->Buffer_image_24b,context->Width,context->Height,context->Palette)) File_error=2; Hide_cursor(); Cursor_shape=old_cursor_shape; @@ -778,7 +778,7 @@ void Load_image(T_IO_Context *context) } // Copy the loaded palette memcpy(Main.palette, context->Palette, sizeof(T_Palette)); - memcpy(Main_backups->Pages->Palette, context->Palette, sizeof(T_Palette)); + memcpy(Main.backups->Pages->Palette, context->Palette, sizeof(T_Palette)); // For formats that handle more than just the palette: // Transfer the data to main image. @@ -787,13 +787,13 @@ void Load_image(T_IO_Context *context) if (context->Original_file_name && context->Original_file_name[0] && context->Original_file_directory && context->Original_file_directory[0]) { - strcpy(Main_backups->Pages->Filename,context->Original_file_name); - strcpy(Main_backups->Pages->File_directory,context->Original_file_directory); + strcpy(Main.backups->Pages->Filename,context->Original_file_name); + strcpy(Main.backups->Pages->File_directory,context->Original_file_directory); } else { - strcpy(Main_backups->Pages->Filename,context->File_name); - strcpy(Main_backups->Pages->File_directory,context->File_directory); + strcpy(Main.backups->Pages->Filename,context->File_name); + strcpy(Main.backups->Pages->File_directory,context->File_directory); } // On considère que l'image chargée n'est plus modifiée @@ -805,7 +805,7 @@ void Load_image(T_IO_Context *context) //Main_image_width= context->Width; //Main_image_height= context->Height; - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { Main.current_layer = 0; } @@ -816,8 +816,8 @@ void Load_image(T_IO_Context *context) } // Load the transparency data - Main_backups->Pages->Transparent_color = context->Transparent_color; - Main_backups->Pages->Background_transparent = context->Background_transparent; + Main.backups->Pages->Transparent_color = context->Transparent_color; + Main.backups->Pages->Background_transparent = context->Background_transparent; // Correction des dimensions if (Main.image_width<1) @@ -827,17 +827,17 @@ void Load_image(T_IO_Context *context) // Color cyling ranges: for (i=0; i<16; i++) - Main_backups->Pages->Gradients->Range[i].Speed=0; + Main.backups->Pages->Gradients->Range[i].Speed=0; for (i=0; iColor_cycles; i++) { - Main_backups->Pages->Gradients->Range[i].Start=context->Cycle_range[i].Start; - Main_backups->Pages->Gradients->Range[i].End=context->Cycle_range[i].End; - Main_backups->Pages->Gradients->Range[i].Inverse=context->Cycle_range[i].Inverse; - Main_backups->Pages->Gradients->Range[i].Speed=context->Cycle_range[i].Speed; + Main.backups->Pages->Gradients->Range[i].Start=context->Cycle_range[i].Start; + Main.backups->Pages->Gradients->Range[i].End=context->Cycle_range[i].End; + Main.backups->Pages->Gradients->Range[i].Inverse=context->Cycle_range[i].Inverse; + Main.backups->Pages->Gradients->Range[i].Speed=context->Cycle_range[i].Speed; } // Comment - strcpy(Main_backups->Pages->Comment, context->Comment); + strcpy(Main.backups->Pages->Comment, context->Comment); } } @@ -852,7 +852,7 @@ void Load_image(T_IO_Context *context) { // Dans ce cas, on sait que l'image n'a pas changé, mais ses // paramètres (dimension, palette, ...) si. Donc on les restaures. - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); } } else if (context->Type == CONTEXT_BRUSH && File_error==0) @@ -987,10 +987,10 @@ void Save_image(T_IO_Context *context) { case CONTEXT_MAIN_IMAGE: if ((!Get_fileformat(context->Format)->Supports_layers) - && (Main_backups->Pages->Nb_layers > 1) + && (Main.backups->Pages->Nb_layers > 1) && (!Get_fileformat(context->Format)->Palette_only)) { - if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { if (! Confirmation_box("This format doesn't support\nanimation and will save only\ncurrent frame. Proceed?")) { @@ -999,7 +999,7 @@ void Save_image(T_IO_Context *context) } // current layer context->Nb_layers=1; - context->Target_address=Main_backups->Pages->Image[Main.current_layer].Pixels; + context->Target_address=Main.backups->Pages->Image[Main.current_layer].Pixels; } else // all other layer-based formats { @@ -1031,11 +1031,11 @@ void Save_image(T_IO_Context *context) { case 1: // flatten context->Nb_layers=1; - context->Target_address=Main_visible_image.Image; + context->Target_address=Main.visible_image.Image; break; case 2: // current layer context->Nb_layers=1; - context->Target_address=Main_backups->Pages->Image[Main.current_layer].Pixels; + context->Target_address=Main.backups->Pages->Image[Main.current_layer].Pixels; break; default: // Cancel // File_error is already set to 1. @@ -1232,10 +1232,10 @@ void Emergency_backup(const char *fname, byte *source, int width, int height, T_ void Image_emergency_backup() { - if (Main_backups && Main_backups->Pages && Main_backups->Pages->Nb_layers == 1) + if (Main.backups && Main.backups->Pages && Main.backups->Pages->Nb_layers == 1) Emergency_backup(SAFETYBACKUP_PREFIX_A "999999" BACKUP_FILE_EXTENSION,Main_screen, Main.image_width, Main.image_height, &Main.palette); - if (Spare_backups && Spare_backups->Pages && Spare_backups->Pages->Nb_layers == 1) - Emergency_backup(SAFETYBACKUP_PREFIX_B "999999" BACKUP_FILE_EXTENSION,Spare_visible_image.Image, Spare.image_width, Spare.image_height, &Spare.palette); + if (Spare.backups && Spare.backups->Pages && Spare.backups->Pages->Nb_layers == 1) + Emergency_backup(SAFETYBACKUP_PREFIX_B "999999" BACKUP_FILE_EXTENSION,Spare.visible_image.Image, Spare.image_width, Spare.image_height, &Spare.palette); } T_Format * Get_fileformat(byte format) @@ -1302,28 +1302,28 @@ void Init_context_layered_image(T_IO_Context * context, char *file_name, char *f memcpy(context->Palette, Main.palette, sizeof(T_Palette)); context->Width = Main.image_width; context->Height = Main.image_height; - context->Nb_layers = Main_backups->Pages->Nb_layers; - strcpy(context->Comment, Main_backups->Pages->Comment); - context->Transparent_color=Main_backups->Pages->Transparent_color; - context->Background_transparent=Main_backups->Pages->Background_transparent; + context->Nb_layers = Main.backups->Pages->Nb_layers; + strcpy(context->Comment, Main.backups->Pages->Comment); + context->Transparent_color=Main.backups->Pages->Transparent_color; + context->Background_transparent=Main.backups->Pages->Background_transparent; if (Pixel_ratio == PIXEL_WIDE || Pixel_ratio == PIXEL_WIDE2) context->Ratio=PIXEL_WIDE; else if (Pixel_ratio == PIXEL_TALL || Pixel_ratio == PIXEL_TALL2 || Pixel_ratio == PIXEL_TALL3) context->Ratio=PIXEL_TALL; else context->Ratio=PIXEL_SIMPLE; - context->Target_address=Main_backups->Pages->Image[0].Pixels; + context->Target_address=Main.backups->Pages->Image[0].Pixels; context->Pitch=Main.image_width; // Color cyling ranges: for (i=0; i<16; i++) { - if (Main_backups->Pages->Gradients->Range[i].Start!=Main_backups->Pages->Gradients->Range[i].End) + if (Main.backups->Pages->Gradients->Range[i].Start!=Main.backups->Pages->Gradients->Range[i].End) { - context->Cycle_range[context->Color_cycles].Start=Main_backups->Pages->Gradients->Range[i].Start; - context->Cycle_range[context->Color_cycles].End=Main_backups->Pages->Gradients->Range[i].End; - context->Cycle_range[context->Color_cycles].Inverse=Main_backups->Pages->Gradients->Range[i].Inverse; - context->Cycle_range[context->Color_cycles].Speed=Main_backups->Pages->Gradients->Range[i].Speed; + context->Cycle_range[context->Color_cycles].Start=Main.backups->Pages->Gradients->Range[i].Start; + context->Cycle_range[context->Color_cycles].End=Main.backups->Pages->Gradients->Range[i].End; + context->Cycle_range[context->Color_cycles].Inverse=Main.backups->Pages->Gradients->Range[i].Inverse; + context->Cycle_range[context->Color_cycles].Speed=Main.backups->Pages->Gradients->Range[i].Speed; context->Color_cycles++; } } @@ -1385,13 +1385,13 @@ void Set_saving_layer(T_IO_Context *context, int layer) if (context->Type == CONTEXT_MAIN_IMAGE) { - if (context->Nb_layers==1 && Main_backups->Pages->Nb_layers!=1) + if (context->Nb_layers==1 && Main.backups->Pages->Nb_layers!=1) { // Context is set to saving a single layer: do nothing } else { - context->Target_address=Main_backups->Pages->Image[layer].Pixels; + context->Target_address=Main.backups->Pages->Image[layer].Pixels; } } } @@ -1406,18 +1406,18 @@ void Set_loading_layer(T_IO_Context *context, int layer) // This awful thing is the part that happens on load while (layer >= context->Nb_layers) { - if (Add_layer(Main_backups, layer)) + if (Add_layer(Main.backups, layer)) { // Failure to add a layer on load: // Position on last layer layer = context->Nb_layers-1; break; } - context->Nb_layers = Main_backups->Pages->Nb_layers; + context->Nb_layers = Main.backups->Pages->Nb_layers; Main.layers_visible = (2<Target_address=Main_backups->Pages->Image[layer].Pixels; + context->Target_address=Main.backups->Pages->Image[layer].Pixels; Update_pixel_renderer(); } @@ -1667,8 +1667,8 @@ void Rotate_safety_backups(void) Init_context_backup_image(&context, file_name, Config_directory); context.Format=FORMAT_GIF; // Provide original file data, to store as a GIF Application Extension - context.Original_file_name = Main_backups->Pages->Filename; - context.Original_file_directory = Main_backups->Pages->File_directory; + context.Original_file_name = Main.backups->Pages->Filename; + context.Original_file_directory = Main.backups->Pages->File_directory; Save_image(&context); Destroy_context(&context); diff --git a/src/main.c b/src/main.c index 30f33198..90849e5b 100644 --- a/src/main.c +++ b/src/main.c @@ -478,10 +478,10 @@ int Init_program(int argc,char * argv[]) // principale et la page de brouillon afin que leurs champs ne soient pas // invalide lors des appels aux multiples fonctions manipulées à // l'initialisation du programme. - Main_backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages)); - Spare_backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages)); - Init_list_of_pages(Main_backups); - Init_list_of_pages(Spare_backups); + Main.backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages)); + Spare.backups=(T_List_of_pages *)malloc(sizeof(T_List_of_pages)); + Init_list_of_pages(Main.backups); + Init_list_of_pages(Spare.backups); // Determine the executable directory Set_program_directory(argv[0],program_directory); @@ -802,8 +802,8 @@ int Init_program(int argc,char * argv[]) memset(Main_screen,0,Main.image_width*Main.image_height); // Now that the backup system is there, we can store the gradients. - memcpy(Main_backups->Pages->Gradients->Range, initial_gradients.Range, sizeof(initial_gradients.Range)); - memcpy(Spare_backups->Pages->Gradients->Range, initial_gradients.Range, sizeof(initial_gradients.Range)); + memcpy(Main.backups->Pages->Gradients->Range, initial_gradients.Range, sizeof(initial_gradients.Range)); + memcpy(Spare.backups->Pages->Gradients->Range, initial_gradients.Range, sizeof(initial_gradients.Range)); Gradient_function=Gradient_basic; Gradient_lower_bound=0; @@ -915,12 +915,12 @@ int Init_program(int argc,char * argv[]) // If only one image was loaded, assume the spare has same image type if (file_in_command_line==1) - Spare_backups->Pages->Image_mode = Main_backups->Pages->Image_mode; + Spare.backups->Pages->Image_mode = Main.backups->Pages->Image_mode; Hide_cursor(); Compute_optimal_menu_colors(Main.palette); - Back_color=Main_backups->Pages->Background_transparent ? - Main_backups->Pages->Transparent_color : + Back_color=Main.backups->Pages->Background_transparent ? + Main.backups->Pages->Transparent_color : Best_color_range(0,0,0,Config.Palette_cells_X*Config.Palette_cells_Y); Fore_color=Main.palette[Back_color].R+Main.palette[Back_color].G+Main.palette[Back_color].B < 3*127 ? Best_color_range(255,255,255,Config.Palette_cells_X*Config.Palette_cells_Y) : diff --git a/src/misc.c b/src/misc.c index 3f5ea386..0f8357c2 100644 --- a/src/misc.c +++ b/src/misc.c @@ -59,9 +59,9 @@ word Count_used_colors(dword* usage) nb_pixels = Main.image_height * Main.image_width; // For each layer - for (layer = 0; layer < Main_backups->Pages->Nb_layers; layer++) + for (layer = 0; layer < Main.backups->Pages->Nb_layers; layer++) { - current_pixel = Main_backups->Pages->Image[layer].Pixels; + current_pixel = Main.backups->Pages->Image[layer].Pixels; // For each pixel in picture for (i = 0; i < nb_pixels; i++) { @@ -204,7 +204,7 @@ void Clear_current_image_with_stencil(byte color, byte * stencil) int nb_pixels=0; //ECX //al=color //edi=Screen_pixels - byte* pixel=Main_backups->Pages->Image[Main.current_layer].Pixels; + byte* pixel=Main.backups->Pages->Image[Main.current_layer].Pixels; int i; nb_pixels=Main.image_height*Main.image_width; @@ -221,7 +221,7 @@ void Clear_current_image(byte color) // Effacer l'image courante avec une certaine couleur { memset( - Main_backups->Pages->Image[Main.current_layer].Pixels, + Main.backups->Pages->Image[Main.current_layer].Pixels, color , Main.image_width * Main.image_height ); @@ -303,14 +303,14 @@ byte Read_pixel_from_spare_screen(word x,word y) // Clipping is required as this can be called with coordinates from main image // (can be a bigger or smaller image) if (x>=Spare.image_width || y>=Spare.image_height) - return Spare_backups->Pages->Transparent_color; - if (Spare_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) + return Spare.backups->Pages->Transparent_color; + if (Spare.backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { - return *(Spare_backups->Pages->Image[Spare.current_layer].Pixels + y*Spare.image_width + x); + return *(Spare.backups->Pages->Image[Spare.current_layer].Pixels + y*Spare.image_width + x); } else { - return *(Spare_visible_image.Image + y*Spare.image_width + x); + return *(Spare.visible_image.Image + y*Spare.image_width + x); } } @@ -365,7 +365,7 @@ void Remap_general_lowlevel(byte * conversion_table,byte * in_buffer, byte *out_ void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Brush_height,word image_width) { - byte* src=start_y*image_width+start_x+Main_backups->Pages->Image[Main.current_layer].Pixels; //Adr départ image (ESI) + byte* src=start_y*image_width+start_x+Main.backups->Pages->Image[Main.current_layer].Pixels; //Adr départ image (ESI) byte* dest=Brush_original_pixels; //Adr dest brosse (EDI) int dx; @@ -410,7 +410,7 @@ void Replace_colors_within_limits(byte * replace_table) // Pour chaque pixel sur la ligne : for (x = Limit_left;x <= Limit_right;x ++) { - pixel = Main_backups->Pages->Image[Main.current_layer].Pixels+y*Main.image_width+x; + pixel = Main.backups->Pages->Image[Main.current_layer].Pixels+y*Main.image_width+x; *pixel = replace_table[*pixel]; } } diff --git a/src/miscfileformats.c b/src/miscfileformats.c index 5a0d123b..6c546285 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -3368,7 +3368,7 @@ void Load_CM5(T_IO_Context* context) Set_loading_layer(context, 0); if (context->Type == CONTEXT_MAIN_IMAGE) - Main_backups->Pages->Image_mode = IMAGE_MODE_MODE5; + Main.backups->Pages->Image_mode = IMAGE_MODE_MODE5; for(ty=0; tyHeight; ty++) for(tx=0; txWidth; tx++) diff --git a/src/oldies.c b/src/oldies.c index 63fb27af..7c19f400 100644 --- a/src/oldies.c +++ b/src/oldies.c @@ -36,7 +36,7 @@ void Pixel_in_layer(word x,word y, byte layer, byte color) { - *((y)*Main.image_width+(x)+Main_backups->Pages->Image[layer].Pixels)=color; + *((y)*Main.image_width+(x)+Main.backups->Pages->Image[layer].Pixels)=color; } byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) @@ -55,7 +55,7 @@ byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) const byte no_color=16; // Prerequisites - if (Main_backups->Pages->Nb_layers < 3) + if (Main.backups->Pages->Nb_layers < 3) return 1; if (Main.image_width != 160 || Main.image_height != 200) return 2; @@ -76,7 +76,7 @@ byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) { for (x=0;x<4;x++) { - byte c=*((row)*Main.image_width+(col*4+x)+Main_backups->Pages->Image[2].Pixels); + byte c=*((row)*Main.image_width+(col*4+x)+Main.backups->Pages->Image[2].Pixels); used_colors[row][col] |= 1<Pages->Image[0].Pixels); + byte c=*((row)*Main.image_width+0+Main.backups->Pages->Image[0].Pixels); if (c<16) { line_color[row]=c; @@ -100,7 +100,7 @@ byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) { for (col=0;col<40;col++) { - byte c=*((row)*Main.image_width+(col*4)+Main_backups->Pages->Image[1].Pixels); + byte c=*((row)*Main.image_width+(col*4)+Main.backups->Pages->Image[1].Pixels); if (c<16) { block_color[row/8][col]=c; @@ -312,7 +312,7 @@ byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) for(x=0; x<4; x++) { byte bits; - byte c=*((row*8+y)*Main.image_width+(col*4+x)+Main_backups->Pages->Image[2].Pixels); + byte c=*((row*8+y)*Main.image_width+(col*4+x)+Main.backups->Pages->Image[2].Pixels); if (c==line_color[row*8+y]) // BG color @@ -360,7 +360,7 @@ byte C64_FLI_enforcer(void) return 1; if (Main.image_height != 200) return 1; - if (Main_backups->Pages->Nb_layers != 4) + if (Main.backups->Pages->Nb_layers != 4) return 2; Backup_layers(3); diff --git a/src/operatio.c b/src/operatio.c index 8cc371f7..86daf183 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -2785,12 +2785,12 @@ void Scroll_12_0(void) else { Backup_layers(LAYER_ALL); // Main.layers_visible - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // Ensure the backup visible image is up-to-date // (after swapping some layers on/off, it gets outdated) memcpy(Main_visible_image_backup.Image, - Main_visible_image.Image, + Main.visible_image.Image, Main.image_width*Main.image_height); } } @@ -2851,7 +2851,7 @@ void Scroll_12_5(void) else { // One layer at once - Scroll_picture(Main_backups->Pages->Next->Image[Main.current_layer].Pixels, Main_backups->Pages->Image[Main.current_layer].Pixels, x_offset, y_offset); + Scroll_picture(Main.backups->Pages->Next->Image[Main.current_layer].Pixels, Main.backups->Pages->Image[Main.current_layer].Pixels, x_offset, y_offset); Redraw_current_layer(); } @@ -2905,9 +2905,9 @@ void Scroll_0_5(void) y_offset=Main.image_height-((center_y-y_pos)%Main.image_height); // Do the actual scroll operation on all layers. - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) //if ((1<Pages->Next->Image[i].Pixels, Main_backups->Pages->Image[i].Pixels, x_offset, y_offset); + Scroll_picture(Main.backups->Pages->Next->Image[i].Pixels, Main.backups->Pages->Image[i].Pixels, x_offset, y_offset); // Update the depth buffer too ... // It would be faster to scroll it, but we don't have method // for in-place scrolling. diff --git a/src/pages.c b/src/pages.c index 2c71fb0b..cd8672bc 100644 --- a/src/pages.c +++ b/src/pages.c @@ -39,10 +39,10 @@ // -- Layers data /// Array of two images, that contains the "flattened" version of the visible layers. -T_Bitmap Main_visible_image; +//T_Bitmap Main_visible_image; T_Bitmap Main_visible_image_backup; T_Bitmap Main_visible_image_depth_buffer; -T_Bitmap Spare_visible_image; +//T_Bitmap Spare_visible_image; /// /// GESTION DES PAGES @@ -198,28 +198,28 @@ void Download_infos_page_main(T_Page * page) void Redraw_layered_image(void) { - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // Re-construct the image with the visible layers byte layer=0; // First layer - if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 && 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 int i; for (i=0; i< Main.image_width*Main.image_height; i++) { - layer = *(Main_backups->Pages->Image[4].Pixels+i); - if (Main.layers_visible & (1 << layer)) - Main_visible_image.Image[i]=*(Main_backups->Pages->Image[layer].Pixels+i); - else - Main_visible_image.Image[i] = layer; + layer = *(Main.backups->Pages->Image[4].Pixels+i); + if (Main.layers_visible & (1 << layer)) + Main.visible_image.Image[i]=*(Main.backups->Pages->Image[layer].Pixels+i); + else + Main.visible_image.Image[i] = layer; } // Copy it to the depth buffer memcpy(Main_visible_image_depth_buffer.Image, - Main_backups->Pages->Image[4].Pixels, + Main.backups->Pages->Image[4].Pixels, Main.image_width*Main.image_height); // Next @@ -227,13 +227,13 @@ void Redraw_layered_image(void) } else { - for (layer=0; layerPages->Nb_layers; layer++) + for (layer=0; layerPages->Nb_layers; layer++) { if ((1<Pages->Image[layer].Pixels, + memcpy(Main.visible_image.Image, + Main.backups->Pages->Image[layer].Pixels, Main.image_width*Main.image_height); // Initialize the depth buffer @@ -248,17 +248,17 @@ void Redraw_layered_image(void) } } // subsequent layer(s) - for (; layerPages->Nb_layers; layer++) + for (; layerPages->Nb_layers; layer++) { if ((1<Pages->Image[layer].Pixels+i); - if (color != Main_backups->Pages->Transparent_color) // transparent color + byte color = *(Main.backups->Pages->Image[layer].Pixels+i); + if (color != Main.backups->Pages->Transparent_color) // transparent color { - *(Main_visible_image.Image+i) = color; + *(Main.visible_image.Image+i) = color; if (layer != Main.current_layer) *(Main_visible_image_depth_buffer.Image+i) = layer; } @@ -275,7 +275,7 @@ void Redraw_layered_image(void) void Update_depth_buffer(void) { - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // Re-construct the depth buffer with the visible layers. // This function doesn't touch the visible buffer, it assumes @@ -283,7 +283,7 @@ void Update_depth_buffer(void) int layer; // First layer - for (layer=0; layerPages->Nb_layers; layer++) + for (layer=0; layerPages->Nb_layers; layer++) { if ((1<Pages->Nb_layers; layer++) + for (; layerPages->Nb_layers; layer++) { // skip the current layer, whenever we reach it if (layer == Main.current_layer) @@ -309,8 +309,8 @@ void Update_depth_buffer(void) int i; for (i=0; iPages->Image[layer].Pixels+i); - if (color != Main_backups->Pages->Transparent_color) // transparent color + byte color = *(Main.backups->Pages->Image[layer].Pixels+i); + if (color != Main.backups->Pages->Transparent_color) // transparent color { *(Main_visible_image_depth_buffer.Image+i) = layer; } @@ -323,18 +323,18 @@ void Update_depth_buffer(void) void Redraw_spare_image(void) { - if (Spare_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Spare.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // Re-construct the image with the visible layers byte layer; // First layer - for (layer=0; layerPages->Nb_layers; layer++) + for (layer=0; layerPages->Nb_layers; layer++) { if ((1<Pages->Image[layer].Pixels, + memcpy(Spare.visible_image.Image, + Spare.backups->Pages->Image[layer].Pixels, Spare.image_width*Spare.image_height); // No depth buffer in the spare @@ -348,17 +348,17 @@ void Redraw_spare_image(void) } } // subsequent layer(s) - for (; layerPages->Nb_layers; layer++) + for (; layerPages->Nb_layers; layer++) { if ((1<Pages->Image[layer].Pixels+i); - if (color != Spare_backups->Pages->Transparent_color) // transparent color + byte color = *(Spare.backups->Pages->Image[layer].Pixels+i); + if (color != Spare.backups->Pages->Transparent_color) // transparent color { - *(Spare_visible_image.Image+i) = color; + *(Spare.visible_image.Image+i) = color; //if (layer != Spare.current_layer) // *(Spare_visible_image_depth_buffer.Image+i) = layer; } @@ -370,7 +370,7 @@ void Redraw_spare_image(void) void Redraw_current_layer(void) { - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { int i; for (i=0; iPages->Image[Main.current_layer].Pixels+i); - if (color != Main_backups->Pages->Transparent_color) // transparent color + byte color = *(Main.backups->Pages->Image[Main.current_layer].Pixels+i); + if (color != Main.backups->Pages->Transparent_color) // transparent color { - *(Main_visible_image.Image+i) = color; + *(Main.visible_image.Image+i) = color; } else { - *(Main_visible_image.Image+i) = *(Main_backups->Pages->Image[depth].Pixels+i); + *(Main.visible_image.Image+i) = *(Main.backups->Pages->Image[depth].Pixels+i); } } } @@ -436,9 +436,9 @@ void Update_FX_feedback(byte with_feedback) { if (with_feedback) - FX_feedback_screen=Main_backups->Pages->Image[Main.current_layer].Pixels; + FX_feedback_screen=Main.backups->Pages->Image[Main.current_layer].Pixels; else - FX_feedback_screen=Main_backups->Pages->Next->Image[Main.current_layer].Pixels; + FX_feedback_screen=Main.backups->Pages->Next->Image[Main.current_layer].Pixels; } void Clear_page(T_Page * page) @@ -672,7 +672,7 @@ void Free_page_of_a_list(T_List_of_pages * list) { // On fait faire un undo à la liste, comme ça, la nouvelle page courante // est la page précédente - Backward_in_list_of_pages(Main_backups); + Backward_in_list_of_pages(Main.backups); // Puis on détruit la dernière page, qui est l'ancienne page courante Free_last_page_of_list(list); @@ -681,25 +681,25 @@ void Free_page_of_a_list(T_List_of_pages * list) void Update_screen_targets(void) { - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { - Main_screen=Main_visible_image.Image; + Main_screen=Main.visible_image.Image; Screen_backup=Main_visible_image_backup.Image; } else { - Main_screen=Main_backups->Pages->Image[Main.current_layer].Pixels; + Main_screen=Main.backups->Pages->Image[Main.current_layer].Pixels; // Sometimes this function will be called in situations where the // current history step and previous one don't have as many layers. // I don't like the idea of letting Screen_backup NULL or dangling, // so in case Screen_backup was queried, it will point to a valid // readable bitmap of correct size : current image. - if (Main_backups->Pages->Nb_layers != Main_backups->Pages->Next->Nb_layers - || Main_backups->Pages->Width != Main_backups->Pages->Next->Width - || Main_backups->Pages->Height != Main_backups->Pages->Next->Height) + if (Main.backups->Pages->Nb_layers != Main.backups->Pages->Next->Nb_layers + || Main.backups->Pages->Width != Main.backups->Pages->Next->Width + || Main.backups->Pages->Height != Main.backups->Pages->Next->Height) Screen_backup=Main_screen; else - Screen_backup=Main_backups->Pages->Next->Image[Main.current_layer].Pixels; + Screen_backup=Main.backups->Pages->Next->Image[Main.current_layer].Pixels; } Update_pixel_renderer(); } @@ -707,20 +707,20 @@ void Update_screen_targets(void) /// Update all the special image buffers, if necessary. int Update_buffers(int width, int height) { - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // At least one dimension is different - if (Main_visible_image.Width*Main_visible_image.Height != width*height) + if (Main.visible_image.Width*Main.visible_image.Height != width*height) { // Current image - free(Main_visible_image.Image); - Main_visible_image.Image = (byte *)malloc(width * height); - if (Main_visible_image.Image == NULL) + free(Main.visible_image.Image); + Main.visible_image.Image = (byte *)malloc(width * height); + if (Main.visible_image.Image == NULL) return 0; } - Main_visible_image.Width = width; - Main_visible_image.Height = height; - + Main.visible_image.Width = width; + Main.visible_image.Height = height; + if (Main_visible_image_backup.Width*Main_visible_image_backup.Height != width*height) { // Previous image @@ -749,19 +749,19 @@ int Update_buffers(int width, int height) /// Update all the special image buffers of the spare page, if necessary. int Update_spare_buffers(int width, int height) { - if (Spare_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Spare.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // At least one dimension is different - if (Spare_visible_image.Width*Spare_visible_image.Height != width*height) + if (Spare.visible_image.Width*Spare.visible_image.Height != width*height) { // Current image - free(Spare_visible_image.Image); - Spare_visible_image.Image = (byte *)malloc(width * height); - if (Spare_visible_image.Image == NULL) + free(Spare.visible_image.Image); + Spare.visible_image.Image = (byte *)malloc(width * height); + if (Spare.visible_image.Image == NULL) return 0; } - Spare_visible_image.Width = width; - Spare_visible_image.Height = height; + Spare.visible_image.Width = width; + Spare.visible_image.Height = height; } return 1; @@ -776,38 +776,38 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height) // width et height correspondent à la dimension des images de départ. int i; - if (! Allocate_list_of_pages(Main_backups) || - ! Allocate_list_of_pages(Spare_backups)) + if (! Allocate_list_of_pages(Main.backups) || + ! Allocate_list_of_pages(Spare.backups)) return 0; // On a réussi à allouer deux listes de pages dont la taille correspond à // celle demandée par l'utilisateur. // On crée un descripteur de page correspondant à la page principale - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); // On y met les infos sur la dimension de démarrage - Main_backups->Pages->Width=width; - Main_backups->Pages->Height=height; - strcpy(Main_backups->Pages->File_directory,Main.selector.Directory); - strcpy(Main_backups->Pages->Filename,"NO_NAME.GIF"); + Main.backups->Pages->Width=width; + Main.backups->Pages->Height=height; + strcpy(Main.backups->Pages->File_directory,Main.selector.Directory); + strcpy(Main.backups->Pages->Filename,"NO_NAME.GIF"); - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - Main_backups->Pages->Image[i].Pixels=New_layer(width*height); - if (! Main_backups->Pages->Image[i].Pixels) + Main.backups->Pages->Image[i].Pixels=New_layer(width*height); + if (! Main.backups->Pages->Image[i].Pixels) return 0; - memset(Main_backups->Pages->Image[i].Pixels, 0, width*height); + memset(Main.backups->Pages->Image[i].Pixels, 0, width*height); } - Main_visible_image.Width = 0; - Main_visible_image.Height = 0; - Main_visible_image.Image = NULL; + Main.visible_image.Width = 0; + Main.visible_image.Height = 0; + Main.visible_image.Image = NULL; Main_visible_image_backup.Image = NULL; Main_visible_image_depth_buffer.Image = NULL; - Main_backups->Pages->Image_mode = image_mode; - Spare_visible_image.Width = 0; - Spare_visible_image.Height = 0; - Spare_visible_image.Image = NULL; - Spare_backups->Pages->Image_mode = image_mode; + Main.backups->Pages->Image_mode = image_mode; + Spare.visible_image.Width = 0; + Spare.visible_image.Height = 0; + Spare.visible_image.Image = NULL; + Spare.backups->Pages->Image_mode = image_mode; if (!Update_buffers(width, height)) return 0; @@ -815,28 +815,28 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height) return 0; // For speed, instead of Redraw_layered_image() we'll directly set the buffers. - if (Main_visible_image.Image != NULL) + if (Main.visible_image.Image != NULL) { - memset(Main_visible_image.Image, 0, width*height); + memset(Main.visible_image.Image, 0, width*height); memset(Main_visible_image_backup.Image, 0, width*height); memset(Main_visible_image_depth_buffer.Image, 0, width*height); } - if (Spare_visible_image.Image != NULL) - memset(Spare_visible_image.Image, 0, width*height); - - Download_infos_page_main(Main_backups->Pages); + if (Spare.visible_image.Image != NULL) + memset(Spare.visible_image.Image, 0, width*height); + + Download_infos_page_main(Main.backups->Pages); Update_FX_feedback(Config.FX_Feedback); // Default values for spare page - Spare_backups->Pages->Width = width; - Spare_backups->Pages->Height = height; - memcpy(Spare_backups->Pages->Palette,Main.palette,sizeof(T_Palette)); - strcpy(Spare_backups->Pages->Comment,""); - strcpy(Spare_backups->Pages->File_directory,Main.selector.Directory); - strcpy(Spare_backups->Pages->Filename,"NO_NAME2.GIF"); - Spare_backups->Pages->File_format=DEFAULT_FILEFORMAT; + Spare.backups->Pages->Width = width; + Spare.backups->Pages->Height = height; + memcpy(Spare.backups->Pages->Palette,Main.palette,sizeof(T_Palette)); + strcpy(Spare.backups->Pages->Comment,""); + strcpy(Spare.backups->Pages->File_directory,Main.selector.Directory); + strcpy(Spare.backups->Pages->Filename,"NO_NAME2.GIF"); + Spare.backups->Pages->File_format=DEFAULT_FILEFORMAT; // Copy this informations in the global Spare_ variables - Download_infos_page_spare(Spare_backups->Pages); + Download_infos_page_spare(Spare.backups->Pages); // Clear the initial Visible buffer //memset(Main_screen,0,Main.image_width*Main.image_height); @@ -844,10 +844,10 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height) // Spare for (i=0; iPages->Image[i].Pixels=New_layer(width*height); - if (! Spare_backups->Pages->Image[i].Pixels) + Spare.backups->Pages->Image[i].Pixels=New_layer(width*height); + if (! Spare.backups->Pages->Image[i].Pixels) return 0; - memset(Spare_backups->Pages->Image[i].Pixels, 0, width*height); + memset(Spare.backups->Pages->Image[i].Pixels, 0, width*height); } //memset(Spare_screen,0,Spare.image_width*Spare.image_height); @@ -858,8 +858,8 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height) void Set_number_of_backups(int nb_backups) { - Change_page_number_of_list(Main_backups,nb_backups+1); - Change_page_number_of_list(Spare_backups,nb_backups+1); + Change_page_number_of_list(Main.backups,nb_backups+1); + Change_page_number_of_list(Spare.backups,nb_backups+1); // Le +1 vient du fait que dans chaque liste, en 1ère position on retrouve // les infos de la page courante sur le brouillon et la page principale. @@ -882,7 +882,7 @@ int Backup_new_image(int layers,int width,int height) new_page->Height=height; new_page->Transparent_color=0; new_page->Gradients=Dup_gradient(NULL); - if (!Create_new_page(new_page,Main_backups,LAYER_ALL)) + if (!Create_new_page(new_page,Main.backups,LAYER_ALL)) { Error(0); return 0; @@ -891,7 +891,7 @@ int Backup_new_image(int layers,int width,int height) Update_buffers(width, height); memset(Main_visible_image_depth_buffer.Image, 0, width*height); - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); return 1; } @@ -906,7 +906,7 @@ int Backup_with_new_dimensions(int width,int height) int i; // On crée un descripteur pour la nouvelle page courante - new_page=New_page(Main_backups->Pages->Nb_layers); + new_page=New_page(Main.backups->Pages->Nb_layers); if (!new_page) { Error(0); @@ -915,39 +915,39 @@ int Backup_with_new_dimensions(int width,int height) new_page->Width=width; new_page->Height=height; new_page->Transparent_color=0; - if (!Create_new_page(new_page,Main_backups,LAYER_ALL)) + if (!Create_new_page(new_page,Main.backups,LAYER_ALL)) { Error(0); return 0; } // Copy data from previous history step - memcpy(Main_backups->Pages->Palette,Main_backups->Pages->Next->Palette,sizeof(T_Palette)); - strcpy(Main_backups->Pages->Comment,Main_backups->Pages->Next->Comment); - Main_backups->Pages->File_format=Main_backups->Pages->Next->File_format; - strcpy(Main_backups->Pages->Filename, Main_backups->Pages->Next->Filename); - strcpy(Main_backups->Pages->File_directory, Main_backups->Pages->Next->File_directory); - 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; + memcpy(Main.backups->Pages->Palette,Main.backups->Pages->Next->Palette,sizeof(T_Palette)); + strcpy(Main.backups->Pages->Comment,Main.backups->Pages->Next->Comment); + Main.backups->Pages->File_format=Main.backups->Pages->Next->File_format; + strcpy(Main.backups->Pages->Filename, Main.backups->Pages->Next->Filename); + strcpy(Main.backups->Pages->File_directory, Main.backups->Pages->Next->File_directory); + 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++) + for (i=0; iPages->Nb_layers;i++) { - memset(Main_backups->Pages->Image[i].Pixels, Main_backups->Pages->Transparent_color, width*height); + memset(Main.backups->Pages->Image[i].Pixels, Main.backups->Pages->Transparent_color, width*height); } Update_buffers(width, height); - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); // Same code as in End_of_modification(), // Without saving a safety backup: - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { memcpy(Main_visible_image_backup.Image, - Main_visible_image.Image, + Main.visible_image.Image, Main.image_width*Main.image_height); } else @@ -974,11 +974,11 @@ int Backup_in_place(int width,int height) // Perform all allocations first - new_layer=calloc(Main_backups->Pages->Nb_layers,sizeof(byte *)); + new_layer=calloc(Main.backups->Pages->Nb_layers,sizeof(byte *)); if (!new_layer) return 0; - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { new_layer[i]=New_layer(height*width); if (!new_layer[i]) @@ -993,36 +993,36 @@ int Backup_in_place(int width,int height) // Now ok to proceed - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { // Replace layers - Free_layer(Main_backups->Pages,i); - Main_backups->Pages->Image[i].Pixels=new_layer[i]; + Free_layer(Main.backups->Pages,i); + Main.backups->Pages->Image[i].Pixels=new_layer[i]; // Fill with transparency - memset(Main_backups->Pages->Image[i].Pixels, Main_backups->Pages->Transparent_color, width*height); + memset(Main.backups->Pages->Image[i].Pixels, Main.backups->Pages->Transparent_color, width*height); } - Main_backups->Pages->Width=width; - Main_backups->Pages->Height=height; + Main.backups->Pages->Width=width; + Main.backups->Pages->Height=height; - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); // The following is part of Update_buffers() // (without changing the backup buffer) - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // At least one dimension is different - if (Main_visible_image.Width*Main_visible_image.Height != width*height) + if (Main.visible_image.Width*Main.visible_image.Height != width*height) { // Current image - free(Main_visible_image.Image); - Main_visible_image.Image = (byte *)malloc(width * height); - if (Main_visible_image.Image == NULL) + free(Main.visible_image.Image); + Main.visible_image.Image = (byte *)malloc(width * height); + if (Main.visible_image.Image == NULL) return 0; } - Main_visible_image.Width = width; - Main_visible_image.Height = height; + Main.visible_image.Width = width; + Main.visible_image.Height = height; if (Main_visible_image_depth_buffer.Width*Main_visible_image_depth_buffer.Height != width*height) { @@ -1050,7 +1050,7 @@ int Backup_and_resize_the_spare(int width,int height) int return_code=0; int nb_layers; - nb_layers=Spare_backups->Pages->Nb_layers; + nb_layers=Spare.backups->Pages->Nb_layers; // On crée un descripteur pour la nouvelle page de brouillon new_page=New_page(nb_layers); if (!new_page) @@ -1060,23 +1060,23 @@ int Backup_and_resize_the_spare(int width,int height) } // Fill it with a copy of the latest history - Copy_S_page(new_page,Spare_backups->Pages); - new_page->Gradients=Dup_gradient(Spare_backups->Pages); + Copy_S_page(new_page,Spare.backups->Pages); + new_page->Gradients=Dup_gradient(Spare.backups->Pages); new_page->Width=width; new_page->Height=height; - if (Create_new_page(new_page,Spare_backups,LAYER_ALL)) + if (Create_new_page(new_page,Spare.backups,LAYER_ALL)) { byte i; for (i=0; iPages->Image[i].Pixels, Spare_backups->Pages->Transparent_color, width*height); + memset(Spare.backups->Pages->Image[i].Pixels, Spare.backups->Pages->Transparent_color, width*height); } // Update_buffers(width, height); // Not for spare - Download_infos_page_spare(Spare_backups->Pages); + Download_infos_page_spare(Spare.backups->Pages); // Light up the 'has unsaved changes' indicator Spare.image_is_modified=1; @@ -1105,10 +1105,10 @@ void Backup_layers(int layer) // On remet à jour l'état des infos de la page courante (pour pouvoir les // retrouver plus tard) - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); // Create a fresh Page descriptor - new_page=New_page(Main_backups->Pages->Nb_layers); + new_page=New_page(Main.backups->Pages->Nb_layers); if (!new_page) { Error(0); @@ -1116,9 +1116,9 @@ void Backup_layers(int layer) } // Fill it with a copy of the latest history - Copy_S_page(new_page,Main_backups->Pages); - new_page->Gradients=Dup_gradient(Main_backups->Pages); - Create_new_page(new_page,Main_backups,layer); + Copy_S_page(new_page,Main.backups->Pages); + new_page->Gradients=Dup_gradient(Main.backups->Pages); + Create_new_page(new_page,Main.backups,layer); Download_infos_page_main(new_page); Update_FX_feedback(Config.FX_Feedback); @@ -1126,11 +1126,11 @@ void Backup_layers(int layer) // Copy the actual pixels from the backup to the latest page if (layer != LAYER_NONE) { - for (i=0; iPages->Nb_layers;i++) + for (i=0; iPages->Nb_layers;i++) { if (layer == LAYER_ALL || i == layer) - memcpy(Main_backups->Pages->Image[i].Pixels, - Main_backups->Pages->Next->Image[i].Pixels, + memcpy(Main.backups->Pages->Image[i].Pixels, + Main.backups->Pages->Next->Image[i].Pixels, Main.image_width*Main.image_height); } } @@ -1168,7 +1168,7 @@ void Backup_the_spare(int layer) T_Page *new_page; // Create a fresh Page descriptor - new_page=New_page(Spare_backups->Pages->Nb_layers); + new_page=New_page(Spare.backups->Pages->Nb_layers); if (!new_page) { Error(0); @@ -1176,18 +1176,18 @@ void Backup_the_spare(int layer) } // Fill it with a copy of the latest history - Copy_S_page(new_page,Spare_backups->Pages); - new_page->Gradients=Dup_gradient(Spare_backups->Pages); - Create_new_page(new_page,Spare_backups,layer); + Copy_S_page(new_page,Spare.backups->Pages); + new_page->Gradients=Dup_gradient(Spare.backups->Pages); + Create_new_page(new_page,Spare.backups,layer); // Copy the actual pixels from the backup to the latest page if (layer != LAYER_NONE) { - for (i=0; iPages->Nb_layers;i++) + for (i=0; iPages->Nb_layers;i++) { if (layer == LAYER_ALL || i == layer) - memcpy(Spare_backups->Pages->Image[i].Pixels, - Spare_backups->Pages->Next->Image[i].Pixels, + memcpy(Spare.backups->Pages->Image[i].Pixels, + Spare.backups->Pages->Next->Image[i].Pixels, Spare.image_width*Spare.image_height); } } @@ -1198,9 +1198,9 @@ void Backup_the_spare(int layer) void Check_layers_limits() { - if (Main.current_layer > Main_backups->Pages->Nb_layers-1) + if (Main.current_layer > Main.backups->Pages->Nb_layers-1) { - Main.current_layer = Main_backups->Pages->Nb_layers-1; + Main.current_layer = Main.backups->Pages->Nb_layers-1; Main.layers_visible |= 1<Pages); + Upload_infos_page_main(Main.backups->Pages); // On fait faire un undo à la liste des backups de la page principale - Backward_in_list_of_pages(Main_backups); + Backward_in_list_of_pages(Main.backups); - Update_buffers(Main_backups->Pages->Width, Main_backups->Pages->Height); + Update_buffers(Main.backups->Pages->Width, Main.backups->Pages->Height); // On extrait ensuite les infos sur la nouvelle page courante - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); // Note: le backup n'a pas obligatoirement les mêmes dimensions ni la même // palette que la page courante. Mais en temps normal, le backup // n'est pas utilisé à la suite d'un Undo. Donc ça ne devrait pas @@ -1246,19 +1246,19 @@ void Redo(void) if (Last_backed_up_layers) { - Free_page_of_a_list(Main_backups); + Free_page_of_a_list(Main.backups); Last_backed_up_layers=0; } // On remet à jour l'état des infos de la page courante (pour pouvoir les // retrouver plus tard) - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); // On fait faire un redo à la liste des backups de la page principale - Advance_in_list_of_pages(Main_backups); + Advance_in_list_of_pages(Main.backups); - Update_buffers(Main_backups->Pages->Width, Main_backups->Pages->Height); + Update_buffers(Main.backups->Pages->Width, Main.backups->Pages->Height); // On extrait ensuite les infos sur la nouvelle page courante - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); // Note: le backup n'a pas obligatoirement les mêmes dimensions ni la même // palette que la page courante. Mais en temps normal, le backup // n'est pas utilisé à la suite d'un Redo. Donc ça ne devrait pas @@ -1275,16 +1275,16 @@ void Redo(void) void Free_current_page(void) { // On détruit la page courante de la liste principale - Free_page_of_a_list(Main_backups); + Free_page_of_a_list(Main.backups); // On extrait ensuite les infos sur la nouvelle page courante - Download_infos_page_main(Main_backups->Pages); + Download_infos_page_main(Main.backups->Pages); // Note: le backup n'a pas obligatoirement les mêmes dimensions ni la même // palette que la page courante. Mais en temps normal, le backup // n'est pas utilisé à la suite d'une destruction de page. Donc ça ne // devrait pas poser de problèmes. - Update_buffers(Main_backups->Pages->Width, Main_backups->Pages->Height); + Update_buffers(Main.backups->Pages->Width, Main.backups->Pages->Height); Check_layers_limits(); Redraw_layered_image(); End_of_modification(); @@ -1297,14 +1297,14 @@ void Exchange_main_and_spare(void) // On commence par mettre à jour dans les descripteurs les infos sur les // pages qu'on s'apprête à échanger, pour qu'on se retrouve pas avec de // vieilles valeurs qui datent de mathuzalem. - Upload_infos_page_main(Main_backups->Pages); - Upload_infos_page_spare(Spare_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); + Upload_infos_page_spare(Spare.backups->Pages); // On inverse les listes de pages //TODO - temp_list=Main_backups; - Main_backups=Spare_backups; - Spare_backups=temp_list; + temp_list=Main.backups; + Main.backups=Spare.backups; + Spare.backups=temp_list; // On extrait ensuite les infos sur les nouvelles pages courante, brouillon // et backup. @@ -1315,11 +1315,11 @@ void Exchange_main_and_spare(void) // un changement de dimensions et va bêtement sortir du mode loupe, alors // que lors d'un changement de page, on veut bien conserver l'état du mode // loupe du brouillon. - Main.image_width=Main_backups->Pages->Width; - Main.image_height=Main_backups->Pages->Height; + Main.image_width=Main.backups->Pages->Width; + Main.image_height=Main.backups->Pages->Height; - Download_infos_page_main(Main_backups->Pages); - Download_infos_page_spare(Spare_backups->Pages); + Download_infos_page_main(Main.backups->Pages); + Download_infos_page_spare(Spare.backups->Pages); } void End_of_modification(void) @@ -1327,7 +1327,7 @@ void End_of_modification(void) //Update_buffers(Main.image_width, Main.image_height); - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // Backup buffer can have "wrong" size if a Lua script // performs a resize. @@ -1335,7 +1335,7 @@ void End_of_modification(void) // memcpy(Main_visible_image_backup.Image, - Main_visible_image.Image, + Main.visible_image.Image, Main.image_width*Main.image_height); } else @@ -1411,7 +1411,7 @@ byte Add_layer(T_List_of_pages *list, int layer) duration=new_page->Image[1].Duration; new_page->Image[layer].Duration=duration; // Fill with transparency, initially - memset(new_image, Main_backups->Pages->Transparent_color, list->Pages->Height*list->Pages->Width); // transparent color + memset(new_image, Main.backups->Pages->Transparent_color, list->Pages->Height*list->Pages->Width); // transparent color // Done. Note that the visible buffer is already ok since we // only inserted a transparent "slide" somewhere. @@ -1424,7 +1424,7 @@ byte Add_layer(T_List_of_pages *list, int layer) dword *visible_layers_flag; // Determine if we're modifying the spare or the main page. - if (list == Main_backups) + if (list == Main.backups) { visible_layers_flag = &Main.layers_visible; Main.current_layer = layer; @@ -1483,7 +1483,7 @@ byte Delete_layer(T_List_of_pages *list, int layer) byte new_current_layer; // Determine if we're modifying the spare or the main page. - if (list == Main_backups) + if (list == Main.backups) { visible_layers_flag = &Main.layers_visible; if (Main.current_layer>=layer && Main.current_layer>0) @@ -1516,19 +1516,19 @@ byte Merge_layer() int i; for (i=0; iPages->Image[Main.current_layer].Pixels+i); - if (color != Main_backups->Pages->Transparent_color) // transparent color - *(Main_backups->Pages->Image[Main.current_layer-1].Pixels+i) = color; + byte color = *(Main.backups->Pages->Image[Main.current_layer].Pixels+i); + if (color != Main.backups->Pages->Transparent_color) // transparent color + *(Main.backups->Pages->Image[Main.current_layer-1].Pixels+i) = color; } - return Delete_layer(Main_backups,Main.current_layer); + return Delete_layer(Main.backups,Main.current_layer); } void Switch_layer_mode(enum IMAGE_MODES new_mode) { - if (new_mode == Main_backups->Pages->Image_mode) + if (new_mode == Main.backups->Pages->Image_mode) return; - Main_backups->Pages->Image_mode = new_mode; + Main.backups->Pages->Image_mode = new_mode; switch (new_mode) { diff --git a/src/pages.h b/src/pages.h index 47dcdff1..d8b0fbe1 100644 --- a/src/pages.h +++ b/src/pages.h @@ -41,13 +41,13 @@ extern byte * FX_feedback_screen; ////////////////////////////////////////////////////////////////////////// /// The pixels of visible layers, flattened copy. -extern T_Bitmap Main_visible_image; +//extern T_Bitmap Main_visible_image; /// The pixels of visible layers, flattened copy, used for no-feedback effects. extern T_Bitmap Main_visible_image_backup; /// The index of visible pixels from ::Main_visible_image. Points to the right layer. extern T_Bitmap Main_visible_image_depth_buffer; /// The pixels of visible layers for the spare page, flattened copy. -extern T_Bitmap Spare_visible_image; +//extern T_Bitmap Spare_visible_image; /// /// INDIVIDUAL PAGES diff --git a/src/palette.c b/src/palette.c index 009666b5..19d99490 100644 --- a/src/palette.c +++ b/src/palette.c @@ -344,19 +344,19 @@ void Remap_image_highlevel(byte * conversion_table) int layer; // Remap the flatenned image view - if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION - && Main_backups->Pages->Image_mode != IMAGE_MODE_MODE5) + if (Main.backups->Pages->Image_mode != IMAGE_MODE_ANIMATION + && Main.backups->Pages->Image_mode != IMAGE_MODE_MODE5) { - Remap_general_lowlevel(conversion_table,Main_visible_image.Image,Main_visible_image.Image, + Remap_general_lowlevel(conversion_table,Main.visible_image.Image,Main.visible_image.Image, Main.image_width,Main.image_height,Main.image_width); } // Remap all layers - for (layer=0; layerPages->Nb_layers; layer++) - Remap_general_lowlevel(conversion_table,Main_backups->Pages->Image[layer].Pixels,Main_backups->Pages->Image[layer].Pixels,Main.image_width,Main.image_height,Main.image_width); + for (layer=0; layerPages->Nb_layers; layer++) + Remap_general_lowlevel(conversion_table,Main.backups->Pages->Image[layer].Pixels,Main.backups->Pages->Image[layer].Pixels,Main.image_width,Main.image_height,Main.image_width); // Remap transparent color - Main_backups->Pages->Transparent_color = - conversion_table[Main_backups->Pages->Transparent_color]; + Main.backups->Pages->Transparent_color = + conversion_table[Main.backups->Pages->Transparent_color]; // On calcule les limites à l'écran de l'image if (Main.image_height>=Menu_Y_before_window) diff --git a/src/struct.h b/src/struct.h index b26a4bb7..24f78cb2 100644 --- a/src/struct.h +++ b/src/struct.h @@ -606,6 +606,10 @@ typedef struct byte safety_backup_prefix; /// Tilemap mode byte tilemap_mode; + /// The pixels of visible layers, flattened copy. + T_Bitmap visible_image; + /// List of backup pages for the main image. + T_List_of_pages * backups; } T_Document; #endif diff --git a/src/tiles.c b/src/tiles.c index f8e7a106..056ecceb 100644 --- a/src/tiles.c +++ b/src/tiles.c @@ -118,8 +118,8 @@ int Tile_is_same(int t1, int t2) byte *bmp1,*bmp2; int y; - bmp1 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); - bmp2 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2))*Main.image_width+(TILE_X(t2)); + bmp1 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); + bmp2 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2))*Main.image_width+(TILE_X(t2)); for (y=0; y < Snap_height; y++) { @@ -135,8 +135,8 @@ int Tile_is_same_flipped_x(int t1, int t2) byte *bmp1,*bmp2; int y, x; - bmp1 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); - bmp2 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2))*Main.image_width+(TILE_X(t2)+Snap_width-1); + bmp1 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); + bmp2 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2))*Main.image_width+(TILE_X(t2)+Snap_width-1); for (y=0; y < Snap_height; y++) { @@ -153,8 +153,8 @@ int Tile_is_same_flipped_y(int t1, int t2) byte *bmp1,*bmp2; int y; - bmp1 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); - bmp2 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2)+Snap_height-1)*Main.image_width+(TILE_X(t2)); + bmp1 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); + bmp2 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2)+Snap_height-1)*Main.image_width+(TILE_X(t2)); for (y=0; y < Snap_height; y++) { @@ -171,8 +171,8 @@ int Tile_is_same_flipped_xy(int t1, int t2) byte *bmp1,*bmp2; int y, x; - bmp1 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); - bmp2 = Main_backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2)+Snap_height-1)*Main.image_width+(TILE_X(t2)+Snap_width-1); + bmp1 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t1))*Main.image_width+(TILE_X(t1)); + bmp2 = Main.backups->Pages->Image[Main.current_layer].Pixels+(TILE_Y(t2)+Snap_height-1)*Main.image_width+(TILE_X(t2)+Snap_width-1); for (y=0; y < Snap_height; y++) { diff --git a/src/transform.c b/src/transform.c index a7833612..df174917 100644 --- a/src/transform.c +++ b/src/transform.c @@ -371,7 +371,7 @@ void Button_Transform_menu(void) old_width=Main.image_width; old_height=Main.image_height; - Upload_infos_page_main(Main_backups->Pages); + Upload_infos_page_main(Main.backups->Pages); // Allocate a new page if (Backup_with_new_dimensions(new_width,new_height)) { @@ -385,42 +385,42 @@ void Button_Transform_menu(void) int i; case 2 : // Flip X - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - memcpy(Main_backups->Pages->Image[i].Pixels,Main_backups->Pages->Next->Image[i].Pixels,Main.image_width*Main.image_height); - Flip_X_lowlevel(Main_backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height); + memcpy(Main.backups->Pages->Image[i].Pixels,Main.backups->Pages->Next->Image[i].Pixels,Main.image_width*Main.image_height); + Flip_X_lowlevel(Main.backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height); } break; case 3 : // Flip Y - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - memcpy(Main_backups->Pages->Image[i].Pixels,Main_backups->Pages->Next->Image[i].Pixels,Main.image_width*Main.image_height); - Flip_Y_lowlevel(Main_backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height); + memcpy(Main.backups->Pages->Image[i].Pixels,Main.backups->Pages->Next->Image[i].Pixels,Main.image_width*Main.image_height); + Flip_Y_lowlevel(Main.backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height); } break; case 4 : // -90° Rotation - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - Rotate_270_deg_lowlevel(Main_backups->Pages->Next->Image[i].Pixels, Main_backups->Pages->Image[i].Pixels, old_width, old_height); + Rotate_270_deg_lowlevel(Main.backups->Pages->Next->Image[i].Pixels, Main.backups->Pages->Image[i].Pixels, old_width, old_height); } break; case 5 : // +90° Rotation - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - Rotate_90_deg_lowlevel(Main_backups->Pages->Next->Image[i].Pixels, Main_backups->Pages->Image[i].Pixels, old_width, old_height); + Rotate_90_deg_lowlevel(Main.backups->Pages->Next->Image[i].Pixels, Main.backups->Pages->Image[i].Pixels, old_width, old_height); } break; case 6 : // 180° Rotation - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - memcpy(Main_backups->Pages->Image[i].Pixels,Main_backups->Pages->Next->Image[i].Pixels,Main.image_width*Main.image_height); - Rotate_180_deg_lowlevel(Main_backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height); + memcpy(Main.backups->Pages->Image[i].Pixels,Main.backups->Pages->Next->Image[i].Pixels,Main.image_width*Main.image_height); + Rotate_180_deg_lowlevel(Main.backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height); } break; case 7 : // Resize - for (i=0; iPages->Nb_layers; i++) + for (i=0; iPages->Nb_layers; i++) { - Rescale(Main_backups->Pages->Next->Image[i].Pixels, old_width, old_height, Main_backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height, 0, 0); + Rescale(Main.backups->Pages->Next->Image[i].Pixels, old_width, old_height, Main.backups->Pages->Image[i].Pixels, Main.image_width, Main.image_height, 0, 0); } break; } @@ -428,9 +428,9 @@ void Button_Transform_menu(void) for (i=0; iPages->Next->Image[i].Pixels,0,0,Min(old_width,Main.image_width), + Main.backups->Pages->Next->Image[i].Pixels,0,0,Min(old_width,Main.image_width), Min(old_height,Main.image_height),old_width, - Main_backups->Pages->Image[i].Pixels,0,0,Main.image_width); + Main.backups->Pages->Image[i].Pixels,0,0,Main.image_width); } */ Redraw_layered_image(); diff --git a/src/windows.c b/src/windows.c index ab0307eb..697f806d 100644 --- a/src/windows.c +++ b/src/windows.c @@ -282,8 +282,8 @@ void Frame_menu_color(byte id) int cw = (Menu_palette_cell_width)*Menu_factor_X; int ch = (cell_height)*Menu_factor_Y; - if (Main_backups->Pages->Image_mode == 0 && Main_backups->Pages->Nb_layers > 1) - transparent = Main_backups->Pages->Transparent_color; + if (Main.backups->Pages->Image_mode == 0 && Main.backups->Pages->Nb_layers > 1) + transparent = Main.backups->Pages->Transparent_color; // Color is not selected, no dotted lines Block(start_x,start_y,Menu_palette_cell_width*Menu_factor_X, @@ -352,9 +352,9 @@ void Display_menu_palette(void) (Menu_bars[MENUBAR_TOOLS].Height)*Menu_factor_Y, MC_Black); - if (Main_backups->Pages->Image_mode == 0 - && Main_backups->Pages->Nb_layers > 1) - transparent = Main_backups->Pages->Transparent_color; + if (Main.backups->Pages->Image_mode == 0 + && Main.backups->Pages->Nb_layers > 1) + transparent = Main.backups->Pages->Transparent_color; // Compute the size of the color cells (they are smaller by 1px when using // 'separate colors" @@ -505,7 +505,7 @@ void Display_layerbar(void) { word x_off=0; word button_width = LAYER_SPRITE_WIDTH; - word button_number = Main_backups->Pages->Nb_layers; + word button_number = Main.backups->Pages->Nb_layers; word horiz_space; word current_button; word repeats=1; @@ -592,7 +592,7 @@ void Display_layerbar(void) // Frame# background rectangle // Block((Menu_bars[MENUBAR_ANIMATION].Skin_width)*Menu_factor_X,(0+Menu_bars[MENUBAR_ANIMATION].Top)*Menu_factor_Y+Menu_Y,8*8*Menu_factor_X,8*Menu_factor_Y,MC_Light); // Frame #/# - snprintf(str, 8, "%3d/%3d", Main.current_layer+1, Main_backups->Pages->Nb_layers); + snprintf(str, 8, "%3d/%3d", Main.current_layer+1, Main.backups->Pages->Nb_layers); Print_general((59)*Menu_factor_X,(Menu_bars[MENUBAR_ANIMATION].Top+3)*Menu_factor_Y+Menu_Y,str,MC_Black,MC_Light); Update_rect( (59)*Menu_factor_X, @@ -802,7 +802,7 @@ void Print_filename(void) // Partial copy of the name { #ifdef ENABLE_FILENAMES_ICONV - char * input = Main_backups->Pages->Filename; + char * input = Main.backups->Pages->Filename; size_t inbytesleft = strlen(input); char * output = display_string; size_t outbytesleft = sizeof(display_string)-1; @@ -811,7 +811,7 @@ void Print_filename(void) else #endif /* ENABLE_FILENAMES_ICONV */ { - strncpy(display_string, Main_backups->Pages->Filename, sizeof(display_string)-1); + strncpy(display_string, Main.backups->Pages->Filename, sizeof(display_string)-1); display_string[sizeof(display_string)-1] = '\0'; } } @@ -2628,15 +2628,15 @@ void Display_all_screen(void) if (Main.magnifier_mode) { if (Main.image_widthPages->Transparent_color); + Block(Main.image_width,0,(Main.separator_position-Main.image_width),Menu_Y,Main.backups->Pages->Transparent_color); } else { if (Main.image_widthPages->Transparent_color); + Block(Main.image_width,0,(Screen_width-Main.image_width),Menu_Y,Main.backups->Pages->Transparent_color); } if (Main.image_heightPages->Transparent_color); + Block(0,Main.image_height,width,(Menu_Y-height),Main.backups->Pages->Transparent_color); // ---/\/\/\ Partie zoomée: /\/\/\--- if (Main.magnifier_mode) @@ -2665,9 +2665,9 @@ void Display_all_screen(void) if (Main.image_widthPages->Transparent_color); + Menu_Y,Main.backups->Pages->Transparent_color); if (heightPages->Transparent_color); + Block(Main.X_zoom,height,width*Main.magnifier_factor,(Menu_Y-height),Main.backups->Pages->Transparent_color); } // ---/\/\/\ Affichage des limites /\/\/\---