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

222 lines
8.7 KiB
C

/* *****************************************************************************
* libg1m/mcs.h -- libg1m main memory header.
* 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_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
# define g1m_ans 29
/* ************************************************************************** */
/* Main Memory types and platforms */
/* ************************************************************************** */
/* MCS file type */
# define PRIuMCSTYPE "lu"
# define PRIxMCSTYPE "lx"
# define PRIXMCSTYPE "lX"
typedef long unsigned int g1m_mcsfile_type_t;
typedef g1m_mcsfile_type_t g1m_mcstype_t;
/* MCS file types */
# define g1m_mcstype_unknown 0x00000000
# define g1m_mcstype_program 0x00000001
# define g1m_mcstype_list 0x00000002
# define g1m_mcstype_mat 0x00000004
# define g1m_mcstype_pict 0x00000008
# define g1m_mcstype_capt 0x00000010
# define g1m_mcstype_ssheet 0x00000020
# define g1m_mcstype_string 0x00000040
# define g1m_mcstype_setup 0x00000080
# define g1m_mcstype_var 0x00000100
# define g1m_mcstype_vct 0x00000200
# define g1m_mcstype_end 0x00000400
/* MCS file type aliases */
# define g1m_mcstype_matrix g1m_mcstype_mat
# define g1m_mcstype_pic g1m_mcstype_pict
# define g1m_mcstype_picture g1m_mcstype_pict
# define g1m_mcstype_capture g1m_mcstype_capt
# define g1m_mcstype_spreadsheet g1m_mcstype_ssheet
# define g1m_mcstype_vector g1m_mcstype_vct
# define g1m_mcstype_alpha g1m_mcstype_var
# define g1m_mcstype_alphamem g1m_mcstype_var
# define g1m_mcstype_variable g1m_mcstype_var
# define g1m_mcstype_variables g1m_mcstype_var
/* MCS file platform */
typedef unsigned int g1m_mcsinfo_t;
# define g1m_mcsinfo_none 0x0000
# define g1m_mcsinfo_mcs 0x0001
# define g1m_mcsinfo_cas40 0x0002
# define g1m_mcsinfo_cas g1m_mcsinfo_cas40
# define g1m_mcsinfo_cas50 0x0004
# define g1m_mcsinfo_caspro g1m_mcsinfo_cas50
# define g1m_mcsinfo_cas100 0x0008
# define g1m_mcsinfo_graph100 g1m_mcsinfo_cas100
/* Macros to check if the type uses the ID, and to interact with it */
# define g1m_mcshead_uses_id(H) (((H)->g1m_mcshead_type & (\
g1m_mcstype_list | g1m_mcstype_mat | g1m_mcstype_vct | \
g1m_mcstype_pict | g1m_mcstype_capt | g1m_mcstype_string) || \
((H)->g1m_mcshead_type == g1m_mcstype_var && \
(H)->g1m_mcshead_count == 1)))
# define g1m_get_id_major(I) ((I) >> 6)
# define g1m_get_id_minor(I) ((I) & 0x3F)
/* ************************************************************************** */
/* List, Matrix, Vector, Spreadsheet Cell */
/* ************************************************************************** */
/* Flags */
# define g1m_mcscellflag_used 0x0001
/* Main structure */
typedef struct g1m_mcscell_s {
unsigned int g1m_mcscell_flags;
g1m_bcd_t g1m_mcscell_real;
g1m_bcd_t g1m_mcscell_imgn;
} g1m_mcscell_t;
/* ************************************************************************** */
/* Setup */
/* ************************************************************************** */
/* Input flags */
# define g1m_setupiflag_shift 0x0001 /* SHIFT is pressed */
# define g1m_setupiflag_alpha 0x0002 /* ALPHA is pressed */
# define g1m_setupiflag_insert 0x0004 /* Insert/overwrite mode */
# define g1m_setupiflag_math 0x0008 /* Math input mode instead of linear */
/* Window flags */
# define g1m_setupwflag_grid 0x0001 /* Grid */
# define g1m_setupwflag_axes 0x0002 /* Axes */
# define g1m_setupwflag_plot 0x0004 /* Draw Plot Type instead of Con */
# define g1m_setupwflag_coord 0x0010 /* Coord */
# define g1m_setupwflag_sigma 0x0020 /* Sigma Display */
# define g1m_setupwflag_stat 0x0040 /* Stat Window */
# define g1m_setupwflag_graph 0x0080 /* Graph Function */
# define g1m_setupwflag_simul 0x0100 /* Simul Graph */
# define g1m_setupwflag_slope 0x0200 /* Slope */
/* Miscallenous flags */
# define g1m_setupmflag_deriv 0x0001 /* Derivative */
# define g1m_setupmflag_label 0x0002 /* label */
# define g1m_setupmflag_date360 0x0004 /* 360 Date Mode, instead of 365 */
# define g1m_setupmflag_complex 0x0008 /* Complex answer instead of real */
# define g1m_setupmflag_simp 0x0010 /* Auto Simplify (not Manual) */
# define g1m_setupmflag_dynamic 0x0020 /* Continue Dynamic Type (not Stop) */
# define g1m_setupmflag_payment 0x0040 /* Begin Payment (not End) */
# define g1m_setupmflag_autocalc 0x0080 /* Auto Calc */
# define g1m_setupmflag_cformula 0x0100 /* Show Cell Formula (not Value) */
# define g1m_setupmflag_dpfix 0x1000 /* Display Fix instead of Sci */
# define g1m_setupmflag_dpnorm 0x2000 /* Display Norm */
# define g1m_setupmflag_dpemode 0x4000 /* Toggle /E-mode */
/* More complex values */
# define g1m_setupval_number 0 /* 0 being comp, 2,8,10,16 being the base */
# define g1m_setupval_function 1 /* -> 0x18 */
# define g1m_setupval_listfile 2 /* List File 1-6, 0 being none */
# define g1m_setupval_bg 3 /* Background picture ID, 0 being none */
# define g1m_setupval_dispid 4 /* Display ID, see dpfix/dpnorm/dpemode */
# define g1m_setupval_residlist 5 /* Resid List */
/* Function types */
# define g1m_functype_yequ 0x00 /* Y= */
# define g1m_functype_requ 0x01 /* r= */
# define g1m_functype_param 0x02 /* Param */
# define g1m_functype_xequc 0x03 /* X=c */
# define g1m_functype_ygt 0x04 /* Y> */
# define g1m_functype_ylt 0x05 /* Y< */
# define g1m_functype_yge 0x06 /* Y>= */
# define g1m_functype_yle 0x07 /* Y<= */
/* Main structure */
# define g1m_setup_vals_count 6
typedef struct g1m_setup_s {
unsigned int g1m_setup_iflags;
unsigned int g1m_setup_wflags;
unsigned int g1m_setup_mflags;
unsigned char g1m_setup_vals[g1m_setup_vals_count];
} g1m_setup_t;
/* ************************************************************************** */
/* Main structures */
/* ************************************************************************** */
/* mcs file special flags */
# define g1m_mcsflag_unfinished 0x8000 /* is there still parts to read? */
# define g1m_mcsflag_multiple 0x4000 /* is a group */
# define g1m_mcsflag_request 0x2000 /* is a request */
/* mcs file content flags */
# define g1m_mcsflag_complex 0x0001 /* is a complex variable */
/* mcs file head */
typedef struct g1m_mcshead_s {
/* file main information */
g1m_mcstype_t g1m_mcshead_type;
g1m_mcsinfo_t g1m_mcshead_info;
unsigned int g1m_mcshead_flags;
unsigned int g1m_mcshead_id;
/* content size */
int g1m_mcshead_count;
unsigned int g1m_mcshead_width;
unsigned int g1m_mcshead_height;
uint_fast32_t g1m_mcshead_size;
/* raw data */
unsigned int g1m_mcshead_rawtype;
g1m_pictureformat_t g1m_mcshead_picformat;
/* strings */
char g1m_mcshead_name[13];
char g1m_mcshead_password[9];
/* raw string data */
unsigned char g1m_mcshead_group[17];
unsigned char g1m_mcshead_dirname[9];
unsigned char g1m_mcshead_appname[4];
unsigned char g1m_mcshead_datatype[3];
} g1m_mcshead_t;
/* mcs file */
# define g1m_has_password(F) \
(F)->g1m_mcsfile_head.g1m_mcshead_password[0]
# define g1m_remove_password(F) \
(F)->g1m_mcsfile_head.g1m_mcshead_password[0] = 0
typedef struct g1m_mcsfile_s {
/* head */
g1m_mcshead_t g1m_mcsfile_head;
/* content (useful when not read) */
char *g1m_mcsfile_content;
/* variables */
g1m_mcscell_t g1m_mcsfile_var;
g1m_mcscell_t *g1m_mcsfile_vars;
g1m_mcscell_t **g1m_mcsfile_cells;
/* for pictures and captures */
uint32_t **g1m_mcsfile_pic; /* 0x0RGB */
uint32_t ***g1m_mcsfile_pics;
/* for settings */
g1m_setup_t g1m_mcsfile_setup;
} g1m_mcsfile_t;
#endif /* LIBG1M_MCS_H */