Fixed bad display and possible crash, when the zoomed area showed more than 512 pixels (requires resolution >1600)
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@824 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									0826798943
								
							
						
					
					
						commit
						33bb5622c0
					
				
							
								
								
									
										7
									
								
								global.h
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								global.h
									
									
									
									
									
								
							@ -726,13 +726,6 @@ GFX2_GLOBAL byte Mask_table[256];
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// -- Magnifier data
 | 
					// -- Magnifier data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Pointer to ::Magnify_table[n] : table of multipliers used by the Magnifier.
 | 
					 | 
				
			||||||
// FIXME: This only caches a multiplication. Maybe we should scrap it
 | 
					 | 
				
			||||||
GFX2_GLOBAL word  * Zoom_factor_table;
 | 
					 | 
				
			||||||
/// Precomputed tables of multipliers used by the Magnifier.
 | 
					 | 
				
			||||||
// FIXME: This only caches a multiplication. Maybe we should scrap it
 | 
					 | 
				
			||||||
GFX2_GLOBAL word  Magnify_table[NB_ZOOM_FACTORS][512];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#ifdef GLOBAL_VARIABLES
 | 
					#ifdef GLOBAL_VARIABLES
 | 
				
			||||||
  word ZOOM_FACTOR[NB_ZOOM_FACTORS]={2,3,4,5,6,8,10,12,14,16,18,20};
 | 
					  word ZOOM_FACTOR[NB_ZOOM_FACTORS]={2,3,4,5,6,8,10,12,14,16,18,20};
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										18
									
								
								init.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								init.c
									
									
									
									
									
								
							@ -2168,24 +2168,6 @@ Erreur_sauvegarde_config:
 | 
				
			|||||||
  return ERROR_SAVING_CFG;
 | 
					  return ERROR_SAVING_CFG;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
void Init_multiplication_tables(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
  word factor_index;
 | 
					 | 
				
			||||||
  word zoom_factor;
 | 
					 | 
				
			||||||
  word mult_index;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  for (factor_index=0;factor_index<NB_ZOOM_FACTORS;factor_index++)
 | 
					 | 
				
			||||||
  {
 | 
					 | 
				
			||||||
    zoom_factor=ZOOM_FACTOR[factor_index];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (mult_index=0;mult_index<512;mult_index++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
      Magnify_table[factor_index][mult_index]=zoom_factor*mult_index;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// (Ré)assigne toutes les valeurs de configuration par défaut
 | 
					// (Ré)assigne toutes les valeurs de configuration par défaut
 | 
				
			||||||
void Set_config_defaults(void)
 | 
					void Set_config_defaults(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								init.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								init.h
									
									
									
									
									
								
							@ -27,7 +27,6 @@ void Init_buttons(void);
 | 
				
			|||||||
void Init_operations(void);
 | 
					void Init_operations(void);
 | 
				
			||||||
int  Load_CFG(int reload_all);
 | 
					int  Load_CFG(int reload_all);
 | 
				
			||||||
int  Save_CFG(void);
 | 
					int  Save_CFG(void);
 | 
				
			||||||
void Init_multiplication_tables(void);
 | 
					 | 
				
			||||||
void Set_all_video_modes(void);
 | 
					void Set_all_video_modes(void);
 | 
				
			||||||
void Set_config_defaults(void);
 | 
					void Set_config_defaults(void);
 | 
				
			||||||
void Init_sighandler(void);
 | 
					void Init_sighandler(void);
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.c
									
									
									
									
									
								
							@ -464,8 +464,6 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
    // On initialise les infos de la loupe:
 | 
					    // On initialise les infos de la loupe:
 | 
				
			||||||
  Main_magnifier_mode=0;
 | 
					  Main_magnifier_mode=0;
 | 
				
			||||||
  Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
 | 
					  Main_magnifier_factor=DEFAULT_ZOOM_FACTOR;
 | 
				
			||||||
  Init_multiplication_tables();
 | 
					 | 
				
			||||||
  Zoom_factor_table=Magnify_table[2];
 | 
					 | 
				
			||||||
  Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
 | 
					  Main_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
 | 
				
			||||||
  Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
 | 
					  Spare_separator_proportion=INITIAL_SEPARATOR_PROPORTION;
 | 
				
			||||||
    // On initialise les infos du mode smear:
 | 
					    // On initialise les infos du mode smear:
 | 
				
			||||||
 | 
				
			|||||||
@ -106,7 +106,7 @@ void Pixel_preview_magnifier_double  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -116,7 +116,7 @@ void Pixel_preview_magnifier_double  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_double(
 | 
					    Block_double(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								pxquad.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								pxquad.c
									
									
									
									
									
								
							@ -121,7 +121,7 @@ void Pixel_preview_magnifier_quad  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -131,7 +131,7 @@ void Pixel_preview_magnifier_quad  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_quad(
 | 
					    Block_quad(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -91,7 +91,7 @@ void Pixel_preview_magnifier_simple  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -101,7 +101,7 @@ void Pixel_preview_magnifier_simple  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_simple(
 | 
					    Block_simple(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								pxtall.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								pxtall.c
									
									
									
									
									
								
							@ -98,7 +98,7 @@ void Pixel_preview_magnifier_tall  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -108,7 +108,7 @@ void Pixel_preview_magnifier_tall  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_tall(
 | 
					    Block_tall(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -113,7 +113,7 @@ void Pixel_preview_magnifier_tall2  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -123,7 +123,7 @@ void Pixel_preview_magnifier_tall2  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_tall2(
 | 
					    Block_tall2(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -112,7 +112,7 @@ void Pixel_preview_magnifier_triple  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -122,7 +122,7 @@ void Pixel_preview_magnifier_triple  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_triple(
 | 
					    Block_triple(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										4
									
								
								pxwide.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								pxwide.c
									
									
									
									
									
								
							@ -101,7 +101,7 @@ void Pixel_preview_magnifier_wide  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -111,7 +111,7 @@ void Pixel_preview_magnifier_wide  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_wide(
 | 
					    Block_wide(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -109,7 +109,7 @@ void Pixel_preview_magnifier_wide2  (word x,word y,byte color)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    // On est dedans
 | 
					    // On est dedans
 | 
				
			||||||
    int height;
 | 
					    int height;
 | 
				
			||||||
    int y_zoom = Zoom_factor_table[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
 | 
					      // On ne doit dessiner qu'un morceau du pixel
 | 
				
			||||||
@ -119,7 +119,7 @@ void Pixel_preview_magnifier_wide2  (word x,word y,byte color)
 | 
				
			|||||||
      height = Main_magnifier_factor;
 | 
					      height = Main_magnifier_factor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Block_wide2(
 | 
					    Block_wide2(
 | 
				
			||||||
      Zoom_factor_table[x-Main_magnifier_offset_X]+Main_X_zoom, 
 | 
					      Main_magnifier_factor * (x-Main_magnifier_offset_X) + Main_X_zoom, 
 | 
				
			||||||
      y_zoom, Main_magnifier_factor, height, color
 | 
					      y_zoom, Main_magnifier_factor, height, color
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -1399,7 +1399,6 @@ void Change_magnifier_factor(byte factor_index)
 | 
				
			|||||||
  center_y=Main_magnifier_offset_Y+(Main_magnifier_height>>1);
 | 
					  center_y=Main_magnifier_offset_Y+(Main_magnifier_height>>1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Main_magnifier_factor=ZOOM_FACTOR[factor_index];
 | 
					  Main_magnifier_factor=ZOOM_FACTOR[factor_index];
 | 
				
			||||||
  Zoom_factor_table=Magnify_table[factor_index];
 | 
					 | 
				
			||||||
  Compute_magnifier_data();
 | 
					  Compute_magnifier_data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (Main_magnifier_mode)
 | 
					  if (Main_magnifier_mode)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user