GrafX2 2.9.3227
The ultimate 256-color painting program
|
Formats for the Commodore 64. More...
#include <stdlib.h>
#include <string.h>
#include <zlib.h>
#include "engine.h"
#include "screen.h"
#include "windows.h"
#include "input.h"
#include "help.h"
#include "fileformats.h"
#include "loadsavefuncs.h"
#include "io.h"
#include "misc.h"
#include "oldies.h"
#include "c64load.h"
#include "keycodes.h"
#include "packbits.h"
#include "gfx2mem.h"
#include "gfx2log.h"
#include "c64picview_inc.h"
Macros | |
#define | READU32LE(p) ((p)[0] | (p)[1] << 8 | (p)[2] << 16 | (p)[3] << 24) |
Enumerations | |
enum | c64_format { F_invalid = -1 , F_hires = 0 , F_multi = 1 , F_bitmap = 2 , F_fli = 3 } |
C64 file formats. More... | |
Functions | |
static long | C64_unpack_doodle (byte **file_buffer, long file_size) |
Unpack doodle/koala painter 2 data. More... | |
void | Test_C64 (T_IO_Context *context, FILE *file) |
Test for a C64 picture file. More... | |
void | Test_PRG (T_IO_Context *context, FILE *file) |
Test for a C64 auto-load machine language program which could be a picture. More... | |
static void | Load_C64_hires (T_IO_Context *context, byte *bitmap, byte *screen_ram) |
Load C64 hires (320x200) More... | |
static void | Load_C64_multi (T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *color_ram, byte background) |
Load C64 multicolor (160x200) More... | |
void | Load_C64_fli (T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) |
Loads a C64 FLI (Flexible Line Interpretation) picture. More... | |
static long | C64_unpack_get_length (const byte *buffer, long input_size, byte RLE_code, int order) |
Count the length of the unpacked data. More... | |
static void | C64_unpack (byte *unpacked, const byte *buffer, long input_size, byte RLE_code, int order) |
unpack RLE packed data More... | |
static long | C64_unpack_amica (byte **file_buffer, long file_size) |
Unpack the Amica Paint RLE packing. More... | |
static long | C64_unpack_draz (byte **file_buffer, long file_size) |
Unpack the DRAZPAINT RLE packing. More... | |
void | Load_C64 (T_IO_Context *context) |
Load C64 pictures formats. More... | |
void | Load_PRG (T_IO_Context *context) |
Load C64 autoload pictures. More... | |
static int | Save_C64_window (enum c64_format *saveFormat, byte *saveWhat, word *loadAddr) |
Display the dialog for C64 save parameters. More... | |
static int | Encode_C64_hires (T_IO_Context *context, byte *bitmap, byte *screen_ram) |
Encode a C64 HiRes Bitmap picture. More... | |
static int | Save_C64_hires (T_IO_Context *context, byte saveWhat, word loadAddr) |
Save a C64 hires picture. More... | |
int | Save_C64_fli_monolayer (T_IO_Context *context, byte saveWhat, word loadAddr) |
Save a C64 FLI (Flexible Line Interpretation) picture. More... | |
static int | Encode_C64_multicolor (T_IO_Context *context, byte *bitmap, byte *screen_ram, byte *color_ram, byte *background) |
Encode a picture in the C64 Multicolor bitmap format. More... | |
int | Save_C64_multi (T_IO_Context *context, byte saveWhat, word loadAddr) |
Save a C64 multicolor picture. More... | |
int | Save_C64_fli (T_IO_Context *context, byte saveWhat, word loadAddr) |
Save a C64 FLI (Flexible Line Interpretation) picture. More... | |
void | Save_C64 (T_IO_Context *context) |
Save C64 picture. More... | |
static int | C64_color_ram_pack (FILE *f, const byte *data, int count) |
Pack a stream of nibbles (ignore the high 4 bits) to a file. More... | |
void | Save_PRG (T_IO_Context *context) |
Save autoloading C64 picture. More... | |
void | Test_GPX (T_IO_Context *context, FILE *file) |
void | Load_GPX (T_IO_Context *context) |
Variables | |
static const char * | c64_format_names [] |
C64 file formats names. More... | |
Formats for the Commodore 64.
#define READU32LE | ( | p | ) | ((p)[0] | (p)[1] << 8 | (p)[2] << 16 | (p)[3] << 24) |
enum c64_format |
|
static |
Unpack doodle/koala painter 2 data.
References C64_unpack(), C64_unpack_get_length(), GFX2_DEBUG, GFX2_Log(), GFX2_malloc, and NULL.
Referenced by Load_C64(), and Test_C64().
|
static |
Load C64 hires (320x200)
context | the IO context |
bitmap | the bitmap RAM (8000 bytes) |
screen_ram | the screen RAM (1000 bytes) |
If screen_ram is NULL, uses default C64 basic colors
References NULL, and Set_pixel().
Referenced by Load_C64(), and Load_PRG().
|
static |
Load C64 multicolor (160x200)
context | the IO context |
bitmap | the bitmap RAM (8000 bytes) |
screen_ram | the screen RAM (1000 bytes) |
color_ram | the color RAM (1000 bytes) |
background | the background color |
References Set_pixel().
Referenced by Load_C64(), Load_GPX(), and Load_PRG().
void Load_C64_fli | ( | T_IO_Context * | context, |
byte * | bitmap, | ||
byte * | screen_ram, | ||
byte * | color_ram, | ||
byte * | background | ||
) |
Loads a C64 FLI (Flexible Line Interpretation) picture.
Sets 4 layers :
context | the IO context |
bitmap | 8000 bytes buffer |
screen_ram | 8 x 1024 bytes buffers |
color_ram | 1000 byte buffer |
background | 200 byte buffer |
References CONTEXT_MAIN_IMAGE, NULL, Set_loading_layer(), Set_pixel(), and T_IO_Context::Type.
Referenced by Load_C64(), and Load_PRG().
|
static |
Count the length of the unpacked data.
RLE encoding is either ESCAPE CODE, COUNT, VALUE or ESCAPE CODE, VALUE, COUNT
buffer | the packed data |
input_size | the packed data byte count |
RLE_code | the escape code |
order | 0 for ESCAPE, COUNT, VALUE, 1 for ESCAPE, VALUE, COUNT |
Referenced by C64_unpack_amica(), C64_unpack_doodle(), and C64_unpack_draz().
|
static |
unpack RLE packed data
RLE encoding is either ESCAPE CODE, COUNT, VALUE or ESCAPE CODE, VALUE, COUNT
unpacked | buffer to received unpacked data |
buffer | the packed data |
input_size | the packed data byte count |
RLE_code | the escape code |
order | 0 for ESCAPE, COUNT, VALUE, 1 for ESCAPE, VALUE, COUNT |
Referenced by C64_unpack_amica(), C64_unpack_doodle(), and C64_unpack_draz().
|
static |
Unpack the Amica Paint RLE packing.
[in,out] | file_buffer | will contain the unpacked buffer on return |
[in] | file_size | packed buffer size |
Ref:
References C64_unpack(), C64_unpack_get_length(), GFX2_DEBUG, GFX2_Log(), GFX2_malloc, and NULL.
Referenced by Load_C64().
|
static |
Unpack the DRAZPAINT RLE packing.
[in,out] | file_buffer | will contain the unpacked buffer on return |
[in] | file_size | packed buffer size |
Ref:
References C64_unpack(), C64_unpack_get_length(), GFX2_DEBUG, GFX2_Log(), GFX2_malloc, and NULL.
Referenced by Load_C64().
|
static |
Display the dialog for C64 save parameters.
[in,out] | saveFormat | one of the C64 mode from c64_format |
[in,out] | saveWhat | 0=All, 1=Only bitmap, 2=Only Screen RAM, 3=Only color RAM |
[in,out] | loadAddr | actual load address or 0 for "None" |
References BUTTON_HELP, BUTTON_SAVE, c64_format_names, Close_window(), Display_cursor(), F_bitmap, F_fli, F_hires, F_multi, format, GFX2_DEBUG, GFX2_Log(), Is_shortcut(), Key, KEY_ESCAPE, KEY_RETURN, LEFT_SIDE, MC_Dark, MC_Light, Open_window(), Print_in_window(), Update_window_area, Window_attribute2, Window_clicked_button(), Window_dropdown_add_item(), Window_dropdown_clear_items(), Window_height, Window_help(), Window_set_dropdown_button(), Window_set_normal_button(), and Window_width.
Referenced by Save_C64().
|
static |
Encode a C64 HiRes Bitmap picture.
320x200 pixels, with only 2 different colors per 8x8 block.
8000 bytes bitmap, 1000 bytes screen RAM
References c64state::bitmap, Get_pixel(), Warning_message(), and Warning_with_format().
Referenced by Save_C64_hires(), and Save_PRG().
|
static |
Save a C64 hires picture.
c64 hires is 320x200 with only 2 colors per 8x8 block.
References c64state::bitmap, Encode_C64_hires(), File_error, Open_file_write(), Warning_message(), Write_bytes(), and Write_word_le().
Referenced by Save_C64().
int Save_C64_fli_monolayer | ( | T_IO_Context * | context, |
byte | saveWhat, | ||
word | loadAddr | ||
) |
Save a C64 FLI (Flexible Line Interpretation) picture.
This function is able to save a one layer picture, by finding itself the background colors and color RAM value to be used.
The algorithm is :
The algorithm can fail by picking a "wrong" background color for a line, that make the choice for the color RAM value of one of the 40 blocks impossible.
context | the IO context |
saveWhat | what part of the data to save |
loadAddr | The load address |
References c64state::bitmap, C64_pixels_to_FLI(), File_error, Open_file_write(), T_IO_Context::Pitch, T_IO_Context::Target_address, Warning_message(), Write_bytes(), and Write_word_le().
Referenced by Save_C64().
|
static |
Encode a picture in the C64 Multicolor bitmap format.
8000 bytes bitmap, 1000 bytes screen RAM and 1000 bytes color RAM :
BITS COLOR INFORMATION COMES FROM 00 Background color #0 (screen color) 01 Upper 4 bits of Screen RAM 10 Lower 4 bits of Screen RAM 11 Color RAM nybble (nybble = 1/2 byte = 4 bits)
References c64state::bitmap, Get_pixel(), GFX2_DEBUG, GFX2_Log(), Warning_message(), and Warning_with_format().
Referenced by Save_C64_multi(), and Save_PRG().
int Save_C64_multi | ( | T_IO_Context * | context, |
byte | saveWhat, | ||
word | loadAddr | ||
) |
Save a C64 multicolor picture.
context | the IO context |
saveWhat | what part of the data to save |
loadAddr | The load address |
References c64state::bitmap, Encode_C64_multicolor(), File_error, NULL, Open_file_write(), Warning_message(), Write_byte(), Write_bytes(), and Write_word_le().
Referenced by Save_C64().
int Save_C64_fli | ( | T_IO_Context * | context, |
byte | saveWhat, | ||
word | loadAddr | ||
) |
Save a C64 FLI (Flexible Line Interpretation) picture.
This function need a 3 layer image :
context | the IO context |
saveWhat | what part of the data to save |
loadAddr | The load address |
References C64_FLI(), File_error, Open_file_write(), Warning_message(), Write_bytes(), and Write_word_le().
Referenced by Save_C64().
|
static |
Pack a stream of nibbles (ignore the high 4 bits) to a file.
This is designed to pack the color RAM data for VIC-II, as the color RAM is only 4 bits.
The output format is a stream of bytes of the following format : CD C = (16 - count), D = DATA (4bits)
References Write_byte().
Referenced by Save_PRG().
|
static |
C64 file formats names.
Referenced by Load_C64(), and Save_C64_window().