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

213 lines
8.3 KiB
C

/* *****************************************************************************
* libg1m/format/mcsfile.h -- description of the MCS subfiles formats.
* 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_MCSFILE_H
# define LIBG1M_FORMAT_MCSFILE_H
# include <libg1m/format/mcs.h>
# pragma pack(1)
/* ************************************************************************** */
/* Programs */
/* ************************************************************************** */
/* Programs have a simple header: */
struct mcs_programheader {
/* the program password. not encrypted, anything */
uint8_t password[8];
/* and some alignment. */
uint8_t align[2];
};
/* Then comes their content, multi-byte FONTCHARACTER encoded. */
/* ************************************************************************** */
/* Setup */
/* ************************************************************************** */
/* Setup files have no headers, they are just a bunch of bytes you can copy.
* Legacy fx setup files have 100 entries (100 bytes), fx-CG setup files
* have twice as much (even though the first 100 entries have the same
* signification in the two).
*
* Known settings are:
* [0x13] Angle (0x00: degrees, 0x01: radians, 0x02: gradians);
* [0x14] SHIFT/Alpha status (0x00: both off, 0x01: shift only on,
* 0x04: alpha only on, 0x84: both on);
* [0x15] Insert/Overwrite status (0x01: overwrite, 0x02: insert);
* [0x17] Number mode (0x00: Comp, 0x01: Bin, 0x07: Oct, 0x09: Dec, 0x0F: Hex);
* [0x18] Function type (0x00: Y=, 0x01: r=, 0x02: Param, 0x03: X=c,
* 0x04: Y>, 0x05: Y<, 0x06: Y>=, 0x07: Y<=);
* [0x19] Draw type (0x00: Con, 0x01: Plot);
* [0x1A] Derivative;
* [0x1B] Coord;
* [0x1C] Grid;
* [0x1D] Axes;
* [0x1E] Label;
* [0x20] Stat Wind (0x00: Auto, 0x01: Manual);
* [0x21] Graph Func;
* [0x22] Dual Screen (0x03: OFF);
* [0x24] Dynamic Type (0x00: Cont, 0x01: Stop);
* [0x25] SigmaDisplay;
* [0x26] Slope;
* [0x27] Payment (0x00: Bgn, 0x01: End);
* [0x28] Date Mode (0x00: 365, 0x01: 360);
* [0x29] Answer Type (0x00: Real, 0x01: Complex);
* [0x2A] Complex Mode (0x00: Real, 0x01: a+bi, 0x02: r<T);
* [0x2B] Display (0x00: Norm1, 0x10: Norm2, 0x20-0x29: Fix[0-9],
* 0x30-0x39: Sci[0-9] -- bit 0x80 toggles /E mode);
* [0x2C] Background (0x00: None, 0x01-0x14: Pict[1-20]);
* [0x2D] Resid List (0x00: None, 0x01-0x1A: List[1-26]);
* [0x2E] List File (0x01-0x06: File[1-6]);
* [0x2F] Variable (0x00: Range, 0x01-0x26: List[1-26]);
* [0x31] Recur Dual (Dual Screen) (0x00: T+G, 0x01: OFF);
* [0x4E] Auto Calc;
* [0x4F] Show Sell (Show cell) (0x00: Formula, 0x01: Value);
* [0x50] Move (0x00: Lower, 0x01: Right);
* [0x51] Sub Name (0x00: ON, 0x01: OFF);
* [0x53] Input Mode (0x00: Math, 0x01: Linear);
* [0x54] Locus;
* [0x55] Y=Draw Speed (0x00: Norm, 0x01: High);
* [0x56] Sketch Line (0x00: Norm, 0x01: Thick, 0x02: Broken, 0x03: Dot);
* [0x57] Frac Result (0x00: d/c, 0x01: a+b/c);
* [0x5C] Q1Q3 Type (0x00: Std, 0x01: OnD [STAT]);
* [0x5D] Ineq Type (0x00: Intersect (And), 0x01: Union (Or) [GRAPH]);
* [0x5E] Periods/Yr. (0x00: Annu, 0x01: Semi [TVM]);
* [0x5F] Simplify (0x00: Auto, 0x01: Manual);
*
* When options aren't given, it's 0x00 for ON, and 0x01 for OFF. */
/* ************************************************************************** */
/* Spreadsheets */
/* ************************************************************************** */
/* Spreadsheets are more complicated than that.
*
* For normal ones, there is a header: */
struct mcs_spreadsheetheader {
/* has subheader: 0x01 if yes */
uint8_t has_subheader;
/* column count (max: 26), on 24 bits and non-aligned */
uint32_t column_count : 24;
};
/* Then, if it is a normal spreadsheet, there is a subheader,
* a column directory and a column definition table.
*
* Here's the subheader: */
struct mcs_spreadsheet_subheader {
/* alignment or magic? {0, 0, 0, 0} */
uint8_t align[4];
/* number of column definitions */
uint32_t defs_size;
/* alignment or magic II? {0, 0, 0, 0} */
uint8_t align2[4];
};
/* The column definition table is the main definition. It contains the row
* directory, which is a 80-bytes long bitfield indicating if cells are empty
* or not, and the list of non-empty cells.
*
* Each cell is a BCD structure (the real part of the number). Numbers in
* spreadsheets can't have imaginary parts.
*
* The column directory is just a list of 4-bytes sizes of each column,
* counting the row directory and the cells. It's easier to naviguate to
* a column quicker. */
/* ************************************************************************** */
/* Captures */
/* ************************************************************************** */
/* Captures start with a simple header: */
struct mcs_captureheader {
/* the width (0x80) */
uint16_t width;
/* the height (0x40) */
uint16_t height;
};
/* Then the image follows (0x400 for a 0x80*0x40px image).
* A picture is the same that an capture, but without the header and containing
* two 128x64 images (0x800 bytes). */
/* ************************************************************************** */
/* Pictures */
/* ************************************************************************** */
/* Pictures don't have any header: it's just two 128x64 images (packed 1-bit)
* and that's all. */
/* ************************************************************************** */
/* Lists */
/* ************************************************************************** */
/* Lists start with a header: */
struct mcs_listheader {
/* probably the title */
uint8_t title[8];
/* the elements count */
uint16_t element_count;
/* undocumented (always 0?) */
uint8_t undocumented[5];
/* undocumented (either 0x00 or 0x4F) */
uint8_t undocumented2;
};
/* Then there is the list of real parts of the elements.
* If the complex bit is present on at least one of the elements (highest bit
* of the first nibble, which is the highest nibble of the exponent), then it
* is followed by the list of the imaginary parts of the elements.
*
* If the imaginary parts is here, only read the imaginary part of an element
* if his highest bit is set: it might contain complete crap! */
/* ************************************************************************** */
/* Matrixes and vectors */
/* ************************************************************************** */
/* Matrixes and vectors have exactly the same format; it's just that the OS
* refuses to have more that one row for vectors.
*
* They have this simple header: */
struct mcs_matheader {
/* undocumented */
uint8_t undocumented[8];
/* height */
uint16_t height;
/* width */
uint16_t width;
/* re-undocumented */
uint8_t undocumented2[4];
};
/* Then we have width*height BCD cells, which corresponds to the real parts,
* grouped by height.
*
* If at least one of the cells has an imaginary part (highest bit of the
* first nibble set), it is followed by a list of the imaginary parts, that
* has the same size that the real parts list, that is grouped the same way and
* that contains actual things (and not crap) only if the complex bit is set
* on the real part. */
# pragma pack()
#endif /* LIBG1M_FORMAT_MCSFILE_H */