Allow Analyze_command_line() to be executed earlier
This commit is contained in:
		
							parent
							
								
									a96d0289f4
								
							
						
					
					
						commit
						450d5f06a4
					
				
							
								
								
									
										62
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										62
									
								
								src/main.c
									
									
									
									
									
								
							@ -355,9 +355,11 @@ struct {
 | 
				
			|||||||
 * @param argv argument values
 | 
					 * @param argv argument values
 | 
				
			||||||
 * @param filenames pointers to receive file names
 | 
					 * @param filenames pointers to receive file names
 | 
				
			||||||
 * @param directories pointers to receive file directories
 | 
					 * @param directories pointers to receive file directories
 | 
				
			||||||
 | 
					 * @param videomode_arg pointer to receive the -mode argument
 | 
				
			||||||
 | 
					 * @param pixel_ratio pointer to receive the pixel ratio requested
 | 
				
			||||||
 * @return the number of file to open (0, 1 or 2)
 | 
					 * @return the number of file to open (0, 1 or 2)
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
int Analyze_command_line(int argc, char * argv[], char * filenames[], char * directories[])
 | 
					int Analyze_command_line(int argc, char * argv[], char * filenames[], char * directories[], const char ** videomode_arg, int * pixel_ratio)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  char *buffer;
 | 
					  char *buffer;
 | 
				
			||||||
  char *filename;
 | 
					  char *filename;
 | 
				
			||||||
@ -421,18 +423,8 @@ int Analyze_command_line(int argc, char * argv[], char * filenames[], char * dir
 | 
				
			|||||||
        index++;
 | 
					        index++;
 | 
				
			||||||
        if (index<argc)
 | 
					        if (index<argc)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          Resolution_in_command_line = 1;
 | 
					          // will be processed later, when video is initialized
 | 
				
			||||||
          Current_resolution = Convert_videomode_arg(argv[index]);
 | 
					          *videomode_arg = argv[index];
 | 
				
			||||||
          if (Current_resolution == -1)
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            Error(ERROR_COMMAND_LINE);
 | 
					 | 
				
			||||||
            exit(0);
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
          if ((Video_mode[Current_resolution].State & 0x7F) == 3)
 | 
					 | 
				
			||||||
          {
 | 
					 | 
				
			||||||
            Error(ERROR_FORBIDDEN_MODE);
 | 
					 | 
				
			||||||
            exit(0);
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@ -441,28 +433,28 @@ int Analyze_command_line(int argc, char * argv[], char * filenames[], char * dir
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_TALL:
 | 
					      case CMDPARAM_PIXELRATIO_TALL:
 | 
				
			||||||
        Pixel_ratio = PIXEL_TALL;
 | 
					        *pixel_ratio = PIXEL_TALL;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_WIDE:
 | 
					      case CMDPARAM_PIXELRATIO_WIDE:
 | 
				
			||||||
        Pixel_ratio = PIXEL_WIDE;
 | 
					        *pixel_ratio = PIXEL_WIDE;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_DOUBLE:
 | 
					      case CMDPARAM_PIXELRATIO_DOUBLE:
 | 
				
			||||||
        Pixel_ratio = PIXEL_DOUBLE;
 | 
					        *pixel_ratio = PIXEL_DOUBLE;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_TRIPLE:
 | 
					      case CMDPARAM_PIXELRATIO_TRIPLE:
 | 
				
			||||||
        Pixel_ratio = PIXEL_TRIPLE;
 | 
					        *pixel_ratio = PIXEL_TRIPLE;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_QUAD:
 | 
					      case CMDPARAM_PIXELRATIO_QUAD:
 | 
				
			||||||
        Pixel_ratio = PIXEL_QUAD;
 | 
					        *pixel_ratio = PIXEL_QUAD;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_TALL2:
 | 
					      case CMDPARAM_PIXELRATIO_TALL2:
 | 
				
			||||||
        Pixel_ratio = PIXEL_TALL2;
 | 
					        *pixel_ratio = PIXEL_TALL2;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_TALL3:
 | 
					      case CMDPARAM_PIXELRATIO_TALL3:
 | 
				
			||||||
        Pixel_ratio = PIXEL_TALL3;
 | 
					        *pixel_ratio = PIXEL_TALL3;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_PIXELRATIO_WIDE2:
 | 
					      case CMDPARAM_PIXELRATIO_WIDE2:
 | 
				
			||||||
        Pixel_ratio = PIXEL_WIDE2;
 | 
					        *pixel_ratio = PIXEL_WIDE2;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
      case CMDPARAM_RGB:
 | 
					      case CMDPARAM_RGB:
 | 
				
			||||||
        /* RGB scale */
 | 
					        /* RGB scale */
 | 
				
			||||||
@ -624,6 +616,8 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
  T_Gradient_array initial_gradients;
 | 
					  T_Gradient_array initial_gradients;
 | 
				
			||||||
  char * filenames[2] = {NULL, NULL};
 | 
					  char * filenames[2] = {NULL, NULL};
 | 
				
			||||||
  char * directories[2] = {NULL, NULL};
 | 
					  char * directories[2] = {NULL, NULL};
 | 
				
			||||||
 | 
					  const char * videomode = NULL;
 | 
				
			||||||
 | 
					  int cmdline_pixelratio = -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  #if defined(__MINT__)
 | 
					  #if defined(__MINT__)
 | 
				
			||||||
  printf("===============================\n");
 | 
					  printf("===============================\n");
 | 
				
			||||||
@ -646,6 +640,9 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
#endif /* ENABLE_FILENAMES_ICONV */
 | 
					#endif /* ENABLE_FILENAMES_ICONV */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Analyse command-line as soon as possible.
 | 
				
			||||||
 | 
					  file_in_command_line = Analyze_command_line(argc, argv, filenames, directories, &videomode, &cmdline_pixelratio);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // On crée dès maintenant les descripteurs des listes de pages pour la page
 | 
					  // On crée dès maintenant les descripteurs des listes de pages pour la page
 | 
				
			||||||
  // principale et la page de brouillon afin que leurs champs ne soient pas
 | 
					  // principale et la page de brouillon afin que leurs champs ne soient pas
 | 
				
			||||||
  // invalide lors des appels aux multiples fonctions manipulées à
 | 
					  // invalide lors des appels aux multiples fonctions manipulées à
 | 
				
			||||||
@ -771,11 +768,6 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
  // Initialize all video modes
 | 
					  // Initialize all video modes
 | 
				
			||||||
  Set_all_video_modes();
 | 
					  Set_all_video_modes();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Analyse command-line as soon as possible.
 | 
					 | 
				
			||||||
  // This must come after video mode initialization because
 | 
					 | 
				
			||||||
  // a video mode may be requested as a command-line parameter
 | 
					 | 
				
			||||||
  file_in_command_line = Analyze_command_line(argc, argv, filenames, directories);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(USE_JOYSTICK) && (defined(USE_SDL) || defined(USE_SDL2))
 | 
					#if defined(USE_JOYSTICK) && (defined(USE_SDL) || defined(USE_SDL2))
 | 
				
			||||||
  GFX2_Log(GFX2_DEBUG, "%d joystick(s) attached\n", SDL_NumJoysticks());
 | 
					  GFX2_Log(GFX2_DEBUG, "%d joystick(s) attached\n", SDL_NumJoysticks());
 | 
				
			||||||
  if (SDL_NumJoysticks() > 0)
 | 
					  if (SDL_NumJoysticks() > 0)
 | 
				
			||||||
@ -969,10 +961,28 @@ int Init_program(int argc,char * argv[])
 | 
				
			|||||||
  if (!Smear_brush)
 | 
					  if (!Smear_brush)
 | 
				
			||||||
    Error(ERROR_MEMORY);
 | 
					    Error(ERROR_MEMORY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // set videomode according to the command line
 | 
				
			||||||
 | 
					  if (videomode)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    Resolution_in_command_line = 1;
 | 
				
			||||||
 | 
					    Current_resolution = Convert_videomode_arg(videomode);
 | 
				
			||||||
 | 
					    if (Current_resolution == -1)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      Error(ERROR_COMMAND_LINE);
 | 
				
			||||||
 | 
					      exit(0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if ((Video_mode[Current_resolution].State & 0x7F) == 3)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      Error(ERROR_FORBIDDEN_MODE);
 | 
				
			||||||
 | 
					      exit(0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  starting_videomode=Current_resolution;
 | 
					  starting_videomode=Current_resolution;
 | 
				
			||||||
  Horizontal_line_buffer=NULL;
 | 
					  Horizontal_line_buffer=NULL;
 | 
				
			||||||
  Screen_width=Screen_height=Current_resolution=0;
 | 
					  Screen_width=Screen_height=Current_resolution=0;
 | 
				
			||||||
 | 
					  if (cmdline_pixelratio >= 0 && cmdline_pixelratio < (int)PIXEL_MAX)
 | 
				
			||||||
 | 
					    Pixel_ratio = cmdline_pixelratio;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Init_mode_video(
 | 
					  Init_mode_video(
 | 
				
			||||||
    Video_mode[starting_videomode].Width,
 | 
					    Video_mode[starting_videomode].Width,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user