GrafX2 2.9.3227
The ultimate 256-color painting program
|
Support for Amstrad CPC/CPC+ picture formats. More...
Data Structures | |
struct | sgx_data |
Structure for current information about loading SGX file. More... | |
Typedefs | |
typedef int(* | Read_SGX_Callback) (struct sgx_data *, word, word, word, word, word, byte) |
Callback function for Read_SGX() More... | |
Functions | |
void | Test_SGX (T_IO_Context *context, FILE *file) |
Test for SGX file (SymbOS) More... | |
static void | Set_SGX_Palette (T_IO_Context *context) |
static int | Read_SGX (struct sgx_data *data, Read_SGX_Callback cb) |
Read a SGX file structure. More... | |
int | SGX_Get_dimensions (struct sgx_data *data, word posx, word posy, word width, word height, word byte_width, byte ncolors) |
Only skip bytes. More... | |
int | SGX_Load_Picture (struct sgx_data *data, word posx, word posy, word width, word height, word byte_width, byte ncolors) |
Set the pixels. More... | |
void | Load_SGX (T_IO_Context *context) |
static int | Save_SGX_Sub (T_IO_Context *context, FILE *file, word n_colors) |
Write SGX file format as specified here : http://www.cpcwiki.eu/index.php/Format:SGX_(SymbOS_graphic_files) More... | |
void | Save_SGX (T_IO_Context *context) |
void | Test_SCR (T_IO_Context *context, FILE *file) |
Test for SCR file (Amstrad CPC) More... | |
static int | Depack_CPC_LZW (byte *dst, FILE *file) |
Unpack LZ streams from CPCconvImg v0.x (Demoniak/iMPACT!) More... | |
void | Load_SCR (T_IO_Context *context) |
Load Advanced OCP Art Studio files (Amstrad CPC) More... | |
void | Save_SCR (T_IO_Context *context) |
Save Amstrad SCR file. More... | |
void | Test_GOS (T_IO_Context *context, FILE *file) |
Test for GO1/GO2/KIT - Amstrad Plus Graphos. More... | |
void | Load_GOS (T_IO_Context *context) |
Load GO1/GO2/KIT - Amstrad CPC Plus Graphos. More... | |
void | Save_GOS (T_IO_Context *context) |
void | Test_CM5 (T_IO_Context *context, FILE *file) |
Test for CM5 - Amstrad CPC "Mode 5" picture. More... | |
void | Load_CM5 (T_IO_Context *context) |
Load Amstrad CPC "Mode 5" picture. More... | |
void | Save_CM5 (T_IO_Context *context) |
Save a CPC Mode 5 picture. More... | |
void | Test_PPH (T_IO_Context *context, FILE *file) |
Amstrad CPC 'PPH' for Perfect Pix. More... | |
static uint8_t | pph_blend (uint8_t a, uint8_t b) |
void | Load_PPH (T_IO_Context *context) |
void | Save_PPH (T_IO_Context *context) |
Not yet implemented. More... | |
Support for Amstrad CPC/CPC+ picture formats.
The Amstrad CPC has 3 video modes :
Supported formats :
Callback function for Read_SGX()
void Test_SGX | ( | T_IO_Context * | context, |
FILE * | file | ||
) |
Test for SGX file (SymbOS)
http://www.cpcwiki.eu/index.php/Format:SGX_(SymbOS_graphic_files)
References File_error, File_length_file(), and Read_bytes().
|
static |
References T_Config::Clear_palette, Config, and T_IO_Context::Palette.
Referenced by Load_SGX().
|
static |
Read a SGX file structure.
References sgx_data::file, GFX2_DEBUG, GFX2_Log(), GFX2_WARNING, sgx_data::height, MAX, sgx_data::ncolors, Read_byte(), Read_word_le(), and sgx_data::width.
Referenced by Load_SGX().
int SGX_Get_dimensions | ( | struct sgx_data * | data, |
word | posx, | ||
word | posy, | ||
word | width, | ||
word | height, | ||
word | byte_width, | ||
byte | ncolors | ||
) |
Only skip bytes.
References sgx_data::file, sgx_data::height, sgx_data::ncolors, and sgx_data::width.
Referenced by Load_SGX().
int SGX_Load_Picture | ( | struct sgx_data * | data, |
word | posx, | ||
word | posy, | ||
word | width, | ||
word | height, | ||
word | byte_width, | ||
byte | ncolors | ||
) |
Set the pixels.
References sgx_data::context, sgx_data::file, sgx_data::height, sgx_data::ncolors, Read_byte(), Set_pixel(), and sgx_data::width.
Referenced by Load_SGX().
void Load_SGX | ( | T_IO_Context * | context | ) |
References sgx_data::context, sgx_data::file, File_error, File_length_file(), sgx_data::file_size, FORMAT_SGX, GFX2_DEBUG, GFX2_Log(), sgx_data::height, sgx_data::ncolors, NULL, Open_file_read(), PIXEL_SIMPLE, Pre_load(), Read_SGX(), Set_SGX_Palette(), SGX_Get_dimensions(), SGX_Load_Picture(), and sgx_data::width.
|
static |
Write SGX file format as specified here : http://www.cpcwiki.eu/index.php/Format:SGX_(SymbOS_graphic_files)
We are using only simple chunks for 4 colors pictures. Chunk dimentions are limited to the ones of simple chunks (252x255), we could go up to 508x65535 with extended chunks.
References sgx_data::context, sgx_data::file, Get_pixel(), GFX2_DEBUG, GFX2_Log(), sgx_data::height, T_IO_Context::Height, MIN, sgx_data::width, T_IO_Context::Width, Write_byte(), and Write_word_le().
Referenced by Save_SGX().
void Save_SGX | ( | T_IO_Context * | context | ) |
void Test_SCR | ( | T_IO_Context * | context, |
FILE * | file | ||
) |
Test for SCR file (Amstrad CPC)
SCR file format is originally from "Advanced OCP Art Studio" : http://www.cpcwiki.eu/index.php/Format:Advanced_OCP_Art_Studio_File_Formats
.WIN "window" format is also supported.
SCR files are normally just a dump of the 16K of video memory. So they are essentially 16 kilobytes of pixel data without any header. To make things more fun, there is an optional compression. This all makes detection a bit fuzzy. However there are various things we can still check:
C7D0: 3a d0 d7 cd 1c bd 21 d1 d7 46 48 cd 38 bc af 21 | :.....!..FH.8..!
C7E0: d1 d7 46 48 f5 e5 cd 32 bc e1 f1 23 3c fe 10 20 | ..FH...2...#<..
C7F0: f1 c3 18 bb 00 00 00 00 00 00 00 00 00 00 00 00 | ................
D7D0: 00 1a 00 0c 03 0b 01 0d 17 10 02 0f 09 19 06 00 | ................
References sgx_data::context, CPC_check_AMSDOS(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, GFX2_DEBUG, GFX2_Log(), GFX2_LogHexDump(), mode, NULL, Open_file_read_with_alternate_ext(), Read_byte(), and Read_bytes().
|
static |
Unpack LZ streams from CPCconvImg v0.x (Demoniak/iMPACT!)
dst | destination buffer |
file | input |
References sgx_data::file, and Read_byte().
Referenced by Load_SCR().
void Load_SCR | ( | T_IO_Context * | context | ) |
Load Advanced OCP Art Studio files (Amstrad CPC)
Standard resolution files (Mode 0 160x200, mode 1 320x200 and mode 2 640x200) are supported. The .PAL file is loaded if available. "MJH" RLE packing is supported. Embedded CRTC registers and palette data from various tools is also supported.
.WIN "window" format is also loaded here and allows different picture sizes.
References T_Config::Clear_palette, Close_window(), T_IO_Context::Comment, COMMENT_SIZE, Config, sgx_data::context, CONTEXT_MAIN_IMAGE, CPC_check_AMSDOS(), CPC_Firmware_to_Hardware_color(), CPC_set_HW_palette(), Depack_CPC_LZW(), Display_cursor(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, FORMAT_SCR, GFX2_DEBUG, GFX2_ERROR, GFX2_INFO, GFX2_is_mem_filled_with(), GFX2_Log(), GFX2_LogHexDump(), GFX2_malloc, GFX2_WARNING, sgx_data::height, INPUT_TYPE_INTEGER, KEY_ESCAPE, KEY_RETURN, LEFT_SIDE, MC_Dark, MC_Light, mode, NULL, Num2str, Open_file_read(), Open_file_read_with_alternate_ext(), Open_window(), T_IO_Context::Palette, PIXEL_SIMPLE, PIXEL_TALL, PIXEL_WIDE, Pre_load(), Print_in_window(), Read_byte(), Read_bytes(), Read_word_le(), Readline(), Set_pixel(), T_IO_Context::Type, Update_window_area, sgx_data::width, Window_attribute2, Window_clicked_button(), Window_dropdown_add_item(), Window_dropdown_clear_items(), Window_height, Window_input_content(), Window_set_dropdown_button(), Window_set_input_button(), Window_set_normal_button(), and Window_width.
void Save_SCR | ( | T_IO_Context * | context | ) |
Save Amstrad SCR file.
guess mode from aspect ratio :
Mode and palette are stored in a .PAL file for compatibility with OCP Art studio.
The picture color index should be 0-15, The CPC Hardware palette is expected to be set (indexes 64 to 95)
If the picture is using overscan (more than 16384 bytes) we produce a iMPdraw v2 format autoloading file. see http://orgams.wikidot.com/le-format-impdraw-v2
If the picture is not using overscan (standard resolutions, < 16384 screen buffer) a BASIC loader is saved.
Add possibility to set R9 value
Add OCP packing support
References sgx_data::context, CPC_compare_colors(), CPC_is_CPC_old_color(), cpc_scr_simple_loader, CPC_set_HW_palette(), CPC_write_AMSDOS_header(), sgx_data::file, File_error, T_IO_Context::File_name, GFX2_DEBUG, GFX2_Log(), GFX2_WARNING, T_IO_Context::Height, impdraw_loader, NULL, Open_file_write(), Open_file_write_with_alternate_ext(), T_IO_Context::Palette, PIXEL_TALL, PIXEL_TALL2, PIXEL_TALL3, PIXEL_WIDE, PIXEL_WIDE2, T_IO_Context::Ratio, raw2crtc(), T_IO_Context::Width, Write_byte(), and Write_bytes().
void Test_GOS | ( | T_IO_Context * | context, |
FILE * | file | ||
) |
Test for GO1/GO2/KIT - Amstrad Plus Graphos.
This format is made of 3 files .KIT hold the palette in "Kit4096" format. There are 16 colors each stored as 12 bit RGB in RB0G order. .GO1 and GO2 hold each half of the picture (top and bottom) The file always cover the whole display of the Plus (192*272 mode 0 pixels) Only mode 0 is possible.
References sgx_data::context, CPC_check_AMSDOS(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, NULL, and Open_file_read_with_alternate_ext().
void Load_GOS | ( | T_IO_Context * | context | ) |
Load GO1/GO2/KIT - Amstrad CPC Plus Graphos.
References T_Config::Clear_palette, Config, sgx_data::context, CPC_check_AMSDOS(), CPC_set_HW_palette(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, FORMAT_GOS, GFX2_malloc, NULL, Open_file_read(), Open_file_read_with_alternate_ext(), T_IO_Context::Palette, PIXEL_WIDE, Pre_load(), Read_byte(), Read_bytes(), Read_word_le(), and Set_pixel().
Referenced by Test_Save().
void Save_GOS | ( | T_IO_Context * | context | ) |
References sgx_data::context, sgx_data::file, File_error, GFX2_DEBUG, GFX2_Log(), T_IO_Context::Height, NULL, Open_file_write(), Open_file_write_with_alternate_ext(), T_IO_Context::Palette, T_IO_Context::Pitch, raw2crtc(), T_IO_Context::Target_address, T_IO_Context::Width, Write_bytes(), and Write_word_le().
void Test_CM5 | ( | T_IO_Context * | context, |
FILE * | file | ||
) |
Test for CM5 - Amstrad CPC "Mode 5" picture.
This is a format designed by SyX. There is one .GFX file in the usual amstrad format and a .CM5 file with the palette, which varies over time.
CM5 file is 2049 bytes, GFX is 18432 bytes.
References sgx_data::context, CPC_check_AMSDOS(), sgx_data::file, File_error, File_length_file(), sgx_data::file_size, NULL, and Open_file_read_with_alternate_ext().
void Load_CM5 | ( | T_IO_Context * | context | ) |
Load Amstrad CPC "Mode 5" picture.
Only support 288x256 resolution as the Mode 5 Viewer app only handles this single resolution.
References T_Config::Clear_palette, Config, sgx_data::context, CONTEXT_MAIN_IMAGE, CONTEXT_PREVIEW, CPC_check_AMSDOS(), CPC_set_HW_palette(), sgx_data::file, File_error, First_color_in_palette, FORMAT_CM5, T_IO_Context::Height, IMAGE_MODE_MODE5, NULL, Open_file_read(), Open_file_read_with_alternate_ext(), T_IO_Context::Palette, PIXEL_SIMPLE, Pre_load(), Read_byte(), Set_image_mode(), Set_loading_layer(), Set_pixel(), T_IO_Context::Type, and T_IO_Context::Width.
void Save_CM5 | ( | T_IO_Context * | context | ) |
Save a CPC Mode 5 picture.
Resolution is fixed to 288x256. The pictures uses 5 layers. 4 for defining the "inks" the 5th to select one of the 4 inks.
The .CM5 file contains the inks from layers 1-4, the .GFX file contains the pixel data in linear fashion
Check picture has 5 layers
Check the constraints on the layers
References sgx_data::context, sgx_data::file, File_error, Get_pixel(), Open_file_write(), Open_file_write_with_alternate_ext(), Set_saving_layer(), and Write_byte().
void Test_PPH | ( | T_IO_Context * | context, |
FILE * | file | ||
) |
Amstrad CPC 'PPH' for Perfect Pix.
This is a format designed by Rhino. There are 3 modes:
References sgx_data::context, sgx_data::file, File_error, File_length_file(), sgx_data::file_size, NULL, Open_file_read_with_alternate_ext(), and Read_bytes().
|
static |
Referenced by Load_PPH().
void Load_PPH | ( | T_IO_Context * | context | ) |
References sgx_data::context, sgx_data::file, File_error, File_length_file(), sgx_data::file_size, FORMAT_PPH, sgx_data::height, mode, NULL, Open_file_read(), Open_file_read_with_alternate_ext(), T_IO_Context::Palette, PIXEL_SIMPLE, PIXEL_TALL, PIXEL_WIDE, pph_blend(), Pre_load(), T_IO_Context::Ratio, Read_byte(), Read_word_le(), Set_pixel(), and sgx_data::width.
void Save_PPH | ( | T_IO_Context * | context | ) |
Not yet implemented.
References sgx_data::context.