96 lines
3.2 KiB
C
96 lines
3.2 KiB
C
/* *****************************************************************************
|
|
* libg1m/format/cas.h -- the CAS file format description.
|
|
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libg1m.
|
|
* libg1m is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 3.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* libg1m is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See the GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with libg1m; if not, see <http://www.gnu.org/licenses/>.
|
|
* ************************************************************************** */
|
|
#ifndef LIBG1M_FORMAT_CAS_H
|
|
# define LIBG1M_FORMAT_CAS_H
|
|
# include <libg1m.h>
|
|
# include <stdint.h>
|
|
# pragma pack(1)
|
|
|
|
/* The CASIOLINK format looks a lot like the legacy communication protocol,
|
|
* but the two are to distinguish. A CASIOLINK-encoded file is basically
|
|
* a set of one or more MCS files of the same type.
|
|
*
|
|
* The file has two parts, each starting with a 0x3A (':').
|
|
* It starts with a header: */
|
|
|
|
struct casiolink_header {
|
|
uint8_t data[2];
|
|
uint8_t _specific[5]; /* type-specific subheader */
|
|
uint8_t filename[12]; /* unused chars are filled with 0xFFs. */
|
|
uint8_t _unused[19]; /* 0xFFs. */
|
|
uint8_t checksum;
|
|
};
|
|
|
|
/* For a program, the specific bytes are the following: */
|
|
|
|
# define casiolink_program_uk0 0x01 /* <unknown> */
|
|
# define casiolink_program_stats 0x02 /* store stats data */
|
|
# define casiolink_program_matrix 0x04 /* matrix mode */
|
|
# define casiolink_program_uk1 0x08 /* <unknown */
|
|
# define casiolink_program_stddev 0x10 /* standard deviation mode */
|
|
# define casiolink_program_linreg 0x20 /* linear regression mode */
|
|
# define casiolink_program_basen 0x40 /* base-n mode */
|
|
# define casiolink_program_drawst 0x80 /* draw stats graph */
|
|
|
|
struct casiolink_spe_program {
|
|
uint8_t _unknown;
|
|
uint16_t length;
|
|
uint8_t flags;
|
|
uint8_t _unknown2;
|
|
};
|
|
|
|
/* The specific bytes are the same for a set of programs, but `flags` is
|
|
* not used, and the length is the size of all of the programs put together.
|
|
*
|
|
* Now, here are the specific bytes for a screenshot: */
|
|
|
|
struct casiolink_spe_screenshot {
|
|
uint8_t height;
|
|
uint8_t width;
|
|
uint8_t _unused[3];
|
|
};
|
|
|
|
/* The specific bytes for a number start with either "RA" or "CA", 'R' or 'C'
|
|
* meaning the number is complex or not. */
|
|
|
|
/* This should be put somewhere else, as it represents the packets in
|
|
* a legacy protocol communication. (FIXME: maybe the new CAS header?) */
|
|
|
|
struct casiolink_new_header {
|
|
/* types */
|
|
uint8_t type[4];
|
|
uint8_t data[4];
|
|
|
|
/* data length */
|
|
uint16_t length;
|
|
uint8_t name[8];
|
|
|
|
/* variable-related data */
|
|
uint8_t prefix[8]; /* "Variable"? */
|
|
uint8_t real; /* 'R' for real, 'C' for complex */
|
|
uint8_t magic; /* 0x0A */
|
|
|
|
/* alignment */
|
|
uint8_t _ffs[21];
|
|
uint8_t checksum;
|
|
};
|
|
|
|
# pragma pack()
|
|
#endif /* LIBG1M_FORMAT_CAS_H */
|