SCx: Doxygen + fix of file extension selection
This commit is contained in:
parent
bc4c2db2e4
commit
760cd0d960
@ -89,6 +89,7 @@
|
|||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "pages.h"
|
#include "pages.h"
|
||||||
#include "windows.h" // Best_color()
|
#include "windows.h" // Best_color()
|
||||||
|
#include "unicode.h"
|
||||||
#include "fileformats.h"
|
#include "fileformats.h"
|
||||||
#include "oldies.h"
|
#include "oldies.h"
|
||||||
#include "bitcount.h"
|
#include "bitcount.h"
|
||||||
@ -5973,26 +5974,34 @@ void Save_PCX(T_IO_Context * context)
|
|||||||
|
|
||||||
|
|
||||||
//////////////////////////////////// SCx ////////////////////////////////////
|
//////////////////////////////////// SCx ////////////////////////////////////
|
||||||
|
/**
|
||||||
|
* @defgroup SCx SCx format
|
||||||
|
* @ingroup loadsaveformats
|
||||||
|
* ColoRix VGA Paint SCx File Format
|
||||||
|
*
|
||||||
|
* file extensions are sci, scq, scf, scn, sco
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// SCx header data
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
byte Filler1[4];
|
byte Filler1[4]; ///< "RIX3"
|
||||||
word Width;
|
word Width; ///< Image Width
|
||||||
word Height;
|
word Height; ///< Image Height
|
||||||
byte PaletteType; // M P RGB PIX 0xAF = VGA
|
byte PaletteType; ///< M P RGB PIX 0xAF = VGA
|
||||||
byte StorageType; // 00 = Linear (1 byte per pixel) 01,02 Planar 03 text 80 Compressed 40 extension block 20 encrypted
|
byte StorageType; ///< 00 = Linear (1 byte per pixel) 01,02 Planar 03 text 80 Compressed 40 extension block 20 encrypted
|
||||||
} T_SCx_Header;
|
} T_SCx_Header;
|
||||||
|
|
||||||
// -- Tester si un fichier est au format SCx --------------------------------
|
/// Test if a file is SCx format
|
||||||
void Test_SCx(T_IO_Context * context, FILE * file)
|
void Test_SCx(T_IO_Context * context, FILE * file)
|
||||||
{
|
{
|
||||||
//byte Signature[3];
|
|
||||||
T_SCx_Header SCx_header;
|
T_SCx_Header SCx_header;
|
||||||
|
|
||||||
(void)context;
|
(void)context;
|
||||||
File_error=1;
|
File_error=1;
|
||||||
|
|
||||||
// Ouverture du fichier
|
// read and check header
|
||||||
// Lecture et vérification de la signature
|
|
||||||
if (Read_bytes(file,SCx_header.Filler1,4)
|
if (Read_bytes(file,SCx_header.Filler1,4)
|
||||||
&& Read_word_le(file, &(SCx_header.Width))
|
&& Read_word_le(file, &(SCx_header.Width))
|
||||||
&& Read_word_le(file, &(SCx_header.Height))
|
&& Read_word_le(file, &(SCx_header.Height))
|
||||||
@ -6007,7 +6016,7 @@ void Test_SCx(T_IO_Context * context, FILE * file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- Lire un fichier au format SCx -----------------------------------------
|
/// Read a SCx file
|
||||||
void Load_SCx(T_IO_Context * context)
|
void Load_SCx(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
@ -6099,14 +6108,15 @@ void Load_SCx(T_IO_Context * context)
|
|||||||
File_error=1;
|
File_error=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Sauver un fichier au format SCx ---------------------------------------
|
/// Save a SCx file
|
||||||
void Save_SCx(T_IO_Context * context)
|
void Save_SCx(T_IO_Context * context)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
short x_pos,y_pos;
|
short x_pos,y_pos;
|
||||||
T_SCx_Header SCx_header;
|
T_SCx_Header SCx_header;
|
||||||
byte last_char;
|
size_t last_char;
|
||||||
|
|
||||||
|
// replace the '?' in file extension with the right letter
|
||||||
last_char = strlen(context->File_name) - 1;
|
last_char = strlen(context->File_name) - 1;
|
||||||
if (context->File_name[last_char] == '?')
|
if (context->File_name[last_char] == '?')
|
||||||
{
|
{
|
||||||
@ -6129,16 +6139,26 @@ void Save_SCx(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// makes it same case as the previous character
|
||||||
|
if (last_char > 0)
|
||||||
|
context->File_name[last_char] |= (context->File_name[last_char - 1] & 32);
|
||||||
|
// also fix the unicode file name
|
||||||
|
if (context->File_name_unicode != NULL && context->File_name_unicode[0] != 0)
|
||||||
|
{
|
||||||
|
size_t ulen = Unicode_strlen(context->File_name_unicode);
|
||||||
|
if (ulen > 1)
|
||||||
|
context->File_name_unicode[ulen - 1] = context->File_name[last_char];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File_error=0;
|
|
||||||
|
|
||||||
// Ouverture du fichier
|
file = Open_file_write(context);
|
||||||
if ((file=Open_file_write(context)))
|
|
||||||
|
if (file != NULL)
|
||||||
{
|
{
|
||||||
T_Palette palette_64;
|
T_Palette palette_64;
|
||||||
|
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
File_error = 0;
|
||||||
memcpy(palette_64, context->Palette, sizeof(T_Palette));
|
memcpy(palette_64, context->Palette, sizeof(T_Palette));
|
||||||
Palette_256_to_64(palette_64);
|
Palette_256_to_64(palette_64);
|
||||||
|
|
||||||
@ -6159,18 +6179,14 @@ void Save_SCx(T_IO_Context * context)
|
|||||||
for (y_pos=0; ((y_pos<context->Height) && (!File_error)); y_pos++)
|
for (y_pos=0; ((y_pos<context->Height) && (!File_error)); y_pos++)
|
||||||
for (x_pos=0; x_pos<context->Width; x_pos++)
|
for (x_pos=0; x_pos<context->Width; x_pos++)
|
||||||
Write_one_byte(file, Get_pixel(context, x_pos, y_pos));
|
Write_one_byte(file, Get_pixel(context, x_pos, y_pos));
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
if (File_error)
|
|
||||||
Remove_file(context);
|
|
||||||
}
|
}
|
||||||
else // Error d'écriture (disque plein ou protégé)
|
else
|
||||||
{
|
{
|
||||||
fclose(file);
|
|
||||||
Remove_file(context);
|
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
}
|
}
|
||||||
|
fclose(file);
|
||||||
|
if (File_error)
|
||||||
|
Remove_file(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -6178,6 +6194,8 @@ void Save_SCx(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @} */
|
||||||
|
|
||||||
//////////////////////////////////// XPM ////////////////////////////////////
|
//////////////////////////////////// XPM ////////////////////////////////////
|
||||||
void Save_XPM(T_IO_Context* context)
|
void Save_XPM(T_IO_Context* context)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user