Sort of added CAS capture decoding.
This commit is contained in:
parent
24f971bc93
commit
4913619f7d
|
@ -59,9 +59,7 @@ typedef unsigned int g1m_platform_t;
|
|||
/* ************************************************************************** */
|
||||
/* Version */
|
||||
typedef struct g1m_version_s {
|
||||
int major;
|
||||
int minor;
|
||||
int revision;
|
||||
int major, minor, revision;
|
||||
} g1m_version_t;
|
||||
/* ************************************************************************** */
|
||||
/* Handle structure */
|
||||
|
|
|
@ -156,6 +156,7 @@ G1M_CASFUNC(var)
|
|||
G1M_CASFUNC(program)
|
||||
G1M_CASHFUNC(program)
|
||||
G1M_CASFUNC(matrix)
|
||||
G1M_CASFUNC(capture)
|
||||
/* ************************************************************************** */
|
||||
/* Picture utilities */
|
||||
/* ************************************************************************** */
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#ifndef LIBG1M_MCS_H
|
||||
# define LIBG1M_MCS_H
|
||||
# include <libg1m/bcd.h>
|
||||
# include <libg1m/picture.h>
|
||||
# include <inttypes.h>
|
||||
# define g1m_theta 27
|
||||
# define g1m_r 28
|
||||
|
@ -113,6 +114,7 @@ typedef struct g1m_mcshead_s {
|
|||
/* cas-related raw data */
|
||||
unsigned char _appname[4];
|
||||
unsigned char _datatype[3];
|
||||
g1m_pictureformat_t _picformat;
|
||||
|
||||
/* the program password */
|
||||
char password[9];
|
||||
|
|
|
@ -38,10 +38,10 @@ typedef int g1m_pictureformat_t;
|
|||
((W) * (H) / 8)
|
||||
# define g1m_picturesize_1bit_reverse(W, H) \
|
||||
g1m_picturesize_1bit_packed(W, H)
|
||||
# define g1m_picturesize_1bit_color(W, H) \
|
||||
# define g1m_picturesize_4bit_color(W, H) \
|
||||
(4 * g1m_picturesize_1bit_reverse(W, H))
|
||||
# define g1m_picturesize_1bit_mono(W, H) \
|
||||
g1m_picturesize_1bit_color(W, H)
|
||||
# define g1m_picturesize_4bit_mono(W, H) \
|
||||
g1m_picturesize_4bit_color(W, H)
|
||||
|
||||
# define g1m_picturesize_2bit_dual(W, H) \
|
||||
(((W) * (H) / 4) * 2)
|
||||
|
|
|
@ -49,6 +49,7 @@ static struct cas_corresp cas_types[] = {
|
|||
{g1m_mcstype_program, FUNC(program), HFUNC(program)},
|
||||
{g1m_mcstype_matrix, FUNC(matrix), NULL},
|
||||
{g1m_mcstype_list, FUNC(matrix), NULL},
|
||||
{g1m_mcstype_capture, FUNC(capture), NULL},
|
||||
TTERM
|
||||
};
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
* ************************************************************************** */
|
||||
#include <libg1m/internals.h>
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* MCS files */
|
||||
/* ************************************************************************** */
|
||||
/**
|
||||
* g1m_decode_mcs_capture:
|
||||
* Decode a capture.
|
||||
|
@ -99,3 +102,32 @@ int g1m_decode_mcs_picture(g1m_mcsfile_t **handle, g1m_buffer_t *buffer,
|
|||
/* no error */
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* CAS files */
|
||||
/* ************************************************************************** */
|
||||
/**
|
||||
* g1m_decode_caspart_capture:
|
||||
* Decode a CAS picture.
|
||||
*
|
||||
* @arg handle the handle to contribute to.
|
||||
* @arg buffer the buffer to read from.
|
||||
* @return the error code (0 if ok).
|
||||
*/
|
||||
|
||||
int g1m_decode_caspart_capture(g1m_mcsfile_t *handle, g1m_buffer_t *buffer)
|
||||
{
|
||||
/* read the picture data */
|
||||
unsigned int width = handle->head.width, height = handle->head.height;
|
||||
size_t pic_size = g1m_picturesize_4bit_color(width, height);
|
||||
uint8_t pic_data[pic_size]; READ(pic_data, pic_size)
|
||||
|
||||
/* decode the picture data */
|
||||
int err = g1m_decode_picture(handle->pics[0], handle->head._picformat,
|
||||
pic_data, width, height);
|
||||
if (err) { g1m_free_mcsfile(handle); return (err); }
|
||||
|
||||
/* no error */
|
||||
handle->head.flags &= ~g1m_mcsflag_unfinished;
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ struct type_corresp {
|
|||
/* libg1m MCS file type, flags */
|
||||
g1m_mcstype_t type;
|
||||
unsigned int flags;
|
||||
g1m_pictureformat_t picformat;
|
||||
};
|
||||
|
||||
/* ************************************************************************** */
|
||||
|
@ -38,47 +39,48 @@ struct type_corresp {
|
|||
* - Correspondances with a NULL data type means the data type isn't to be
|
||||
* read. */
|
||||
|
||||
#define TTERM {NULL, 0, 0}
|
||||
#define UNIMPLEMENTED(S) {S, 0, 0, 0}
|
||||
#define TTERM {NULL, 0, 0, 0}
|
||||
static struct type_corresp cas_groups[] = {
|
||||
/* implemented */
|
||||
{"LT", g1m_mcstype_list, 0}, // list
|
||||
{"MT", g1m_mcstype_matrix, 0}, // matrix
|
||||
{"P1", g1m_mcstype_program, 0}, // one program
|
||||
{"PG", g1m_mcstype_program, 0}, // same than above
|
||||
{"PZ", g1m_mcstype_program, g1m_mcsflag_multiple}, // set of programs
|
||||
{"VM", g1m_mcstype_variable, 0}, // one variable
|
||||
{"LT", g1m_mcstype_list, 0, 0},
|
||||
{"MT", g1m_mcstype_matrix, 0, 0},
|
||||
{"P1", g1m_mcstype_program, 0, 0},
|
||||
{"PG", g1m_mcstype_program, 0, 0},
|
||||
{"PZ", g1m_mcstype_program, g1m_mcsflag_multiple, 0},
|
||||
{"VM", g1m_mcstype_variable, 0, 0},
|
||||
{"DC", g1m_mcstype_capture, 0, g1m_pictureformat_4bit_color},
|
||||
{"DD", g1m_mcstype_capture, 0, g1m_pictureformat_4bit_mono},
|
||||
|
||||
/* not implemented yet */
|
||||
{"AA", 0, 0}, // dynamic graph functions
|
||||
{"AD", 0, 0}, // variable memory
|
||||
{"AL", 0, 0}, // all
|
||||
{"AM", 0, 0}, // alpha variable memory
|
||||
{"BU", 0, 0}, // backup
|
||||
{"DM", 0, 0}, // defined memory
|
||||
{"DC", 0, 0}, // color screenshot
|
||||
{"DD", 0, 0}, // monochrome screenshot
|
||||
{"EN", 0, 0}, // one editor file
|
||||
{"FN", 0, 0}, // set of editor files
|
||||
{"FT", 0, 0}, // ??? (cafix)
|
||||
{"F1", 0, 0}, // one function memory
|
||||
{"F6", 0, 0}, // set of function memories
|
||||
{"GA", 0, 0}, // set of graph functions
|
||||
{"GF", 0, 0}, // graph zoom factor (graph function?)
|
||||
{"GM", 0, 0}, // gmem (cafix)
|
||||
{"GR", 0, 0}, // graph range
|
||||
{"GT", 0, 0}, // function table
|
||||
{"MA", 0, 0}, // set of matrices
|
||||
{"PC", 0, 0}, // picture from 9xxx (cafix)
|
||||
{"PD", 0, 0}, // polynomial equations
|
||||
{"RF", 0, 0}, // ??? (cafix)
|
||||
{"RR", 0, 0}, // ??? (cafix)
|
||||
{"RT", 0, 0}, // recursion table
|
||||
{"SD", 0, 0}, // simultaneous equations
|
||||
{"SE", 0, 0}, // equation (cafix)
|
||||
{"SR", 0, 0}, // linear regression data
|
||||
{"SS", 0, 0}, // standard deviation data
|
||||
{"TR", 0, 0}, // ??? (cafix)
|
||||
{"WD", 0, 0}, // window data (cafix)
|
||||
UNIMPLEMENTED("AA"), // dynamic graph functions
|
||||
UNIMPLEMENTED("AD"), // variable memory
|
||||
UNIMPLEMENTED("AL"), // all
|
||||
UNIMPLEMENTED("AM"), // alpha variable memory
|
||||
UNIMPLEMENTED("BU"), // backup
|
||||
UNIMPLEMENTED("DM"), // defined memory
|
||||
UNIMPLEMENTED("EN"), // one editor file
|
||||
UNIMPLEMENTED("FN"), // set of editor files
|
||||
UNIMPLEMENTED("FT"), // ??? (cafix)
|
||||
UNIMPLEMENTED("F1"), // one function memory
|
||||
UNIMPLEMENTED("F6"), // set of function memories
|
||||
UNIMPLEMENTED("GA"), // set of graph functions
|
||||
UNIMPLEMENTED("GF"), // graph zoom factor (graph function?)
|
||||
UNIMPLEMENTED("GM"), // gmem (cafix)
|
||||
UNIMPLEMENTED("GR"), // graph range
|
||||
UNIMPLEMENTED("GT"), // function table
|
||||
UNIMPLEMENTED("MA"), // set of matrices
|
||||
UNIMPLEMENTED("PC"), // picture from 9xxx (cafix)
|
||||
UNIMPLEMENTED("PD"), // polynomial equations
|
||||
UNIMPLEMENTED("RF"), // ??? (cafix)
|
||||
UNIMPLEMENTED("RR"), // ??? (cafix)
|
||||
UNIMPLEMENTED("RT"), // recursion table
|
||||
UNIMPLEMENTED("SD"), // simultaneous equations
|
||||
UNIMPLEMENTED("SE"), // equation (cafix)
|
||||
UNIMPLEMENTED("SR"), // linear regression data
|
||||
UNIMPLEMENTED("SS"), // standard deviation data
|
||||
UNIMPLEMENTED("TR"), // ??? (cafix)
|
||||
UNIMPLEMENTED("WD"), // window data (cafix)
|
||||
|
||||
/* terminating entry */
|
||||
TTERM
|
||||
|
@ -115,6 +117,7 @@ int g1m_maketype_cas(g1m_mcshead_t *head, const char *datatype)
|
|||
|
||||
/* fill in info and return */
|
||||
head->type = c->type;
|
||||
head->_picformat = c->picformat;
|
||||
head->flags |= c->flags;
|
||||
return (0);
|
||||
|
||||
|
|
Reference in New Issue