diff --git a/Makefile b/Makefile index cf9e41e6..0a53b610 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,7 @@ datarootdir = $(prefix)/share datadir = $(datarootdir) +# Compile with OPTIM=0 to disable gcc optimizations, to enable debug. STRIP = strip @@ -40,7 +41,7 @@ ifdef COMSPEC RMDIR = rmdir CP = cp BIN = grafx2.exe - COPT = -W -Wall -Wdeclaration-after-statement -O -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) + COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb `sdl-config --cflags` $(TTFCOPT) $(JOYCOPT) LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng CC = gcc OBJDIR = obj/win32 @@ -177,7 +178,7 @@ else #cross compile a Win32 executable CC = i586-mingw32msvc-gcc BIN = grafx2.exe - COPT = -W -Wall -Wdeclaration-after-statement -O -g -ggdb -Dmain=SDL_main `/usr/local/cross-tools/i386-mingw32/bin/sdl-config --cflags` $(TTFCOPT) + COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb -Dmain=SDL_main `/usr/local/cross-tools/i386-mingw32/bin/sdl-config --cflags` $(TTFCOPT) LOPT = -mwindows -lmingw32 -lSDLmain -lSDL -lshlwapi `/usr/local/cross-tools/i386-mingw32/bin/sdl-config --libs` -lSDL_image $(TTFLOPT) OBJDIR = obj/win32 PLATFORM = win32 @@ -197,7 +198,7 @@ else # Compiles a regular linux exectutable for the native platform BIN = grafx2 COPT = -W -Wall -Wdeclaration-after-statement -pedantic -std=c99 -c -g `sdl-config --cflags` $(TTFCOPT) - LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) + LOPT = `sdl-config --libs` -lSDL_image $(TTFLOPT) -lpng CC = gcc OBJDIR = obj/unix X11LOPT = -lX11 diff --git a/buttons.c b/buttons.c index 205efb10..b9dd4847 100644 --- a/buttons.c +++ b/buttons.c @@ -1673,8 +1673,6 @@ void Button_Safety_resolution(void) Unselect_bouton(BUTTON_MAGNIFIER); Init_mode_video(640, 400, 0,PIXEL_SIMPLE); Current_resolution=0; - Video_mode[0].Width = Screen_width*Pixel_width; - Video_mode[0].Height = Screen_height*Pixel_height; Display_menu(); Display_all_screen(); diff --git a/engine.c b/engine.c index a8e2074c..c2bd1c81 100644 --- a/engine.c +++ b/engine.c @@ -524,8 +524,6 @@ void Main_handler(void) { Hide_cursor(); Init_mode_video(Resize_width, Resize_height, 0, Pixel_ratio); - Video_mode[0].Width = Screen_width*Pixel_width; - Video_mode[0].Height = Screen_height*Pixel_height; // Remise à zero des variables indiquant le Redimensionnement demandé Display_menu(); Display_all_screen(); diff --git a/graph.c b/graph.c index f5cc2afd..1905d44f 100644 --- a/graph.c +++ b/graph.c @@ -190,6 +190,9 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio) int pix_height; byte screen_changed; byte pixels_changed; + int absolute_mouse_x=Mouse_X*Pixel_width; + int absolute_mouse_y=Mouse_Y*Pixel_height; + switch (pix_ratio) { @@ -212,13 +215,26 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio) break; } + screen_changed = (Screen_width*Pixel_width!=width || + Screen_height*Pixel_height!=height || + Video_mode[Current_resolution].Fullscreen != fullscreen); + // Valeurs raisonnables: minimum 320x200 if (!fullscreen) { if (width < 320*pix_width) + { width = 320*pix_width; + screen_changed=1; + } if (height < 200*pix_height) + { height = 200*pix_height; + screen_changed=1; + } + Video_mode[0].Width = width; + Video_mode[0].Height = height; + } else { @@ -233,9 +249,6 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio) width = (width + 3 ) & 0xFFFFFFFC; #endif - screen_changed = (Screen_width*Pixel_width!=width || - Screen_height*Pixel_height!=height || - Video_mode[Current_resolution].Fullscreen != fullscreen); pixels_changed = (Pixel_ratio!=pix_ratio); if (!screen_changed && !pixels_changed) @@ -405,6 +418,14 @@ int Init_mode_video(int width, int height, int fullscreen, int pix_ratio) y_sensitivity>>=Mouse_fix_factor_Y; Mouse_sensitivity(x_sensitivity?x_sensitivity:1,y_sensitivity?y_sensitivity:1); + Mouse_X=absolute_mouse_x/Pixel_width; + if (Mouse_X>=Screen_width) + Mouse_X=Screen_width-1; + Mouse_Y=absolute_mouse_y/Pixel_height; + if (Mouse_Y>=Screen_height) + Mouse_Y=Screen_height-1; + 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. diff --git a/loadsave.c b/loadsave.c index d5fd7bbe..73f01154 100644 --- a/loadsave.c +++ b/loadsave.c @@ -514,7 +514,8 @@ void filename_complet(char * filename, byte is_colorix_format) void Read_one_byte(FILE * file, byte *b) { // FIXME : Replace les appelants par Read_bytes(), et gérer les retours d'erreur. - Read_byte(file, b); + if (!Read_byte(file, b)) + File_error=2; } // -------------------------------------------------------------------------- @@ -645,6 +646,16 @@ void Load_image(byte image) { if ( (File_error!=1) && (File_formats[format].Backup_done) ) { + if (Pixel_load_function==Pixel_load_in_preview) + { + dword color_usage[256]; + Count_used_colors_area(color_usage,Preview_pos_X,Preview_pos_Y,Main_image_width/Preview_factor_X,Main_image_height/Preview_factor_Y); + //Count_used_colors(color_usage); + Display_cursor(); + Set_nice_menu_colors(color_usage,1); + Hide_cursor(); + } + // On considère que l'image chargée n'est plus modifiée Main_image_is_modified=0; // Et on documente la variable Main_fileformat avec la valeur: diff --git a/misc.c b/misc.c index 31103d3a..ca599ccc 100644 --- a/misc.c +++ b/misc.c @@ -40,7 +40,7 @@ word Count_used_colors(dword* usage) { int nb_pixels=0; - Uint8* Pixel_Courant=Main_screen; + Uint8* current_pixel=Main_screen; Uint8 color; word nb_colors=0; int i; @@ -53,12 +53,12 @@ word Count_used_colors(dword* usage) // On parcourt l'écran courant pour compter les utilisations des couleurs for(i=0;i