Free memory properly when saving a cpc .scr.
Also allow to save a brush in this format (in "screen" mode). git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1160 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
		
							parent
							
								
									45f04503c6
								
							
						
					
					
						commit
						2239adbd58
					
				@ -24,33 +24,33 @@ unsigned short addrCalc(unsigned char vcc, unsigned char rcc, unsigned char hcc,
 | 
				
			|||||||
  return addr;
 | 
					  return addr;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned char mode0interlace(unsigned char *x)
 | 
					unsigned char mode0interlace(unsigned char x, unsigned char y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned char mode0pixel[] = {0, 64, 4, 68, 16, 80, 20, 84, 1, 65, 5, 69, 17, 81, 21, 85};
 | 
					  unsigned char mode0pixel[] = {0, 64, 4, 68, 16, 80, 20, 84, 1, 65, 5, 69, 17, 81, 21, 85};
 | 
				
			||||||
  return mode0pixel[x[0]] << 1 | mode0pixel[x[1]];
 | 
					  return mode0pixel[Read_pixel_function(x,y)] << 1 | mode0pixel[Read_pixel_function(x+1,y)];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned char mode1interlace(unsigned char *x)
 | 
					unsigned char mode1interlace(unsigned char x, unsigned char y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned char mode1pixel[] = {0, 16, 1, 17};
 | 
					  unsigned char mode1pixel[] = {0, 16, 1, 17};
 | 
				
			||||||
  return mode1pixel[x[0]] << 3 | mode1pixel[x[1]] << 2 | mode1pixel[x[2]] << 1 | mode1pixel[x[3]];
 | 
					  return mode1pixel[Read_pixel_function(x,y)] << 3 | mode1pixel[Read_pixel_function(x+1,y)] << 2 | mode1pixel[Read_pixel_function(x+2,y)] << 1 | mode1pixel[Read_pixel_function(x+3,y)];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned char mode2interlace(unsigned char *x)
 | 
					unsigned char mode2interlace(unsigned char x, unsigned char y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned char out = 0;
 | 
					  unsigned char out = 0;
 | 
				
			||||||
  int i;
 | 
					  int i;
 | 
				
			||||||
  for(i = 0; i < 8; i++) out += ((x[7-i]&1) << i);
 | 
					  for(i = 0; i < 8; i++) out += ((Read_pixel_function(x+7-i,y)&1) << i);
 | 
				
			||||||
  return out;
 | 
					  return out;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned char mode3interlace(unsigned char *x)
 | 
					unsigned char mode3interlace(unsigned char x, unsigned char y)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  unsigned char mode3pixel[] = {0, 16, 1, 17};
 | 
					  unsigned char mode3pixel[] = {0, 16, 1, 17};
 | 
				
			||||||
  return mode3pixel[x[0]] << 3 | mode3pixel[x[1]] << 2;
 | 
					  return mode3pixel[Read_pixel_function(x,y)] << 3 | mode3pixel[Read_pixel_function(x+1,y)] << 2;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned char (*ptrMode)(unsigned char *x);
 | 
					unsigned char (*ptrMode)(unsigned char x, unsigned char y);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
unsigned char *raw2crtc(unsigned short width, unsigned short height, unsigned char mode, unsigned char r9, unsigned long *outSize, unsigned char *r1, unsigned char r12, unsigned char r13)
 | 
					unsigned char *raw2crtc(unsigned short width, unsigned short height, unsigned char mode, unsigned char r9, unsigned long *outSize, unsigned char *r1, unsigned char r12, unsigned char r13)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -135,8 +135,7 @@ unsigned char *raw2crtc(unsigned short width, unsigned short height, unsigned ch
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
	  x = (hcc << 1 | cclk);
 | 
						  x = (hcc << 1 | cclk);
 | 
				
			||||||
	  y = vcc*(r9+1) + rcc;
 | 
						  y = vcc*(r9+1) + rcc;
 | 
				
			||||||
	  // TODO : make this work properly when saving a brush...
 | 
						  *(tmpBuffer + addrCalc(vcc, rcc, hcc, cclk, *r1, r12, r13)) = (*ptrMode)(x,y);
 | 
				
			||||||
	  *(tmpBuffer + addrCalc(vcc, rcc, hcc, cclk, *r1, r12, r13)) = (*ptrMode)(Main_screen+y*width+x);
 | 
					 | 
				
			||||||
	  *(allocationBuffer + addrCalc(vcc, rcc, hcc, cclk, *r1, r12, r13)) += 1;
 | 
						  *(allocationBuffer + addrCalc(vcc, rcc, hcc, cclk, *r1, r12, r13)) += 1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -2546,10 +2546,9 @@ void Save_SCR(void)
 | 
				
			|||||||
	unsigned char r1;
 | 
						unsigned char r1;
 | 
				
			||||||
	int cpc_mode;
 | 
						int cpc_mode;
 | 
				
			||||||
	FILE* file;
 | 
						FILE* file;
 | 
				
			||||||
        char filename[MAX_PATH_CHARACTERS];
 | 
						char filename[MAX_PATH_CHARACTERS];
 | 
				
			||||||
        long file_size;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Get_full_filename(filename,0);
 | 
						Get_full_filename(filename,0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch(Pixel_ratio)
 | 
						switch(Pixel_ratio)
 | 
				
			||||||
@ -2573,5 +2572,7 @@ void Save_SCR(void)
 | 
				
			|||||||
	Write_bytes(file, output, outsize);
 | 
						Write_bytes(file, output, outsize);
 | 
				
			||||||
	fclose(file);
 | 
						fclose(file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						free (output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	File_error = 0;
 | 
						File_error = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user