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/eact.h

135 lines
4.1 KiB
C

/* *****************************************************************************
* libg1m/format/eact.h -- the G1M e-activity 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_EACT_H
# define LIBG1M_FORMAT_EACT_H
# include <stdint.h>
/* E-Activities are the format CASIO uses for in-calc documents.
* It is the funniest subformat the the libg1m can parse.
*
* There is only one part for e-activities.
* The overall header has two zones:
* - the special header, that keeps the global info;
* - the setup area, that keeps one part of the calculator setup.
*
* There are several types for E-Activies, identified by the extensions
* CASIO give them.
* The E-Act version in the header is 0x10100 for g1e, 0x10200 for g2e,
* and 0x10400 for g3e. */
# define EACT_G1E 0x10100
# define EACT_G2E 0x10200
# define EACT_G3E 0x10400
/* The differences between these formats are the following:
* - On g1e, the OS version is always 0x5061636B, where on g2e/g3e,
* the OS version is the version of the OS on which the file was written.
* - On g1e/g2e, the setup directory is 0x10-bytes long, where on g3e,
* the setup directory is 0x2C-bytes long.
*
* So the main header is: */
struct eact_header {
/* the filesize */
uint32_t filesize;
/* the size of the setup area */
uint32_t setup_area_size;
/* the E-Act version */
uint32_t eact_version;
/* The OS version - only with G2E/G3E */
uint32_t os_version;
};
/* And now, the funniest part: the content.
* So a content has this header: */
struct eact_contentheader {
/* content type: @EACT, @RUNMAT, ... */
uint8_t type[8];
/* align for element name */
uint8_t align[8];
/* element name: "EACT1", "TEXT1", ... */
uint8_t name[16];
/* align for subheader */
uint8_t align2[4];
};
/* There are several types of contents.
* The most basic one is also called "@EACT".
* It has this content subheader: */
struct eact_eactheader {
/* line count */
uint32_t line_count;
};
/* And after, lines come. First of all, there is a line descriptor table,
* that contain the line type and the line offset from the subheader begin.
* A line type can have these types: */
enum eact_linetype {
/* contains a calculation */
eact_ltype_calc = 0x03,
/* contains a calculation result (right after the calculation line) */
eact_ltype_calc_result = 0x04,
/* a subcontent, with content header and everything */
eact_ltype_content = 0x06,
/* standard heading - the title surrounded by '=' */
eact_ltype_stdheading = 0x07,
/* a picture - the content is the path to the picture
* ex: '\\fls0\Pict\Pict01.g3p' (With CASIO's encoding on 16-bits) */
eact_ltype_picture = 0x08,
/* Some pure text */
eact_ltype_text = 0x81,
/* Text mixed up with functions -- described by SimLo, untested here */
eact_ltype_code = 0x82
};
/* And here's the line descriptor structure: */
struct line_descriptor {
/* the entry type */
uint8_t entry_type;
/* the entry offset */
uint32_t entry_offset :24;
};
/* And there is only one content after the main header, and it's a content
* of EACT type. But hey, why the heck have we defined several types and stuff?
* Well, that's the funniest thing of E-Activities:
*
* they are RECURSIVE. [drama alert]
*
* Which means in each node, there can be a content to parse. */
#endif /* LIBG1M_FORMAT_EACT_H */