diff --git a/buttons.h b/buttons.h index 68502d10..7ccd4728 100644 --- a/buttons.h +++ b/buttons.h @@ -33,21 +33,21 @@ void Stencil_update_color(byte color); void Stencil_tag_color(byte color, byte tag_color); /*! - Displays an error message when there is no more memory for the requested - operation. + Displays an error message when there is no more memory for the requested + operation. */ void Message_out_of_memory(void); /*! - Displays the splash screen at program startup. + Displays the splash screen at program startup. */ void Button_Message_initial(void); /*! - Changes brush shape. - This function saves the current brush shape and swith to the default one - (single pixel brush) for the filler and the color picker. - These functions don't need (and will not work with) a custom brush. + Changes brush shape. + This function saves the current brush shape and swith to the default one + (single pixel brush) for the filler and the color picker. + These functions don't need (and will not work with) a custom brush. */ void Change_paintbrush_shape(byte shape); @@ -587,7 +587,7 @@ void Button_Autosave(void); void Button_Settings(void); /*! - Display the skin selector window. + Display the skin selector window. */ void Button_Skins(void); diff --git a/buttons_effects.c b/buttons_effects.c index a6a51284..f3acedb5 100644 --- a/buttons_effects.c +++ b/buttons_effects.c @@ -258,9 +258,9 @@ void Button_Grid_menu(void) Window_set_normal_button(12, 62, 14, 14, " ", 0, 1, 0); // 7 Window_set_normal_button(70, 62, 14, 14, " ", 0, 1, 0); // 8 if (snapgrid) - Print_in_window(16, 65, "X", MC_Black, MC_Light); + Print_in_window(16, 65, "X", MC_Black, MC_Light); if (Show_grid) - Print_in_window(74, 65, "X", MC_Black, MC_Light); + Print_in_window(74, 65, "X", MC_Black, MC_Light); Print_in_window(32, 65,"Snap",MC_Dark,MC_Light); Print_in_window(90, 65,"Show",MC_Dark,MC_Light); @@ -349,18 +349,18 @@ void Button_Grid_menu(void) Display_cursor(); - case 7: - snapgrid = !snapgrid; - Hide_cursor(); - Print_in_window(16, 65, snapgrid?"X":" ", MC_Black, MC_Light); - Display_cursor(); - break; - case 8: - showgrid = !showgrid; - Hide_cursor(); - Print_in_window(74, 65, showgrid?"X":" ", MC_Black, MC_Light); - Display_cursor(); - break; + case 7: + snapgrid = !snapgrid; + Hide_cursor(); + Print_in_window(16, 65, snapgrid?"X":" ", MC_Black, MC_Light); + Display_cursor(); + break; + case 8: + showgrid = !showgrid; + Hide_cursor(); + Print_in_window(74, 65, showgrid?"X":" ", MC_Black, MC_Light); + Display_cursor(); + break; } if (Is_shortcut(Key,0x100+BUTTON_HELP)) @@ -375,7 +375,7 @@ void Button_Grid_menu(void) Snap_offset_X=dx_selected; Snap_offset_Y=dy_selected; Snap_mode=snapgrid; - Show_grid=showgrid; + Show_grid=showgrid; } Close_window(); diff --git a/const.h b/const.h index f01c2720..d79a8606 100644 --- a/const.h +++ b/const.h @@ -149,14 +149,14 @@ enum ERROR_CODES enum PIXEL_RATIO { PIXEL_SIMPLE=0, ///< Use real pixels - PIXEL_WIDE, ///< Use wide pixels (2x1) like on Amstrad CPC mode 0 - PIXEL_TALL, ///< Use tall pixels (1x2) like on Amstrad CPC mode 2 - PIXEL_DOUBLE, ///< Use big pixels (2x2) if your LCD screen can't do lowres by itself - PIXEL_TRIPLE, ///< Use really big pixels (3x3) - PIXEL_WIDE2, ///< Use big wide pixels (4x2) - PIXEL_TALL2, ///< Use big tall pixels (2x4) - PIXEL_QUAD, ///< Use really giant pixels (4x4). You need to have a screen resolution at least 1280x800 to use this one - PIXEL_MAX ///< Number of elements in enum + PIXEL_WIDE, ///< Use wide pixels (2x1) like on Amstrad CPC mode 0 + PIXEL_TALL, ///< Use tall pixels (1x2) like on Amstrad CPC mode 2 + PIXEL_DOUBLE, ///< Use big pixels (2x2) if your LCD screen can't do lowres by itself + PIXEL_TRIPLE, ///< Use really big pixels (3x3) + PIXEL_WIDE2, ///< Use big wide pixels (4x2) + PIXEL_TALL2, ///< Use big tall pixels (2x4) + PIXEL_QUAD, ///< Use really giant pixels (4x4). You need to have a screen resolution at least 1280x800 to use this one + PIXEL_MAX ///< Number of elements in enum }; /// Different kinds of menu button behavior. diff --git a/engine.h b/engine.h index 820a7dd0..391879f0 100644 --- a/engine.h +++ b/engine.h @@ -40,7 +40,7 @@ void Open_popup (word x_pos, word y_pos, word width, word height); void Close_popup (void); void Window_draw_normal_bouton(word x_pos,word y_pos,word width,word height, - char * title,byte undersc_letter,byte clickable); + char * title,byte undersc_letter,byte clickable); void Window_select_normal_button(word x_pos,word y_pos,word width,word height); void Window_unselect_normal_button(word x_pos,word y_pos,word width,word height); void Window_draw_palette_bouton(word x_pos,word y_pos); @@ -54,35 +54,35 @@ void Window_clear_input_button(T_Special_button * button); void Window_draw_input_bouton(word x_pos, word y_pos, word width_in_characters); T_Normal_button * Window_set_normal_button(word x_pos, word y_pos, - word width, word height, char * title, byte undersc_letter, - byte clickable, word shortcut); + word width, word height, char * title, byte undersc_letter, + byte clickable, word shortcut); T_Normal_button * Window_set_repeatable_button(word x_pos, word y_pos, - word width, word height, char * title, byte undersc_letter, - byte clickable, word shortcut); + word width, word height, char * title, byte undersc_letter, + byte clickable, word shortcut); T_Palette_button * Window_set_palette_button(word x_pos, word y_pos); void Window_clear_tags(void); void Tag_color_range(byte start, byte end); T_Scroller_button * Window_set_scroller_button(word x_pos, word y_pos, - word height, word nb_elements, word nb_elements_visible, - word initial_position); + word height, word nb_elements, word nb_elements_visible, + word initial_position); T_Special_button * Window_set_special_button(word x_pos, word y_pos, word width, - word height); + word height); T_Special_button * Window_set_input_button(word x_pos, word y_pos, - word width_in_characters); + word width_in_characters); T_Dropdown_button * Window_set_dropdown_button(word x_pos, word y_pos, - word width, word height, word dropdown_width, const char *label, - byte display_choice, byte display_centered, byte display_arrow, - byte active_button,byte bottom_up); + word width, word height, word dropdown_width, const char *label, + byte display_choice, byte display_centered, byte display_arrow, + byte active_button,byte bottom_up); /// Adds an item to a dropdown menu void Window_dropdown_add_item(T_Dropdown_button * dropdown, word btn_number, - const char *label); + const char *label); void Window_dropdown_clear_items(T_Dropdown_button * dropdown); @@ -94,10 +94,10 @@ void Window_dropdown_clear_items(T_Dropdown_button * dropdown); T_Dropdown_choice * Dropdown_activate(T_Dropdown_button *button, short off_x, short off_y); T_List_button * Window_set_list_button(T_Special_button * entry_button, - T_Scroller_button * scroller, Func_draw_list_item draw_list_item); + T_Scroller_button * scroller, Func_draw_list_item draw_list_item); void Window_redraw_list(T_List_button * list); byte Window_click_in_rectangle(short start_x, short start_y, short end_x, - short end_y); + short end_y); short Wait_click_in_palette(T_Palette_button * button); void Get_color_behind_window(byte * color, byte * click); diff --git a/filesel.c b/filesel.c index a3618636..b6b9939d 100644 --- a/filesel.c +++ b/filesel.c @@ -1404,8 +1404,8 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context) else Selected_type = 0; } - // Now load immediately, but only if the user exited readline by pressing ENTER - if (Mouse_K == 0) has_clicked_ok = 1; + // Now load immediately, but only if the user exited readline by pressing ENTER + if (Mouse_K == 0) has_clicked_ok = 1; } else { @@ -1647,7 +1647,7 @@ byte Button_Load_or_Save(byte load, T_IO_Context *context) Display_cursor(); New_preview_is_needed=1; - // On est dans un nouveau répertoire, donc on remet le quicksearch à 0 + // On est dans un nouveau répertoire, donc on remet le quicksearch à 0 *quicksearch_filename=0; } else // Sinon on essaye de charger ou sauver le fichier diff --git a/init.c b/init.c index 180f538c..26822c64 100644 --- a/init.c +++ b/init.c @@ -353,9 +353,9 @@ byte Parse_skin(SDL_Surface * gui, T_Gui_skin *gfx) // Preview cursor_x += Menu_bars[MENUBAR_TOOLS].Skin_width; if (GUI_seek_right(gui, &cursor_x, cursor_y, neutral_color, "preview")) - return 1; + return 1; if (Read_GUI_block(gfx, gui, cursor_x, cursor_y, gfx->Preview, 173, 16, "logo", 0)) - return 1; + return 1; cursor_y+= Menu_bars[MENUBAR_TOOLS].Height; // Layerbar @@ -1936,10 +1936,10 @@ void Set_all_video_modes(void) { int index2; #if defined(__GP2X__) - // On the GP2X the first mode is not windowed, so include it in the search. - index2=0; + // On the GP2X the first mode is not windowed, so include it in the search. + index2=0; #else - index2=1; + index2=1; #endif for (/**/; index2 < Nb_video_modes; index2++) if (Modes[index]->w == Video_mode[index2].Width && @@ -2084,9 +2084,9 @@ int Load_CFG(int reload_all) goto Erreur_lecture_config; #if defined(__GP2X__) - index2=0; + index2=0; #else - index2=1; + index2=1; #endif for (/**/; index2Pages->Image[Main_current_layer]; - int i; + int nb_pixels=0; //ECX + //al=color + //edi=Screen_pixels + byte* pixel=Main_backups->Pages->Image[Main_current_layer]; + 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], - color , - Main_image_width * Main_image_height - ); + memset( + Main_backups->Pages->Image[Main_current_layer], + color , + Main_image_width * Main_image_height + ); } void Init_chrono(dword delay) - // Démarrer le chrono + // Démarrer le chrono { - Timer_delay = delay; - Timer_start = SDL_GetTicks()/55; - return; + Timer_delay = delay; + Timer_start = SDL_GetTicks()/55; + return; } void Pixel_in_brush (word x, word y, byte color) { - *(Brush + y * Brush_width + x)=color; + *(Brush + y * Brush_width + x)=color; } byte Read_pixel_from_brush (word x, word y) { - return *(Brush + y * Brush_width + x); + return *(Brush + y * Brush_width + x); } void Replace_a_color(byte old_color, byte new_color) @@ -226,62 +226,62 @@ void Replace_a_color(byte old_color, byte new_color) word y; // Update all pixels - for (y=0; y0;dx--) - { - // Pour chaque pixel - for(cx=width;cx>0;cx--) - { - *buffer = conversion_table[*buffer]; - buffer++; - } - buffer += buffer_width-width; - } + // Pour chaque ligne + for(dx=height;dx>0;dx--) + { + // Pour chaque pixel + for(cx=width;cx>0;cx--) + { + *buffer = conversion_table[*buffer]; + buffer++; + } + buffer += buffer_width-width; + } } 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]; //Adr départ image (ESI) - byte* dest=Brush; //Adr dest brosse (EDI) - int dx; + byte* src=start_y*image_width+start_x+Main_backups->Pages->Image[Main_current_layer]; //Adr départ image (ESI) + byte* dest=Brush; //Adr dest brosse (EDI) + int dx; - for (dx=Brush_height;dx!=0;dx--) - //Pour chaque ligne - { + for (dx=Brush_height;dx!=0;dx--) + //Pour chaque ligne + { - // On fait une copie de la ligne - memcpy(dest,src,Brush_width); + // On fait une copie de la ligne + memcpy(dest,src,Brush_width); - // On passe à la ligne suivante - src+=image_width; - dest+=Brush_width; - } + // On passe à la ligne suivante + src+=image_width; + dest+=Brush_width; + } } 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) { - return numerator/divisor; + return numerator/divisor; } byte Effect_sieve(word x,word y) { - return Sieve[x % Sieve_width][y % Sieve_height]; + return Sieve[x % Sieve_width][y % Sieve_height]; } void Replace_colors_within_limits(byte * replace_table) { - int y; - int x; - byte* pixel; + int y; + int x; + byte* pixel; - // Pour chaque ligne : - for(y = Limit_top;y <= Limit_bottom; y++) - { - // Pour chaque pixel sur la ligne : - for (x = Limit_left;x <= Limit_right;x ++) - { - pixel = Main_backups->Pages->Image[Main_current_layer]+y*Main_image_width+x; - *pixel = replace_table[*pixel]; - } - } + // Pour chaque ligne : + for(y = Limit_top;y <= Limit_bottom; y++) + { + // Pour chaque pixel sur la ligne : + for (x = Limit_left;x <= Limit_right;x ++) + { + pixel = Main_backups->Pages->Image[Main_current_layer]+y*Main_image_width+x; + *pixel = replace_table[*pixel]; + } + } } 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) { - int i; - for(i=0;i<256;i++) - { - palette[i].R = palette[i].R >> 2; - palette[i].G = palette[i].G >> 2; - palette[i].B = palette[i].B >> 2; - } + int i; + for(i=0;i<256;i++) + { + palette[i].R = palette[i].R >> 2; + palette[i].G = palette[i].G >> 2; + palette[i].B = palette[i].B >> 2; + } } void Palette_64_to_256(T_Palette palette) { - int i; - for(i=0;i<256;i++) - { - palette[i].R = (palette[i].R << 2)|(palette[i].R >> 4); - palette[i].G = (palette[i].G << 2)|(palette[i].G >> 4); - palette[i].B = (palette[i].B << 2)|(palette[i].B >> 4); - } + int i; + for(i=0;i<256;i++) + { + palette[i].R = (palette[i].R << 2)|(palette[i].R >> 4); + palette[i].G = (palette[i].G << 2)|(palette[i].G >> 4); + palette[i].B = (palette[i].B << 2)|(palette[i].B >> 4); + } } byte Effect_interpolated_colorize (word x,word y,byte color) { - // factor_a = 256*(100-Colorize_opacity)/100 - // factor_b = 256*( Colorize_opacity)/100 - // - // (Couleur_dessous*factor_a+color*facteur_B)/256 - // + // factor_a = 256*(100-Colorize_opacity)/100 + // factor_b = 256*( Colorize_opacity)/100 + // + // (Couleur_dessous*factor_a+color*facteur_B)/256 + // - // 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; + // 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; - // On récupère les 3 composantes RVB + // On récupère les 3 composantes RVB - // blue - blue = (Factors_inv_table[blue] - + Factors_table[blue_under]) / 256; - green = (Factors_inv_table[green] - + Factors_table[green_under]) / 256; - red = (Factors_inv_table[red] - + Factors_table[red_under]) / 256; - return Best_color(red,green,blue); + // blue + blue = (Factors_inv_table[blue] + + Factors_table[blue_under]) / 256; + green = (Factors_inv_table[green] + + Factors_table[green_under]) / 256; + red = (Factors_inv_table[red] + + Factors_table[red_under]) / 256; + return Best_color(red,green,blue); } 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 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; - return Best_color( - red>red_under?red:red_under, - green>green_under?green:green_under, - blue>blue_under?blue:blue_under); + return Best_color( + red>red_under?red:red_under, + green>green_under?green:green_under, + blue>blue_under?blue:blue_under); } 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 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; - return Best_color( - redTimer_start) Timer_state=1; + if((SDL_GetTicks()/55)-Timer_delay>Timer_start) Timer_state=1; } void Flip_Y_lowlevel(byte *src, short width, short height) { - // ESI pointe sur la partie haute de la brosse - // EDI sur la partie basse - byte* ESI = src ; - byte* EDI = src + (height - 1) *width; - byte tmp; - word cx; + // ESI pointe sur la partie haute de la brosse + // EDI sur la partie basse + byte* ESI = src ; + byte* EDI = src + (height - 1) *width; + byte tmp; + word cx; - while(ESI < EDI) - { - // Il faut inverser les lignes pointées par ESI et - // EDI ("Brush_width" octets en tout) + while(ESI < EDI) + { + // Il faut inverser les lignes pointées par ESI et + // EDI ("Brush_width" octets en tout) - for(cx = width;cx>0;cx--) - { - tmp = *ESI; - *ESI = *EDI; - *EDI = tmp; - ESI++; - EDI++; - } + for(cx = width;cx>0;cx--) + { + tmp = *ESI; + *ESI = *EDI; + *EDI = tmp; + ESI++; + EDI++; + } - // On change de ligne : - // ESI pointe déjà sur le début de la ligne suivante - // EDI pointe sur la fin de la ligne en cours, il - // doit pointer sur le début de la précédente... - EDI -= 2 * width; // On recule de 2 lignes - } + // On change de ligne : + // ESI pointe déjà sur le début de la ligne suivante + // EDI pointe sur la fin de la ligne en cours, il + // doit pointer sur le début de la précédente... + EDI -= 2 * width; // On recule de 2 lignes + } } void Flip_X_lowlevel(byte *src, short width, short height) { - // ESI pointe sur la partie gauche et EDI sur la partie - // droite - byte* ESI = src; - byte* EDI = src + width - 1; + // ESI pointe sur la partie gauche et EDI sur la partie + // droite + byte* ESI = src; + byte* EDI = src + width - 1; - byte* line_start; - byte* line_end; - byte tmp; - word cx; + byte* line_start; + byte* line_end; + byte tmp; + word cx; - while(ESI0;cx--) - { - tmp=*ESI; - *ESI=*EDI; - *EDI=tmp; - EDI+=width; - ESI+=width; - } + // On échange par colonnes + for(cx=height;cx>0;cx--) + { + tmp=*ESI; + *ESI=*EDI; + *EDI=tmp; + EDI+=width; + ESI+=width; + } - // On change de colonne - // ESI > colonne suivante - // EDI > colonne précédente - ESI = line_start + 1; - EDI = line_end - 1; - } + // On change de colonne + // ESI > colonne suivante + // EDI > colonne précédente + ESI = line_start + 1; + EDI = line_end - 1; + } } // Rotate a pixel buffer 180º on itself. void Rotate_180_deg_lowlevel(byte *src, short width, short height) { - // ESI pointe sur la partie supérieure de la brosse - // EDI pointe sur la partie basse - byte* ESI = src; - byte* EDI = src + height*width - 1; - // EDI pointe sur le dernier pixel de la derniere ligne - byte tmp; - word cx; + // ESI pointe sur la partie supérieure de la brosse + // EDI pointe sur la partie basse + byte* ESI = src; + byte* EDI = src + height*width - 1; + // EDI pointe sur le dernier pixel de la derniere ligne + byte tmp; + word cx; - // In case of odd height, the algorithm in this function would - // miss the middle line, so we do it this way: - if (height & 1) - { - Flip_X_lowlevel(src, width, height); - Flip_Y_lowlevel(src, width, height); - return; - } + // In case of odd height, the algorithm in this function would + // miss the middle line, so we do it this way: + if (height & 1) + { + Flip_X_lowlevel(src, width, height); + Flip_Y_lowlevel(src, width, height); + return; + } - while(ESI < EDI) - { - // On échange les deux lignes pointées par EDI et - // ESI (Brush_width octets) - // En même temps, on échange les pixels, donc EDI - // pointe sur la FIN de sa ligne + while(ESI < EDI) + { + // On échange les deux lignes pointées par EDI et + // ESI (Brush_width octets) + // En même temps, on échange les pixels, donc EDI + // pointe sur la FIN de sa ligne - for(cx=width;cx>0;cx--) - { - tmp = *ESI; - *ESI = *EDI; - *EDI = tmp; + for(cx=width;cx>0;cx--) + { + tmp = *ESI; + *ESI = *EDI; + *EDI = tmp; - EDI--; // Attention ici on recule ! - ESI++; - } - } + EDI--; // Attention ici on recule ! + ESI++; + } + } } void Rescale(byte *src_buffer, short src_width, short src_height, byte *dst_buffer, short dst_width, short dst_height, short x_flipped, short y_flipped) { - int offset,line,column; + int offset,line,column; - int x_pos_in_brush; // Position courante dans l'ancienne brosse - int y_pos_in_brush; - int delta_x_in_brush; // "Vecteur incrémental" du point précédent - int delta_y_in_brush; - int initial_x_pos; // Position X de début de parcours de ligne + int x_pos_in_brush; // Position courante dans l'ancienne brosse + int y_pos_in_brush; + int delta_x_in_brush; // "Vecteur incrémental" du point précédent + int delta_y_in_brush; + int initial_x_pos; // Position X de début de parcours de ligne - // Calcul du "vecteur incrémental": - delta_x_in_brush=(src_width<<16) * (x_flipped?-1:1) / (dst_width); - delta_y_in_brush=(src_height<<16) * (y_flipped?-1:1) / (dst_height); + // Calcul du "vecteur incrémental": + delta_x_in_brush=(src_width<<16) * (x_flipped?-1:1) / (dst_width); + delta_y_in_brush=(src_height<<16) * (y_flipped?-1:1) / (dst_height); - offset=0; + offset=0; - // Calcul de la valeur initiale de y_pos: - if (y_flipped) - y_pos_in_brush=(src_height<<16)-1; // Inversion en Y de la brosse - else - y_pos_in_brush=0; // Pas d'inversion en Y de la brosse + // Calcul de la valeur initiale de y_pos: + if (y_flipped) + y_pos_in_brush=(src_height<<16)-1; // Inversion en Y de la brosse + else + y_pos_in_brush=0; // Pas d'inversion en Y de la brosse - // Calcul de la valeur initiale de x_pos pour chaque ligne: - if (x_flipped) - initial_x_pos = (src_width<<16)-1; // Inversion en X de la brosse - else - initial_x_pos = 0; // Pas d'inversion en X de la brosse + // Calcul de la valeur initiale de x_pos pour chaque ligne: + if (x_flipped) + initial_x_pos = (src_width<<16)-1; // Inversion en X de la brosse + else + initial_x_pos = 0; // Pas d'inversion en X de la brosse - // Pour chaque ligne - for (line=0;line>16) + (y_pos_in_brush>>16)*src_width); - // On passe à la colonne de brosse suivante: - x_pos_in_brush+=delta_x_in_brush; - // On passe au pixel suivant de la nouvelle brosse: - offset++; - } - // On passe à la ligne de brosse suivante: - y_pos_in_brush+=delta_y_in_brush; - } + // Pour chaque colonne: + for (column=0;column>16) + (y_pos_in_brush>>16)*src_width); + // On passe à la colonne de brosse suivante: + x_pos_in_brush+=delta_x_in_brush; + // On passe au pixel suivant de la nouvelle brosse: + offset++; + } + // On passe à la ligne de brosse suivante: + y_pos_in_brush+=delta_y_in_brush; + } } void Slider_timer(byte speed) - //Boucle d'attente pour faire bouger les scrollbars à une vitesse correcte + //Boucle d'attente pour faire bouger les scrollbars à une vitesse correcte { - Uint32 end; - byte original_mouse_k = Mouse_K; - end = SDL_GetTicks() + speed*10; - do - { - if (!Get_input()) SDL_Delay(20); - } while (Mouse_K == original_mouse_k && SDL_GetTicks()0;y--) - { - // Pour chaque ligne - memcpy(dest,src,length); - memcpy(dest - x_offset,src+length,x_offset); + byte* src = main_src; //source de la copie + byte* dest = main_dest + y_offset * Main_image_width + x_offset; + const word length = Main_image_width - x_offset; // Nombre de pixels à copier à droite + word 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; - } + // On passe à la ligne suivante + dest += Main_image_width; + src += Main_image_width; + } - // On vient de faire le traitement pour otutes les lignes au-dessous de y_offset - // Maintenant on traite celles au dessus - dest = x_offset + main_dest; - for(y = y_offset;y>0;y--) - { - memcpy(dest,src,length); - memcpy(dest - x_offset,src+length,x_offset); + // On vient de faire le traitement pour otutes les lignes au-dessous de y_offset + // Maintenant on traite celles au dessus + dest = x_offset + main_dest; + for(y = y_offset;y>0;y--) + { + 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); + Update_rect(0,0,0,0); } void Zoom_a_line(byte* original_line, byte* zoomed_line, - word factor, word width - ) + word factor, word width + ) { - byte color; - word x; + byte color; + word x; - // Pour chaque pixel - for(x=0;x on BeOS or Haiku - // AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate) + // No on BeOS or Haiku + // AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate) #warning "There is missing code there for your platform ! please check and correct :)" - return 10*1024*1024; + return 10*1024*1024; #elif defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) - return AvailMem(MEMF_ANY); + return AvailMem(MEMF_ANY); #else - struct sysinfo info; - sysinfo(&info); - return info.freeram*info.mem_unit; + struct sysinfo info; + sysinfo(&info); + return info.freeram*info.mem_unit; #endif } @@ -777,50 +777,50 @@ unsigned long Memory_free(void) // TODO : this should probably be replaced with round() from C99... short Round(float value) { - short temp=value; + short temp=value; - if (value>=0) - { if ((value-temp)>= 0.5) temp++; } - else - { if ((value-temp)<=-0.5) temp--; } + if (value>=0) + { if ((value-temp)>= 0.5) temp++; } + else + { if ((value-temp)<=-0.5) temp--; } - return temp; + return temp; } // Arrondir le résultat d'une division à la valeur entière supérieure short Round_div_max(short numerator,short divisor) { - if (!(numerator % divisor)) - return (numerator/divisor); - else - return (numerator/divisor)+1; + if (!(numerator % divisor)) + return (numerator/divisor); + else + return (numerator/divisor)+1; } // Retourne le minimum entre deux nombres int Min(int a,int b) { - return (ab)?a:b; + return (a>b)?a:b; } // Fonction retournant le libellé d'une mode (ex: " 320x200") char * Mode_label(int mode) { - static char str[24]; - if (! Video_mode[mode].Fullscreen) - return "window"; - sprintf(str, "%dx%d", Video_mode[mode].Width, Video_mode[mode].Height); + static char str[24]; + if (! Video_mode[mode].Fullscreen) + return "window"; + sprintf(str, "%dx%d", Video_mode[mode].Width, Video_mode[mode].Height); - return str; + return str; } @@ -829,13 +829,13 @@ char * Mode_label(int mode) // Renvoie -1 si la chaine n'est pas convertible int Convert_videomode_arg(const char *argument) { - // Je suis paresseux alors je vais juste tester les libellés - int mode_index; - for (mode_index=0; mode_indexFile_name, context->File_directory); + Get_full_filename(filename, context->File_name, context->File_directory); - switch(Pixel_ratio) - { - case PIXEL_WIDE: - case PIXEL_WIDE2: - cpc_mode = 0; - break; - case PIXEL_TALL: - case PIXEL_TALL2: - cpc_mode = 2; - break; - default: - cpc_mode = 1; - break; - } + switch(Pixel_ratio) + { + case PIXEL_WIDE: + case PIXEL_WIDE2: + cpc_mode = 0; + break; + case PIXEL_TALL: + case PIXEL_TALL2: + cpc_mode = 2; + break; + default: + cpc_mode = 1; + break; + } - output = raw2crtc(context->Width,context->Height,cpc_mode,7,&outsize,&r1,0,0); + output = raw2crtc(context->Width,context->Height,cpc_mode,7,&outsize,&r1,0,0); - file = fopen(filename,"wb"); - Write_bytes(file, output, outsize); - fclose(file); + file = fopen(filename,"wb"); + Write_bytes(file, output, outsize); + fclose(file); - free (output); + free (output); output = NULL; - File_error = 0; + File_error = 0; } diff --git a/op_c.c b/op_c.c index 20b41ff3..8bcc065a 100644 --- a/op_c.c +++ b/op_c.c @@ -187,18 +187,18 @@ T_Conversion_table * CT_new(int nbb_r,int nbb_g,int nbb_b) n->nbb_b=nbb_b; // Calculate the others - - // Value ranges (max value actually) + + // Value ranges (max value actually) n->rng_r=(1<rng_g=(1<rng_b=(1<dec_r=nbb_g+nbb_b; n->dec_g=nbb_b; n->dec_b=0; - // Reductions (how many bits are lost) + // Reductions (how many bits are lost) n->red_r=8-nbb_r; n->red_g=8-nbb_g; n->red_b=8-nbb_b; @@ -550,7 +550,7 @@ ENDCRUSH: /// Split a cluster on its longest axis. /// c = source cluster, c1, c2 = output after split void Cluster_split(T_Cluster * c, T_Cluster * c1, T_Cluster * c2, int hue, - T_Occurrence_table * to) + T_Occurrence_table * to) { int limit; int cumul; @@ -561,7 +561,7 @@ void Cluster_split(T_Cluster * c, T_Cluster * c1, T_Cluster * c2, int hue, cumul = 0; if (hue == 0) // split on red { - // Run over the cluster until we reach the requested number of pixels + // Run over the cluster until we reach the requested number of pixels for (r = c->rmin<<16; r<=c->rmax<<16; r+=1<<16) { for (g = c->vmin<<8; g<=c->vmax<<8; g+=1<<8) @@ -582,9 +582,9 @@ void Cluster_split(T_Cluster * c, T_Cluster * c1, T_Cluster * c2, int hue, r>>=16; g>>=8; - // We tried to split on red, but found half of the pixels with r = rmin - // so we enforce some split to happen anyway, instead of creating an empty - // c2 and c1 == c + // We tried to split on red, but found half of the pixels with r = rmin + // so we enforce some split to happen anyway, instead of creating an empty + // c2 and c1 == c if (r==c->rmin) r++; @@ -724,15 +724,15 @@ void Cluster_compute_hue(T_Cluster * c,T_Occurrence_table * to) /* void CS_Check(T_Cluster_set* cs) { - int i; - T_Cluster* c = cs->clusters; - for (i = cs->nb; i > 0; i--) - { - assert( c != NULL); - c = c->next; - } + int i; + T_Cluster* c = cs->clusters; + for (i = cs->nb; i > 0; i--) + { + assert( c != NULL); + c = c->next; + } - assert(c == NULL); + assert(c == NULL); } */ @@ -762,8 +762,8 @@ T_Cluster_set * CS_New(int nbmax, T_Occurrence_table * to) // Copy requested params n->nb_max = OT_count_colors(to); - // If the number of colors asked is > 256, we ceil it because we know we - // don't want more + // If the number of colors asked is > 256, we ceil it because we know we + // don't want more if (n->nb_max > nbmax) { n->nb_max = nbmax; @@ -787,14 +787,14 @@ T_Cluster_set * CS_New(int nbmax, T_Occurrence_table * to) /// Free a cluster set void CS_Delete(T_Cluster_set * cs) { - T_Cluster* nxt; - while (cs->clusters != NULL) - { - nxt = cs->clusters->next; - free(cs->clusters); - cs->clusters = nxt; - } - free(cs); + T_Cluster* nxt; + while (cs->clusters != NULL) + { + nxt = cs->clusters->next; + free(cs->clusters); + cs->clusters = nxt; + } + free(cs); cs = NULL; } @@ -817,8 +817,8 @@ void CS_Get(T_Cluster_set * cs, T_Cluster * c) (current->bmin < current->bmax) ) break; - prev = current; - + prev = current; + } while((current = current -> next)); // copy it to c @@ -828,9 +828,9 @@ void CS_Get(T_Cluster_set * cs, T_Cluster * c) cs->nb--; if(prev) - prev->next = current->next; + prev->next = current->next; else - cs->clusters = current->next; + cs->clusters = current->next; free(current); current = NULL; } @@ -845,8 +845,8 @@ void CS_Set(T_Cluster_set * cs,T_Cluster * c) // Search the first cluster that is smaller than ours (less pixels) while (current && current->occurences > c->occurences) { - prev = current; - current = current->next; + prev = current; + current = current->next; } // Now insert our cluster just before the one we found @@ -885,12 +885,12 @@ void CS_Generate(T_Cluster_set * cs, T_Occurrence_table * to) // Split it Cluster_split(¤t, &Nouveau1, &Nouveau2, current.plus_large, to); - // Pack the 2 new clusters (the split may leave some empty space between the - // box border and the first actual pixel) + // Pack the 2 new clusters (the split may leave some empty space between the + // box border and the first actual pixel) Cluster_pack(&Nouveau1, to); Cluster_pack(&Nouveau2, to); - // Put them back in the list + // Put them back in the list CS_Set(cs,&Nouveau1); CS_Set(cs,&Nouveau2); @@ -914,69 +914,69 @@ void CS_Compute_colors(T_Cluster_set * cs, T_Occurrence_table * to) /// Sort the clusters by chrominance value void CS_Sort_by_chrominance(T_Cluster_set * cs) { - T_Cluster* nc; - T_Cluster* prev = NULL; - T_Cluster* place; - T_Cluster* newlist = NULL; + T_Cluster* nc; + T_Cluster* prev = NULL; + T_Cluster* place; + T_Cluster* newlist = NULL; - while (cs->clusters) - { - // Remove the first cluster from the original list - nc = cs->clusters; - cs->clusters = cs->clusters->next; + while (cs->clusters) + { + // Remove the first cluster from the original list + nc = cs->clusters; + cs->clusters = cs->clusters->next; - // Find his position in the new list - for (place = newlist; place != NULL; place = place->next) - { - if (place->h > nc->h) break; - prev = place; - } + // Find his position in the new list + for (place = newlist; place != NULL; place = place->next) + { + if (place->h > nc->h) break; + prev = place; + } - // Chain it there - nc->next = place; - if (prev) prev->next = nc; - else newlist = nc; + // Chain it there + nc->next = place; + if (prev) prev->next = nc; + else newlist = nc; - prev = NULL; - } + prev = NULL; + } - // Put the new list back in place - cs->clusters = newlist; + // Put the new list back in place + cs->clusters = newlist; } /// Sort the clusters by luminance value void CS_Sort_by_luminance(T_Cluster_set * cs) { - T_Cluster* nc; - T_Cluster* prev = NULL; - T_Cluster* place; - T_Cluster* newlist = NULL; + T_Cluster* nc; + T_Cluster* prev = NULL; + T_Cluster* place; + T_Cluster* newlist = NULL; - while (cs->clusters) - { - // Remove the first cluster from the original list - nc = cs->clusters; - cs->clusters = cs->clusters->next; + while (cs->clusters) + { + // Remove the first cluster from the original list + nc = cs->clusters; + cs->clusters = cs->clusters->next; - // Find its position in the new list - for (place = newlist; place != NULL; place = place->next) - { - if (place->l > nc->l) break; - prev = place; - } + // Find its position in the new list + for (place = newlist; place != NULL; place = place->next) + { + if (place->l > nc->l) break; + prev = place; + } - // Chain it there - nc->next = place; - if (prev) prev->next = nc; - else newlist = nc; + // Chain it there + nc->next = place; + if (prev) prev->next = nc; + else newlist = nc; - // reset prev pointer - prev = NULL; - } + // reset prev pointer + prev = NULL; + } - // Put the new list back in place - cs->clusters = newlist; + // Put the new list back in place + cs->clusters = newlist; } @@ -997,7 +997,7 @@ void CS_Generate_color_table_and_palette(T_Cluster_set * cs,T_Conversion_table * for (g=current->Gmin;g<=current->Vmax;g++) for (b=current->Bmin;b<=current->Bmax;b++) CT_set(tc,r,g,b,index); - current = current->next; + current = current->next; } } @@ -1053,62 +1053,62 @@ void GS_Generate(T_Gradient_set * ds,T_Cluster_set * cs) int best_gradient; // Meilleur d‚grad‚ int best_diff; // Meilleure diff‚rence de chrominance int diff; // difference de chrominance courante - T_Cluster * current = cs->clusters; + T_Cluster * current = cs->clusters; // Pour chacun des clusters … traiter do - { - // On recherche le d‚grad‚ le plus proche de la chrominance du cluster - best_gradient=-1; - best_diff=99999999; - for (id=0;idnb;id++) - { - diff=abs(current->h - ds->gradients[id].hue); - if ((best_diff>diff) && (diff<16)) - { - best_gradient=id; - best_diff=diff; - } - } + { + // On recherche le d‚grad‚ le plus proche de la chrominance du cluster + best_gradient=-1; + best_diff=99999999; + for (id=0;idnb;id++) + { + diff=abs(current->h - ds->gradients[id].hue); + if ((best_diff>diff) && (diff<16)) + { + best_gradient=id; + best_diff=diff; + } + } - // Si on a trouv‚ un d‚grad‚ dans lequel inclure le cluster - if (best_gradient!=-1) - { - // On met … jour le d‚grad‚ - if (current->h < ds->gradients[best_gradient].min) - ds->gradients[best_gradient].min=current->h; - if (current->h > ds->gradients[best_gradient].max) - ds->gradients[best_gradient].max=current->h; - ds->gradients[best_gradient].hue=((ds->gradients[best_gradient].hue* - ds->gradients[best_gradient].nb_colors) - +current->h) - /(ds->gradients[best_gradient].nb_colors+1); - ds->gradients[best_gradient].nb_colors++; - } - else - { - // On cr‚e un nouveau d‚grad‚ - best_gradient=ds->nb; - ds->gradients[best_gradient].nb_colors=1; - ds->gradients[best_gradient].min=current->h; - ds->gradients[best_gradient].max=current->h; - ds->gradients[best_gradient].hue=current->h; - ds->nb++; - } - current->h=best_gradient; - } while((current = current->next)); + // Si on a trouv‚ un d‚grad‚ dans lequel inclure le cluster + if (best_gradient!=-1) + { + // On met … jour le d‚grad‚ + if (current->h < ds->gradients[best_gradient].min) + ds->gradients[best_gradient].min=current->h; + if (current->h > ds->gradients[best_gradient].max) + ds->gradients[best_gradient].max=current->h; + ds->gradients[best_gradient].hue=((ds->gradients[best_gradient].hue* + ds->gradients[best_gradient].nb_colors) + +current->h) + /(ds->gradients[best_gradient].nb_colors+1); + ds->gradients[best_gradient].nb_colors++; + } + else + { + // On cr‚e un nouveau d‚grad‚ + best_gradient=ds->nb; + ds->gradients[best_gradient].nb_colors=1; + ds->gradients[best_gradient].min=current->h; + ds->gradients[best_gradient].max=current->h; + ds->gradients[best_gradient].hue=current->h; + ds->nb++; + } + current->h=best_gradient; + } while((current = current->next)); - // On redistribue les valeurs dans les clusters - current = cs -> clusters; - do - current->h=ds->gradients[current->h].hue; - while((current = current ->next)); + // On redistribue les valeurs dans les clusters + current = cs -> clusters; + do + current->h=ds->gradients[current->h].hue; + while((current = current ->next)); } /// Compute best palette for given picture. T_Conversion_table * Optimize_palette(T_Bitmap24B image, int size, - T_Components * palette, int r, int g, int b) + T_Components * palette, int r, int g, int b) { T_Occurrence_table * to; T_Conversion_table * tc; @@ -1120,13 +1120,13 @@ T_Conversion_table * Optimize_palette(T_Bitmap24B image, int size, to = OT_new(r, g, b); if (to == NULL) - return 0; + return 0; tc = CT_new(r, g, b); if (tc == NULL) { - OT_delete(to); - return 0; + OT_delete(to); + return 0; } // Count pixels for each color @@ -1137,7 +1137,7 @@ T_Conversion_table * Optimize_palette(T_Bitmap24B image, int size, { CT_delete(tc); OT_delete(to); - return 0; + return 0; } //CS_Check(cs); // Ok, everything was allocated @@ -1153,8 +1153,8 @@ T_Conversion_table * Optimize_palette(T_Bitmap24B image, int size, ds = GS_New(cs); if (ds!= NULL) { - GS_Generate(ds, cs); - GS_Delete(ds); + GS_Generate(ds, cs); + GS_Delete(ds); } // Sort the clusters on L and H to get a nice palette CS_Sort_by_luminance(cs); @@ -1286,8 +1286,8 @@ void Convert_24b_bitmap_to_256_Floyd_Steinberg(T_Bitmap256 dest,T_Bitmap24B sour /// Converts from 24b to 256c without dithering, using given conversion table void Convert_24b_bitmap_to_256_nearest_neighbor(T_Bitmap256 dest, - T_Bitmap24B source, int width, int height, __attribute__((unused)) T_Components * palette, - T_Conversion_table * tc) + T_Bitmap24B source, int width, int height, __attribute__((unused)) T_Components * palette, + T_Conversion_table * tc) { T_Bitmap24B current; T_Bitmap256 d; @@ -1310,7 +1310,7 @@ void Convert_24b_bitmap_to_256_nearest_neighbor(T_Bitmap256 dest, green = current->G; blue = current->B; // Cherche la couleur correspondant dans la palette et la range dans - // l'image de destination + // l'image de destination *d = CT_get(tc, red, green, blue); // On passe au pixel suivant : diff --git a/operatio.c b/operatio.c index 8f31f8f2..fdcd98da 100644 --- a/operatio.c +++ b/operatio.c @@ -299,14 +299,14 @@ void Freehand_mode2_1_2(void) if ( (start_x!=Paintbrush_X) || (start_y!=Paintbrush_Y) ) { Print_coordinates(); - if (SDL_GetTicks()>Airbrush_next_time) - { - Airbrush_next_time+=Airbrush_delay*10; - Hide_cursor(); - // On affiche définitivement le pinceau - Display_paintbrush(Paintbrush_X,Paintbrush_Y,Fore_color,0); - Display_cursor(); - } + if (SDL_GetTicks()>Airbrush_next_time) + { + Airbrush_next_time+=Airbrush_delay*10; + Hide_cursor(); + // On affiche définitivement le pinceau + Display_paintbrush(Paintbrush_X,Paintbrush_Y,Fore_color,0); + Display_cursor(); + } } Operation_push(Paintbrush_X); @@ -328,9 +328,9 @@ void Freehand_mode2_2_0(void) Operation_push(Paintbrush_X); Operation_push(Paintbrush_Y); Print_coordinates(); - Airbrush_next_time = SDL_GetTicks() + Airbrush_delay*10; - // On affiche définitivement le pinceau - Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0); + Airbrush_next_time = SDL_GetTicks() + Airbrush_delay*10; + // On affiche définitivement le pinceau + Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0); } @@ -350,14 +350,14 @@ void Freehand_mode2_2_2(void) if ( (start_x!=Paintbrush_X) || (start_y!=Paintbrush_Y) ) { Print_coordinates(); - if (SDL_GetTicks()>Airbrush_next_time) - { - Airbrush_next_time+=Airbrush_delay*10; - Hide_cursor(); - // On affiche définitivement le pinceau - Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0); - Display_cursor(); - } + if (SDL_GetTicks()>Airbrush_next_time) + { + Airbrush_next_time+=Airbrush_delay*10; + Hide_cursor(); + // On affiche définitivement le pinceau + Display_paintbrush(Paintbrush_X,Paintbrush_Y,Back_color,0); + Display_cursor(); + } } Operation_push(Paintbrush_X); @@ -3425,60 +3425,60 @@ void Grad_rectangle_0_5(void) || Min(ray, rby) > Main_image_height // Rectangle below picture || Min(ray, rby) - 1 - Main_offset_Y > Menu_Y ) // Rectangle below viewport { - Operation_pop(&rby); // reset the stack - return; // cancel the operation + Operation_pop(&rby); // reset the stack + return; // cancel the operation } - // Handle clipping - if (Max(rax, rbx)-Main_offset_X > Min(Main_image_width, - Main_magnifier_mode?Main_separator_position:Screen_width)) - { - offset_width = Max(rax, rbx) - Min(Main_image_width, - Main_magnifier_mode?Main_separator_position:Screen_width); - } + // Handle clipping + if (Max(rax, rbx)-Main_offset_X > Min(Main_image_width, + Main_magnifier_mode?Main_separator_position:Screen_width)) + { + offset_width = Max(rax, rbx) - Min(Main_image_width, + Main_magnifier_mode?Main_separator_position:Screen_width); + } - if (Max(ray, rby)-Main_offset_Y > Min(Main_image_height, Menu_Y)) - offset_height = Max(ray, rby) - Min(Main_image_height, Menu_Y); + if (Max(ray, rby)-Main_offset_Y > Min(Main_image_height, Menu_Y)) + offset_height = Max(ray, rby) - Min(Main_image_height, Menu_Y); - // Dessin dans la zone de dessin normale - Horizontal_XOR_line(Min(rax, rbx)-Main_offset_X, - Min(ray, rby) - Main_offset_Y, width - offset_width); + // Dessin dans la zone de dessin normale + Horizontal_XOR_line(Min(rax, rbx)-Main_offset_X, + Min(ray, rby) - Main_offset_Y, width - offset_width); - // If not, this line is out of the picture so there is no need to draw it - if (offset_height == 0 || Max(ray, rby) - 1 > Menu_Y + Main_offset_Y ) - { - Horizontal_XOR_line(Min(rax, rbx) - Main_offset_X, Max(ray, rby) - 1 - - Main_offset_Y, width - offset_width); - } + // If not, this line is out of the picture so there is no need to draw it + if (offset_height == 0 || Max(ray, rby) - 1 > Menu_Y + Main_offset_Y ) + { + Horizontal_XOR_line(Min(rax, rbx) - Main_offset_X, Max(ray, rby) - 1 + - Main_offset_Y, width - offset_width); + } if (height > offset_height) { - Vertical_XOR_line(Min(rax, rbx)-Main_offset_X, Min(ray, rby) - - Main_offset_Y, height - offset_height); + Vertical_XOR_line(Min(rax, rbx)-Main_offset_X, Min(ray, rby) + - Main_offset_Y, height - offset_height); - if (offset_width == 0) - { - Vertical_XOR_line(Max(rax, rbx) - 1 - Main_offset_X, Min(ray, rby) - - Main_offset_Y, height - offset_height); - } + if (offset_width == 0) + { + Vertical_XOR_line(Max(rax, rbx) - 1 - Main_offset_X, Min(ray, rby) + - Main_offset_Y, height - offset_height); + } } - Update_rect(Min(rax, rbx) - Main_offset_X, Min(ray, rby) - Main_offset_Y, - width + 1 - offset_width, height + 1 - offset_height); + Update_rect(Min(rax, rbx) - Main_offset_X, Min(ray, rby) - Main_offset_Y, + width + 1 - offset_width, height + 1 - offset_height); // Dessin dans la zone zoomée if (Main_magnifier_mode && Min(rax, rbx) <= Limit_right_zoom - && Max(rax, rbx) > Limit_left_zoom - && Min(ray, rby) <= Limit_bottom_zoom - && Max(ray, rby) > Limit_top_zoom ) + && Max(rax, rbx) > Limit_left_zoom + && Min(ray, rby) <= Limit_bottom_zoom + && Max(ray, rby) > Limit_top_zoom ) { - offset_width = 0; - offset_height = 0; + offset_width = 0; + offset_height = 0; - if (Min(rax, rbx)<=Limit_left_zoom) // On dépasse du zoom à gauche - { - offset_width += Limit_left_zoom - Min(rax, rbx); - offset_left = Limit_left_zoom; - } + if (Min(rax, rbx)<=Limit_left_zoom) // On dépasse du zoom à gauche + { + offset_width += Limit_left_zoom - Min(rax, rbx); + offset_left = Limit_left_zoom; + } if(Max(rax,rbx)>Limit_right_zoom) // On dépasse du zoom à droite offset_width += Max(rax,rbx) - Limit_right_zoom - 1; @@ -3604,8 +3604,8 @@ void Grad_rectangle_12_7(void) // Dessin dans la zone zoomée if (Main_magnifier_mode && Min(rax, rbx) <= Limit_right_zoom - && Max(rax, rbx)>Limit_left_zoom && Min(ray, rby) <= Limit_bottom_zoom - && Max(ray,rby)>Limit_top_zoom ) + && Max(rax, rbx)>Limit_left_zoom && Min(ray, rby) <= Limit_bottom_zoom + && Max(ray,rby)>Limit_top_zoom ) { offset_width = 0; offset_height=0; @@ -3758,10 +3758,10 @@ void Grad_rectangle_0_9(void) // Dessin dans la zone zoomée if (Main_magnifier_mode - && Min(rect_start_x, rect_end_x) <= Limit_right_zoom - && Max(rect_start_x, rect_end_x) > Limit_left_zoom - && Min(rect_start_y, rect_end_y) <= Limit_bottom_zoom - && Max(rect_start_y, rect_end_y) > Limit_top_zoom ) + && Min(rect_start_x, rect_end_x) <= Limit_right_zoom + && Max(rect_start_x, rect_end_x) > Limit_left_zoom + && Min(rect_start_y, rect_end_y) <= Limit_bottom_zoom + && Max(rect_start_y, rect_end_y) > Limit_top_zoom ) { offset_width = 0; offset_height=0; diff --git a/readini.c b/readini.c index 642d0b86..5516d208 100644 --- a/readini.c +++ b/readini.c @@ -715,15 +715,15 @@ int Load_INI(T_Config * conf) // Do that only if the first mode is actually windowed (not the case on gp2x for example) if(Video_mode[0].Fullscreen==0) { - Video_mode[0].Width = 640; - Video_mode[0].Height = 480; - if (!Load_INI_get_values (file,buffer,"Default_window_size",2,values)) - { - if ((values[0]>=320)) - Video_mode[0].Width = values[0]; - if ((values[1]>=200)) - Video_mode[0].Height = values[1]; - } + Video_mode[0].Width = 640; + Video_mode[0].Height = 480; + if (!Load_INI_get_values (file,buffer,"Default_window_size",2,values)) + { + if ((values[0]>=320)) + Video_mode[0].Width = values[0]; + if ((values[1]>=200)) + Video_mode[0].Height = values[1]; + } } conf->Mouse_merge_movement=100; @@ -823,14 +823,14 @@ int Load_INI(T_Config * conf) // Optional, name of skin file. (>2.0) if(!Load_INI_get_string(file,buffer,"Skin_file",value_label,1)) { - conf->Skin_file = strdup(value_label); + conf->Skin_file = strdup(value_label); } else conf->Skin_file = strdup("skin_modern.png"); // Optional, name of font file. (>2.0) if(!Load_INI_get_string(file,buffer,"Font_file",value_label,1)) - conf->Font_file = strdup(value_label); + conf->Font_file = strdup(value_label); else conf->Font_file = strdup("font_Classic.png"); diff --git a/setup.c b/setup.c index b6b0bb98..c9163c81 100644 --- a/setup.c +++ b/setup.c @@ -118,8 +118,8 @@ void Set_config_directory(const char * program_dir, char * config_dir) strcpy(config_dir,"PROGDIR:"); // GP2X #elif defined(__GP2X__) - // On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is - // on an internal flash chip. So, keep these settings locals. + // On the GP2X, the program is installed to the sdcard, and we don't want to mess with the system tree which is + // on an internal flash chip. So, keep these settings locals. strcpy(config_dir,program_dir); #else char filename[MAX_PATH_CHARACTERS]; diff --git a/shade.c b/shade.c index 5b0cc9d6..71579428 100644 --- a/shade.c +++ b/shade.c @@ -617,12 +617,12 @@ int Menu_shade(void) } break; - case 5: // Ok - if (selection_start == selection_end && Shade_list[Shade_current].List[selection_start] > 0) - Set_fore_color(Shade_list[Shade_current].List[selection_start]); - else if (first_color == last_color) - Set_fore_color(first_color); - break; + case 5: // Ok + if (selection_start == selection_end && Shade_list[Shade_current].List[selection_start] > 0) + Set_fore_color(Shade_list[Shade_current].List[selection_start]); + else if (first_color == last_color) + Set_fore_color(first_color); + break; case 6 : // Copy memcpy(buffer,Shade_list[Shade_current].List,512*sizeof(word)); diff --git a/struct.h b/struct.h index 413f5458..327eb7bd 100644 --- a/struct.h +++ b/struct.h @@ -38,7 +38,7 @@ // POSIX calls it strcasecmp, Windows uses stricmp... no ANSI standard. #ifdef WIN32 - #define strcasecmp stricmp + #define strcasecmp stricmp #endif // Definition of the base data types