use Open_file_read()/Open_file_write()
This commit is contained in:
parent
3a0e187d73
commit
74818299a3
@ -73,17 +73,13 @@ static void Load_PNG_Sub(T_IO_Context * context, FILE * file);
|
|||||||
void Test_IMG(T_IO_Context * context)
|
void Test_IMG(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
T_IMG_Header IMG_header;
|
T_IMG_Header IMG_header;
|
||||||
byte signature[6]={0x01,0x00,0x47,0x12,0x6D,0xB0};
|
byte signature[6]={0x01,0x00,0x47,0x12,0x6D,0xB0};
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Lecture et vérification de la signature
|
// Lecture et vérification de la signature
|
||||||
if (Read_bytes(file,IMG_header.Filler1,6)
|
if (Read_bytes(file,IMG_header.Filler1,6)
|
||||||
@ -106,17 +102,15 @@ void Test_IMG(T_IO_Context * context)
|
|||||||
// -- Lire un fichier au format IMG -----------------------------------------
|
// -- Lire un fichier au format IMG -----------------------------------------
|
||||||
void Load_IMG(T_IO_Context * context)
|
void Load_IMG(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
word x_pos,y_pos;
|
word x_pos,y_pos;
|
||||||
long file_size;
|
long file_size;
|
||||||
T_IMG_Header IMG_header;
|
T_IMG_Header IMG_header;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size=File_length_file(file);
|
file_size=File_length_file(file);
|
||||||
|
|
||||||
@ -165,18 +159,15 @@ void Load_IMG(T_IO_Context * context)
|
|||||||
// -- Sauver un fichier au format IMG ---------------------------------------
|
// -- Sauver un fichier au format IMG ---------------------------------------
|
||||||
void Save_IMG(T_IO_Context * context)
|
void Save_IMG(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
short x_pos,y_pos;
|
short x_pos,y_pos;
|
||||||
T_IMG_Header IMG_header;
|
T_IMG_Header IMG_header;
|
||||||
byte signature[6]={0x01,0x00,0x47,0x12,0x6D,0xB0};
|
byte signature[6]={0x01,0x00,0x47,0x12,0x6D,0xB0};
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -208,19 +199,19 @@ void Save_IMG(T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else // Error d'écriture (disque plein ou protégé)
|
else // Error d'écriture (disque plein ou protégé)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,16 +255,13 @@ typedef struct
|
|||||||
void Test_IFF(T_IO_Context * context, const char *sub_type)
|
void Test_IFF(T_IO_Context * context, const char *sub_type)
|
||||||
{
|
{
|
||||||
FILE * IFF_file;
|
FILE * IFF_file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
char format[4];
|
char format[4];
|
||||||
char section[4];
|
char section[4];
|
||||||
dword dummy;
|
dword dummy;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
if ((IFF_file=fopen(filename, "rb")))
|
if ((IFF_file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
do // Dummy loop, so that all breaks jump to end.
|
do // Dummy loop, so that all breaks jump to end.
|
||||||
{
|
{
|
||||||
@ -620,7 +608,6 @@ static void IFF_Set_EHB_Palette(T_IO_Context * context)
|
|||||||
void Load_IFF(T_IO_Context * context)
|
void Load_IFF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE * IFF_file;
|
FILE * IFF_file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
T_IFF_Header header;
|
T_IFF_Header header;
|
||||||
T_IFF_AnimHeader aheader;
|
T_IFF_AnimHeader aheader;
|
||||||
char format[4];
|
char format[4];
|
||||||
@ -657,11 +644,9 @@ void Load_IFF(T_IO_Context * context)
|
|||||||
|
|
||||||
memset(&aheader, 0, sizeof(aheader));
|
memset(&aheader, 0, sizeof(aheader));
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((IFF_file=fopen(filename, "rb")))
|
if ((IFF_file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size=File_length_file(IFF_file);
|
file_size=File_length_file(IFF_file);
|
||||||
|
|
||||||
@ -1973,7 +1958,6 @@ printf("%d x %d = %d %d\n", tiny_width, tiny_height, tiny_width*tiny_height, s
|
|||||||
void Save_IFF(T_IO_Context * context)
|
void Save_IFF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE * IFF_file;
|
FILE * IFF_file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
T_IFF_Header header;
|
T_IFF_Header header;
|
||||||
word x_pos;
|
word x_pos;
|
||||||
word y_pos;
|
word y_pos;
|
||||||
@ -2005,10 +1989,8 @@ void Save_IFF(T_IO_Context * context)
|
|||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((IFF_file=fopen(filename,"wb")))
|
if ((IFF_file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(IFF_file, NULL, _IOFBF, 64*1024);
|
setvbuf(IFF_file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -2188,10 +2170,9 @@ void Save_IFF(T_IO_Context * context)
|
|||||||
fseek(IFF_file,4,SEEK_SET);
|
fseek(IFF_file,4,SEEK_SET);
|
||||||
Write_dword_be(IFF_file,file_size-8);
|
Write_dword_be(IFF_file,file_size-8);
|
||||||
}
|
}
|
||||||
|
else // Il y a eu une erreur lors du compactage => on efface le fichier
|
||||||
|
Remove_file(context);
|
||||||
fclose(IFF_file);
|
fclose(IFF_file);
|
||||||
IFF_file = NULL;
|
|
||||||
if (File_error != 0) // delete file if any error during saving
|
|
||||||
remove(filename);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
File_error=1;
|
File_error=1;
|
||||||
@ -2224,14 +2205,12 @@ typedef struct
|
|||||||
// -- Tester si un fichier est au format BMP --------------------------------
|
// -- Tester si un fichier est au format BMP --------------------------------
|
||||||
void Test_BMP(T_IO_Context * context)
|
void Test_BMP(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_BMP_Header header;
|
T_BMP_Header header;
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
if (Read_bytes(file,&(header.Signature),2) // "BM"
|
if (Read_bytes(file,&(header.Signature),2) // "BM"
|
||||||
&& Read_dword_le(file,&(header.Size_1))
|
&& Read_dword_le(file,&(header.Size_1))
|
||||||
@ -2535,7 +2514,6 @@ static void Load_BMP_Pixels(T_IO_Context * context, FILE * file, unsigned int co
|
|||||||
// -- Charger un fichier au format BMP --------------------------------------
|
// -- Charger un fichier au format BMP --------------------------------------
|
||||||
void Load_BMP(T_IO_Context * context)
|
void Load_BMP(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_BMP_Header header;
|
T_BMP_Header header;
|
||||||
word nb_colors = 0;
|
word nb_colors = 0;
|
||||||
@ -2544,11 +2522,9 @@ void Load_BMP(T_IO_Context * context)
|
|||||||
byte true_color = 0;
|
byte true_color = 0;
|
||||||
dword mask[3]; // R G B
|
dword mask[3]; // R G B
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size=File_length_file(file);
|
file_size=File_length_file(file);
|
||||||
|
|
||||||
@ -2694,7 +2670,6 @@ void Load_BMP(T_IO_Context * context)
|
|||||||
// -- Sauvegarder un fichier au format BMP ----------------------------------
|
// -- Sauvegarder un fichier au format BMP ----------------------------------
|
||||||
void Save_BMP(T_IO_Context * context)
|
void Save_BMP(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_BMP_Header header;
|
T_BMP_Header header;
|
||||||
short x_pos;
|
short x_pos;
|
||||||
@ -2705,10 +2680,9 @@ void Save_BMP(T_IO_Context * context)
|
|||||||
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -2779,12 +2753,12 @@ void Save_BMP(T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2792,7 +2766,7 @@ void Save_BMP(T_IO_Context * context)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2815,7 +2789,6 @@ typedef struct {
|
|||||||
|
|
||||||
void Test_ICO(T_IO_Context * context)
|
void Test_ICO(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
struct {
|
struct {
|
||||||
word Reserved;
|
word Reserved;
|
||||||
@ -2824,9 +2797,8 @@ void Test_ICO(T_IO_Context * context)
|
|||||||
} header;
|
} header;
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
if (Read_word_le(file,&(header.Reserved))
|
if (Read_word_le(file,&(header.Reserved))
|
||||||
&& Read_word_le(file,&(header.Type))
|
&& Read_word_le(file,&(header.Type))
|
||||||
@ -2841,7 +2813,6 @@ void Test_ICO(T_IO_Context * context)
|
|||||||
|
|
||||||
void Load_ICO(T_IO_Context * context)
|
void Load_ICO(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
struct {
|
struct {
|
||||||
word Reserved;
|
word Reserved;
|
||||||
@ -2857,9 +2828,8 @@ void Load_ICO(T_IO_Context * context)
|
|||||||
dword mask[3]; // R G B
|
dword mask[3]; // R G B
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
if (Read_word_le(file,&(header.Reserved))
|
if (Read_word_le(file,&(header.Reserved))
|
||||||
&& Read_word_le(file,&(header.Type))
|
&& Read_word_le(file,&(header.Type))
|
||||||
@ -3042,7 +3012,6 @@ void Load_ICO(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_ICO(T_IO_Context * context)
|
void Save_ICO(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
short x_pos;
|
short x_pos;
|
||||||
short y_pos;
|
short y_pos;
|
||||||
@ -3057,9 +3026,8 @@ void Save_ICO(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if ((file=fopen(filename,"wb")) == NULL)
|
if ((file=Open_file_write(context)) == NULL)
|
||||||
File_error=1;
|
File_error=1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -3158,7 +3126,7 @@ void Save_ICO(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
if (File_error != 0)
|
if (File_error != 0)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3209,15 +3177,13 @@ enum DISPOSAL_METHOD
|
|||||||
|
|
||||||
void Test_GIF(T_IO_Context * context)
|
void Test_GIF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
char signature[6];
|
char signature[6];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
(Read_bytes(file,signature,6)) &&
|
(Read_bytes(file,signature,6)) &&
|
||||||
@ -3334,7 +3300,6 @@ void GIF_new_pixel(T_IO_Context * context, T_GIF_IDB *idb, int is_transparent, b
|
|||||||
|
|
||||||
void Load_GIF(T_IO_Context * context)
|
void Load_GIF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
char signature[6];
|
char signature[6];
|
||||||
|
|
||||||
word * alphabet_stack; // Pile de décodage d'une chaîne
|
word * alphabet_stack; // Pile de décodage d'une chaîne
|
||||||
@ -3378,9 +3343,7 @@ void Load_GIF(T_IO_Context * context)
|
|||||||
|
|
||||||
number_LID=0;
|
number_LID=0;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((GIF_file=Open_file_read(context)))
|
||||||
|
|
||||||
if ((GIF_file=fopen(filename, "rb")))
|
|
||||||
{
|
{
|
||||||
file_size=File_length_file(GIF_file);
|
file_size=File_length_file(GIF_file);
|
||||||
if ( (Read_bytes(GIF_file,signature,6)) &&
|
if ( (Read_bytes(GIF_file,signature,6)) &&
|
||||||
@ -3913,8 +3876,6 @@ void Load_GIF(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_GIF(T_IO_Context * context)
|
void Save_GIF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
|
|
||||||
word * alphabet_prefix; // Table des préfixes des codes
|
word * alphabet_prefix; // Table des préfixes des codes
|
||||||
word * alphabet_suffix; // Table des suffixes des codes
|
word * alphabet_suffix; // Table des suffixes des codes
|
||||||
word * alphabet_daughter; // Table des chaînes filles (plus longues)
|
word * alphabet_daughter; // Table des chaînes filles (plus longues)
|
||||||
@ -3941,9 +3902,7 @@ void Save_GIF(T_IO_Context * context)
|
|||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((GIF_file=Open_file_write(context)))
|
||||||
|
|
||||||
if ((GIF_file=fopen(filename,"wb")))
|
|
||||||
{
|
{
|
||||||
setvbuf(GIF_file, NULL, _IOFBF, 64*1024);
|
setvbuf(GIF_file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -4387,7 +4346,7 @@ void Save_GIF(T_IO_Context * context)
|
|||||||
|
|
||||||
fclose(GIF_file);
|
fclose(GIF_file);
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
|
|
||||||
} // On a pu ouvrir le fichier en écriture
|
} // On a pu ouvrir le fichier en écriture
|
||||||
else
|
else
|
||||||
@ -4426,13 +4385,11 @@ T_PCX_Header PCX_header;
|
|||||||
|
|
||||||
void Test_PCX(T_IO_Context * context)
|
void Test_PCX(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
if (Read_byte(file,&(PCX_header.Manufacturer)) &&
|
if (Read_byte(file,&(PCX_header.Manufacturer)) &&
|
||||||
Read_byte(file,&(PCX_header.Version)) &&
|
Read_byte(file,&(PCX_header.Version)) &&
|
||||||
@ -4506,7 +4463,6 @@ static void Set_CGA_Color(int i, T_Components * comp)
|
|||||||
|
|
||||||
void Load_PCX(T_IO_Context * context)
|
void Load_PCX(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
short line_size;
|
short line_size;
|
||||||
@ -4524,11 +4480,9 @@ void Load_PCX(T_IO_Context * context)
|
|||||||
long image_size;
|
long image_size;
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size=File_length_file(file);
|
file_size=File_length_file(file);
|
||||||
if (Read_byte(file,&(PCX_header.Manufacturer)) &&
|
if (Read_byte(file,&(PCX_header.Manufacturer)) &&
|
||||||
@ -4854,7 +4808,6 @@ void Load_PCX(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_PCX(T_IO_Context * context)
|
void Save_PCX(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
short line_size;
|
short line_size;
|
||||||
@ -4866,11 +4819,9 @@ void Save_PCX(T_IO_Context * context)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -4956,7 +4907,7 @@ void Save_PCX(T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -4978,17 +4929,13 @@ typedef struct
|
|||||||
void Test_SCx(T_IO_Context * context)
|
void Test_SCx(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
//byte Signature[3];
|
//byte Signature[3];
|
||||||
T_SCx_Header SCx_header;
|
T_SCx_Header SCx_header;
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Lecture et vérification de la signature
|
// Lecture et vérification de la signature
|
||||||
if (Read_bytes(file,SCx_header.Filler1,4)
|
if (Read_bytes(file,SCx_header.Filler1,4)
|
||||||
@ -5011,7 +4958,6 @@ void Test_SCx(T_IO_Context * context)
|
|||||||
// -- Lire un fichier au format SCx -----------------------------------------
|
// -- Lire un fichier au format SCx -----------------------------------------
|
||||||
void Load_SCx(T_IO_Context * context)
|
void Load_SCx(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
word x_pos,y_pos;
|
word x_pos,y_pos;
|
||||||
long size,real_size;
|
long size,real_size;
|
||||||
@ -5020,11 +4966,9 @@ void Load_SCx(T_IO_Context * context)
|
|||||||
T_Palette SCx_Palette;
|
T_Palette SCx_Palette;
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size=File_length_file(file);
|
file_size=File_length_file(file);
|
||||||
|
|
||||||
@ -5099,7 +5043,6 @@ void Load_SCx(T_IO_Context * context)
|
|||||||
// -- Sauver un fichier au format SCx ---------------------------------------
|
// -- Sauver un fichier au format SCx ---------------------------------------
|
||||||
void Save_SCx(T_IO_Context * context)
|
void Save_SCx(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
short x_pos,y_pos;
|
short x_pos,y_pos;
|
||||||
T_SCx_Header SCx_header;
|
T_SCx_Header SCx_header;
|
||||||
@ -5128,12 +5071,11 @@ void Save_SCx(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
T_Palette palette_64;
|
T_Palette palette_64;
|
||||||
|
|
||||||
@ -5162,19 +5104,19 @@ void Save_SCx(T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else // Error d'écriture (disque plein ou protégé)
|
else // Error d'écriture (disque plein ou protégé)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5226,15 +5168,12 @@ void Save_XPM(T_IO_Context* context)
|
|||||||
void Test_PNG(T_IO_Context * context)
|
void Test_PNG(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
byte png_header[8];
|
byte png_header[8];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Lecture du header du fichier
|
// Lecture du header du fichier
|
||||||
if (Read_bytes(file,png_header,8))
|
if (Read_bytes(file,png_header,8))
|
||||||
@ -5630,14 +5569,11 @@ static void Load_PNG_Sub(T_IO_Context * context, FILE * file)
|
|||||||
void Load_PNG(T_IO_Context * context)
|
void Load_PNG(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
byte png_header[8];
|
byte png_header[8];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Load header (8 first bytes)
|
// Load header (8 first bytes)
|
||||||
if (Read_bytes(file,png_header,8))
|
if (Read_bytes(file,png_header,8))
|
||||||
@ -5659,7 +5595,6 @@ void Load_PNG(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_PNG(T_IO_Context * context)
|
void Save_PNG(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int y;
|
int y;
|
||||||
byte * pixel_ptr;
|
byte * pixel_ptr;
|
||||||
@ -5669,12 +5604,11 @@ void Save_PNG(T_IO_Context * context)
|
|||||||
byte cycle_data[16*6]; // Storage for color-cycling data, referenced by crng_chunk
|
byte cycle_data[16*6]; // Storage for color-cycling data, referenced by crng_chunk
|
||||||
static png_bytep * Row_pointers;
|
static png_bytep * Row_pointers;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Row_pointers = NULL;
|
Row_pointers = NULL;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -5834,7 +5768,7 @@ void Save_PNG(T_IO_Context * context)
|
|||||||
// S'il y a eu une erreur de sauvegarde, on ne va tout de même pas laisser
|
// S'il y a eu une erreur de sauvegarde, on ne va tout de même pas laisser
|
||||||
// ce fichier pourri trainait... Ca fait pas propre.
|
// ce fichier pourri trainait... Ca fait pas propre.
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
|
|
||||||
if (Row_pointers)
|
if (Row_pointers)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -48,15 +48,13 @@
|
|||||||
// -- Test wether a file is in PAL format --------------------------------
|
// -- Test wether a file is in PAL format --------------------------------
|
||||||
void Test_PAL(T_IO_Context * context)
|
void Test_PAL(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
|
char buffer[32];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
long file_size;
|
long file_size;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
|
|
||||||
if ((file = fopen(filename, "rb")))
|
if ((file = Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size = File_length_file(file);
|
file_size = File_length_file(file);
|
||||||
// First check for GrafX2 legacy palette format. The simplest one, 768 bytes
|
// First check for GrafX2 legacy palette format. The simplest one, 768 bytes
|
||||||
@ -64,23 +62,25 @@ void Test_PAL(T_IO_Context * context)
|
|||||||
// header at all, so we check for the file size.
|
// header at all, so we check for the file size.
|
||||||
if (file_size == sizeof(T_Palette))
|
if (file_size == sizeof(T_Palette))
|
||||||
File_error = 0;
|
File_error = 0;
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
// Bigger (or smaller ?) files may be in other formats. These have an
|
// Bigger (or smaller ?) files may be in other formats. These have an
|
||||||
// header, so look for it.
|
// header, so look for it.
|
||||||
fread(filename, 1, 8, file);
|
fread(buffer, 1, 8, file);
|
||||||
if (strncmp(filename,"JASC-PAL",8) == 0)
|
if (strncmp(buffer,"JASC-PAL",8) == 0)
|
||||||
{
|
{
|
||||||
// JASC file format, used by Paint Shop Pro and GIMP. This is also the
|
// JASC file format, used by Paint Shop Pro and GIMP. This is also the
|
||||||
// one used for saving, as it brings greater interoperability.
|
// one used for saving, as it brings greater interoperability.
|
||||||
File_error = 0;
|
File_error = 0;
|
||||||
} else if(strncmp(filename,"RIFF", 4) == 0)
|
}
|
||||||
|
else if(strncmp(buffer,"RIFF", 4) == 0)
|
||||||
{
|
{
|
||||||
// Microsoft RIFF file
|
// Microsoft RIFF file
|
||||||
// This is a data container (similar to IFF). We only check the first
|
// This is a data container (similar to IFF). We only check the first
|
||||||
// chunk header, and give up if that's not a palette.
|
// chunk header, and give up if that's not a palette.
|
||||||
fseek(file, 8, SEEK_SET);
|
fseek(file, 8, SEEK_SET);
|
||||||
fread(filename, 1, 8, file);
|
fread(buffer, 1, 8, file);
|
||||||
if (strncmp(filename, "PAL data", 8) == 0)
|
if (strncmp(buffer, "PAL data", 8) == 0)
|
||||||
{
|
{
|
||||||
File_error = 0;
|
File_error = 0;
|
||||||
}
|
}
|
||||||
@ -92,22 +92,20 @@ void Test_PAL(T_IO_Context * context)
|
|||||||
|
|
||||||
void Test_GPL(T_IO_Context * context)
|
void Test_GPL(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
|
char buffer[16];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
long file_size;
|
long file_size;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
|
|
||||||
if ((file = fopen(filename, "rb")))
|
if ((file = Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size = File_length_file(file);
|
file_size = File_length_file(file);
|
||||||
if (file_size > 33) {
|
if (file_size > 33) {
|
||||||
// minimum header length == 33
|
// minimum header length == 33
|
||||||
// "GIMP Palette" == 12
|
// "GIMP Palette" == 12
|
||||||
fread(filename, 1, 12, file);
|
fread(buffer, 1, 12, file);
|
||||||
if (strncmp(filename,"GIMP Palette",12) == 0)
|
if (strncmp(buffer,"GIMP Palette",12) == 0)
|
||||||
File_error = 0;
|
File_error = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,11 +143,10 @@ void Load_GPL(T_IO_Context * context)
|
|||||||
char filename[MAX_PATH_CHARACTERS]; // full filename
|
char filename[MAX_PATH_CHARACTERS]; // full filename
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
fread(filename, 1, 13, file);
|
fread(filename, 1, 13, file);
|
||||||
if (strncmp(filename,"GIMP Palette\n",13) == 0)
|
if (strncmp(filename,"GIMP Palette\n",13) == 0)
|
||||||
@ -239,7 +236,7 @@ Save_GPL (T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -258,11 +255,10 @@ void Load_PAL(T_IO_Context * context)
|
|||||||
//long file_size; // Taille du fichier
|
//long file_size; // Taille du fichier
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
long file_size = File_length_file(file);
|
long file_size = File_length_file(file);
|
||||||
// Le fichier ne peut être au format PAL que si sa taille vaut 768 octets
|
// Le fichier ne peut être au format PAL que si sa taille vaut 768 octets
|
||||||
@ -363,7 +359,7 @@ void Save_PAL(T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -393,16 +389,13 @@ typedef struct
|
|||||||
void Test_PKM(T_IO_Context * context)
|
void Test_PKM(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
T_PKM_Header header;
|
T_PKM_Header header;
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Lecture du header du fichier
|
// Lecture du header du fichier
|
||||||
if (Read_bytes(file,&header.Ident,3) &&
|
if (Read_bytes(file,&header.Ident,3) &&
|
||||||
@ -429,7 +422,6 @@ void Test_PKM(T_IO_Context * context)
|
|||||||
void Load_PKM(T_IO_Context * context)
|
void Load_PKM(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
T_PKM_Header header;
|
T_PKM_Header header;
|
||||||
byte color;
|
byte color;
|
||||||
byte temp_byte;
|
byte temp_byte;
|
||||||
@ -441,11 +433,9 @@ void Load_PKM(T_IO_Context * context)
|
|||||||
dword Taille_pack;
|
dword Taille_pack;
|
||||||
long file_size;
|
long file_size;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size=File_length_file(file);
|
file_size=File_length_file(file);
|
||||||
|
|
||||||
@ -679,7 +669,6 @@ void Load_PKM(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_PKM(T_IO_Context * context)
|
void Save_PKM(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_PKM_Header header;
|
T_PKM_Header header;
|
||||||
dword Compteur_de_pixels;
|
dword Compteur_de_pixels;
|
||||||
@ -707,12 +696,10 @@ void Save_PKM(T_IO_Context * context)
|
|||||||
header.Jump+=comment_size+2;
|
header.Jump+=comment_size+2;
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -828,7 +815,7 @@ void Save_PKM(T_IO_Context * context)
|
|||||||
// S'il y a eu une erreur de sauvegarde, on ne va tout de même pas laisser
|
// S'il y a eu une erreur de sauvegarde, on ne va tout de même pas laisser
|
||||||
// ce fichier pourri traîner... Ca fait pas propre.
|
// ce fichier pourri traîner... Ca fait pas propre.
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -856,7 +843,6 @@ typedef struct
|
|||||||
|
|
||||||
void Test_CEL(T_IO_Context * context)
|
void Test_CEL(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
int size;
|
int size;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_CEL_Header1 header1;
|
T_CEL_Header1 header1;
|
||||||
@ -864,19 +850,13 @@ void Test_CEL(T_IO_Context * context)
|
|||||||
int file_size;
|
int file_size;
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
file_size=File_length(filename);
|
|
||||||
if (file_size==0)
|
|
||||||
{
|
|
||||||
File_error = 1; // Si on ne peut pas faire de stat il vaut mieux laisser tomber
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! (file=fopen(filename, "rb")))
|
if (! (file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
file_size = File_length_file(file);
|
||||||
if (Read_word_le(file,&header1.Width) &&
|
if (Read_word_le(file,&header1.Width) &&
|
||||||
Read_word_le(file,&header1.Height) )
|
Read_word_le(file,&header1.Height) )
|
||||||
{
|
{
|
||||||
@ -921,7 +901,6 @@ void Test_CEL(T_IO_Context * context)
|
|||||||
|
|
||||||
void Load_CEL(T_IO_Context * context)
|
void Load_CEL(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_CEL_Header1 header1;
|
T_CEL_Header1 header1;
|
||||||
T_CEL_Header2 header2;
|
T_CEL_Header2 header2;
|
||||||
@ -932,8 +911,7 @@ void Load_CEL(T_IO_Context * context)
|
|||||||
const long int header_size = 4;
|
const long int header_size = 4;
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((file=Open_file_read(context)))
|
||||||
if ((file=fopen(filename, "rb")))
|
|
||||||
{
|
{
|
||||||
if (Read_word_le(file,&(header1.Width))
|
if (Read_word_le(file,&(header1.Width))
|
||||||
&& Read_word_le(file,&(header1.Height)))
|
&& Read_word_le(file,&(header1.Height)))
|
||||||
@ -1050,7 +1028,6 @@ void Load_CEL(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_CEL(T_IO_Context * context)
|
void Save_CEL(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_CEL_Header1 header1;
|
T_CEL_Header1 header1;
|
||||||
T_CEL_Header2 header2;
|
T_CEL_Header2 header2;
|
||||||
@ -1064,8 +1041,7 @@ void Save_CEL(T_IO_Context * context)
|
|||||||
Count_used_colors(color_usage);
|
Count_used_colors(color_usage);
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((file=Open_file_write(context)))
|
||||||
if ((file=fopen(filename,"wb")))
|
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -1158,7 +1134,7 @@ void Save_CEL(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
File_error=1;
|
File_error=1;
|
||||||
@ -1182,7 +1158,6 @@ typedef struct
|
|||||||
|
|
||||||
void Test_KCF(T_IO_Context * context)
|
void Test_KCF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_KCF_Header header1;
|
T_KCF_Header header1;
|
||||||
T_CEL_Header2 header2;
|
T_CEL_Header2 header2;
|
||||||
@ -1190,8 +1165,7 @@ void Test_KCF(T_IO_Context * context)
|
|||||||
int color_index;
|
int color_index;
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((file=Open_file_read(context)))
|
||||||
if ((file=fopen(filename, "rb")))
|
|
||||||
{
|
{
|
||||||
if (File_length_file(file)==320)
|
if (File_length_file(file)==320)
|
||||||
{
|
{
|
||||||
@ -1241,7 +1215,6 @@ void Test_KCF(T_IO_Context * context)
|
|||||||
|
|
||||||
void Load_KCF(T_IO_Context * context)
|
void Load_KCF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_KCF_Header header1;
|
T_KCF_Header header1;
|
||||||
T_CEL_Header2 header2;
|
T_CEL_Header2 header2;
|
||||||
@ -1253,8 +1226,7 @@ void Load_KCF(T_IO_Context * context)
|
|||||||
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((file=Open_file_read(context)))
|
||||||
if ((file=fopen(filename, "rb")))
|
|
||||||
{
|
{
|
||||||
file_size=File_length_file(file);
|
file_size=File_length_file(file);
|
||||||
if (file_size==320)
|
if (file_size==320)
|
||||||
@ -1363,7 +1335,6 @@ void Load_KCF(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_KCF(T_IO_Context * context)
|
void Save_KCF(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
T_KCF_Header header1;
|
T_KCF_Header header1;
|
||||||
T_CEL_Header2 header2;
|
T_CEL_Header2 header2;
|
||||||
@ -1377,8 +1348,7 @@ void Save_KCF(T_IO_Context * context)
|
|||||||
Count_used_colors(color_usage);
|
Count_used_colors(color_usage);
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
if ((file=Open_file_write(context)))
|
||||||
if ((file=fopen(filename,"wb")))
|
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
// Sauvegarde de la palette
|
// Sauvegarde de la palette
|
||||||
@ -1445,7 +1415,7 @@ void Save_KCF(T_IO_Context * context)
|
|||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
if (File_error)
|
if (File_error)
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
File_error=1;
|
File_error=1;
|
||||||
@ -1659,17 +1629,14 @@ void PI1_save_ranges(T_IO_Context * context, byte * buffer, int size)
|
|||||||
void Test_PI1(T_IO_Context * context)
|
void Test_PI1(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE * file; // Fichier du fichier
|
FILE * file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
int size; // Taille du fichier
|
int size; // Taille du fichier
|
||||||
word resolution; // Résolution de l'image
|
word resolution; // Résolution de l'image
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Vérification de la taille
|
// Vérification de la taille
|
||||||
size=File_length_file(file);
|
size=File_length_file(file);
|
||||||
@ -1691,17 +1658,14 @@ void Test_PI1(T_IO_Context * context)
|
|||||||
// -- Lire un fichier au format PI1 -----------------------------------------
|
// -- Lire un fichier au format PI1 -----------------------------------------
|
||||||
void Load_PI1(T_IO_Context * context)
|
void Load_PI1(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
word x_pos,y_pos;
|
word x_pos,y_pos;
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
byte * ptr;
|
byte * ptr;
|
||||||
byte pixels[320];
|
byte pixels[320];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// allocation d'un buffer mémoire
|
// allocation d'un buffer mémoire
|
||||||
buffer=(byte *)malloc(32034);
|
buffer=(byte *)malloc(32034);
|
||||||
@ -1751,18 +1715,15 @@ void Load_PI1(T_IO_Context * context)
|
|||||||
// -- Sauver un fichier au format PI1 ---------------------------------------
|
// -- Sauver un fichier au format PI1 ---------------------------------------
|
||||||
void Save_PI1(T_IO_Context * context)
|
void Save_PI1(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
short x_pos,y_pos;
|
short x_pos,y_pos;
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
byte * ptr;
|
byte * ptr;
|
||||||
byte pixels[320];
|
byte pixels[320];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -1800,7 +1761,7 @@ void Save_PI1(T_IO_Context * context)
|
|||||||
else // Error d'écriture (disque plein ou protégé)
|
else // Error d'écriture (disque plein ou protégé)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
// Libération du buffer mémoire
|
// Libération du buffer mémoire
|
||||||
@ -1810,7 +1771,7 @@ void Save_PI1(T_IO_Context * context)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1984,17 +1945,14 @@ void PC1_1line_to_4bp(byte * src,byte * dst0,byte * dst1,byte * dst2,byte * dst3
|
|||||||
void Test_PC1(T_IO_Context * context)
|
void Test_PC1(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
int size; // Taille du fichier
|
int size; // Taille du fichier
|
||||||
word resolution; // Résolution de l'image
|
word resolution; // Résolution de l'image
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Vérification de la taille
|
// Vérification de la taille
|
||||||
size=File_length_file(file);
|
size=File_length_file(file);
|
||||||
@ -2016,7 +1974,6 @@ void Test_PC1(T_IO_Context * context)
|
|||||||
// -- Lire un fichier au format PC1 -----------------------------------------
|
// -- Lire un fichier au format PC1 -----------------------------------------
|
||||||
void Load_PC1(T_IO_Context * context)
|
void Load_PC1(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int size;
|
int size;
|
||||||
word x_pos,y_pos;
|
word x_pos,y_pos;
|
||||||
@ -2025,10 +1982,8 @@ void Load_PC1(T_IO_Context * context)
|
|||||||
byte * ptr;
|
byte * ptr;
|
||||||
byte pixels[320];
|
byte pixels[320];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
size=File_length_file(file);
|
size=File_length_file(file);
|
||||||
// allocation des buffers mémoire
|
// allocation des buffers mémoire
|
||||||
@ -2091,7 +2046,6 @@ void Load_PC1(T_IO_Context * context)
|
|||||||
// -- Sauver un fichier au format PC1 ---------------------------------------
|
// -- Sauver un fichier au format PC1 ---------------------------------------
|
||||||
void Save_PC1(T_IO_Context * context)
|
void Save_PC1(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int size;
|
int size;
|
||||||
short x_pos,y_pos;
|
short x_pos,y_pos;
|
||||||
@ -2100,11 +2054,9 @@ void Save_PC1(T_IO_Context * context)
|
|||||||
byte * ptr;
|
byte * ptr;
|
||||||
byte pixels[320];
|
byte pixels[320];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -2146,7 +2098,7 @@ void Save_PC1(T_IO_Context * context)
|
|||||||
else // Error d'écriture (disque plein ou protégé)
|
else // Error d'écriture (disque plein ou protégé)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
// Libération des buffers mémoire
|
// Libération des buffers mémoire
|
||||||
@ -2157,7 +2109,7 @@ void Save_PC1(T_IO_Context * context)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2168,17 +2120,14 @@ void Save_PC1(T_IO_Context * context)
|
|||||||
void Test_NEO(T_IO_Context * context)
|
void Test_NEO(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file; // Fichier du fichier
|
FILE *file; // Fichier du fichier
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
int size; // Taille du fichier
|
int size; // Taille du fichier
|
||||||
word resolution; // Résolution de l'image
|
word resolution; // Résolution de l'image
|
||||||
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// Vérification de la taille
|
// Vérification de la taille
|
||||||
size=File_length_file(file);
|
size=File_length_file(file);
|
||||||
@ -2206,17 +2155,14 @@ void Test_NEO(T_IO_Context * context)
|
|||||||
|
|
||||||
void Load_NEO(T_IO_Context * context)
|
void Load_NEO(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
word x_pos,y_pos;
|
word x_pos,y_pos;
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
byte * ptr;
|
byte * ptr;
|
||||||
byte pixels[320];
|
byte pixels[320];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
if ((file=fopen(filename, "rb")))
|
if ((file=Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// allocation d'un buffer mémoire
|
// allocation d'un buffer mémoire
|
||||||
buffer=(byte *)malloc(32128);
|
buffer=(byte *)malloc(32128);
|
||||||
@ -2264,18 +2210,15 @@ void Load_NEO(T_IO_Context * context)
|
|||||||
|
|
||||||
void Save_NEO(T_IO_Context * context)
|
void Save_NEO(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS]; // Nom complet du fichier
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
short x_pos,y_pos;
|
short x_pos,y_pos;
|
||||||
byte * buffer;
|
byte * buffer;
|
||||||
byte * ptr;
|
byte * ptr;
|
||||||
byte pixels[320];
|
byte pixels[320];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error=0;
|
File_error=0;
|
||||||
// Ouverture du fichier
|
// Ouverture du fichier
|
||||||
if ((file=fopen(filename,"wb")))
|
if ((file=Open_file_write(context)))
|
||||||
{
|
{
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
|
|
||||||
@ -2314,7 +2257,7 @@ void Save_NEO(T_IO_Context * context)
|
|||||||
else // Error d'écriture (disque plein ou protégé)
|
else // Error d'écriture (disque plein ou protégé)
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
// Libération du buffer mémoire
|
// Libération du buffer mémoire
|
||||||
@ -2324,7 +2267,7 @@ void Save_NEO(T_IO_Context * context)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
fclose(file);
|
||||||
remove(filename);
|
Remove_file(context);
|
||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2334,12 +2277,9 @@ void Save_NEO(T_IO_Context * context)
|
|||||||
void Test_C64(T_IO_Context * context)
|
void Test_C64(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
long file_size;
|
long file_size;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
file = Open_file_read(context);
|
||||||
|
|
||||||
file = fopen(filename,"rb");
|
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
@ -2519,7 +2459,6 @@ void Load_C64_fli(T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *c
|
|||||||
void Load_C64(T_IO_Context * context)
|
void Load_C64(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
long file_size;
|
long file_size;
|
||||||
byte hasLoadAddr=0;
|
byte hasLoadAddr=0;
|
||||||
int loadFormat=0;
|
int loadFormat=0;
|
||||||
@ -2528,7 +2467,7 @@ void Load_C64(T_IO_Context * context)
|
|||||||
|
|
||||||
|
|
||||||
// Palette from http://www.pepto.de/projects/colorvic/
|
// Palette from http://www.pepto.de/projects/colorvic/
|
||||||
byte pal[48]={
|
static const byte pal[48]={
|
||||||
0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00,
|
||||||
0xFF, 0xFF, 0xFF,
|
0xFF, 0xFF, 0xFF,
|
||||||
0x68, 0x37, 0x2B,
|
0x68, 0x37, 0x2B,
|
||||||
@ -2551,8 +2490,7 @@ void Load_C64(T_IO_Context * context)
|
|||||||
word width=320, height=200;
|
word width=320, height=200;
|
||||||
static byte dummy_screen[1000];
|
static byte dummy_screen[1000];
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
file = Open_file_read(context);
|
||||||
file = fopen(filename,"rb");
|
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
@ -2802,7 +2740,7 @@ int Save_C64_window(byte *saveWhat, byte *loadAddr)
|
|||||||
return button==1;
|
return button==1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Save_C64_hires(T_IO_Context *context, char *filename, byte saveWhat, byte loadAddr)
|
int Save_C64_hires(T_IO_Context *context, byte saveWhat, byte loadAddr)
|
||||||
{
|
{
|
||||||
int cx,cy,x,y,c1,c2=0,i,pixel,bits,pos=0;
|
int cx,cy,x,y,c1,c2=0,i,pixel,bits,pos=0;
|
||||||
word numcolors;
|
word numcolors;
|
||||||
@ -2868,7 +2806,7 @@ int Save_C64_hires(T_IO_Context *context, char *filename, byte saveWhat, byte lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(filename,"wb");
|
file = Open_file_write(context);
|
||||||
|
|
||||||
if(!file)
|
if(!file)
|
||||||
{
|
{
|
||||||
@ -2893,7 +2831,7 @@ int Save_C64_hires(T_IO_Context *context, char *filename, byte saveWhat, byte lo
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Save_C64_multi(T_IO_Context *context, char *filename, byte saveWhat, byte loadAddr)
|
int Save_C64_multi(T_IO_Context *context, byte saveWhat, byte loadAddr)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
BITS COLOR INFORMATION COMES FROM
|
BITS COLOR INFORMATION COMES FROM
|
||||||
@ -3046,7 +2984,7 @@ int Save_C64_multi(T_IO_Context *context, char *filename, byte saveWhat, byte lo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(filename,"wb");
|
file = Open_file_write(context);
|
||||||
|
|
||||||
if(!file)
|
if(!file)
|
||||||
{
|
{
|
||||||
@ -3080,7 +3018,7 @@ int Save_C64_multi(T_IO_Context *context, char *filename, byte saveWhat, byte lo
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Save_C64_fli(char *filename, byte saveWhat, byte loadAddr)
|
int Save_C64_fli(T_IO_Context * context, byte saveWhat, byte loadAddr)
|
||||||
{
|
{
|
||||||
|
|
||||||
FILE *file;
|
FILE *file;
|
||||||
@ -3094,7 +3032,7 @@ int Save_C64_fli(char *filename, byte saveWhat, byte loadAddr)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
file = fopen(filename,"wb");
|
file = Open_file_write(context);
|
||||||
|
|
||||||
if(!file)
|
if(!file)
|
||||||
{
|
{
|
||||||
@ -3133,11 +3071,8 @@ int Save_C64_fli(char *filename, byte saveWhat, byte loadAddr)
|
|||||||
|
|
||||||
void Save_C64(T_IO_Context * context)
|
void Save_C64(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
static byte saveWhat=0, loadAddr=0;
|
static byte saveWhat=0, loadAddr=0;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
if (((context->Width!=320) && (context->Width!=160)) || context->Height!=200)
|
if (((context->Width!=320) && (context->Width!=160)) || context->Height!=200)
|
||||||
{
|
{
|
||||||
Warning_message("must be 320x200 or 160x200");
|
Warning_message("must be 320x200 or 160x200");
|
||||||
@ -3151,14 +3086,14 @@ void Save_C64(T_IO_Context * context)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcasecmp(filename + strlen(filename) - 4, ".fli") == 0)
|
if (strcasecmp(context->File_name + strlen(context->File_name) - 4, ".fli") == 0)
|
||||||
{
|
{
|
||||||
// FIXME moving FLI to a separate format in the fileselector would be smarter
|
// FIXME moving FLI to a separate format in the fileselector would be smarter
|
||||||
File_error = Save_C64_fli(filename,saveWhat,loadAddr);
|
File_error = Save_C64_fli(context, saveWhat, loadAddr);
|
||||||
} else if (context->Width==320)
|
} else if (context->Width==320)
|
||||||
File_error = Save_C64_hires(context,filename,saveWhat,loadAddr);
|
File_error = Save_C64_hires(context, saveWhat, loadAddr);
|
||||||
else {
|
else {
|
||||||
File_error = Save_C64_multi(context, filename,saveWhat,loadAddr);
|
File_error = Save_C64_multi(context, saveWhat, loadAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3221,9 +3156,6 @@ void Save_SCR(T_IO_Context * context)
|
|||||||
unsigned char r1;
|
unsigned char r1;
|
||||||
int cpc_mode;
|
int cpc_mode;
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
|
|
||||||
switch(Pixel_ratio)
|
switch(Pixel_ratio)
|
||||||
@ -3244,7 +3176,7 @@ void Save_SCR(T_IO_Context * context)
|
|||||||
|
|
||||||
output = raw2crtc(context, cpc_mode, 7, &outsize, &r1, 0x0C, 0);
|
output = raw2crtc(context, cpc_mode, 7, &outsize, &r1, 0x0C, 0);
|
||||||
|
|
||||||
file = fopen(filename,"wb");
|
file = Open_file_write(context);
|
||||||
Write_bytes(file, output, outsize);
|
Write_bytes(file, output, outsize);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
@ -3262,14 +3194,11 @@ void Test_CM5(T_IO_Context * context)
|
|||||||
{
|
{
|
||||||
// check cm5 file size == 2049 bytes
|
// check cm5 file size == 2049 bytes
|
||||||
FILE *file;
|
FILE *file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
|
||||||
long file_size;
|
long file_size;
|
||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
|
|
||||||
if ((file = fopen(filename, "rb")))
|
if ((file = Open_file_read(context)))
|
||||||
{
|
{
|
||||||
file_size = File_length_file(file);
|
file_size = File_length_file(file);
|
||||||
if (file_size == 2049)
|
if (file_size == 2049)
|
||||||
@ -3297,7 +3226,7 @@ void Load_CM5(T_IO_Context* context)
|
|||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
Get_full_filename(filename, context->File_name, context->File_directory);
|
||||||
|
|
||||||
if (!(file = fopen(filename, "rb")))
|
if (!(file = Open_file_read(context)))
|
||||||
{
|
{
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
return;
|
return;
|
||||||
@ -3452,7 +3381,7 @@ void Save_CM5(T_IO_Context* context)
|
|||||||
// Layer 4 : 1 color / 48x1 block
|
// Layer 4 : 1 color / 48x1 block
|
||||||
// TODO: handle filesize
|
// TODO: handle filesize
|
||||||
|
|
||||||
if (!(file = fopen(filename,"wb")))
|
if (!(file = Open_file_write(context)))
|
||||||
{
|
{
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
return;
|
return;
|
||||||
@ -3536,11 +3465,9 @@ void Test_PPH(T_IO_Context * context)
|
|||||||
int w;
|
int w;
|
||||||
int expected;
|
int expected;
|
||||||
|
|
||||||
Get_full_filename(buffer, context->File_name, context->File_directory);
|
|
||||||
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
|
|
||||||
if ((file = fopen(buffer, "rb")))
|
if ((file = Open_file_read(context)))
|
||||||
{
|
{
|
||||||
// First check file size is large enough to hold the header
|
// First check file size is large enough to hold the header
|
||||||
file_size = File_length_file(file);
|
file_size = File_length_file(file);
|
||||||
@ -3665,7 +3592,7 @@ void Load_PPH(T_IO_Context* context)
|
|||||||
|
|
||||||
Get_full_filename(filename, context->File_name, context->File_directory);
|
Get_full_filename(filename, context->File_name, context->File_directory);
|
||||||
|
|
||||||
if (!(file = fopen(filename, "rb")))
|
if (!(file = Open_file_read(context)))
|
||||||
{
|
{
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
return;
|
return;
|
||||||
@ -3786,7 +3713,7 @@ void Load_PPH(T_IO_Context* context)
|
|||||||
// Load the picture data
|
// Load the picture data
|
||||||
// There are two pages, each storing bytes in the CPC vram format but lines in
|
// There are two pages, each storing bytes in the CPC vram format but lines in
|
||||||
// linear order.
|
// linear order.
|
||||||
ext = filename + strlen(filename) - 3;
|
ext = filename + strlen(filename) - 3; // TODO : make a function to load file with another extension !
|
||||||
ext[0] = 'O';
|
ext[0] = 'O';
|
||||||
ext[1] = 'D';
|
ext[1] = 'D';
|
||||||
ext[2] = 'D';
|
ext[2] = 'D';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user