cake
/
libg1m
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/include/libg1m/format/caspro.h

80 lines
2.9 KiB
C

/* *****************************************************************************
* libg1m/format/caspro.h -- the newer 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_CASPRO_H
# define LIBG1M_FORMAT_CASPRO_H
# include <stdint.h>
# pragma pack(1)
/* This is the later CASIOLINK format. It is more or less a raw dump of the
* communications protocol the 9850 uses. It is basically an MCS file.
*
* A CASIOLINK-encoded file is made of one header and one or more parts.
* Each element is preceded by a 0x3A, and is a packet in the communications
* protocol interpretation. */
/* ************************************************************************** */
/* Header (first element) */
/* ************************************************************************** */
/* The header is the following: */
struct caspro_header {
/* types */
uint8_t type[4];
uint8_t data[3];
/* data length */
uint8_t used; /* 0x00 if is reset/unused, 0x01 if used */
uint16_t length; /* for a variable: same value as in `used` */
uint8_t name[8];
/* variable-related data */
uint8_t prefix[8]; /* "Variable" for vars, 0xFFs otherwise */
uint8_t aux[8]; /* variable: "R\x0A"/"C\x0A", editor: password */
/* something else (?) */
uint8_t nl[2]; /* 'NL' */
uint8_t _ffs[11];
/* end of packet */
uint8_t checksum;
};
/* ************************************************************************** */
/* Variable/number */
/* ************************************************************************** */
/* Variable has the following structure (described in a comment):
*
* uint8_t magic[4];
* Four bytes, always {0x00, 0x01, 0x00, 0x01} for a variable;
* cas_bcd_t real;
* The real part of the variable.
*
* If the real part has the complex flag enabled, then the following is there:
*
* cas_bcd_t imgn;
* The imaginary part of the variable.
*
* Then finally, everytime:
*
* uint8_t checksum;
* The checksum (calculated as for the header). */
/* TODO: other file formats */
# pragma pack()
#endif /* LIBG1M_FORMAT_CASPRO_H */