From 8ae651c75f6cf717e00f00cc0de7c149b9b3085e Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 22 Jan 2018 13:42:33 +0100 Subject: [PATCH] put common fields for Main and Spare page in a T_Document structure --- src/brush.c | 150 ++++++------- src/brush_ops.c | 28 +-- src/buttons.c | 323 ++++++++++++++------------- src/buttons_effects.c | 14 +- src/engine.c | 150 ++++++------- src/factory.c | 114 +++++----- src/fileformats.c | 6 +- src/filesel.c | 4 +- src/global.h | 15 +- src/graph.c | 356 ++++++++++++++--------------- src/help.c | 18 +- src/input.c | 32 +-- src/layers.c | 90 ++++---- src/loadsave.c | 94 ++++---- src/main.c | 126 +++++------ src/misc.c | 96 ++++---- src/oldies.c | 18 +- src/operatio.c | 86 +++---- src/pages.c | 199 +++++++++-------- src/palette.c | 86 +++---- src/pxdouble.c | 66 +++--- src/pxquad.c | 70 +++--- src/pxsimple.c | 64 +++--- src/pxtall.c | 66 +++--- src/pxtall2.c | 70 +++--- src/pxtall3.c | 70 +++--- src/pxtriple.c | 68 +++--- src/pxwide.c | 64 +++--- src/pxwide2.c | 66 +++--- src/sdlscreen.c | 6 +- src/special.c | 40 ++-- src/struct.h | 59 +++++ src/text.c | 10 +- src/tiles.c | 37 +-- src/transform.c | 66 +++--- src/windows.c | 508 +++++++++++++++++++++--------------------- 36 files changed, 1703 insertions(+), 1632 deletions(-) diff --git a/src/brush.c b/src/brush.c index cc270640..a3ef64b6 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; } @@ -154,8 +154,8 @@ void Display_paintbrush(short x,short y,byte color) start_y_counter=start_y-(y-Brush_offset_Y); if (Paintbrush_shape==PAINTBRUSH_SHAPE_COLOR_BRUSH) Display_brush_color( - start_x-Main_offset_X, - start_y-Main_offset_Y, + start_x-Main.offset_X, + start_y-Main.offset_Y, start_x_counter, start_y_counter, width, @@ -163,8 +163,8 @@ void Display_paintbrush(short x,short y,byte color) Back_color, Brush_width); else // mono preview - Display_brush_mono(start_x-Main_offset_X, - start_y-Main_offset_Y, + Display_brush_mono(start_x-Main.offset_X, + start_y-Main.offset_Y, start_x_counter, start_y_counter, width, @@ -175,7 +175,7 @@ void Display_paintbrush(short x,short y,byte color) Update_part_of_screen(x-Brush_offset_X,y-Brush_offset_Y,Brush_width,Brush_height); - if (Main_magnifier_mode != 0) + if (Main.magnifier_mode != 0) { Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); start_x_counter=start_x-(x-Brush_offset_X); @@ -183,19 +183,19 @@ void Display_paintbrush(short x,short y,byte color) if ( (width>0) && (height>0) ) { // Corrections dues au Zoom: - start_x=(start_x-Main_magnifier_offset_X)*Main_magnifier_factor; - start_y=(start_y-Main_magnifier_offset_Y)*Main_magnifier_factor; - height=start_y+(height*Main_magnifier_factor); + start_x=(start_x-Main.magnifier_offset_X)*Main.magnifier_factor; + start_y=(start_y-Main.magnifier_offset_Y)*Main.magnifier_factor; + height=start_y+(height*Main.magnifier_factor); if (height>Menu_Y) height=Menu_Y; if (Paintbrush_shape==PAINTBRUSH_SHAPE_COLOR_BRUSH) - Display_brush_color_zoom(Main_X_zoom+start_x,start_y, + Display_brush_color_zoom(Main.X_zoom+start_x,start_y, start_x_counter,start_y_counter, width,height,Back_color, Brush_width, Horizontal_line_buffer); else // mono preview - Display_brush_mono_zoom(Main_X_zoom+start_x,start_y, + Display_brush_mono_zoom(Main.X_zoom+start_x,start_y, start_x_counter,start_y_counter, width,height, Back_color,Fore_color, @@ -218,14 +218,14 @@ void Display_paintbrush(short x,short y,byte color) Brush=Paintbrush_sprite; if ( (width>0) && (height>0) ) - Display_brush_mono(start_x-Main_offset_X, - start_y-Main_offset_Y, + Display_brush_mono(start_x-Main.offset_X, + start_y-Main.offset_Y, start_x_counter,start_y_counter, width,height, 0,Fore_color, MAX_PAINTBRUSH_SIZE); - if (Main_magnifier_mode != 0) + if (Main.magnifier_mode != 0) { Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); start_x_counter=start_x-(x-Paintbrush_offset_X); @@ -234,13 +234,13 @@ void Display_paintbrush(short x,short y,byte color) if ( (width>0) && (height>0) ) { // Corrections dues au Zoom: - start_x=(start_x-Main_magnifier_offset_X)*Main_magnifier_factor; - start_y=(start_y-Main_magnifier_offset_Y)*Main_magnifier_factor; - height=start_y+(height*Main_magnifier_factor); + start_x=(start_x-Main.magnifier_offset_X)*Main.magnifier_factor; + start_y=(start_y-Main.magnifier_offset_Y)*Main.magnifier_factor; + height=start_y+(height*Main.magnifier_factor); if (height>Menu_Y) height=Menu_Y; - Display_brush_mono_zoom(Main_X_zoom+start_x,start_y, + Display_brush_mono_zoom(Main.X_zoom+start_x,start_y, start_x_counter,start_y_counter, width,height, 0,Fore_color, @@ -284,10 +284,10 @@ 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 + if (x= 0 && y >= 0 && (color=Effect_function(x,y,color)) != (old_color=Read_pixel_from_current_layer(x,y)) && (!((Stencil_mode) && (Stencil[old_color]))) && (!((Mask_mode) && (Mask_table[Read_pixel_from_spare_screen(x,y)]))) @@ -297,22 +297,22 @@ void Draw_paintbrush(short x,short y,byte color) short xx,yy; // determine area - switch(Main_current_layer) + switch(Main.current_layer) { case 0: default: // Full layer min_x=0; min_y=0; - width=Main_image_width; - height=Main_image_height; + width=Main.image_width; + height=Main.image_height; break; case 1: case 2: // Line min_x=0; min_y=y; - width=Main_image_width; + width=Main.image_width; height=1; break; case 3: @@ -332,12 +332,12 @@ void Draw_paintbrush(short x,short y,byte color) } // Clip the bottom edge. // (Necessary if image height is not a multiple) - if (min_y+height>=Main_image_height) - height=Main_image_height-min_y; + if (min_y+height>=Main.image_height) + height=Main.image_height-min_y; // Clip the right edge. // (Necessary if image width is not a multiple) - if (min_x+width>=Main_image_width) - width=Main_image_width-min_x; + if (min_x+width>=Main.image_width) + width=Main.image_width-min_x; for (yy=min_y; yy0) && (height>0) ) - Clear_brush(min_x-Main_offset_X, - min_y-Main_offset_Y, + Clear_brush(min_x-Main.offset_X, + min_y-Main.offset_Y, 0,0, width,height,0, - Main_image_width); + Main.image_width); - if (Main_magnifier_mode != 0) + if (Main.magnifier_mode != 0) { Compute_clipped_dimensions_zoom(&min_x,&min_y,&width,&height); xx=min_x; @@ -364,16 +364,16 @@ void Draw_paintbrush(short x,short y,byte color) if ( (width>0) && (height>0) ) { // Corrections dues au Zoom: - min_x=(min_x-Main_magnifier_offset_X)*Main_magnifier_factor; - min_y=(min_y-Main_magnifier_offset_Y)*Main_magnifier_factor; - height=min_y+(height*Main_magnifier_factor); + min_x=(min_x-Main.magnifier_offset_X)*Main.magnifier_factor; + min_y=(min_y-Main.magnifier_offset_Y)*Main.magnifier_factor; + height=min_y+(height*Main.magnifier_factor); if (height>Menu_Y) height=Menu_Y; - Clear_brush_scaled(Main_X_zoom+min_x,min_y, + Clear_brush_scaled(Main.X_zoom+min_x,min_y, xx,yy, width,height,0, - Main_image_width, + Main.image_width, Horizontal_line_buffer); } } @@ -407,7 +407,7 @@ void Draw_paintbrush(short x,short y,byte color) { Copy_part_of_image_to_another( Main_screen, start_x, start_y, width, height, - Main_image_width, Smear_brush, + Main.image_width, Smear_brush, start_x_counter, start_y_counter, Smear_brush_width ); @@ -487,7 +487,7 @@ void Draw_paintbrush(short x,short y,byte color) Copy_part_of_image_to_another(Main_screen, start_x,start_y, width,height, - Main_image_width, + Main.image_width, Smear_brush, start_x_counter, start_y_counter, @@ -549,7 +549,7 @@ void Draw_paintbrush(short x,short y,byte color) Copy_part_of_image_to_another(Main_screen, start_x,start_y, width,height, - Main_image_width, + Main.image_width, Smear_brush, start_x_counter, start_y_counter, @@ -731,13 +731,13 @@ void Hide_paintbrush(short x,short y) start_y_counter=start_y-(y-Brush_offset_Y); if ( (width>0) && (height>0) ) - Clear_brush(start_x-Main_offset_X, - start_y-Main_offset_Y, + Clear_brush(start_x-Main.offset_X, + start_y-Main.offset_Y, start_x_counter,start_y_counter, width,height,Back_color, - Main_image_width); + Main.image_width); - if (Main_magnifier_mode != 0) + if (Main.magnifier_mode != 0) { Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); start_x_counter=start_x; @@ -746,16 +746,16 @@ void Hide_paintbrush(short x,short y) if ( (width>0) && (height>0) ) { // Corrections dues au Zoom: - start_x=(start_x-Main_magnifier_offset_X)*Main_magnifier_factor; - start_y=(start_y-Main_magnifier_offset_Y)*Main_magnifier_factor; - height=start_y+(height*Main_magnifier_factor); + start_x=(start_x-Main.magnifier_offset_X)*Main.magnifier_factor; + start_y=(start_y-Main.magnifier_offset_Y)*Main.magnifier_factor; + height=start_y+(height*Main.magnifier_factor); if (height>Menu_Y) height=Menu_Y; - Clear_brush_scaled(Main_X_zoom+start_x,start_y, + Clear_brush_scaled(Main.X_zoom+start_x,start_y, start_x_counter,start_y_counter, width,height,Back_color, - Main_image_width, + Main.image_width, Horizontal_line_buffer); } } @@ -774,14 +774,14 @@ void Hide_paintbrush(short x,short y) if ( (width>0) && (height>0) ) { - Clear_brush(start_x-Main_offset_X, - start_y-Main_offset_Y, + Clear_brush(start_x-Main.offset_X, + start_y-Main.offset_Y, start_x_counter,start_y_counter, width,height,0, - Main_image_width); + Main.image_width); } - if (Main_magnifier_mode != 0) + if (Main.magnifier_mode != 0) { Compute_clipped_dimensions_zoom(&start_x,&start_y,&width,&height); start_x_counter=start_x; @@ -790,16 +790,16 @@ void Hide_paintbrush(short x,short y) if ( (width>0) && (height>0) ) { // Corrections dues au Zoom: - start_x=(start_x-Main_magnifier_offset_X)*Main_magnifier_factor; - start_y=(start_y-Main_magnifier_offset_Y)*Main_magnifier_factor; - height=start_y+(height*Main_magnifier_factor); + start_x=(start_x-Main.magnifier_offset_X)*Main.magnifier_factor; + start_y=(start_y-Main.magnifier_offset_Y)*Main.magnifier_factor; + height=start_y+(height*Main.magnifier_factor); if (height>Menu_Y) height=Menu_Y; - Clear_brush_scaled(Main_X_zoom+start_x,start_y, + Clear_brush_scaled(Main.X_zoom+start_x,start_y, start_x_counter,start_y_counter, width,height,0, - Main_image_width, + Main.image_width, Horizontal_line_buffer); } } @@ -837,7 +837,7 @@ void Capture_brush(short start_x,short start_y,short end_x,short end_y,short cle // On ne capture la nouvelle brosse que si elle est au moins partiellement // dans l'image: - if ((start_xMain_image_width) - new_brush_width=Main_image_width-start_x; - if (start_y+new_brush_height>Main_image_height) - new_brush_height=Main_image_height-start_y; + if (start_x+new_brush_width>Main.image_width) + new_brush_width=Main.image_width-start_x; + if (start_y+new_brush_height>Main.image_height) + new_brush_height=Main.image_height-start_y; if (Realloc_brush(new_brush_width, new_brush_height, NULL, NULL)) return; // Unable to allocate the new brush, keep the old one. - Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main_image_width); + Copy_image_to_brush(start_x,start_y,Brush_width,Brush_height,Main.image_width); // On regarde s'il faut effacer quelque chose: if (clear) { - if (Main_tilemap_mode) + if (Main.tilemap_mode) { for (y_pos=start_y;y_pos>1); - Main_magnifier_offset_Y=Mouse_Y-(Main_magnifier_height>>1); + Main.magnifier_offset_X=Mouse_X-(Main.magnifier_width>>1); + Main.magnifier_offset_Y=Mouse_Y-(Main.magnifier_height>>1); // Calcul des coordonnées absolues de ce coin DANS L'IMAGE - Main_magnifier_offset_X+=Main_offset_X; - Main_magnifier_offset_Y+=Main_offset_Y; + Main.magnifier_offset_X+=Main.offset_X; + Main.magnifier_offset_Y+=Main.offset_Y; - Clip_magnifier_offsets(&Main_magnifier_offset_X, &Main_magnifier_offset_Y); + Clip_magnifier_offsets(&Main.magnifier_offset_X, &Main.magnifier_offset_Y); // On calcule les bornes visibles dans l'écran Position_screen_according_to_zoom(); @@ -154,8 +154,8 @@ void Colorpicker_1_1(void) char str[4]; if ( (Paintbrush_X>=0) && (Paintbrush_Y>=0) - && (Paintbrush_X=0) && (Paintbrush_Y>=0) - && (Paintbrush_X=0) && (Paintbrush_Y>=0) - && (Paintbrush_X=Main_X_zoom) ) ) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) Print_in_menu("X: Y: ",0); Print_coordinates(); @@ -1156,7 +1156,7 @@ void Draw_stretch_spot(short x_pos, short y_pos) if (y>=Limit_top && y<=Limit_visible_bottom) for (x=x_pos-1;x=Limit_left && x<=Limit_visible_right) - Pixel_preview(x,y,xor_lut[Read_pixel(x-Main_offset_X,y-Main_offset_Y)]); + Pixel_preview(x,y,xor_lut[Read_pixel(x-Main.offset_X,y-Main.offset_Y)]); Update_part_of_screen(x_pos-1, y_pos-1, 2, 2); } diff --git a/src/buttons.c b/src/buttons.c index 50cdde09..b86e0e7d 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -204,7 +204,7 @@ void Button_Message_initial(void) } // Modify the mode for the spare too Spare_backups->Pages->Image_mode = Main_backups->Pages->Image_mode; - Update_spare_buffers(Spare_image_width,Spare_image_height); + Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); } Display_cursor(); @@ -238,13 +238,13 @@ void Button_Undo(void) { Hide_cursor(); Undo(); - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); + Set_palette(Main.palette); + Compute_optimal_menu_colors(Main.palette); Check_menu_mode(); Display_all_screen(); Unselect_button(BUTTON_UNDO); - Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode); + Draw_menu_button(BUTTON_MAGNIFIER,Main.magnifier_mode); Display_menu(); Display_cursor(); } @@ -253,13 +253,13 @@ void Button_Redo(void) { Hide_cursor(); Redo(); - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); + Set_palette(Main.palette); + Compute_optimal_menu_colors(Main.palette); Check_menu_mode(); Display_all_screen(); Unselect_button(BUTTON_UNDO); - Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode); + Draw_menu_button(BUTTON_MAGNIFIER,Main.magnifier_mode); Display_menu(); Display_cursor(); } @@ -430,31 +430,31 @@ void Button_Hide_menu(void) Menu_is_visible=0; Menu_Y=Screen_height; - if (Main_magnifier_mode) + if (Main.magnifier_mode) { Compute_magnifier_data(); } // On repositionne le décalage de l'image pour qu'il n'y ait pas d'in- // -cohérences lorsqu'on sortira du mode Loupe. - if (Main_offset_Y+Screen_height>Main_image_height) + if (Main.offset_Y+Screen_height>Main.image_height) { - if (Screen_height>Main_image_height) - Main_offset_Y=0; + if (Screen_height>Main.image_height) + Main.offset_Y=0; else - Main_offset_Y=Main_image_height-Screen_height; + Main.offset_Y=Main.image_height-Screen_height; } // On fait pareil pour le brouillon - if (Spare_offset_Y+Screen_height>Spare_image_height) + if (Spare.offset_Y+Screen_height>Spare.image_height) { - if (Screen_height>Spare_image_height) - Spare_offset_Y=0; + if (Screen_height>Spare.image_height) + Spare.offset_Y=0; else - Spare_offset_Y=Spare_image_height-Screen_height; + Spare.offset_Y=Spare.image_height-Screen_height; } Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Position_screen_according_to_zoom(); Compute_limits(); Compute_paintbrush_coordinates(); @@ -470,12 +470,12 @@ void Button_Hide_menu(void) Menu_Y -= Menu_bars[current_menu].Height * Menu_factor_Y; Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Position_screen_according_to_zoom(); Compute_limits(); Compute_paintbrush_coordinates(); Display_menu(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Display_all_screen(); } Unselect_button(BUTTON_HIDE); @@ -603,7 +603,7 @@ byte Button_Quit_local_function(void) static char filename[MAX_PATH_CHARACTERS]; byte old_cursor_shape; - if (!Main_image_is_modified) + if (!Main.image_is_modified) return 1; // On commence par afficher la fenêtre de QUIT @@ -671,7 +671,7 @@ void Button_Quit(void) if (Button_Quit_local_function()) { - if (Spare_image_is_modified) + if (Spare.image_is_modified) { Button_Page(); // On passe sur le brouillon // Si l'utilisateur présente les derniers symptomes de l'abandon @@ -1168,10 +1168,10 @@ void Button_Settings(void) { // Reset fileselector offsets // since different files are shown now - Main_selector.Position=0; - Main_selector.Offset=0; - Spare_selector.Position=0; - Spare_selector.Offset=0; + Main.selector.Position=0; + Main.selector.Offset=0; + Spare.selector.Position=0; + Spare.selector.Offset=0; Brush_selector.Position=0; Brush_selector.Offset=0; } @@ -1184,7 +1184,7 @@ void Button_Settings(void) Config=selected_config; if (config_is_reloaded) - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); Close_window(); Unselect_button(BUTTON_SETTINGS); @@ -1514,12 +1514,12 @@ void Button_Skins(void) // Now find the best colors for the new skin in the current palette // and remap the skin - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); } // We don't want to keep the skin's palette, as this would corrupt the current picture's one. - Set_palette(Main_palette); + Set_palette(Main.palette); Close_window(); Unselect_button(BUTTON_SETTINGS); @@ -1534,7 +1534,7 @@ void Button_Skins(void) switch(button) { case BUTTON_MAGNIFIER: - state|=Main_magnifier_mode; + state|=Main.magnifier_mode; break; case BUTTON_EFFECTS: state|=Any_effect_active(); @@ -1564,74 +1564,75 @@ void Button_Page(void) Swap_tilemap(); // On fait le reste du travail "à la main": - 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) - SWAP_SHORTS(Main_X_zoom,Spare_X_zoom) - SWAP_FLOATS(Main_separator_proportion,Spare_separator_proportion) - SWAP_BYTES (Main_magnifier_mode,Spare_magnifier_mode) +// 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_SHORTS(Main.offset_X,Spare.offset_X) + SWAP_SHORTS(Main.offset_Y,Spare.offset_Y) + SWAP_SHORTS(Main.separator_position,Spare.separator_position) + SWAP_SHORTS(Main.X_zoom,Spare.X_zoom) + SWAP_FLOATS(Main.separator_proportion,Spare.separator_proportion) + SWAP_BYTES (Main.magnifier_mode,Spare.magnifier_mode) - Pixel_preview=(Main_magnifier_mode)?Pixel_preview_magnifier:Pixel_preview_normal; + Pixel_preview=(Main.magnifier_mode)?Pixel_preview_magnifier:Pixel_preview_normal; - SWAP_WORDS (Main_magnifier_factor,Spare_magnifier_factor) - SWAP_WORDS (Main_magnifier_height,Spare_magnifier_height) - SWAP_WORDS (Main_magnifier_width,Spare_magnifier_width) - SWAP_SHORTS(Main_magnifier_offset_X,Spare_magnifier_offset_X) - SWAP_SHORTS(Main_magnifier_offset_Y,Spare_magnifier_offset_Y) + SWAP_WORDS (Main.magnifier_factor,Spare.magnifier_factor) + SWAP_WORDS (Main.magnifier_height,Spare.magnifier_height) + SWAP_WORDS (Main.magnifier_width,Spare.magnifier_width) + SWAP_SHORTS(Main.magnifier_offset_X,Spare.magnifier_offset_X) + SWAP_SHORTS(Main.magnifier_offset_Y,Spare.magnifier_offset_Y) // Swap du booléen "Image modifiée" - SWAP_BYTES (Main_image_is_modified,Spare_image_is_modified) + SWAP_BYTES (Main.image_is_modified,Spare.image_is_modified) // Swap fileselector data - SWAP_BYTES (Main_selector.Format_filter,Spare_selector.Format_filter) - SWAP_WORDS (Main_selector.Position,Spare_selector.Position) - SWAP_WORDS (Main_selector.Offset,Spare_selector.Offset) - strcpy(Temp_buffer ,Spare_selector.Directory); - strcpy(Spare_selector.Directory,Main_selector.Directory); - strcpy(Main_selector.Directory,Temp_buffer ); + SWAP_BYTES (Main.selector.Format_filter,Spare.selector.Format_filter) + SWAP_WORDS (Main.selector.Position,Spare.selector.Position) + SWAP_WORDS (Main.selector.Offset,Spare.selector.Offset) + strcpy(Temp_buffer ,Spare.selector.Directory); + strcpy(Spare.selector.Directory,Main.selector.Directory); + strcpy(Main.selector.Directory,Temp_buffer ); - SWAP_BYTES (Main_current_layer,Spare_current_layer) - SWAP_DWORDS(Main_layers_visible,Spare_layers_visible) - SWAP_DWORDS(Main_layers_visible_backup,Spare_layers_visible_backup) + SWAP_BYTES (Main.current_layer,Spare.current_layer) + SWAP_DWORDS(Main.layers_visible,Spare.layers_visible) + SWAP_DWORDS(Main.layers_visible_backup,Spare.layers_visible_backup) - SWAP_DWORDS(Main_safety_number,Spare_safety_number) - SWAP_DWORDS(Main_edits_since_safety_backup,Spare_edits_since_safety_backup) - SWAP_BYTES(Main_safety_backup_prefix,Spare_safety_backup_prefix) + SWAP_DWORDS(Main.safety_number,Spare.safety_number) + SWAP_DWORDS(Main.edits_since_safety_backup,Spare.edits_since_safety_backup) + SWAP_BYTES(Main.safety_backup_prefix,Spare.safety_backup_prefix) { Uint32 a; - a=Main_time_of_safety_backup; - Main_time_of_safety_backup=Spare_time_of_safety_backup; - Spare_time_of_safety_backup=a; + a=Main.time_of_safety_backup; + Main.time_of_safety_backup=Spare.time_of_safety_backup; + Spare.time_of_safety_backup=a; } //Redraw_layered_image(); // replaced by - Update_buffers(Main_image_width, Main_image_height); + Update_buffers(Main.image_width, Main.image_height); Update_depth_buffer(); Update_screen_targets(); End_of_modification(); // -- // A la fin, on affiche l'écran - for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main_magnifier_factor; factor_index++); - //Change_magnifier_factor(factor_index,0); + for (factor_index=0; ZOOM_FACTOR[factor_index]!=Main.magnifier_factor; factor_index++); + //Change.magnifier_factor(factor_index,0); Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Pixel_preview=Pixel_preview_magnifier; else Pixel_preview=Pixel_preview_normal; Compute_limits(); Compute_paintbrush_coordinates(); - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); + Set_palette(Main.palette); + Compute_optimal_menu_colors(Main.palette); Check_menu_mode(); Display_all_screen(); Unselect_button(BUTTON_PAGE); - Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode); + Draw_menu_button(BUTTON_MAGNIFIER,Main.magnifier_mode); // Tilemap mode might be different Draw_menu_button(BUTTON_EFFECTS,Any_effect_active()); Display_menu(); @@ -1644,27 +1645,27 @@ void Button_Page(void) void Copy_image_only(void) { - word old_width=Spare_image_width; - word old_height=Spare_image_height; + word old_width=Spare.image_width; + word old_height=Spare.image_height; - if (Backup_and_resize_the_spare(Main_image_width,Main_image_height)) + if (Backup_and_resize_the_spare(Main.image_width,Main.image_height)) { byte i; for (i=0; iPages->Nb_layers; i++) { - if (i == Spare_current_layer) + 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), - Min(old_height,Spare_image_height),old_width, - Spare_backups->Pages->Image[i].Pixels,0,0,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); } } @@ -1674,8 +1675,8 @@ void Copy_image_only(void) ces valeurs pour qu'elles soient correctes. */ /* - Spare_image_width=Main_image_width; - Spare_image_height=Main_image_height; + Spare.image_width=Main.image_width; + Spare.image_height=Main.image_height; */ Copy_view_to_spare(); @@ -1687,7 +1688,7 @@ void Copy_image_only(void) // (It's the same reason that the "Page" function gets complex, // it needs to rebuild a depth buffer only, trusting the // depth buffer that was already available in Spare_.) - Update_spare_buffers(Spare_image_width,Spare_image_height); + Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); } @@ -1712,7 +1713,7 @@ void Copy_some_colors(void) for (index=0; index<256; index++) { if (mask_color_to_copy[index]) - memcpy(Spare_palette+index,Main_palette+index, + memcpy(Spare.palette+index,Main.palette+index, sizeof(T_Components)); } } @@ -1755,12 +1756,12 @@ void Button_Copy_page(void) // backup is done by the following function Copy_image_only(); // copie de la palette - memcpy(Spare_palette,Main_palette,sizeof(T_Palette)); + memcpy(Spare.palette,Main.palette,sizeof(T_Palette)); // Equivalent of 'end_of_modifications' for spare. - Update_spare_buffers(Spare_image_width,Spare_image_height); + Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); - Spare_image_is_modified=1; - if (Spare_tilemap_mode) + Spare.image_is_modified=1; + if (Spare.tilemap_mode) Disable_spare_tilemap(); break; @@ -1768,21 +1769,21 @@ void Button_Copy_page(void) // backup is done by the following function Copy_image_only(); // Equivalent of 'end_of_modifications' for spare. - Update_spare_buffers(Spare_image_width,Spare_image_height); + Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); - Spare_image_is_modified=1; - if (Spare_tilemap_mode) + Spare.image_is_modified=1; + if (Spare.tilemap_mode) Disable_spare_tilemap(); break; case 3: // Palette only Backup_the_spare(LAYER_NONE); // Copy palette - memcpy(Spare_palette,Main_palette,sizeof(T_Palette)); + memcpy(Spare.palette,Main.palette,sizeof(T_Palette)); // Equivalent of 'end_of_modifications' for spare. - Update_spare_buffers(Spare_image_width,Spare_image_height); + Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); - Spare_image_is_modified=1; + Spare.image_is_modified=1; break; case 4: // Some colors @@ -1794,11 +1795,11 @@ void Button_Copy_page(void) Backup_the_spare(LAYER_ALL); Remap_spare(); // Copy palette - memcpy(Spare_palette,Main_palette,sizeof(T_Palette)); + memcpy(Spare.palette,Main.palette,sizeof(T_Palette)); // Equivalent of 'end_of_modifications' for spare. - Update_spare_buffers(Spare_image_width,Spare_image_height); + Update_spare_buffers(Spare.image_width,Spare.image_height); Redraw_spare_image(); - Spare_image_is_modified=1; + Spare.image_is_modified=1; break; } @@ -1825,12 +1826,12 @@ void Button_Kill(void) Hide_cursor(); Free_current_page(); - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); + Set_palette(Main.palette); + Compute_optimal_menu_colors(Main.palette); Display_all_screen(); Unselect_button(BUTTON_KILL); - Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode); + Draw_menu_button(BUTTON_MAGNIFIER,Main.magnifier_mode); Display_menu(); Display_cursor(); } @@ -2029,11 +2030,11 @@ void Button_Resolution(void) Check_mode_button(184,172,3); - chosen_width=Main_image_width; + chosen_width=Main.image_width; Num2str(chosen_width,str,4); Window_input_content(input_width_button,str); - chosen_height=Main_image_height; + chosen_height=Main.image_height; Num2str(chosen_height,str,4); Window_input_content(input_button_height,str); @@ -2216,11 +2217,11 @@ void Button_Resolution(void) if (clicked_button==1) // OK { - if (Main_magnifier_mode) + if (Main.magnifier_mode) Unselect_button(BUTTON_MAGNIFIER); - if ( (chosen_width!=Main_image_width) - || (chosen_height!=Main_image_height) ) + if ( (chosen_width!=Main.image_width) + || (chosen_height!=Main.image_height) ) { Resize_image(chosen_width,chosen_height); End_of_modification(); @@ -2636,7 +2637,7 @@ void Button_Gradients(void) { Allow_colorcycling=0; // Restore palette - Set_palette(Main_palette); + Set_palette(Main.palette); } switch(clicked_button) @@ -2849,7 +2850,7 @@ void Button_Fill(void) } else if ( (Mouse_Y=Main_X_zoom) ) ) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) Print_in_menu("X: Y: ",0); Start_operation_stack(OPERATION_FILL); Display_cursor(); @@ -2868,7 +2869,7 @@ void Button_Replace(void) Paintbrush_shape=PAINTBRUSH_SHAPE_POINT; } if ( (Mouse_Y=Main_X_zoom) ) ) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) Print_in_menu("X: Y: ( )",0); Start_operation_stack(OPERATION_REPLACE); Display_cursor(); @@ -2882,7 +2883,7 @@ void Button_Unselect_fill(void) if (Current_operation==OPERATION_REPLACE) if ( (Mouse_Y=Main_X_zoom) ) ) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) Print_in_menu("X: Y: ",0); } @@ -3093,13 +3094,13 @@ int Best_video_mode(void) // On commence par borner les dimensions, ou du moins les rendre cohérentes if ((Original_screen_X<=0) || (Config.Set_resolution_according_to==2)) - Original_screen_X=Main_image_width; + Original_screen_X=Main.image_width; else if (Original_screen_X<320) Original_screen_X=320; if ((Original_screen_Y<=0) || (Config.Set_resolution_according_to==2)) - Original_screen_Y=Main_image_height; + Original_screen_Y=Main.image_height; else if (Original_screen_Y<200) Original_screen_Y=200; @@ -3167,13 +3168,13 @@ void Load_picture(byte image) strcpy(directory, Brush_file_directory); Init_context_brush(&context, filename, directory); } - confirm=Button_Load_or_Save(image?&Main_selector:&Brush_selector, 1, &context); + confirm=Button_Load_or_Save(image?&Main.selector:&Brush_selector, 1, &context); if (confirm) { if (image) { - if (Main_image_is_modified) + if (Main.image_is_modified) confirm=Confirmation_box("Discard unsaved changes?"); } } @@ -3225,20 +3226,20 @@ void Load_picture(byte image) } - if ( (File_error==1) || (Get_fileformat(Main_fileformat)->Palette_only) ) + if ( (File_error==1) || (Get_fileformat(Main.fileformat)->Palette_only) ) { if (File_error!=1) - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); } else { if (image) { - if (Main_magnifier_mode) + if (Main.magnifier_mode) { Pixel_preview=Pixel_preview_normal; - Main_magnifier_mode=0; - Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode); + Main.magnifier_mode=0; + Draw_menu_button(BUTTON_MAGNIFIER,Main.magnifier_mode); } new_mode=Best_video_mode(); @@ -3268,18 +3269,18 @@ void Load_picture(byte image) } else { - Main_offset_X=0; - Main_offset_Y=0; + Main.offset_X=0; + Main.offset_Y=0; Compute_limits(); Compute_paintbrush_coordinates(); } - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); Redraw_layered_image(); End_of_modification(); Check_menu_mode(); Display_all_screen(); - Main_image_is_modified=0; + Main.image_is_modified=0; } } @@ -3292,7 +3293,7 @@ void Load_picture(byte image) Hide_cursor(); Print_filename(); Display_cursor(); - Set_palette(Main_palette); + Set_palette(Main.palette); } @@ -3316,7 +3317,7 @@ void Button_Reload(void) // restituer en cas d'erreur n'affectant pas l'image Upload_infos_page_main(Main_backups->Pages); - if ( (!Main_image_is_modified) || Confirmation_box("Discard unsaved changes ?") ) + if ( (!Main.image_is_modified) || Confirmation_box("Discard unsaved changes ?") ) { T_IO_Context context; @@ -3336,11 +3337,11 @@ void Button_Reload(void) if (File_error!=1) { - if (Main_magnifier_mode) + if (Main.magnifier_mode) { Pixel_preview=Pixel_preview_normal; - Main_magnifier_mode=0; - Draw_menu_button(BUTTON_MAGNIFIER,Main_magnifier_mode); + Main.magnifier_mode=0; + Draw_menu_button(BUTTON_MAGNIFIER,Main.magnifier_mode); } new_mode=Best_video_mode(); @@ -3371,8 +3372,8 @@ void Button_Reload(void) } else { - Main_offset_X=0; - Main_offset_Y=0; + Main.offset_X=0; + Main.offset_Y=0; Compute_limits(); Compute_paintbrush_coordinates(); } @@ -3382,14 +3383,14 @@ void Button_Reload(void) Check_menu_mode(); Display_all_screen(); - Main_image_is_modified=0; + Main.image_is_modified=0; } Destroy_context(&context); } else Hide_cursor(); - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); Display_menu(); if (Config.Display_image_limits) Display_image_limits(); @@ -3451,7 +3452,7 @@ void Save_picture(enum CONTEXT_TYPE type) 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; + save_context.Format = Main.fileformat; } else if (type == CONTEXT_BRUSH) { @@ -3481,7 +3482,7 @@ void Save_picture(enum CONTEXT_TYPE type) else return; - confirm=Button_Load_or_Save((type==CONTEXT_MAIN_IMAGE)?&Main_selector:&Brush_selector,0, &save_context); + confirm=Button_Load_or_Save((type==CONTEXT_MAIN_IMAGE)?&Main.selector:&Brush_selector,0, &save_context); if (confirm && File_exists(save_context.File_name)) { @@ -3511,8 +3512,8 @@ void Save_picture(enum CONTEXT_TYPE type) 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)) { - Main_image_is_modified=0; - Main_fileformat=save_context.Format; + 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); } @@ -3529,7 +3530,7 @@ void Save_picture(enum CONTEXT_TYPE type) Destroy_context(&save_context); Print_filename(); - Set_palette(Main_palette); + Set_palette(Main.palette); } @@ -3570,7 +3571,7 @@ void Button_Autosave(void) Save_image(&save_context); if (!File_error) { - Main_image_is_modified=0; + Main.image_is_modified=0; } Destroy_context(&save_context); @@ -3710,7 +3711,7 @@ void Button_Colorpicker(void) Paintbrush_shape=PAINTBRUSH_SHAPE_NONE; if (Operation_before_interrupt!=OPERATION_REPLACE) if ( (Mouse_Y=Main_X_zoom) ) ) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) Print_in_menu("X: Y: ( )",0); } else @@ -3725,7 +3726,7 @@ void Button_Unselect_colorpicker(void) // Erase the color block which shows the picked color if (Operation_before_interrupt!=OPERATION_REPLACE) if ( (Mouse_Y=Main_X_zoom) ) ) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) Print_in_menu("X: Y: ",0); // On fait de notre mieux pour restaurer l'ancienne opération: @@ -3763,7 +3764,7 @@ byte Coming_from_zoom_factor_menu=0; void Button_Magnify(void) { Hide_cursor(); - if ( (Current_operation==OPERATION_MAGNIFY) || (Main_magnifier_mode) ) + if ( (Current_operation==OPERATION_MAGNIFY) || (Main.magnifier_mode) ) { Unselect_button(BUTTON_MAGNIFIER); } @@ -3780,21 +3781,21 @@ void Button_Magnify(void) /* la loupe... Il serait peut-être plus propre de faire une procédure */ /* qui s'en charge... */ // On passe en mode loupe - Main_magnifier_mode=1; + Main.magnifier_mode=1; // La fonction d'affichage dans la partie image est désormais un affichage // spécial loupe. Pixel_preview=Pixel_preview_magnifier; // On calcule l'origine de la loupe - Main_magnifier_offset_X=Mouse_X-(Main_magnifier_width>>1); - Main_magnifier_offset_Y=Mouse_Y-(Main_magnifier_height>>1); + Main.magnifier_offset_X=Mouse_X-(Main.magnifier_width>>1); + Main.magnifier_offset_Y=Mouse_Y-(Main.magnifier_height>>1); // Calcul des coordonnées absolues de ce coin DANS L'IMAGE - Main_magnifier_offset_X+=Main_offset_X; - Main_magnifier_offset_Y+=Main_offset_Y; + Main.magnifier_offset_X+=Main.offset_X; + Main.magnifier_offset_Y+=Main.offset_Y; - Clip_magnifier_offsets(&Main_magnifier_offset_X, &Main_magnifier_offset_Y); + Clip_magnifier_offsets(&Main.magnifier_offset_X, &Main.magnifier_offset_Y); // On calcule les bornes visibles dans l'écran Position_screen_according_to_zoom(); @@ -3838,14 +3839,14 @@ void Button_Magnify_menu(void) Change_magnifier_factor(item->Number,0); } - if ( (!item) && (!Main_magnifier_mode) && (Current_operation!=OPERATION_MAGNIFY) ) // Cancel + if ( (!item) && (!Main.magnifier_mode) && (Current_operation!=OPERATION_MAGNIFY) ) // Cancel Unselect_button(BUTTON_MAGNIFIER); Display_all_screen(); Display_cursor(); - Update_rect(Main_separator_position,0,Screen_width-Main_separator_position,Menu_Y); + Update_rect(Main.separator_position,0,Screen_width-Main.separator_position,Menu_Y); - if ( (item) && (!Main_magnifier_mode) && (Current_operation!=OPERATION_MAGNIFY) ) // Passage en mode zoom + if ( (item) && (!Main.magnifier_mode) && (Current_operation!=OPERATION_MAGNIFY) ) // Passage en mode zoom { Coming_from_zoom_factor_menu=1; Select_button(BUTTON_MAGNIFIER,LEFT_SIDE); @@ -3856,27 +3857,27 @@ void Button_Magnify_menu(void) void Button_Unselect_magnifier(void) { - if (Main_magnifier_mode) + if (Main.magnifier_mode) { // On sort du mode loupe - Main_magnifier_mode=0; + Main.magnifier_mode=0; // --> Recalculer le décalage de l'écran lorsqu'on sort de la loupe <-- // Centrage "brut" de lécran par rapport à la loupe - Main_offset_X=Main_magnifier_offset_X-((Screen_width-Main_magnifier_width)>>1); - Main_offset_Y=Main_magnifier_offset_Y-((Menu_Y-Main_magnifier_height)>>1); + Main.offset_X=Main.magnifier_offset_X-((Screen_width-Main.magnifier_width)>>1); + Main.offset_Y=Main.magnifier_offset_Y-((Menu_Y-Main.magnifier_height)>>1); // Correction en cas de débordement de l'image - if (Main_offset_X+Screen_width>Main_image_width) - Main_offset_X=Main_image_width-Screen_width; - if (Main_offset_X<0) - Main_offset_X=0; + if (Main.offset_X+Screen_width>Main.image_width) + Main.offset_X=Main.image_width-Screen_width; + if (Main.offset_X<0) + Main.offset_X=0; - if (Main_offset_Y+Menu_Y>Main_image_height) - Main_offset_Y=Main_image_height-Menu_Y; - if (Main_offset_Y<0) - Main_offset_Y=0; + if (Main.offset_Y+Menu_Y>Main.image_height) + Main.offset_Y=Main.image_height-Menu_Y; + if (Main.offset_Y<0) + Main.offset_Y=0; // La fonction d'affichage dans l'image est désormais un affichage normal. Pixel_preview=Pixel_preview_normal; @@ -4557,7 +4558,7 @@ void Display_effect_states(void) 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(C3,L3, "Tilemap",Main_tilemap_mode); + Display_effect_state(C3,L3, "Tilemap",Main.tilemap_mode); } @@ -4871,7 +4872,7 @@ void Button_Effects(void) { Button_Tilemap_mode(); Hide_cursor(); - Display_effect_state(C3,L3, "Tilemap" ,Main_tilemap_mode); + Display_effect_state(C3,L3, "Tilemap" ,Main.tilemap_mode); Display_cursor(); } else @@ -5056,7 +5057,7 @@ void Button_Text(void) g=text_palette[color].G; b=text_palette[color].B; - //if (r==Main_palette[color].R && g==Main_palette[color].G && b==Main_palette[color].B) + //if (r==Main.palette[color].R && g==Main.palette[color].G && b==Main.palette[color].B) // colmap[color]=color; //else colmap[color]=Best_color_perceptual_except(r,g,b,Back_color); @@ -5330,7 +5331,7 @@ void Store_brush(int index) Brush_container[index].Paintbrush_shape=Paintbrush_shape; Brush_container[index].Width=Paintbrush_width; Brush_container[index].Height=Paintbrush_height; - //memcpy(Brush_container[index].Palette,Main_palette,sizeof(T_Palette)); + //memcpy(Brush_container[index].Palette,Main.palette,sizeof(T_Palette)); // Preview: pick center for big mono brush if (Paintbrush_width>BRUSH_CONTAINER_PREVIEW_WIDTH) brush_offset_x = (Paintbrush_width-BRUSH_CONTAINER_PREVIEW_WIDTH)/2; @@ -5612,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 031d0d78..bd1db6fe 100644 --- a/src/buttons_effects.c +++ b/src/buttons_effects.c @@ -183,12 +183,12 @@ 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)) + 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++) + for (pixel=0; pixel < Main.image_width*Main.image_height; pixel++) { if (Main_backups->Pages->Image[4].Pixels[pixel]>3) { @@ -249,7 +249,7 @@ void Button_Constraint_menu(void) // Tilemap mode void Button_Tilemap_mode(void) { - Main_tilemap_mode=!Main_tilemap_mode; + Main.tilemap_mode=!Main.tilemap_mode; Tilemap_update(); } @@ -317,7 +317,7 @@ void Button_Tilemap_menu(void) byte changed = Config.Tilemap_allow_flipped_x!=flip_x || Config.Tilemap_allow_flipped_y!=flip_y || - !Main_tilemap_mode; + !Main.tilemap_mode; Config.Tilemap_allow_flipped_x=flip_x; Config.Tilemap_allow_flipped_y=flip_y; @@ -325,7 +325,7 @@ void Button_Tilemap_menu(void) if (changed) { - Main_tilemap_mode=1; + Main.tilemap_mode=1; Tilemap_update(); } } @@ -959,7 +959,7 @@ void Effects_off(void) Mask_mode=0; Sieve_mode=0; Snap_mode=0; - Main_tilemap_mode=0; + Main.tilemap_mode=0; } @@ -1240,7 +1240,7 @@ void Button_Sieve_menu(void) *(Brush_original_pixels + y_pos * Brush_width + x_pos) = (Sieve[x_pos][y_pos])?Fore_color:Back_color; // Grab palette - memcpy(Brush_original_palette, Main_palette,sizeof(T_Palette)); + memcpy(Brush_original_palette, Main.palette,sizeof(T_Palette)); // Remap (no change) Remap_brush(); diff --git a/src/engine.c b/src/engine.c index 81716117..e9efd50a 100644 --- a/src/engine.c +++ b/src/engine.c @@ -434,7 +434,7 @@ void Select_button(int btn_number,byte click) break; case FAMILY_INTERRUPTION: // Petit cas spécial dans la famille "Interruption": - if ((btn_number!=BUTTON_MAGNIFIER) || (!Main_magnifier_mode)) + if ((btn_number!=BUTTON_MAGNIFIER) || (!Main.magnifier_mode)) // Pour chaque bouton: for (b=0; b1) { - previewW = Min(Main_image_width/Menu_factor_X,Layer_button_width); - previewH = previewW * Main_image_height / Main_image_width * Menu_factor_X / Menu_factor_Y; + previewW = Min(Main.image_width/Menu_factor_X,Layer_button_width); + previewH = previewW * Main.image_height / Main.image_width * Menu_factor_X / Menu_factor_Y; if (previewH > Screen_height/4) { previewH = Screen_height/4; - previewW = Main_image_width*previewH/Main_image_height*Menu_factor_Y/Menu_factor_X; + previewW = Main.image_width*previewH/Main.image_height*Menu_factor_Y/Menu_factor_X; } Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X, @@ -620,11 +620,11 @@ void Layer_preview_on(int * preview_is_visible) for (y = 0; y < previewH*Pixel_height*Menu_factor_Y-1; y++) for (x = 0; x < previewW*Pixel_width*Menu_factor_X-1; x++) { - 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); + 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 - + imgx + imgy * Main_image_width)); + + imgx + imgy * Main.image_width)); } } Update_window_area(0,0,Window_width, Window_height); @@ -675,7 +675,7 @@ void Main_handler(void) else if (Drop_file_name) { // A file was dragged into Grafx2's window - if (Main_image_is_modified && !Confirmation_box("Discard unsaved changes ?")) + if (Main.image_is_modified && !Confirmation_box("Discard unsaved changes ?")) { // do nothing } @@ -703,11 +703,11 @@ void Main_handler(void) Compute_paintbrush_coordinates(); Redraw_layered_image(); End_of_modification(); - Main_image_is_modified=0; + Main.image_is_modified=0; } Destroy_context(&context); - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); Check_menu_mode(); Display_menu(); if (Config.Display_image_limits) @@ -808,84 +808,84 @@ void Main_handler(void) switch (key_index) { case SPECIAL_SCROLL_UP : // Scroll up - if (Main_magnifier_mode) - Scroll_magnifier(0,-(Main_magnifier_height>>2)); + if (Main.magnifier_mode) + Scroll_magnifier(0,-(Main.magnifier_height>>2)); else Scroll_screen(0,-(Screen_height>>3)); action++; break; case SPECIAL_SCROLL_DOWN : // Scroll down - if (Main_magnifier_mode) - Scroll_magnifier(0,(Main_magnifier_height>>2)); + if (Main.magnifier_mode) + Scroll_magnifier(0,(Main.magnifier_height>>2)); else Scroll_screen(0,(Screen_height>>3)); action++; break; case SPECIAL_SCROLL_LEFT : // Scroll left - if (Main_magnifier_mode) - Scroll_magnifier(-(Main_magnifier_width>>2),0); + if (Main.magnifier_mode) + Scroll_magnifier(-(Main.magnifier_width>>2),0); else Scroll_screen(-(Screen_width>>3),0); action++; break; case SPECIAL_SCROLL_RIGHT : // Scroll right - if (Main_magnifier_mode) - Scroll_magnifier((Main_magnifier_width>>2),0); + if (Main.magnifier_mode) + Scroll_magnifier((Main.magnifier_width>>2),0); else Scroll_screen((Screen_width>>3),0); action++; break; case SPECIAL_SCROLL_UP_FAST : // Scroll up faster - if (Main_magnifier_mode) - Scroll_magnifier(0,-(Main_magnifier_height>>1)); + if (Main.magnifier_mode) + Scroll_magnifier(0,-(Main.magnifier_height>>1)); else Scroll_screen(0,-(Screen_height>>2)); action++; break; case SPECIAL_SCROLL_DOWN_FAST : // Scroll down faster - if (Main_magnifier_mode) - Scroll_magnifier(0,(Main_magnifier_height>>1)); + if (Main.magnifier_mode) + Scroll_magnifier(0,(Main.magnifier_height>>1)); else Scroll_screen(0,(Screen_height>>2)); action++; break; case SPECIAL_SCROLL_LEFT_FAST : // Scroll left faster - if (Main_magnifier_mode) - Scroll_magnifier(-(Main_magnifier_width>>1),0); + if (Main.magnifier_mode) + Scroll_magnifier(-(Main.magnifier_width>>1),0); else Scroll_screen(-(Screen_width>>2),0); action++; break; case SPECIAL_SCROLL_RIGHT_FAST : // Scroll right faster - if (Main_magnifier_mode) - Scroll_magnifier((Main_magnifier_width>>1),0); + if (Main.magnifier_mode) + Scroll_magnifier((Main.magnifier_width>>1),0); else Scroll_screen((Screen_width>>2),0); action++; break; case SPECIAL_SCROLL_UP_SLOW : // Scroll up slower - if (Main_magnifier_mode) + if (Main.magnifier_mode) Scroll_magnifier(0,-1); else Scroll_screen(0,-1); action++; break; case SPECIAL_SCROLL_DOWN_SLOW : // Scroll down slower - if (Main_magnifier_mode) + if (Main.magnifier_mode) Scroll_magnifier(0,1); else Scroll_screen(0,1); action++; break; case SPECIAL_SCROLL_LEFT_SLOW : // Scroll left slower - if (Main_magnifier_mode) + if (Main.magnifier_mode) Scroll_magnifier(-1,0); else Scroll_screen(-1,0); action++; break; case SPECIAL_SCROLL_RIGHT_SLOW : // Scroll right slower - if (Main_magnifier_mode) + if (Main.magnifier_mode) Scroll_magnifier(1,0); else Scroll_screen(1,0); @@ -1361,7 +1361,7 @@ void Main_handler(void) Cycling_mode= !Cycling_mode; // Restore palette if (!Cycling_mode) - Set_palette(Main_palette); + Set_palette(Main.palette); action++; break; case SPECIAL_HOLD_PAN: @@ -1419,8 +1419,8 @@ void Main_handler(void) // Gestion de la souris Cursor_in_menu=(Mouse_Y>=Menu_Y) || - ( (Main_magnifier_mode) && (Mouse_X>=Main_separator_position) && - (Mouse_X=Main.separator_position) && + (Mouse_X=Menu_Y) || - ( (Main_magnifier_mode) && (Mouse_X>=Main_separator_position) && - (Mouse_X=Main.separator_position) && + (Mouse_XPos_Y+3)) / 5; Cursor_shape=CURSOR_SHAPE_ARROW; Cursor_hidden=old_hide_cursor; - Main_magnifier_mode=old_main_magnifier_mode; + Main.magnifier_mode=old_main_magnifier_mode; Display_cursor(); return selected_color; } @@ -2494,7 +2494,7 @@ short Wait_click_in_palette(T_Palette_button * button) selected_color=Read_pixel(Mouse_X,Mouse_Y); Cursor_shape=CURSOR_SHAPE_ARROW; Cursor_hidden=old_hide_cursor; - Main_magnifier_mode=old_main_magnifier_mode; + Main.magnifier_mode=old_main_magnifier_mode; Display_cursor(); return selected_color; } @@ -2505,7 +2505,7 @@ short Wait_click_in_palette(T_Palette_button * button) Hide_cursor(); Cursor_shape=CURSOR_SHAPE_ARROW; Cursor_hidden=old_hide_cursor; - Main_magnifier_mode=old_main_magnifier_mode; + Main.magnifier_mode=old_main_magnifier_mode; Display_cursor(); return -1; } @@ -2566,11 +2566,11 @@ void Get_color_behind_window(byte * color, byte * click) sprintf(str,"%d",a); d=strlen(str); strcat(str," ("); - sprintf(str+strlen(str),"%d",Main_palette[a].R); + sprintf(str+strlen(str),"%d",Main.palette[a].R); strcat(str,","); - sprintf(str+strlen(str),"%d",Main_palette[a].G); + sprintf(str+strlen(str),"%d",Main.palette[a].G); strcat(str,","); - sprintf(str+strlen(str),"%d",Main_palette[a].B); + sprintf(str+strlen(str),"%d",Main.palette[a].B); strcat(str,")"); a=24-d; for (index=strlen(str); indexMain_image_height) + if (Main.offset_Y+Screen_height>Main.image_height) { - if (Screen_height>Main_image_height) - Main_offset_Y=0; + if (Screen_height>Main.image_height) + Main.offset_Y=0; else - Main_offset_Y=Main_image_height-Screen_height; + Main.offset_Y=Main.image_height-Screen_height; } // On fait pareil pour le brouillon - if (Spare_offset_Y+Screen_height>Spare_image_height) + if (Spare.offset_Y+Screen_height>Spare.image_height) { - if (Screen_height>Spare_image_height) - Spare_offset_Y=0; + if (Screen_height>Spare.image_height) + Spare.offset_Y=0; else - Spare_offset_Y=Spare_image_height-Screen_height; + Spare.offset_Y=Spare.image_height-Screen_height; } Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Position_screen_according_to_zoom(); Compute_limits(); Compute_paintbrush_coordinates(); @@ -3626,14 +3626,14 @@ void Set_bar_visibility(word bar, int visible, int with_redraw) Compute_menu_offsets(); Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Position_screen_according_to_zoom(); Compute_limits(); Compute_paintbrush_coordinates(); if (with_redraw) { Display_menu(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Display_all_screen(); } } diff --git a/src/factory.c b/src/factory.c index f3aea685..e4b70886 100644 --- a/src/factory.c +++ b/src/factory.c @@ -165,7 +165,7 @@ do { \ #define DECLARE_UNSAVED(BIND) \ int BIND ## _unsaved(lua_State* L) \ { \ - Backup_if_necessary(L, Main_current_layer); \ + Backup_if_necessary(L, Main.current_layer); \ Register_main_writable(L); \ return BIND(L); \ } @@ -196,8 +196,8 @@ void Update_colors_during_script(void) { if (Palette_has_changed) { - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); + Set_palette(Main.palette); + Compute_optimal_menu_colors(Main.palette); Display_menu(); Palette_has_changed=0; } @@ -206,7 +206,7 @@ void Update_colors_during_script(void) /// Paint a pixel in image without updating the screen void Pixel_figure_no_screen(short x_pos,short y_pos,byte color) { - if (x_pos>0 && y_pos >0 && x_pos0 && y_pos >0 && x_posPages->Next; Main_backup_screen = Screen_backup; @@ -261,7 +261,7 @@ int L_SetBrushSize(lua_State* L) memset(Brush_original_pixels,Back_color,(long)Brush_width*Brush_height); memset(Brush,Back_color,(long)Brush_width*Brush_height); // Adopt the current palette. - memcpy(Brush_original_palette, Main_palette,sizeof(T_Palette)); + memcpy(Brush_original_palette, Main.palette,sizeof(T_Palette)); for (i=0; i<256; i++) Brush_colormap[i]=i; //-- @@ -297,7 +297,7 @@ int L_PutBrushPixel(lua_State* L) // First time writing in brush: // Adopt the current palette. - memcpy(Brush_original_palette, Main_palette,sizeof(T_Palette)); + memcpy(Brush_original_palette, Main.palette,sizeof(T_Palette)); memcpy(Brush_original_pixels, Brush, Brush_width*Brush_height); for (i=0; i<256; i++) Brush_colormap[i]=i; @@ -372,7 +372,7 @@ int L_SetPictureSize(lua_State* L) LUA_ARG_NUMBER(1, "setpicturesize", w, 1, 9999); LUA_ARG_NUMBER(2, "setpicturesize", h, 1, 9999); - if (w == Main_image_width && h == Main_image_height) + if (w == Main.image_width && h == Main.image_height) { // nothing to do at all return 0; @@ -394,9 +394,9 @@ int L_SetPictureSize(lua_State* L) 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(); @@ -427,9 +427,9 @@ int L_SetSparePictureSize(lua_State* L) 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(); @@ -438,8 +438,8 @@ int L_SetSparePictureSize(lua_State* L) int L_GetPictureSize(lua_State* L) { - lua_pushinteger(L, Main_image_width); - lua_pushinteger(L, Main_image_height); + lua_pushinteger(L, Main.image_width); + lua_pushinteger(L, Main.image_height); return 2; } @@ -473,7 +473,7 @@ int L_PutPicturePixel(lua_State* L) LUA_ARG_NUMBER(3, "putpicturepixel", c, INT_MIN, INT_MAX); // Bound check - if (x<0 || y<0 || x>=Main_image_width || y>=Main_image_height) + if (x<0 || y<0 || x>=Main.image_width || y>=Main.image_height) { // Silently ignored return 0; @@ -496,7 +496,7 @@ int L_PutSparePicturePixel(lua_State* L) LUA_ARG_NUMBER(3, "putsparepicturepixel", c, INT_MIN, INT_MAX); // Bound check - if (x<0 || y<0 || x>=Spare_image_width || y>=Spare_image_height) + if (x<0 || y<0 || x>=Spare.image_width || y>=Spare.image_height) { // Silently ignored return 0; @@ -563,10 +563,10 @@ int L_DrawFilledRect(lua_State* L) } // Clipping limits - if (max_x>Main_image_width) - max_x=Main_image_width-1; - if (max_y>Main_image_height) - max_y=Main_image_height-1; + if (max_x>Main.image_width) + max_x=Main.image_width-1; + if (max_y>Main.image_height) + max_y=Main.image_height-1; if (min_x<0) min_x=0; if (min_y<0) @@ -627,9 +627,9 @@ int L_DrawDisk(lua_State* L) // Compute clipping limits min_x=center_x-r+even<0 ? 0 : center_x-r+even; - max_x=center_x+r>=Main_image_width? Main_image_width-1 : center_x+r; + max_x=center_x+r>=Main.image_width? Main.image_width-1 : center_x+r; min_y=center_y-r+even<0 ? 0 : center_y-r+even; - max_y=center_y+r>=Main_image_height? Main_image_height-1 : center_y+r; + max_y=center_y+r>=Main.image_height? Main.image_height-1 : center_y+r; for (y_pos=min_y;y_pos<=max_y;y_pos++) { @@ -657,7 +657,7 @@ int L_GetPicturePixel(lua_State* L) LUA_ARG_NUMBER(2, "getpicturepixel", y, INT_MIN, INT_MAX); // Bound check - if (x<0 || y<0 || x>=Main_image_width || y>=Main_image_height) + 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); @@ -702,7 +702,7 @@ int L_GetLayerPixel(lua_State* L) LUA_ARG_NUMBER(2, "getlayerpixel", y, INT_MIN, INT_MAX); // Bound check - if (x<0 || y<0 || x>=Main_image_width || y>=Main_image_height) + 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); @@ -716,8 +716,8 @@ int L_GetLayerPixel(lua_State* L) int L_GetSparePictureSize(lua_State* L) { - lua_pushinteger(L, Spare_image_width); - lua_pushinteger(L, Spare_image_height); + lua_pushinteger(L, Spare.image_width); + lua_pushinteger(L, Spare.image_height); return 2; } @@ -732,13 +732,13 @@ int L_GetSpareLayerPixel(lua_State* L) LUA_ARG_NUMBER(2, "getsparelayerpixel", y, INT_MIN, INT_MAX); // Bound check - if (x<0 || y<0 || x>=Spare_image_width || y>=Spare_image_height) + 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); 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; } @@ -771,9 +771,9 @@ int L_GetSpareColor(lua_State* L) LUA_ARG_LIMIT (1, "getsparecolor"); LUA_ARG_NUMBER(1, "getsparecolor", c, INT_MIN, INT_MAX); - lua_pushinteger(L, Spare_palette[c].R); - lua_pushinteger(L, Spare_palette[c].G); - lua_pushinteger(L, Spare_palette[c].B); + lua_pushinteger(L, Spare.palette[c].R); + lua_pushinteger(L, Spare.palette[c].G); + lua_pushinteger(L, Spare.palette[c].B); return 3; } @@ -797,9 +797,9 @@ int L_SetColor(lua_State* L) LUA_ARG_NUMBER(4, "setcolor", b, INT_MIN, INT_MAX); - Main_palette[c].R=Round_palette_component(clamp_byte(r)); - Main_palette[c].G=Round_palette_component(clamp_byte(g)); - Main_palette[c].B=Round_palette_component(clamp_byte(b)); + Main.palette[c].R=Round_palette_component(clamp_byte(r)); + Main.palette[c].G=Round_palette_component(clamp_byte(g)); + Main.palette[c].B=Round_palette_component(clamp_byte(b)); // Set_color(c, r, g, b); Not needed. Update screen when script is finished Palette_has_changed=1; return 0; @@ -821,9 +821,9 @@ int L_GetColor(lua_State* L) LUA_ARG_LIMIT (1, "getcolor"); LUA_ARG_NUMBER(1, "getcolor", c, INT_MIN, INT_MAX); - lua_pushinteger(L, Main_palette[c].R); - lua_pushinteger(L, Main_palette[c].G); - lua_pushinteger(L, Main_palette[c].B); + lua_pushinteger(L, Main.palette[c].R); + lua_pushinteger(L, Main.palette[c].G); + lua_pushinteger(L, Main.palette[c].B); return 3; } @@ -906,12 +906,12 @@ int L_MatchColor2(lua_State* L) continue; diff_c = sqrt( - (0.26*(Main_palette[col].R-r))* - (0.26*(Main_palette[col].R-r))+ - (0.55*(Main_palette[col].G-g))* - (0.55*(Main_palette[col].G-g))+ - (0.19*(Main_palette[col].B-b))* - (0.19*(Main_palette[col].B-b))); + (0.26*(Main.palette[col].R-r))* + (0.26*(Main.palette[col].R-r))+ + (0.55*(Main.palette[col].G-g))* + (0.55*(Main.palette[col].G-g))+ + (0.19*(Main.palette[col].B-b))* + (0.19*(Main.palette[col].B-b))); // Exact match if (diff_c<1.0) { @@ -919,7 +919,7 @@ int L_MatchColor2(lua_State* L) return 1; } - bri = sqrt(0.26*0.26*(Main_palette[col].R*Main_palette[col].R) + 0.55*0.55*(Main_palette[col].G*Main_palette[col].G) + 0.19*0.19*(Main_palette[col].B*Main_palette[col].B)); + bri = sqrt(0.26*0.26*(Main.palette[col].R*Main.palette[col].R) + 0.55*0.55*(Main.palette[col].G*Main.palette[col].G) + 0.19*0.19*(Main.palette[col].B*Main.palette[col].B)); diff_b = fabs(target_bri-bri); diff=l_weight*(diff_b-diff_c)+diff_c; @@ -1914,13 +1914,13 @@ 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 (! ((1 << Spare_current_layer) & Spare_layers_visible)) + if (! ((1 << Spare.current_layer) & Spare.layers_visible)) { - Spare_layers_visible |= (1 << Spare_current_layer); + Spare.layers_visible |= (1 << Spare.current_layer); } } return 0; @@ -1932,15 +1932,15 @@ 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); + Backup_if_necessary(L, Main.current_layer); // if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { - if (! ((1 << Main_current_layer) & Main_layers_visible)) + if (! ((1 << Main.current_layer) & Main.layers_visible)) { - Main_layers_visible |= (1 << Main_current_layer); + Main.layers_visible |= (1 << Main.current_layer); Redraw_layered_image(); } else @@ -2302,8 +2302,8 @@ void Run_script(const char *script_subdirectory, const char *script_filename) const char* message; byte old_cursor_shape=Cursor_shape; char buf[MAX_PATH_CHARACTERS]; - int original_image_width=Main_image_width; - int original_image_height=Main_image_height; + int original_image_width=Main.image_width; + int original_image_height=Main.image_height; // Some scripts are slow Cursor_shape=CURSOR_SHAPE_HOURGLASS; @@ -2499,8 +2499,8 @@ void Run_script(const char *script_subdirectory, const char *script_filename) Display_all_screen(); // Update tilemap if image size has changed - if (original_image_width!=Main_image_width - || original_image_height!=Main_image_height) + if (original_image_width!=Main.image_width + || original_image_height!=Main.image_height) { Tilemap_update(); } diff --git a/src/fileformats.c b/src/fileformats.c index bb922c23..b35cfb8f 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -2760,8 +2760,8 @@ void Load_GIF(T_IO_Context * context) { // 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->Image[Main.current_layer].Pixels, + Main_backups->Pages->Image[Main.current_layer-1].Pixels, Main_backups->Pages->Width*Main_backups->Pages->Height); } else @@ -2820,7 +2820,7 @@ void Load_GIF(T_IO_Context * context) int y; for (y=0; yPages->Image[Main_current_layer].Pixels + 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); diff --git a/src/filesel.c b/src/filesel.c index e1189b75..5540d9eb 100644 --- a/src/filesel.c +++ b/src/filesel.c @@ -2199,10 +2199,10 @@ byte Button_Load_or_Save(T_Selector_settings *settings, byte load, T_IO_Context // On restaure les données de l'image qui ont certainement été modifiées // par la preview. - Set_palette(Main_palette); + Set_palette(Main.palette); Back_color=initial_back_color; - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); temp=(Window_pos_Y+(Window_height*Menu_factor_Y) Main_separator_position) - effective_w = Main_separator_position - effective_X; + if(Main.magnifier_mode && effective_X + effective_w > Main.separator_position) + effective_w = Main.separator_position - effective_X; else if(effective_X + effective_w > Screen_width) effective_w = Screen_width - effective_X; @@ -138,13 +138,13 @@ void Update_part_of_screen(short x, short y, short width, short height) Update_rect(effective_X,effective_Y,effective_w,effective_h); // Now update the "zoomed" part of the display - if(Main_magnifier_mode) + if(Main.magnifier_mode) { // Convert picture to zoomed-screen coordinates - effective_X = (x-Main_magnifier_offset_X)*Main_magnifier_factor; - effective_Y = (y-Main_magnifier_offset_Y)*Main_magnifier_factor; - effective_w = width * Main_magnifier_factor; - effective_h = height * Main_magnifier_factor; + effective_X = (x-Main.magnifier_offset_X)*Main.magnifier_factor; + effective_Y = (y-Main.magnifier_offset_Y)*Main.magnifier_factor; + effective_w = width * Main.magnifier_factor; + effective_h = height * Main.magnifier_factor; // Apply horizontal clipping if (effective_X < 0) @@ -153,11 +153,11 @@ void Update_part_of_screen(short x, short y, short width, short height) if (effective_w<0) return; - effective_X = Main_separator_position + SEPARATOR_WIDTH*Menu_factor_X; + effective_X = Main.separator_position + SEPARATOR_WIDTH*Menu_factor_X; } else - effective_X += Main_separator_position + SEPARATOR_WIDTH*Menu_factor_X; - diff = effective_X+effective_w-Min(Screen_width, Main_X_zoom+(Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor); + effective_X += Main.separator_position + SEPARATOR_WIDTH*Menu_factor_X; + diff = effective_X+effective_w-Min(Screen_width, Main.X_zoom+(Main.image_width-Main.magnifier_offset_X)*Main.magnifier_factor); if (diff>0) { effective_w -=diff; @@ -174,7 +174,7 @@ void Update_part_of_screen(short x, short y, short width, short height) return; effective_Y = 0; } - diff = effective_Y+effective_h-Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor); + diff = effective_Y+effective_h-Min(Menu_Y, (Main.image_height-Main.magnifier_offset_Y)*Main.magnifier_factor); if (diff>0) { effective_h -=diff; @@ -196,17 +196,17 @@ void Update_part_of_screen(short x, short y, short width, short height) // In this case, the whole magnified area requires a refreshed grid. // This could be optimized further, but at the moment this seemed // fast enough. - if (Show_grid && Main_tilemap_mode && ( + if (Show_grid && Main.tilemap_mode && ( x/Snap_width <(x+width )/Snap_width || y/Snap_height<(y+height)/Snap_height)) { short w,h; - w=Min(Screen_width-Main_X_zoom, (Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor); - h=Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor); + w=Min(Screen_width-Main.X_zoom, (Main.image_width-Main.magnifier_offset_X)*Main.magnifier_factor); + h=Min(Menu_Y, (Main.image_height-Main.magnifier_offset_Y)*Main.magnifier_factor); - Redraw_grid(Main_X_zoom,0,w,h); - Update_rect(Main_X_zoom,0,w,h); + Redraw_grid(Main.X_zoom,0,w,h); + Update_rect(Main.X_zoom,0,w,h); } else { @@ -447,9 +447,9 @@ try_again: free(Horizontal_line_buffer); Horizontal_line_buffer=(byte *)malloc(Pixel_width * - ((Screen_width>Main_image_width)?Screen_width:Main_image_width)); + ((Screen_width>Main.image_width)?Screen_width:Main.image_width)); - Set_palette(Main_palette); + Set_palette(Main.palette); Current_resolution=0; if (fullscreen) @@ -483,11 +483,11 @@ try_again: if (fullscreen) Set_mouse_position(); - Spare_offset_X=0; // | Il faut penser à éviter les incohérences - Spare_offset_Y=0; // |- de décalage du brouillon par rapport à - Spare_magnifier_mode=0; // | la résolution. + Spare.offset_X=0; // | Il faut penser à éviter les incohérences + Spare.offset_Y=0; // |- de décalage du brouillon par rapport à + Spare.magnifier_mode=0; // | la résolution. - if (Main_magnifier_mode) + if (Main.magnifier_mode) { Pixel_preview=Pixel_preview_magnifier; } @@ -495,18 +495,18 @@ try_again: { Pixel_preview=Pixel_preview_normal; // Recaler la vue (meme clipping que dans Scroll_screen()) - if (Main_offset_X+Screen_width>Main_image_width) - Main_offset_X=Main_image_width-Screen_width; - if (Main_offset_X<0) - Main_offset_X=0; - if (Main_offset_Y+Menu_Y>Main_image_height) - Main_offset_Y=Main_image_height-Menu_Y; - if (Main_offset_Y<0) - Main_offset_Y=0; + if (Main.offset_X+Screen_width>Main.image_width) + Main.offset_X=Main.image_width-Screen_width; + if (Main.offset_X<0) + Main.offset_X=0; + if (Main.offset_Y+Menu_Y>Main.image_height) + Main.offset_Y=Main.image_height-Menu_Y; + if (Main.offset_Y<0) + Main.offset_Y=0; } Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) Position_screen_according_to_zoom(); Compute_limits(); Compute_paintbrush_coordinates(); @@ -522,8 +522,8 @@ try_again: void Resize_image(word chosen_width,word chosen_height) { - word old_width=Main_image_width; - word old_height=Main_image_height; + word old_width=Main.image_width; + word old_height=Main.image_height; int i; // +-+-+ @@ -536,17 +536,17 @@ void Resize_image(word chosen_width,word chosen_height) if (Backup_with_new_dimensions(chosen_width,chosen_height)) { // La nouvelle page a pu être allouée, elle est pour l'instant pleine de - // 0s. Elle fait Main_image_width de large. + // 0s. Elle fait Main.image_width de large. - Main_image_is_modified=1; + Main.image_is_modified=1; // On copie donc maintenant la partie C dans la nouvelle image. 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), - Min(old_height,Main_image_height),old_width, - Main_backups->Pages->Image[i].Pixels,0,0,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); } Redraw_layered_image(); } @@ -575,9 +575,9 @@ void Remap_spare(void) // On calcule la table d'utilisation des couleurs for (layer=0; layerPages->Nb_layers; layer++) - for (y_pos=0;y_posPages->Image[layer].Pixels+(y_pos*Spare_image_width+x_pos))]=1; + for (y_pos=0;y_posPages->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 @@ -588,13 +588,13 @@ void Remap_spare(void) // ne seront pas utilisées par Remap_general_lowlevel. for (color=0;color<=255;color++) if (used[color]) - used[color]=Best_color_perceptual(Spare_palette[color].R,Spare_palette[color].G,Spare_palette[color].B); + used[color]=Best_color_perceptual(Spare.palette[color].R,Spare.palette[color].G,Spare.palette[color].B); // 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); + 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]; @@ -637,9 +637,9 @@ void Get_colors_from_brush(void) // Try locate it in current palette for (image_color=0; image_color<256; image_color++) { - if (Brush_original_palette[color].R==Main_palette[image_color].R - && Brush_original_palette[color].G==Main_palette[image_color].G - && Brush_original_palette[color].B==Main_palette[image_color].B) + if (Brush_original_palette[color].R==Main.palette[image_color].R + && Brush_original_palette[color].G==Main.palette[image_color].G + && Brush_original_palette[color].B==Main.palette[image_color].B) { // Color already in main palette: @@ -668,9 +668,9 @@ void Get_colors_from_brush(void) if (!usage[image_color]) { // Copy from color to image_color - Main_palette[image_color].R=Brush_original_palette[color].R; - Main_palette[image_color].G=Brush_original_palette[color].G; - Main_palette[image_color].B=Brush_original_palette[color].B; + Main.palette[image_color].R=Brush_original_palette[color].R; + Main.palette[image_color].G=Brush_original_palette[color].G; + Main.palette[image_color].B=Brush_original_palette[color].B; image_color++; break; @@ -680,15 +680,15 @@ void Get_colors_from_brush(void) } Remap_brush(); - Set_palette(Main_palette); - Compute_optimal_menu_colors(Main_palette); + Set_palette(Main.palette); + Compute_optimal_menu_colors(Main.palette); Hide_cursor(); Display_all_screen(); Display_menu(); Display_cursor(); End_of_modification(); - Main_image_is_modified=1; + Main.image_is_modified=1; } @@ -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) @@ -920,15 +920,15 @@ void Fill_general(byte fill_color) (Paintbrush_Y<=Limit_bottom) ) { // If tilemap mode is ON, ignore action if it's outside grid limits - if (Main_tilemap_mode) + if (Main.tilemap_mode) { if (Paintbrush_X= (Main_image_width-Snap_offset_X)/Snap_width*Snap_width+Snap_offset_X) + if (Paintbrush_X >= (Main.image_width-Snap_offset_X)/Snap_width*Snap_width+Snap_offset_X) return; if (Paintbrush_Y= (Main_image_height-Snap_offset_Y)/Snap_height*Snap_height+Snap_offset_Y) + if (Paintbrush_Y >= (Main.image_height-Snap_offset_Y)/Snap_height*Snap_height+Snap_offset_Y) return; } @@ -948,7 +948,7 @@ void Fill_general(byte fill_color) Update_FX_feedback(0); // If tilemap mode is ON, adapt limits to current tile only - if (Main_tilemap_mode) + if (Main.tilemap_mode) { Limit_right = Min(Limit_right, (Paintbrush_X-Snap_offset_X)/Snap_width*Snap_width+Snap_width-1+Snap_offset_X); Limit_left = Max(Limit_left, (Paintbrush_X-Snap_offset_X)/Snap_width*Snap_width+Snap_offset_X); @@ -973,35 +973,35 @@ 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.image_width, // width de la source + Main_backups->Pages->Image[Main.current_layer].Pixels, // Destination Limit_left,Limit_top, // Pos X et Y destination - Main_image_width); // width 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, - Limit_left,bottom_reached+1,Main_image_width); + 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, - Limit_left,top_reached,Main_image_width); + 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, - right_reached+1,top_reached,Main_image_width); + 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, // otherwise it will not display other modified tiles. @@ -1035,14 +1035,14 @@ void Fill_general(byte fill_color) // puisque les seuls points qui ont changé dans l'image ont été raffichés // par l'utilisation de "Display_pixel()", et que les autres... eh bein // on n'y a jamais touché à l'écran les autres: ils sont donc corrects. - if(Main_magnifier_mode) + if(Main.magnifier_mode) { short w,h; - w=Min(Screen_width-Main_X_zoom, (Main_image_width-Main_magnifier_offset_X)*Main_magnifier_factor); - h=Min(Menu_Y, (Main_image_height-Main_magnifier_offset_Y)*Main_magnifier_factor); + w=Min(Screen_width-Main.X_zoom, (Main.image_width-Main.magnifier_offset_X)*Main.magnifier_factor); + h=Min(Menu_Y, (Main.image_height-Main.magnifier_offset_Y)*Main.magnifier_factor); - Redraw_grid(Main_X_zoom,0,w,h); + Redraw_grid(Main.X_zoom,0,w,h); } Update_rect(0,0,0,0); @@ -1124,8 +1124,8 @@ void Fill_general(byte fill_color) (x_pos<=Limit_right) && (y_pos>=Limit_top) && (y_pos<=Limit_bottom) ) - Pixel_preview(x_pos,y_pos,xor_lut[Read_pixel(x_pos-Main_offset_X, - y_pos-Main_offset_Y)]); + Pixel_preview(x_pos,y_pos,xor_lut[Read_pixel(x_pos-Main.offset_X, + y_pos-Main.offset_Y)]); } // Affichage d'un point pour une preview en xor additif @@ -1138,7 +1138,7 @@ void Fill_general(byte fill_color) (x_pos<=Limit_right) && (y_pos>=Limit_top) && (y_pos<=Limit_bottom) ) - Pixel_preview(x_pos,y_pos,xor_lut[Main_screen[x_pos+y_pos*Main_image_width]]); + Pixel_preview(x_pos,y_pos,xor_lut[Main_screen[x_pos+y_pos*Main.image_width]]); } @@ -2562,7 +2562,7 @@ void Polyfill_general(int vertices, short * points, int color) initial_edge = NULL; // On ne connait pas simplement les xmin et xmax ici, mais de toutes façon ce n'est pas utilisé en preview - Update_part_of_screen(0,top,Main_image_width,bottom-top+1); + Update_part_of_screen(0,top,Main.image_width,bottom-top+1); } @@ -2606,8 +2606,8 @@ void Replace(byte new_color) { byte old_color; - if ((Paintbrush_XPages->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); } @@ -2931,18 +2931,18 @@ void Redraw_grid(short x, short y, unsigned short w, unsigned short h) if (!Show_grid) return; - row=y+((Snap_height*1000-(y-0)/Main_magnifier_factor-Main_magnifier_offset_Y+Snap_offset_Y-1)%Snap_height)*Main_magnifier_factor+Main_magnifier_factor-1; + row=y+((Snap_height*1000-(y-0)/Main.magnifier_factor-Main.magnifier_offset_Y+Snap_offset_Y-1)%Snap_height)*Main.magnifier_factor+Main.magnifier_factor-1; while (row < y+h) { Horizontal_grid_line(x, row, w); - row+= Snap_height*Main_magnifier_factor; + row+= Snap_height*Main.magnifier_factor; } - col=x+((Snap_width*1000-(x-Main_X_zoom)/Main_magnifier_factor-Main_magnifier_offset_X+Snap_offset_X-1)%Snap_width)*Main_magnifier_factor+Main_magnifier_factor-1; + col=x+((Snap_width*1000-(x-Main.X_zoom)/Main.magnifier_factor-Main.magnifier_offset_X+Snap_offset_X-1)%Snap_width)*Main.magnifier_factor+Main.magnifier_factor-1; while (col < x+w) { Vertical_grid_line(col, y, h); - col+= Snap_width*Main_magnifier_factor; + col+= Snap_width*Main.magnifier_factor; } } @@ -2954,61 +2954,61 @@ byte Read_pixel_from_current_screen (word x,word y) 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_current_layer==4) - return *(Main_backups->Pages->Image[Main_current_layer].Pixels + x+y*Main_image_width); + if (Main.current_layer==4) + return *(Main_backups->Pages->Image[Main.current_layer].Pixels + x+y*Main.image_width); - color = *(Main_screen+y*Main_image_width+x); + color = *(Main_screen+y*Main.image_width+x); 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); + depth = *(Main_visible_image_depth_buffer.Image+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); } /// Paint a a single pixel in image only : using layered display. 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; - if ( depth <= Main_current_layer) + 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; + if ( depth <= Main.current_layer) { 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; + *(x+y*Main.image_width+Main_screen)=color; } } /// Paint a a single pixel in image and on screen : using layered display. 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; - if ( depth <= Main_current_layer) + 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; + if ( depth <= Main.current_layer) { 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; + *(x+y*Main.image_width+Main_screen)=color; Pixel_preview(x,y,color); } @@ -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,8 +3134,8 @@ 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 - + x + y * Main_image_width); + c1 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + + x + y * Main.image_width); if (c1 == color) return; @@ -3144,8 +3144,8 @@ 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 - + (x2 + start) + (y2 + starty) * Main_image_width); + 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) continue; @@ -3177,8 +3177,8 @@ done: for (x2 = 0; x2 < 8; x2++) for (y2 = 0; y2 < 8; y2++) { - c2 = *(Main_backups->Pages->Image[Main_current_layer].Pixels - + (x2 + start) + (y2 + starty) * Main_image_width); + 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); } else { @@ -3196,8 +3196,8 @@ 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 - + x + y * Main_image_width); + c1 = *(Main_backups->Pages->Image[Main.current_layer].Pixels + + x + y * Main.image_width); // Pixel is already of the wanted color: nothing to do if (c1 == color) @@ -3207,8 +3207,8 @@ 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 - + (x2 + start) + (y2 + starty) * Main_image_width); + 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) continue; @@ -3240,8 +3240,8 @@ done: for (x2 = 0; x2 < 8; x2++) for (y2 = 0; y2 < 8; y2++) { - c2 = *(Main_backups->Pages->Image[Main_current_layer].Pixels - + (x2 + start) + (y2 + starty) * Main_image_width); + 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); } else { @@ -3257,14 +3257,14 @@ 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) + if ( depth == Main.current_layer) { // Draw that color on the visible image buffer - *(x+y*Main_image_width+Main_screen)=color; + *(x+y*Main.image_width+Main_screen)=color; } } @@ -3274,14 +3274,14 @@ 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) + if ( depth == Main.current_layer) { // Draw that color on the visible image buffer - *(x+y*Main_image_width+Main_screen)=color; + *(x+y*Main.image_width+Main_screen)=color; Pixel_preview(x,y,color); } @@ -3293,14 +3293,14 @@ 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; + *(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); + if (Main.layers_visible & (1 << color)) + 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; + *(x+y*Main.image_width+Main_screen)=color; } } @@ -3310,14 +3310,14 @@ 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; + *(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); + if (Main.layers_visible & (1 << color)) + 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; + *(x+y*Main.image_width+Main_screen)=color; Pixel_preview(x,y,color); } @@ -3328,17 +3328,17 @@ 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) @@ -3377,13 +3377,13 @@ void Update_pixel_renderer(void) Pixel_in_current_screen_with_preview = Pixel_in_screen_zx_with_preview; } // Implicit else : Image_mode must be IMAGE_MODE_MODE5 - else if ( Main_current_layer == 4) + else if ( Main.current_layer == 4) { // overlay Pixel_in_current_screen = Pixel_in_screen_overlay; Pixel_in_current_screen_with_preview = Pixel_in_screen_overlay_with_preview; } - else if (Main_current_layer<4 && (Main_layers_visible & (1<<4))) + else if (Main.current_layer<4 && (Main.layers_visible & (1<<4))) { // underlay Pixel_in_current_screen = Pixel_in_screen_underlay; diff --git a/src/help.c b/src/help.c index dfefdb02..203bfd0d 100644 --- a/src/help.c +++ b/src/help.c @@ -785,17 +785,17 @@ void Button_Stats(void) #if defined(__WIN32__) { ULARGE_INTEGER tailleU; - GetDiskFreeSpaceEx(Main_selector.Directory,&tailleU,NULL,NULL); + GetDiskFreeSpaceEx(Main.selector.Directory,&tailleU,NULL,NULL); mem_size = tailleU.QuadPart; } #elif defined(__linux__) || defined(__macosx__) || defined(__FreeBSD__) || defined(__SYLLABLE__) || defined(__AROS__) { struct statfs disk_info; - statfs(Main_selector.Directory,&disk_info); + statfs(Main.selector.Directory,&disk_info); mem_size=(qword) disk_info.f_bfree * (qword) disk_info.f_bsize; } #elif defined(__HAIKU__) - mem_size = haiku_get_free_space(Main_selector.Directory); + mem_size = haiku_get_free_space(Main.selector.Directory); #elif defined (__MINT__) mem_size=0; Dfree(&drvInfo,0); @@ -813,16 +813,16 @@ void Button_Stats(void) if (mem_size != 0) { #if defined(__AROS__) - char *colon = strchr(Main_selector.Directory, ':'); - int len = strlen(Main_selector.Directory); + char *colon = strchr(Main.selector.Directory, ':'); + int len = strlen(Main.selector.Directory); if (colon) { - len = (long)colon - (long)Main_selector.Directory; + len = (long)colon - (long)Main.selector.Directory; } if (len > 8) len = 8; - sprintf(buffer,"Free space on %.*s:",len,Main_selector.Directory); + sprintf(buffer,"Free space on %.*s:",len,Main.selector.Directory); #else - sprintf(buffer,"Free space on %c:",Main_selector.Directory[0]); + sprintf(buffer,"Free space on %c:",Main.selector.Directory[0]); #endif Print_in_window(10,y,buffer,STATS_TITLE_COLOR,MC_Black); @@ -853,7 +853,7 @@ void Button_Stats(void) // Affichage des dimensions de l'image Print_in_window(18,y,"Dimensions :",STATS_TITLE_COLOR,MC_Black); - sprintf(buffer,"%dx%d",Main_image_width,Main_image_height); + sprintf(buffer,"%dx%d",Main.image_width,Main.image_height); Print_in_window(122,y,buffer,STATS_DATA_COLOR,MC_Black); y+=8; diff --git a/src/input.c b/src/input.c index c4a9adba..1ed2c83c 100644 --- a/src/input.c +++ b/src/input.c @@ -231,22 +231,22 @@ int Move_cursor_with_constraints() Input_new_mouse_Y=Menu_Y-1; //La ligne !!au-dessus!! du menu } - if(Main_magnifier_mode) + if(Main.magnifier_mode) { if(Operation_in_magnifier==0) { - if(Input_new_mouse_X>=Main_separator_position) + if(Input_new_mouse_X>=Main.separator_position) { mouse_blocked=1; - Input_new_mouse_X=Main_separator_position-1; + Input_new_mouse_X=Main.separator_position-1; } } else { - if(Input_new_mouse_X Main_separator_position) + if(Main.magnifier_mode && Input_new_mouse_Y < Menu_Y && Input_new_mouse_X > Main.separator_position) { // Cursor in zoomed area if (delta_x<0) - Input_new_mouse_X = Max(Main_separator_position, x-Main_magnifier_factor); + Input_new_mouse_X = Max(Main.separator_position, x-Main.magnifier_factor); else if (delta_x>0) - Input_new_mouse_X = Min(Screen_width-1, x+Main_magnifier_factor); + Input_new_mouse_X = Min(Screen_width-1, x+Main.magnifier_factor); if (delta_y<0) - Input_new_mouse_Y = Max(0, y-Main_magnifier_factor); + Input_new_mouse_Y = Max(0, y-Main.magnifier_factor); else if (delta_y>0) - Input_new_mouse_Y = Min(Screen_height-1, y+Main_magnifier_factor); + Input_new_mouse_Y = Min(Screen_height-1, y+Main.magnifier_factor); } else { @@ -1110,9 +1110,9 @@ int Color_cycling(void) // Initialize the palette for(color=0;color<256;color++) { - PaletteSDL[color].r=Main_palette[color].R; - PaletteSDL[color].g=Main_palette[color].G; - PaletteSDL[color].b=Main_palette[color].B; + PaletteSDL[color].r=Main.palette[color].R; + PaletteSDL[color].g=Main.palette[color].G; + PaletteSDL[color].b=Main.palette[color].B; } for (i=0; i<16; i++) { @@ -1123,9 +1123,9 @@ int Color_cycling(void) { 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 cefa95c6..9382335b 100644 --- a/src/layers.c +++ b/src/layers.c @@ -40,39 +40,39 @@ void Layer_activate(int layer, short side) return; // Keep a copy of which layers were visible - old_layers = Main_layers_visible; + old_layers = Main.layers_visible; if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { if (side == RIGHT_SIDE) { // Right-click on current layer - if (Main_current_layer == layer) + if (Main.current_layer == layer) { - if (Main_layers_visible == (dword)(1<Pages->Image[Main_current_layer].Pixels, - Main_backups->Pages->Image[Main_current_layer-1].Pixels, + 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) { @@ -169,7 +169,7 @@ void Button_Layer_remove(void) { // 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(); @@ -352,10 +352,10 @@ void Button_Layer_merge(void) { Hide_cursor(); - if (Main_current_layer>0) + if (Main.current_layer>0) { // Backup layer below the current - Backup_layers(Main_current_layer-1); + Backup_layers(Main.current_layer-1); Merge_layer(); @@ -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,20 +383,20 @@ 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; + layer_flags = (Main.layers_visible >> Main.current_layer) & 3; // Only needed if they are different. if (layer_flags == 1 || layer_flags == 2) { // One is on, the other is off. Negating them will // perform the swap. - Main_layers_visible ^= (3 << Main_current_layer); + Main.layers_visible ^= (3 << Main.current_layer); } - Main_current_layer++; + Main.current_layer++; Update_screen_targets(); Redraw_layered_image(); @@ -414,7 +414,7 @@ void Button_Layer_down(void) { Hide_cursor(); - if (Main_current_layer > 0) + if (Main.current_layer > 0) { T_Image tmp; dword layer_flags; @@ -423,21 +423,21 @@ 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; + layer_flags = (Main.layers_visible >> (Main.current_layer-1)) & 3; // Only needed if they are different. if (layer_flags == 1 || layer_flags == 2) { // Only needed if they are different. // One is on, the other is off. Negating them will // perform the swap. - Main_layers_visible ^= (3 << (Main_current_layer-1)); + Main.layers_visible ^= (3 << (Main.current_layer-1)); } - Main_current_layer--; + Main.current_layer--; Update_screen_targets(); Redraw_layered_image(); Display_layerbar(); @@ -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,7 +547,7 @@ 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) @@ -581,7 +581,7 @@ void Button_Anim_time(void) void Button_Anim_first_frame(void) { - if (Main_current_layer>0) + if (Main.current_layer>0) Layer_activate(0,LEFT_SIDE); Hide_cursor(); @@ -593,10 +593,10 @@ void Button_Anim_prev_frame(void) { if (Main_backups->Pages->Nb_layers>1) { - if (Main_current_layer==0) + if (Main.current_layer==0) Layer_activate(Main_backups->Pages->Nb_layers-1,LEFT_SIDE); else - Layer_activate(Main_current_layer-1,LEFT_SIDE); + Layer_activate(Main.current_layer-1,LEFT_SIDE); } Hide_cursor(); Unselect_button(BUTTON_ANIM_PREV_FRAME); @@ -607,10 +607,10 @@ void Button_Anim_next_frame(void) { 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); + Layer_activate(Main.current_layer+1,LEFT_SIDE); } Hide_cursor(); @@ -620,7 +620,7 @@ void Button_Anim_next_frame(void) void Button_Anim_last_frame(void) { - if (Main_current_layer < (Main_backups->Pages->Nb_layers-1)) + if (Main.current_layer < (Main_backups->Pages->Nb_layers-1)) Layer_activate((Main_backups->Pages->Nb_layers-1),LEFT_SIDE); Hide_cursor(); @@ -645,13 +645,13 @@ void Button_Anim_continuous_next(void) time_now=SDL_GetTicks(); time_in_current_frame += time_now-time_start; time_start=time_now; - target_frame = Main_current_layer; + target_frame = Main.current_layer; 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; } - if (target_frame != Main_current_layer) + if (target_frame != Main.current_layer) { Layer_activate(target_frame,LEFT_SIDE); } @@ -680,13 +680,13 @@ void Button_Anim_continuous_prev(void) time_now=SDL_GetTicks(); time_in_current_frame += time_now-time_start; time_start=time_now; - target_frame = Main_current_layer; + target_frame = Main.current_layer; 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; } - if (target_frame != Main_current_layer) + if (target_frame != Main.current_layer) { Layer_activate(target_frame,LEFT_SIDE); } diff --git a/src/loadsave.c b/src/loadsave.c index adbf4184..dac03e23 100644 --- a/src/loadsave.c +++ b/src/loadsave.c @@ -276,7 +276,7 @@ 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); break; @@ -485,8 +485,8 @@ void Pre_load(T_IO_Context *context, short width, short height, long file_size, // Load into layer 0, by default. context->Nb_layers=1; - Main_current_layer=0; - Main_layers_visible=1<<0; + Main.current_layer=0; + Main.layers_visible=1<<0; Set_loading_layer(context,0); // Remove previous comment, unless we load just a palette @@ -777,7 +777,7 @@ void Load_image(T_IO_Context *context) Backup_layers(LAYER_NONE); } // Copy the loaded palette - memcpy(Main_palette, context->Palette, sizeof(T_Palette)); + memcpy(Main.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: @@ -797,9 +797,9 @@ void Load_image(T_IO_Context *context) } // On considère que l'image chargée n'est plus modifiée - Main_image_is_modified=0; + Main.image_is_modified=0; // Et on documente la variable Main_fileformat avec la valeur: - Main_fileformat=format->Identifier; + Main.fileformat=format->Identifier; // already done initially on Backup_with_new_dimensions //Main_image_width= context->Width; @@ -807,12 +807,12 @@ void Load_image(T_IO_Context *context) if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION) { - Main_current_layer = 0; + Main.current_layer = 0; } else { - Main_current_layer = context->Nb_layers - 1; - Main_layers_visible = (2<Nb_layers - 1; + Main.layers_visible = (2<Pages->Background_transparent = context->Background_transparent; // Correction des dimensions - if (Main_image_width<1) - Main_image_width=1; - if (Main_image_height<1) - Main_image_height=1; + if (Main.image_width<1) + Main.image_width=1; + if (Main.image_height<1) + Main.image_height=1; // Color cyling ranges: for (i=0; i<16; i++) @@ -844,9 +844,9 @@ void Load_image(T_IO_Context *context) else if (File_error!=1) { // On considère que l'image chargée est encore modifiée - Main_image_is_modified=1; + Main.image_is_modified=1; // Et on documente la variable Main_fileformat avec la valeur: - Main_fileformat=format->Identifier; + Main.fileformat=format->Identifier; } else { @@ -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 { @@ -1035,7 +1035,7 @@ void Save_image(T_IO_Context *context) 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. @@ -1233,9 +1233,9 @@ 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) - Emergency_backup(SAFETYBACKUP_PREFIX_A "999999" BACKUP_FILE_EXTENSION,Main_screen, Main_image_width, Main_image_height, &Main_palette); + 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); + 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) @@ -1279,7 +1279,7 @@ void Init_context_preview(T_IO_Context * context, char *file_name, char *file_di context->Type = CONTEXT_PREVIEW; context->File_name = file_name; context->File_directory = file_directory; - context->Format = Main_fileformat; // FIXME ? + context->Format = Main.fileformat; // FIXME ? } // Setup for loading/saving an intermediate backup @@ -1298,10 +1298,10 @@ void Init_context_layered_image(T_IO_Context * context, char *file_name, char *f context->Type = CONTEXT_MAIN_IMAGE; context->File_name = file_name; context->File_directory = file_directory; - context->Format = Main_fileformat; - memcpy(context->Palette, Main_palette, sizeof(T_Palette)); - context->Width = Main_image_width; - context->Height = Main_image_height; + context->Format = Main.fileformat; + 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; @@ -1313,7 +1313,7 @@ void Init_context_layered_image(T_IO_Context * context, char *file_name, char *f else context->Ratio=PIXEL_SIMPLE; context->Target_address=Main_backups->Pages->Image[0].Pixels; - context->Pitch=Main_image_width; + context->Pitch=Main.image_width; // Color cyling ranges: for (i=0; i<16; i++) @@ -1345,7 +1345,7 @@ void Init_context_brush(T_IO_Context * context, char *file_name, char *file_dire context->File_directory = file_directory; context->Format = Brush_fileformat; // Use main screen's palette - memcpy(context->Palette, Main_palette, sizeof(T_Palette)); + memcpy(context->Palette, Main.palette, sizeof(T_Palette)); context->Width = Brush_width; context->Height = Brush_height; context->Nb_layers = 1; @@ -1414,9 +1414,9 @@ void Set_loading_layer(T_IO_Context *context, int layer) break; } context->Nb_layers = Main_backups->Pages->Nb_layers; - Main_layers_visible = (2<Target_address=Main_backups->Pages->Image[layer].Pixels; Update_pixel_renderer(); @@ -1465,9 +1465,9 @@ void Add_backup_file(const char *name) Extract_filename(file_name, name); // Check first character - if (file_name[0]==Main_safety_backup_prefix) + if (file_name[0]==Main.safety_backup_prefix) list = &Backups_main; - else if (file_name[0]==Spare_safety_backup_prefix) + else if (file_name[0]==Spare.safety_backup_prefix) list = &Backups_spare; else { // Not a good file @@ -1555,7 +1555,7 @@ byte Process_backups(T_String_list **list) context.Original_file_name = file_name; context.Original_file_directory = file_directory; Load_image(&context); - Main_image_is_modified=1; + Main.image_is_modified=1; Destroy_context(&context); Redraw_layered_image(); Display_all_screen(); @@ -1608,8 +1608,8 @@ if (Create_lock_file(Config_directory)) restored_spare = Process_backups(&Backups_spare); if (restored_spare) { - Main_offset_X=0; - Main_offset_Y=0; + Main.offset_X=0; + Main.offset_Y=0; Compute_limits(); Compute_paintbrush_coordinates(); if (Backups_main) @@ -1619,8 +1619,8 @@ if (Create_lock_file(Config_directory)) if (restored_main) { - Main_offset_X=0; - Main_offset_Y=0; + Main.offset_X=0; + Main.offset_Y=0; Compute_limits(); Compute_paintbrush_coordinates(); } @@ -1642,28 +1642,28 @@ void Rotate_safety_backups(void) // - Many edits have taken place // - A minimum number of edits have taken place AND a minimum time has passed // - At least one edit was done, and a maximum time has passed - if ((Main_edits_since_safety_backup > Max_edits_for_safety_backup) || - (Main_edits_since_safety_backup > Min_edits_for_safety_backup && - now > Main_time_of_safety_backup + Min_interval_for_safety_backup) || - (Main_edits_since_safety_backup > 1 && - now > Main_time_of_safety_backup + Max_interval_for_safety_backup)) + if ((Main.edits_since_safety_backup > Max_edits_for_safety_backup) || + (Main.edits_since_safety_backup > Min_edits_for_safety_backup && + now > Main.time_of_safety_backup + Min_interval_for_safety_backup) || + (Main.edits_since_safety_backup > 1 && + now > Main.time_of_safety_backup + Max_interval_for_safety_backup)) { // Clear a previous save (rotating saves) sprintf(deleted_file, "%s%c%6.6d" BACKUP_FILE_EXTENSION, Config_directory, - Main_safety_backup_prefix, - (Uint32)(Main_safety_number + 1000000l - Rotation_safety_backup) % (Uint32)1000000l); + Main.safety_backup_prefix, + (Uint32)(Main.safety_number + 1000000l - Rotation_safety_backup) % (Uint32)1000000l); remove(deleted_file); // no matter if fail // Reset counters - Main_edits_since_safety_backup=0; - Main_time_of_safety_backup=now; + Main.edits_since_safety_backup=0; + Main.time_of_safety_backup=now; // Create a new file name and save sprintf(file_name, "%c%6.6d" BACKUP_FILE_EXTENSION, - Main_safety_backup_prefix, - (Uint32)Main_safety_number); + Main.safety_backup_prefix, + (Uint32)Main.safety_number); Init_context_backup_image(&context, file_name, Config_directory); context.Format=FORMAT_GIF; // Provide original file data, to store as a GIF Application Extension @@ -1673,7 +1673,7 @@ void Rotate_safety_backups(void) Save_image(&context); Destroy_context(&context); - Main_safety_number++; + Main.safety_number++; } } diff --git a/src/main.c b/src/main.c index 0f167221..30f33198 100644 --- a/src/main.c +++ b/src/main.c @@ -490,10 +490,10 @@ int Init_program(int argc,char * argv[]) // Choose directory for settings (read/write) Set_config_directory(program_directory,Config_directory); #if defined(__MINT__) - strcpy(Main_selector.Directory,program_directory); + strcpy(Main.selector.Directory,program_directory); #else // On détermine le répertoire courant: - getcwd(Main_selector.Directory,MAX_PATH_CHARACTERS); + getcwd(Main.selector.Directory,MAX_PATH_CHARACTERS); #endif #ifdef ENABLE_FILENAMES_ICONV @@ -504,68 +504,68 @@ int Init_program(int argc,char * argv[]) #endif /* ENABLE_FILENAMES_ICONV */ // On en profite pour le mémoriser dans le répertoire principal: - strcpy(Initial_directory,Main_selector.Directory); + strcpy(Initial_directory,Main.selector.Directory); // On initialise les données sur le nom de fichier de l'image de brouillon: - strcpy(Spare_selector.Directory,Main_selector.Directory); + strcpy(Spare.selector.Directory,Main.selector.Directory); - Main_fileformat=DEFAULT_FILEFORMAT; - Spare_fileformat =Main_fileformat; + Main.fileformat=DEFAULT_FILEFORMAT; + Spare.fileformat =DEFAULT_FILEFORMAT; - strcpy(Brush_selector.Directory,Main_selector.Directory); - strcpy(Brush_file_directory,Main_selector.Directory); + strcpy(Brush_selector.Directory,Main.selector.Directory); + strcpy(Brush_file_directory,Main.selector.Directory); strcpy(Brush_filename ,"NO_NAME.GIF"); - Brush_fileformat =Main_fileformat; + Brush_fileformat =DEFAULT_FILEFORMAT; // On initialise ce qu'il faut pour que les fileselects ne plantent pas: - Main_selector.Position=0; // Au début, le fileselect est en haut de la liste des fichiers - Main_selector.Offset=0; // Au début, le fileselect est en haut de la liste des fichiers - Main_selector.Format_filter=FORMAT_ALL_IMAGES; + Main.selector.Position=0; // Au début, le fileselect est en haut de la liste des fichiers + Main.selector.Offset=0; // Au début, le fileselect est en haut de la liste des fichiers + Main.selector.Format_filter=FORMAT_ALL_IMAGES; - Main_current_layer=0; - Main_layers_visible=0xFFFFFFFF; - Main_layers_visible_backup=0xFFFFFFFF; - Spare_current_layer=0; - Spare_layers_visible=0xFFFFFFFF; - Spare_layers_visible_backup=0xFFFFFFFF; + Main.current_layer=0; + Main.layers_visible=0xFFFFFFFF; + Main.layers_visible_backup=0xFFFFFFFF; + Spare.current_layer=0; + Spare.layers_visible=0xFFFFFFFF; + Spare.layers_visible_backup=0xFFFFFFFF; - Spare_selector.Position=0; - Spare_selector.Offset=0; - Spare_selector.Format_filter=FORMAT_ALL_IMAGES; + Spare.selector.Position=0; + Spare.selector.Offset=0; + Spare.selector.Format_filter=FORMAT_ALL_IMAGES; Brush_selector.Position=0; Brush_selector.Offset=0; Brush_selector.Format_filter=FORMAT_ALL_IMAGES; // On initialise d'ot' trucs - Main_offset_X=0; - Main_offset_Y=0; - Main_separator_position=0; - Main_X_zoom=0; - Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION; - Main_magnifier_mode=0; - Main_magnifier_factor=DEFAULT_ZOOM_FACTOR; - Main_magnifier_height=0; - Main_magnifier_width=0; - Main_magnifier_offset_X=0; - Main_magnifier_offset_Y=0; - Spare_offset_X=0; - Spare_offset_Y=0; - Spare_separator_position=0; - Spare_X_zoom=0; - Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION; - Spare_magnifier_mode=0; - Spare_magnifier_factor=DEFAULT_ZOOM_FACTOR; - Spare_magnifier_height=0; - Spare_magnifier_width=0; - Spare_magnifier_offset_X=0; - Spare_magnifier_offset_Y=0; + Main.offset_X=0; + Main.offset_Y=0; + Main.separator_position=0; + Main.X_zoom=0; + Main.separator_proportion=INITIAL_SEPARATOR_PROPORTION; + Main.magnifier_mode=0; + Main.magnifier_factor=DEFAULT_ZOOM_FACTOR; + Main.magnifier_height=0; + Main.magnifier_width=0; + Main.magnifier_offset_X=0; + Main.magnifier_offset_Y=0; + Spare.offset_X=0; + Spare.offset_Y=0; + Spare.separator_position=0; + Spare.X_zoom=0; + Spare.separator_proportion=INITIAL_SEPARATOR_PROPORTION; + Spare.magnifier_mode=0; + Spare.magnifier_factor=DEFAULT_ZOOM_FACTOR; + Spare.magnifier_height=0; + Spare.magnifier_width=0; + Spare.magnifier_offset_X=0; + Spare.magnifier_offset_Y=0; Keyboard_click_allowed = 1; - Main_safety_backup_prefix = SAFETYBACKUP_PREFIX_A[0]; - Spare_safety_backup_prefix = SAFETYBACKUP_PREFIX_B[0]; - Main_time_of_safety_backup = 0; - Spare_time_of_safety_backup = 0; + Main.safety_backup_prefix = SAFETYBACKUP_PREFIX_A[0]; + Spare.safety_backup_prefix = SAFETYBACKUP_PREFIX_B[0]; + Main.time_of_safety_backup = 0; + Spare.time_of_safety_backup = 0; // SDL @@ -611,10 +611,10 @@ int Init_program(int argc,char * argv[]) Selected_curve_mode =OPERATION_3_POINTS_CURVE; Effect_function=No_effect; // On initialise les infos de la loupe: - Main_magnifier_mode=0; - Main_magnifier_factor=DEFAULT_ZOOM_FACTOR; - Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION; - Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION; + Main.magnifier_mode=0; + Main.magnifier_factor=DEFAULT_ZOOM_FACTOR; + Main.separator_proportion=INITIAL_SEPARATOR_PROPORTION; + Spare.separator_proportion=INITIAL_SEPARATOR_PROPORTION; // On initialise les infos du mode smear: Smear_mode=0; Smear_brush_width=PAINTBRUSH_WIDTH; @@ -746,7 +746,7 @@ int Init_program(int argc,char * argv[]) Error(ERROR_GUI_MISSING); } - memcpy(Main_palette, Gfx->Default_palette, sizeof(T_Palette)); + memcpy(Main.palette, Gfx->Default_palette, sizeof(T_Palette)); Fore_color=Best_color_range(255,255,255,Config.Palette_cells_X*Config.Palette_cells_Y); Back_color=Best_color_range(0,0,0,Config.Palette_cells_X*Config.Palette_cells_Y); @@ -785,10 +785,10 @@ int Init_program(int argc,char * argv[]) //ActivateConsole(); #endif - Main_image_width=Screen_width/Pixel_width; - Main_image_height=Screen_height/Pixel_height; - Spare_image_width=Screen_width/Pixel_width; - Spare_image_height=Screen_height/Pixel_height; + Main.image_width=Screen_width/Pixel_width; + Main.image_height=Screen_height/Pixel_height; + Spare.image_width=Screen_width/Pixel_width; + Spare.image_height=Screen_height/Pixel_height; starting_image_mode = Config.Default_mode_layers ? IMAGE_MODE_LAYERED : IMAGE_MODE_ANIMATION; @@ -799,7 +799,7 @@ int Init_program(int argc,char * argv[]) Check_menu_mode(); // Nettoyage de l'écran virtuel (les autres recevront celui-ci par copie) - memset(Main_screen,0,Main_image_width*Main_image_height); + 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)); @@ -828,8 +828,8 @@ int Init_program(int argc,char * argv[]) // On affiche le curseur pour débuter correctement l'état du programme: Display_cursor(); - Spare_image_is_modified=0; - Main_image_is_modified=0; + Spare.image_is_modified=0; + Main.image_is_modified=0; // Gestionnaire de signaux, quand il ne reste plus aucun espoir Init_sighandler(); @@ -851,7 +851,7 @@ int Init_program(int argc,char * argv[]) // backups if (file_in_command_line > 0) { - strcpy(Main_selector.Directory, main_directory); + strcpy(Main.selector.Directory, main_directory); } // Test de recuperation de fichiers sauvés @@ -862,7 +862,7 @@ int Init_program(int argc,char * argv[]) default: // Some files were loaded from last crash-exit. // Do not load files from command-line, nor show splash screen. - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); Check_menu_mode(); Display_all_screen(); Display_menu(); @@ -918,11 +918,11 @@ int Init_program(int argc,char * argv[]) Spare_backups->Pages->Image_mode = Main_backups->Pages->Image_mode; Hide_cursor(); - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); 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 ? + 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) : Best_color_range(0,0,0,Config.Palette_cells_X*Config.Palette_cells_Y); Check_menu_mode(); diff --git a/src/misc.c b/src/misc.c index aee4b21f..3f5ea386 100644 --- a/src/misc.c +++ b/src/misc.c @@ -56,7 +56,7 @@ word Count_used_colors(dword* usage) for (i = 0; i < 256; i++) usage[i]=0; // Compute total number of pixels in the picture - nb_pixels = Main_image_height * Main_image_width; + nb_pixels = Main.image_height * Main.image_width; // For each layer for (layer = 0; layer < Main_backups->Pages->Nb_layers; layer++) @@ -137,7 +137,7 @@ word Count_used_colors_area(dword* usage, word start_x, word start_y, for (x = 0; x < width; x++) { // Get color from picture - color=*(Main_screen+((start_x + x)+(start_y + y)*Main_image_width)); + color=*(Main_screen+((start_x + x)+(start_y + y)*Main.image_width)); usage[color]++; //Un point de plus pour cette couleur } } @@ -204,10 +204,10 @@ 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; + nb_pixels=Main.image_height*Main.image_width; for(i=0;iPages->Image[Main_current_layer].Pixels, + Main_backups->Pages->Image[Main.current_layer].Pixels, color , - Main_image_width * Main_image_height + Main.image_width * Main.image_height ); } @@ -298,19 +298,19 @@ void Copy_part_of_image_to_another(byte * source,word source_x,word source_y,wor byte Read_pixel_from_spare_screen(word x,word y) { -// return *(Spare_screen+y*Spare_image_width+x); +// return *(Spare_screen+y*Spare.image_width+x); // 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) + 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->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; @@ -385,7 +385,7 @@ void Copy_image_to_brush(short start_x,short start_y,short Brush_width,short Bru byte Read_pixel_from_feedback_screen (word x,word y) { - return *(FX_feedback_screen+y*Main_image_width+x); + return *(FX_feedback_screen+y*Main.image_width+x); } dword Round_div(dword numerator,dword divisor) @@ -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]; } } @@ -418,7 +418,7 @@ void Replace_colors_within_limits(byte * replace_table) byte Read_pixel_from_backup_screen (word x,word y) { - return *(Screen_backup + x + Main_image_width * y); + return *(Screen_backup + x + Main.image_width * y); } void Palette_256_to_64(T_Palette palette) @@ -454,12 +454,12 @@ byte Effect_interpolated_colorize (word x,word y,byte color) // On place dans ESI 3*Couleur_dessous ( = position de cette couleur dans la // palette des teintes) et dans EDI, 3*color. byte color_under = Read_pixel_from_feedback_screen(x,y); - byte blue_under=Main_palette[color_under].B; - byte blue=Main_palette[color].B; - byte green_under=Main_palette[color_under].G; - byte green=Main_palette[color].G; - byte red_under=Main_palette[color_under].R; - byte red=Main_palette[color].R; + byte blue_under=Main.palette[color_under].B; + byte blue=Main.palette[color].B; + byte green_under=Main.palette[color_under].G; + byte green=Main.palette[color].G; + byte red_under=Main.palette[color_under].R; + byte red=Main.palette[color].R; // On récupère les 3 composantes RVB @@ -477,12 +477,12 @@ byte Effect_interpolated_colorize (word x,word y,byte color) byte Effect_additive_colorize (word x,word y,byte color) { byte color_under = Read_pixel_from_feedback_screen(x,y); - byte blue_under=Main_palette[color_under].B; - byte green_under=Main_palette[color_under].G; - byte red_under=Main_palette[color_under].R; - byte blue=Main_palette[color].B; - byte green=Main_palette[color].G; - byte red=Main_palette[color].R; + byte blue_under=Main.palette[color_under].B; + byte green_under=Main.palette[color_under].G; + byte red_under=Main.palette[color_under].R; + byte blue=Main.palette[color].B; + byte green=Main.palette[color].G; + byte red=Main.palette[color].R; return Best_color( red>red_under?red:red_under, @@ -493,12 +493,12 @@ byte Effect_additive_colorize (word x,word y,byte color) byte Effect_substractive_colorize(word x,word y,byte color) { byte color_under = Read_pixel_from_feedback_screen(x,y); - byte blue_under=Main_palette[color_under].B; - byte green_under=Main_palette[color_under].G; - byte red_under=Main_palette[color_under].R; - byte blue=Main_palette[color].B; - byte green=Main_palette[color].G; - byte red=Main_palette[color].R; + byte blue_under=Main.palette[color_under].B; + byte green_under=Main.palette[color_under].G; + byte red_under=Main.palette[color_under].R; + byte blue=Main.palette[color].B; + byte green=Main.palette[color].G; + byte red=Main.palette[color].R; return Best_color( red0;y--) + for(y = Main.image_height - y_offset;y>0;y--) { // Pour chaque ligne memcpy(dest,src,length); memcpy(dest - x_offset,src+length,x_offset); // On passe à la ligne suivante - dest += Main_image_width; - src += Main_image_width; + dest += Main.image_width; + src += Main.image_width; } // On vient de faire le traitement pour otutes les lignes au-dessous de y_offset @@ -709,8 +709,8 @@ void Scroll_picture(byte * main_src, byte * main_dest, short x_offset,short y_of memcpy(dest,src,length); memcpy(dest - x_offset,src+length,x_offset); - dest += Main_image_width; - src += Main_image_width; + dest += Main.image_width; + src += Main.image_width; } Update_rect(0,0,0,0); diff --git a/src/oldies.c b/src/oldies.c index b8344b8c..63fb27af 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) @@ -57,7 +57,7 @@ byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) // Prerequisites if (Main_backups->Pages->Nb_layers < 3) return 1; - if (Main_image_width != 160 || Main_image_height != 200) + if (Main.image_width != 160 || Main.image_height != 200) return 2; memset(used_colors,0,200*40*sizeof(word)); @@ -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 @@ -356,9 +356,9 @@ byte C64_FLI_enforcer(void) byte c[4]; // Checks - if (Main_image_width != 160) + if (Main.image_width != 160) return 1; - if (Main_image_height != 200) + if (Main.image_height != 200) return 1; if (Main_backups->Pages->Nb_layers != 4) return 2; @@ -397,7 +397,7 @@ byte C64_FLI_enforcer(void) // Visible feedback: // If the "check" layer was visible, manually update the whole thing - if (Main_layers_visible & (1<<3)) + if (Main.layers_visible & (1<<3)) { Hide_cursor(); Redraw_layered_image(); diff --git a/src/operatio.c b/src/operatio.c index 992ed6e2..8cc371f7 100644 --- a/src/operatio.c +++ b/src/operatio.c @@ -110,7 +110,7 @@ void Start_operation_stack(word new_operation) void Init_start_operation(void) { - Operation_in_magnifier=(Mouse_X>=Main_X_zoom); + Operation_in_magnifier=(Mouse_X>=Main.X_zoom); Smear_start=1; } @@ -1435,14 +1435,14 @@ void Draw_curve_cross(short x_pos, short y_pos) for (i=start_x; i<=end_x; i++) { temp=x_pos+i-3; - Pixel_preview(temp,y_pos,xor_lut[Read_pixel(temp -Main_offset_X, - y_pos-Main_offset_Y)]); + Pixel_preview(temp,y_pos,xor_lut[Read_pixel(temp -Main.offset_X, + y_pos-Main.offset_Y)]); } for (i=start_y; i<=end_y; i++) { temp=y_pos+i-3; - Pixel_preview(x_pos,temp,xor_lut[Read_pixel(x_pos-Main_offset_X, - temp -Main_offset_Y)]); + Pixel_preview(x_pos,temp,xor_lut[Read_pixel(x_pos-Main.offset_X, + temp -Main.offset_Y)]); } Update_part_of_screen(x_pos+start_x-3,y_pos+start_y-3,end_x-start_x+1,end_y-start_y+1); } @@ -2784,14 +2784,14 @@ void Scroll_12_0(void) Backup(); else { - Backup_layers(LAYER_ALL); // Main_layers_visible + Backup_layers(LAYER_ALL); // Main.layers_visible 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_image_width*Main_image_height); + Main.image_width*Main.image_height); } } Update_screen_targets(); @@ -2832,14 +2832,14 @@ void Scroll_12_5(void) // L'utilisateur a bougé, il faut scroller l'image if (Paintbrush_X>=center_x) - x_offset=(Paintbrush_X-center_x)%Main_image_width; + x_offset=(Paintbrush_X-center_x)%Main.image_width; else - x_offset=Main_image_width-((center_x-Paintbrush_X)%Main_image_width); + x_offset=Main.image_width-((center_x-Paintbrush_X)%Main.image_width); if (Paintbrush_Y>=center_y) - y_offset=(Paintbrush_Y-center_y)%Main_image_height; + y_offset=(Paintbrush_Y-center_y)%Main.image_height; else - y_offset=Main_image_height-((center_y-Paintbrush_Y)%Main_image_height); + y_offset=Main.image_height-((center_y-Paintbrush_Y)%Main.image_height); Display_coords_rel_or_abs(center_x,center_y); @@ -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(); } @@ -2895,18 +2895,18 @@ void Scroll_0_5(void) { // All layers at once if (x_pos>=center_x) - x_offset=(x_pos-center_x)%Main_image_width; + x_offset=(x_pos-center_x)%Main.image_width; else - x_offset=Main_image_width-((center_x-x_pos)%Main_image_width); + x_offset=Main.image_width-((center_x-x_pos)%Main.image_width); if (y_pos>=center_y) - y_offset=(y_pos-center_y)%Main_image_height; + y_offset=(y_pos-center_y)%Main.image_height; else - y_offset=Main_image_height-((center_y-y_pos)%Main_image_height); + 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++) - //if ((1<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 @@ -2917,7 +2917,7 @@ void Scroll_0_5(void) { // One layer : everything was done while dragging the mouse } - if (Main_tilemap_mode) + if (Main.tilemap_mode) Tilemap_update(); Cursor_hidden=Cursor_hidden_before_scroll; @@ -3511,59 +3511,59 @@ void Draw_xor_rect(short start_x, short start_y, short end_x, short end_y) short height = end_y-start_y; // Handle clipping - if (end_x-Main_offset_X > Min(Main_image_width, - Main_magnifier_mode?Main_separator_position:Screen_width)) + if (end_x-Main.offset_X > Min(Main.image_width, + Main.magnifier_mode?Main.separator_position:Screen_width)) { - offset_width = end_x - Min(Main_image_width, - Main_magnifier_mode?Main_separator_position:Screen_width); + offset_width = end_x - Min(Main.image_width, + Main.magnifier_mode?Main.separator_position:Screen_width); } - if (end_y-Main_offset_Y > Min(Main_image_height, Menu_Y)) - offset_height = end_y - Min(Main_image_height, Menu_Y); + if (end_y-Main.offset_Y > Min(Main.image_height, Menu_Y)) + offset_height = end_y - Min(Main.image_height, Menu_Y); if (width == 0) { // Single line - Vertical_XOR_line(start_x-Main_offset_X, start_y - - Main_offset_Y, height - offset_height + 1); + Vertical_XOR_line(start_x-Main.offset_X, start_y + - Main.offset_Y, height - offset_height + 1); } else if (height == 0) { // Single line - Horizontal_XOR_line(start_x-Main_offset_X, - start_y - Main_offset_Y, width - offset_width + 1); + Horizontal_XOR_line(start_x-Main.offset_X, + start_y - Main.offset_Y, width - offset_width + 1); } else { // Dessin dans la zone de dessin normale - Horizontal_XOR_line(start_x-Main_offset_X, - start_y - Main_offset_Y, width - offset_width + 1); + Horizontal_XOR_line(start_x-Main.offset_X, + start_y - Main.offset_Y, width - offset_width + 1); // If not, this line is out of the picture so there is no need to draw it - if (offset_height == 0 || end_y - 1 > Menu_Y + Main_offset_Y) + if (offset_height == 0 || end_y - 1 > Menu_Y + Main.offset_Y) { - Horizontal_XOR_line(start_x - Main_offset_X, end_y - - Main_offset_Y, width - offset_width + 1); + Horizontal_XOR_line(start_x - Main.offset_X, end_y + - Main.offset_Y, width - offset_width + 1); } if (height > offset_height + 2) { - Vertical_XOR_line(start_x-Main_offset_X, start_y - - Main_offset_Y + 1, height - offset_height - 1); + Vertical_XOR_line(start_x-Main.offset_X, start_y + - Main.offset_Y + 1, height - offset_height - 1); if (offset_width == 0) { - Vertical_XOR_line(end_x - Main_offset_X, start_y - - Main_offset_Y + 1, height - offset_height - 1); + Vertical_XOR_line(end_x - Main.offset_X, start_y + - Main.offset_Y + 1, height - offset_height - 1); } } } - Update_rect(start_x - Main_offset_X, start_y - Main_offset_Y, + Update_rect(start_x - Main.offset_X, start_y - Main.offset_Y, width + 1 - offset_width, height + 1 - offset_height); // Dessin dans la zone zoomée - if (Main_magnifier_mode && start_x <= Limit_right_zoom + if (Main.magnifier_mode && start_x <= Limit_right_zoom && end_x > Limit_left_zoom && start_y <= Limit_bottom_zoom && end_y > Limit_top_zoom ) @@ -3652,9 +3652,9 @@ void Grad_rectangle_0_5(void) Hide_cursor(); // Check if the rectangle is not fully outside the picture - if (start_x > Main_image_width // Rectangle at right of picture - || start_y > Main_image_height // Rectangle below picture - || start_y - 1 - Main_offset_Y > Menu_Y ) // Rectangle below viewport + if (start_x > Main.image_width // Rectangle at right of picture + || start_y > Main.image_height // Rectangle below picture + || start_y - 1 - Main.offset_Y > Menu_Y ) // Rectangle below viewport { Operation_pop(&end_y); // reset the stack return; // cancel the operation @@ -4084,7 +4084,7 @@ void Pan_view_12_2(void) if (Paintbrush_X!=start_x || Paintbrush_Y!=start_y) { // User moved - if (Main_magnifier_mode) + if (Main.magnifier_mode) Scroll_magnifier(start_x-Paintbrush_X,start_y-Paintbrush_Y); else Scroll_screen(start_x-Paintbrush_X,start_y-Paintbrush_Y); diff --git a/src/pages.c b/src/pages.c index f9f46b73..2c71fb0b 100644 --- a/src/pages.c +++ b/src/pages.c @@ -172,19 +172,19 @@ void Download_infos_page_main(T_Page * page) if (page!=NULL) { - size_is_modified=(Main_image_width!=page->Width) || - (Main_image_height!=page->Height); + size_is_modified=(Main.image_width!=page->Width) || + (Main.image_height!=page->Height); - Main_image_width=page->Width; - Main_image_height=page->Height; - memcpy(Main_palette,page->Palette,sizeof(T_Palette)); - Main_fileformat=page->File_format; + Main.image_width=page->Width; + Main.image_height=page->Height; + memcpy(Main.palette,page->Palette,sizeof(T_Palette)); + Main.fileformat=page->File_format; if (size_is_modified) { - Main_magnifier_mode=0; - Main_offset_X=0; - Main_offset_Y=0; + Main.magnifier_mode=0; + Main.offset_X=0; + Main.offset_Y=0; Pixel_preview=Pixel_preview_normal; Compute_limits(); Compute_paintbrush_coordinates(); @@ -192,7 +192,7 @@ void Download_infos_page_main(T_Page * page) } //Update_buffers( page->Width, page->Height); - //memcpy(Main_screen, page->Image[Main_current_layer].Pixels, page->Width*page->Height); + //memcpy(Main_screen, page->Image[Main.current_layer].Pixels, page->Width*page->Height); } @@ -203,15 +203,15 @@ void Redraw_layered_image(void) // 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++) + 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)) + 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; @@ -220,7 +220,7 @@ void Redraw_layered_image(void) // Copy it to the depth buffer memcpy(Main_visible_image_depth_buffer.Image, Main_backups->Pages->Image[4].Pixels, - Main_image_width*Main_image_height); + Main.image_width*Main.image_height); // Next layer= (1<<4)+1; @@ -229,17 +229,17 @@ void Redraw_layered_image(void) { for (layer=0; layerPages->Nb_layers; layer++) { - if ((1<Pages->Image[layer].Pixels, - Main_image_width*Main_image_height); + Main.image_width*Main.image_height); // Initialize the depth buffer memset(Main_visible_image_depth_buffer.Image, layer, - Main_image_width*Main_image_height); + Main.image_width*Main.image_height); // skip all other layers layer++; @@ -250,16 +250,16 @@ void Redraw_layered_image(void) // subsequent layer(s) for (; layerPages->Nb_layers; layer++) { - if ((1<Pages->Image[layer].Pixels+i); if (color != Main_backups->Pages->Transparent_color) // transparent color { *(Main_visible_image.Image+i) = color; - if (layer != Main_current_layer) + if (layer != Main.current_layer) *(Main_visible_image_depth_buffer.Image+i) = layer; } } @@ -285,12 +285,12 @@ void Update_depth_buffer(void) // First layer for (layer=0; layerPages->Nb_layers; layer++) { - if ((1<Pages->Nb_layers; layer++) { // skip the current layer, whenever we reach it - if (layer == Main_current_layer) + if (layer == Main.current_layer) continue; - if ((1<Pages->Image[layer].Pixels+i); if (color != Main_backups->Pages->Transparent_color) // transparent color @@ -330,17 +330,17 @@ void Redraw_spare_image(void) // First layer for (layer=0; layerPages->Nb_layers; layer++) { - if ((1<Pages->Image[layer].Pixels, - Spare_image_width*Spare_image_height); + Spare.image_width*Spare.image_height); // No depth buffer in the spare //memset(Spare_visible_image_depth_buffer.Image, // layer, - // Spare_image_width*Spare_image_height); + // Spare.image_width*Spare.image_height); // skip all other layers layer++; @@ -350,16 +350,16 @@ void Redraw_spare_image(void) // subsequent layer(s) for (; layerPages->Nb_layers; layer++) { - if ((1<Pages->Image[layer].Pixels+i); if (color != Spare_backups->Pages->Transparent_color) // transparent color { *(Spare_visible_image.Image+i) = color; - //if (layer != Spare_current_layer) + //if (layer != Spare.current_layer) // *(Spare_visible_image_depth_buffer.Image+i) = layer; } } @@ -373,12 +373,12 @@ void Redraw_current_layer(void) if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { int i; - for (i=0; iPages->Image[Main_current_layer].Pixels+i); + 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; @@ -392,27 +392,29 @@ void Redraw_current_layer(void) } } +// TODO : Upload_infos_page_main/Upload_infos_page_spare => Upload_infos_page() void Upload_infos_page_main(T_Page * page) // Sauve l'écran courant dans la page { if (page!=NULL) { - //page->Image[Main_current_layer].Pixels=Main_screen; - page->Width=Main_image_width; - page->Height=Main_image_height; - memcpy(page->Palette,Main_palette,sizeof(T_Palette)); - page->File_format=Main_fileformat; + //page->Image[Main.current_layer].Pixels=Main_screen; + page->Width=Main.image_width; + page->Height=Main.image_height; + memcpy(page->Palette,Main.palette,sizeof(T_Palette)); + page->File_format=Main.fileformat; } } +// TODO : Download_infos_page_main/Download_infos_page_spare => Download_infos_page() void Download_infos_page_spare(T_Page * page) { if (page!=NULL) { - Spare_image_width=page->Width; - Spare_image_height=page->Height; - memcpy(Spare_palette,page->Palette,sizeof(T_Palette)); - Spare_fileformat=page->File_format; + Spare.image_width=page->Width; + Spare.image_height=page->Height; + memcpy(Spare.palette,page->Palette,sizeof(T_Palette)); + Spare.fileformat=page->File_format; } } @@ -420,11 +422,11 @@ void Upload_infos_page_spare(T_Page * page) { if (page!=NULL) { - //page->Image[Spare_current_layer].Pixels=Spare_screen; - page->Width=Spare_image_width; - page->Height=Spare_image_height; - memcpy(page->Palette,Spare_palette,sizeof(T_Palette)); - page->File_format=Spare_fileformat; + //page->Image[Spare.current_layer].Pixels=Spare_screen; + page->Width=Spare.image_width; + page->Height=Spare.image_height; + memcpy(page->Palette,Spare.palette,sizeof(T_Palette)); + page->File_format=Spare.fileformat; } } @@ -434,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) @@ -686,7 +688,7 @@ void Update_screen_targets(void) } 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, @@ -697,7 +699,7 @@ void Update_screen_targets(void) || 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(); } @@ -785,7 +787,7 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height) // 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->File_directory,Main.selector.Directory); strcpy(Main_backups->Pages->Filename,"NO_NAME.GIF"); @@ -828,16 +830,16 @@ int Init_all_backup_lists(enum IMAGE_MODES image_mode, int width, int height) // 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)); + 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->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); // Clear the initial Visible buffer - //memset(Main_screen,0,Main_image_width*Main_image_height); + //memset(Main_screen,0,Main.image_width*Main.image_height); // Spare for (i=0; iPages->Image[i].Pixels, 0, width*height); } - //memset(Spare_screen,0,Spare_image_width*Spare_image_height); + //memset(Spare_screen,0,Spare.image_width*Spare.image_height); End_of_modification(); return 1; @@ -946,7 +948,7 @@ int Backup_with_new_dimensions(int width,int height) { memcpy(Main_visible_image_backup.Image, Main_visible_image.Image, - Main_image_width*Main_image_height); + Main.image_width*Main.image_height); } else { @@ -1077,7 +1079,7 @@ int Backup_and_resize_the_spare(int width,int height) Download_infos_page_spare(Spare_backups->Pages); // Light up the 'has unsaved changes' indicator - Spare_image_is_modified=1; + Spare.image_is_modified=1; return_code=1; } @@ -1088,7 +1090,7 @@ void Backup(void) // Sauve la page courante comme première page de backup et crée une nouvelle page // pur continuer à dessiner. Utilisé par exemple pour le fill { - Backup_layers(Main_current_layer); + Backup_layers(Main.current_layer); } void Backup_layers(int layer) @@ -1097,7 +1099,7 @@ void Backup_layers(int layer) T_Page *new_page; /* - if (Last_backed_up_layers == (1<Pages->Image[i].Pixels, Main_backups->Pages->Next->Image[i].Pixels, - Main_image_width*Main_image_height); + Main.image_width*Main.image_height); } } // Light up the 'has unsaved changes' indicator - Main_image_is_modified=1; + Main.image_is_modified=1; /* - Last_backed_up_layers = 1<Pages->Image[i].Pixels, Spare_backups->Pages->Next->Image[i].Pixels, - Spare_image_width*Spare_image_height); + Spare.image_width*Spare.image_height); } } // Light up the 'has unsaved changes' indicator - Spare_image_is_modified=1; + Spare.image_is_modified=1; } 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_layers_visible |= 1<Pages->Nb_layers-1; + Main.layers_visible |= 1<Pages); // On inverse les listes de pages +//TODO temp_list=Main_backups; Main_backups=Spare_backups; Spare_backups=temp_list; @@ -1312,8 +1315,8 @@ 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); @@ -1322,18 +1325,18 @@ void Exchange_main_and_spare(void) void End_of_modification(void) { - //Update_buffers(Main_image_width, Main_image_height); + //Update_buffers(Main.image_width, Main.image_height); if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION) { // Backup buffer can have "wrong" size if a Lua script // performs a resize. - Update_buffers(Main_image_width, Main_image_height); + Update_buffers(Main.image_width, Main.image_height); // memcpy(Main_visible_image_backup.Image, Main_visible_image.Image, - Main_image_width*Main_image_height); + Main.image_width*Main.image_height); } else { @@ -1347,7 +1350,7 @@ void End_of_modification(void) // // Processing safety backups // - Main_edits_since_safety_backup++; + Main.edits_since_safety_backup++; Rotate_safety_backups(); } @@ -1423,13 +1426,13 @@ byte Add_layer(T_List_of_pages *list, int layer) // Determine if we're modifying the spare or the main page. if (list == Main_backups) { - visible_layers_flag = &Main_layers_visible; - Main_current_layer = layer; + visible_layers_flag = &Main.layers_visible; + Main.current_layer = layer; } else { - visible_layers_flag = &Spare_layers_visible; - Spare_current_layer = layer; + visible_layers_flag = &Spare.layers_visible; + Spare.current_layer = layer; } // Fun with binary! @@ -1482,17 +1485,17 @@ byte Delete_layer(T_List_of_pages *list, int layer) // Determine if we're modifying the spare or the main page. if (list == Main_backups) { - visible_layers_flag = &Main_layers_visible; - if (Main_current_layer>=layer && Main_current_layer>0) - Main_current_layer--; - new_current_layer = Main_current_layer; + visible_layers_flag = &Main.layers_visible; + if (Main.current_layer>=layer && Main.current_layer>0) + Main.current_layer--; + new_current_layer = Main.current_layer; } else { - visible_layers_flag = &Spare_layers_visible; - if (Spare_current_layer>=layer && Spare_current_layer>0) - Spare_current_layer--; - new_current_layer = Spare_current_layer; + visible_layers_flag = &Spare.layers_visible; + if (Spare.current_layer>=layer && Spare.current_layer>0) + Spare.current_layer--; + new_current_layer = Spare.current_layer; } // Fun with binary! @@ -1511,13 +1514,13 @@ byte Delete_layer(T_List_of_pages *list, int layer) byte Merge_layer() { int i; - for (i=0; iPages->Image[Main_current_layer].Pixels+i); + 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; + *(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) @@ -1532,7 +1535,7 @@ void Switch_layer_mode(enum IMAGE_MODES new_mode) case IMAGE_MODE_MODE5: case IMAGE_MODE_LAYERED: default: - Update_buffers(Main_image_width, Main_image_height); + Update_buffers(Main.image_width, Main.image_height); Redraw_layered_image(); break; case IMAGE_MODE_ANIMATION: diff --git a/src/palette.c b/src/palette.c index 53c36201..009666b5 100644 --- a/src/palette.c +++ b/src/palette.c @@ -348,58 +348,58 @@ void Remap_image_highlevel(byte * conversion_table) && Main_backups->Pages->Image_mode != IMAGE_MODE_MODE5) { Remap_general_lowlevel(conversion_table,Main_visible_image.Image,Main_visible_image.Image, - Main_image_width,Main_image_height,Main_image_width); + 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); + 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]; // On calcule les limites à l'écran de l'image - if (Main_image_height>=Menu_Y_before_window) + if (Main.image_height>=Menu_Y_before_window) end_y=Menu_Y_before_window; else - end_y=Main_image_height; + end_y=Main.image_height; - if (!Main_magnifier_mode) + if (!Main.magnifier_mode) { - if (Main_image_width>=Screen_width) + if (Main.image_width>=Screen_width) end_x=Screen_width; else - end_x=Main_image_width; + end_x=Main.image_width; } else { - if (Main_image_width>=Main_separator_position) - end_x=Main_separator_position; + if (Main.image_width>=Main.separator_position) + end_x=Main.separator_position; else - end_x=Main_image_width; + end_x=Main.image_width; - if ((Main_X_zoom+(Main_image_width*Main_magnifier_factor))>=Screen_width) + if ((Main.X_zoom+(Main.image_width*Main.magnifier_factor))>=Screen_width) end_x_mag=Screen_width; else - end_x_mag=(Main_X_zoom+(Main_image_width*Main_magnifier_factor)); + end_x_mag=(Main.X_zoom+(Main.image_width*Main.magnifier_factor)); - if (Main_image_height*Main_magnifier_factor>=Menu_Y_before_window) + if (Main.image_height*Main.magnifier_factor>=Menu_Y_before_window) end_y_mag=Menu_Y_before_window; else - end_y_mag=Main_image_height*Main_magnifier_factor; + end_y_mag=Main.image_height*Main.magnifier_factor; } // On doit maintenant faire la traduction à l'écran Remap_zone_highlevel(0,0,end_x,end_y,conversion_table); - if (Main_magnifier_mode) + if (Main.magnifier_mode) { - Remap_zone_highlevel(Main_separator_position,0,end_x_mag,end_y_mag,conversion_table); + Remap_zone_highlevel(Main.separator_position,0,end_x_mag,end_y_mag,conversion_table); // Il peut encore rester le bas de la barre de split à remapper si la // partie zoomée ne descend pas jusqu'en bas... - Remap_zone_highlevel(Main_separator_position,end_y_mag, - (Main_separator_position+(SEPARATOR_WIDTH*Menu_factor_X)), + Remap_zone_highlevel(Main.separator_position,end_y_mag, + (Main.separator_position+(SEPARATOR_WIDTH*Menu_factor_X)), Menu_Y_before_window,conversion_table); } // Remappe tous les fonds de fenetre (qui doivent contenir un bout d'écran) @@ -558,12 +558,12 @@ void Set_nice_menu_colors(dword * color_usage,int not_picture) target_rgb=Favorite_GUI_color(index); color=new_colors[index]; - rgb[index].R=Main_palette[color].R; - rgb[index].G=Main_palette[color].G; - rgb[index].B=Main_palette[color].B; - Main_palette[color].R=Round_palette_component(target_rgb->R); - Main_palette[color].G=Round_palette_component(target_rgb->G); - Main_palette[color].B=Round_palette_component(target_rgb->B); + rgb[index].R=Main.palette[color].R; + rgb[index].G=Main.palette[color].G; + rgb[index].B=Main.palette[color].B; + Main.palette[color].R=Round_palette_component(target_rgb->R); + Main.palette[color].G=Round_palette_component(target_rgb->G); + Main.palette[color].B=Round_palette_component(target_rgb->B); } // Maintenant qu'on a placé notre nouvelle palette, on va chercher quelles @@ -1153,7 +1153,7 @@ void Button_Palette(void) Open_window(299, 196,"Palette"); - memcpy(working_palette, Main_palette, sizeof(T_Palette)); + memcpy(working_palette, Main.palette, sizeof(T_Palette)); Palette_edit_step(); Window_set_palette_button(5, 89); // 1 @@ -1977,11 +1977,11 @@ void Button_Palette(void) if ((Config.Safety_colors) && (used_colors<4)) { - memcpy(temp_palette, Main_palette, sizeof(T_Palette)); - memcpy(Main_palette, working_palette, sizeof(T_Palette)); + memcpy(temp_palette, Main.palette, sizeof(T_Palette)); + memcpy(Main.palette, working_palette, sizeof(T_Palette)); Set_nice_menu_colors(color_usage, 0); - memcpy(working_palette, Main_palette, sizeof(T_Palette)); - memcpy(Main_palette, temp_palette, sizeof(T_Palette)); + memcpy(working_palette, Main.palette, sizeof(T_Palette)); + memcpy(Main.palette, temp_palette, sizeof(T_Palette)); } Set_palette(working_palette); // On définit la nouvelle palette @@ -2024,11 +2024,11 @@ void Button_Palette(void) if ((Config.Safety_colors) && (used_colors<4) && (block_end==block_start)) { - memcpy(temp_palette,Main_palette,sizeof(T_Palette)); - memcpy(Main_palette,working_palette,sizeof(T_Palette)); + memcpy(temp_palette,Main.palette,sizeof(T_Palette)); + memcpy(Main.palette,working_palette,sizeof(T_Palette)); Set_nice_menu_colors(color_usage,0); - memcpy(working_palette,Main_palette,sizeof(T_Palette)); - memcpy(Main_palette,temp_palette,sizeof(T_Palette)); + memcpy(working_palette,Main.palette,sizeof(T_Palette)); + memcpy(Main.palette,temp_palette,sizeof(T_Palette)); } Set_palette(working_palette); @@ -2706,11 +2706,11 @@ void Button_Palette(void) Update_color_count(&used_colors, color_usage); Palette_edit_step(); - memcpy(temp_palette,Main_palette,sizeof(T_Palette)); - memcpy(Main_palette,working_palette,sizeof(T_Palette)); + memcpy(temp_palette,Main.palette,sizeof(T_Palette)); + memcpy(Main.palette,working_palette,sizeof(T_Palette)); Set_nice_menu_colors(color_usage,0); - memcpy(working_palette,Main_palette,sizeof(T_Palette)); - memcpy(Main_palette,temp_palette,sizeof(T_Palette)); + memcpy(working_palette,Main.palette,sizeof(T_Palette)); + memcpy(Main.palette,temp_palette,sizeof(T_Palette)); Set_palette(working_palette); memcpy(temp_palette,working_palette,sizeof(T_Palette)); Draw_all_palette_sliders(red_slider,green_slider,blue_slider,working_palette,block_start,block_end); @@ -2827,14 +2827,14 @@ void Button_Palette(void) if (clicked_button==14) // Sortie par OK { if ( (!image_is_backed_up) - && memcmp(Main_palette,working_palette,sizeof(T_Palette)) ) + && memcmp(Main.palette,working_palette,sizeof(T_Palette)) ) Backup_layers(LAYER_NONE); - memcpy(Main_palette,working_palette,sizeof(T_Palette)); + memcpy(Main.palette,working_palette,sizeof(T_Palette)); End_of_modification(); // Not really needed, the change was in palette entries } - Compute_optimal_menu_colors(Main_palette); + Compute_optimal_menu_colors(Main.palette); // La variable employée ici n'a pas vraiment de rapport avec son nom... need_to_remap=(Window_pos_Y+(Window_height*Menu_factor_Y)= 0 && y - Main_offset_Y >= 0) - Pixel_double(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_double(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_double (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_double(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_double(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -110,18 +110,18 @@ void Pixel_preview_magnifier_double (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_double( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -216,7 +216,7 @@ void Display_brush_mono_double(word x_pos, word y_pos, void Clear_brush_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -349,8 +349,8 @@ void Display_part_of_screen_scaled_double( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -359,24 +359,24 @@ void Display_part_of_screen_scaled_double( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor; + x = Main.magnifier_factor; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_double( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -401,12 +401,12 @@ void Display_brush_color_zoom_double(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { - Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color); - memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color); + memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -437,18 +437,18 @@ void Display_brush_mono_zoom_double(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_double( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -457,9 +457,9 @@ void Display_brush_mono_zoom_double(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -482,23 +482,23 @@ void Clear_brush_scaled_double(word x_pos,word y_pos,word x_offset,word y_offset // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ Display_line_on_screen_fast_double(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxquad.c b/src/pxquad.c index a74f090d..c5b6b1da 100644 --- a/src/pxquad.c +++ b/src/pxquad.c @@ -76,7 +76,7 @@ void Display_part_of_screen_quad (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; int dy; @@ -110,14 +110,14 @@ void Pixel_preview_normal_quad (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_quad(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_quad(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_quad (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_quad(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_quad(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -125,18 +125,18 @@ void Pixel_preview_magnifier_quad (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_quad( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -231,7 +231,7 @@ void Display_brush_mono_quad(word x_pos, word y_pos, void Clear_brush_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -366,8 +366,8 @@ void Display_part_of_screen_scaled_quad( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -376,24 +376,24 @@ void Display_part_of_screen_scaled_quad( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor/**ZOOMY*/; + x = Main.magnifier_factor/**ZOOMY*/; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_quad( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height/**ZOOMY*/) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -418,15 +418,15 @@ void Display_brush_color_zoom_quad(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { byte* line_src = buffer; byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; word x; // Pour chaque pixel de la ligne - for(x = width*Main_magnifier_factor;x > 0;x--) + for(x = width*Main.magnifier_factor;x > 0;x--) { if(*line_src!=transp_color) { @@ -436,11 +436,11 @@ void Display_brush_color_zoom_quad(word x_pos,word y_pos, dest+=ZOOMX; } // Double the line - memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Triple the line - memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Quadruple it - memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -471,18 +471,18 @@ void Display_brush_mono_zoom_quad(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_quad( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -491,9 +491,9 @@ void Display_brush_mono_zoom_quad(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -516,24 +516,24 @@ void Clear_brush_scaled_quad(word x_pos,word y_pos,word x_offset,word y_offset,w // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ // TODO a verifier Display_line_on_screen_fast_quad(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxsimple.c b/src/pxsimple.c index 1e4a95d7..371269ea 100644 --- a/src/pxsimple.c +++ b/src/pxsimple.c @@ -58,7 +58,7 @@ void Display_part_of_screen_simple (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; for(y=height;y!=0;y--) @@ -80,14 +80,14 @@ void Pixel_preview_normal_simple (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_simple(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_simple (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_simple(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_simple(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -95,18 +95,18 @@ void Pixel_preview_magnifier_simple (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_simple( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -200,7 +200,7 @@ void Display_brush_mono_simple(word x_pos, word y_pos, void Clear_brush_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; (void)x_offset; // unused (void)y_offset; // unused @@ -307,8 +307,8 @@ void Display_part_of_screen_scaled_simple( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -317,24 +317,24 @@ void Display_part_of_screen_scaled_simple( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor; + x = Main.magnifier_factor; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_simple( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -376,11 +376,11 @@ void Display_brush_color_zoom_simple(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { - Display_transparent_line_on_screen_simple(x_pos,y,width*Main_magnifier_factor,buffer,transp_color); + Display_transparent_line_on_screen_simple(x_pos,y,width*Main.magnifier_factor,buffer,transp_color); y++; if(y==end_y_pos) { @@ -411,18 +411,18 @@ void Display_brush_mono_zoom_simple(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor; + bx = Main.magnifier_factor; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_simple( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -431,9 +431,9 @@ void Display_brush_mono_zoom_simple(word x_pos, word y_pos, if(y == end_y_pos) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -455,23 +455,23 @@ void Clear_brush_scaled_simple(word x_pos,word y_pos,word x_offset,word y_offset // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ Display_line_on_screen_simple(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxtall.c b/src/pxtall.c index 6e867d99..f8ae2849 100644 --- a/src/pxtall.c +++ b/src/pxtall.c @@ -63,7 +63,7 @@ void Display_part_of_screen_tall (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; for(y=height;y!=0;y--) @@ -87,14 +87,14 @@ void Pixel_preview_normal_tall (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_tall(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_tall (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_tall(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_tall(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -102,18 +102,18 @@ void Pixel_preview_magnifier_tall (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_tall( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -215,7 +215,7 @@ void Display_brush_mono_tall(word x_pos, word y_pos, void Clear_brush_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; (void)x_offset; // unused (void)y_offset; // unused @@ -308,8 +308,8 @@ void Display_part_of_screen_scaled_tall( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -318,24 +318,24 @@ void Display_part_of_screen_scaled_tall( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor*ZOOMY; + x = Main.magnifier_factor*ZOOMY; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_simple( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height*ZOOMY) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -360,12 +360,12 @@ void Display_brush_color_zoom_tall(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { - Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color); - memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main_magnifier_factor); + Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color); + memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -396,18 +396,18 @@ void Display_brush_mono_zoom_tall(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_simple( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -416,9 +416,9 @@ void Display_brush_mono_zoom_tall(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -440,23 +440,23 @@ void Clear_brush_scaled_tall(word x_pos,word y_pos,word x_offset,word y_offset,w // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ Display_line_on_screen_tall(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxtall2.c b/src/pxtall2.c index 66821457..1f963f71 100644 --- a/src/pxtall2.c +++ b/src/pxtall2.c @@ -68,7 +68,7 @@ void Display_part_of_screen_tall2 (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; int dy; @@ -102,14 +102,14 @@ void Pixel_preview_normal_tall2 (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_tall2(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_tall2(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_tall2 (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_tall2(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_tall2(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -117,18 +117,18 @@ void Pixel_preview_magnifier_tall2 (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_tall2( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -223,7 +223,7 @@ void Display_brush_mono_tall2(word x_pos, word y_pos, void Clear_brush_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -358,8 +358,8 @@ void Display_part_of_screen_scaled_tall2( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -368,24 +368,24 @@ void Display_part_of_screen_scaled_tall2( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor/**ZOOMY*/; + x = Main.magnifier_factor/**ZOOMY*/; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_tall2( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height/**ZOOMY*/) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -410,15 +410,15 @@ void Display_brush_color_zoom_tall2(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { byte* line_src = buffer; byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; word x; // Pour chaque pixel de la ligne - for(x = width*Main_magnifier_factor;x > 0;x--) + for(x = width*Main.magnifier_factor;x > 0;x--) { if(*line_src!=transp_color) { @@ -428,11 +428,11 @@ void Display_brush_color_zoom_tall2(word x_pos,word y_pos, dest+=ZOOMX; } // Double the line - memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Triple the line - memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Quadruple it - memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -463,18 +463,18 @@ void Display_brush_mono_zoom_tall2(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_tall2( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -483,9 +483,9 @@ void Display_brush_mono_zoom_tall2(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -508,24 +508,24 @@ void Clear_brush_scaled_tall2(word x_pos,word y_pos,word x_offset,word y_offset, // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ // TODO a verifier Display_line_on_screen_fast_tall2(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxtall3.c b/src/pxtall3.c index 9bdc55db..58742860 100644 --- a/src/pxtall3.c +++ b/src/pxtall3.c @@ -72,7 +72,7 @@ void Display_part_of_screen_tall3 (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; int dy; @@ -106,14 +106,14 @@ void Pixel_preview_normal_tall3 (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_tall3(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_tall3(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_tall3 (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_tall3(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_tall3(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -121,18 +121,18 @@ void Pixel_preview_magnifier_tall3 (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_tall3( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -227,7 +227,7 @@ void Display_brush_mono_tall3(word x_pos, word y_pos, void Clear_brush_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -362,8 +362,8 @@ void Display_part_of_screen_scaled_tall3( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -372,24 +372,24 @@ void Display_part_of_screen_scaled_tall3( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor/**ZOOMY*/; + x = Main.magnifier_factor/**ZOOMY*/; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_tall3( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height/**ZOOMY*/) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -414,15 +414,15 @@ void Display_brush_color_zoom_tall3(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { byte* line_src = buffer; byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; word x; // Pour chaque pixel de la ligne - for(x = width*Main_magnifier_factor;x > 0;x--) + for(x = width*Main.magnifier_factor;x > 0;x--) { if(*line_src!=transp_color) { @@ -432,11 +432,11 @@ void Display_brush_color_zoom_tall3(word x_pos,word y_pos, dest+=ZOOMX; } // Double the line - memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Triple the line - memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Quadruple it - memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -467,18 +467,18 @@ void Display_brush_mono_zoom_tall3(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_tall3( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -487,9 +487,9 @@ void Display_brush_mono_zoom_tall3(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -512,24 +512,24 @@ void Clear_brush_scaled_tall3(word x_pos,word y_pos,word x_offset,word y_offset, // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ // TODO a verifier Display_line_on_screen_fast_tall3(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxtriple.c b/src/pxtriple.c index bcca69dc..2b49ce80 100644 --- a/src/pxtriple.c +++ b/src/pxtriple.c @@ -69,7 +69,7 @@ void Display_part_of_screen_triple (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; int dy; @@ -101,14 +101,14 @@ void Pixel_preview_normal_triple (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_triple(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_triple (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_triple(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_triple(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -116,18 +116,18 @@ void Pixel_preview_magnifier_triple (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_triple( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -222,7 +222,7 @@ void Display_brush_mono_triple(word x_pos, word y_pos, void Clear_brush_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -356,8 +356,8 @@ void Display_part_of_screen_scaled_triple( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -366,24 +366,24 @@ void Display_part_of_screen_scaled_triple( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor/**ZOOMY*/; + x = Main.magnifier_factor/**ZOOMY*/; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_triple( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height/**ZOOMY*/) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -408,15 +408,15 @@ void Display_brush_color_zoom_triple(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { byte* line_src = buffer; byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; word x; // Pour chaque pixel de la ligne - for(x = width*Main_magnifier_factor;x > 0;x--) + for(x = width*Main.magnifier_factor;x > 0;x--) { if(*line_src!=transp_color) { @@ -426,9 +426,9 @@ void Display_brush_color_zoom_triple(word x_pos,word y_pos, dest+=ZOOMX; } // Double the line - memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); // Triple the line - memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -459,18 +459,18 @@ void Display_brush_mono_zoom_triple(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_triple( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -479,9 +479,9 @@ void Display_brush_mono_zoom_triple(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -504,24 +504,24 @@ void Clear_brush_scaled_triple(word x_pos,word y_pos,word x_offset,word y_offset // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ // TODO a verifier Display_line_on_screen_fast_triple(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxwide.c b/src/pxwide.c index 90761fc7..ecc50ce5 100644 --- a/src/pxwide.c +++ b/src/pxwide.c @@ -62,7 +62,7 @@ void Display_part_of_screen_wide (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; int dy; @@ -90,14 +90,14 @@ void Pixel_preview_normal_wide (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_wide(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_wide(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_wide (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_wide(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_wide(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -105,18 +105,18 @@ void Pixel_preview_magnifier_wide (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_wide( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -211,7 +211,7 @@ void Display_brush_mono_wide(word x_pos, word y_pos, void Clear_brush_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -342,8 +342,8 @@ void Display_part_of_screen_scaled_wide( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -352,24 +352,24 @@ void Display_part_of_screen_scaled_wide( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor; + x = Main.magnifier_factor; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_wide( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -412,11 +412,11 @@ void Display_brush_color_zoom_wide(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { - Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main_magnifier_factor,buffer,transp_color); + Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color); y++; if(y==end_y_pos) { @@ -447,18 +447,18 @@ void Display_brush_mono_zoom_wide(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_wide( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -467,9 +467,9 @@ void Display_brush_mono_zoom_wide(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -491,23 +491,23 @@ void Clear_brush_scaled_wide(word x_pos,word y_pos,word x_offset,word y_offset,w // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ Display_line_on_screen_fast_wide(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/pxwide2.c b/src/pxwide2.c index c8e7be43..c8179952 100644 --- a/src/pxwide2.c +++ b/src/pxwide2.c @@ -68,7 +68,7 @@ void Display_part_of_screen_wide2 (word width,word height,word image_width) /* Afficher une partie de l'image telle quelle sur l'écran */ { byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) - byte* src=Main_offset_Y*image_width+Main_offset_X+Main_screen; //Coords de départ ds la source (src) + byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) int y; int dy; @@ -98,14 +98,14 @@ void Pixel_preview_normal_wide2 (word x,word y,byte color) * Note: si on modifie cette procédure, il faudra penser à faire également * la modif dans la procédure Pixel_Preview_Loupe_SDL. */ { -// if(x-Main_offset_X >= 0 && y - Main_offset_Y >= 0) - Pixel_wide2(x-Main_offset_X,y-Main_offset_Y,color); +// if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0) + Pixel_wide2(x-Main.offset_X,y-Main.offset_Y,color); } void Pixel_preview_magnifier_wide2 (word x,word y,byte color) { // Affiche le pixel dans la partie non zoomée - Pixel_wide2(x-Main_offset_X,y-Main_offset_Y,color); + Pixel_wide2(x-Main.offset_X,y-Main.offset_Y,color); // Regarde si on doit aussi l'afficher dans la partie zoomée if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom @@ -113,18 +113,18 @@ void Pixel_preview_magnifier_wide2 (word x,word y,byte color) { // On est dedans int height; - int y_zoom = Main_magnifier_factor * (y-Main_magnifier_offset_Y); + int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y); - if (Menu_Y - y_zoom < Main_magnifier_factor) + if (Menu_Y - y_zoom < Main.magnifier_factor) // On ne doit dessiner qu'un morceau du pixel // sinon on dépasse sur le menu height = Menu_Y - y_zoom; else - height = Main_magnifier_factor; + height = Main.magnifier_factor; Block_wide2( - Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, - y_zoom, Main_magnifier_factor, height, color + Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom, + y_zoom, Main.magnifier_factor, height, color ); } } @@ -219,7 +219,7 @@ void Display_brush_mono_wide2(word x_pos, word y_pos, void Clear_brush_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) { byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) - byte* src = ( y_pos + Main_offset_Y ) * image_width + x_pos + Main_offset_X + Main_screen; //Coords de départ ds la source (src) + byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) int y; int x; (void)x_offset; // unused @@ -352,8 +352,8 @@ void Display_part_of_screen_scaled_wide2( word height, // height zoomée word image_width,byte * buffer) { - byte* src = Main_screen + Main_magnifier_offset_Y * image_width - + Main_magnifier_offset_X; + byte* src = Main_screen + Main.magnifier_offset_Y * image_width + + Main.magnifier_offset_X; int y = 0; // Ligne en cours de traitement // Pour chaque ligne à zoomer @@ -362,24 +362,24 @@ void Display_part_of_screen_scaled_wide2( int x; // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); // On l'affiche Facteur fois, sur des lignes consécutives - x = Main_magnifier_factor/**ZOOMY*/; + x = Main.magnifier_factor/**ZOOMY*/; // Pour chaque ligne do{ // On affiche la ligne zoomée Display_line_on_screen_fast_wide2( - Main_X_zoom, y, width*Main_magnifier_factor, + Main.X_zoom, y, width*Main.magnifier_factor, buffer ); // On passe à la suivante y++; if(y==height/**ZOOMY*/) { - Redraw_grid(Main_X_zoom,0, - width*Main_magnifier_factor,height); - Update_rect(Main_X_zoom,0, - width*Main_magnifier_factor,height); + Redraw_grid(Main.X_zoom,0, + width*Main.magnifier_factor,height); + Update_rect(Main.X_zoom,0, + width*Main.magnifier_factor,height); return; } x--; @@ -404,15 +404,15 @@ void Display_brush_color_zoom_wide2(word x_pos,word y_pos, // Pour chaque ligne while(1) { - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche facteur fois la ligne zoomée - for(bx=Main_magnifier_factor;bx>0;bx--) + for(bx=Main.magnifier_factor;bx>0;bx--) { byte* line_src = buffer; byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; word x; // Pour chaque pixel de la ligne - for(x = width*Main_magnifier_factor;x > 0;x--) + for(x = width*Main.magnifier_factor;x > 0;x--) { if(*line_src!=transp_color) { @@ -422,7 +422,7 @@ void Display_brush_color_zoom_wide2(word x_pos,word y_pos, dest+=ZOOMX; } // Double the line - memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main_magnifier_factor); + memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); y++; if(y==end_y_pos) { @@ -453,18 +453,18 @@ void Display_brush_mono_zoom_wide2(word x_pos, word y_pos, int bx; // src = Ligne originale // On éclate la ligne - Zoom_a_line(src,buffer,Main_magnifier_factor,width); + Zoom_a_line(src,buffer,Main.magnifier_factor,width); // On affiche la ligne Facteur fois à l'écran (sur des // lignes consécutives) - bx = Main_magnifier_factor*ZOOMY; + bx = Main.magnifier_factor*ZOOMY; // Pour chaque ligne écran do { // On affiche la ligne zoomée Display_transparent_mono_line_on_screen_wide2( - x_pos, y, width * Main_magnifier_factor, + x_pos, y, width * Main.magnifier_factor, buffer, transp_color, color ); // On passe à la ligne suivante @@ -473,9 +473,9 @@ void Display_brush_mono_zoom_wide2(word x_pos, word y_pos, if(y == end_y_pos*ZOOMY) { Redraw_grid( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); Update_rect( x_pos, y_pos, - width * Main_magnifier_factor, end_y_pos - y_pos ); + width * Main.magnifier_factor, end_y_pos - y_pos ); return; } bx --; @@ -498,24 +498,24 @@ void Clear_brush_scaled_wide2(word x_pos,word y_pos,word x_offset,word y_offset, // Pour chaque ligne à zoomer while(1){ - Zoom_a_line(src,buffer,Main_magnifier_factor*ZOOMX,width); + Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width); - bx=Main_magnifier_factor; + bx=Main.magnifier_factor; // Pour chaque ligne do{ // TODO a verifier Display_line_on_screen_fast_wide2(x_pos,y, - width * Main_magnifier_factor,buffer); + width * Main.magnifier_factor,buffer); // Ligne suivante y++; if(y==end_y_pos) { Redraw_grid(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); Update_rect(x_pos,y_pos, - width*Main_magnifier_factor,end_y_pos-y_pos); + width*Main.magnifier_factor,end_y_pos-y_pos); return; } bx--; diff --git a/src/sdlscreen.c b/src/sdlscreen.c index 7ded3758..54679070 100644 --- a/src/sdlscreen.c +++ b/src/sdlscreen.c @@ -259,9 +259,9 @@ byte * Surface_to_bytefield(SDL_Surface *source, byte * dest) SDL_Color Color_to_SDL_color(byte index) { SDL_Color color; - color.r = Main_palette[index].R; - color.g = Main_palette[index].G; - color.b = Main_palette[index].B; + color.r = Main.palette[index].R; + color.g = Main.palette[index].G; + color.b = Main.palette[index].B; color.unused = 255; return color; } diff --git a/src/special.c b/src/special.c index db8e14c0..bcc6424a 100644 --- a/src/special.c +++ b/src/special.c @@ -301,24 +301,24 @@ void Scroll_screen(short delta_x,short delta_y) short temp_x_offset; short temp_y_offset; - temp_x_offset=Main_offset_X+delta_x; - temp_y_offset=Main_offset_Y+delta_y; + temp_x_offset=Main.offset_X+delta_x; + temp_y_offset=Main.offset_Y+delta_y; - if (temp_x_offset+Screen_width>Main_image_width) - temp_x_offset=Main_image_width-Screen_width; - if (temp_y_offset+Menu_Y>Main_image_height) - temp_y_offset=Main_image_height-Menu_Y; + if (temp_x_offset+Screen_width>Main.image_width) + temp_x_offset=Main.image_width-Screen_width; + if (temp_y_offset+Menu_Y>Main.image_height) + temp_y_offset=Main.image_height-Menu_Y; if (temp_x_offset<0) temp_x_offset=0; if (temp_y_offset<0) temp_y_offset=0; - if ( (Main_offset_X!=temp_x_offset) || - (Main_offset_Y!=temp_y_offset) ) + if ( (Main.offset_X!=temp_x_offset) || + (Main.offset_Y!=temp_y_offset) ) { Hide_cursor(); - Main_offset_X=temp_x_offset; - Main_offset_Y=temp_y_offset; + Main.offset_X=temp_x_offset; + Main.offset_Y=temp_y_offset; Compute_limits(); Compute_paintbrush_coordinates(); @@ -335,17 +335,17 @@ void Scroll_magnifier(short delta_x,short delta_y) short temp_x_offset; short temp_y_offset; - temp_x_offset=Main_magnifier_offset_X+delta_x; - temp_y_offset=Main_magnifier_offset_Y+delta_y; + temp_x_offset=Main.magnifier_offset_X+delta_x; + temp_y_offset=Main.magnifier_offset_Y+delta_y; Clip_magnifier_offsets(&temp_x_offset, &temp_y_offset); - if ( (Main_magnifier_offset_X!=temp_x_offset) || - (Main_magnifier_offset_Y!=temp_y_offset) ) + if ( (Main.magnifier_offset_X!=temp_x_offset) || + (Main.magnifier_offset_Y!=temp_y_offset) ) { Hide_cursor(); - Main_magnifier_offset_X=temp_x_offset; - Main_magnifier_offset_Y=temp_y_offset; + Main.magnifier_offset_X=temp_x_offset; + Main.magnifier_offset_Y=temp_y_offset; Position_screen_according_to_zoom(); @@ -362,14 +362,14 @@ void Scroll_magnifier(short delta_x,short delta_y) void Zoom(short delta) { short index; - for (index=0; ZOOM_FACTOR[index]!=Main_magnifier_factor; index++); + for (index=0; ZOOM_FACTOR[index]!=Main.magnifier_factor; index++); index+=delta; if ( (index>=0) && (indexw * text_surface->h; index++) @@ -508,7 +508,7 @@ byte *Render_text_TTF(const char *str, int font_number, int size, int antialias, // Now copy the current palette to brushe's, for consistency // with the indices. - memcpy(palette, Main_palette, sizeof(T_Palette)); + memcpy(palette, Main.palette, sizeof(T_Palette)); } *width=text_surface->w; diff --git a/src/tiles.c b/src/tiles.c index 6da3ed07..f8e7a106 100644 --- a/src/tiles.c +++ b/src/tiles.c @@ -118,12 +118,12 @@ 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++) { - if (memcmp(bmp1+y*Main_image_width, bmp2+y*Main_image_width, Snap_width)) + if (memcmp(bmp1+y*Main.image_width, bmp2+y*Main.image_width, Snap_width)) return 0; } return 1; @@ -135,13 +135,13 @@ 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++) { for (x=0; x < Snap_width; x++) - if (*(bmp1+y*Main_image_width+x) != *(bmp2+y*Main_image_width-x)) + if (*(bmp1+y*Main.image_width+x) != *(bmp2+y*Main.image_width-x)) return 0; } return 1; @@ -153,12 +153,12 @@ 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++) { - if (memcmp(bmp1+y*Main_image_width, bmp2-y*Main_image_width, Snap_width)) + if (memcmp(bmp1+y*Main.image_width, bmp2-y*Main.image_width, Snap_width)) return 0; } return 1; @@ -171,13 +171,13 @@ 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++) { for (x=0; x < Snap_width; x++) - if (*(bmp1+y*Main_image_width+x) != *(bmp2-y*Main_image_width-x)) + if (*(bmp1+y*Main.image_width+x) != *(bmp2-y*Main.image_width-x)) return 0; } return 1; @@ -195,11 +195,11 @@ void Tilemap_update(void) int wait_window=0; byte old_cursor=0; - if (!Main_tilemap_mode) + if (!Main.tilemap_mode) return; - width=(Main_image_width-Snap_offset_X)/Snap_width; - height=(Main_image_height-Snap_offset_Y)/Snap_height; + width=(Main.image_width-Snap_offset_X)/Snap_width; + height=(Main.image_height-Snap_offset_Y)/Snap_height; if (width<1 || height<1 || width*height>1000000l || (tile_ptr=(T_Tile *)malloc(width*height*sizeof(T_Tile))) == NULL) @@ -382,7 +382,8 @@ void Tilemap_update(void) /// be called when swapping pages. void Swap_tilemap(void) { - SWAP_BYTES(Main_tilemap_mode, Spare_tilemap_mode) +//TODO + SWAP_BYTES(Main.tilemap_mode, Spare.tilemap_mode) { T_Tile * a; a=Main_tilemap; @@ -406,7 +407,7 @@ void Disable_main_tilemap(void) } Main_tilemap_width=0; Main_tilemap_height=0; - Main_tilemap_mode=0; + Main.tilemap_mode=0; } /// @@ -422,5 +423,5 @@ void Disable_spare_tilemap(void) } Spare_tilemap_width=0; Spare_tilemap_height=0; - Spare_tilemap_mode=0; + Spare.tilemap_mode=0; } diff --git a/src/transform.c b/src/transform.c index 645c7cfb..a7833612 100644 --- a/src/transform.c +++ b/src/transform.c @@ -92,8 +92,8 @@ void Button_Transform_menu(void) short old_ratio_height; short new_ratio_width; short new_ratio_height; - short new_width=Main_image_width; - short new_height=Main_image_height; + short new_width=Main.image_width; + short new_height=Main.image_height; byte need_display_size = 0; // Persistent data @@ -162,9 +162,9 @@ void Button_Transform_menu(void) case UNIT_PIXELS: default: input_value[0]=&new_width; - input_value[1]=&Main_image_width; // Don't worry, it's read-only + input_value[1]=&Main.image_width; // Don't worry, it's read-only input_value[2]=&new_height; - input_value[3]=&Main_image_height; // Don't worry, it's read-only + input_value[3]=&Main.image_height; // Don't worry, it's read-only break; case UNIT_PERCENT: case UNIT_RATIO: @@ -220,14 +220,14 @@ void Button_Transform_menu(void) old_ratio_width = 100; old_ratio_height = 100; // Update pixel dimensions, to match percentage exactly - new_width=Compute_dimension(Main_image_width, new_ratio_width, old_ratio_width); - new_height=Compute_dimension(Main_image_height, new_ratio_height, old_ratio_height); + new_width=Compute_dimension(Main.image_width, new_ratio_width, old_ratio_width); + new_height=Compute_dimension(Main.image_height, new_ratio_height, old_ratio_height); } else // unit_index == UNIT_PIXELS { // Approximate from current pixel size - new_ratio_width = new_width*100/Main_image_width; - new_ratio_height = new_height*100/Main_image_height; + new_ratio_width = new_width*100/Main.image_width; + new_ratio_height = new_height*100/Main.image_height; old_ratio_width = 100; old_ratio_height = 100; } @@ -244,8 +244,8 @@ void Button_Transform_menu(void) // Compute simplest ratio from current pixel size new_ratio_width = new_width; new_ratio_height = new_height; - old_ratio_width = Main_image_width; - old_ratio_height = Main_image_height; + old_ratio_width = Main.image_width; + old_ratio_height = Main.image_height; Factorize(&new_ratio_width, &old_ratio_width); Factorize(&new_ratio_height, &old_ratio_height); } @@ -292,7 +292,7 @@ void Button_Transform_menu(void) // Get Y value because X changed if (unit_index == UNIT_PIXELS) { - new_height=Compute_dimension(Main_image_height, new_width, Main_image_width); + new_height=Compute_dimension(Main.image_height, new_width, Main.image_width); } else { @@ -306,7 +306,7 @@ void Button_Transform_menu(void) // Get X value because Y changed if (unit_index == UNIT_PIXELS) { - new_width=Compute_dimension(Main_image_width, new_height, Main_image_height); + new_width=Compute_dimension(Main.image_width, new_height, Main.image_height); } else { @@ -320,13 +320,13 @@ void Button_Transform_menu(void) // Re-compute ratio from size in pixels if (unit_index == UNIT_PIXELS) { - //new_width=(long)Main_image_width*new_ratio_width/old_ratio_width; - //new_height=(long)Main_image_height*new_ratio_height/old_ratio_height; + //new_width=(long)Main.image_width*new_ratio_width/old_ratio_width; + //new_height=(long)Main.image_height*new_ratio_height/old_ratio_height; } else // Re-compute size in pixels from ratio { - new_width=Compute_dimension(Main_image_width,new_ratio_width,old_ratio_width); - new_height=Compute_dimension(Main_image_height,new_ratio_height,old_ratio_height); + new_width=Compute_dimension(Main.image_width,new_ratio_width,old_ratio_width); + new_height=Compute_dimension(Main.image_height,new_ratio_height,old_ratio_height); } need_display_size=1; } @@ -356,20 +356,20 @@ void Button_Transform_menu(void) case 2 : // Flip X case 3 : // Flip Y case 6 : // 180° Rotation - new_width=Main_image_width; - new_height=Main_image_height; + new_width=Main.image_width; + new_height=Main.image_height; break; case 4 : // -90° Rotation case 5 : // +90° Rotation - new_width=Main_image_height; - new_height=Main_image_width; + new_width=Main.image_height; + new_height=Main.image_width; break; } // Memorize the current dimensions - old_width=Main_image_width; - old_height=Main_image_height; + old_width=Main.image_width; + old_height=Main.image_height; Upload_infos_page_main(Main_backups->Pages); // Allocate a new page @@ -377,7 +377,7 @@ void Button_Transform_menu(void) { // The new image is allocated, the new dimensions are already updated. - Main_image_is_modified=1; + Main.image_is_modified=1; // Process the transformation: switch(clicked_button) @@ -387,15 +387,15 @@ void Button_Transform_menu(void) case 2 : // Flip X 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++) { - 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 @@ -413,14 +413,14 @@ void Button_Transform_menu(void) case 6 : // 180° Rotation 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++) { - 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), - Min(old_height,Main_image_height),old_width, - Main_backups->Pages->Image[i].Pixels,0,0,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); } */ Redraw_layered_image(); diff --git a/src/windows.c b/src/windows.c index eebc15e5..ab0307eb 100644 --- a/src/windows.c +++ b/src/windows.c @@ -534,9 +534,9 @@ void Display_layerbar(void) word y_pos; word sprite_index; - if (Main_current_layer == current_button) + if (Main.current_layer == current_button) sprite_index=1; - else if (Main_layers_visible & (1 << current_button)) + else if (Main.layers_visible & (1 << current_button)) sprite_index=0; else sprite_index=2; @@ -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, @@ -650,7 +650,7 @@ void Display_menu(void) if (!Windows_open) { if ((Mouse_Y=Main_X_zoom) )) + ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) )) { // Prepare display of XY coordinates even if in some cases they will be // erased with some other text @@ -768,8 +768,8 @@ void Print_coordinates(void) || (Current_operation==OPERATION_REPLACE) ) { if ( (Paintbrush_X>=0) && (Paintbrush_Y>=0) - && (Paintbrush_X=Main_image_height) - Limit_bottom=Main_image_height-1; + if (Limit_visible_bottom>=Main.image_height) + Limit_bottom=Main.image_height-1; else Limit_bottom=Limit_visible_bottom; - if (Limit_visible_right>=Main_image_width) - Limit_right=Main_image_width-1; + if (Limit_visible_right>=Main.image_width) + Limit_right=Main.image_width-1; else Limit_right=Limit_visible_right; // -- Calcul des limites de la partie zoomée de l'image -- - Limit_top_zoom =Main_magnifier_offset_Y; - Limit_left_zoom=Main_magnifier_offset_X; - Limit_visible_bottom_zoom =Limit_top_zoom+Main_magnifier_height-1; - Limit_visible_right_zoom=Limit_left_zoom+Main_magnifier_width-1; + Limit_top_zoom =Main.magnifier_offset_Y; + Limit_left_zoom=Main.magnifier_offset_X; + Limit_visible_bottom_zoom =Limit_top_zoom+Main.magnifier_height-1; + Limit_visible_right_zoom=Limit_left_zoom+Main.magnifier_width-1; - if (Limit_visible_bottom_zoom>=Main_image_height) - Limit_bottom_zoom=Main_image_height-1; + if (Limit_visible_bottom_zoom>=Main.image_height) + Limit_bottom_zoom=Main.image_height-1; else Limit_bottom_zoom=Limit_visible_bottom_zoom; - if (Limit_visible_right_zoom>=Main_image_width) - Limit_right_zoom=Main_image_width-1; + if (Limit_visible_right_zoom>=Main.image_width) + Limit_right_zoom=Main.image_width-1; else Limit_right_zoom=Limit_visible_right_zoom; } else { // -- Calcul des limites de la partie visible de l'image -- - Limit_top =Main_offset_Y; - Limit_left=Main_offset_X; + Limit_top =Main.offset_Y; + Limit_left=Main.offset_X; Limit_visible_bottom =Limit_top+(Menu_is_visible?Menu_Y:Screen_height)-1; // A REVOIR POUR SIMPLIFICATION Limit_visible_right=Limit_left+Screen_width-1; - if (Limit_visible_bottom>=Main_image_height) - Limit_bottom=Main_image_height-1; + if (Limit_visible_bottom>=Main.image_height) + Limit_bottom=Main.image_height-1; else Limit_bottom=Limit_visible_bottom; - if (Limit_visible_right>=Main_image_width) - Limit_right=Main_image_width-1; + if (Limit_visible_right>=Main.image_width) + Limit_right=Main.image_width-1; else Limit_right=Limit_visible_right; } @@ -1550,15 +1550,15 @@ void Compute_limits(void) // -- Calculer les coordonnées du pinceau en fonction du snap et de la loupe - void Compute_paintbrush_coordinates(void) { - if ((Main_magnifier_mode) && (Mouse_X>=Main_X_zoom)) + if ((Main.magnifier_mode) && (Mouse_X>=Main.X_zoom)) { - Paintbrush_X=((Mouse_X-Main_X_zoom)/Main_magnifier_factor)+Main_magnifier_offset_X; - Paintbrush_Y=(Mouse_Y/Main_magnifier_factor)+Main_magnifier_offset_Y; + Paintbrush_X=((Mouse_X-Main.X_zoom)/Main.magnifier_factor)+Main.magnifier_offset_X; + Paintbrush_Y=(Mouse_Y/Main.magnifier_factor)+Main.magnifier_offset_Y; } else { - Paintbrush_X=Mouse_X+Main_offset_X; - Paintbrush_Y=Mouse_Y+Main_offset_Y; + Paintbrush_X=Mouse_X+Main.offset_X; + Paintbrush_Y=Mouse_Y+Main.offset_Y; } if (Snap_mode) @@ -1621,16 +1621,16 @@ void Display_image_limits(void) byte bottom_is_visible; short old_zoom_limit; - right_is_visible=Main_image_width<((Main_magnifier_mode)?Main_separator_position:Screen_width); - bottom_is_visible =Main_image_heightMain_separator_position) + if (Main.image_width>Main.separator_position) { - Main_offset_X=Main_magnifier_offset_X+(Main_magnifier_width>>1) - -(Main_separator_position>>1); - if (Main_offset_X<0) - Main_offset_X=0; - else if (Main_image_width>1) + -(Main.separator_position>>1); + if (Main.offset_X<0) + Main.offset_X=0; + else if (Main.image_widthMenu_Y) + if (Main.image_height>Menu_Y) { - Main_offset_Y=Main_magnifier_offset_Y+(Main_magnifier_height>>1) + Main.offset_Y=Main.magnifier_offset_Y+(Main.magnifier_height>>1) -(Menu_Y>>1); - if (Main_offset_Y<0) - Main_offset_Y=0; - else if (Main_image_heightMain_separator_position) + if (Main.image_width>Main.separator_position) { - Main_offset_X=target_x-Mouse_X; + Main.offset_X=target_x-Mouse_X; // Do not allow the zoomed part to show something that the // non-zoomed part doesn't see. All clipping is computed according // to the non-zoomed part. - if (Main_magnifier_offset_X Main_offset_X+Main_separator_position) - Main_offset_X = Main_magnifier_offset_X+Main_magnifier_width-Main_separator_position; - if (Main_offset_X<0) - Main_offset_X=0; - else if (Main_image_width Main.offset_X+Main.separator_position) + Main.offset_X = Main.magnifier_offset_X+Main.magnifier_width-Main.separator_position; + if (Main.offset_X<0) + Main.offset_X=0; + else if (Main.image_widthMenu_Y) + if (Main.image_height>Menu_Y) { - Main_offset_Y=target_y-Mouse_Y; + Main.offset_Y=target_y-Mouse_Y; // Do not allow the zoomed part to show something that the // non-zoomed part doesn't see. All clipping is computed according // to the non-zoomed part. - if (Main_magnifier_offset_Y Main_offset_Y) - Main_offset_Y = Main_magnifier_offset_Y+Main_magnifier_height; - if (Main_offset_Y<0) - Main_offset_Y=0; - else if (Main_image_height Main.offset_Y) + Main.offset_Y = Main.magnifier_offset_Y+Main.magnifier_height; + if (Main.offset_Y<0) + Main.offset_Y=0; + else if (Main.image_height>1)-theoric_X)/Main_magnifier_factor)*Main_magnifier_factor); - Main_separator_position=Main_X_zoom-(Menu_factor_X*SEPARATOR_WIDTH); + Main.X_zoom=Screen_width-(((Screen_width+(Main.magnifier_factor>>1)-theoric_X)/Main.magnifier_factor)*Main.magnifier_factor); + Main.separator_position=Main.X_zoom-(Menu_factor_X*SEPARATOR_WIDTH); // Correction en cas de débordement sur la gauche - while (Main_separator_position*(Main_magnifier_factor+1)=theoric_X) + theoric_X=Screen_width-((NB_ZOOMED_PIXELS_MIN-1)*Main.magnifier_factor); + while (Main.X_zoom>=theoric_X) { - Main_separator_position-=Main_magnifier_factor; - Main_X_zoom-=Main_magnifier_factor; + Main.separator_position-=Main.magnifier_factor; + Main.X_zoom-=Main.magnifier_factor; } } @@ -1781,30 +1781,30 @@ void Compute_magnifier_data(void) { Compute_separator_data(); - Main_magnifier_width=(Screen_width-Main_X_zoom)/Main_magnifier_factor; + Main.magnifier_width=(Screen_width-Main.X_zoom)/Main.magnifier_factor; - Main_magnifier_height=Menu_Y/Main_magnifier_factor; - if (Menu_Y%Main_magnifier_factor) - Main_magnifier_height++; + Main.magnifier_height=Menu_Y/Main.magnifier_factor; + if (Menu_Y%Main.magnifier_factor) + Main.magnifier_height++; - Clip_magnifier_offsets(&Main_magnifier_offset_X, &Main_magnifier_offset_Y); + Clip_magnifier_offsets(&Main.magnifier_offset_X, &Main.magnifier_offset_Y); } void Clip_magnifier_offsets(short *x_offset, short *y_offset) { - if (Main_magnifier_mode) + if (Main.magnifier_mode) { if (*x_offset) { - if (Main_image_width<*x_offset+Main_magnifier_width) - *x_offset=Main_image_width-Main_magnifier_width; + if (Main.image_width<*x_offset+Main.magnifier_width) + *x_offset=Main.image_width-Main.magnifier_width; if (*x_offset<0) *x_offset=0; } if (*y_offset) { - if (Main_image_height<*y_offset+Main_magnifier_height) - *y_offset=Main_image_height-Main_magnifier_height+(Main_magnifier_height*Main_magnifier_factor-Menu_Y>=Main_magnifier_factor/2); + if (Main.image_height<*y_offset+Main.magnifier_height) + *y_offset=Main.image_height-Main.magnifier_height+(Main.magnifier_height*Main.magnifier_factor-Menu_Y>=Main.magnifier_factor/2); if (*y_offset<0) *y_offset=0; } @@ -1818,49 +1818,49 @@ void Change_magnifier_factor(byte factor_index, byte point_at_mouse) byte magnified_view_leads=1; // Values that need to be computed before switching to the new zoom factor - if (!point_at_mouse || Cursor_in_menu || !Main_magnifier_mode) + if (!point_at_mouse || Cursor_in_menu || !Main.magnifier_mode) { // Locate the pixel in center of the magnified area - target_x = Main_magnifier_offset_X + (Main_magnifier_width >> 1); - target_y = Main_magnifier_offset_Y + (Main_magnifier_height >> 1); + target_x = Main.magnifier_offset_X + (Main.magnifier_width >> 1); + target_y = Main.magnifier_offset_Y + (Main.magnifier_height >> 1); point_at_mouse=0; } - else if (Mouse_X>=Main_X_zoom) + else if (Mouse_X>=Main.X_zoom) { // Locate the pixel under the cursor, in magnified area - target_x=((Mouse_X-Main_X_zoom)/Main_magnifier_factor)+Main_magnifier_offset_X; - target_y=(Mouse_Y/Main_magnifier_factor)+Main_magnifier_offset_Y; + target_x=((Mouse_X-Main.X_zoom)/Main.magnifier_factor)+Main.magnifier_offset_X; + target_y=(Mouse_Y/Main.magnifier_factor)+Main.magnifier_offset_Y; point_at_mouse=1; } else { // Locate the pixel under the cursor, in normal area - target_x=Mouse_X+Main_offset_X; - target_y=Mouse_Y+Main_offset_Y; + target_x=Mouse_X+Main.offset_X; + target_y=Mouse_Y+Main.offset_Y; magnified_view_leads=0; point_at_mouse=0; } - Main_magnifier_factor=ZOOM_FACTOR[factor_index]; + Main.magnifier_factor=ZOOM_FACTOR[factor_index]; Compute_magnifier_data(); - if (Main_magnifier_mode) + if (Main.magnifier_mode) { // Recompute the magnifier offset (center its view) if (point_at_mouse) { // Target pixel must be located under the mouse position. - Main_magnifier_offset_X = target_x-((Mouse_X-Main_X_zoom)/Main_magnifier_factor); - Main_magnifier_offset_Y = target_y-((Mouse_Y)/Main_magnifier_factor); + Main.magnifier_offset_X = target_x-((Mouse_X-Main.X_zoom)/Main.magnifier_factor); + Main.magnifier_offset_Y = target_y-((Mouse_Y)/Main.magnifier_factor); } else { // Target pixel must be positioned at new center - Main_magnifier_offset_X = target_x-(Main_magnifier_width>>1); - Main_magnifier_offset_Y = target_y-(Main_magnifier_height>>1); + Main.magnifier_offset_X = target_x-(Main.magnifier_width>>1); + Main.magnifier_offset_Y = target_y-(Main.magnifier_height>>1); } // Fix cases where the image would overflow on edges - Clip_magnifier_offsets(&Main_magnifier_offset_X, &Main_magnifier_offset_Y); + Clip_magnifier_offsets(&Main.magnifier_offset_X, &Main.magnifier_offset_Y); if (magnified_view_leads) Position_screen_according_to_zoom(); @@ -1881,31 +1881,31 @@ void Copy_view_to_spare(void) { // Don't do anything if the pictures have different dimensions - if (Main_image_width!=Spare_image_width || Main_image_height!=Spare_image_height) + if (Main.image_width!=Spare.image_width || Main.image_height!=Spare.image_height) return; // Copie des décalages de la fenêtre principale (non zoomée) de l'image - Spare_offset_X=Main_offset_X; - Spare_offset_Y=Main_offset_Y; + Spare.offset_X=Main.offset_X; + Spare.offset_Y=Main.offset_Y; // Copie du booléen "Mode loupe" de l'image - Spare_magnifier_mode=Main_magnifier_mode; + Spare.magnifier_mode=Main.magnifier_mode; // Copie du facteur de zoom du brouillon - Spare_magnifier_factor=Main_magnifier_factor; + Spare.magnifier_factor=Main.magnifier_factor; // Copie des dimensions de la fenêtre de zoom - Spare_magnifier_width=Main_magnifier_width; - Spare_magnifier_height=Main_magnifier_height; + Spare.magnifier_width=Main.magnifier_width; + Spare.magnifier_height=Main.magnifier_height; // Copie des décalages de la fenêtre de zoom - Spare_magnifier_offset_X=Main_magnifier_offset_X; - Spare_magnifier_offset_Y=Main_magnifier_offset_Y; + Spare.magnifier_offset_X=Main.magnifier_offset_X; + Spare.magnifier_offset_Y=Main.magnifier_offset_Y; // Copie des données du split du zoom - Spare_separator_position=Main_separator_position; - Spare_X_zoom=Main_X_zoom; - Spare_separator_proportion=Main_separator_proportion; + Spare.separator_position=Main.separator_position; + Spare.X_zoom=Main.X_zoom; + Spare.separator_proportion=Main.separator_proportion; } // -- Afficher la barre de séparation entre les parties zoomées ou non en @@ -1914,40 +1914,40 @@ void Copy_view_to_spare(void) void Display_separator(void) { // Partie grise du milieu - Block(Main_separator_position+(Menu_factor_X<<1),Menu_factor_Y, + Block(Main.separator_position+(Menu_factor_X<<1),Menu_factor_Y, (SEPARATOR_WIDTH-4)*Menu_factor_X, Menu_Y-(Menu_factor_Y<<1),MC_Light); // Barre noire de gauche - Block(Main_separator_position,0,Menu_factor_X,Menu_Y,MC_Black); + Block(Main.separator_position,0,Menu_factor_X,Menu_Y,MC_Black); // Barre noire de droite - Block(Main_X_zoom-Menu_factor_X,0,Menu_factor_X,Menu_Y,MC_Black); + Block(Main.X_zoom-Menu_factor_X,0,Menu_factor_X,Menu_Y,MC_Black); // Bord haut (blanc) - Block(Main_separator_position+Menu_factor_X,0, + Block(Main.separator_position+Menu_factor_X,0, (SEPARATOR_WIDTH-3)*Menu_factor_X,Menu_factor_Y,MC_White); // Bord gauche (blanc) - Block(Main_separator_position+Menu_factor_X,Menu_factor_Y, + Block(Main.separator_position+Menu_factor_X,Menu_factor_Y, Menu_factor_X,(Menu_Y-(Menu_factor_Y<<1)),MC_White); // Bord droite (gris foncé) - Block(Main_X_zoom-(Menu_factor_X<<1),Menu_factor_Y, + Block(Main.X_zoom-(Menu_factor_X<<1),Menu_factor_Y, Menu_factor_X,(Menu_Y-(Menu_factor_Y<<1)),MC_Dark); // Bord bas (gris foncé) - Block(Main_separator_position+(Menu_factor_X<<1),Menu_Y-Menu_factor_Y, + Block(Main.separator_position+(Menu_factor_X<<1),Menu_Y-Menu_factor_Y, (SEPARATOR_WIDTH-3)*Menu_factor_X,Menu_factor_Y,MC_Dark); // Coin bas gauche - Block(Main_separator_position+Menu_factor_X,Menu_Y-Menu_factor_Y, + Block(Main.separator_position+Menu_factor_X,Menu_Y-Menu_factor_Y, Menu_factor_X,Menu_factor_Y,MC_Light); // Coin haut droite - Block(Main_X_zoom-(Menu_factor_X<<1),0, + Block(Main.X_zoom-(Menu_factor_X<<1),0, Menu_factor_X,Menu_factor_Y,MC_Light); - Update_rect(Main_separator_position,0,SEPARATOR_WIDTH*Menu_factor_X,Menu_Y); // On réaffiche toute la partie à gauche du split, ce qui permet d'effacer son ancienne position + Update_rect(Main.separator_position,0,SEPARATOR_WIDTH*Menu_factor_X,Menu_Y); // On réaffiche toute la partie à gauche du split, ce qui permet d'effacer son ancienne position } @@ -1959,10 +1959,10 @@ void Display_separator(void) void Horizontal_XOR_line_zoom(short x_pos, short y_pos, short width) { - short real_x_pos=Main_X_zoom+(x_pos-Main_magnifier_offset_X)*Main_magnifier_factor; - short real_y_pos=(y_pos-Main_magnifier_offset_Y)*Main_magnifier_factor; - short real_width=width*Main_magnifier_factor; - short end_y_pos=(real_y_pos+Main_magnifier_factor=Main_X_zoom) ) ) + && ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) || (Windows_open) || (Cursor_shape==CURSOR_SHAPE_HOURGLASS) ) shape=Cursor_shape; else @@ -2163,29 +2163,29 @@ void Display_cursor(void) break; case CURSOR_SHAPE_XOR_TARGET : - x_pos=Paintbrush_X-Main_offset_X; - y_pos=Paintbrush_Y-Main_offset_Y; + x_pos=Paintbrush_X-Main.offset_X; + y_pos=Paintbrush_Y-Main.offset_Y; - counter_x=(Main_magnifier_mode)?Main_separator_position:Screen_width; // width de la barre XOR + counter_x=(Main.magnifier_mode)?Main.separator_position:Screen_width; // width de la barre XOR if ((y_pos=Limit_top)) { - Horizontal_XOR_line(0,Paintbrush_Y-Main_offset_Y,counter_x); - Update_rect(0,Paintbrush_Y-Main_offset_Y,counter_x,1); + Horizontal_XOR_line(0,Paintbrush_Y-Main.offset_Y,counter_x); + Update_rect(0,Paintbrush_Y-Main.offset_Y,counter_x,1); } if ((x_pos=Limit_left)) { - Vertical_XOR_line(Paintbrush_X-Main_offset_X,0,Menu_Y); - Update_rect(Paintbrush_X-Main_offset_X,0,1,Menu_Y); + Vertical_XOR_line(Paintbrush_X-Main.offset_X,0,Menu_Y); + Update_rect(Paintbrush_X-Main.offset_X,0,1,Menu_Y); } - if (Main_magnifier_mode) + if (Main.magnifier_mode) { // UPDATERECT if ((Paintbrush_Y>=Limit_top_zoom) && (Paintbrush_Y<=Limit_visible_bottom_zoom)) - Horizontal_XOR_line_zoom(Limit_left_zoom,Paintbrush_Y,Main_magnifier_width); + Horizontal_XOR_line_zoom(Limit_left_zoom,Paintbrush_Y,Main.magnifier_width); if ((Paintbrush_X>=Limit_left_zoom) && (Paintbrush_X<=Limit_visible_right_zoom)) - Vertical_XOR_line_zoom(Paintbrush_X,Limit_top_zoom,Main_magnifier_height); + Vertical_XOR_line_zoom(Paintbrush_X,Limit_top_zoom,Main.magnifier_height); } break; case CURSOR_SHAPE_XOR_RECTANGLE : @@ -2209,23 +2209,23 @@ void Display_cursor(void) Vertical_XOR_line (Mouse_X,start_y,end_y-start_y); // Grand rectangle autour - start_x=Mouse_X-(Main_magnifier_width>>1); - start_y=Mouse_Y-(Main_magnifier_height>>1); - if (start_x+Main_magnifier_width>=Limit_right-Main_offset_X) - start_x=Limit_right-Main_magnifier_width-Main_offset_X+1; - if (start_y+Main_magnifier_height>=Limit_bottom-Main_offset_Y) - start_y=Limit_bottom-Main_magnifier_height-Main_offset_Y+1; + start_x=Mouse_X-(Main.magnifier_width>>1); + start_y=Mouse_Y-(Main.magnifier_height>>1); + if (start_x+Main.magnifier_width>=Limit_right-Main.offset_X) + start_x=Limit_right-Main.magnifier_width-Main.offset_X+1; + if (start_y+Main.magnifier_height>=Limit_bottom-Main.offset_Y) + start_y=Limit_bottom-Main.magnifier_height-Main.offset_Y+1; if (start_x<0) start_x=0; if (start_y<0) start_y=0; - end_x=start_x+Main_magnifier_width-1; - end_y=start_y+Main_magnifier_height-1; + end_x=start_x+Main.magnifier_width-1; + end_y=start_y+Main.magnifier_height-1; - Horizontal_XOR_line(start_x,start_y,Main_magnifier_width); - Vertical_XOR_line(start_x,start_y+1,Main_magnifier_height-2); - Vertical_XOR_line( end_x,start_y+1,Main_magnifier_height-2); - Horizontal_XOR_line(start_x, end_y,Main_magnifier_width); + Horizontal_XOR_line(start_x,start_y,Main.magnifier_width); + Vertical_XOR_line(start_x,start_y+1,Main.magnifier_height-2); + Vertical_XOR_line( end_x,start_y+1,Main.magnifier_height-2); + Horizontal_XOR_line(start_x, end_y,Main.magnifier_width); Update_rect(start_x,start_y,end_x+1-start_x,end_y+1-start_y); @@ -2311,8 +2311,8 @@ void Hide_cursor(void) short x1,y1,x2,y2,x3,y3,x4,y4; if ( ( (Mouse_Y=Main_X_zoom) ) ) + && ( (!Main.magnifier_mode) || (Mouse_X=Main.X_zoom) ) ) || (Windows_open) || (Cursor_shape==CURSOR_SHAPE_HOURGLASS) ) shape=Cursor_shape; else @@ -2459,29 +2459,29 @@ void Hide_cursor(void) break; case CURSOR_SHAPE_XOR_TARGET : - x_pos=Paintbrush_X-Main_offset_X; - y_pos=Paintbrush_Y-Main_offset_Y; + x_pos=Paintbrush_X-Main.offset_X; + y_pos=Paintbrush_Y-Main.offset_Y; - counter_x=(Main_magnifier_mode)?Main_separator_position:Screen_width; // width de la barre XOR + counter_x=(Main.magnifier_mode)?Main.separator_position:Screen_width; // width de la barre XOR if ((y_pos=Limit_top)) { - Horizontal_XOR_line(0,Paintbrush_Y-Main_offset_Y,counter_x); - Update_rect(0,Paintbrush_Y-Main_offset_Y,counter_x,1); + Horizontal_XOR_line(0,Paintbrush_Y-Main.offset_Y,counter_x); + Update_rect(0,Paintbrush_Y-Main.offset_Y,counter_x,1); } if ((x_pos=Limit_left)) { - Vertical_XOR_line(Paintbrush_X-Main_offset_X,0,Menu_Y); - Update_rect(Paintbrush_X-Main_offset_X,0,1,Menu_Y); + Vertical_XOR_line(Paintbrush_X-Main.offset_X,0,Menu_Y); + Update_rect(Paintbrush_X-Main.offset_X,0,1,Menu_Y); } - if (Main_magnifier_mode) + if (Main.magnifier_mode) { // UPDATERECT if ((Paintbrush_Y>=Limit_top_zoom) && (Paintbrush_Y<=Limit_visible_bottom_zoom)) - Horizontal_XOR_line_zoom(Limit_left_zoom,Paintbrush_Y,Main_magnifier_width); + Horizontal_XOR_line_zoom(Limit_left_zoom,Paintbrush_Y,Main.magnifier_width); if ((Paintbrush_X>=Limit_left_zoom) && (Paintbrush_X<=Limit_visible_right_zoom)) - Vertical_XOR_line_zoom(Paintbrush_X,Limit_top_zoom,Main_magnifier_height); + Vertical_XOR_line_zoom(Paintbrush_X,Limit_top_zoom,Main.magnifier_height); } @@ -2508,23 +2508,23 @@ void Hide_cursor(void) // Grand rectangle autour - start_x=Mouse_X-(Main_magnifier_width>>1); - start_y=Mouse_Y-(Main_magnifier_height>>1); - if (start_x+Main_magnifier_width>=Limit_right-Main_offset_X) - start_x=Limit_right-Main_magnifier_width-Main_offset_X+1; - if (start_y+Main_magnifier_height>=Limit_bottom-Main_offset_Y) - start_y=Limit_bottom-Main_magnifier_height-Main_offset_Y+1; + start_x=Mouse_X-(Main.magnifier_width>>1); + start_y=Mouse_Y-(Main.magnifier_height>>1); + if (start_x+Main.magnifier_width>=Limit_right-Main.offset_X) + start_x=Limit_right-Main.magnifier_width-Main.offset_X+1; + if (start_y+Main.magnifier_height>=Limit_bottom-Main.offset_Y) + start_y=Limit_bottom-Main.magnifier_height-Main.offset_Y+1; if (start_x<0) start_x=0; if (start_y<0) start_y=0; - end_x=start_x+Main_magnifier_width-1; - end_y=start_y+Main_magnifier_height-1; + end_x=start_x+Main.magnifier_width-1; + end_y=start_y+Main.magnifier_height-1; - Horizontal_XOR_line(start_x,start_y,Main_magnifier_width); - Vertical_XOR_line(start_x,start_y+1,Main_magnifier_height-2); - Vertical_XOR_line( end_x,start_y+1,Main_magnifier_height-2); - Horizontal_XOR_line(start_x, end_y,Main_magnifier_width); + Horizontal_XOR_line(start_x,start_y,Main.magnifier_width); + Vertical_XOR_line(start_x,start_y+1,Main.magnifier_height-2); + Vertical_XOR_line( end_x,start_y+1,Main.magnifier_height-2); + Horizontal_XOR_line(start_x, end_y,Main.magnifier_width); Update_rect(start_x,start_y,end_x+1-start_x,end_y+1-start_y); @@ -2604,70 +2604,70 @@ void Display_all_screen(void) word height; // ---/\/\/\ Partie non zoomée: /\/\/\--- - if (Main_magnifier_mode) + if (Main.magnifier_mode) { - if (Main_image_widthPages->Transparent_color); + if (Main.image_widthPages->Transparent_color); } else { - if (Main_image_widthPages->Transparent_color); + if (Main.image_widthPages->Transparent_color); } - if (Main_image_heightPages->Transparent_color); + if (Main.image_heightPages->Transparent_color); // ---/\/\/\ Partie zoomée: /\/\/\--- - if (Main_magnifier_mode) + if (Main.magnifier_mode) { // Affichage de la barre de split Display_separator(); // Calcul de la largeur visible - if (Main_image_widthPages->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 /\/\/\--- @@ -2691,11 +2691,11 @@ byte Best_color(byte r,byte g,byte b) { if (!Exclude_color[col]) { - delta_r=(int)Main_palette[col].R-r; - delta_g=(int)Main_palette[col].G-g; - delta_b=(int)Main_palette[col].B-b; + delta_r=(int)Main.palette[col].R-r; + delta_g=(int)Main.palette[col].G-g; + delta_b=(int)Main.palette[col].B-b; - rmean = ( Main_palette[col].R + r ) / 2; + rmean = ( Main.palette[col].R + r ) / 2; if (!(dist= ( ( (512+rmean) *delta_r*delta_r) >>8) + 4*delta_g*delta_g + (((767-rmean)*delta_b*delta_b)>>8))) //if (!(dist=(delta_r*delta_r*30)+(delta_g*delta_g*59)+(delta_b*delta_b*11))) @@ -2723,13 +2723,13 @@ byte Best_color_nonexcluded(byte red,byte green,byte blue) for (col=0; col<256; col++) { - delta_r=(int)Main_palette[col].R-red; - delta_g=(int)Main_palette[col].G-green; - delta_b=(int)Main_palette[col].B-blue; + delta_r=(int)Main.palette[col].R-red; + delta_g=(int)Main.palette[col].G-green; + delta_b=(int)Main.palette[col].B-blue; if(delta_r == 0 && delta_g == 0 && delta_b == 0) return col; - rmean = ( Main_palette[col].R + red ) / 2; + rmean = ( Main.palette[col].R + red ) / 2; dist= ( ( (512+rmean) *delta_r*delta_r) >>8) + 4*delta_g*delta_g + (((767-rmean)*delta_b*delta_b)>>8); //dist=(delta_r*delta_r*30)+(delta_g*delta_g*59)+(delta_b*delta_b*11) @@ -2762,17 +2762,17 @@ byte Best_color_range(byte r, byte g, byte b, byte max) continue; diff_c = sqrt( - (0.26*(Main_palette[col].R-r))* - (0.26*(Main_palette[col].R-r))+ - (0.55*(Main_palette[col].G-g))* - (0.55*(Main_palette[col].G-g))+ - (0.19*(Main_palette[col].B-b))* - (0.19*(Main_palette[col].B-b))); + (0.26*(Main.palette[col].R-r))* + (0.26*(Main.palette[col].R-r))+ + (0.55*(Main.palette[col].G-g))* + (0.55*(Main.palette[col].G-g))+ + (0.19*(Main.palette[col].B-b))* + (0.19*(Main.palette[col].B-b))); // Exact match if (diff_c==0) return col; - bri = sqrt(0.26*Main_palette[col].R*0.26*Main_palette[col].R + 0.55*Main_palette[col].G*0.55*Main_palette[col].G + 0.19*Main_palette[col].B*0.19*Main_palette[col].B); + bri = sqrt(0.26*Main.palette[col].R*0.26*Main.palette[col].R + 0.55*Main.palette[col].G*0.55*Main.palette[col].G + 0.19*Main.palette[col].B*0.19*Main.palette[col].B); diff_b = abs(target_bri-bri); diff=0.25*(diff_b-diff_c)+diff_c; @@ -2805,17 +2805,17 @@ byte Best_color_perceptual(byte r,byte g,byte b) continue; diff_c = sqrt( - (0.26*(Main_palette[col].R-r))* - (0.26*(Main_palette[col].R-r))+ - (0.55*(Main_palette[col].G-g))* - (0.55*(Main_palette[col].G-g))+ - (0.19*(Main_palette[col].B-b))* - (0.19*(Main_palette[col].B-b))); + (0.26*(Main.palette[col].R-r))* + (0.26*(Main.palette[col].R-r))+ + (0.55*(Main.palette[col].G-g))* + (0.55*(Main.palette[col].G-g))+ + (0.19*(Main.palette[col].B-b))* + (0.19*(Main.palette[col].B-b))); // Exact match if (diff_c==0) return col; - bri = sqrt(0.26*Main_palette[col].R*0.26*Main_palette[col].R + 0.55*Main_palette[col].G*0.55*Main_palette[col].G + 0.19*Main_palette[col].B*0.19*Main_palette[col].B); + bri = sqrt(0.26*Main.palette[col].R*0.26*Main.palette[col].R + 0.55*Main.palette[col].G*0.55*Main.palette[col].G + 0.19*Main.palette[col].B*0.19*Main.palette[col].B); diff_b = abs(target_bri-bri); diff=0.25*(diff_b-diff_c)+diff_c; @@ -2848,17 +2848,17 @@ byte Best_color_perceptual_except(byte r,byte g,byte b, byte except) continue; diff_c = sqrt( - (0.26*(Main_palette[col].R-r))* - (0.26*(Main_palette[col].R-r))+ - (0.55*(Main_palette[col].G-g))* - (0.55*(Main_palette[col].G-g))+ - (0.19*(Main_palette[col].B-b))* - (0.19*(Main_palette[col].B-b))); + (0.26*(Main.palette[col].R-r))* + (0.26*(Main.palette[col].R-r))+ + (0.55*(Main.palette[col].G-g))* + (0.55*(Main.palette[col].G-g))+ + (0.19*(Main.palette[col].B-b))* + (0.19*(Main.palette[col].B-b))); // Exact match if (diff_c==0) return col; - bri = sqrt(0.26*Main_palette[col].R*0.26*Main_palette[col].R + 0.55*Main_palette[col].G*0.55*Main_palette[col].G + 0.19*Main_palette[col].B*0.19*Main_palette[col].B); + bri = sqrt(0.26*Main.palette[col].R*0.26*Main.palette[col].R + 0.55*Main.palette[col].G*0.55*Main.palette[col].G + 0.19*Main.palette[col].B*0.19*Main.palette[col].B); diff_b = abs(target_bri-bri); diff=0.25*(diff_b-diff_c)+diff_c; @@ -2955,9 +2955,9 @@ void Remap_screen_after_menu_colors_change(void) static int Diff(int i, int j) { - int dr = Main_palette[i].R - Main_palette[j].R; - int dg = Main_palette[i].G - Main_palette[j].G; - int db = Main_palette[i].B - Main_palette[j].B; + int dr = Main.palette[i].R - Main.palette[j].R; + int dg = Main.palette[i].G - Main.palette[j].G; + int db = Main.palette[i].B - Main.palette[j].B; return dr*dr + dg*dg + db*db; }