Support CM5/GFX files with AMSDOS header
also fixes the extension in load/save dialog
This commit is contained in:
		
							parent
							
								
									7db529b5c8
								
							
						
					
					
						commit
						2a34ca83c8
					
				@ -1105,10 +1105,11 @@ void Test_CM5(T_IO_Context * context, FILE * file)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  // check cm5 file size == 2049 bytes
 | 
					  // check cm5 file size == 2049 bytes
 | 
				
			||||||
  FILE *file_gfx;
 | 
					  FILE *file_gfx;
 | 
				
			||||||
  long file_size;
 | 
					  unsigned long file_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  File_error = 1;
 | 
					  File_error = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!CPC_check_AMSDOS(file, NULL, NULL, &file_size))
 | 
				
			||||||
    file_size = File_length_file(file);
 | 
					    file_size = File_length_file(file);
 | 
				
			||||||
  if (file_size != 2049)
 | 
					  if (file_size != 2049)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
@ -1117,6 +1118,7 @@ void Test_CM5(T_IO_Context * context, FILE * file)
 | 
				
			|||||||
  file_gfx = Open_file_read_with_alternate_ext(context, "gfx");
 | 
					  file_gfx = Open_file_read_with_alternate_ext(context, "gfx");
 | 
				
			||||||
  if (file_gfx == NULL)
 | 
					  if (file_gfx == NULL)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					  if (!CPC_check_AMSDOS(file_gfx, NULL, NULL, &file_size))
 | 
				
			||||||
    file_size = File_length_file(file_gfx);
 | 
					    file_size = File_length_file(file_gfx);
 | 
				
			||||||
  fclose(file_gfx);
 | 
					  fclose(file_gfx);
 | 
				
			||||||
  if (file_size != 18432)
 | 
					  if (file_size != 18432)
 | 
				
			||||||
@ -1155,7 +1157,7 @@ void Load_CM5(T_IO_Context* context)
 | 
				
			|||||||
      return;
 | 
					      return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Pre_load(context, 48*6, 256, 2049, FORMAT_CM5, PIXEL_SIMPLE, 0);
 | 
					  Pre_load(context, 48*6, 256, 2049, FORMAT_CM5, PIXEL_SIMPLE, 5);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (Config.Clear_palette)
 | 
					  if (Config.Clear_palette)
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
@ -1171,6 +1173,8 @@ void Load_CM5(T_IO_Context* context)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  First_color_in_palette = 64;
 | 
					  First_color_in_palette = 64;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (CPC_check_AMSDOS(file, NULL, NULL, NULL))
 | 
				
			||||||
 | 
					    fseek(file, 128, SEEK_SET); // seek after AMSDOS header
 | 
				
			||||||
  if (!Read_byte(file, &ink0))
 | 
					  if (!Read_byte(file, &ink0))
 | 
				
			||||||
    File_error = 2;
 | 
					    File_error = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1190,8 +1194,13 @@ void Load_CM5(T_IO_Context* context)
 | 
				
			|||||||
        Set_pixel(context, tx, ty, ink0);
 | 
					        Set_pixel(context, tx, ty, ink0);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  while(Read_byte(file, &value))
 | 
					  for (line = 0; line < 256; )
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
					    if (!Read_byte(file, &value))
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      File_error = 1;
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    switch(mod)
 | 
					    switch(mod)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      case 0:
 | 
					      case 0:
 | 
				
			||||||
@ -1233,6 +1242,8 @@ void Load_CM5(T_IO_Context* context)
 | 
				
			|||||||
    File_error = 1;
 | 
					    File_error = 1;
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					  if (CPC_check_AMSDOS(file, NULL, NULL, NULL))
 | 
				
			||||||
 | 
					    fseek(file, 128, SEEK_SET); // seek after AMSDOS header
 | 
				
			||||||
  Set_loading_layer(context, 4);
 | 
					  Set_loading_layer(context, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (context->Type == CONTEXT_PREVIEW)
 | 
					  if (context->Type == CONTEXT_PREVIEW)
 | 
				
			||||||
@ -1300,7 +1311,6 @@ void Save_CM5(T_IO_Context* context)
 | 
				
			|||||||
    File_error = 1;
 | 
					    File_error = 1;
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  setvbuf(file, NULL, _IOFBF, 64*1024);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Write layer 0
 | 
					  // Write layer 0
 | 
				
			||||||
  Set_saving_layer(context, 0);
 | 
					  Set_saving_layer(context, 0);
 | 
				
			||||||
@ -1326,7 +1336,6 @@ void Save_CM5(T_IO_Context* context)
 | 
				
			|||||||
    File_error = 2;
 | 
					    File_error = 2;
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  setvbuf(file, NULL, _IOFBF, 64*1024);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Set_saving_layer(context, 4);
 | 
					  Set_saving_layer(context, 4);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -118,7 +118,7 @@ const T_Format File_formats[] = {
 | 
				
			|||||||
    "pi1;pc1;pi2;pc2;pi3;pc3;neo;tny;tn1;tn2;tn3;tn4;"
 | 
					    "pi1;pc1;pi2;pc2;pi3;pc3;neo;tny;tn1;tn2;tn3;tn4;"
 | 
				
			||||||
    "c64;p64;a64;pi;rp;aas;art;dd;iph;ipt;hpc;ocp;koa;koala;fli;bml;cdu;prg;pmg;rpm;"
 | 
					    "c64;p64;a64;pi;rp;aas;art;dd;iph;ipt;hpc;ocp;koa;koala;fli;bml;cdu;prg;pmg;rpm;"
 | 
				
			||||||
    "gpx;"
 | 
					    "gpx;"
 | 
				
			||||||
    "cpc;scr;win;pph,cm5;go1;"
 | 
					    "cpc;scr;win;pph;cm5;go1;"
 | 
				
			||||||
    "hgr;dhgr;"
 | 
					    "hgr;dhgr;"
 | 
				
			||||||
    "grb;grob;"
 | 
					    "grb;grob;"
 | 
				
			||||||
    "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;ic2;cur;info;flc;bin;map"},
 | 
					    "tga;pnm;xpm;xcf;jpg;jpeg;tif;tiff;ico;ic2;cur;info;flc;bin;map"},
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user